From 85839a4c43588c5e80cc631a9296578a6dd84c96 Mon Sep 17 00:00:00 2001 From: Hesaam Farhang Date: Fri, 5 Jan 2018 17:00:05 -0800 Subject: [PATCH] move kz_types type declarations to its own module (#4462) tab -> space actually use the module instead of re-typing move time related types to kz_time move term related types to kz_term remove kz_ prefix script to convert kz_types the great types convert use builtin timeout type don't clash with node forgot to change kz_time + sed being stupid, converting manually maunallt fixing proplist_kv don't ever mess with node again more maunal changes fix rebase artifacts adding kz_types to list of beam files to make dialyzer happy make fmt sed + arity regex and kz_node fix the script rename function to get_server_ref to not collide with type regex hardcode types that have to be handle run the script again --- applications/acdc/src/acdc.hrl | 2 +- applications/acdc/src/acdc_agent_fsm.erl | 174 ++--- applications/acdc/src/acdc_agent_handler.erl | 42 +- applications/acdc/src/acdc_agent_listener.erl | 152 ++-- .../acdc/src/acdc_agent_maintenance.erl | 8 +- applications/acdc/src/acdc_agent_manager.erl | 8 +- applications/acdc/src/acdc_agent_stats.erl | 34 +- applications/acdc/src/acdc_agent_sup.erl | 16 +- applications/acdc/src/acdc_agent_util.erl | 50 +- applications/acdc/src/acdc_agents_sup.erl | 26 +- applications/acdc/src/acdc_announcements.erl | 16 +- .../acdc/src/acdc_announcements_sup.erl | 6 +- applications/acdc/src/acdc_app.erl | 2 +- applications/acdc/src/acdc_eavesdrop.erl | 2 +- applications/acdc/src/acdc_handlers.erl | 16 +- applications/acdc/src/acdc_init.erl | 16 +- applications/acdc/src/acdc_listener.erl | 10 +- applications/acdc/src/acdc_maintenance.erl | 68 +- applications/acdc/src/acdc_queue_fsm.erl | 66 +- applications/acdc/src/acdc_queue_handler.erl | 18 +- applications/acdc/src/acdc_queue_listener.erl | 52 +- applications/acdc/src/acdc_queue_manager.erl | 80 +- applications/acdc/src/acdc_queue_manager.hrl | 14 +- applications/acdc/src/acdc_queue_shared.erl | 14 +- applications/acdc/src/acdc_queue_sup.erl | 8 +- applications/acdc/src/acdc_queue_thief.erl | 2 +- .../acdc/src/acdc_queue_worker_sup.erl | 14 +- .../acdc/src/acdc_queue_workers_sup.erl | 10 +- applications/acdc/src/acdc_queues_sup.erl | 16 +- applications/acdc/src/acdc_recordings_sup.erl | 6 +- applications/acdc/src/acdc_stats.erl | 86 +-- applications/acdc/src/acdc_stats.hrl | 54 +- applications/acdc/src/acdc_stats_etsmgr.erl | 12 +- applications/acdc/src/acdc_stats_sup.erl | 4 +- applications/acdc/src/acdc_stats_util.erl | 10 +- applications/acdc/src/acdc_sup.erl | 4 +- applications/acdc/src/acdc_util.erl | 30 +- applications/acdc/src/cb_acdc_call_stats.erl | 4 +- applications/acdc/src/cb_agents.erl | 26 +- applications/acdc/src/cb_queues.erl | 26 +- applications/acdc/src/cf_acdc_agent.erl | 18 +- applications/acdc/src/cf_acdc_member.erl | 16 +- applications/acdc/src/cf_acdc_queue.erl | 2 +- applications/acdc/src/kapi_acdc_agent.erl | 114 +-- applications/acdc/src/kapi_acdc_queue.erl | 168 ++--- applications/acdc/src/kapi_acdc_stats.erl | 180 ++--- applications/ananke/src/ananke_app.erl | 2 +- applications/ananke/src/ananke_listener.erl | 24 +- applications/ananke/src/ananke_sup.erl | 4 +- applications/ananke/src/ananke_tasks_sup.erl | 6 +- .../src/tasks/ananke_callback_worker.erl | 10 +- .../ananke/src/tasks/ananke_vm_callback.erl | 30 +- applications/blackhole/src/bh_context.erl | 60 +- applications/blackhole/src/bh_events.erl | 8 +- applications/blackhole/src/blackhole.hrl | 28 +- applications/blackhole/src/blackhole_app.erl | 2 +- .../blackhole/src/blackhole_bindings.erl | 36 +- .../blackhole/src/blackhole_config.erl | 6 +- .../blackhole/src/blackhole_data_emitter.erl | 4 +- applications/blackhole/src/blackhole_init.erl | 8 +- .../blackhole/src/blackhole_listener.erl | 28 +- .../blackhole/src/blackhole_maintenance.erl | 10 +- .../src/blackhole_socket_handler.erl | 4 +- applications/blackhole/src/blackhole_sup.erl | 4 +- .../blackhole/src/blackhole_tracking.erl | 18 +- .../blackhole/src/modules/bh_conference.erl | 4 +- applications/blackhole/src/modules/bh_fax.erl | 8 +- .../blackhole/src/modules/bh_object.erl | 2 +- .../blackhole/src/modules/bh_skel.erl | 2 +- .../src/analyzers/ci_analysis.erl | 20 +- .../src/analyzers/ci_analyzers.erl | 2 +- .../src/analyzers/ci_analyzers_sup.erl | 4 +- .../call_inspector/src/call_inspector_app.erl | 2 +- .../src/call_inspector_maintenance.erl | 14 +- .../call_inspector/src/call_inspector_sup.erl | 4 +- .../call_inspector/src/ci_datastore.erl | 22 +- .../call_inspector/src/ci_filter_req.erl | 2 +- .../call_inspector/src/ci_listener.erl | 10 +- .../call_inspector/src/ci_lookup_req.erl | 2 +- .../call_inspector/src/parsers/ci_chunk.erl | 74 +- .../src/parsers/ci_parser_freeswitch.erl | 46 +- .../src/parsers/ci_parser_hep.erl | 14 +- .../src/parsers/ci_parser_kamailio.erl | 46 +- .../src/parsers/ci_parsers_sup.erl | 4 +- .../src/parsers/ci_parsers_util.erl | 20 +- applications/callflow/src/callflow_app.erl | 2 +- .../callflow/src/callflow_maintenance.erl | 44 +- applications/callflow/src/callflow_sup.erl | 4 +- .../callflow/src/cf_event_handler_sup.erl | 10 +- applications/callflow/src/cf_exe.erl | 74 +- applications/callflow/src/cf_exe_sup.erl | 8 +- applications/callflow/src/cf_flow.erl | 34 +- applications/callflow/src/cf_listener.erl | 10 +- applications/callflow/src/cf_route_req.erl | 28 +- applications/callflow/src/cf_route_resume.erl | 2 +- applications/callflow/src/cf_route_win.erl | 28 +- .../callflow/src/cf_shared_listener.erl | 10 +- .../callflow/src/cf_singular_call_hooks.erl | 8 +- .../src/cf_singular_call_hooks_listener.erl | 4 +- applications/callflow/src/cf_task.erl | 14 +- applications/callflow/src/cf_util.erl | 130 ++-- .../callflow/src/module/cf_after_bridge.erl | 2 +- .../src/module/cf_branch_variable.erl | 12 +- .../callflow/src/module/cf_call_forward.erl | 18 +- .../callflow/src/module/cf_call_waiting.erl | 10 +- .../src/module/cf_camping_feature.erl | 12 +- .../callflow/src/module/cf_check_cid.erl | 8 +- .../callflow/src/module/cf_cidlistmatch.erl | 12 +- .../callflow/src/module/cf_collect_dtmf.erl | 6 +- .../callflow/src/module/cf_directory.erl | 36 +- applications/callflow/src/module/cf_disa.erl | 12 +- .../callflow/src/module/cf_do_not_disturb.erl | 14 +- .../callflow/src/module/cf_dynamic_cid.erl | 44 +- .../callflow/src/module/cf_eavesdrop.erl | 16 +- .../src/module/cf_eavesdrop_feature.erl | 18 +- .../callflow/src/module/cf_faxbox.erl | 4 +- .../callflow/src/module/cf_flush_dtmf.erl | 2 +- applications/callflow/src/module/cf_group.erl | 6 +- .../callflow/src/module/cf_group_pickup.erl | 42 +- .../src/module/cf_group_pickup_feature.erl | 12 +- .../callflow/src/module/cf_hotdesk.erl | 24 +- .../callflow/src/module/cf_intercept.erl | 34 +- .../src/module/cf_intercept_feature.erl | 26 +- .../callflow/src/module/cf_lookupcidname.erl | 28 +- .../src/module/cf_manual_presence.erl | 2 +- applications/callflow/src/module/cf_menu.erl | 46 +- .../src/module/cf_missed_call_alert.erl | 14 +- applications/callflow/src/module/cf_move.erl | 2 +- .../callflow/src/module/cf_nomorobo.erl | 18 +- .../callflow/src/module/cf_page_group.erl | 8 +- applications/callflow/src/module/cf_park.erl | 98 +-- applications/callflow/src/module/cf_play.erl | 2 +- .../callflow/src/module/cf_prepend_cid.erl | 4 +- .../callflow/src/module/cf_privacy.erl | 4 +- .../callflow/src/module/cf_record_call.erl | 4 +- .../callflow/src/module/cf_record_caller.erl | 4 +- .../callflow/src/module/cf_resources.erl | 52 +- .../callflow/src/module/cf_ring_group.erl | 26 +- .../src/module/cf_ring_group_toggle.erl | 2 +- .../callflow/src/module/cf_route_to_cid.erl | 4 +- .../callflow/src/module/cf_set_cid.erl | 4 +- .../callflow/src/module/cf_set_variable.erl | 6 +- applications/callflow/src/module/cf_sleep.erl | 2 +- .../callflow/src/module/cf_temporal_route.erl | 24 +- .../callflow/src/module/cf_temporal_route.hrl | 34 +- applications/callflow/src/module/cf_user.erl | 2 +- .../callflow/src/module/cf_voicemail.erl | 142 ++-- applications/camper/src/camper_app.erl | 2 +- applications/camper/src/camper_init.erl | 2 +- .../camper/src/camper_offnet_handler.erl | 28 +- applications/camper/src/camper_offnet_sup.erl | 6 +- .../camper/src/camper_onnet_handler.erl | 32 +- .../camper/src/camper_request_listener.erl | 10 +- applications/camper/src/camper_sup.erl | 4 +- applications/cccp/src/cb_cccps.erl | 12 +- applications/cccp/src/cccp.hrl | 26 +- applications/cccp/src/cccp_app.erl | 2 +- .../cccp/src/cccp_callback_listener.erl | 22 +- applications/cccp/src/cccp_callback_sup.erl | 6 +- applications/cccp/src/cccp_handlers.erl | 8 +- applications/cccp/src/cccp_listener.erl | 12 +- .../cccp/src/cccp_platform_listener.erl | 12 +- applications/cccp/src/cccp_platform_sup.erl | 6 +- .../cccp/src/cccp_shared_listener.erl | 12 +- applications/cccp/src/cccp_sup.erl | 4 +- applications/cccp/src/cccp_util.erl | 50 +- applications/cdr/src/cdr.hrl | 4 +- applications/cdr/src/cdr_app.erl | 2 +- applications/cdr/src/cdr_channel_destroy.erl | 24 +- applications/cdr/src/cdr_listener.erl | 18 +- applications/cdr/src/cdr_sup.erl | 4 +- applications/cdr/src/cdr_util.erl | 8 +- applications/cdr/src/csv_util.erl | 2 +- .../conference/src/conf_authn_req.erl | 4 +- .../conference/src/conf_config_req.erl | 44 +- .../conference/src/conf_discovery_req.erl | 12 +- .../conference/src/conf_participant.erl | 38 +- .../conference/src/conf_participant_req.erl | 2 +- .../conference/src/conf_participant_sup.erl | 6 +- .../conference/src/conf_pronounced_name.erl | 22 +- .../conference/src/conf_route_req.erl | 10 +- .../conference/src/conference_app.erl | 2 +- .../conference/src/conference_listener.erl | 10 +- .../conference/src/conference_maintenance.erl | 2 +- .../src/conference_shared_listener.erl | 10 +- .../conference/src/conference_sup.erl | 4 +- .../conference/src/kapi_conf_participant.erl | 6 +- .../port-request-scheduled-schema.escript | 2 +- applications/crossbar/src/api_resource.erl | 74 +- applications/crossbar/src/api_util.erl | 84 +-- .../crossbar/src/cb_apps_maintenance.erl | 6 +- applications/crossbar/src/cb_apps_util.erl | 38 +- applications/crossbar/src/cb_context.erl | 150 ++-- .../crossbar/src/cb_devices_utils.erl | 8 +- .../crossbar/src/cb_mobile_manager.erl | 4 +- applications/crossbar/src/crossbar.hrl | 48 +- applications/crossbar/src/crossbar_app.erl | 2 +- applications/crossbar/src/crossbar_auth.erl | 50 +- .../crossbar/src/crossbar_bindings.erl | 26 +- applications/crossbar/src/crossbar_config.erl | 10 +- .../crossbar/src/crossbar_default_handler.erl | 2 +- applications/crossbar/src/crossbar_doc.erl | 100 +-- applications/crossbar/src/crossbar_filter.erl | 20 +- .../crossbar/src/crossbar_freeswitch.erl | 52 +- applications/crossbar/src/crossbar_init.erl | 20 +- .../crossbar/src/crossbar_maintenance.erl | 110 +-- .../crossbar/src/crossbar_module_sup.erl | 8 +- .../crossbar/src/crossbar_services.erl | 10 +- applications/crossbar/src/crossbar_sup.erl | 4 +- applications/crossbar/src/crossbar_types.hrl | 24 +- applications/crossbar/src/crossbar_util.erl | 128 ++-- applications/crossbar/src/crossbar_view.erl | 58 +- .../crossbar/src/modules/cb_accounts.erl | 134 ++-- .../crossbar/src/modules/cb_alerts.erl | 4 +- .../crossbar/src/modules/cb_allotments.erl | 12 +- .../crossbar/src/modules/cb_api_auth.erl | 4 +- .../crossbar/src/modules/cb_apps_link.erl | 2 +- .../crossbar/src/modules/cb_apps_store.erl | 30 +- applications/crossbar/src/modules/cb_auth.erl | 20 +- .../crossbar/src/modules/cb_basic_auth.erl | 10 +- .../crossbar/src/modules/cb_blacklists.erl | 12 +- .../crossbar/src/modules/cb_braintree.erl | 8 +- applications/crossbar/src/modules/cb_bulk.erl | 24 +- .../src/modules/cb_call_inspector.erl | 12 +- .../crossbar/src/modules/cb_callflows.erl | 48 +- applications/crossbar/src/modules/cb_cdrs.erl | 24 +- .../crossbar/src/modules/cb_channels.erl | 46 +- .../crossbar/src/modules/cb_clicktocall.erl | 52 +- .../crossbar/src/modules/cb_comments.erl | 16 +- .../crossbar/src/modules/cb_conferences.erl | 68 +- .../crossbar/src/modules/cb_configs.erl | 6 +- .../crossbar/src/modules/cb_connectivity.erl | 12 +- .../crossbar/src/modules/cb_dialplans.erl | 4 +- .../crossbar/src/modules/cb_directories.erl | 22 +- .../crossbar/src/modules/cb_faxboxes.erl | 46 +- .../crossbar/src/modules/cb_faxes.erl | 52 +- .../crossbar/src/modules/cb_freeswitch.erl | 4 +- .../cb_global_provisioner_templates.erl | 14 +- .../crossbar/src/modules/cb_groups.erl | 8 +- .../crossbar/src/modules/cb_hotdesks.erl | 8 +- .../crossbar/src/modules/cb_ip_auth.erl | 2 +- applications/crossbar/src/modules/cb_ips.erl | 30 +- .../crossbar/src/modules/cb_jobs_listener.erl | 36 +- .../crossbar/src/modules/cb_ledgers.erl | 18 +- .../cb_local_provisioner_templates.erl | 6 +- .../src/modules/cb_local_resources.erl | 26 +- .../crossbar/src/modules/cb_media.erl | 74 +- .../crossbar/src/modules/cb_menus.erl | 8 +- .../crossbar/src/modules/cb_metaflows.erl | 14 +- .../crossbar/src/modules/cb_migrations.erl | 2 +- .../crossbar/src/modules/cb_modules_util.erl | 68 +- .../crossbar/src/modules/cb_multi_factor.erl | 10 +- .../crossbar/src/modules/cb_notifications.erl | 128 ++-- .../crossbar/src/modules/cb_onboard.erl | 38 +- .../crossbar/src/modules/cb_pivot.erl | 6 +- .../crossbar/src/modules/cb_port_requests.erl | 94 +-- .../crossbar/src/modules/cb_presence.erl | 38 +- .../crossbar/src/modules/cb_profile.erl | 4 +- .../crossbar/src/modules/cb_quickcall.erl | 2 +- .../crossbar/src/modules/cb_rate_limits.erl | 16 +- .../crossbar/src/modules/cb_rates.erl | 42 +- .../crossbar/src/modules/cb_recordings.erl | 24 +- .../crossbar/src/modules/cb_registrations.erl | 8 +- .../src/modules/cb_resource_selectors.erl | 10 +- .../src/modules/cb_resource_templates.erl | 6 +- .../crossbar/src/modules/cb_resources.erl | 22 +- .../crossbar/src/modules/cb_schemas.erl | 8 +- .../crossbar/src/modules/cb_search.erl | 34 +- .../crossbar/src/modules/cb_security.erl | 16 +- .../crossbar/src/modules/cb_service_plans.erl | 16 +- .../crossbar/src/modules/cb_shared_auth.erl | 8 +- .../crossbar/src/modules/cb_skels.erl | 8 +- applications/crossbar/src/modules/cb_sms.erl | 12 +- .../crossbar/src/modules/cb_storage.erl | 18 +- applications/crossbar/src/modules/cb_sup.erl | 4 +- .../src/modules/cb_system_configs.erl | 14 +- .../crossbar/src/modules/cb_tasks.erl | 28 +- .../crossbar/src/modules/cb_templates.erl | 16 +- .../src/modules/cb_temporal_rules.erl | 8 +- .../src/modules/cb_temporal_rules_sets.erl | 8 +- .../crossbar/src/modules/cb_token_auth.erl | 16 +- .../src/modules/cb_token_restrictions.erl | 36 +- .../crossbar/src/modules/cb_transactions.erl | 10 +- .../crossbar/src/modules/cb_ubiquiti_auth.erl | 4 +- .../crossbar/src/modules/cb_ubiquiti_util.erl | 14 +- .../crossbar/src/modules/cb_user_auth.erl | 38 +- .../crossbar/src/modules/cb_vmboxes.erl | 80 +- .../crossbar/src/modules/cb_webhooks.erl | 42 +- .../crossbar/src/modules/cb_websockets.erl | 4 +- .../crossbar/src/modules/cb_whitelabel.erl | 72 +- .../src/modules/notification_util.erl | 2 +- .../src/modules/provisioner_contact_list.erl | 14 +- .../crossbar/src/modules/provisioner_util.erl | 40 +- .../crossbar/src/modules/provisioner_v5.erl | 54 +- .../crossbar/src/modules_v1/cb_devices_v1.erl | 52 +- .../crossbar/src/modules_v1/cb_lists_v1.erl | 14 +- .../src/modules_v1/cb_phone_numbers_v1.erl | 16 +- .../crossbar/src/modules_v1/cb_users_v1.erl | 50 +- .../crossbar/src/modules_v2/cb_devices_v2.erl | 74 +- .../crossbar/src/modules_v2/cb_lists_v2.erl | 12 +- .../src/modules_v2/cb_phone_numbers_v2.erl | 40 +- .../crossbar/src/modules_v2/cb_users_v2.erl | 44 +- applications/doodle/src/doodle.hrl | 2 +- applications/doodle/src/doodle_api.erl | 12 +- applications/doodle/src/doodle_app.erl | 2 +- .../doodle/src/doodle_delivery_handler.erl | 4 +- .../doodle/src/doodle_doc_handler.erl | 4 +- .../doodle/src/doodle_event_handler_sup.erl | 8 +- applications/doodle/src/doodle_exe.erl | 48 +- applications/doodle/src/doodle_exe_sup.erl | 8 +- .../doodle/src/doodle_inbound_handler.erl | 20 +- .../doodle/src/doodle_inbound_listener.erl | 10 +- .../src/doodle_inbound_listener_sup.erl | 8 +- applications/doodle/src/doodle_listener.erl | 10 +- .../doodle/src/doodle_maintenance.erl | 32 +- .../doodle/src/doodle_notify_handler.erl | 6 +- applications/doodle/src/doodle_route_req.erl | 12 +- applications/doodle/src/doodle_route_win.erl | 10 +- .../doodle/src/doodle_shared_listener.erl | 10 +- applications/doodle/src/doodle_sup.erl | 4 +- applications/doodle/src/doodle_util.erl | 86 +-- .../doodle/src/module/cf_sms_device.erl | 6 +- .../doodle/src/module/cf_sms_resources.erl | 34 +- .../doodle/src/module/cf_sms_user.erl | 4 +- applications/dth/src/dth.erl | 4 +- applications/dth/src/dth_api.erl | 12 +- applications/dth/src/dth_app.erl | 2 +- applications/dth/src/dth_blacklist_req.erl | 2 +- applications/dth/src/dth_cdr_handler.erl | 4 +- applications/dth/src/dth_listener.erl | 8 +- applications/dth/src/dth_sup.erl | 4 +- applications/ecallmgr/src/ecallmgr.hrl | 104 +-- applications/ecallmgr/src/ecallmgr_app.erl | 4 +- .../ecallmgr/src/ecallmgr_auxiliary_sup.erl | 4 +- .../src/ecallmgr_balance_crawler_statem.erl | 14 +- .../src/ecallmgr_balance_crawler_worker.erl | 14 +- .../ecallmgr/src/ecallmgr_call_command.erl | 238 +++--- .../ecallmgr/src/ecallmgr_call_control.erl | 120 +-- .../src/ecallmgr_call_control_sup.erl | 8 +- .../ecallmgr/src/ecallmgr_call_event_sup.erl | 6 +- .../ecallmgr/src/ecallmgr_call_events.erl | 142 ++-- .../ecallmgr/src/ecallmgr_call_sup.erl | 12 +- .../ecallmgr/src/ecallmgr_channel_move.erl | 14 +- .../src/ecallmgr_channel_redirect.erl | 12 +- .../src/ecallmgr_conference_command.erl | 18 +- .../src/ecallmgr_conference_control.erl | 16 +- .../ecallmgr/src/ecallmgr_conference_sup.erl | 8 +- applications/ecallmgr/src/ecallmgr_config.erl | 32 +- applications/ecallmgr/src/ecallmgr_events.erl | 10 +- .../ecallmgr/src/ecallmgr_fs_authn.erl | 38 +- .../ecallmgr/src/ecallmgr_fs_authz.erl | 46 +- .../ecallmgr/src/ecallmgr_fs_bridge.erl | 70 +- .../ecallmgr/src/ecallmgr_fs_channel.erl | 114 +-- .../ecallmgr/src/ecallmgr_fs_channel_hold.erl | 18 +- .../ecallmgr/src/ecallmgr_fs_channels.erl | 68 +- .../ecallmgr/src/ecallmgr_fs_command.erl | 20 +- .../ecallmgr/src/ecallmgr_fs_conference.erl | 24 +- .../ecallmgr/src/ecallmgr_fs_conferences.erl | 64 +- .../src/ecallmgr_fs_conferences_shared.erl | 62 +- .../ecallmgr/src/ecallmgr_fs_config.erl | 34 +- .../ecallmgr/src/ecallmgr_fs_event_stream.erl | 32 +- .../src/ecallmgr_fs_event_stream_sup.erl | 10 +- applications/ecallmgr/src/ecallmgr_fs_fax.erl | 2 +- .../ecallmgr/src/ecallmgr_fs_flite.erl | 6 +- .../ecallmgr/src/ecallmgr_fs_loopback.erl | 14 +- applications/ecallmgr/src/ecallmgr_fs_msg.erl | 52 +- .../ecallmgr/src/ecallmgr_fs_node.erl | 72 +- .../ecallmgr/src/ecallmgr_fs_node_command.erl | 16 +- .../ecallmgr/src/ecallmgr_fs_node_sup.erl | 38 +- .../ecallmgr/src/ecallmgr_fs_nodes.erl | 68 +- .../ecallmgr/src/ecallmgr_fs_notify.erl | 34 +- .../ecallmgr/src/ecallmgr_fs_pinger.erl | 12 +- .../ecallmgr/src/ecallmgr_fs_pinger_sup.erl | 8 +- .../ecallmgr/src/ecallmgr_fs_presence.erl | 52 +- .../ecallmgr/src/ecallmgr_fs_recordings.erl | 32 +- .../ecallmgr/src/ecallmgr_fs_resource.erl | 16 +- .../ecallmgr/src/ecallmgr_fs_route.erl | 20 +- .../ecallmgr/src/ecallmgr_fs_route_sup.erl | 6 +- .../ecallmgr/src/ecallmgr_fs_router_call.erl | 24 +- .../ecallmgr/src/ecallmgr_fs_router_text.erl | 30 +- .../ecallmgr/src/ecallmgr_fs_router_util.erl | 32 +- applications/ecallmgr/src/ecallmgr_fs_sup.erl | 8 +- applications/ecallmgr/src/ecallmgr_fs_xml.erl | 150 ++-- .../ecallmgr/src/ecallmgr_maintenance.erl | 110 +-- .../ecallmgr/src/ecallmgr_originate.erl | 94 +-- .../ecallmgr/src/ecallmgr_originate_sup.erl | 6 +- .../ecallmgr/src/ecallmgr_registrar.erl | 156 ++-- applications/ecallmgr/src/ecallmgr_sup.erl | 4 +- applications/ecallmgr/src/ecallmgr_util.erl | 226 +++--- applications/ecallmgr/src/freeswitch.erl | 10 +- applications/ecallmgr/src/mod_kazoo.erl | 10 +- applications/fax/src/fax.hrl | 6 +- applications/fax/src/fax_app.erl | 2 +- applications/fax/src/fax_cloud.erl | 50 +- applications/fax/src/fax_init.erl | 2 +- applications/fax/src/fax_jobs.erl | 32 +- applications/fax/src/fax_jobs_sup.erl | 6 +- applications/fax/src/fax_maintenance.erl | 46 +- applications/fax/src/fax_monitor.erl | 14 +- applications/fax/src/fax_request.erl | 62 +- applications/fax/src/fax_requests_sup.erl | 8 +- applications/fax/src/fax_shared_listener.erl | 8 +- applications/fax/src/fax_smtp.erl | 82 +- applications/fax/src/fax_sup.erl | 4 +- applications/fax/src/fax_util.erl | 40 +- applications/fax/src/fax_worker.erl | 116 +-- applications/fax/src/fax_worker_sup.erl | 4 +- applications/fax/src/fax_xmpp.erl | 36 +- applications/fax/src/fax_xmpp_sup.erl | 6 +- applications/fax/src/kapi_xmpp.erl | 20 +- applications/frontier/src/cb_access_lists.erl | 8 +- .../frontier/src/frontier_handle_acl.erl | 18 +- .../frontier/src/frontier_handle_rate.erl | 44 +- .../frontier/src/frontier_maintenance.erl | 8 +- .../frontier/src/frontier_shared_listener.erl | 10 +- applications/frontier/src/frontier_sup.erl | 4 +- applications/frontier/src/frontier_utils.erl | 8 +- applications/frontier/src/kapi_frontier.erl | 32 +- applications/hangups/src/hangups_app.erl | 2 +- .../hangups/src/hangups_channel_destroy.erl | 30 +- applications/hangups/src/hangups_config.erl | 4 +- applications/hangups/src/hangups_listener.erl | 10 +- .../hangups/src/hangups_maintenance.erl | 46 +- .../hangups/src/hangups_monitoring.erl | 20 +- .../hangups/src/hangups_query_listener.erl | 24 +- applications/hangups/src/hangups_sup.erl | 4 +- applications/hangups/src/hangups_util.erl | 16 +- applications/hotornot/src/hon_rater.erl | 18 +- applications/hotornot/src/hon_trie.erl | 34 +- applications/hotornot/src/hon_trie_lru.erl | 22 +- applications/hotornot/src/hon_tries_sup.erl | 10 +- applications/hotornot/src/hon_util.erl | 34 +- applications/hotornot/src/hotornot.hrl | 4 +- applications/hotornot/src/hotornot_app.erl | 2 +- applications/hotornot/src/hotornot_config.erl | 14 +- .../hotornot/src/hotornot_listener.erl | 10 +- .../hotornot/src/hotornot_maintenance.erl | 14 +- applications/hotornot/src/hotornot_sup.erl | 4 +- .../hotornot/test/hon_trie_lru_pqc.erl | 2 +- applications/jonny5/src/j5_allotments.erl | 18 +- applications/jonny5/src/j5_authz_req.erl | 24 +- .../jonny5/src/j5_balance_check_req.erl | 4 +- .../jonny5/src/j5_channel_destroy.erl | 2 +- applications/jonny5/src/j5_channels.erl | 88 +-- applications/jonny5/src/j5_flat_rate.erl | 6 +- applications/jonny5/src/j5_limits.erl | 44 +- applications/jonny5/src/j5_request.erl | 114 +-- applications/jonny5/src/j5_util.erl | 8 +- applications/jonny5/src/jonny5_app.erl | 2 +- applications/jonny5/src/jonny5_listener.erl | 10 +- .../jonny5/src/jonny5_maintenance.erl | 18 +- applications/jonny5/src/jonny5_sup.erl | 4 +- applications/konami/src/kapi_konami.erl | 24 +- applications/konami/src/konami_app.erl | 2 +- applications/konami/src/konami_code_exe.erl | 4 +- .../konami/src/konami_code_statem.erl | 58 +- applications/konami/src/konami_config.erl | 20 +- .../konami/src/konami_event_listener.erl | 66 +- applications/konami/src/konami_listener.erl | 24 +- .../konami/src/konami_maintenance.erl | 10 +- applications/konami/src/konami_sup.erl | 4 +- applications/konami/src/konami_util.erl | 6 +- .../konami/src/module/konami_break.erl | 4 +- .../konami/src/module/konami_hangup.erl | 4 +- .../konami/src/module/konami_hold.erl | 6 +- .../konami/src/module/konami_intercept.erl | 18 +- .../konami/src/module/konami_move.erl | 18 +- .../konami/src/module/konami_play.erl | 16 +- .../konami/src/module/konami_record_call.erl | 18 +- .../konami/src/module/konami_resume.erl | 4 +- .../konami/src/module/konami_transfer.erl | 100 +-- applications/media_mgr/src/media_listener.erl | 14 +- applications/media_mgr/src/media_mgr_app.erl | 2 +- .../media_mgr/src/media_mgr_maintenance.erl | 6 +- applications/media_mgr/src/media_mgr_sup.erl | 4 +- applications/milliwatt/src/milliwatt_app.erl | 2 +- .../milliwatt/src/milliwatt_listener.erl | 10 +- .../milliwatt/src/milliwatt_route_req.erl | 10 +- applications/milliwatt/src/milliwatt_sup.erl | 4 +- applications/notify/src/notify.hrl | 2 +- applications/notify/src/notify_app.erl | 2 +- .../notify/src/notify_cnam_request.erl | 6 +- applications/notify/src/notify_deregister.erl | 6 +- .../src/notify_fax_inbound_error_to_email.erl | 6 +- .../src/notify_fax_inbound_to_email.erl | 6 +- .../notify_fax_outbound_error_to_email.erl | 6 +- .../src/notify_fax_outbound_to_email.erl | 8 +- applications/notify/src/notify_fax_util.erl | 28 +- .../notify/src/notify_first_occurrence.erl | 6 +- applications/notify/src/notify_listener.erl | 10 +- .../notify/src/notify_low_balance.erl | 16 +- .../notify/src/notify_maintenance.erl | 34 +- .../notify/src/notify_new_account.erl | 6 +- .../notify/src/notify_password_recovery.erl | 6 +- .../notify/src/notify_port_cancel.erl | 18 +- .../notify/src/notify_port_request.erl | 32 +- applications/notify/src/notify_ported.erl | 8 +- applications/notify/src/notify_sup.erl | 4 +- .../notify/src/notify_system_alert.erl | 10 +- applications/notify/src/notify_topup.erl | 8 +- .../notify/src/notify_transaction.erl | 10 +- applications/notify/src/notify_util.erl | 46 +- .../notify/src/notify_voicemail_full.erl | 16 +- .../notify/src/notify_voicemail_to_email.erl | 26 +- .../omnipresence/src/kapi_omnipresence.erl | 22 +- .../omnipresence/src/omnip_subscriptions.erl | 28 +- applications/omnipresence/src/omnip_util.erl | 8 +- .../omnipresence/src/omnipresence.hrl | 38 +- .../omnipresence/src/omnipresence_app.erl | 2 +- .../src/omnipresence_listener.erl | 14 +- .../src/omnipresence_maintenance.erl | 24 +- .../src/omnipresence_shared_listener.erl | 12 +- .../omnipresence/src/omnipresence_sup.erl | 6 +- applications/pivot/src/pivot_app.erl | 2 +- applications/pivot/src/pivot_call.erl | 66 +- applications/pivot/src/pivot_calls_sup.erl | 6 +- applications/pivot/src/pivot_handlers.erl | 2 +- applications/pivot/src/pivot_listener.erl | 4 +- applications/pivot/src/pivot_sup.erl | 4 +- applications/pusher/src/kapi_pusher.erl | 30 +- applications/pusher/src/modules/pm_apple.erl | 18 +- applications/pusher/src/modules/pm_google.erl | 16 +- applications/pusher/src/pusher_app.erl | 2 +- applications/pusher/src/pusher_listener.erl | 30 +- applications/pusher/src/pusher_module_sup.erl | 4 +- applications/pusher/src/pusher_sup.erl | 4 +- applications/pusher/src/pusher_util.erl | 6 +- applications/registrar/src/reg.hrl | 38 +- applications/registrar/src/reg_authn_req.erl | 58 +- applications/registrar/src/reg_route_req.erl | 8 +- applications/registrar/src/registrar_app.erl | 2 +- applications/registrar/src/registrar_init.erl | 2 +- .../registrar/src/registrar_maintenance.erl | 4 +- .../src/registrar_shared_listener.erl | 10 +- .../src/registrar_shared_listener_sup.erl | 6 +- applications/registrar/src/registrar_sup.erl | 4 +- applications/reorder/src/reorder_app.erl | 2 +- applications/reorder/src/reorder_listener.erl | 10 +- .../reorder/src/reorder_route_req.erl | 22 +- applications/reorder/src/reorder_sup.erl | 4 +- applications/skel/src/skel_app.erl | 2 +- applications/skel/src/skel_handlers.erl | 4 +- applications/skel/src/skel_listener.erl | 10 +- applications/skel/src/skel_sup.erl | 4 +- applications/spyvsspy/src/spyvsspy_app.erl | 2 +- .../spyvsspy/src/spyvsspy_handlers.erl | 22 +- .../spyvsspy/src/spyvsspy_listener.erl | 10 +- applications/spyvsspy/src/spyvsspy_sup.erl | 4 +- applications/stats/src/stats_app.erl | 2 +- applications/stats/src/stats_handler.erl | 16 +- applications/stats/src/stats_listener.erl | 10 +- applications/stats/src/stats_sup.erl | 4 +- applications/stepswitch/src/kz_srs_util.erl | 18 +- .../resource_selectors/kz_srs_filter_list.erl | 6 +- .../kz_srs_filter_prefix.erl | 6 +- .../kz_srs_filter_regex.erl | 16 +- .../kz_srs_get_resources.erl | 6 +- .../src/resource_selectors/kz_srs_null.erl | 2 +- .../src/resource_selectors/kz_srs_order.erl | 8 +- .../stepswitch/src/stepswitch_app.erl | 2 +- .../stepswitch/src/stepswitch_authn_req.erl | 4 +- .../stepswitch/src/stepswitch_bridge.erl | 64 +- .../stepswitch/src/stepswitch_cnam.erl | 42 +- .../src/stepswitch_cnam_pool_sup.erl | 4 +- .../stepswitch/src/stepswitch_inbound.erl | 14 +- .../stepswitch/src/stepswitch_listener.erl | 8 +- .../src/stepswitch_local_extension.erl | 38 +- .../stepswitch/src/stepswitch_local_sms.erl | 14 +- .../stepswitch/src/stepswitch_maintenance.erl | 24 +- .../stepswitch/src/stepswitch_originate.erl | 28 +- .../stepswitch/src/stepswitch_outbound.erl | 24 +- .../stepswitch/src/stepswitch_request_sup.erl | 16 +- .../src/stepswitch_resource_selectors.erl | 10 +- .../stepswitch/src/stepswitch_resources.erl | 228 +++--- .../stepswitch/src/stepswitch_sms.erl | 74 +- .../stepswitch/src/stepswitch_sup.erl | 4 +- .../stepswitch/src/stepswitch_util.erl | 54 +- applications/sysconf/src/sysconf_acls.erl | 24 +- applications/sysconf/src/sysconf_app.erl | 2 +- applications/sysconf/src/sysconf_flush.erl | 2 +- applications/sysconf/src/sysconf_gateways.erl | 2 +- applications/sysconf/src/sysconf_get.erl | 6 +- applications/sysconf/src/sysconf_listener.erl | 10 +- applications/sysconf/src/sysconf_set.erl | 2 +- applications/sysconf/src/sysconf_sup.erl | 4 +- applications/tasks/src/knm_number_crawler.erl | 10 +- .../tasks/src/knm_port_request_crawler.erl | 8 +- applications/tasks/src/kz_account_crawler.erl | 18 +- applications/tasks/src/kz_notify_resend.erl | 22 +- applications/tasks/src/kz_service_sync.erl | 24 +- applications/tasks/src/kz_tasks_help.erl | 14 +- applications/tasks/src/kz_tasks_scheduler.erl | 10 +- applications/tasks/src/kz_tasks_trigger.erl | 20 +- applications/tasks/src/modules/kt_cleanup.erl | 6 +- .../tasks/src/modules/kt_compactor.erl | 44 +- .../tasks/src/modules/kt_compactor_worker.erl | 48 +- .../src/modules/kt_initial_occurrence.erl | 14 +- .../tasks/src/modules/kt_low_balance.erl | 4 +- applications/tasks/src/modules/kt_modb.erl | 2 +- applications/tasks/src/modules/kt_numbers.erl | 56 +- .../tasks/src/modules/kt_port_requests.erl | 12 +- applications/tasks/src/modules/kt_rates.erl | 36 +- .../src/modules/kt_resource_selectors.erl | 34 +- .../tasks/src/modules/kt_services.erl | 22 +- applications/tasks/src/modules/kt_skel.erl | 10 +- .../tasks/src/modules/kt_token_auth.erl | 2 +- .../tasks/src/modules/kt_user_auth.erl | 4 +- .../tasks/src/modules/kt_webhooks.erl | 6 +- .../tasks/src/notify_resend_maintenance.erl | 28 +- applications/tasks/src/tasks_app.erl | 2 +- applications/tasks/src/tasks_bindings.erl | 30 +- applications/tasks/src/tasks_listener.erl | 16 +- applications/tasks/src/tasks_maintenance.erl | 30 +- applications/tasks/src/tasks_sup.erl | 4 +- applications/teletype/src/teletype.hrl | 32 +- applications/teletype/src/teletype_app.erl | 2 +- .../teletype/src/teletype_bindings.erl | 12 +- .../teletype/src/teletype_farms_sup.erl | 4 +- .../teletype/src/teletype_fax_util.erl | 34 +- .../src/teletype_gen_email_template.erl | 10 +- .../teletype/src/teletype_listener.erl | 12 +- .../teletype/src/teletype_maintenance.erl | 32 +- .../teletype/src/teletype_port_utils.erl | 12 +- .../teletype/src/teletype_renderer.erl | 14 +- .../teletype/src/teletype_shared_listener.erl | 12 +- applications/teletype/src/teletype_sup.erl | 4 +- .../teletype/src/teletype_templates.erl | 90 +-- applications/teletype/src/teletype_tests.erl | 28 +- applications/teletype/src/teletype_util.erl | 162 ++-- .../teletype_account_zone_change.erl | 2 +- .../src/templates/teletype_cnam_request.erl | 2 +- .../templates/teletype_customer_update.erl | 14 +- .../src/templates/teletype_deregister.erl | 16 +- .../teletype_fax_inbound_error_to_email.erl | 6 +- ...pe_fax_inbound_error_to_email_filtered.erl | 2 +- .../teletype_fax_inbound_to_email.erl | 4 +- .../teletype_fax_outbound_error_to_email.erl | 4 +- ...etype_fax_outbound_smtp_error_to_email.erl | 2 +- .../teletype_fax_outbound_to_email.erl | 4 +- .../templates/teletype_first_occurrence.erl | 2 +- .../src/templates/teletype_low_balance.erl | 24 +- .../src/templates/teletype_missed_call.erl | 6 +- .../src/templates/teletype_new_account.erl | 20 +- .../src/templates/teletype_new_user.erl | 18 +- .../templates/teletype_password_recovery.erl | 4 +- .../src/templates/teletype_port_comment.erl | 4 +- .../templates/teletype_port_request_admin.erl | 4 +- .../src/templates/teletype_service_added.erl | 24 +- .../src/templates/teletype_system_alert.erl | 32 +- .../src/templates/teletype_template_skel.erl | 6 +- .../teletype/src/templates/teletype_topup.erl | 8 +- .../src/templates/teletype_transaction.erl | 10 +- .../src/templates/teletype_voicemail_full.erl | 10 +- .../templates/teletype_voicemail_to_email.erl | 40 +- .../templates/teletype_webhook_disabled.erl | 4 +- .../trunkstore/src/trunkstore_app.erl | 2 +- .../trunkstore/src/trunkstore_listener.erl | 10 +- .../trunkstore/src/trunkstore_maintenance.erl | 8 +- .../trunkstore/src/trunkstore_sup.erl | 4 +- applications/trunkstore/src/ts.hrl | 14 +- applications/trunkstore/src/ts_callflow.erl | 40 +- .../trunkstore/src/ts_from_offnet.erl | 34 +- applications/trunkstore/src/ts_from_onnet.erl | 16 +- applications/trunkstore/src/ts_offnet_sup.erl | 8 +- applications/trunkstore/src/ts_onnet_sup.erl | 8 +- applications/trunkstore/src/ts_responder.erl | 10 +- applications/trunkstore/src/ts_route_req.erl | 2 +- applications/trunkstore/src/ts_util.erl | 58 +- .../src/modules/webhooks_notifications.erl | 8 +- .../webhooks/src/modules/webhooks_object.erl | 12 +- .../webhooks/src/modules/webhooks_parking.erl | 4 +- .../webhooks/src/modules/webhooks_skel.erl | 2 +- applications/webhooks/src/webhooks.hrl | 14 +- applications/webhooks/src/webhooks_app.erl | 2 +- .../webhooks/src/webhooks_channel_util.erl | 28 +- .../webhooks/src/webhooks_disabler.erl | 24 +- applications/webhooks/src/webhooks_init.erl | 12 +- .../webhooks/src/webhooks_listener.erl | 14 +- .../webhooks/src/webhooks_maintenance.erl | 20 +- .../webhooks/src/webhooks_shared_listener.erl | 14 +- applications/webhooks/src/webhooks_sup.erl | 10 +- applications/webhooks/src/webhooks_util.erl | 68 +- core/amqp_cron/src/amqp_cron.erl | 12 +- core/amqp_cron/src/amqp_cron_app.erl | 2 +- core/amqp_cron/src/amqp_cron_sup.erl | 4 +- core/amqp_cron/src/amqp_cron_task.erl | 23 +- core/amqp_leader/src/amqp_leader.erl | 2 +- core/amqp_leader/src/amqp_leader_app.erl | 2 +- core/amqp_leader/src/amqp_leader_listener.erl | 8 +- core/amqp_leader/src/amqp_leader_proc.erl | 30 +- core/amqp_leader/src/amqp_leader_proc_sup.erl | 4 +- core/amqp_leader/src/amqp_leader_sup.erl | 6 +- core/braintree/include/braintree.hrl | 252 +++---- core/braintree/src/braintree_addon.erl | 8 +- core/braintree/src/braintree_address.erl | 22 +- core/braintree/src/braintree_card.erl | 28 +- core/braintree/src/braintree_client_token.erl | 2 +- core/braintree/src/braintree_customer.erl | 38 +- core/braintree/src/braintree_descriptor.erl | 14 +- core/braintree/src/braintree_discount.erl | 8 +- core/braintree/src/braintree_request.erl | 4 +- core/braintree/src/braintree_subscription.erl | 52 +- core/braintree/src/braintree_transaction.erl | 46 +- core/braintree/src/braintree_util.erl | 8 +- core/gcm/src/gcm.erl | 4 +- core/gcm/src/gcm_sup.erl | 6 +- core/kazoo/src/kazoo_maintenance.erl | 12 +- core/kazoo/src/kz_doc.erl | 104 +-- core/kazoo/src/kz_network_utils.erl | 50 +- core/kazoo/src/kz_util.erl | 110 +-- core/kazoo_amqp/include/kz_amqp.hrl | 44 +- core/kazoo_amqp/include/kz_api.hrl | 22 +- core/kazoo_amqp/src/amqp_util.erl | 336 ++++----- core/kazoo_amqp/src/api/kapi_asr.erl | 32 +- core/kazoo_amqp/src/api/kapi_authn.erl | 36 +- core/kazoo_amqp/src/api/kapi_authz.erl | 42 +- core/kazoo_amqp/src/api/kapi_call.erl | 120 +-- core/kazoo_amqp/src/api/kapi_callflow.erl | 10 +- core/kazoo_amqp/src/api/kapi_camping.erl | 16 +- core/kazoo_amqp/src/api/kapi_conf.erl | 62 +- core/kazoo_amqp/src/api/kapi_conference.erl | 270 +++---- core/kazoo_amqp/src/api/kapi_delegate.erl | 20 +- core/kazoo_amqp/src/api/kapi_dialplan.erl | 284 +++---- core/kazoo_amqp/src/api/kapi_fax.erl | 60 +- core/kazoo_amqp/src/api/kapi_fs.erl | 8 +- core/kazoo_amqp/src/api/kapi_globals.erl | 90 +-- core/kazoo_amqp/src/api/kapi_hangups.erl | 20 +- core/kazoo_amqp/src/api/kapi_inspector.erl | 36 +- core/kazoo_amqp/src/api/kapi_leader.erl | 24 +- core/kazoo_amqp/src/api/kapi_maintenance.erl | 78 +- core/kazoo_amqp/src/api/kapi_media.erl | 28 +- core/kazoo_amqp/src/api/kapi_metaflow.erl | 48 +- core/kazoo_amqp/src/api/kapi_money.erl | 44 +- core/kazoo_amqp/src/api/kapi_nodes.erl | 12 +- .../kazoo_amqp/src/api/kapi_notifications.erl | 310 ++++---- .../src/api/kapi_offnet_resource.erl | 144 ++-- core/kazoo_amqp/src/api/kapi_pivot.erl | 24 +- core/kazoo_amqp/src/api/kapi_presence.erl | 152 ++-- core/kazoo_amqp/src/api/kapi_rate.erl | 24 +- core/kazoo_amqp/src/api/kapi_registration.erl | 62 +- core/kazoo_amqp/src/api/kapi_resource.erl | 66 +- core/kazoo_amqp/src/api/kapi_route.erl | 62 +- core/kazoo_amqp/src/api/kapi_self.erl | 10 +- core/kazoo_amqp/src/api/kapi_sms.erl | 68 +- core/kazoo_amqp/src/api/kapi_switch.erl | 54 +- core/kazoo_amqp/src/api/kapi_sysconf.erl | 54 +- core/kazoo_amqp/src/api/kapi_tasks.erl | 78 +- core/kazoo_amqp/src/api/kapi_websockets.erl | 44 +- core/kazoo_amqp/src/api/kz_api.erl | 132 ++-- core/kazoo_amqp/src/gen_listener.erl | 160 ++-- core/kazoo_amqp/src/kapi_definition.erl | 16 +- core/kazoo_amqp/src/kazoo_amqp_app.erl | 2 +- .../kazoo_amqp/src/kazoo_amqp_maintenance.erl | 16 +- core/kazoo_amqp/src/kz_amqp_assignments.erl | 34 +- core/kazoo_amqp/src/kz_amqp_bootstrap.erl | 24 +- core/kazoo_amqp/src/kz_amqp_channel.erl | 16 +- core/kazoo_amqp/src/kz_amqp_connection.erl | 8 +- .../kazoo_amqp/src/kz_amqp_connection_sup.erl | 6 +- core/kazoo_amqp/src/kz_amqp_connections.erl | 46 +- core/kazoo_amqp/src/kz_amqp_history.erl | 24 +- core/kazoo_amqp/src/kz_amqp_sup.erl | 22 +- core/kazoo_amqp/src/kz_amqp_worker.erl | 108 +-- core/kazoo_amqp/src/listener_federator.erl | 20 +- core/kazoo_amqp/src/listener_types.hrl | 20 +- core/kazoo_apps/src/kapps_alert.erl | 16 +- core/kazoo_apps/src/kapps_controller.erl | 28 +- core/kazoo_apps/src/kapps_maintenance.erl | 124 ++-- .../kazoo_apps/src/kapps_notify_publisher.erl | 28 +- core/kazoo_apps/src/kapps_util.erl | 120 +-- core/kazoo_apps/src/kazoo_apps_app.erl | 4 +- core/kazoo_apps/src/kazoo_apps_init.erl | 2 +- .../src/kazoo_apps_maint_listener.erl | 20 +- core/kazoo_apps/src/kazoo_apps_sup.erl | 6 +- core/kazoo_apps/src/kz_hooks.erl | 16 +- core/kazoo_apps/src/kz_hooks_listener.erl | 12 +- core/kazoo_apps/src/kz_hooks_listener_sup.erl | 4 +- .../src/kz_hooks_shared_listener.erl | 12 +- core/kazoo_apps/src/kz_hooks_util.erl | 52 +- core/kazoo_apps/src/kz_notify.erl | 10 +- core/kazoo_apps/src/kz_storage.erl | 18 +- core/kazoo_ast/src/cb_api_endpoints.erl | 66 +- core/kazoo_ast/src/kapi_schemas.erl | 8 +- core/kazoo_ast/src/kapps_config_usage.erl | 2 +- core/kazoo_ast/src/kast_app_deps.erl | 2 +- core/kazoo_ast/src/kazoo_ast.erl | 2 +- core/kazoo_ast/src/kz_ast_util.erl | 18 +- .../src/kazoo_attachments_app.erl | 2 +- .../src/kazoo_attachments_sup.erl | 4 +- core/kazoo_attachments/src/kz_att.hrl | 2 +- core/kazoo_attachments/src/kz_att_azure.erl | 8 +- .../src/kz_att_azure_sup.erl | 10 +- core/kazoo_attachments/src/kz_att_dropbox.erl | 12 +- core/kazoo_attachments/src/kz_att_ftp.erl | 8 +- .../src/kz_att_google_drive.erl | 22 +- .../src/kz_att_google_storage.erl | 16 +- core/kazoo_attachments/src/kz_att_http.erl | 8 +- core/kazoo_attachments/src/kz_att_link.erl | 4 +- .../kazoo_attachments/src/kz_att_onedrive.erl | 14 +- core/kazoo_attachments/src/kz_att_s3.erl | 24 +- core/kazoo_attachments/src/kz_att_util.erl | 30 +- core/kazoo_auth/src/kazoo_auth.hrl | 2 +- core/kazoo_auth/src/kazoo_auth_app.erl | 2 +- .../kazoo_auth/src/kazoo_auth_maintenance.erl | 4 +- core/kazoo_auth/src/kazoo_auth_sup.erl | 4 +- core/kazoo_auth/src/kz_auth.erl | 28 +- core/kazoo_auth/src/kz_auth_apps.erl | 6 +- core/kazoo_auth/src/kz_auth_client.erl | 8 +- core/kazoo_auth/src/kz_auth_identity.erl | 12 +- core/kazoo_auth/src/kz_auth_init.erl | 2 +- core/kazoo_auth/src/kz_auth_jwt.erl | 16 +- core/kazoo_auth/src/kz_auth_keys.erl | 16 +- core/kazoo_auth/src/kz_auth_profile.erl | 24 +- core/kazoo_auth/src/kz_auth_providers.erl | 4 +- core/kazoo_auth/src/kz_auth_rsa.erl | 10 +- core/kazoo_auth/src/kz_auth_token_util.erl | 4 +- core/kazoo_auth/src/kz_auth_util.erl | 8 +- core/kazoo_auth/src/kz_mfa_auth.erl | 14 +- .../src/mfa_provider/kz_mfa_duo.erl | 24 +- core/kazoo_bindings/src/kazoo_bindings.erl | 96 +-- .../kazoo_bindings/src/kazoo_bindings_app.erl | 2 +- .../src/kazoo_bindings_init.erl | 2 +- core/kazoo_bindings/src/kazoo_bindings_rt.erl | 4 +- .../kazoo_bindings/src/kazoo_bindings_sup.erl | 4 +- .../test/kazoo_bindings_test.erl | 2 +- core/kazoo_caches/include/kazoo_caches.hrl | 16 +- core/kazoo_caches/src/kazoo_caches_app.erl | 2 +- core/kazoo_caches/src/kazoo_caches_sup.erl | 4 +- core/kazoo_caches/src/kz_cache.erl | 62 +- .../include/kapps_call_command_types.hrl | 4 +- core/kazoo_call/src/kapps_call.erl | 276 +++---- core/kazoo_call/src/kapps_call_command.erl | 700 +++++++++--------- core/kazoo_call/src/kapps_call_util.erl | 6 +- core/kazoo_call/src/kapps_conference.erl | 112 +-- .../src/kapps_conference_command.erl | 36 +- core/kazoo_call/src/kapps_sms_command.erl | 26 +- core/kazoo_call/src/kazoo_call_app.erl | 2 +- core/kazoo_call/src/kazoo_call_sup.erl | 4 +- core/kazoo_call/src/kz_call_response.erl | 26 +- core/kazoo_call/src/kzc_recording.erl | 70 +- core/kazoo_call/src/kzc_recordings_sup.erl | 10 +- .../kazoo_config/src/kapps_account_config.erl | 114 +-- core/kazoo_config/src/kapps_config.erl | 142 ++-- core/kazoo_config/src/kapps_config_doc.erl | 34 +- core/kazoo_config/src/kapps_config_util.erl | 26 +- core/kazoo_config/src/kazoo_config_app.erl | 2 +- core/kazoo_config/src/kazoo_config_init.erl | 6 +- core/kazoo_config/src/kazoo_config_sup.erl | 4 +- core/kazoo_config/src/kz_config.erl | 44 +- core/kazoo_couch/src/kazoo_couch.erl | 70 +- core/kazoo_couch/src/kazoo_couch_app.erl | 2 +- core/kazoo_couch/src/kazoo_couch_sup.erl | 4 +- core/kazoo_couch/src/kz_couch.hrl | 12 +- core/kazoo_couch/src/kz_couch_attachments.erl | 26 +- core/kazoo_couch/src/kz_couch_db.erl | 30 +- core/kazoo_couch/src/kz_couch_doc.erl | 48 +- core/kazoo_couch/src/kz_couch_util.erl | 24 +- core/kazoo_couch/src/kz_couch_view.erl | 22 +- core/kazoo_csv/src/kz_csv.erl | 34 +- core/kazoo_data/src/kazoo_data_app.erl | 2 +- core/kazoo_data/src/kazoo_data_bootstrap.erl | 8 +- core/kazoo_data/src/kazoo_data_config.erl | 24 +- core/kazoo_data/src/kazoo_data_init.erl | 2 +- core/kazoo_data/src/kazoo_data_link_sup.erl | 4 +- .../kazoo_data/src/kazoo_data_maintenance.erl | 18 +- core/kazoo_data/src/kazoo_data_sup.erl | 4 +- .../src/kazoo_dataconnection_error.erl | 50 +- core/kazoo_data/src/kz_data.erl | 54 +- core/kazoo_data/src/kz_data.hrl | 16 +- core/kazoo_data/src/kz_data_tracing.erl | 10 +- core/kazoo_data/src/kz_dataconfig.erl | 4 +- core/kazoo_data/src/kz_dataconnection.erl | 8 +- core/kazoo_data/src/kz_dataconnection_sup.erl | 6 +- core/kazoo_data/src/kz_dataconnections.erl | 10 +- core/kazoo_data/src/kz_datamgr.erl | 244 +++--- core/kazoo_data/src/kzs_attachments.erl | 22 +- core/kazoo_data/src/kzs_cache.erl | 40 +- core/kazoo_data/src/kzs_db.erl | 64 +- core/kazoo_data/src/kzs_doc.erl | 34 +- core/kazoo_data/src/kzs_plan.erl | 26 +- core/kazoo_data/src/kzs_publish.erl | 24 +- core/kazoo_data/src/kzs_server.erl | 6 +- core/kazoo_data/src/kzs_util.erl | 8 +- core/kazoo_data/src/kzs_view.erl | 14 +- core/kazoo_documents/src/kz_account.erl | 110 +-- core/kazoo_documents/src/kz_attachment.erl | 6 +- core/kazoo_documents/src/kz_call_event.erl | 90 +-- .../src/kz_custom_sip_headers.erl | 6 +- core/kazoo_documents/src/kz_device.erl | 108 +-- core/kazoo_documents/src/kz_notification.erl | 56 +- core/kazoo_documents/src/kz_whitelabel.erl | 10 +- core/kazoo_documents/src/kzd_agent.erl | 8 +- core/kazoo_documents/src/kzd_alert.erl | 48 +- core/kazoo_documents/src/kzd_app.erl | 34 +- core/kazoo_documents/src/kzd_apps_store.erl | 10 +- core/kazoo_documents/src/kzd_audit_log.erl | 42 +- core/kazoo_documents/src/kzd_box_message.erl | 48 +- .../src/kzd_call_recording.erl | 46 +- core/kazoo_documents/src/kzd_callflow.erl | 14 +- core/kazoo_documents/src/kzd_conference.erl | 2 +- core/kazoo_documents/src/kzd_domains.erl | 84 +-- core/kazoo_documents/src/kzd_fax.erl | 60 +- core/kazoo_documents/src/kzd_fax_box.erl | 14 +- core/kazoo_documents/src/kzd_freeswitch.erl | 144 ++-- core/kazoo_documents/src/kzd_item_plan.erl | 18 +- core/kazoo_documents/src/kzd_media.erl | 14 +- core/kazoo_documents/src/kzd_metaflow.erl | 14 +- core/kazoo_documents/src/kzd_rate.erl | 74 +- core/kazoo_documents/src/kzd_ratedeck.erl | 10 +- core/kazoo_documents/src/kzd_resource.erl | 12 +- core/kazoo_documents/src/kzd_schema.erl | 6 +- .../src/kzd_schema_caller_id.erl | 2 +- core/kazoo_documents/src/kzd_service_plan.erl | 58 +- core/kazoo_documents/src/kzd_services.erl | 66 +- core/kazoo_documents/src/kzd_skel.erl | 4 +- core/kazoo_documents/src/kzd_task.erl | 30 +- core/kazoo_documents/src/kzd_user.erl | 66 +- .../kazoo_documents/src/kzd_voicemail_box.erl | 28 +- core/kazoo_documents/src/kzd_webhook.erl | 40 +- .../kazoo_endpoint/src/kazoo_endpoint_app.erl | 2 +- .../kazoo_endpoint/src/kazoo_endpoint_sup.erl | 4 +- core/kazoo_endpoint/src/kz_attributes.erl | 134 ++-- core/kazoo_endpoint/src/kz_endpoint.erl | 210 +++--- .../src/kz_endpoint_recording.erl | 46 +- core/kazoo_endpoint/src/kz_endpoints.erl | 4 +- core/kazoo_endpoint/src/kz_formatters.erl | 48 +- core/kazoo_endpoint/src/kz_privacy.erl | 40 +- core/kazoo_etsmgr/src/kazoo_etsmgr_srv.erl | 14 +- core/kazoo_fixturedb/src/kazoo_fixturedb.erl | 56 +- .../src/kazoo_fixturedb_app.erl | 2 +- .../src/kazoo_fixturedb_sup.erl | 4 +- core/kazoo_fixturedb/src/kz_fixturedb.hrl | 6 +- .../src/kz_fixturedb_attachments.erl | 12 +- core/kazoo_fixturedb/src/kz_fixturedb_db.erl | 20 +- core/kazoo_fixturedb/src/kz_fixturedb_doc.erl | 16 +- .../src/kz_fixturedb_server.erl | 8 +- .../kazoo_fixturedb/src/kz_fixturedb_util.erl | 48 +- .../kazoo_fixturedb/src/kz_fixturedb_view.erl | 14 +- core/kazoo_globals/src/kazoo_globals_app.erl | 4 +- core/kazoo_globals/src/kazoo_globals_init.erl | 2 +- core/kazoo_globals/src/kazoo_globals_sup.erl | 4 +- core/kazoo_globals/src/kz_global.erl | 16 +- .../src/kz_global_proxies_sup.erl | 8 +- core/kazoo_globals/src/kz_global_proxy.erl | 8 +- core/kazoo_globals/src/kz_globals.erl | 30 +- core/kazoo_globals/src/kz_nodes.erl | 164 ++-- core/kazoo_ips/src/kazoo_ips_maintenance.erl | 12 +- core/kazoo_ips/src/kz_ip.erl | 24 +- core/kazoo_ips/src/kz_ips.erl | 16 +- core/kazoo_ledgers/src/kazoo_ledger.erl | 44 +- core/kazoo_ledgers/src/kz_ledger.erl | 42 +- core/kazoo_ledgers/src/kz_ledgers.erl | 10 +- .../src/kapps_config_maint_listener.erl | 20 +- .../src/kazoo_maintenance_app.erl | 2 +- .../src/kazoo_maintenance_sup.erl | 4 +- .../src/kazoo_oauth_maint_listener.erl | 14 +- .../src/skel_maint_listener.erl | 12 +- core/kazoo_media/src/kazoo_media.hrl | 8 +- core/kazoo_media/src/kazoo_media_app.erl | 2 +- core/kazoo_media/src/kazoo_media_init.erl | 2 +- .../src/kazoo_media_maintenance.erl | 56 +- core/kazoo_media/src/kazoo_media_sup.erl | 4 +- core/kazoo_media/src/kz_media_cache_sup.erl | 10 +- core/kazoo_media/src/kz_media_config.erl | 4 +- core/kazoo_media/src/kz_media_doc.erl | 2 +- core/kazoo_media/src/kz_media_file.erl | 28 +- core/kazoo_media/src/kz_media_file_cache.erl | 16 +- core/kazoo_media/src/kz_media_map.erl | 60 +- core/kazoo_media/src/kz_media_proxy.erl | 2 +- core/kazoo_media/src/kz_media_proxy_util.erl | 8 +- core/kazoo_media/src/kz_media_store_proxy.erl | 24 +- core/kazoo_media/src/kz_media_tts.erl | 2 +- core/kazoo_media/src/kz_media_tts_cache.erl | 22 +- core/kazoo_media/src/kz_media_url.erl | 10 +- core/kazoo_media/src/kz_media_util.erl | 94 +-- core/kazoo_modb/src/kazoo_modb.erl | 102 +-- .../kazoo_modb/src/kazoo_modb_maintenance.erl | 44 +- .../src/kazoo_modb_migrate_maintenance.erl | 38 +- core/kazoo_modb/src/kazoo_modb_util.erl | 18 +- .../src/carriers/knm_bandwidth.erl | 22 +- .../src/carriers/knm_bandwidth2.erl | 40 +- .../src/carriers/knm_carriers.erl | 54 +- .../src/carriers/knm_inum.erl | 18 +- .../src/carriers/knm_inventory.erl | 10 +- .../src/carriers/knm_local.erl | 10 +- .../src/carriers/knm_managed.erl | 22 +- .../src/carriers/knm_mdn.erl | 6 +- .../src/carriers/knm_other.erl | 12 +- .../src/carriers/knm_reserved.erl | 10 +- .../src/carriers/knm_reserved_reseller.erl | 10 +- .../src/carriers/knm_simwood.erl | 12 +- .../src/carriers/knm_telnyx.erl | 8 +- .../src/carriers/knm_vitelity.erl | 36 +- .../src/carriers/knm_voip_innovations.erl | 14 +- .../src/converters/knm_converter_regex.erl | 24 +- .../src/converters/knm_converters.erl | 38 +- .../src/kapi_discovery.erl | 42 +- .../src/kazoo_number_manager_app.erl | 2 +- .../src/kazoo_number_manager_maintenance.erl | 116 +-- .../src/kazoo_number_manager_sup.erl | 4 +- core/kazoo_number_manager/src/knm_config.erl | 4 +- core/kazoo_number_manager/src/knm_errors.erl | 30 +- .../src/knm_gen_carrier.erl | 4 +- .../kazoo_number_manager/src/knm_locality.erl | 10 +- core/kazoo_number_manager/src/knm_number.erl | 72 +- .../src/knm_number_options.erl | 46 +- .../src/knm_number_states.erl | 14 +- core/kazoo_number_manager/src/knm_numbers.erl | 54 +- .../src/knm_phone_number.erl | 150 ++-- .../src/knm_port_request.erl | 62 +- core/kazoo_number_manager/src/knm_search.erl | 60 +- .../kazoo_number_manager/src/knm_services.erl | 18 +- .../src/knm_telnyx_util.erl | 2 +- core/kazoo_number_manager/src/knm_util.erl | 22 +- .../kazoo_number_manager/src/knm_vitelity.hrl | 28 +- .../src/knm_vitelity_util.erl | 40 +- .../src/providers/knm_cnam_notifier.erl | 2 +- .../src/providers/knm_dash_e911.erl | 16 +- .../src/providers/knm_failover.erl | 2 +- .../src/providers/knm_port_notifier.erl | 2 +- .../src/providers/knm_prepend.erl | 2 +- .../src/providers/knm_providers.erl | 74 +- .../src/providers/knm_telnyx_cnam.erl | 2 +- .../src/providers/knm_telnyx_e911.erl | 20 +- .../src/providers/knm_vitelity_cnam.erl | 20 +- .../src/providers/knm_vitelity_e911.erl | 32 +- .../kazoo_oauth/include/kazoo_oauth_types.hrl | 58 +- core/kazoo_oauth/src/kazoo_oauth_client.erl | 10 +- .../src/kazoo_oauth_maintenance.erl | 2 +- core/kazoo_oauth/src/kazoo_oauth_service.erl | 2 +- core/kazoo_oauth/src/kazoo_oauth_util.erl | 36 +- .../kazoo_perf/src/kazoo_perf_maintenance.erl | 2 +- .../src/kazoo_proper_maintenance.erl | 4 +- core/kazoo_proper/src/pqc_cb_accounts.erl | 18 +- core/kazoo_proper/src/pqc_cb_api.erl | 32 +- core/kazoo_proper/src/pqc_cb_ips.erl | 22 +- .../kazoo_proper/src/pqc_cb_phone_numbers.erl | 14 +- core/kazoo_proper/src/pqc_cb_rates.erl | 30 +- core/kazoo_proper/src/pqc_cb_response.erl | 6 +- core/kazoo_proper/src/pqc_cb_search.erl | 2 +- .../kazoo_proper/src/pqc_cb_service_plans.erl | 8 +- core/kazoo_proper/src/pqc_cb_tasks.erl | 10 +- core/kazoo_proper/src/pqc_kazoo_model.erl | 96 +-- core/kazoo_proper/src/pqc_util.erl | 6 +- core/kazoo_schemas/src/kz_json_schema.erl | 46 +- .../bookkeepers/kz_bookkeeper_braintree.erl | 68 +- .../src/bookkeepers/kz_bookkeeper_http.erl | 30 +- .../src/bookkeepers/kz_bookkeeper_local.erl | 14 +- .../kazoo_services/src/kazoo_services_app.erl | 2 +- .../src/kazoo_services_maintenance.erl | 24 +- .../kazoo_services/src/kazoo_services_sup.erl | 4 +- core/kazoo_services/src/kz_gen_bookkeeper.erl | 10 +- core/kazoo_services/src/kz_service_item.erl | 62 +- core/kazoo_services/src/kz_service_items.erl | 8 +- core/kazoo_services/src/kz_service_plan.erl | 24 +- core/kazoo_services/src/kz_service_plans.erl | 18 +- core/kazoo_services/src/kz_services.erl | 182 ++--- core/kazoo_services/src/kz_services_modb.erl | 10 +- .../src/services/kz_service_billing.erl | 2 +- .../src/services/kz_service_devices.erl | 4 +- .../src/services/kz_service_ips.erl | 4 +- .../src/services/kz_service_ledgers.erl | 4 +- .../src/services/kz_service_phone_numbers.erl | 14 +- .../src/services/kz_service_ratedeck.erl | 4 +- .../src/services/kz_service_ratedeck_name.erl | 4 +- .../src/services/kz_service_transactions.erl | 4 +- .../src/services/kz_service_ui_apps.erl | 2 +- .../src/services/kz_service_users.erl | 2 +- .../src/services/kz_service_whitelabel.erl | 2 +- .../src/whs_account_conversion.erl | 20 +- core/kazoo_sip/src/kzsip_diversion.erl | 74 +- core/kazoo_sip/src/kzsip_uri.erl | 18 +- .../src/asr/kazoo_asr_ispeech.erl | 18 +- core/kazoo_speech/src/gen_asr_provider.erl | 4 +- core/kazoo_speech/src/gen_tts_provider.erl | 4 +- core/kazoo_speech/src/kazoo_asr.erl | 24 +- core/kazoo_speech/src/kazoo_asr_util.erl | 2 +- core/kazoo_speech/src/kazoo_speech.hrl | 4 +- .../src/kazoo_speech_maintenance.erl | 6 +- core/kazoo_speech/src/kazoo_speech_util.erl | 2 +- core/kazoo_speech/src/kazoo_tts.erl | 26 +- .../src/tts/kazoo_tts_ispeech.erl | 8 +- .../src/tts/kazoo_tts_voicefabric.erl | 20 +- core/kazoo_stats/src/kazoo_stats.erl | 10 +- core/kazoo_stats/src/kazoo_stats_app.erl | 2 +- core/kazoo_stats/src/kazoo_stats_sup.erl | 4 +- core/kazoo_stdlib/include/kazoo_json.hrl | 2 +- core/kazoo_stdlib/include/kz_records.hrl | 28 + core/kazoo_stdlib/include/kz_types.hrl | 215 +----- core/kazoo_stdlib/src/kz_binary.erl | 18 +- core/kazoo_stdlib/src/kz_date.erl | 30 +- core/kazoo_stdlib/src/kz_json.erl | 66 +- core/kazoo_stdlib/src/kz_term.erl | 104 ++- core/kazoo_stdlib/src/kz_time.erl | 74 +- core/kazoo_stdlib/src/kz_types.erl | 171 +++++ core/kazoo_stdlib/src/props.erl | 102 +-- core/kazoo_stdlib/test/kz_date_tests.erl | 4 +- core/kazoo_tasks/src/kz_tasks.erl | 60 +- core/kazoo_templates/src/kz_pdf.erl | 20 +- core/kazoo_templates/src/kz_template.erl | 12 +- .../src/kazoo_token_buckets_app.erl | 2 +- .../src/kazoo_token_buckets_sup.erl | 6 +- core/kazoo_token_buckets/src/kz_buckets.erl | 52 +- .../src/kz_buckets_sup.erl | 8 +- .../src/kz_token_bucket.erl | 20 +- .../src/kazoo_transactions_maintenance.erl | 12 +- core/kazoo_transactions/src/kz_topup.erl | 16 +- .../kazoo_transactions/src/kz_transaction.erl | 126 ++-- .../src/kz_transactions.erl | 36 +- core/kazoo_transactions/src/wht_util.erl | 92 +-- .../src/convertors/kzt_kazoo.erl | 4 +- .../src/convertors/kzt_twiml.erl | 36 +- .../src/convertors/kzt_twiml_dial.erl | 24 +- .../src/convertors/kzt_twiml_say.erl | 2 +- .../src/convertors/kzt_twiml_util.erl | 36 +- core/kazoo_translator/src/kzt_receiver.erl | 54 +- core/kazoo_translator/src/kzt_translator.erl | 8 +- core/kazoo_translator/src/kzt_util.erl | 98 +-- .../src/kazoo_voicemail_maintenance.erl | 30 +- core/kazoo_voicemail/src/kvm_message.erl | 98 +-- core/kazoo_voicemail/src/kvm_messages.erl | 78 +- core/kazoo_voicemail/src/kvm_util.erl | 54 +- core/kazoo_voicemail/src/kz_voicemail.hrl | 14 +- .../src/migrate/kvm_migrate_account.erl | 40 +- .../src/migrate/kvm_migrate_crawler.erl | 34 +- core/kazoo_web/src/kz_http.erl | 74 +- core/kazoo_web/src/kz_http_util.erl | 8 +- core/kazoo_xml/src/kz_xml.erl | 18 +- core/sup/src/sup.erl | 8 +- core/webseq/src/webseq.erl | 44 +- core/webseq/src/webseq.hrl | 12 +- core/webseq/src/webseq_diagram_srv.erl | 48 +- scripts/check-dialyzer.escript | 7 +- scripts/dialyze-changed.bash | 1 + scripts/dialyze-usage.bash | 7 + scripts/kz_diaspora.bash | 175 +++++ 1135 files changed, 16012 insertions(+), 15701 deletions(-) create mode 100644 core/kazoo_stdlib/include/kz_records.hrl create mode 100644 core/kazoo_stdlib/src/kz_types.erl diff --git a/applications/acdc/src/acdc.hrl b/applications/acdc/src/acdc.hrl index 9113b0af335..28836d6fce8 100644 --- a/applications/acdc/src/acdc.hrl +++ b/applications/acdc/src/acdc.hrl @@ -36,7 +36,7 @@ -type deliveries() :: [gen_listener:basic_deliver()]. --type announcements_pids() :: #{ne_binary() => pid()}. +-type announcements_pids() :: #{kz_term:ne_binary() => pid()}. -type fsm_state_name() :: 'wait' | 'sync' | 'ready' | 'ringing' | 'ringing_callback' | 'awaiting_callback' | diff --git a/applications/acdc/src/acdc_agent_fsm.erl b/applications/acdc/src/acdc_agent_fsm.erl index ae84780e0f9..7f625f103da 100644 --- a/applications/acdc/src/acdc_agent_fsm.erl +++ b/applications/acdc/src/acdc_agent_fsm.erl @@ -88,32 +88,32 @@ -define(RESOURCE_TYPE_AUDIO, <<"audio">>). --record(state, {account_id :: ne_binary() - ,account_db :: ne_binary() - ,agent_id :: ne_binary() - ,agent_listener :: server_ref() - ,agent_listener_id :: api_ne_binary() - ,agent_name :: api_binary() +-record(state, {account_id :: kz_term:ne_binary() + ,account_db :: kz_term:ne_binary() + ,agent_id :: kz_term:ne_binary() + ,agent_listener :: kz_types:server_ref() + ,agent_listener_id :: kz_term:api_ne_binary() + ,agent_name :: kz_term:api_binary() ,wrapup_timeout = 0 :: integer() % optionally set on win - ,wrapup_ref :: api_reference() + ,wrapup_ref :: kz_term:api_reference() - ,sync_ref :: api_reference() - ,pause_ref :: api_reference() + ,sync_ref :: kz_term:api_reference() + ,pause_ref :: kz_term:api_reference() ,member_call :: kapps_call:call() | 'undefined' - ,member_call_id :: api_binary() - ,member_call_queue_id :: api_binary() - ,member_call_start :: kz_now() | 'undefined' - ,caller_exit_key = <<"#">> :: ne_binary() - ,queue_notifications :: api_object() - - ,agent_call_id :: api_binary() - ,next_status :: api_binary() - ,statem_call_id :: api_binary() % used when no call-ids are available + ,member_call_id :: kz_term:api_binary() + ,member_call_queue_id :: kz_term:api_binary() + ,member_call_start :: kz_time:now() | 'undefined' + ,caller_exit_key = <<"#">> :: kz_term:ne_binary() + ,queue_notifications :: kz_term:api_object() + + ,agent_call_id :: kz_term:api_binary() + ,next_status :: kz_term:api_binary() + ,statem_call_id :: kz_term:api_binary() % used when no call-ids are available ,endpoints = [] :: kz_json:objects() - ,outbound_call_ids = [] :: ne_binaries() - ,max_connect_failures :: kz_timeout() + ,outbound_call_ids = [] :: kz_term:ne_binaries() + ,max_connect_failures :: timeout() ,connect_failures = 0 :: non_neg_integer() ,agent_state_updates = [] :: list() }). @@ -155,7 +155,7 @@ agent_timeout(ServerRef, JObj) -> %% for bridge and hangup events). %% @end %%-------------------------------------------------------------------- --spec call_event(pid(), ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec call_event(pid(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. call_event(ServerRef, <<"call_event">>, <<"CHANNEL_BRIDGE">>, JObj) -> gen_statem:cast(ServerRef, {'channel_bridged', call_id(JObj)}); call_event(ServerRef, <<"call_event">>, <<"CHANNEL_UNBRIDGE">>, JObj) -> @@ -192,7 +192,7 @@ call_event(_, _C, _E, _) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec maybe_send_execute_complete(pid(), ne_binary(), kz_json:object()) -> 'ok'. +-spec maybe_send_execute_complete(pid(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. maybe_send_execute_complete(ServerRef, <<"bridge">>, JObj) -> lager:info("Send EXECUTE_COMPLETE,bridge to ~p with ci: ~s, olci: ~s", [ServerRef @@ -208,19 +208,19 @@ maybe_send_execute_complete(_, _, _) -> 'ok'. %% @doc %% @end %%-------------------------------------------------------------------- --spec originate_ready(server_ref(), kz_json:object()) -> 'ok'. +-spec originate_ready(kz_types:server_ref(), kz_json:object()) -> 'ok'. originate_ready(ServerRef, JObj) -> gen_statem:cast(ServerRef, {'originate_ready', JObj}). --spec originate_resp(server_ref(), kz_json:object()) -> 'ok'. +-spec originate_resp(kz_types:server_ref(), kz_json:object()) -> 'ok'. originate_resp(ServerRef, JObj) -> gen_statem:cast(ServerRef, {'originate_resp', kz_json:get_value(<<"Call-ID">>, JObj)}). --spec originate_started(server_ref(), kz_json:object()) -> 'ok'. +-spec originate_started(kz_types:server_ref(), kz_json:object()) -> 'ok'. originate_started(ServerRef, JObj) -> gen_statem:cast(ServerRef, {'originate_started', kz_json:get_value(<<"Call-ID">>, JObj)}). --spec originate_uuid(server_ref(), kz_json:object()) -> 'ok'. +-spec originate_uuid(kz_types:server_ref(), kz_json:object()) -> 'ok'. originate_uuid(ServerRef, JObj) -> gen_statem:cast(ServerRef, {'originate_uuid' ,kz_json:get_value(<<"Outbound-Call-ID">>, JObj) @@ -231,7 +231,7 @@ originate_uuid(ServerRef, JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec originate_failed(server_ref(), kz_json:object()) -> 'ok'. +-spec originate_failed(kz_types:server_ref(), kz_json:object()) -> 'ok'. originate_failed(ServerRef, JObj) -> gen_statem:cast(ServerRef, {'originate_failed', JObj}). @@ -239,7 +239,7 @@ originate_failed(ServerRef, JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec sync_req(server_ref(), kz_json:object()) -> 'ok'. +-spec sync_req(kz_types:server_ref(), kz_json:object()) -> 'ok'. sync_req(ServerRef, JObj) -> gen_statem:cast(ServerRef, {'sync_req', JObj}). @@ -247,7 +247,7 @@ sync_req(ServerRef, JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec sync_resp(server_ref(), kz_json:object()) -> 'ok'. +-spec sync_resp(kz_types:server_ref(), kz_json:object()) -> 'ok'. sync_resp(ServerRef, JObj) -> gen_statem:cast(ServerRef, {'sync_resp', JObj}). @@ -255,7 +255,7 @@ sync_resp(ServerRef, JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec pause(server_ref(), kz_timeout()) -> 'ok'. +-spec pause(kz_types:server_ref(), timeout()) -> 'ok'. pause(ServerRef, Timeout) -> gen_statem:cast(ServerRef, {'pause', Timeout}). @@ -263,7 +263,7 @@ pause(ServerRef, Timeout) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec resume(server_ref()) -> 'ok'. +-spec resume(kz_types:server_ref()) -> 'ok'. resume(ServerRef) -> gen_statem:cast(ServerRef, {'resume'}). @@ -273,7 +273,7 @@ resume(ServerRef) -> %% availability update depending on agent state %% @end %%-------------------------------------------------------------------- --spec add_acdc_queue(server_ref(), ne_binary()) -> 'ok'. +-spec add_acdc_queue(kz_types:server_ref(), kz_term:ne_binary()) -> 'ok'. add_acdc_queue(ServerRef, QueueId) -> gen_statem:cast(ServerRef, {'add_acdc_queue', QueueId}). @@ -283,7 +283,7 @@ add_acdc_queue(ServerRef, QueueId) -> %% unavailability update %% @end %%-------------------------------------------------------------------- --spec rm_acdc_queue(server_ref(), ne_binary()) -> 'ok'. +-spec rm_acdc_queue(kz_types:server_ref(), kz_term:ne_binary()) -> 'ok'. rm_acdc_queue(ServerRef, QueueId) -> gen_statem:cast(ServerRef, {'rm_acdc_queue', QueueId}). @@ -291,7 +291,7 @@ rm_acdc_queue(ServerRef, QueueId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec update_presence(server_ref(), ne_binary(), ne_binary()) -> 'ok'. +-spec update_presence(kz_types:server_ref(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. update_presence(ServerRef, PresenceId, PresenceState) -> gen_statem:cast(ServerRef, {'update_presence', PresenceId, PresenceState}). @@ -299,7 +299,7 @@ update_presence(ServerRef, PresenceId, PresenceState) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec agent_logout(server_ref()) -> 'ok'. +-spec agent_logout(kz_types:server_ref()) -> 'ok'. agent_logout(ServerRef) -> gen_statem:cast(ServerRef, {'agent_logout'}). @@ -310,10 +310,10 @@ agent_logout(ServerRef) -> -spec refresh(pid(), kz_json:object()) -> 'ok'. refresh(ServerRef, AgentJObj) -> gen_statem:cast(ServerRef, {'refresh', AgentJObj}). --spec current_call(pid()) -> api_object(). +-spec current_call(pid()) -> kz_term:api_object(). current_call(ServerRef) -> gen_statem:call(ServerRef, 'current_call'). --spec status(pid()) -> kz_proplist(). +-spec status(pid()) -> kz_term:proplist(). status(ServerRef) -> gen_statem:call(ServerRef, 'status'). %%-------------------------------------------------------------------- @@ -323,9 +323,9 @@ status(ServerRef) -> gen_statem:call(ServerRef, 'status'). %% function does not return until Module:init/1 has returned. %% @end %%-------------------------------------------------------------------- --spec start_link(pid(), kz_json:object()) -> startlink_ret(). --spec start_link(pid(), kapps_call:call(), ne_binary()) -> startlink_ret(). --spec start_link(ne_binary(), ne_binary(), pid(), kz_proplist()) -> startlink_ret(). +-spec start_link(pid(), kz_json:object()) -> kz_types:startlink_ret(). +-spec start_link(pid(), kapps_call:call(), kz_term:ne_binary()) -> kz_types:startlink_ret(). +-spec start_link(kz_term:ne_binary(), kz_term:ne_binary(), pid(), kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Supervisor, AgentJObj) when is_pid(Supervisor) -> pvt_start_link(kz_doc:account_id(AgentJObj) @@ -344,7 +344,7 @@ start_link(Supervisor, ThiefCall, _QueueId) -> start_link(AccountId, AgentId, Supervisor, Props) -> pvt_start_link(AccountId, AgentId, Supervisor, Props, 'false'). --spec start_link(pid(), any(), ne_binary(), ne_binary(), any()) -> startlink_ret(). +-spec start_link(pid(), any(), kz_term:ne_binary(), kz_term:ne_binary(), any()) -> kz_types:startlink_ret(). start_link(Supervisor, _AgentJObj, AccountId, AgentId, _Queues) -> pvt_start_link(AccountId, AgentId, Supervisor, [], 'false'). @@ -405,7 +405,7 @@ init([AccountId, AgentId, Supervisor, Props, IsThief]) -> } }. --spec max_failures(ne_binary() | kz_json:object()) -> non_neg_integer(). +-spec max_failures(kz_term:ne_binary() | kz_json:object()) -> non_neg_integer(). max_failures(Account) when is_binary(Account) -> case kz_account:fetch(Account) of {'ok', AccountJObj} -> max_failures(AccountJObj); @@ -414,7 +414,7 @@ max_failures(Account) when is_binary(Account) -> max_failures(JObj) -> kz_json:get_integer_value(?MAX_CONNECT_FAILURES, JObj, ?MAX_FAILURES). --spec wait_for_listener(pid(), pid(), kz_proplist(), boolean()) -> 'ok'. +-spec wait_for_listener(pid(), pid(), kz_term:proplist(), boolean()) -> 'ok'. wait_for_listener(Supervisor, ServerRef, Props, IsThief) -> case acdc_agent_sup:listener(Supervisor) of 'undefined' -> @@ -450,7 +450,7 @@ callback_mode() -> %% @doc %% @end %%-------------------------------------------------------------------- --spec wait(gen_statem:event_type(), any(), state()) -> handle_fsm_ret(state()). +-spec wait(gen_statem:event_type(), any(), state()) -> kz_types:handle_fsm_ret(state()). wait('cast', {'listener', AgentListener, NextState, SyncRef}, #state{account_id=AccountId ,agent_id=AgentId }=State) -> @@ -477,7 +477,7 @@ wait('info', Evt, State) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec sync(gen_statem:event_type(), any(), state()) -> handle_fsm_ret(state()). +-spec sync(gen_statem:event_type(), any(), state()) -> kz_types:handle_fsm_ret(state()). sync('cast', 'send_sync_event', #state{agent_listener=AgentListener ,agent_listener_id=_AProcId }=State) -> @@ -552,7 +552,7 @@ sync('info', Evt, State) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec ready(gen_statem:event_type(), any(), state()) -> handle_fsm_ret(state()). +-spec ready(gen_statem:event_type(), any(), state()) -> kz_types:handle_fsm_ret(state()). ready('cast', {'sync_req', JObj}, #state{agent_listener=AgentListener}=State) -> lager:debug("recv sync_req from ~s", [kz_json:get_value(<<"Server-ID">>, JObj)]), acdc_agent_listener:send_sync_resp(AgentListener, 'ready', JObj), @@ -696,7 +696,7 @@ ready('info', Evt, State) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec ringing(gen_statem:event_type(), any(), state()) -> handle_fsm_ret(state()). +-spec ringing(gen_statem:event_type(), any(), state()) -> kz_types:handle_fsm_ret(state()). ringing('cast', {'member_connect_req', _}, State) -> {'next_state', 'ringing', State}; ringing('cast', {'member_connect_win', JObj}, #state{agent_listener=AgentListener}=State) -> @@ -955,7 +955,7 @@ ringing('info', Evt, State) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec answered(gen_statem:event_type(), any(), state()) -> handle_fsm_ret(state()). +-spec answered(gen_statem:event_type(), any(), state()) -> kz_types:handle_fsm_ret(state()). answered('cast', {'member_connect_req', _}, State) -> {'next_state', 'answered', State}; answered('cast', {'member_connect_win', JObj}, #state{agent_listener=AgentListener}=State) -> @@ -1124,7 +1124,7 @@ answered('info', Evt, State) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec wrapup(gen_statem:event_type(), any(), state()) -> handle_fsm_ret(state()). +-spec wrapup(gen_statem:event_type(), any(), state()) -> kz_types:handle_fsm_ret(state()). wrapup('cast', {'pause', Timeout}, #state{account_id=AccountId ,agent_id=AgentId ,agent_listener=AgentListener @@ -1192,7 +1192,7 @@ wrapup('info', Evt, State) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec paused(gen_statem:event_type(), any(), state()) -> handle_fsm_ret(state()). +-spec paused(gen_statem:event_type(), any(), state()) -> kz_types:handle_fsm_ret(state()). paused('cast', {'sync_req', JObj}, #state{agent_listener=AgentListener ,pause_ref=Ref }=State) -> @@ -1249,7 +1249,7 @@ paused('info', Evt, State) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec outbound(gen_statem:event_type(), any(), state()) -> handle_fsm_ret(state()). +-spec outbound(gen_statem:event_type(), any(), state()) -> kz_types:handle_fsm_ret(state()). outbound('cast', {'channel_hungup', CallId, Cause}, #state{agent_listener=AgentListener ,outbound_call_ids=OutboundCallIds }=State) -> @@ -1335,7 +1335,7 @@ outbound('info', Evt, State) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec handle_event(any(), atom(), state()) -> handle_fsm_ret(state()). +-spec handle_event(any(), atom(), state()) -> kz_types:handle_fsm_ret(state()). handle_event({'agent_logout'}=Event, StateName, #state{agent_state_updates=Queue}=State) -> case valid_state_for_logout(StateName) of 'true' -> handle_agent_logout(State); @@ -1410,7 +1410,7 @@ handle_event(Event, StateName, State) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), atom(), state()) -> handle_fsm_ret(state()). +-spec handle_info(any(), atom(), state()) -> kz_types:handle_fsm_ret(state()). handle_info({'timeout', _Ref, ?SYNC_RESPONSE_MESSAGE}=Msg, StateName, State) -> gen_statem:cast(self(), Msg), {'next_state', StateName, State}; @@ -1512,20 +1512,20 @@ start_sync_timer(P) -> start_resync_timer() -> erlang:start_timer(?RESYNC_RESPONSE_TIMEOUT, self(), ?RESYNC_RESPONSE_MESSAGE). --spec start_pause_timer(pos_integer()) -> api_reference(). +-spec start_pause_timer(pos_integer()) -> kz_term:api_reference(). start_pause_timer('undefined') -> start_pause_timer(1); start_pause_timer(0) -> 'undefined'; start_pause_timer(Timeout) -> erlang:start_timer(Timeout * 1000, self(), ?PAUSE_MESSAGE). --spec call_id(kz_json:object()) -> api_binary(). +-spec call_id(kz_json:object()) -> kz_term:api_binary(). call_id(JObj) -> case kz_json:get_value(<<"Call-ID">>, JObj) of 'undefined' -> kz_json:get_value([<<"Call">>, <<"Call-ID">>], JObj); CallId -> CallId end. --spec hangup_cause(kz_json:object()) -> ne_binary(). +-spec hangup_cause(kz_json:object()) -> kz_term:ne_binary(). hangup_cause(JObj) -> case kz_json:get_value(<<"Hangup-Cause">>, JObj) of 'undefined' -> <<"unknown">>; @@ -1533,7 +1533,7 @@ hangup_cause(JObj) -> end. %% returns time left in seconds --spec time_left(reference() | 'false' | api_integer()) -> api_integer(). +-spec time_left(reference() | 'false' | kz_term:api_integer()) -> kz_term:api_integer(). time_left(Ref) when is_reference(Ref) -> time_left(erlang:read_timer(Ref)); time_left('false') -> 'undefined'; @@ -1579,8 +1579,8 @@ clear_call(#state{statem_call_id=StateMCallId ,caller_exit_key = <<"#">> }. --spec current_call(kapps_call:call() | 'undefined', atom(), ne_binary(), 'undefined' | kz_now()) -> - api_object(). +-spec current_call(kapps_call:call() | 'undefined', atom(), kz_term:ne_binary(), 'undefined' | kz_time:now()) -> + kz_term:api_object(). current_call('undefined', _, _, _) -> 'undefined'; current_call(Call, AgentState, QueueId, Start) -> kz_json:from_list([{<<"call_id">>, kapps_call:call_id(Call)} @@ -1593,7 +1593,7 @@ current_call(Call, AgentState, QueueId, Start) -> ,{<<"queue_id">>, QueueId} ]). --spec elapsed('undefined' | kz_now()) -> api_integer(). +-spec elapsed('undefined' | kz_time:now()) -> kz_term:api_integer(). elapsed('undefined') -> 'undefined'; elapsed(Start) -> kz_time:elapsed_s(Start). @@ -1625,8 +1625,8 @@ hangup_call(#state{agent_listener=AgentListener maybe_notify(Ns, ?NOTIFY_HANGUP, State), wrapup_timer(State). --spec maybe_stop_timer(api_reference()) -> 'ok'. --spec maybe_stop_timer(api_reference(), boolean()) -> 'ok'. +-spec maybe_stop_timer(kz_term:api_reference()) -> 'ok'. +-spec maybe_stop_timer(kz_term:api_reference(), boolean()) -> 'ok'. maybe_stop_timer('undefined') -> 'ok'; maybe_stop_timer(ConnRef) when is_reference(ConnRef) -> _ = erlang:cancel_timer(ConnRef), @@ -1635,7 +1635,7 @@ maybe_stop_timer(ConnRef) when is_reference(ConnRef) -> maybe_stop_timer(TimerRef, 'true') -> maybe_stop_timer(TimerRef); maybe_stop_timer(_, 'false') -> 'ok'. --spec start_outbound_call_handling(ne_binary() | kapps_call:call(), state()) -> state(). +-spec start_outbound_call_handling(kz_term:ne_binary() | kapps_call:call(), state()) -> state(). start_outbound_call_handling(CallId, #state{agent_listener=AgentListener ,account_id=AccountId ,agent_id=AgentId @@ -1649,7 +1649,7 @@ start_outbound_call_handling(CallId, #state{agent_listener=AgentListener start_outbound_call_handling(Call, State) -> start_outbound_call_handling(kapps_call:call_id(Call), State). --spec outbound_hungup(state()) -> handle_fsm_ret(state()). +-spec outbound_hungup(state()) -> kz_types:handle_fsm_ret(state()). outbound_hungup(#state{agent_listener=AgentListener ,wrapup_ref=WRef ,pause_ref=PRef @@ -1670,7 +1670,7 @@ outbound_hungup(State) -> lager:debug("agent still has some outbound calls active"), {'next_state', 'outbound', State}. --spec missed_reason(ne_binary()) -> ne_binary(). +-spec missed_reason(kz_term:ne_binary()) -> kz_term:ne_binary(). missed_reason(<<"-ERR ", Reason/binary>>) -> missed_reason(binary:replace(Reason, <<"\n">>, <<>>, ['global'])); missed_reason(<<"ALLOTTED_TIMEOUT">>) -> <<"timeout">>; @@ -1679,16 +1679,16 @@ missed_reason(<<"CALL_REJECTED">>) -> <<"rejected">>; missed_reason(<<"USER_BUSY">>) -> <<"rejected">>; missed_reason(Reason) -> Reason. --spec find_username(kz_json:object()) -> api_binary(). +-spec find_username(kz_json:object()) -> kz_term:api_binary(). find_username(EP) -> find_sip_username(EP, kz_device:sip_username(EP)). --spec find_sip_username(kz_json:object(), api_binary()) -> api_binary(). +-spec find_sip_username(kz_json:object(), kz_term:api_binary()) -> kz_term:api_binary(). find_sip_username(EP, 'undefined') -> kz_json:get_value(<<"To-User">>, EP); find_sip_username(_EP, Username) -> Username. --spec find_endpoint_id(kz_json:object()) -> api_binary(). --spec find_endpoint_id(kz_json:object(), api_binary()) -> api_binary(). +-spec find_endpoint_id(kz_json:object()) -> kz_term:api_binary(). +-spec find_endpoint_id(kz_json:object(), kz_term:api_binary()) -> kz_term:api_binary(). find_endpoint_id(EP) -> find_endpoint_id(EP, kz_doc:id(EP)). @@ -1696,7 +1696,7 @@ find_endpoint_id(EP) -> find_endpoint_id(EP, 'undefined') -> kz_json:get_value(<<"Endpoint-ID">>, EP); find_endpoint_id(_EP, EPId) -> EPId. --spec monitor_endpoint(kz_json:object(), ne_binary(), server_ref()) -> any(). +-spec monitor_endpoint(kz_json:object(), kz_term:ne_binary(), kz_types:server_ref()) -> any(). monitor_endpoint(EP, AccountId, AgentListener) -> %% Bind for outbound call requests acdc_agent_listener:add_endpoint_bindings(AgentListener @@ -1707,7 +1707,7 @@ monitor_endpoint(EP, AccountId, AgentListener) -> catch gproc:reg(?ENDPOINT_UPDATE_REG(AccountId, find_endpoint_id(EP))), catch gproc:reg(?NEW_CHANNEL_REG(AccountId, find_username(EP))). --spec unmonitor_endpoint(kz_json:object(), ne_binary(), server_ref()) -> any(). +-spec unmonitor_endpoint(kz_json:object(), kz_term:ne_binary(), kz_types:server_ref()) -> any(). unmonitor_endpoint(EP, AccountId, AgentListener) -> %% Bind for outbound call requests acdc_agent_listener:remove_endpoint_bindings(AgentListener @@ -1718,7 +1718,7 @@ unmonitor_endpoint(EP, AccountId, AgentListener) -> catch gproc:unreg(?ENDPOINT_UPDATE_REG(AccountId, kz_doc:id(EP))), catch gproc:unreg(?NEW_CHANNEL_REG(AccountId, find_username(EP))). --spec maybe_add_endpoint(ne_binary(), kz_json:object(), kz_json:objects(), ne_binary(), server_ref()) -> any(). +-spec maybe_add_endpoint(kz_term:ne_binary(), kz_json:object(), kz_json:objects(), kz_term:ne_binary(), kz_types:server_ref()) -> any(). maybe_add_endpoint(EPId, EP, EPs, AccountId, AgentListener) -> case lists:partition(fun(E) -> kz_doc:id(E) =:= EPId end, EPs) of {[], _} -> @@ -1727,7 +1727,7 @@ maybe_add_endpoint(EPId, EP, EPs, AccountId, AgentListener) -> {_, _} -> EPs end. --spec maybe_remove_endpoint(ne_binary(), kz_json:objects(), ne_binary(), server_ref()) -> kz_json:objects(). +-spec maybe_remove_endpoint(kz_term:ne_binary(), kz_json:objects(), kz_term:ne_binary(), kz_types:server_ref()) -> kz_json:objects(). maybe_remove_endpoint(EPId, EPs, AccountId, AgentListener) -> case lists:partition(fun(EP) -> kz_doc:id(EP) =:= EPId end, EPs) of {[], _} -> EPs; %% unknown endpoint @@ -1737,7 +1737,7 @@ maybe_remove_endpoint(EPId, EPs, AccountId, AgentListener) -> EPs1 end. --spec get_endpoints(kz_json:objects(), server_ref(), kapps_call:call(), api_binary(), api_binary()) -> +-spec get_endpoints(kz_json:objects(), kz_types:server_ref(), kapps_call:call(), kz_term:api_binary(), kz_term:api_binary()) -> {'ok', kz_json:objects()} | {'error', any()}. get_endpoints(OrigEPs, AgentListener, Call, AgentId, QueueId) -> @@ -1812,11 +1812,11 @@ get_method(Ns) -> M -> standardize_method(kz_term:to_lower_binary(M)) end. --spec standardize_method(ne_binary()) -> 'get' | 'post'. +-spec standardize_method(kz_term:ne_binary()) -> 'get' | 'post'. standardize_method(<<"post">>) -> 'post'; standardize_method(_) -> 'get'. --spec notify(ne_binary(), 'get' | 'post', ne_binary(), state()) -> 'ok'. +-spec notify(kz_term:ne_binary(), 'get' | 'post', kz_term:ne_binary(), state()) -> 'ok'. notify(Url, Method, Key, #state{account_id=AccountId ,agent_id=AgentId ,member_call=MemberCall @@ -1837,7 +1837,7 @@ notify(Url, Method, Key, #state{account_id=AccountId ]), notify(Url, Method, Data). --spec notify(ne_binary(), 'get' | 'post', kz_json:object()) -> 'ok'. +-spec notify(kz_term:ne_binary(), 'get' | 'post', kz_json:object()) -> 'ok'. notify(Url, 'post', Data) -> notify(Url, [], 'post', kz_json:encode(Data) ,[{'content_type', "application/json"}] @@ -1847,7 +1847,7 @@ notify(Url, 'get', Data) -> ,[], 'get', <<>>, [] ). --spec notify(iolist(), [], 'get' | 'post', binary(), kz_proplist()) -> 'ok'. +-spec notify(iolist(), [], 'get' | 'post', binary(), kz_term:proplist()) -> 'ok'. notify(Uri, Headers, Method, Body, Opts) -> Options = [{'connect_timeout', 200} ,{'timeout', 1000} @@ -1861,21 +1861,21 @@ notify(Uri, Headers, Method, Body, Opts) -> lager:debug("failed to send request to ~s: ~p", [Uri, _E]) end. --spec cdr_url(kz_json:object()) -> api_binary(). +-spec cdr_url(kz_json:object()) -> kz_term:api_binary(). cdr_url(JObj) -> case kz_json:get_value([<<"Notifications">>, ?NOTIFY_CDR], JObj) of 'undefined' -> kz_json:get_ne_value(<<"CDR-Url">>, JObj); Url -> Url end. --spec recording_url(kz_json:object()) -> api_binary(). +-spec recording_url(kz_json:object()) -> kz_term:api_binary(). recording_url(JObj) -> case kz_json:get_value([<<"Notifications">>, ?NOTIFY_RECORDING], JObj) of 'undefined' -> kz_json:get_ne_value(<<"Recording-URL">>, JObj); Url -> Url end. --spec uri(ne_binary(), iolist()) -> iolist(). +-spec uri(kz_term:ne_binary(), iolist()) -> iolist(). uri(URI, QueryString) -> case kz_http_util:urlsplit(URI) of {Scheme, Host, Path, <<>>, Fragment} -> @@ -1884,7 +1884,7 @@ uri(URI, QueryString) -> kz_http_util:urlunsplit({Scheme, Host, Path, <>, Fragment}) end. --spec apply_state_updates(state()) -> handle_fsm_ret(state()). +-spec apply_state_updates(state()) -> kz_types:handle_fsm_ret(state()). apply_state_updates(#state{agent_state_updates=Q ,wrapup_ref=WRef ,pause_ref=PRef @@ -1900,7 +1900,7 @@ apply_state_updates(#state{agent_state_updates=Q lager:debug("default state for applying state updates ~s", [FoldDefaultState]), apply_state_updates_fold({'next_state', FoldDefaultState, State#state{agent_state_updates=[]}}, lists:reverse(Q)). --spec apply_state_updates_fold({'next_state', atom(), state()}, list()) -> handle_fsm_ret(state()). +-spec apply_state_updates_fold({'next_state', atom(), state()}, list()) -> kz_types:handle_fsm_ret(state()). apply_state_updates_fold({_, StateName, #state{account_id=AccountId ,agent_id=AgentId ,agent_listener=AgentListener @@ -1936,14 +1936,14 @@ valid_state_for_logout('wrapup') -> 'true'; valid_state_for_logout('paused') -> 'true'; valid_state_for_logout(_) -> 'false'. --spec handle_agent_logout(state()) -> handle_fsm_ret(state()). +-spec handle_agent_logout(state()) -> kz_types:handle_fsm_ret(state()). handle_agent_logout(#state{account_id = AccountId ,agent_id = AgentId }=State) -> acdc_agent_stats:agent_logged_out(AccountId, AgentId), {'stop', 'normal', State}. --spec handle_presence_update(ne_binary(), ne_binary(), state()) -> 'ok'. +-spec handle_presence_update(kz_term:ne_binary(), kz_term:ne_binary(), state()) -> 'ok'. handle_presence_update(PresenceId, PresenceState, #state{agent_id = AgentId ,account_id = AccountId }) -> @@ -1952,7 +1952,7 @@ handle_presence_update(PresenceId, PresenceState, #state{agent_id = AgentId acdc_agent_listener:maybe_update_presence_id(Listener, PresenceId), acdc_agent_listener:presence_update(Listener, PresenceState). --spec handle_resume(state()) -> handle_fsm_ret(state()). +-spec handle_resume(state()) -> kz_types:handle_fsm_ret(state()). handle_resume(#state{agent_listener=AgentListener ,pause_ref=Ref }=State) -> @@ -1965,7 +1965,7 @@ handle_resume(#state{agent_listener=AgentListener acdc_agent_listener:presence_update(AgentListener, ?PRESENCE_GREEN), {'next_state', 'ready', State#state{pause_ref='undefined'}}. --spec handle_pause(integer(), state()) -> handle_fsm_ret(state()). +-spec handle_pause(integer(), state()) -> kz_types:handle_fsm_ret(state()). handle_pause(Timeout, #state{agent_listener=AgentListener}=State) -> acdc_agent_listener:presence_update(AgentListener, ?PRESENCE_RED_FLASH), Ref = start_pause_timer(Timeout), diff --git a/applications/acdc/src/acdc_agent_handler.erl b/applications/acdc/src/acdc_agent_handler.erl index c8217247e2b..283034bfdac 100644 --- a/applications/acdc/src/acdc_agent_handler.erl +++ b/applications/acdc/src/acdc_agent_handler.erl @@ -28,7 +28,7 @@ -define(DEFAULT_PAUSE, kapps_config:get_integer(?CONFIG_CAT, <<"default_agent_pause_timeout">>, 600)). --spec handle_status_update(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_status_update(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_status_update(JObj, _Props) -> _ = kz_util:put_callid(JObj), AccountId = kz_json:get_value(<<"Account-ID">>, JObj), @@ -56,14 +56,14 @@ handle_status_update(JObj, _Props) -> ) end. --spec login(ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec login(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. login(AccountId, AgentId, JObj) -> case maybe_start_agent(AccountId, AgentId, JObj) of 'fail' -> login_fail(JObj); _ -> login_success(JObj) end. --spec maybe_agent_queue_change(ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec maybe_agent_queue_change(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. maybe_agent_queue_change(AccountId, AgentId, <<"login_queue">>, QueueId, JObj) -> lager:debug("queue login for agent ~s into ~s", [AgentId, QueueId]), case maybe_start_agent(AccountId, AgentId, JObj) of @@ -79,7 +79,7 @@ maybe_agent_queue_change(AccountId, AgentId, <<"logout_queue">>, QueueId, JObj) acdc_agent_fsm:rm_acdc_queue(acdc_agent_sup:fsm(Sup), QueueId) end. --spec maybe_start_agent(ne_binary(), ne_binary(), kz_json:object()) -> pid() | 'fail'. +-spec maybe_start_agent(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> pid() | 'fail'. maybe_start_agent(AccountId, AgentId, JObj) -> try maybe_start_agent(AccountId, AgentId) of {'ok', Sup} -> @@ -124,7 +124,7 @@ login_resp(JObj, Status) -> kapi_acdc_agent:publish_login_resp(ServerID, Prop) end. --spec maybe_start_agent(api_binary(), api_binary()) -> +-spec maybe_start_agent(kz_term:api_binary(), kz_term:api_binary()) -> {'ok', pid()} | {'exists', pid()} | {'error', any()}. @@ -180,17 +180,17 @@ maybe_resume_agent(AccountId, AgentId, JObj) -> acdc_agent_fsm:resume(FSM) end. --spec handle_sync_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_sync_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_sync_req(JObj, Props) -> 'true' = kapi_acdc_agent:sync_req_v(JObj), acdc_agent_fsm:sync_req(props:get_value('fsm_pid', Props), JObj). --spec handle_sync_resp(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_sync_resp(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_sync_resp(JObj, Props) -> 'true' = kapi_acdc_agent:sync_resp_v(JObj), acdc_agent_fsm:sync_resp(props:get_value('fsm_pid', Props), JObj). --spec handle_call_event(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_call_event(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_call_event(JObj, Props) -> _ = kz_util:put_callid(JObj), FSM = props:get_value('fsm_pid', Props), @@ -207,7 +207,7 @@ handle_call_event(JObj, Props) -> end end. --spec handle_call_event(ne_binary(), ne_binary(), server_ref(), kz_json:object(), kz_proplist()) -> any(). +-spec handle_call_event(kz_term:ne_binary(), kz_term:ne_binary(), kz_types:server_ref(), kz_json:object(), kz_term:proplist()) -> any(). handle_call_event(Category, <<"CHANNEL_DESTROY">> = Name, FSM, JObj, Props) -> Urls = props:get_value('cdr_urls', Props), CallId = kz_json:get_value(<<"Call-ID">>, JObj), @@ -222,13 +222,13 @@ handle_call_event(Category, <<"CHANNEL_DESTROY">> = Name, FSM, JObj, Props) -> handle_call_event(Category, Name, FSM, JObj, _) -> acdc_agent_fsm:call_event(FSM, Category, Name, JObj). --spec handle_new_channel(kz_json:object(), ne_binary()) -> 'ok'. +-spec handle_new_channel(kz_json:object(), kz_term:ne_binary()) -> 'ok'. handle_new_channel(JObj, AccountId) -> 'true' = kapi_call:event_v(JObj), _ = kz_util:put_callid(JObj), handle_new_channel_acct(JObj, AccountId). --spec handle_new_channel_acct(kz_json:object(), api_binary()) -> 'ok'. +-spec handle_new_channel_acct(kz_json:object(), kz_term:api_binary()) -> 'ok'. handle_new_channel_acct(_, 'undefined') -> 'ok'; handle_new_channel_acct(JObj, AccountId) -> FromUser = hd(binary:split(kz_json:get_value(<<"From">>, JObj), <<"@">>)), @@ -248,7 +248,7 @@ handle_new_channel_acct(JObj, AccountId) -> _ -> lager:debug("invalid call direction for call ~s", [CallId]) end. --spec handle_originate_resp(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_originate_resp(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_originate_resp(JObj, Props) -> case kz_json:get_value(<<"Event-Name">>, JObj) of <<"originate_resp">> -> @@ -262,8 +262,8 @@ handle_originate_resp(JObj, Props) -> acdc_agent_fsm:originate_uuid(props:get_value('fsm_pid', Props), JObj) end. --spec handle_member_message(kz_json:object(), kz_proplist()) -> 'ok'. --spec handle_member_message(kz_json:object(), kz_proplist(), ne_binary()) -> 'ok'. +-spec handle_member_message(kz_json:object(), kz_term:proplist()) -> 'ok'. +-spec handle_member_message(kz_json:object(), kz_term:proplist(), kz_term:ne_binary()) -> 'ok'. handle_member_message(JObj, Props) -> handle_member_message(JObj, Props, kz_json:get_value(<<"Event-Name">>, JObj)). @@ -276,8 +276,8 @@ handle_member_message(JObj, Props, <<"connect_win">>) -> handle_member_message(_, _, EvtName) -> lager:debug("not handling member event ~s", [EvtName]). --spec handle_agent_message(kz_json:object(), kz_proplist()) -> 'ok'. --spec handle_agent_message(kz_json:object(), kz_proplist(), ne_binary()) -> 'ok'. +-spec handle_agent_message(kz_json:object(), kz_term:proplist()) -> 'ok'. +-spec handle_agent_message(kz_json:object(), kz_term:proplist(), kz_term:ne_binary()) -> 'ok'. handle_agent_message(JObj, Props) -> handle_agent_message(JObj, Props, kz_json:get_value(<<"Event-Name">>, JObj)). @@ -287,12 +287,12 @@ handle_agent_message(JObj, Props, <<"connect_timeout">>) -> handle_agent_message(_, _, _EvtName) -> lager:debug("not handling agent event ~s", [_EvtName]). --spec handle_config_change(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_config_change(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_config_change(JObj, _Props) -> 'true' = kapi_conf:doc_update_v(JObj), handle_change(JObj, kz_json:get_value(<<"Type">>, JObj)). --spec handle_change(kz_json:object(), ne_binary()) -> 'ok'. +-spec handle_change(kz_json:object(), kz_term:ne_binary()) -> 'ok'. handle_change(JObj, <<"user">>) -> handle_agent_change(kz_json:get_value(<<"Database">>, JObj) ,kz_json:get_value(<<"Account-ID">>, JObj) @@ -383,7 +383,7 @@ handle_agent_change(_, AccountId, AgentId, ?DOC_DELETED) -> acdc_agent_stats:agent_logged_out(AccountId, AgentId) end. --spec handle_presence_probe(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_presence_probe(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_presence_probe(JObj, _Props) -> 'true' = kapi_presence:probe_v(JObj), Realm = kz_json:get_value(<<"Realm">>, JObj), @@ -418,7 +418,7 @@ send_probe(JObj, State) -> ], kapi_presence:publish_update(PresenceUpdate). --spec handle_destroy(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_destroy(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_destroy(JObj, Props) -> 'true' = kapi_call:event_v(JObj), FSM = props:get_value('fsm_pid', Props), @@ -430,7 +430,7 @@ presence_id(JObj, AgentId) -> lager:debug("find presence in ~p", [JObj]), kz_json:get_value(<<"Presence-ID">>, JObj, AgentId). --spec presence_state(kz_json:object(), api_binary()) -> api_binary(). +-spec presence_state(kz_json:object(), kz_term:api_binary()) -> kz_term:api_binary(). presence_state(JObj, State) -> kz_json:get_value(<<"Presence-State">>, JObj, State). diff --git a/applications/acdc/src/acdc_agent_listener.erl b/applications/acdc/src/acdc_agent_listener.erl index c6dbae09b93..58863f02b2a 100644 --- a/applications/acdc/src/acdc_agent_listener.erl +++ b/applications/acdc/src/acdc_agent_listener.erl @@ -63,7 +63,7 @@ ,code_change/3 ]). --type config() :: {ne_binary(), ne_binary(), ne_binary()}. +-type config() :: {kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()}. -export_type([config/0]). -include("acdc.hrl"). @@ -71,27 +71,27 @@ -define(SERVER, ?MODULE). -record(state, {call :: kapps_call:call() | 'undefined' - ,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() | '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 :: api_reference() - ,sync_resp :: api_object() % furthest along resp + ,acdc_queue_id :: kz_term:api_ne_binary() % the ACDc Queue ID + ,msg_queue_id :: kz_term:api_ne_binary() % the AMQP Queue ID of the ACDc Queue process + ,agent_id :: kz_term:api_ne_binary() + ,acct_db :: kz_term:api_ne_binary() + ,acct_id :: kz_term:api_ne_binary() + ,fsm_pid :: kz_term:api_pid() + ,agent_queues = [] :: kz_term:ne_binaries() + ,last_connect :: kz_time:now() | 'undefined' % last connection + ,last_attempt :: kz_time:now() | 'undefined' % last attempt to connect + ,my_id :: kz_term:ne_binary() + ,my_q :: kz_term:api_binary() % AMQP queue name + ,timer_ref :: kz_term:api_reference() + ,sync_resp :: kz_term:api_object() % furthest along resp ,supervisor :: pid() ,record_calls = 'false' :: boolean() - ,recording_url :: api_binary() %% where to send recordings after the call + ,recording_url :: kz_term:api_binary() %% where to send recordings after the call ,is_thief = 'false' :: boolean() ,agent :: agent() - ,agent_call_ids = [] :: api_binaries() | kz_proplist() + ,agent_call_ids = [] :: kz_term:api_binaries() | kz_term:proplist() ,cdr_urls = dict:new() :: dict:dict() %% {CallId, Url} - ,agent_presence_id :: api_binary() + ,agent_presence_id :: kz_term:api_binary() }). -type state() :: #state{}. @@ -170,9 +170,9 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(pid(), kz_json:object()) -> startlink_ret(). --spec start_link(pid(), kz_json:object(), ne_binary(), ne_binary(), ne_binaries()) -> startlink_ret(). --spec start_link(pid(), kapps_call:call(), ne_binary()) -> startlink_ret(). +-spec start_link(pid(), kz_json:object()) -> kz_types:startlink_ret(). +-spec start_link(pid(), kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binaries()) -> kz_types:startlink_ret(). +-spec start_link(pid(), kapps_call:call(), kz_term:ne_binary()) -> kz_types:startlink_ret(). start_link(Supervisor, AgentJObj) -> AgentId = kz_doc:id(AgentJObj), AcctId = account_id(AgentJObj), @@ -207,7 +207,7 @@ stop(Srv) -> gen_listener:cast(Srv, {'stop_agent', self()}). member_connect_resp(Srv, ReqJObj) -> gen_listener:cast(Srv, {'member_connect_resp', ReqJObj}). --spec member_connect_retry(pid(), ne_binary() | kz_json:object()) -> 'ok'. +-spec member_connect_retry(pid(), kz_term:ne_binary() | kz_json:object()) -> 'ok'. member_connect_retry(Srv, WinOrCallId) -> gen_listener:cast(Srv, {'member_connect_retry', WinOrCallId}). @@ -215,7 +215,7 @@ member_connect_retry(Srv, WinOrCallId) -> agent_timeout(Srv) -> gen_listener:cast(Srv, 'agent_timeout'). -spec member_connect_accepted(pid()) -> 'ok'. --spec member_connect_accepted(pid(), ne_binary()) -> 'ok'. +-spec member_connect_accepted(pid(), kz_term:ne_binary()) -> 'ok'. member_connect_accepted(Srv) -> gen_listener:cast(Srv, {'member_connect_accepted'}). member_connect_accepted(Srv, ACallId) -> @@ -226,24 +226,24 @@ hangup_call(Srv) -> gen_listener:cast(Srv, {'hangup_call'}). -spec bridge_to_member(pid(), kapps_call:call(), kz_json:object() - ,kz_json:objects(), api_binary(), api_binary() + ,kz_json:objects(), kz_term:api_binary(), kz_term:api_binary() ) -> 'ok'. bridge_to_member(Srv, Call, WinJObj, EPs, CDRUrl, RecordingUrl) -> gen_listener:cast(Srv, {'bridge_to_member', Call, WinJObj, EPs, CDRUrl, RecordingUrl}). --spec monitor_call(pid(), kapps_call:call(), api_binary(), api_binary()) -> 'ok'. +-spec monitor_call(pid(), kapps_call:call(), kz_term:api_binary(), kz_term:api_binary()) -> 'ok'. monitor_call(Srv, Call, CDRUrl, RecordingUrl) -> gen_listener:cast(Srv, {'monitor_call', Call, CDRUrl, RecordingUrl}). --spec channel_hungup(pid(), ne_binary()) -> 'ok'. +-spec channel_hungup(pid(), kz_term:ne_binary()) -> 'ok'. channel_hungup(Srv, CallId) -> gen_listener:cast(Srv, {'channel_hungup', CallId}). --spec unbind_from_events(pid(), ne_binary()) -> 'ok'. +-spec unbind_from_events(pid(), kz_term:ne_binary()) -> 'ok'. unbind_from_events(Srv, CallId) -> gen_listener:cast(Srv, {'unbind_from_events', CallId}). --spec rebind_events(pid(), ne_binary(), ne_binary()) -> 'ok'. +-spec rebind_events(pid(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. rebind_events(Srv, OldCallId, NewCallId) -> gen_listener:cast(Srv, {'rebind_events', OldCallId, NewCallId}). @@ -251,11 +251,11 @@ rebind_events(Srv, OldCallId, NewCallId) -> originate_execute(Srv, JObj) -> gen_listener:cast(Srv, {'originate_execute', JObj}). --spec originate_uuid(pid(), ne_binary(), ne_binary()) -> 'ok'. +-spec originate_uuid(pid(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. originate_uuid(Srv, UUID, CtlQ) -> gen_listener:cast(Srv, {'originate_uuid', UUID, CtlQ}). --spec outbound_call(pid(), ne_binary()) -> 'ok'. +-spec outbound_call(pid(), kz_term:ne_binary()) -> 'ok'. outbound_call(Srv, CallId) -> gen_listener:cast(Srv, {'outbound_call', CallId}). @@ -270,8 +270,8 @@ send_agent_busy(Srv) -> -spec send_sync_req(pid()) -> 'ok'. send_sync_req(Srv) -> gen_listener:cast(Srv, {'send_sync_req'}). --spec send_sync_resp(pid(), text(), kz_json:object()) -> 'ok'. --spec send_sync_resp(pid(), text(), kz_json:object(), kz_proplist()) -> 'ok'. +-spec send_sync_resp(pid(), kz_term:text(), kz_json:object()) -> 'ok'. +-spec send_sync_resp(pid(), kz_term:text(), kz_json:object(), kz_term:proplist()) -> 'ok'. send_sync_resp(Srv, Status, ReqJObj) -> send_sync_resp(Srv, Status, ReqJObj, []). send_sync_resp(Srv, Status, ReqJObj, Options) -> gen_listener:cast(Srv, {'send_sync_resp', Status, ReqJObj, Options}). @@ -279,7 +279,7 @@ send_sync_resp(Srv, Status, ReqJObj, Options) -> -spec config(pid()) -> config(). config(Srv) -> gen_listener:call(Srv, 'config'). --spec refresh_config(pid(), api_ne_binaries(), fsm_state_name()) -> 'ok'. +-spec refresh_config(pid(), kz_term:api_ne_binaries(), fsm_state_name()) -> 'ok'. refresh_config(_, 'undefined', _) -> 'ok'; refresh_config(Srv, Qs, StateName) -> gen_listener:cast(Srv, {'refresh_config', Qs, StateName}). @@ -291,16 +291,16 @@ agent_info(Srv, Field) -> gen_listener:call(Srv, {'agent_info', Field}). send_status_resume(Srv) -> gen_listener:cast(Srv, {'send_status_update', 'resume'}). --spec add_acdc_queue(pid(), ne_binary(), fsm_state_name()) -> 'ok'. +-spec add_acdc_queue(pid(), kz_term:ne_binary(), fsm_state_name()) -> 'ok'. add_acdc_queue(Srv, Q, StateName) -> gen_listener:cast(Srv, {'add_acdc_queue', Q, StateName}). --spec rm_acdc_queue(pid(), ne_binary()) -> 'ok'. +-spec rm_acdc_queue(pid(), kz_term:ne_binary()) -> 'ok'. rm_acdc_queue(Srv, Q) -> gen_listener:cast(Srv, {'rm_acdc_queue', Q}). -spec call_status_req(pid()) -> 'ok'. --spec call_status_req(pid(), ne_binary()) -> 'ok'. +-spec call_status_req(pid(), kz_term:ne_binary()) -> 'ok'. call_status_req(Srv) -> gen_listener:cast(Srv, 'call_status_req'). call_status_req(Srv, CallId) -> @@ -310,7 +310,7 @@ call_status_req(Srv, CallId) -> fsm_started(Srv, FSM) -> gen_listener:cast(Srv, {'fsm_started', FSM}). --spec add_endpoint_bindings(pid(), ne_binary(), api_ne_binary()) -> 'ok'. +-spec add_endpoint_bindings(pid(), kz_term:ne_binary(), kz_term:api_ne_binary()) -> 'ok'. add_endpoint_bindings(_Srv, _Realm, 'undefined') -> lager:debug("ignoring adding endpoint bindings for undefined user @ ~s", [_Realm]); add_endpoint_bindings(Srv, Realm, User) -> @@ -319,47 +319,47 @@ add_endpoint_bindings(Srv, Realm, User) -> ,{'user', User} ]). --spec remove_endpoint_bindings(pid(), ne_binary(), ne_binary()) -> 'ok'. +-spec remove_endpoint_bindings(pid(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. remove_endpoint_bindings(Srv, Realm, User) -> lager:debug("removing route bindings to ~p for endpoint ~s@~s", [Srv, User, Realm]), gen_listener:rm_binding(Srv, 'route', [{'realm', Realm} ,{'user', User} ]). --spec remove_cdr_urls(pid(), ne_binary()) -> 'ok'. +-spec remove_cdr_urls(pid(), kz_term:ne_binary()) -> 'ok'. remove_cdr_urls(Srv, CallId) -> gen_listener:cast(Srv, {'remove_cdr_urls', CallId}). -spec logout_agent(pid()) -> 'ok'. logout_agent(Srv) -> gen_listener:cast(Srv, 'logout_agent'). --spec maybe_update_presence_id(pid(), api_ne_binary()) -> 'ok'. +-spec maybe_update_presence_id(pid(), kz_term:api_ne_binary()) -> 'ok'. maybe_update_presence_id(_Srv, 'undefined') -> 'ok'; maybe_update_presence_id(Srv, Id) -> gen_listener:cast(Srv, {'presence_id', Id}). --spec maybe_update_presence_state(pid(), api_ne_binary()) -> 'ok'. +-spec maybe_update_presence_state(pid(), kz_term:api_ne_binary()) -> 'ok'. maybe_update_presence_state(_Srv, 'undefined') -> 'ok'; maybe_update_presence_state(Srv, State) -> presence_update(Srv, State). --spec presence_update(pid(), api_ne_binary()) -> 'ok'. +-spec presence_update(pid(), kz_term:api_ne_binary()) -> 'ok'. presence_update(_, 'undefined') -> 'ok'; presence_update(Srv, PresenceState) -> gen_listener:cast(Srv, {'presence_update', PresenceState}). --spec update_agent_status(pid(), ne_binary()) -> 'ok'. +-spec update_agent_status(pid(), kz_term:ne_binary()) -> 'ok'. update_agent_status(Srv, Status) -> gen_listener:cast(Srv, {'update_status', Status}). --spec presence_id(pid()) -> api_binary(). +-spec presence_id(pid()) -> kz_term:api_binary(). presence_id(Srv) -> gen_listener:call(Srv, 'presence_id'). --spec queues(pid()) -> ne_binaries(). +-spec queues(pid()) -> kz_term:ne_binaries(). queues(Srv) -> gen_listener:call(Srv, 'queues'). --spec id(pid()) -> api_binary(). +-spec id(pid()) -> kz_term:api_binary(). id(Srv) -> gen_listener:call(Srv, 'my_id'). @@ -378,7 +378,7 @@ id(Srv) -> %% {stop, Reason} %% @end %%-------------------------------------------------------------------- --spec init([atom() | agent() | ne_binaries()]) -> {'ok', state()}. +-spec init([atom() | agent() | kz_term:ne_binaries()]) -> {'ok', state()}. init([Supervisor, Agent, Queues]) -> AgentId = agent_id(Agent), kz_util:put_callid(AgentId), @@ -410,7 +410,7 @@ init([Supervisor, Agent, Queues]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call('presence_id', _, #state{agent_presence_id=PresenceId}=State) -> {'reply', PresenceId, State, 'hibernate'}; handle_call('queues', _, #state{agent_queues=Queues}=State) -> @@ -438,7 +438,7 @@ handle_call(_Request, _From, #state{}=State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'refresh_config', Qs, StateName}, #state{agent_queues=Queues}=State) -> {Add, Rm} = acdc_agent_util:changed(Queues, Qs), @@ -907,7 +907,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> lager:debug("unhandled message: ~p", [_Info]), {'noreply', State}. @@ -971,12 +971,12 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec is_valid_queue(ne_binary(), ne_binaries()) -> boolean(). +-spec is_valid_queue(kz_term:ne_binary(), kz_term:ne_binaries()) -> boolean(). is_valid_queue(Q, Qs) -> lists:member(Q, Qs). --spec send_member_connect_resp(kz_json:object(), ne_binary() - ,ne_binary(), ne_binary() - , kz_now() | 'undefined' +-spec send_member_connect_resp(kz_json:object(), kz_term:ne_binary() + ,kz_term:ne_binary(), kz_term:ne_binary() + , kz_time:now() | 'undefined' ) -> 'ok'. send_member_connect_resp(JObj, MyQ, AgentId, MyId, LastConn) -> Queue = kz_json:get_value(<<"Server-ID">>, JObj), @@ -991,8 +991,8 @@ send_member_connect_resp(JObj, MyQ, AgentId, MyId, LastConn) -> lager:debug("sending connect_resp to ~s for ~s: ~s", [Queue, call_id(JObj), MyId]), kapi_acdc_queue:publish_member_connect_resp(Queue, Resp). --spec send_member_connect_retry(kz_json:object(), ne_binary(), ne_binary()) -> 'ok'. --spec send_member_connect_retry(ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec send_member_connect_retry(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. +-spec send_member_connect_retry(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. send_member_connect_retry(JObj, MyId, AgentId) -> send_member_connect_retry(kz_json:get_value(<<"Server-ID">>, JObj) ,call_id(JObj) @@ -1011,7 +1011,7 @@ send_member_connect_retry(Queue, CallId, MyId, AgentId) -> ]), kapi_acdc_queue:publish_member_connect_retry(Queue, Resp). --spec send_member_connect_accepted(ne_binary(), ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec send_member_connect_accepted(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. send_member_connect_accepted(Queue, CallId, AcctId, AgentId, MyId) -> Resp = props:filter_undefined([{<<"Call-ID">>, CallId} ,{<<"Account-ID">>, AcctId} @@ -1021,7 +1021,7 @@ send_member_connect_accepted(Queue, CallId, AcctId, AgentId, MyId) -> ]), kapi_acdc_queue:publish_member_connect_accepted(Queue, Resp). --spec send_originate_execute(kz_json:object(), ne_binary()) -> 'ok'. +-spec send_originate_execute(kz_json:object(), kz_term:ne_binary()) -> 'ok'. send_originate_execute(JObj, Q) -> Prop = [{<<"Call-ID">>, kz_json:get_value(<<"Call-ID">>, JObj)} ,{<<"Msg-ID">>, kz_json:get_value(<<"Msg-ID">>, JObj)} @@ -1029,7 +1029,7 @@ send_originate_execute(JObj, Q) -> ], kapi_dialplan:publish_originate_execute(kz_json:get_value(<<"Server-ID">>, JObj), Prop). --spec send_sync_request(ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec send_sync_request(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. send_sync_request(AcctId, AgentId, MyId, MyQ) -> Prop = [{<<"Account-ID">>, AcctId} ,{<<"Agent-ID">>, AgentId} @@ -1059,12 +1059,12 @@ send_status_update(AcctId, AgentId, 'resume') -> kapi_acdc_agent:publish_resume(Update). --spec idle_time('undefined' | kz_now()) -> api_integer(). +-spec idle_time('undefined' | kz_time:now()) -> kz_term:api_integer(). idle_time('undefined') -> 'undefined'; idle_time(T) -> kz_time:elapsed_s(T). --spec call_id(kapps_call:call() | api_object()) -> - api_binary(). +-spec call_id(kapps_call:call() | kz_term:api_object()) -> + kz_term:api_binary(). call_id('undefined') -> 'undefined'; call_id(Call) -> case kapps_call:is_call(Call) of @@ -1079,8 +1079,8 @@ call_id(Call) -> end, 'undefined', Keys) end. --spec maybe_connect_to_agent(ne_binary(), kz_json:objects(), kapps_call:call(), api_integer(), ne_binary(), api_binary()) -> - ne_binaries(). +-spec maybe_connect_to_agent(kz_term:ne_binary(), kz_json:objects(), kapps_call:call(), kz_term:api_integer(), kz_term:ne_binary(), kz_term:api_binary()) -> + kz_term:ne_binaries(). maybe_connect_to_agent(MyQ, EPs, Call, Timeout, AgentId, _CdrUrl) -> MCallId = kapps_call:call_id(Call), kz_util:put_callid(MCallId), @@ -1136,7 +1136,7 @@ maybe_connect_to_agent(MyQ, EPs, Call, Timeout, AgentId, _CdrUrl) -> kapi_resource:publish_originate_req(Prop), ACallIds. --spec outbound_call_id(kapps_call:call() | ne_binary(), ne_binary()) -> ne_binary(). +-spec outbound_call_id(kapps_call:call() | kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). outbound_call_id(CallId, AgentId) when is_binary(CallId) -> Hash = kz_term:to_hex_binary(erlang:md5(CallId)), Rnd = kz_binary:rand_hex(4), @@ -1144,7 +1144,7 @@ outbound_call_id(CallId, AgentId) when is_binary(CallId) -> outbound_call_id(Call, AgentId) -> outbound_call_id(kapps_call:call_id(Call), AgentId). --spec add_queue_binding(ne_binary(), ne_binary(), ne_binary(), fsm_state_name()) -> +-spec add_queue_binding(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), fsm_state_name()) -> 'ok'. add_queue_binding(AcctId, AgentId, QueueId, StateName) -> lager:debug("adding queue binding for ~s", [QueueId]), @@ -1156,7 +1156,7 @@ add_queue_binding(AcctId, AgentId, QueueId, StateName) -> ]), send_availability_update(AcctId, AgentId, QueueId, StateName). --spec rm_queue_binding(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec rm_queue_binding(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. rm_queue_binding(AcctId, AgentId, QueueId) -> lager:debug("removing queue binding for ~s", [QueueId]), gen_listener:rm_binding(self() @@ -1167,14 +1167,14 @@ rm_queue_binding(AcctId, AgentId, QueueId) -> ]), send_agent_unavailable(AcctId, AgentId, QueueId). --spec send_availability_update(ne_binary(), ne_binary(), ne_binary(), fsm_state_name()) -> +-spec send_availability_update(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), fsm_state_name()) -> 'ok'. send_availability_update(AcctId, AgentId, QueueId, 'ready') -> send_agent_available(AcctId, AgentId, QueueId); send_availability_update(AcctId, AgentId, QueueId, _) -> send_agent_busy(AcctId, AgentId, QueueId). --spec send_agent_available(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec send_agent_available(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. send_agent_available(AcctId, AgentId, QueueId) -> Prop = [{<<"Account-ID">>, AcctId} ,{<<"Agent-ID">>, AgentId} @@ -1184,7 +1184,7 @@ send_agent_available(AcctId, AgentId, QueueId) -> ], kapi_acdc_queue:publish_agent_change(Prop). --spec send_agent_busy(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec send_agent_busy(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. send_agent_busy(AcctId, AgentId, QueueId) -> Prop = [{<<"Account-ID">>, AcctId} ,{<<"Agent-ID">>, AgentId} @@ -1194,7 +1194,7 @@ send_agent_busy(AcctId, AgentId, QueueId) -> ], kapi_acdc_queue:publish_agent_change(Prop). --spec send_agent_unavailable(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec send_agent_unavailable(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. send_agent_unavailable(AcctId, AgentId, QueueId) -> Prop = [{<<"Account-ID">>, AcctId} ,{<<"Agent-ID">>, AgentId} @@ -1215,7 +1215,7 @@ update_my_queues_of_change(AcctId, AgentId, Qs) -> ], 'ok'. --spec should_record_endpoints(kz_json:objects(), boolean(), api_boolean()) -> boolean(). +-spec should_record_endpoints(kz_json:objects(), boolean(), kz_term:api_boolean()) -> boolean(). should_record_endpoints(_EPs, 'true', _) -> 'true'; should_record_endpoints(_EPs, 'false', 'true') -> 'true'; should_record_endpoints(EPs, _, _) -> @@ -1223,7 +1223,7 @@ should_record_endpoints(EPs, _, _) -> kz_json:is_true(<<"record_calls">>, EP, 'false') end, EPs). --spec maybe_start_recording(kapps_call:call(), boolean(), ne_binary()) -> 'ok'. +-spec maybe_start_recording(kapps_call:call(), boolean(), kz_term:ne_binary()) -> 'ok'. maybe_start_recording(_Call, 'false', _) -> lager:debug("not recording this call"); maybe_start_recording(Call, 'true', Url) -> @@ -1242,21 +1242,21 @@ maybe_start_recording(Call, 'true', Url) -> recording_format() -> kapps_config:get_ne_binary(<<"callflow">>, [<<"call_recording">>, <<"extension">>], <<"mp3">>). --spec agent_id(agent()) -> api_binary(). +-spec agent_id(agent()) -> kz_term:api_binary(). agent_id(Agent) -> case kz_json:is_json_object(Agent) of 'true' -> kz_doc:id(Agent); 'false' -> kapps_call:owner_id(Agent) end. --spec account_id(agent()) -> api_binary(). +-spec account_id(agent()) -> kz_term:api_binary(). account_id(Agent) -> case kz_json:is_json_object(Agent) of 'true' -> find_account_id(Agent); 'false' -> kapps_call:account_id(Agent) end. --spec account_db(agent()) -> api_binary(). +-spec account_db(agent()) -> kz_term:api_binary(). account_db(Agent) -> case kz_json:is_json_object(Agent) of 'true' -> kz_doc:account_db(Agent); @@ -1290,7 +1290,7 @@ find_account_id(JObj) -> AcctId -> AcctId end. --spec filter_agent_calls(kz_proplist(), ne_binary()) -> kz_proplist(). +-spec filter_agent_calls(kz_term:proplist(), kz_term:ne_binary()) -> kz_term:proplist(). filter_agent_calls(ACallIds, ACallId) -> lists:filter(fun({ACancelId, ACtrlQ}) when ACancelId =/= ACallId -> lager:debug("cancelling and stopping leg ~s", [ACancelId]), diff --git a/applications/acdc/src/acdc_agent_maintenance.erl b/applications/acdc/src/acdc_agent_maintenance.erl index 1bfd4ff040a..8613618d2db 100644 --- a/applications/acdc/src/acdc_agent_maintenance.erl +++ b/applications/acdc/src/acdc_agent_maintenance.erl @@ -22,7 +22,7 @@ -spec status() -> 'ok'. status() -> acdc_agents_sup:status(). --spec acct_status(text()) -> 'ok'. +-spec acct_status(kz_term:text()) -> 'ok'. acct_status(AcctId) when not is_binary(AcctId) -> acct_status(kz_term:to_binary(AcctId)); acct_status(AcctId) -> @@ -33,7 +33,7 @@ acct_status(AcctId) -> lists:foreach(fun acdc_agent_sup:status/1, As) end. --spec agent_status(text(), text()) -> 'ok'. +-spec agent_status(kz_term:text(), kz_term:text()) -> 'ok'. agent_status(AcctId, AgentId) when not is_binary(AcctId); not is_binary(AgentId) -> agent_status(kz_term:to_binary(AcctId), kz_term:to_binary(AgentId)); @@ -43,7 +43,7 @@ agent_status(AcctId, AgentId) -> S -> acdc_agent_sup:status(S) end. --spec acct_restart(text()) -> 'ok'. +-spec acct_restart(kz_term:text()) -> 'ok'. acct_restart(AcctId) when not is_binary(AcctId) -> acct_restart(kz_term:to_binary(AcctId)); acct_restart(AcctId) -> @@ -57,7 +57,7 @@ acct_restart(AcctId) -> 'ok' end. --spec agent_restart(text(), text()) -> 'ok'. +-spec agent_restart(kz_term:text(), kz_term:text()) -> 'ok'. agent_restart(AcctId, AgentId) when not is_binary(AcctId); not is_binary(AgentId) -> agent_restart(kz_term:to_binary(AcctId), kz_term:to_binary(AgentId)); diff --git a/applications/acdc/src/acdc_agent_manager.erl b/applications/acdc/src/acdc_agent_manager.erl index 20800e35827..c40076e9d44 100644 --- a/applications/acdc/src/acdc_agent_manager.erl +++ b/applications/acdc/src/acdc_agent_manager.erl @@ -70,7 +70,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link({'local', ?SERVER}, ?MODULE ,[{'bindings', ?BINDINGS} @@ -106,7 +106,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> Reply = 'ok', {'reply', Reply, State}. @@ -121,7 +121,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener',{'is_consuming',_IsConsuming}}, State) -> {'noreply', State}; handle_cast({'gen_listener',{'created_queue',_QueueName}}, State) -> @@ -140,7 +140,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(?HOOK_EVT(AccountId, <<"CHANNEL_CREATE">>, JObj), State) -> lager:debug("channel_create event"), _ = kz_util:spawn(fun acdc_agent_handler:handle_new_channel/2, [JObj, AccountId]), diff --git a/applications/acdc/src/acdc_agent_stats.erl b/applications/acdc/src/acdc_agent_stats.erl index 903f46702c8..94a5d25d4c8 100644 --- a/applications/acdc/src/acdc_agent_stats.erl +++ b/applications/acdc/src/acdc_agent_stats.erl @@ -35,7 +35,7 @@ -spec status_table_id() -> atom(). -spec status_key_pos() -> pos_integer(). --spec status_table_opts() -> kz_proplist(). +-spec status_table_opts() -> kz_term:proplist(). status_table_id() -> 'acdc_stats_status'. status_key_pos() -> #status_stat.id. status_table_opts() -> @@ -43,7 +43,7 @@ status_table_opts() -> ,{'keypos', status_key_pos()} ]. --spec agent_ready(ne_binary(), ne_binary()) -> 'ok'. +-spec agent_ready(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. agent_ready(AccountId, AgentId) -> Prop = props:filter_undefined( [{<<"Account-ID">>, AccountId} @@ -56,7 +56,7 @@ agent_ready(AccountId, AgentId) -> ,fun kapi_acdc_stats:publish_status_ready/1 ). --spec agent_logged_in(ne_binary(), ne_binary()) -> 'ok'. +-spec agent_logged_in(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. agent_logged_in(AccountId, AgentId) -> Prop = props:filter_undefined( [{<<"Account-ID">>, AccountId} @@ -69,7 +69,7 @@ agent_logged_in(AccountId, AgentId) -> ,fun kapi_acdc_stats:publish_status_logged_in/1 ). --spec agent_logged_out(ne_binary(), ne_binary()) -> 'ok'. +-spec agent_logged_out(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. agent_logged_out(AccountId, AgentId) -> Prop = props:filter_undefined( [{<<"Account-ID">>, AccountId} @@ -82,7 +82,7 @@ agent_logged_out(AccountId, AgentId) -> ,fun kapi_acdc_stats:publish_status_logged_out/1 ). --spec agent_pending_logged_out(ne_binary(), ne_binary()) -> +-spec agent_pending_logged_out(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. agent_pending_logged_out(AccountId, AgentId) -> Prop = props:filter_undefined( @@ -96,9 +96,9 @@ agent_pending_logged_out(AccountId, AgentId) -> ,fun kapi_acdc_stats:publish_status_pending_logged_out/1 ). --spec agent_connecting(ne_binary(), ne_binary(), ne_binary()) -> +-spec agent_connecting(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. --spec agent_connecting(ne_binary(), ne_binary(), ne_binary(), api_binary(), api_binary()) -> +-spec agent_connecting(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary(), kz_term:api_binary()) -> 'ok'. agent_connecting(AccountId, AgentId, CallId) -> agent_connecting(AccountId, AgentId, CallId, 'undefined', 'undefined'). @@ -117,9 +117,9 @@ agent_connecting(AccountId, AgentId, CallId, CallerIDName, CallerIDNumber) -> ,fun kapi_acdc_stats:publish_status_connecting/1 ). --spec agent_connected(ne_binary(), ne_binary(), ne_binary()) -> +-spec agent_connected(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. --spec agent_connected(ne_binary(), ne_binary(), ne_binary(), api_binary(), api_binary()) -> +-spec agent_connected(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary(), kz_term:api_binary()) -> 'ok'. agent_connected(AccountId, AgentId, CallId) -> agent_connected(AccountId, AgentId, CallId, 'undefined', 'undefined'). @@ -138,7 +138,7 @@ agent_connected(AccountId, AgentId, CallId, CallerIDName, CallerIDNumber) -> ,fun kapi_acdc_stats:publish_status_connected/1 ). --spec agent_wrapup(ne_binary(), ne_binary(), integer()) -> 'ok'. +-spec agent_wrapup(kz_term:ne_binary(), kz_term:ne_binary(), integer()) -> 'ok'. agent_wrapup(AccountId, AgentId, WaitTime) -> Prop = props:filter_undefined( [{<<"Account-ID">>, AccountId} @@ -152,7 +152,7 @@ agent_wrapup(AccountId, AgentId, WaitTime) -> ,fun kapi_acdc_stats:publish_status_wrapup/1 ). --spec agent_paused(ne_binary(), ne_binary(), api_integer()) -> 'ok'. +-spec agent_paused(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_integer()) -> 'ok'. agent_paused(AccountId, AgentId, 'undefined') -> lager:debug("undefined pause time for ~s(~s)", [AgentId, AccountId]); agent_paused(AccountId, AgentId, PauseTime) -> @@ -168,7 +168,7 @@ agent_paused(AccountId, AgentId, PauseTime) -> ,fun kapi_acdc_stats:publish_status_paused/1 ). --spec agent_outbound(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec agent_outbound(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. agent_outbound(AccountId, AgentId, CallId) -> Prop = props:filter_undefined( [{<<"Account-ID">>, AccountId} @@ -182,7 +182,7 @@ agent_outbound(AccountId, AgentId, CallId) -> ,fun kapi_acdc_stats:publish_status_outbound/1 ). --spec handle_status_stat(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_status_stat(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_status_stat(JObj, Props) -> 'true' = case (EventName = kz_json:get_value(<<"Event-Name">>, JObj)) of <<"ready">> -> kapi_acdc_stats:status_ready_v(JObj); @@ -219,11 +219,11 @@ handle_status_stat(JObj, Props) -> } ). --spec status_stat_id(ne_binary(), pos_integer(), any()) -> ne_binary(). +-spec status_stat_id(kz_term:ne_binary(), pos_integer(), any()) -> kz_term:ne_binary(). status_stat_id(AgentId, Timestamp, _EventName) -> <>. --spec handle_status_query(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_status_query(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_status_query(JObj, _Prop) -> 'true' = kapi_acdc_stats:status_req_v(JObj), RespQ = kz_json:get_value(<<"Server-ID">>, JObj), @@ -235,7 +235,7 @@ handle_status_query(JObj, _Prop) -> {'error', Errors} -> publish_query_errors(RespQ, MsgId, Errors) end. --spec publish_query_errors(ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec publish_query_errors(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. publish_query_errors(RespQ, MsgId, Errors) -> API = [{<<"Error-Reason">>, Errors} ,{<<"Msg-ID">>, MsgId} @@ -321,7 +321,7 @@ status_match_builder_fold(<<"Status">>, Status, {StatusStat, Contstraints}) -> }; status_match_builder_fold(_, _, Acc) -> Acc. --spec query_statuses(ne_binary(), ne_binary(), ets:match_spec(), pos_integer()) -> 'ok'. +-spec query_statuses(kz_term:ne_binary(), kz_term:ne_binary(), ets:match_spec(), pos_integer()) -> 'ok'. query_statuses(RespQ, MsgId, Match, Limit) -> case ets:select(status_table_id(), Match) of [] -> diff --git a/applications/acdc/src/acdc_agent_sup.erl b/applications/acdc/src/acdc_agent_sup.erl index a257f6d2a9d..d355a6d9610 100644 --- a/applications/acdc/src/acdc_agent_sup.erl +++ b/applications/acdc/src/acdc_agent_sup.erl @@ -37,9 +37,9 @@ %%-------------------------------------------------------------------- %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link(kz_json:object()) -> startlink_ret(). --spec start_link(kapps_call:call(), ne_binary()) -> startlink_ret(). --spec start_link(ne_binary(), ne_binary(), kz_json:object(), ne_binaries()) -> startlink_ret(). +-spec start_link(kz_json:object()) -> kz_types:startlink_ret(). +-spec start_link(kapps_call:call(), kz_term:ne_binary()) -> kz_types:startlink_ret(). +-spec start_link(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binaries()) -> kz_types:startlink_ret(). start_link(AgentJObj) -> supervisor:start_link(?SERVER, [AgentJObj]). start_link(ThiefCall, QueueId) -> @@ -51,7 +51,7 @@ start_link(AcctId, AgentId, AgentJObj, Queues) -> stop(Supervisor) -> supervisor:terminate_child('acdc_agents_sup', Supervisor). --spec restart(pid()) -> sup_startchild_ret(). +-spec restart(pid()) -> kz_types:sup_startchild_ret(). restart(Supervisor) -> _ = stop(Supervisor), supervisor:restart_child('acdc_agents_sup', Supervisor). @@ -90,21 +90,21 @@ print_status([{K, V}|T]) -> ?PRINT(" ~s: ~p", [K, V]), print_status(T). --spec listener(pid()) -> api_pid(). +-spec listener(pid()) -> kz_term:api_pid(). listener(Super) -> case child_of_type(Super, 'acdc_agent_listener') of [] -> 'undefined'; [P] -> P end. --spec fsm(pid()) -> api_pid(). +-spec fsm(pid()) -> kz_term:api_pid(). fsm(Super) -> case child_of_type(Super, 'acdc_agent_fsm') of [] -> 'undefined'; [P] -> P end. --spec child_of_type(pid(), atom()) -> pids(). +-spec child_of_type(pid(), atom()) -> kz_term:pids(). child_of_type(S, T) -> [P || {Ty, P, 'worker', _} <- supervisor:which_children(S), T =:= Ty]. %%%=================================================================== @@ -120,7 +120,7 @@ child_of_type(S, T) -> [P || {Ty, P, 'worker', _} <- supervisor:which_children(S %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init(Args) -> RestartStrategy = 'one_for_all', MaxRestarts = 2, diff --git a/applications/acdc/src/acdc_agent_util.erl b/applications/acdc/src/acdc_agent_util.erl index 396540b29c2..5a31b01629a 100644 --- a/applications/acdc/src/acdc_agent_util.erl +++ b/applications/acdc/src/acdc_agent_util.erl @@ -24,8 +24,8 @@ -include("acdc.hrl"). --spec update_status(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. --spec update_status(ne_binary(), ne_binary(), ne_binary(), kz_proplist()) -> 'ok'. +-spec update_status(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. +-spec update_status(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. update_status(AccountId, AgentId, Status) -> update_status(AccountId, AgentId, Status, []). update_status(?NE_BINARY = AccountId, AgentId, Status, Options) -> @@ -37,8 +37,8 @@ update_status(?NE_BINARY = AccountId, AgentId, Status, Options) -> ], kapps_util:amqp_pool_send(API, fun kapi_acdc_stats:publish_status_update/1). --spec most_recent_status(ne_binary(), ne_binary()) -> - {'ok', ne_binary()} | +-spec most_recent_status(kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | {'error', any()}. most_recent_status(AccountId, AgentId) -> case most_recent_ets_status(AccountId, AgentId) of @@ -48,8 +48,8 @@ most_recent_status(AccountId, AgentId) -> most_recent_db_status(AccountId, AgentId) end. --spec most_recent_ets_status(ne_binary(), ne_binary()) -> - {'ok', ne_binary()} | +-spec most_recent_ets_status(kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | {'error', any()}. most_recent_ets_status(AccountId, AgentId) -> API = [{<<"Account-ID">>, AccountId} @@ -68,8 +68,8 @@ most_recent_ets_status(AccountId, AgentId) -> {'ok', kz_json:get_value(<<"status">>, StatusJObj)} end. --spec most_recent_db_status(ne_binary(), ne_binary()) -> - {'ok', ne_binary()}. +-spec most_recent_db_status(kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()}. most_recent_db_status(AccountId, AgentId) -> Opts = [{'startkey', [AgentId, kz_time:now_s()]} ,{'limit', 1} @@ -90,8 +90,8 @@ most_recent_db_status(AccountId, AgentId) -> {'ok', <<"unknown">>} end. --spec prev_month_recent_db_status(ne_binary(), ne_binary()) -> - {'ok', ne_binary()}. +-spec prev_month_recent_db_status(kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()}. prev_month_recent_db_status(AccountId, AgentId) -> Opts = [{'startkey', [AgentId, kz_time:now_s()]} ,{'limit', 1} @@ -112,11 +112,11 @@ prev_month_recent_db_status(AccountId, AgentId) -> end. -type statuses_return() :: {'ok', kz_json:object()}. --spec most_recent_statuses(ne_binary()) -> +-spec most_recent_statuses(kz_term:ne_binary()) -> statuses_return(). --spec most_recent_statuses(ne_binary(), api_binary() | kz_proplist()) -> +-spec most_recent_statuses(kz_term:ne_binary(), kz_term:api_binary() | kz_term:proplist()) -> statuses_return(). --spec most_recent_statuses(ne_binary(), api_binary(), kz_proplist()) -> +-spec most_recent_statuses(kz_term:ne_binary(), kz_term:api_binary(), kz_term:proplist()) -> statuses_return(). most_recent_statuses(AccountId) -> @@ -138,8 +138,8 @@ most_recent_statuses(AccountId, AgentId, Options) -> maybe_reduce_statuses(AgentId, receive_statuses([ETS, DB])). --spec maybe_start_db_lookup(atom(), fun(), ne_binary(), api_binary(), list(), pid()) -> - pid_ref() | 'undefined'. +-spec maybe_start_db_lookup(atom(), fun(), kz_term:ne_binary(), kz_term:api_binary(), list(), pid()) -> + kz_term:pid_ref() | 'undefined'. maybe_start_db_lookup(F, Fun, AccountId, AgentId, Options, Self) -> case kz_cache:fetch_local(?CACHE_NAME, db_fetch_key(F, AccountId, AgentId)) of {'ok', _} -> 'undefined'; @@ -149,7 +149,7 @@ maybe_start_db_lookup(F, Fun, AccountId, AgentId, Options, Self) -> db_fetch_key(F, AccountId, AgentId) -> {F, AccountId, AgentId}. --spec maybe_reduce_statuses(api_binary(), kz_json:object()) -> +-spec maybe_reduce_statuses(kz_term:api_binary(), kz_json:object()) -> {'ok', kz_json:object()}. maybe_reduce_statuses('undefined', Statuses) -> {'ok', kz_json:map(fun map_reduce_agent_statuses/2, Statuses)}; @@ -202,7 +202,7 @@ clear_monitor(Ref) -> end. %% @private --spec async_most_recent_ets_statuses(ne_binary(), api_binary(), kz_proplist(), pid()) -> 'ok'. +-spec async_most_recent_ets_statuses(kz_term:ne_binary(), kz_term:api_binary(), kz_term:proplist(), pid()) -> 'ok'. async_most_recent_ets_statuses(AccountId, AgentId, Options, Pid) -> case most_recent_ets_statuses(AccountId, AgentId, Options) of {'ok', Statuses} -> @@ -214,7 +214,7 @@ async_most_recent_ets_statuses(AccountId, AgentId, Options, Pid) -> end. %% @private --spec async_most_recent_db_statuses(ne_binary(), api_binary(), kz_proplist(), pid()) -> 'ok'. +-spec async_most_recent_db_statuses(kz_term:ne_binary(), kz_term:api_binary(), kz_term:proplist(), pid()) -> 'ok'. async_most_recent_db_statuses(AccountId, AgentId, Options, Pid) -> case most_recent_db_statuses(AccountId, AgentId, Options) of {'ok', Statuses} -> @@ -226,13 +226,13 @@ async_most_recent_db_statuses(AccountId, AgentId, Options, Pid) -> 'ok' end. --spec most_recent_ets_statuses(ne_binary()) -> +-spec most_recent_ets_statuses(kz_term:ne_binary()) -> statuses_return() | {'error', any()}. --spec most_recent_ets_statuses(ne_binary(), api_binary()) -> +-spec most_recent_ets_statuses(kz_term:ne_binary(), kz_term:api_binary()) -> statuses_return() | {'error', any()}. --spec most_recent_ets_statuses(ne_binary(), api_binary(), kz_proplist()) -> +-spec most_recent_ets_statuses(kz_term:ne_binary(), kz_term:api_binary(), kz_term:proplist()) -> statuses_return() | {'error', any()}. most_recent_ets_statuses(AccountId) -> @@ -259,13 +259,13 @@ most_recent_ets_statuses(AccountId, AgentId, Options) -> {'ok', kz_json:get_value([<<"Agents">>], Resp, kz_json:new())} end. --spec most_recent_db_statuses(ne_binary()) -> +-spec most_recent_db_statuses(kz_term:ne_binary()) -> statuses_return() | {'error', any()}. --spec most_recent_db_statuses(ne_binary(), api_binary()) -> +-spec most_recent_db_statuses(kz_term:ne_binary(), kz_term:api_binary()) -> statuses_return() | {'error', any()}. --spec most_recent_db_statuses(ne_binary(), api_binary(), kz_proplist()) -> +-spec most_recent_db_statuses(kz_term:ne_binary(), kz_term:api_binary(), kz_term:proplist()) -> statuses_return() | {'error', any()}. most_recent_db_statuses(AccountId) -> @@ -366,7 +366,7 @@ build_agent_view_options(AgentId, [{<<"End-Range">>, T} | ReqOptions], ViewOptio build_agent_view_options(AgentId, [_| ReqOptions], ViewOptions) -> build_agent_view_options(AgentId, ReqOptions, ViewOptions). --spec find_most_recent_fold(integer() | ne_binary(), kz_json:object(), {integer(), kz_json:object()}) -> +-spec find_most_recent_fold(integer() | kz_term:ne_binary(), kz_json:object(), {integer(), kz_json:object()}) -> {integer(), kz_json:object()}. find_most_recent_fold(K, V, {T, _V}=Acc) -> try kz_term:to_integer(K) of diff --git a/applications/acdc/src/acdc_agents_sup.erl b/applications/acdc/src/acdc_agents_sup.erl index a8cd940ded7..982bac046e4 100644 --- a/applications/acdc/src/acdc_agents_sup.erl +++ b/applications/acdc/src/acdc_agents_sup.erl @@ -40,7 +40,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -51,8 +51,8 @@ status() -> _ = kz_util:spawn(fun() -> lists:foreach(fun acdc_agent_sup:status/1, Ws) end), 'ok'. --spec new(kz_json:object()) -> sup_startchild_ret(). --spec new(ne_binary(), ne_binary()) -> sup_startchild_ret(). +-spec new(kz_json:object()) -> kz_types:sup_startchild_ret(). +-spec new(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_types:sup_startchild_ret(). new(JObj) -> case find_agent_supervisor(kz_doc:account_id(JObj), kz_doc:id(JObj)) of 'undefined' -> supervisor:start_child(?SERVER, [JObj]); @@ -67,33 +67,33 @@ new(AcctId, AgentId) -> P when is_pid(P) -> lager:debug("agent already started here: ~p", [P]) end. --spec new(ne_binary(), ne_binary(), kz_json:object(), ne_binaries()) -> sup_startchild_ret() | 'ok'. +-spec new(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binaries()) -> kz_types:sup_startchild_ret() | 'ok'. new(AcctId, AgentId, AgentJObj, Queues) -> case find_agent_supervisor(AcctId, AgentId) of 'undefined' -> supervisor:start_child(?SERVER, [AgentJObj, AcctId, AgentId, Queues]); P when is_pid(P) -> lager:debug("agent already started here: ~p", [P]) end. --spec new_thief(kapps_call:call(), ne_binary()) -> sup_startchild_ret(). +-spec new_thief(kapps_call:call(), kz_term:ne_binary()) -> kz_types:sup_startchild_ret(). new_thief(Call, QueueId) -> supervisor:start_child(?SERVER, [Call, QueueId]). --spec workers() -> pids(). +-spec workers() -> kz_term:pids(). workers() -> [Pid || {_, Pid, 'supervisor', [_]} <- supervisor:which_children(?SERVER)]. --spec restart_acct(ne_binary()) -> [sup_startchild_ret()]. +-spec restart_acct(kz_term:ne_binary()) -> [kz_types:sup_startchild_ret()]. restart_acct(AcctId) -> [acdc_agent_sup:restart(S) || S <- workers(), is_agent_in_acct(S, AcctId)]. --spec restart_agent(ne_binary(), ne_binary()) -> sup_startchild_ret() | 'ok'. +-spec restart_agent(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_types:sup_startchild_ret() | 'ok'. restart_agent(AcctId, AgentId) -> case find_agent_supervisor(AcctId, AgentId) of 'undefined' -> lager:info("no supervisor for agent ~s(~s) to restart", [AgentId, AcctId]); S -> acdc_agent_sup:restart(S) end. --spec find_acct_supervisors(ne_binary()) -> pids(). +-spec find_acct_supervisors(kz_term:ne_binary()) -> kz_term:pids(). find_acct_supervisors(AcctId) -> [S || S <- workers(), is_agent_in_acct(S, AcctId)]. --spec is_agent_in_acct(pid(), ne_binary()) -> boolean(). +-spec is_agent_in_acct(pid(), kz_term:ne_binary()) -> boolean(). is_agent_in_acct(Super, AcctId) -> case catch acdc_agent_listener:config(acdc_agent_sup:listener(Super)) of {'EXIT', _} -> 'false'; @@ -105,8 +105,8 @@ is_agent_in_acct(Super, AcctId) -> agents_running() -> [{W, catch acdc_agent_listener:config(acdc_agent_sup:listener(W))} || W <- workers()]. --spec find_agent_supervisor(api_binary(), api_binary()) -> api_pid(). --spec find_agent_supervisor(api_binary(), api_binary(), pids()) -> api_pid(). +-spec find_agent_supervisor(kz_term:api_binary(), kz_term:api_binary()) -> kz_term:api_pid(). +-spec find_agent_supervisor(kz_term:api_binary(), kz_term:api_binary(), kz_term:pids()) -> kz_term:api_pid(). find_agent_supervisor(AcctId, AgentId) -> find_agent_supervisor(AcctId, AgentId, workers()). find_agent_supervisor(_AcctId, _AgentId, []) -> @@ -136,7 +136,7 @@ find_agent_supervisor(AcctId, AgentId, [Super|Rest]) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 1, diff --git a/applications/acdc/src/acdc_announcements.erl b/applications/acdc/src/acdc_announcements.erl index b1d32f3ec2e..d72f44611b5 100644 --- a/applications/acdc/src/acdc_announcements.erl +++ b/applications/acdc/src/acdc_announcements.erl @@ -30,7 +30,7 @@ %% %% @end %%-------------------------------------------------------------------- --spec start_link(pid(), kapps_call:call(), kz_proplist()) -> startlink_ret(). +-spec start_link(pid(), kapps_call:call(), kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Manager, Call, Props) -> {'ok', kz_util:spawn_link(fun ?MODULE:init/3, [Manager, Call, Props])}. @@ -40,7 +40,7 @@ start_link(Manager, Call, Props) -> %% %% @end %%-------------------------------------------------------------------- --spec init(pid(), kapps_call:call(), kz_proplist()) -> 'no_return'. +-spec init(pid(), kapps_call:call(), kz_term:proplist()) -> 'no_return'. init(Manager, Call, Props) -> Config = get_config(Props), State = init_state(Manager, Call, Config), @@ -56,7 +56,7 @@ init(Manager, Call, Props) -> %% %% @end %%-------------------------------------------------------------------- --spec get_config(kz_proplist()) -> map(). +-spec get_config(kz_term:proplist()) -> map(). get_config(Props) -> #{position_announcements_enabled => props:get_is_true(<<"position_announcements_enabled">>, Props, 'false') ,wait_time_announcements_enabled => props:get_is_true(<<"wait_time_announcements_enabled">>, Props, 'false') @@ -70,7 +70,7 @@ get_config(Props) -> %% %% @end %%-------------------------------------------------------------------- --spec announcements_media(kz_proplist()) -> kz_proplist(). +-spec announcements_media(kz_term:proplist()) -> kz_term:proplist(). announcements_media(Props) -> case props:get_value(<<"media">>, Props) of 'undefined' -> @@ -177,7 +177,7 @@ play_announcements(Prompts, #{call := Call %% %% @end %%-------------------------------------------------------------------- --spec get_average_wait_time(kapps_call:call()) -> api_pos_integer(). +-spec get_average_wait_time(kapps_call:call()) -> kz_term:api_pos_integer(). get_average_wait_time(Call) -> AccountId = kapps_call:account_id(Call), QueueId = kapps_call:custom_channel_var(<<"Queue-ID">>, Call), @@ -237,7 +237,7 @@ calculate_average_wait_time(Abandoned, Total, TotalWait) -> %% %% @end %%-------------------------------------------------------------------- --spec time_prompt(pos_integer(), binary()) -> {'prompt', ne_binary(), binary(), ne_binary()}. +-spec time_prompt(pos_integer(), binary()) -> {'prompt', kz_term:ne_binary(), binary(), kz_term:ne_binary()}. time_prompt(Time, Language) -> {'prompt', time_prompt2(Time), Language, <<"A">>}. @@ -247,7 +247,7 @@ time_prompt(Time, Language) -> %% %% @end %%-------------------------------------------------------------------- --spec time_prompt2(pos_integer()) -> ne_binary(). +-spec time_prompt2(pos_integer()) -> kz_term:ne_binary(). time_prompt2(Time) when Time < ?SECONDS_IN_MINUTE -> <<"queue-less_than_1_minute">>; time_prompt2(Time) when Time =< 5 * ?SECONDS_IN_MINUTE -> @@ -281,6 +281,6 @@ announcements_interval(#{announcements_interval := Interval}) -> %% %% @end %%-------------------------------------------------------------------- --spec announcements_media_file(ne_binary(), map()) -> api_ne_binary(). +-spec announcements_media_file(kz_term:ne_binary(), map()) -> kz_term:api_ne_binary(). announcements_media_file(Name, #{announcements_media := Media}) -> props:get_binary_value(Name, Media). diff --git a/applications/acdc/src/acdc_announcements_sup.erl b/applications/acdc/src/acdc_announcements_sup.erl index 820f76d4a43..6f186e0aa40 100644 --- a/applications/acdc/src/acdc_announcements_sup.erl +++ b/applications/acdc/src/acdc_announcements_sup.erl @@ -34,7 +34,7 @@ %% %% @end %%-------------------------------------------------------------------- --spec start_link() -> sup_startchild_ret(). +-spec start_link() -> kz_types:sup_startchild_ret(). start_link() -> supervisor:start_link({local, ?SERVER}, ?MODULE, []). @@ -45,7 +45,7 @@ start_link() -> %% %% @end %%-------------------------------------------------------------------- --spec maybe_start_announcements(pid(), kapps_call:call(), kz_proplist()) -> supervisor:startchild_ret() | 'false'. +-spec maybe_start_announcements(pid(), kapps_call:call(), kz_term:proplist()) -> supervisor:startchild_ret() | 'false'. maybe_start_announcements(Manager, Call, Props) -> Enabled = props:get_is_true(<<"position_announcements_enabled">>, Props, 'false') orelse props:get_is_true(<<"wait_time_announcements_enabled">>, Props, 'false'), @@ -76,7 +76,7 @@ stop_announcements(Pid) -> %% %% @end %%-------------------------------------------------------------------- --spec init(list()) -> sup_init_ret(). +-spec init(list()) -> kz_types:sup_init_ret(). init([]) -> SupFlags = #{strategy => simple_one_for_one, diff --git a/applications/acdc/src/acdc_app.erl b/applications/acdc/src/acdc_app.erl index 170ebdda467..fc6830918e8 100644 --- a/applications/acdc/src/acdc_app.erl +++ b/applications/acdc/src/acdc_app.erl @@ -24,7 +24,7 @@ %% Implement the application start behaviour %% @end %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_StartType, _StartArgs) -> kz_datamgr:register_views_from_folder('modb'), acdc_sup:start_link(). diff --git a/applications/acdc/src/acdc_eavesdrop.erl b/applications/acdc/src/acdc_eavesdrop.erl index 2807734232d..68d998404f6 100644 --- a/applications/acdc/src/acdc_eavesdrop.erl +++ b/applications/acdc/src/acdc_eavesdrop.erl @@ -12,7 +12,7 @@ -export([start/3]). --spec start(kapps_call:call(), ne_binary(), ne_binary()) -> 'ok'. +-spec start(kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. start(MCall, AcctId, AgentCallId) -> Prop = [{<<"Eavesdrop-Mode">>, <<"listen">>} ,{<<"Account-ID">>, AcctId} diff --git a/applications/acdc/src/acdc_handlers.erl b/applications/acdc/src/acdc_handlers.erl index d94e4099512..c4318d3aa1d 100644 --- a/applications/acdc/src/acdc_handlers.erl +++ b/applications/acdc/src/acdc_handlers.erl @@ -13,7 +13,7 @@ -include("acdc.hrl"). --spec handle_route_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_route_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_route_req(JObj, Props) -> 'true' = kapi_route:req_v(JObj), _ = kz_util:put_callid(JObj), @@ -80,7 +80,7 @@ update_agent(Call) -> end. -spec update_acdc_actor(kapps_call:call()) -> any(). --spec update_acdc_actor(kapps_call:call(), api_binary(), api_binary()) -> any(). +-spec update_acdc_actor(kapps_call:call(), kz_term:api_binary(), kz_term:api_binary()) -> any(). update_acdc_actor(Call) -> update_acdc_actor(Call ,kapps_call:custom_channel_var(<<"ACDc-ID">>, Call) @@ -106,7 +106,7 @@ update_acdc_actor(Call, AgentId, <<"user">>) -> update_acdc_agent(Call, AcctId, AgentId, <<"logout">>, fun kapi_acdc_agent:publish_logout/1) end. --spec update_acdc_agent(kapps_call:call(), ne_binary(), ne_binary(), ne_binary(), fun()) -> ne_binary(). +-spec update_acdc_agent(kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), fun()) -> kz_term:ne_binary(). update_acdc_agent(Call, AcctId, AgentId, Status, PubFun) -> lager:debug("agent ~s going to new status ~s", [AgentId, Status]), @@ -123,7 +123,7 @@ update_acdc_agent(Call, AcctId, AgentId, Status, PubFun) -> play_failed_update(Call) end. --spec save_status(kapps_call:call(), ne_binary(), ne_binary()) -> 'ok'. +-spec save_status(kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. save_status(Call, AgentId, Status) -> acdc_agent_util:update_status(kapps_call:account_id(Call) ,AgentId @@ -151,7 +151,7 @@ update_agent_device(Call, AgentId, <<"logout">>) -> end; update_agent_device(_, _, _) -> {'ok', 'ok'}. --spec move_agent_device(kapps_call:call(), ne_binary(), kz_json:object()) -> +-spec move_agent_device(kapps_call:call(), kz_term:ne_binary(), kz_json:object()) -> {'ok', kz_json:object()}. move_agent_device(Call, AgentId, Device) -> DeviceId = kz_doc:id(Device), @@ -166,7 +166,7 @@ move_agent_device(Call, AgentId, Device) -> end, {'ok', _} = kz_datamgr:save_doc(kapps_call:account_db(Call), kz_json:set_value(<<"owner_id">>, AgentId, Device)). --spec send_new_status(ne_binary(), ne_binary(), kz_amqp_worker:publish_fun()) -> 'ok'. +-spec send_new_status(kz_term:ne_binary(), kz_term:ne_binary(), kz_amqp_worker:publish_fun()) -> 'ok'. send_new_status(AcctId, AgentId, PubFun) -> Update = props:filter_undefined( [{<<"Account-ID">>, AcctId} @@ -175,7 +175,7 @@ send_new_status(AcctId, AgentId, PubFun) -> ]), PubFun(Update). --spec play_status_prompt(kapps_call:call(), ne_binary()) -> ne_binary(). +-spec play_status_prompt(kapps_call:call(), kz_term:ne_binary()) -> kz_term:ne_binary(). play_status_prompt(Call, <<"login">>) -> kapps_call_command:prompt(<<"agent-logged_in">>, Call); play_status_prompt(Call, <<"logout">>) -> @@ -183,6 +183,6 @@ play_status_prompt(Call, <<"logout">>) -> play_status_prompt(Call, <<"resume">>) -> kapps_call_command:prompt(<<"agent-resume">>, Call). --spec play_failed_update(kapps_call:call()) -> ne_binary(). +-spec play_failed_update(kapps_call:call()) -> kz_term:ne_binary(). play_failed_update(Call) -> kapps_call_command:prompt(<<"agent-invalid_choice">>, Call). diff --git a/applications/acdc/src/acdc_init.erl b/applications/acdc/src/acdc_init.erl index 36d5bb27d0e..5cf5823c6e9 100644 --- a/applications/acdc/src/acdc_init.erl +++ b/applications/acdc/src/acdc_init.erl @@ -47,7 +47,7 @@ init_db() -> _ = kz_datamgr:db_create(?KZ_ACDC_DB), _ = kz_datamgr:revise_doc_from_file(?KZ_ACDC_DB, 'crossbar', <<"views/acdc.json">>). --spec init_acct(ne_binary()) -> 'ok'. +-spec init_acct(kz_term:ne_binary()) -> 'ok'. init_acct(Account) -> AccountDb = kz_util:format_account_id(Account, 'encoded'), AccountId = kz_util:format_account_id(Account, 'raw'), @@ -59,7 +59,7 @@ init_acct(Account) -> init_acct_queues(AccountDb, AccountId), init_acct_agents(AccountDb, AccountId). --spec init_acct_queues(ne_binary()) -> any(). +-spec init_acct_queues(kz_term:ne_binary()) -> any(). init_acct_queues(Account) -> AccountDb = kz_util:format_account_id(Account, 'encoded'), AccountId = kz_util:format_account_id(Account, 'raw'), @@ -67,7 +67,7 @@ init_acct_queues(Account) -> lager:debug("init acdc account queues: ~s", [AccountId]), init_acct_queues(AccountDb, AccountId). --spec init_acct_agents(ne_binary()) -> any(). +-spec init_acct_agents(kz_term:ne_binary()) -> any(). init_acct_agents(Account) -> AccountDb = kz_util:format_account_id(Account, 'encoded'), AccountId = kz_util:format_account_id(Account, 'raw'), @@ -75,19 +75,19 @@ init_acct_agents(Account) -> lager:debug("init acdc account agents: ~s", [AccountId]), init_acct_agents(AccountDb, AccountId). --spec init_acct_queues(ne_binary(), ne_binary()) -> any(). +-spec init_acct_queues(kz_term:ne_binary(), kz_term:ne_binary()) -> any(). init_acct_queues(AccountDb, AccountId) -> init_queues(AccountId ,kz_datamgr:get_results(AccountDb, <<"queues/crossbar_listing">>, []) ). --spec init_acct_agents(ne_binary(), ne_binary()) -> any(). +-spec init_acct_agents(kz_term:ne_binary(), kz_term:ne_binary()) -> any(). init_acct_agents(AccountDb, AccountId) -> init_agents(AccountId ,kz_datamgr:get_results(AccountDb, <<"queues/agents_listing">>, []) ). --spec init_queues(ne_binary(), kazoo_data:get_results_return()) -> any(). +-spec init_queues(kz_term:ne_binary(), kazoo_data:get_results_return()) -> any(). init_queues(_, {'ok', []}) -> 'ok'; init_queues(AccountId, {'error', 'gateway_timeout'}) -> lager:debug("gateway timed out loading queues in account ~s, trying again in a moment", [AccountId]), @@ -105,7 +105,7 @@ init_queues(AccountId, {'ok', Qs}) -> acdc_stats:init_db(AccountId), [acdc_queues_sup:new(AccountId, kz_doc:id(Q)) || Q <- Qs]. --spec init_agents(ne_binary(), kazoo_data:get_results_return()) -> any(). +-spec init_agents(kz_term:ne_binary(), kazoo_data:get_results_return()) -> any(). init_agents(_, {'ok', []}) -> 'ok'; init_agents(AccountId, {'error', 'gateway_timeout'}) -> lager:debug("gateway timed out loading agents in account ~s, trying again in a moment", [AccountId]), @@ -137,7 +137,7 @@ try_again(AccountId, F) -> F(AccountDb, AccountId) end). --spec spawn_previously_logged_in_agent(ne_binary(), ne_binary()) -> any(). +-spec spawn_previously_logged_in_agent(kz_term:ne_binary(), kz_term:ne_binary()) -> any(). spawn_previously_logged_in_agent(AccountId, AgentId) -> kz_util:spawn( fun() -> diff --git a/applications/acdc/src/acdc_listener.erl b/applications/acdc/src/acdc_listener.erl index c65ef3611a9..f8893d0ed74 100644 --- a/applications/acdc/src/acdc_listener.erl +++ b/applications/acdc/src/acdc_listener.erl @@ -51,7 +51,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER ,[{'bindings', ?BINDINGS} @@ -83,7 +83,7 @@ init([]) -> {'ok', #state{}}. %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -97,7 +97,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener',{'is_consuming',_IsConsuming}}, State) -> {'noreply', State}; handle_cast({'gen_listener',{'created_queue',_QueueName}}, State) -> @@ -116,7 +116,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> lager:debug("unhandled message: ~p", [_Info]), {'noreply', State}. @@ -129,7 +129,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/acdc/src/acdc_maintenance.erl b/applications/acdc/src/acdc_maintenance.erl index ab5a4abecd6..e6202155c0e 100644 --- a/applications/acdc/src/acdc_maintenance.erl +++ b/applications/acdc/src/acdc_maintenance.erl @@ -33,7 +33,7 @@ -include("acdc.hrl"). --spec logout_agents(ne_binary()) -> 'ok'. +-spec logout_agents(kz_term:ne_binary()) -> 'ok'. logout_agents(AccountId) -> ?PRINT("Sending notices to logout agents for ~s", [AccountId]), AccountDb = kz_util:format_account_id(AccountId, 'encoded'), @@ -41,7 +41,7 @@ logout_agents(AccountId) -> _ = [logout_agent(AccountId, kz_doc:id(Agent)) || Agent <- AgentView], 'ok'. --spec logout_agent(ne_binary(), ne_binary()) -> 'ok'. +-spec logout_agent(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. logout_agent(AccountId, AgentId) -> io:format("Sending notice to log out agent ~s (~s)~n", [AgentId, AccountId]), Update = props:filter_undefined( @@ -53,7 +53,7 @@ logout_agent(AccountId, AgentId) -> -define(KEYS, [<<"Waiting">>, <<"Handled">>, <<"Processed">>, <<"Abandoned">>]). --spec current_statuses(text()) -> 'ok'. +-spec current_statuses(kz_term:text()) -> 'ok'. current_statuses(AccountId) -> {'ok', Agents} = acdc_agent_util:most_recent_statuses(AccountId), case kz_json:values(Agents) of @@ -77,7 +77,7 @@ log_current_status(A, N) -> ,kz_time:pretty_print_datetime(TS) ]). --spec current_queues(ne_binary()) -> 'ok'. +-spec current_queues(kz_term:ne_binary()) -> 'ok'. current_queues(AccountId) -> case acdc_agents_sup:find_acct_supervisors(AccountId) of [] -> io:format("no agent processes found for ~s~n", [AccountId]); @@ -95,7 +95,7 @@ log_current_queue(AgentSup) -> ,kz_binary:join(acdc_agent_listener:queues(AgentL)) ]). --spec current_agents(ne_binary()) -> 'ok'. +-spec current_agents(kz_term:ne_binary()) -> 'ok'. current_agents(AccountId) -> case acdc_queues_sup:find_acct_supervisors(AccountId) of [] -> io:format("no queue processes found for ~s~n", [AccountId]); @@ -113,14 +113,14 @@ log_current_agent(QueueSup) -> ,kz_binary:join(acdc_queue_manager:current_agents(QueueM)) ]). --spec current_calls(ne_binary()) -> 'ok'. +-spec current_calls(kz_term:ne_binary()) -> 'ok'. current_calls(AccountId) -> Req = [{<<"Account-ID">>, AccountId} | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ], get_and_show(AccountId, <<"all">>, Req). --spec current_calls(ne_binary(), ne_binary()) -> 'ok'. +-spec current_calls(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. current_calls(AccountId, QueueId) when is_binary(QueueId) -> Req = [{<<"Account-ID">>, AccountId} ,{<<"Queue-ID">>, QueueId} @@ -191,7 +191,7 @@ refresh() -> lager:debug("failed to query acdc db: ~p", [_E]) end. --spec refresh_account(ne_binary()) -> 'ok'. +-spec refresh_account(kz_term:ne_binary()) -> 'ok'. refresh_account(Acct) -> MoDB = acdc_stats_util:db_name(Acct), refresh_account(MoDB, kazoo_modb:maybe_create(MoDB)), @@ -221,7 +221,7 @@ migrate_to_acdc_db() -> lists:foreach(fun migrate_to_acdc_db/1, kapps_util:get_all_accounts('raw')), io:format("migration complete~n"). --spec maybe_remove_acdc_account(ne_binary()) -> 'ok'. +-spec maybe_remove_acdc_account(kz_term:ne_binary()) -> 'ok'. maybe_remove_acdc_account(<<"_design/", _/binary>>) -> 'ok'; maybe_remove_acdc_account(AccountId) -> case kz_account:fetch(AccountId) of @@ -232,8 +232,8 @@ maybe_remove_acdc_account(AccountId) -> io:format("account ~p not found in ~s, removing from ~s~n", [AccountId, ?KZ_ACCOUNTS_DB, ?KZ_ACDC_DB]) end. --spec migrate_to_acdc_db(ne_binary()) -> 'ok'. --spec migrate_to_acdc_db(ne_binary(), non_neg_integer()) -> 'ok'. +-spec migrate_to_acdc_db(kz_term:ne_binary()) -> 'ok'. +-spec migrate_to_acdc_db(kz_term:ne_binary(), non_neg_integer()) -> 'ok'. migrate_to_acdc_db(AccountId) -> migrate_to_acdc_db(AccountId, 3). @@ -259,7 +259,7 @@ migrate_to_acdc_db(AccountId, Retries) -> migrate_to_acdc_db(AccountId, Retries-1) end. --spec maybe_migrate(ne_binary()) -> 'ok'. +-spec maybe_migrate(kz_term:ne_binary()) -> 'ok'. maybe_migrate(AccountId) -> AccountDb = kz_util:format_account_id(AccountId, 'encoded'), case kz_datamgr:get_results(AccountDb, <<"queues/crossbar_listing">>, [{'limit', 1}]) of @@ -277,7 +277,7 @@ maybe_migrate(AccountId) -> io:format("failed to query queue listing for account ~s: ~p~n", [AccountId, _E]) end. --spec agent_presence_id(ne_binary(), ne_binary()) -> 'ok'. +-spec agent_presence_id(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. agent_presence_id(AccountId, AgentId) -> case acdc_agents_sup:find_agent_supervisor(AccountId, AgentId) of 'undefined' -> @@ -287,7 +287,7 @@ agent_presence_id(AccountId, AgentId) -> io:format("agent ~s(~s) is using presence ID ~s~n", [AgentId, AccountId, PresenceId]) end. --spec flush_call_stat(ne_binary()) -> 'ok'. +-spec flush_call_stat(kz_term:ne_binary()) -> 'ok'. flush_call_stat(CallId) -> case acdc_stats:find_call(CallId) of 'undefined' -> io:format("nothing found for call ~s~n", [CallId]); @@ -301,8 +301,8 @@ flush_call_stat(CallId) -> end. -spec queues_summary() -> 'ok'. --spec queues_summary(ne_binary()) -> 'ok'. --spec queue_summary(ne_binary(), ne_binary()) -> 'ok'. +-spec queues_summary(kz_term:ne_binary()) -> 'ok'. +-spec queue_summary(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. queues_summary() -> kz_util:put_callid(?MODULE), show_queues_summary(acdc_queues_sup:queues_running()). @@ -322,15 +322,15 @@ queue_summary(AcctId, QueueId) -> QQueueId =:= QueueId ]). --spec show_queues_summary([{pid(), {ne_binary(), ne_binary()}}]) -> 'ok'. +-spec show_queues_summary([{pid(), {kz_term:ne_binary(), kz_term:ne_binary()}}]) -> 'ok'. show_queues_summary([]) -> 'ok'; show_queues_summary([{P, {AcctId, QueueId}}|Qs]) -> ?PRINT(" Supervisor: ~p Acct: ~s Queue: ~s~n", [P, AcctId, QueueId]), show_queues_summary(Qs). -spec queues_detail() -> 'ok'. --spec queues_detail(ne_binary()) -> 'ok'. --spec queue_detail(ne_binary(), ne_binary()) -> 'ok'. +-spec queues_detail(kz_term:ne_binary()) -> 'ok'. +-spec queue_detail(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. queues_detail() -> acdc_queues_sup:status(). queues_detail(AcctId) -> @@ -343,8 +343,8 @@ queue_detail(AcctId, QueueId) -> Pid -> acdc_queue_sup:status(Pid) end. --spec queues_restart(ne_binary()) -> 'ok'. --spec queue_restart(ne_binary(), ne_binary()) -> 'ok'. +-spec queues_restart(kz_term:ne_binary()) -> 'ok'. +-spec queue_restart(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. queues_restart(AcctId) -> kz_util:put_callid(?MODULE), case acdc_queues_sup:find_acct_supervisors(AcctId) of @@ -362,8 +362,8 @@ queue_restart(AcctId, QueueId) -> maybe_stop_then_start_queue(AcctId, QueueId, Pid) end. --spec maybe_stop_then_start_queue(ne_binary(), pid()) -> 'ok'. --spec maybe_stop_then_start_queue(ne_binary(), ne_binary(), pid()) -> 'ok'. +-spec maybe_stop_then_start_queue(kz_term:ne_binary(), pid()) -> 'ok'. +-spec maybe_stop_then_start_queue(kz_term:ne_binary(), kz_term:ne_binary(), pid()) -> 'ok'. maybe_stop_then_start_queue(AcctId, Pid) -> {AcctId, QueueId} = acdc_queue_manager:config(acdc_queue_sup:manager(Pid)), maybe_stop_then_start_queue(AcctId, QueueId, Pid). @@ -393,7 +393,7 @@ maybe_start_queue(AcctId, QueueId) -> end. -spec agents_summary() -> 'ok'. --spec agents_summary(ne_binary()) -> 'ok'. +-spec agents_summary(kz_term:ne_binary()) -> 'ok'. agents_summary() -> kz_util:put_callid(?MODULE), show_agents_summary(acdc_agents_sup:agents_running()). @@ -404,7 +404,7 @@ agents_summary(AcctId) -> AAcctId =:= AcctId ]). --spec agent_summary(ne_binary(), ne_binary()) -> 'ok'. +-spec agent_summary(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. agent_summary(AcctId, AgentId) -> kz_util:put_callid(?MODULE), show_agents_summary( @@ -420,8 +420,8 @@ show_agents_summary([{P, {AcctId, QueueId, _AMQPQueue}}|Qs]) -> show_queues_summary(Qs). -spec agents_detail() -> 'ok'. --spec agents_detail(ne_binary()) -> 'ok'. --spec agent_detail(ne_binary(), ne_binary()) -> 'ok'. +-spec agents_detail(kz_term:ne_binary()) -> 'ok'. +-spec agent_detail(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. agents_detail() -> kz_util:put_callid(?MODULE), acdc_agents_sup:status(). @@ -436,7 +436,7 @@ agent_detail(AcctId, AgentId) -> Pid -> acdc_agent_sup:status(Pid) end. --spec agent_login(ne_binary(), ne_binary()) -> 'ok'. +-spec agent_login(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. agent_login(AcctId, AgentId) -> kz_util:put_callid(?MODULE), Update = props:filter_undefined( @@ -447,7 +447,7 @@ agent_login(AcctId, AgentId) -> kapps_util:amqp_pool_send(Update, fun kapi_acdc_agent:publish_login/1), lager:info("published login update for agent"). --spec agent_logout(ne_binary(), ne_binary()) -> 'ok'. +-spec agent_logout(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. agent_logout(AcctId, AgentId) -> kz_util:put_callid(?MODULE), Update = props:filter_undefined( @@ -458,8 +458,8 @@ agent_logout(AcctId, AgentId) -> kapps_util:amqp_pool_send(Update, fun kapi_acdc_agent:publish_logout/1), lager:info("published logout update for agent"). --spec agent_pause(ne_binary(), ne_binary()) -> 'ok'. --spec agent_pause(ne_binary(), ne_binary(), pos_integer()) -> 'ok'. +-spec agent_pause(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. +-spec agent_pause(kz_term:ne_binary(), kz_term:ne_binary(), pos_integer()) -> 'ok'. agent_pause(AcctId, AgentId) -> Timeout = kapps_config:get_integer(?CONFIG_CAT, <<"default_agent_pause_timeout">>, 600), agent_pause(AcctId, AgentId, Timeout). @@ -474,7 +474,7 @@ agent_pause(AcctId, AgentId, Timeout) -> kapps_util:amqp_pool_send(Update, fun kapi_acdc_agent:publish_pause/1), lager:info("published pause for agent"). --spec agent_resume(ne_binary(), ne_binary()) -> 'ok'. +-spec agent_resume(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. agent_resume(AcctId, AgentId) -> kz_util:put_callid(?MODULE), Update = props:filter_undefined( @@ -485,7 +485,7 @@ agent_resume(AcctId, AgentId) -> kapps_util:amqp_pool_send(Update, fun kapi_acdc_agent:publish_resume/1), lager:info("published resume for agent"). --spec agent_queue_login(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec agent_queue_login(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. agent_queue_login(AcctId, AgentId, QueueId) -> kz_util:put_callid(?MODULE), Update = props:filter_undefined( @@ -497,7 +497,7 @@ agent_queue_login(AcctId, AgentId, QueueId) -> kapps_util:amqp_pool_send(Update, fun kapi_acdc_agent:publish_login_queue/1), lager:info("published login update for agent"). --spec agent_queue_logout(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec agent_queue_logout(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. agent_queue_logout(AcctId, AgentId, QueueId) -> kz_util:put_callid(?MODULE), Update = props:filter_undefined( diff --git a/applications/acdc/src/acdc_queue_fsm.erl b/applications/acdc/src/acdc_queue_fsm.erl index 41a56640630..4b8a0970a9f 100644 --- a/applications/acdc/src/acdc_queue_fsm.erl +++ b/applications/acdc/src/acdc_queue_fsm.erl @@ -60,21 +60,21 @@ -record(state, {queue_proc :: pid() ,manager_proc :: pid() ,connect_resps = [] :: kz_json:objects() - ,collect_ref :: api_reference() - ,account_id :: ne_binary() - ,account_db :: ne_binary() - ,queue_id :: ne_binary() + ,collect_ref :: kz_term:api_reference() + ,account_id :: kz_term:ne_binary() + ,account_db :: kz_term:ne_binary() + ,queue_id :: kz_term:ne_binary() - ,timer_ref :: api_reference() % for tracking timers - ,connection_timer_ref :: api_reference() % how long can a caller wait in the queue - ,agent_ring_timer_ref :: api_reference() % how long to ring an agent before moving to the next + ,timer_ref :: kz_term:api_reference() % for tracking timers + ,connection_timer_ref :: kz_term:api_reference() % how long can a caller wait in the queue + ,agent_ring_timer_ref :: kz_term:api_reference() % how long to ring an agent before moving to the next ,member_call :: kapps_call:call() | 'undefined' - ,member_call_start :: api_non_neg_integer() - ,member_call_winner :: api_object() %% who won the call + ,member_call_start :: kz_term:api_non_neg_integer() + ,member_call_winner :: kz_term:api_object() %% who won the call %% Config options - ,name :: ne_binary() + ,name :: kz_term:ne_binary() ,connection_timeout :: pos_integer() ,agent_ring_timeout = 10 :: pos_integer() % how long to ring an agent before giving up ,max_queue_size = 0 :: integer() % restrict the number of the queued callers @@ -82,14 +82,14 @@ ,enter_when_empty = true :: boolean() % if a queue is agent-less, can the caller enter? ,agent_wrapup_time = 0 :: integer() % forced wrapup time for an agent after a call - ,announce :: ne_binary() % media to play to customer when about to be connected to agent + ,announce :: kz_term:ne_binary() % media to play to customer when about to be connected to agent - ,caller_exit_key :: ne_binary() % DTMF a caller can press to leave the queue + ,caller_exit_key :: kz_term:ne_binary() % DTMF a caller can press to leave the queue ,record_caller = 'false' :: boolean() % record the caller - ,recording_url :: api_binary() %% URL of where to POST recordings - ,cdr_url :: api_binary() % optional URL to request for extra CDR data + ,recording_url :: kz_term:api_binary() %% URL of where to POST recordings + ,cdr_url :: kz_term:api_binary() % optional URL to request for extra CDR data - ,notifications :: api_object() + ,notifications :: kz_term:api_object() }). -type state() :: #state{}. @@ -106,7 +106,7 @@ %% function does not return until Module:init/1 has returned. %% @end %%-------------------------------------------------------------------- --spec start_link(pid(), pid(), kz_json:object()) -> startlink_ret(). +-spec start_link(pid(), pid(), kz_json:object()) -> kz_types:startlink_ret(). start_link(MgrPid, ListenerPid, QueueJObj) -> gen_statem:start_link(?SERVER, [MgrPid, ListenerPid, QueueJObj], []). @@ -153,7 +153,7 @@ member_connect_retry(ServerRef, RetryJObj) -> %% for hangup events). %% @end %%-------------------------------------------------------------------- --spec call_event(pid(), ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec call_event(pid(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. call_event(ServerRef, <<"call_event">>, <<"CHANNEL_DESTROY">>, EvtJObj) -> gen_statem:cast(ServerRef, {'member_hungup', EvtJObj}); call_event(ServerRef, <<"call_event">>, <<"DTMF">>, EvtJObj) -> @@ -169,15 +169,15 @@ call_event(_, _E, _N, _J) -> 'ok'. finish_member_call(ServerRef) -> gen_statem:cast(ServerRef, {'member_finished'}). --spec current_call(pid()) -> api_object(). +-spec current_call(pid()) -> kz_term:api_object(). current_call(ServerRef) -> gen_statem:call(ServerRef, 'current_call'). --spec status(pid()) -> kz_proplist(). +-spec status(pid()) -> kz_term:proplist(). status(ServerRef) -> gen_statem:call(ServerRef, 'status'). --spec cdr_url(pid()) -> api_binary(). +-spec cdr_url(pid()) -> kz_term:api_binary(). cdr_url(ServerRef) -> gen_statem:call(ServerRef, 'cdr_url'). @@ -243,7 +243,7 @@ callback_mode() -> %% @doc %% @end %%-------------------------------------------------------------------- --spec ready(gen_statem:event_type(), any(), state()) -> handle_fsm_ret(state()). +-spec ready(gen_statem:event_type(), any(), state()) -> kz_types:handle_fsm_ret(state()). ready('cast', {'member_call', CallJObj, Delivery}, #state{queue_proc=QueueSrv ,manager_proc=MgrSrv }=State) -> @@ -296,7 +296,7 @@ ready({'call', From}, Event, State) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec connect_req(gen_statem:event_type(), any(), state()) -> handle_fsm_ret(state()). +-spec connect_req(gen_statem:event_type(), any(), state()) -> kz_types:handle_fsm_ret(state()). connect_req('cast', {'member_call', CallJObj, Delivery}, #state{queue_proc=Srv}=State) -> lager:debug("recv a member_call while processing a different member"), CallId = kz_json:get_value(<<"Call-ID">>, CallJObj), @@ -444,7 +444,7 @@ connect_req('info', {'timeout', ConnRef, ?CONNECTION_TIMEOUT_MESSAGE}, #state{qu %% @doc %% @end %%-------------------------------------------------------------------- --spec connecting(gen_statem:event_type(), any(), state()) -> handle_fsm_ret(state()). +-spec connecting(gen_statem:event_type(), any(), state()) -> kz_types:handle_fsm_ret(state()). connecting('cast', {'member_call', CallJObj, Delivery}, #state{queue_proc=Srv}=State) -> lager:debug("recv a member_call while connecting"), acdc_queue_listener:cancel_member_call(Srv, CallJObj, Delivery), @@ -617,7 +617,7 @@ connecting('info', {'timeout', ConnRef, ?CONNECTION_TIMEOUT_MESSAGE}, #state{que %% @doc %% @end %%-------------------------------------------------------------------- --spec handle_event(any(), atom(), state()) -> handle_fsm_ret(state()). +-spec handle_event(any(), atom(), state()) -> kz_types:handle_fsm_ret(state()). handle_event({'refresh', QueueJObj}, StateName, State) -> lager:debug("refreshing queue configs"), {'next_state', StateName, update_properties(QueueJObj, State), 'hibernate'}; @@ -676,7 +676,7 @@ code_change(_OldVsn, StateName, State, _Extra) -> start_collect_timer() -> erlang:start_timer(?COLLECT_RESP_TIMEOUT, self(), ?COLLECT_RESP_MESSAGE). --spec connection_timeout(api_integer()) -> pos_integer(). +-spec connection_timeout(kz_term:api_integer()) -> pos_integer(). connection_timeout(N) when is_integer(N), N > 0 -> N * 1000; connection_timeout(_) -> ?CONNECTION_TIMEOUT. @@ -684,7 +684,7 @@ connection_timeout(_) -> ?CONNECTION_TIMEOUT. start_connection_timer(ConnTimeout) -> erlang:start_timer(ConnTimeout, self(), ?CONNECTION_TIMEOUT_MESSAGE). --spec agent_ring_timeout(api_integer()) -> pos_integer(). +-spec agent_ring_timeout(kz_term:api_integer()) -> pos_integer(). agent_ring_timeout(N) when is_integer(N), N > 0 -> N; agent_ring_timeout(_) -> ?AGENT_RING_TIMEOUT. @@ -692,13 +692,13 @@ agent_ring_timeout(_) -> ?AGENT_RING_TIMEOUT. start_agent_ring_timer(AgentTimeout) -> erlang:start_timer(AgentTimeout * 1600, self(), ?AGENT_RING_TIMEOUT_MESSAGE). --spec maybe_stop_timer(api_reference()) -> 'ok'. +-spec maybe_stop_timer(kz_term:api_reference()) -> 'ok'. maybe_stop_timer('undefined') -> 'ok'; maybe_stop_timer(ConnRef) -> _ = erlang:cancel_timer(ConnRef), 'ok'. --spec maybe_timeout_winner(pid(), api_object()) -> 'ok'. +-spec maybe_timeout_winner(pid(), kz_term:api_object()) -> 'ok'. maybe_timeout_winner(Srv, 'undefined') -> acdc_queue_listener:timeout_member_call(Srv); maybe_timeout_winner(Srv, Winner) -> @@ -743,7 +743,7 @@ update_properties(QueueJObj, State) -> %%,strategy = get_strategy(kz_json:get_value(<<"strategy">>, QueueJObj)) }. --spec current_call('undefined' | kapps_call:call(), api_reference() | kz_timeout(), kz_timeout()) -> api_object(). +-spec current_call('undefined' | kapps_call:call(), kz_term:api_reference() | timeout(), timeout()) -> kz_term:api_object(). current_call('undefined', _, _) -> 'undefined'; current_call(Call, QueueTimeLeft, Start) -> kz_json:from_list([{<<"call_id">>, kapps_call:call_id(Call)} @@ -755,7 +755,7 @@ current_call(Call, QueueTimeLeft, Start) -> ,{<<"wait_time">>, elapsed(Start)} ]). --spec elapsed(api_reference() | kz_timeout() | integer()) -> api_integer(). +-spec elapsed(kz_term:api_reference() | timeout() | integer()) -> kz_term:api_integer(). elapsed('undefined') -> 'undefined'; elapsed(Ref) when is_reference(Ref) -> case erlang:read_timer(Ref) of @@ -813,7 +813,7 @@ maybe_delay_connect_req(Call, CallJObj, Delivery, #state{queue_proc=QueueSrv %% state() %% @end %%-------------------------------------------------------------------- --spec maybe_connect_re_req(pid(), pid(), state()) -> handle_fsm_ret(state()). +-spec maybe_connect_re_req(pid(), pid(), state()) -> kz_types:handle_fsm_ret(state()). maybe_connect_re_req(MgrSrv, ListenerSrv, #state{account_id=AccountId ,queue_id=QueueId ,member_call=Call @@ -914,10 +914,10 @@ maybe_pick_winner(#state{connect_resps=CRs {'ready', clear_member_call(State)} end. --spec have_agents_responded(kz_json:objects(), ne_binaries()) -> boolean(). +-spec have_agents_responded(kz_json:objects(), kz_term:ne_binaries()) -> boolean(). have_agents_responded(Resps, Agents) -> lists:foldl(fun filter_agents/2, Agents, Resps) =:= []. --spec filter_agents(kz_json:object(), ne_binaries()) -> ne_binaries(). +-spec filter_agents(kz_json:object(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). filter_agents(Resp, AgentsAcc) -> lists:delete(kz_json:get_value(<<"Agent-ID">>, Resp), AgentsAcc). diff --git a/applications/acdc/src/acdc_queue_handler.erl b/applications/acdc/src/acdc_queue_handler.erl index 73af2fb4ebe..a3b7d3d4cbe 100644 --- a/applications/acdc/src/acdc_queue_handler.erl +++ b/applications/acdc/src/acdc_queue_handler.erl @@ -20,8 +20,8 @@ -include("acdc.hrl"). -include_lib("kazoo_amqp/include/kapi_conf.hrl"). --spec handle_call_event(kz_json:object(), kz_proplist()) -> 'ok'. --spec handle_call_event(ne_binary(), ne_binary(), kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_call_event(kz_json:object(), kz_term:proplist()) -> 'ok'. +-spec handle_call_event(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), kz_term:proplist()) -> 'ok'. handle_call_event(JObj, Props) -> 'true' = kapi_call:event_v(JObj), {Cat, Name} = kz_util:get_event_type(JObj), @@ -48,28 +48,28 @@ handle_call_event(Category, Name, JObj, Props) -> ,JObj ). --spec handle_member_call(kz_json:object(), kz_proplist(), gen_listener:basic_deliver()) -> 'ok'. +-spec handle_member_call(kz_json:object(), kz_term:proplist(), gen_listener:basic_deliver()) -> 'ok'. handle_member_call(JObj, Props, Delivery) -> 'true' = kapi_acdc_queue:member_call_v(JObj), acdc_queue_fsm:member_call(props:get_value('fsm_pid', Props), JObj, Delivery), gen_listener:cast(props:get_value('server', Props), {'delivery', Delivery}). --spec handle_member_resp(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_member_resp(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_member_resp(JObj, Props) -> 'true' = kapi_acdc_queue:member_connect_resp_v(JObj), acdc_queue_fsm:member_connect_resp(props:get_value('fsm_pid', Props), JObj). --spec handle_member_accepted(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_member_accepted(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_member_accepted(JObj, Props) -> 'true' = kapi_acdc_queue:member_connect_accepted_v(JObj), acdc_queue_fsm:member_accepted(props:get_value('fsm_pid', Props), JObj). --spec handle_member_retry(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_member_retry(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_member_retry(JObj, Props) -> 'true' = kapi_acdc_queue:member_connect_retry_v(JObj), acdc_queue_fsm:member_connect_retry(props:get_value('fsm_pid', Props), JObj). --spec handle_config_change(kz_json:object(), kz_proplist()) -> any(). +-spec handle_config_change(kz_json:object(), kz_term:proplist()) -> any(). handle_config_change(JObj, _Props) -> 'true' = kapi_conf:doc_update_v(JObj), handle_queue_change(kz_json:get_value(<<"Database">>, JObj) @@ -78,7 +78,7 @@ handle_config_change(JObj, _Props) -> ,kz_json:get_value(<<"Event-Name">>, JObj) ). --spec handle_queue_change(ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec handle_queue_change(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. handle_queue_change(_, AccountId, QueueId, ?DOC_CREATED) -> lager:debug("maybe starting new queue for ~s: ~s", [AccountId, QueueId]), case acdc_queues_sup:find_queue_supervisor(AccountId, QueueId) of @@ -107,7 +107,7 @@ handle_queue_change(_, AccountId, QueueId, ?DOC_DELETED) -> acdc_queue_sup:stop(P) end. --spec handle_presence_probe(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_presence_probe(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_presence_probe(JObj, _Props) -> 'true' = kapi_presence:probe_v(JObj), Realm = kz_json:get_value(<<"Realm">>, JObj), diff --git a/applications/acdc/src/acdc_queue_listener.erl b/applications/acdc/src/acdc_queue_listener.erl index c28375c9060..669449cb0ad 100644 --- a/applications/acdc/src/acdc_queue_listener.erl +++ b/applications/acdc/src/acdc_queue_listener.erl @@ -53,23 +53,23 @@ -define(SERVER, ?MODULE). --record(state, {queue_id :: ne_binary() - ,account_id :: ne_binary() +-record(state, {queue_id :: kz_term:ne_binary() + ,account_id :: kz_term:ne_binary() %% PIDs of the gang ,worker_sup :: pid() ,mgr_pid :: pid() - ,fsm_pid :: api_pid() - ,shared_pid :: api_pid() + ,fsm_pid :: kz_term:api_pid() + ,shared_pid :: kz_term:api_pid() %% AMQP-related - ,my_id :: ne_binary() - ,my_q :: api_ne_binary() - ,member_call_queue :: api_ne_binary() + ,my_id :: kz_term:ne_binary() + ,my_q :: kz_term:api_ne_binary() + ,member_call_queue :: kz_term:api_ne_binary() %% While processing a call ,call :: kapps_call:call() | 'undefined' - ,agent_id :: api_ne_binary() + ,agent_id :: kz_term:api_ne_binary() ,delivery :: gen_listener:basic_deliver() | 'undefined' }). -type state() :: #state{}. @@ -102,7 +102,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(pid(), pid(), ne_binary(), ne_binary()) -> startlink_ret(). +-spec start_link(pid(), pid(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_types:startlink_ret(). start_link(WorkerSup, MgrPid, AccountId, QueueId) -> gen_listener:start_link(?SERVER ,[{'bindings', [{'acdc_queue', [{'restrict_to', ['sync_req']} @@ -120,7 +120,7 @@ start_link(WorkerSup, MgrPid, AccountId, QueueId) -> accept_member_calls(Srv) -> gen_listener:cast(Srv, {'accept_member_calls'}). --spec member_connect_req(pid(), kz_json:object(), any(), api_binary()) -> 'ok'. +-spec member_connect_req(pid(), kz_json:object(), any(), kz_term:api_binary()) -> 'ok'. member_connect_req(Srv, MemberCallJObj, Delivery, Url) -> gen_listener:cast(Srv, {'member_connect_req', MemberCallJObj, Delivery, Url}). @@ -128,7 +128,7 @@ member_connect_req(Srv, MemberCallJObj, Delivery, Url) -> member_connect_re_req(Srv) -> gen_listener:cast(Srv, {'member_connect_re_req'}). --spec member_connect_win(pid(), kz_json:object(), kz_proplist()) -> 'ok'. +-spec member_connect_win(pid(), kz_json:object(), kz_term:proplist()) -> 'ok'. member_connect_win(Srv, RespJObj, QueueOpts) -> gen_listener:cast(Srv, {'member_connect_win', RespJObj, QueueOpts}). @@ -140,7 +140,7 @@ timeout_agent(Srv, RespJObj) -> timeout_member_call(Srv) -> timeout_member_call(Srv, 'undefined'). --spec timeout_member_call(pid(), api_object()) -> 'ok'. +-spec timeout_member_call(pid(), kz_term:api_object()) -> 'ok'. timeout_member_call(Srv, JObj) -> gen_listener:cast(Srv, {'timeout_member_call', JObj}). @@ -173,12 +173,12 @@ cancel_member_call(Srv, MemberCallJObj, Delivery) -> ignore_member_call(Srv, Call, Delivery) -> gen_listener:cast(Srv, {'ignore_member_call', Call, Delivery}). --spec send_sync_req(pid(), ne_binary()) -> 'ok'. +-spec send_sync_req(pid(), kz_term:ne_binary()) -> 'ok'. send_sync_req(Srv, Type) -> gen_listener:cast(Srv, {'send_sync_req', Type}). -spec config(pid()) -> - {ne_binary(), ne_binary()}. + {kz_term:ne_binary(), kz_term:ne_binary()}. config(Srv) -> gen_listener:call(Srv, 'config'). @@ -226,7 +226,7 @@ init([WorkerSup, MgrPid, AccountId, QueueId]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call('delivery', _From, #state{delivery=D}=State) -> {'reply', D, State}; handle_call('config', _From, #state{account_id=AccountId @@ -253,7 +253,7 @@ find_pid_from_supervisor({'error', {'already_started', P}}) when is_pid(P) -> {'ok', P}; find_pid_from_supervisor(E) -> E. --spec start_shared_queue(state(), pid(), api_integer()) -> {'noreply', state()}. +-spec start_shared_queue(state(), pid(), kz_term:api_integer()) -> {'noreply', state()}. start_shared_queue(#state{account_id=AccountId ,queue_id=QueueId ,worker_sup=WorkerSup @@ -270,7 +270,7 @@ start_shared_queue(#state{account_id=AccountId ,my_id = acdc_util:proc_id(FSMPid) }}. --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'start_friends', QueueJObj}, #state{worker_sup=WorkerSup ,mgr_pid=MgrPid }=State) -> @@ -489,7 +489,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> lager:debug("unhandled message: ~p", [_Info]), {'noreply', State}. @@ -537,13 +537,13 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec maybe_timeout_agent(api_object(), ne_binary(), kapps_call:call(), kz_json:object()) -> 'ok'. +-spec maybe_timeout_agent(kz_term:api_object(), kz_term:ne_binary(), kapps_call:call(), kz_json:object()) -> 'ok'. maybe_timeout_agent('undefined', _QueueId, _Call, _JObj) -> 'ok'; maybe_timeout_agent(_AgentId, QueueId, Call, JObj) -> lager:debug("timing out winning agent because they should not be able to pick up after the queue timeout"), send_agent_timeout(JObj, Call, QueueId). --spec send_member_connect_req(ne_binary(), ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec send_member_connect_req(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. send_member_connect_req(CallId, AccountId, QueueId, MyQ, MyId) -> Req = props:filter_undefined( [{<<"Account-ID">>, AccountId} @@ -555,7 +555,7 @@ send_member_connect_req(CallId, AccountId, QueueId, MyQ, MyId) -> ]), publish(Req, fun kapi_acdc_queue:publish_member_connect_req/1). --spec send_member_connect_win(kz_json:object(), kapps_call:call(), ne_binary(), ne_binary(), ne_binary(), kz_proplist()) -> 'ok'. +-spec send_member_connect_win(kz_json:object(), kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. send_member_connect_win(RespJObj, Call, QueueId, MyQ, MyId, QueueOpts) -> CallJSON = kapps_call:to_json(Call), Q = kz_json:get_value(<<"Server-ID">>, RespJObj), @@ -568,7 +568,7 @@ send_member_connect_win(RespJObj, Call, QueueId, MyQ, MyId, QueueOpts) -> ]), publish(Q, Win, fun kapi_acdc_queue:publish_member_connect_win/2). --spec send_agent_timeout(kz_json:object(), kapps_call:call(), ne_binary()) -> 'ok'. +-spec send_agent_timeout(kz_json:object(), kapps_call:call(), kz_term:ne_binary()) -> 'ok'. send_agent_timeout(RespJObj, Call, QueueId) -> Prop = [{<<"Queue-ID">>, QueueId} ,{<<"Call-ID">>, kapps_call:call_id(Call)} @@ -604,7 +604,7 @@ send_member_call_failure(Q, AccountId, QueueId, CallId, MyId, AgentId, Reason) - ]), publish(Q, Resp, fun kapi_acdc_queue:publish_member_call_failure/2). --spec publish_queue_member_remove(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec publish_queue_member_remove(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. publish_queue_member_remove(AccountId, QueueId, CallId) -> Prop = [{<<"Account-ID">>, AccountId} ,{<<"Queue-ID">>, QueueId} @@ -653,7 +653,7 @@ maybe_nack(Call, Delivery, SharedPid) -> 'false' end. --spec is_call_alive(kapps_call:call() | ne_binary()) -> boolean(). +-spec is_call_alive(kapps_call:call() | kz_term:ne_binary()) -> boolean(). is_call_alive(Call) -> case kapps_call_command:b_channel_status(Call) of {'ok', StatusJObj} -> @@ -677,8 +677,8 @@ clear_call_state(#state{account_id=AccountId ,delivery='undefined' }. --spec publish(api_terms(), kz_amqp_worker:publish_fun()) -> 'ok'. --spec publish(ne_binary(), api_terms(), fun((ne_binary(), api_terms()) -> 'ok')) -> 'ok'. +-spec publish(kz_term:api_terms(), kz_amqp_worker:publish_fun()) -> 'ok'. +-spec publish(kz_term:ne_binary(), kz_term:api_terms(), fun((kz_term:ne_binary(), kz_term:api_terms()) -> 'ok')) -> 'ok'. publish(Req, F) -> try F(Req) catch _E:_R -> diff --git a/applications/acdc/src/acdc_queue_manager.erl b/applications/acdc/src/acdc_queue_manager.erl index 9676ae460c1..3aa45faa1bc 100644 --- a/applications/acdc/src/acdc_queue_manager.erl +++ b/applications/acdc/src/acdc_queue_manager.erl @@ -118,7 +118,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(pid(), kz_json:object()) -> startlink_ret(). +-spec start_link(pid(), kz_json:object()) -> kz_types:startlink_ret(). start_link(Super, QueueJObj) -> AccountId = kz_doc:account_id(QueueJObj), QueueId = kz_doc:id(QueueJObj), @@ -130,7 +130,7 @@ start_link(Super, QueueJObj) -> ,[Super, QueueJObj] ). --spec start_link(pid(), ne_binary(), ne_binary()) -> startlink_ret(). +-spec start_link(pid(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_types:startlink_ret(). start_link(Super, AccountId, QueueId) -> gen_listener:start_link(?SERVER ,[{'bindings', ?BINDINGS(AccountId, QueueId)} @@ -139,7 +139,7 @@ start_link(Super, AccountId, QueueId) -> ,[Super, AccountId, QueueId] ). --spec handle_member_call(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_member_call(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_member_call(JObj, Props) -> 'true' = kapi_acdc_queue:member_call_v(JObj), _ = kz_util:put_callid(JObj), @@ -159,7 +159,7 @@ handle_member_call(JObj, Props) -> start_queue_call(JObj, Props, Call) end. --spec are_agents_available(server_ref()) -> boolean(). +-spec are_agents_available(kz_types:server_ref()) -> boolean(). are_agents_available(Srv) -> are_agents_available(Srv, gen_listener:call(Srv, 'enter_when_empty')). @@ -197,11 +197,11 @@ start_queue_call(JObj, Props, Call) -> %% Add member to queue for tracking position gen_listener:cast(props:get_value('server', Props), {'add_queue_member', JObj}). --spec handle_member_call_success(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_member_call_success(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_member_call_success(JObj, Prop) -> gen_listener:cast(props:get_value('server', Prop), {'handle_queue_member_remove', kz_json:get_value(<<"Call-ID">>, JObj)}). --spec handle_member_call_cancel(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_member_call_cancel(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_member_call_cancel(JObj, Props) -> kz_util:put_callid(JObj), lager:debug("cancel call ~p", [JObj]), @@ -212,7 +212,7 @@ handle_member_call_cancel(JObj, Props) -> ), gen_listener:cast(props:get_value('server', Props), {'member_call_cancel', K, JObj}). --spec handle_agent_change(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_agent_change(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_agent_change(JObj, Prop) -> 'true' = kapi_acdc_queue:agent_change_v(JObj), Server = props:get_value('server', Prop), @@ -227,20 +227,20 @@ handle_agent_change(JObj, Prop) -> gen_listener:cast(Server, {'agent_unavailable', JObj}) end. --spec handle_queue_member_add(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_queue_member_add(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_queue_member_add(JObj, Prop) -> gen_listener:cast(props:get_value('server', Prop), {'handle_queue_member_add', JObj}). --spec handle_queue_member_remove(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_queue_member_remove(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_queue_member_remove(JObj, Prop) -> gen_listener:cast(props:get_value('server', Prop), {'handle_queue_member_remove', kz_json:get_value(<<"Call-ID">>, JObj)}). --spec handle_config_change(server_ref(), kz_json:object()) -> 'ok'. +-spec handle_config_change(kz_types:server_ref(), kz_json:object()) -> 'ok'. handle_config_change(Srv, JObj) -> gen_listener:cast(Srv, {'update_queue_config', JObj}). --spec should_ignore_member_call(server_ref(), kapps_call:call(), kz_json:object()) -> boolean(). --spec should_ignore_member_call(server_ref(), kapps_call:call(), ne_binary(), ne_binary()) -> boolean(). +-spec should_ignore_member_call(kz_types:server_ref(), kapps_call:call(), kz_json:object()) -> boolean(). +-spec should_ignore_member_call(kz_types:server_ref(), kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). should_ignore_member_call(Srv, Call, CallJObj) -> should_ignore_member_call(Srv ,Call @@ -251,17 +251,17 @@ should_ignore_member_call(Srv, Call, AccountId, QueueId) -> K = make_ignore_key(AccountId, QueueId, kapps_call:call_id(Call)), gen_listener:call(Srv, {'should_ignore_member_call', K}). --spec up_next(pid(), ne_binary()) -> boolean(). +-spec up_next(pid(), kz_term:ne_binary()) -> boolean(). up_next(Srv, CallId) -> gen_listener:call(Srv, {'up_next', CallId}). --spec config(pid()) -> {ne_binary(), ne_binary()}. +-spec config(pid()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. config(Srv) -> gen_listener:call(Srv, 'config'). --spec current_agents(server_ref()) -> ne_binaries(). +-spec current_agents(kz_types:server_ref()) -> kz_term:ne_binaries(). current_agents(Srv) -> gen_listener:call(Srv, 'current_agents'). --spec status(pid()) -> ne_binaries(). +-spec status(pid()) -> kz_term:ne_binaries(). status(Srv) -> gen_listener:call(Srv, 'status'). -spec refresh(pid(), kz_json:object()) -> 'ok'. @@ -285,7 +285,7 @@ pick_winner(Srv, Resps) -> pick_winner(Srv, Resps, strategy(Srv), next_winner(Sr %% @private %% @doc Initializes the server %%-------------------------------------------------------------------- --spec init([pid() | kz_json:object() | ne_binary()]) -> {'ok', mgr_state()}. +-spec init([pid() | kz_json:object() | kz_term:ne_binary()]) -> {'ok', mgr_state()}. init([Super, QueueJObj]) -> AccountId = kz_doc:account_id(QueueJObj), QueueId = kz_doc:id(QueueJObj), @@ -338,7 +338,7 @@ init(Super, AccountId, QueueId, QueueJObj) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), mgr_state()) -> handle_call_ret_state(mgr_state()). +-spec handle_call(any(), kz_term:pid_ref(), mgr_state()) -> kz_types:handle_call_ret_state(mgr_state()). handle_call({'should_ignore_member_call', {AccountId, QueueId, CallId}=K}, _, #state{ignored_member_calls=Dict ,account_id=AccountId ,queue_id=QueueId @@ -413,7 +413,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), mgr_state()) -> handle_cast_ret_state(mgr_state()). +-spec handle_cast(any(), mgr_state()) -> kz_types:handle_cast_ret_state(mgr_state()). handle_cast({'update_strategy', StrategyState}, State) -> {'noreply', State#state{strategy_state=StrategyState}, 'hibernate'}; @@ -614,7 +614,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), mgr_state()) -> handle_info_ret_state(mgr_state()). +-spec handle_info(any(), mgr_state()) -> kz_types:handle_info_ret_state(mgr_state()). handle_info(_Info, State) -> lager:debug("unhandled message: ~p", [_Info]), {'noreply', State}. @@ -669,7 +669,7 @@ start_secondary_queue(AccountId, QueueId) -> ,?SECONDARY_BINDINGS(AccountId, QueueId) ]). --spec lookup_priority_levels(ne_binary(), ne_binary()) -> api_integer(). +-spec lookup_priority_levels(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_integer(). lookup_priority_levels(AccountDB, QueueId) -> case kz_datamgr:open_cache_doc(AccountDB, QueueId) of {'ok', JObj} -> kz_json:get_value(<<"max_priority">>, JObj); @@ -679,7 +679,7 @@ lookup_priority_levels(AccountDB, QueueId) -> make_ignore_key(AccountId, QueueId, CallId) -> {AccountId, QueueId, CallId}. --spec publish_queue_member_add(ne_binary(), ne_binary(), kapps_call:call()) -> 'ok'. +-spec publish_queue_member_add(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> 'ok'. publish_queue_member_add(AccountId, QueueId, Call) -> Prop = [{<<"Account-ID">>, AccountId} ,{<<"Queue-ID">>, QueueId} @@ -688,7 +688,7 @@ publish_queue_member_add(AccountId, QueueId, Call) -> ], kapi_acdc_queue:publish_queue_member_add(Prop). --spec publish_queue_member_remove(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec publish_queue_member_remove(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. publish_queue_member_remove(AccountId, QueueId, CallId) -> Prop = [{<<"Account-ID">>, AccountId} ,{<<"Queue-ID">>, QueueId} @@ -697,7 +697,7 @@ publish_queue_member_remove(AccountId, QueueId, CallId) -> ], kapi_acdc_queue:publish_queue_member_remove(Prop). --spec start_agent_and_worker(pid(), ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec start_agent_and_worker(pid(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. start_agent_and_worker(WorkersSup, AccountId, QueueId, AgentJObj) -> acdc_queue_workers_sup:new_worker(WorkersSup, AccountId, QueueId), AgentId = kz_doc:id(AgentJObj), @@ -714,7 +714,7 @@ start_agent_and_worker(WorkersSup, AccountId, QueueId, AgentJObj) -> end. %% Really sophisticated selection algorithm --spec pick_winner(pid(), kz_json:objects(), queue_strategy(), api_binary()) -> +-spec pick_winner(pid(), kz_json:objects(), queue_strategy(), kz_term:api_binary()) -> 'undefined' | {kz_json:objects(), kz_json:objects()}. pick_winner(_, [], _, _) -> @@ -736,7 +736,7 @@ pick_winner(_Mgr, CRs, 'mi', _) -> {[MostIdle|Same], Other}. --spec update_strategy_with_agent(queue_strategy(), strategy_state(), ne_binary(), 'add' | 'remove', 'busy' | 'undefined') -> +-spec update_strategy_with_agent(queue_strategy(), strategy_state(), kz_term:ne_binary(), 'add' | 'remove', 'busy' | 'undefined') -> strategy_state(). update_strategy_with_agent('rr', #strategy_state{agents=AgentQueue}=SS, AgentId, 'add', Busy) -> case queue:member(AgentId, AgentQueue) of @@ -763,7 +763,7 @@ update_strategy_with_agent('mi', #strategy_state{agents=AgentL}=SS, AgentId, 're 'true' -> set_busy(AgentId, Busy, remove_agent('mi', AgentId, SS)) end. --spec add_agent(queue_strategy(), ne_binary(), strategy_state()) -> strategy_state(). +-spec add_agent(queue_strategy(), kz_term:ne_binary(), strategy_state()) -> strategy_state(). add_agent('rr', AgentId, #strategy_state{agents=AgentQueue ,details=Details }=SS) -> @@ -777,7 +777,7 @@ add_agent('mi', AgentId, #strategy_state{agents=AgentL ,details=incr_agent(AgentId, Details) }. --spec remove_agent(queue_strategy(), ne_binary(), strategy_state()) -> strategy_state(). +-spec remove_agent(queue_strategy(), kz_term:ne_binary(), strategy_state()) -> strategy_state(). remove_agent('rr', AgentId, #strategy_state{agents=AgentQueue ,details=Details }=SS) -> @@ -804,19 +804,19 @@ remove_agent('mi', AgentId, #strategy_state{agents=AgentL } end. --spec incr_agent(ne_binary(), dict:dict(ne_binary(), ss_details())) -> - dict:dict(ne_binary(), ss_details()). +-spec incr_agent(kz_term:ne_binary(), dict:dict(kz_term:ne_binary(), ss_details())) -> + dict:dict(kz_term:ne_binary(), ss_details()). incr_agent(AgentId, Details) -> dict:update(AgentId, fun({Count, Busy}) -> {Count + 1, Busy} end, {1, 'undefined'}, Details). --spec decr_agent(ne_binary(), dict:dict(ne_binary(), ss_details())) -> - dict:dict(ne_binary(), ss_details()). +-spec decr_agent(kz_term:ne_binary(), dict:dict(kz_term:ne_binary(), ss_details())) -> + dict:dict(kz_term:ne_binary(), ss_details()). decr_agent(AgentId, Details) -> dict:update(AgentId, fun({Count, Busy}) when Count > 1 -> {Count - 1, Busy}; ({_, Busy}) -> {0, Busy} end ,{0, 'undefined'}, Details). --spec set_busy(ne_binary(), 'busy' | 'undefined', strategy_state()) -> strategy_state(). +-spec set_busy(kz_term:ne_binary(), 'busy' | 'undefined', strategy_state()) -> strategy_state(). set_busy(AgentId, Busy, #strategy_state{details=Details}=SS) -> SS#strategy_state{details=dict:update(AgentId, fun({Count, _}) -> {Count, Busy} end, {0, Busy}, Details)}. @@ -849,21 +849,21 @@ remove_unknown_agents(Mgr, CRs) -> ] end. --spec split_agents(ne_binary(), kz_json:objects()) -> +-spec split_agents(kz_term:ne_binary(), kz_json:objects()) -> {kz_json:objects(), kz_json:objects()}. split_agents(AgentId, Rest) -> lists:partition(fun(R) -> AgentId =:= kz_json:get_value(<<"Agent-ID">>, R) end, Rest). --spec get_strategy(api_binary()) -> queue_strategy(). +-spec get_strategy(kz_term:api_binary()) -> queue_strategy(). get_strategy(<<"round_robin">>) -> 'rr'; get_strategy(<<"most_idle">>) -> 'mi'; get_strategy(_) -> 'rr'. -spec create_strategy_state(queue_strategy() ,strategy_state() - ,ne_binary(), ne_binary() + ,kz_term:ne_binary(), kz_term:ne_binary() ) -> strategy_state(). create_strategy_state(Strategy, AcctDb, QueueId) -> create_strategy_state(Strategy, #strategy_state{}, AcctDb, QueueId). @@ -915,8 +915,8 @@ update_strategy_state(Srv, 'mi', #strategy_state{agents=AgentL}) -> update_strategy_state(Srv, L) -> [gen_listener:cast(Srv, {'sync_with_agent', A}) || A <- L]. --spec call_position(ne_binary(), [kapps_call:call()]) -> api_integer(). --spec call_position(ne_binary(), [kapps_call:call()], pos_integer()) -> pos_integer(). +-spec call_position(kz_term:ne_binary(), [kapps_call:call()]) -> kz_term:api_integer(). +-spec call_position(kz_term:ne_binary(), [kapps_call:call()], pos_integer()) -> pos_integer(). call_position(CallId, Calls) -> call_position(CallId, Calls, 1). @@ -961,7 +961,7 @@ update_properties(QueueJObj, State) -> ,announcements_config=announcements_config(QueueJObj) }. --spec announcements_config(kz_json:object()) -> kz_proplist(). +-spec announcements_config(kz_json:object()) -> kz_term:proplist(). announcements_config(Config) -> kz_json:recursive_to_proplist( kz_json:get_json_value(<<"announcements">>, Config, kz_json:new())). @@ -991,7 +991,7 @@ cancel_position_announcements(Call, Pids) -> Pids1 end. --spec remove_queue_member(api_binary(), mgr_state()) -> mgr_state(). +-spec remove_queue_member(kz_term:api_binary(), mgr_state()) -> mgr_state(). remove_queue_member(CallId, #state{current_member_calls=CurrentCalls ,announcements_pids=AnnouncementsPids }=State) -> diff --git a/applications/acdc/src/acdc_queue_manager.hrl b/applications/acdc/src/acdc_queue_manager.hrl index 2f591d66ce5..8e421dfb359 100644 --- a/applications/acdc/src/acdc_queue_manager.hrl +++ b/applications/acdc/src/acdc_queue_manager.hrl @@ -4,25 +4,25 @@ %% mi :: Most Idle -type queue_strategy() :: 'rr' | 'mi'. --type queue_strategy_state() :: queue:queue() | ne_binaries(). +-type queue_strategy_state() :: queue:queue() | kz_term:ne_binaries(). -type ss_details() :: {non_neg_integer(), 'busy' | 'undefined'}. -record(strategy_state, {agents :: queue_strategy_state() | 'undefined' %% details include # of agent processes and availability - ,details = dict:new() :: dict:dict(ne_binary(), ss_details()) + ,details = dict:new() :: dict:dict(kz_term:ne_binary(), ss_details()) }). -type strategy_state() :: #strategy_state{}. -record(state, {ignored_member_calls = dict:new() :: dict:dict() - ,account_id :: api_ne_binary() - ,queue_id :: api_ne_binary() - ,supervisor :: api_pid() + ,account_id :: kz_term:api_ne_binary() + ,queue_id :: kz_term:api_ne_binary() + ,supervisor :: kz_term:api_pid() ,strategy = 'rr' :: queue_strategy() % round-robin | most-idle ,strategy_state = #strategy_state{} :: strategy_state() % based on the strategy ,known_agents = dict:new() :: dict:dict() % how many agent processes are available {AgentId, Count} ,enter_when_empty = 'true' :: boolean() % allow caller into queue if no agents are logged in - ,moh :: api_ne_binary() + ,moh :: kz_term:api_ne_binary() ,current_member_calls = [] :: list() % ordered list of current members waiting - ,announcements_config = [] :: kz_proplist() + ,announcements_config = [] :: kz_term:proplist() ,announcements_pids = #{} :: announcements_pids() }). -type mgr_state() :: #state{}. diff --git a/applications/acdc/src/acdc_queue_shared.erl b/applications/acdc/src/acdc_queue_shared.erl index f1cbf6e1f00..2bb0ae4a4b9 100644 --- a/applications/acdc/src/acdc_queue_shared.erl +++ b/applications/acdc/src/acdc_queue_shared.erl @@ -65,7 +65,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(server_ref(), ne_binary(), ne_binary(), api_integer()) -> startlink_ret(). +-spec start_link(kz_types:server_ref(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_integer()) -> kz_types:startlink_ret(). start_link(FSMPid, AcctId, QueueId, Priority) -> gen_listener:start_link(?SERVER ,[{'bindings', ?SHARED_QUEUE_BINDINGS(AcctId, QueueId)} @@ -76,17 +76,17 @@ start_link(FSMPid, AcctId, QueueId, Priority) -> ,[FSMPid] ). --spec ack(server_ref(), gen_listener:basic_deliver()) -> 'ok'. +-spec ack(kz_types:server_ref(), gen_listener:basic_deliver()) -> 'ok'. ack(Srv, Delivery) -> gen_listener:ack(Srv, Delivery), gen_listener:cast(Srv, {'ack', Delivery}). --spec nack(server_ref(), gen_listener:basic_deliver()) -> 'ok'. +-spec nack(kz_types:server_ref(), gen_listener:basic_deliver()) -> 'ok'. nack(Srv, Delivery) -> gen_listener:nack(Srv, Delivery), gen_listener:cast(Srv, {'noack', Delivery}). --spec deliveries(server_ref()) -> deliveries(). +-spec deliveries(kz_types:server_ref()) -> deliveries(). deliveries(Srv) -> gen_listener:call(Srv, 'deliveries'). @@ -126,7 +126,7 @@ init([FSMPid]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call('deliveries', _From, #state{deliveries=Ds}=State) -> {'reply', Ds, State}; handle_call(_Request, _From, State) -> @@ -142,7 +142,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'delivery', Delivery}, #state{deliveries=Ds}=State) -> {'noreply', State#state{deliveries=[Delivery|Ds]}}; handle_cast({'ack', Delivery}, #state{deliveries=Ds}=State) -> @@ -167,7 +167,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'basic.cancel',_,'true'}, State) -> lager:debug("recv basic.cancel...no!!!"), {'noreply', State}; diff --git a/applications/acdc/src/acdc_queue_sup.erl b/applications/acdc/src/acdc_queue_sup.erl index e594fcec9e1..88c3bfca91b 100644 --- a/applications/acdc/src/acdc_queue_sup.erl +++ b/applications/acdc/src/acdc_queue_sup.erl @@ -35,7 +35,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link(ne_binary(), ne_binary()) -> startlink_ret(). +-spec start_link(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_types:startlink_ret(). start_link(AcctId, QueueId) -> supervisor:start_link(?SERVER, [AcctId, QueueId]). @@ -43,11 +43,11 @@ start_link(AcctId, QueueId) -> stop(Super) -> supervisor:terminate_child('acdc_queues_sup', Super). --spec manager(pid()) -> api_pid(). +-spec manager(pid()) -> kz_term:api_pid(). manager(Super) -> hd([P || {_, P, 'worker', _} <- supervisor:which_children(Super)]). --spec workers_sup(pid()) -> api_pid(). +-spec workers_sup(pid()) -> kz_term:api_pid(). workers_sup(Super) -> hd([P || {_, P, 'supervisor', _} <- supervisor:which_children(Super)]). @@ -84,7 +84,7 @@ status(Supervisor) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(list()) -> sup_init_ret(). +-spec init(list()) -> kz_types:sup_init_ret(). init(Args) -> RestartStrategy = 'one_for_all', MaxRestarts = 2, diff --git a/applications/acdc/src/acdc_queue_thief.erl b/applications/acdc/src/acdc_queue_thief.erl index b1f317cd2d2..b0341326623 100644 --- a/applications/acdc/src/acdc_queue_thief.erl +++ b/applications/acdc/src/acdc_queue_thief.erl @@ -12,7 +12,7 @@ -include_lib("kazoo_stdlib/include/kz_types.hrl"). --spec connect(kapps_call:call(), ne_binary()) -> 'ok'. +-spec connect(kapps_call:call(), kz_term:ne_binary()) -> 'ok'. connect(_Call, _QueueId) -> %% no! ok. diff --git a/applications/acdc/src/acdc_queue_worker_sup.erl b/applications/acdc/src/acdc_queue_worker_sup.erl index 3fe9c6f4f36..d8b65815e07 100644 --- a/applications/acdc/src/acdc_queue_worker_sup.erl +++ b/applications/acdc/src/acdc_queue_worker_sup.erl @@ -35,39 +35,39 @@ %%-------------------------------------------------------------------- %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link(pid(), ne_binary(), ne_binary()) -> startlink_ret(). +-spec start_link(pid(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_types:startlink_ret(). start_link(MgrPid, AcctId, QueueId) -> supervisor:start_link(?SERVER, [MgrPid, AcctId, QueueId]). -spec stop(pid()) -> 'ok' | {'error', 'not_found'}. stop(WorkerSup) -> supervisor:terminate_child('acdc_queues_sup', WorkerSup). --spec listener(pid()) -> api_pid(). +-spec listener(pid()) -> kz_term:api_pid(). listener(WorkerSup) -> case child_of_type(WorkerSup, 'acdc_queue_listener') of [] -> 'undefined'; [P] -> P end. --spec shared_queue(pid()) -> api_pid(). +-spec shared_queue(pid()) -> kz_term:api_pid(). shared_queue(WorkerSup) -> case child_of_type(WorkerSup, 'acdc_queue_shared') of [] -> 'undefined'; [P] -> P end. --spec start_shared_queue(pid(), pid(), ne_binary(), ne_binary(), api_integer()) -> sup_startchild_ret(). +-spec start_shared_queue(pid(), pid(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_integer()) -> kz_types:sup_startchild_ret(). start_shared_queue(WorkerSup, FSMPid, AcctId, QueueId, Priority) -> supervisor:start_child(WorkerSup, ?WORKER_ARGS('acdc_queue_shared', [FSMPid, AcctId, QueueId, Priority])). --spec fsm(pid()) -> api_pid(). +-spec fsm(pid()) -> kz_term:api_pid(). fsm(WorkerSup) -> case child_of_type(WorkerSup, 'acdc_queue_fsm') of [] -> 'undefined'; [P] -> P end. --spec start_fsm(pid(), pid(), kz_json:object()) -> sup_startchild_ret(). +-spec start_fsm(pid(), pid(), kz_json:object()) -> kz_types:sup_startchild_ret(). start_fsm(WorkerSup, MgrPid, QueueJObj) -> ListenerPid = self(), supervisor:start_child(WorkerSup, ?WORKER_ARGS('acdc_queue_fsm', [MgrPid, ListenerPid, QueueJObj])). @@ -113,7 +113,7 @@ print_status([{K, V}|T]) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(list()) -> sup_init_ret(). +-spec init(list()) -> kz_types:sup_init_ret(). init(Args) -> RestartStrategy = 'one_for_all', MaxRestarts = 2, diff --git a/applications/acdc/src/acdc_queue_workers_sup.erl b/applications/acdc/src/acdc_queue_workers_sup.erl index 61d33e6fe74..996292100ad 100644 --- a/applications/acdc/src/acdc_queue_workers_sup.erl +++ b/applications/acdc/src/acdc_queue_workers_sup.erl @@ -33,21 +33,21 @@ %%-------------------------------------------------------------------- %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link(?SERVER, []). --spec new_worker(pid(), ne_binary(), ne_binary()) -> 'ok'. +-spec new_worker(pid(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. new_worker(WorkersSup, AcctId, QueueId) -> new_workers(WorkersSup, AcctId, QueueId, 1). --spec new_workers(pid(), ne_binary(), ne_binary(), integer()) -> 'ok'. +-spec new_workers(pid(), kz_term:ne_binary(), kz_term:ne_binary(), integer()) -> 'ok'. new_workers(_, _,_,N) when N =< 0 -> 'ok'; new_workers(WorkersSup, AcctId, QueueId, N) when is_integer(N) -> _ = supervisor:start_child(WorkersSup, [self(), AcctId, QueueId]), new_workers(WorkersSup, AcctId, QueueId, N-1). --spec workers(pid()) -> pids(). +-spec workers(pid()) -> kz_term:pids(). workers(Super) -> [Pid || {_, Pid, 'supervisor', [_]} <- supervisor:which_children(Super), is_pid(Pid)]. @@ -72,7 +72,7 @@ status(Super) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 1, diff --git a/applications/acdc/src/acdc_queues_sup.erl b/applications/acdc/src/acdc_queues_sup.erl index f5e889a4975..50fee89a0be 100644 --- a/applications/acdc/src/acdc_queues_sup.erl +++ b/applications/acdc/src/acdc_queues_sup.erl @@ -36,26 +36,26 @@ %%-------------------------------------------------------------------- %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec new(ne_binary(), ne_binary()) -> startlink_ret(). +-spec new(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_types:startlink_ret(). new(AcctId, QueueId) -> case find_queue_supervisor(AcctId, QueueId) of P when is_pid(P) -> {'ok', P}; 'undefined' -> supervisor:start_child(?SERVER, [AcctId, QueueId]) end. --spec workers() -> pids(). +-spec workers() -> kz_term:pids(). workers() -> [Pid || {_, Pid, 'supervisor', _} <- supervisor:which_children(?SERVER), is_pid(Pid)]. --spec find_acct_supervisors(ne_binary()) -> pids(). +-spec find_acct_supervisors(kz_term:ne_binary()) -> kz_term:pids(). find_acct_supervisors(AcctId) -> [Super || Super <- workers(), is_queue_in_acct(Super, AcctId)]. --spec is_queue_in_acct(pid(), ne_binary()) -> boolean(). +-spec is_queue_in_acct(pid(), kz_term:ne_binary()) -> boolean(). is_queue_in_acct(Super, AcctId) -> case catch acdc_queue_manager:config(acdc_queue_sup:manager(Super)) of {'EXIT', _} -> 'false'; @@ -63,8 +63,8 @@ is_queue_in_acct(Super, AcctId) -> _ -> 'false' end. --spec find_queue_supervisor(ne_binary(), ne_binary()) -> api_pid(). --spec find_queue_supervisor(ne_binary(), ne_binary(), pids()) -> api_pid(). +-spec find_queue_supervisor(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_pid(). +-spec find_queue_supervisor(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:pids()) -> kz_term:api_pid(). find_queue_supervisor(AcctId, QueueId) -> find_queue_supervisor(AcctId, QueueId, workers()). @@ -100,7 +100,7 @@ queues_running() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 1, diff --git a/applications/acdc/src/acdc_recordings_sup.erl b/applications/acdc/src/acdc_recordings_sup.erl index a8a5f1ca387..08477a88ddd 100644 --- a/applications/acdc/src/acdc_recordings_sup.erl +++ b/applications/acdc/src/acdc_recordings_sup.erl @@ -31,11 +31,11 @@ %%-------------------------------------------------------------------- %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec new(kapps_call:call(), kz_json:object()) -> startlink_ret(). +-spec new(kapps_call:call(), kz_json:object()) -> kz_types:startlink_ret(). new(Call, Data) -> supervisor:start_child(?SERVER, [Call, Data]). @@ -52,7 +52,7 @@ new(Call, Data) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 1, diff --git a/applications/acdc/src/acdc_stats.erl b/applications/acdc/src/acdc_stats.erl index ca9f7594b31..14826c4ac42 100644 --- a/applications/acdc/src/acdc_stats.erl +++ b/applications/acdc/src/acdc_stats.erl @@ -63,12 +63,12 @@ -define(SERVER, ?MODULE). %% Public API --spec call_waiting(api_binary() - ,api_binary() - ,api_binary() - ,api_binary() - ,api_binary() - ,api_binary() +-spec call_waiting(kz_term:api_binary() + ,kz_term:api_binary() + ,kz_term:api_binary() + ,kz_term:api_binary() + ,kz_term:api_binary() + ,kz_term:api_binary() ) -> 'ok'. call_waiting(AccountId, QueueId, CallId, CallerIdName, CallerIdNumber, CallerPriority) -> Prop = props:filter_undefined( @@ -83,7 +83,7 @@ call_waiting(AccountId, QueueId, CallId, CallerIdName, CallerIdNumber, CallerPri ]), 'ok' = kz_amqp_worker:cast(Prop, fun kapi_acdc_stats:publish_call_waiting/1). --spec call_abandoned(ne_binary(), ne_binary(), ne_binary(), atom()) -> 'ok'. +-spec call_abandoned(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), atom()) -> 'ok'. call_abandoned(AccountId, QueueId, CallId, Reason) -> Prop = props:filter_undefined( [{<<"Account-ID">>, AccountId} @@ -95,7 +95,7 @@ call_abandoned(AccountId, QueueId, CallId, Reason) -> ]), 'ok' = kz_amqp_worker:cast(Prop, fun kapi_acdc_stats:publish_call_abandoned/1). --spec call_handled(ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec call_handled(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. call_handled(AccountId, QueueId, CallId, AgentId) -> Prop = props:filter_undefined( [{<<"Account-ID">>, AccountId} @@ -107,7 +107,7 @@ call_handled(AccountId, QueueId, CallId, AgentId) -> ]), 'ok' = kz_amqp_worker:cast(Prop, fun kapi_acdc_stats:publish_call_handled/1). --spec call_missed(ne_binary(), ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec call_missed(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. call_missed(AccountId, QueueId, AgentId, CallId, ErrReason) -> Prop = props:filter_undefined( [{<<"Account-ID">>, AccountId} @@ -120,7 +120,7 @@ call_missed(AccountId, QueueId, AgentId, CallId, ErrReason) -> ]), 'ok' = kz_amqp_worker:cast(Prop, fun kapi_acdc_stats:publish_call_missed/1). --spec call_processed(ne_binary(), ne_binary(), ne_binary(), ne_binary(), atom()) -> 'ok'. +-spec call_processed(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), atom()) -> 'ok'. call_processed(AccountId, QueueId, AgentId, CallId, Initiator) -> Prop = props:filter_undefined( [{<<"Account-ID">>, AccountId} @@ -133,7 +133,7 @@ call_processed(AccountId, QueueId, AgentId, CallId, Initiator) -> ]), 'ok' = kz_amqp_worker:cast(Prop, fun kapi_acdc_stats:publish_call_processed/1). --spec agent_ready(ne_binary(), ne_binary()) -> 'ok'. +-spec agent_ready(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. agent_ready(AcctId, AgentId) -> Prop = props:filter_undefined( [{<<"Account-ID">>, AcctId} @@ -144,7 +144,7 @@ agent_ready(AcctId, AgentId) -> ]), 'ok' = kz_amqp_worker:cast(Prop, fun kapi_acdc_stats:publish_status_ready/1). --spec agent_logged_in(ne_binary(), ne_binary()) -> 'ok'. +-spec agent_logged_in(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. agent_logged_in(AcctId, AgentId) -> Prop = props:filter_undefined( [{<<"Account-ID">>, AcctId} @@ -155,7 +155,7 @@ agent_logged_in(AcctId, AgentId) -> ]), 'ok' = kz_amqp_worker:cast(Prop, fun kapi_acdc_stats:publish_status_logged_in/1). --spec agent_logged_out(ne_binary(), ne_binary()) -> 'ok'. +-spec agent_logged_out(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. agent_logged_out(AcctId, AgentId) -> Prop = props:filter_undefined( [{<<"Account-ID">>, AcctId} @@ -166,8 +166,8 @@ agent_logged_out(AcctId, AgentId) -> ]), 'ok' = kz_amqp_worker:cast(Prop, fun kapi_acdc_stats:publish_status_logged_out/1). --spec agent_connecting(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. --spec agent_connecting(ne_binary(), ne_binary(), ne_binary(), api_ne_binary(), api_ne_binary()) -> 'ok'. +-spec agent_connecting(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. +-spec agent_connecting(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> 'ok'. agent_connecting(AcctId, AgentId, CallId) -> agent_connecting(AcctId, AgentId, CallId, 'undefined', 'undefined'). agent_connecting(AcctId, AgentId, CallId, CallerIDName, CallerIDNumber) -> @@ -183,8 +183,8 @@ agent_connecting(AcctId, AgentId, CallId, CallerIDName, CallerIDNumber) -> ]), 'ok' = kz_amqp_worker:cast(Prop, fun kapi_acdc_stats:publish_status_connecting/1). --spec agent_connected(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. --spec agent_connected(ne_binary(), ne_binary(), ne_binary(), api_ne_binary(), api_ne_binary()) -> 'ok'. +-spec agent_connected(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. +-spec agent_connected(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> 'ok'. agent_connected(AcctId, AgentId, CallId) -> agent_connected(AcctId, AgentId, CallId, 'undefined', 'undefined'). agent_connected(AcctId, AgentId, CallId, CallerIDName, CallerIDNumber) -> @@ -200,7 +200,7 @@ agent_connected(AcctId, AgentId, CallId, CallerIDName, CallerIDNumber) -> ]), 'ok' = kz_amqp_worker:cast(Prop, fun kapi_acdc_stats:publish_status_connected/1). --spec agent_wrapup(ne_binary(), ne_binary(), pos_integer()) -> 'ok'. +-spec agent_wrapup(kz_term:ne_binary(), kz_term:ne_binary(), pos_integer()) -> 'ok'. agent_wrapup(AcctId, AgentId, WaitTime) -> Prop = props:filter_undefined( [{<<"Account-ID">>, AcctId} @@ -212,7 +212,7 @@ agent_wrapup(AcctId, AgentId, WaitTime) -> ]), 'ok' = kz_amqp_worker:cast(Prop, fun kapi_acdc_stats:publish_status_wrapup/1). --spec agent_paused(ne_binary(), ne_binary(), api_pos_integer()) -> 'ok'. +-spec agent_paused(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_pos_integer()) -> 'ok'. agent_paused(AcctId, AgentId, 'undefined') -> lager:debug("undefined pause time for ~s(~s)", [AgentId, AcctId]); agent_paused(AcctId, AgentId, PauseTime) -> @@ -226,7 +226,7 @@ agent_paused(AcctId, AgentId, PauseTime) -> ]), 'ok' = kz_amqp_worker:cast(Prop, fun kapi_acdc_stats:publish_status_paused/1). --spec agent_outbound(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec agent_outbound(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. agent_outbound(AcctId, AgentId, CallId) -> Prop = props:filter_undefined( [{<<"Account-ID">>, AcctId} @@ -238,14 +238,14 @@ agent_outbound(AcctId, AgentId, CallId) -> ]), 'ok' = kz_amqp_worker:cast(Prop, fun kapi_acdc_stats:publish_status_outbound/1). --spec agent_statuses() -> ne_binaries(). +-spec agent_statuses() -> kz_term:ne_binaries(). agent_statuses() -> ?STATUS_STATUSES. %% ETS config -spec call_table_id() -> atom(). -spec call_key_pos() -> pos_integer(). --spec call_table_opts() -> kz_proplist(). +-spec call_table_opts() -> kz_term:proplist(). call_table_id() -> 'acdc_stats_call'. call_key_pos() -> #call_stat.id. call_table_opts() -> @@ -286,7 +286,7 @@ call_table_opts() -> ]). -define(QUEUE_NAME, <<>>). --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER ,[{'bindings', ?BINDINGS} @@ -295,7 +295,7 @@ start_link() -> ], []). --spec handle_call_stat(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_call_stat(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_call_stat(JObj, Props) -> case kz_json:get_value(<<"Event-Name">>, JObj) of <<"waiting">> -> handle_waiting_stat(JObj, Props); @@ -308,7 +308,7 @@ handle_call_stat(JObj, Props) -> lager:debug("recv unknown call stat type ~s: ~p", [_Name, JObj]) end. --spec handle_call_query(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_call_query(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_call_query(JObj, _Prop) -> 'true' = kapi_acdc_stats:current_calls_req_v(JObj), RespQ = kz_json:get_value(<<"Server-ID">>, JObj), @@ -320,7 +320,7 @@ handle_call_query(JObj, _Prop) -> {'error', Errors} -> publish_query_errors(RespQ, MsgId, Errors) end. --spec find_call(ne_binary()) -> api_object(). +-spec find_call(kz_term:ne_binary()) -> kz_term:api_object(). find_call(CallId) -> MS = [{#call_stat{call_id=CallId ,_ = '_' @@ -356,11 +356,11 @@ start_archive_timer() -> start_cleanup_timer() -> erlang:send_after(?CLEANUP_PERIOD, self(), ?CLEANUP_MSG). --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Req, _From, State) -> {'reply', 'ok', State}. --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'create_call', #call_stat{id=_Id}=Stat}, State) -> lager:debug("creating new call stat ~s", [_Id]), ets:insert_new(call_table_id(), Stat), @@ -408,7 +408,7 @@ handle_cast(_Req, State) -> lager:debug("unhandled cast: ~p", [_Req]), {'noreply', State}. --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'ETS-TRANSFER', _TblId, _From, _Data}, State) -> lager:debug("ETS control for ~p transferred to me for writing", [_TblId]), {'noreply', State}; @@ -535,7 +535,7 @@ is_valid_call_status(S) -> 'false' -> 'false' end. --spec query_calls(ne_binary(), ne_binary(), ets:match_spec(), pos_integer()) -> 'ok'. +-spec query_calls(kz_term:ne_binary(), kz_term:ne_binary(), ets:match_spec(), pos_integer()) -> 'ok'. query_calls(RespQ, MsgId, Match, _Limit) -> case ets:select(call_table_id(), Match) of [] -> @@ -773,12 +773,12 @@ miss_to_doc(#agent_miss{agent_id=AgentId ,{<<"timestamp">>, T} ]). --spec init_db(ne_binary()) -> 'ok'. +-spec init_db(kz_term:ne_binary()) -> 'ok'. init_db(AccountId) -> DbName = acdc_stats_util:db_name(AccountId), maybe_created_db(DbName, kazoo_modb:maybe_create(DbName)). --spec maybe_created_db(ne_binary(), boolean()) -> 'ok'. +-spec maybe_created_db(kz_term:ne_binary(), boolean()) -> 'ok'. maybe_created_db(DbName, 'false') -> case kz_datamgr:db_exists(DbName) of 'true' -> @@ -791,15 +791,15 @@ maybe_created_db(DbName, 'true') -> lager:debug("created db ~s, adding views", [DbName]), kz_datamgr:revise_views_from_folder(DbName, 'acdc'). --spec call_stat_id(kz_json:object()) -> ne_binary(). --spec call_stat_id(ne_binary(), ne_binary()) -> ne_binary(). +-spec call_stat_id(kz_json:object()) -> kz_term:ne_binary(). +-spec call_stat_id(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). call_stat_id(JObj) -> call_stat_id(kz_json:get_value(<<"Call-ID">>, JObj) ,kz_json:get_value(<<"Queue-ID">>, JObj) ). call_stat_id(CallId, QueueId) -> <>. --spec handle_waiting_stat(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_waiting_stat(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_waiting_stat(JObj, Props) -> 'true' = kapi_acdc_stats:call_waiting_v(JObj), @@ -814,7 +814,7 @@ handle_waiting_stat(JObj, Props) -> update_call_stat(Id, Updates, Props) end. --spec handle_missed_stat(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_missed_stat(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_missed_stat(JObj, Props) -> 'true' = kapi_acdc_stats:call_missed_v(JObj), @@ -833,7 +833,7 @@ create_miss(JObj) -> ,miss_timestamp = kz_json:get_value(<<"Miss-Timestamp">>, JObj) }. --spec handle_abandoned_stat(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_abandoned_stat(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_abandoned_stat(JObj, Props) -> 'true' = kapi_acdc_stats:call_abandoned_v(JObj), @@ -845,7 +845,7 @@ handle_abandoned_stat(JObj, Props) -> ]), update_call_stat(Id, Updates, Props). --spec handle_handled_stat(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_handled_stat(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_handled_stat(JObj, Props) -> 'true' = kapi_acdc_stats:call_handled_v(JObj), @@ -857,7 +857,7 @@ handle_handled_stat(JObj, Props) -> ]), update_call_stat(Id, Updates, Props). --spec handle_processed_stat(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_processed_stat(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_processed_stat(JObj, Props) -> 'true' = kapi_acdc_stats:call_processed_v(JObj), @@ -870,7 +870,7 @@ handle_processed_stat(JObj, Props) -> ]), update_call_stat(Id, Updates, Props). --spec flush_call_stat(kz_json:object(), kz_proplist()) -> 'ok'. +-spec flush_call_stat(kz_json:object(), kz_term:proplist()) -> 'ok'. flush_call_stat(JObj, Props) -> 'true' = kapi_acdc_stats:call_flush_v(JObj), @@ -882,14 +882,14 @@ flush_call_stat(JObj, Props) -> ,{'flush_call', Id} ). --spec find_call_stat(ne_binary()) -> 'undefined' | call_stat(). +-spec find_call_stat(kz_term:ne_binary()) -> 'undefined' | call_stat(). find_call_stat(Id) -> case ets:lookup(call_table_id(), Id) of [] -> 'undefined'; [Stat] -> Stat end. --spec create_call_stat(ne_binary(), kz_json:object(), kz_proplist()) -> 'ok'. +-spec create_call_stat(kz_term:ne_binary(), kz_json:object(), kz_term:proplist()) -> 'ok'. create_call_stat(Id, JObj, Props) -> gen_listener:cast(props:get_value('server', Props) ,{'create_call', #call_stat{ @@ -907,6 +907,6 @@ create_call_stat(Id, JObj, Props) -> }). -type updates() :: [{pos_integer(), any()}]. --spec update_call_stat(ne_binary(), updates(), kz_proplist()) -> 'ok'. +-spec update_call_stat(kz_term:ne_binary(), updates(), kz_term:proplist()) -> 'ok'. update_call_stat(Id, Updates, Props) -> gen_listener:cast(props:get_value('server', Props), {'update_call', Id, Updates}). diff --git a/applications/acdc/src/acdc_stats.hrl b/applications/acdc/src/acdc_stats.hrl index 344060ea75d..b14d09f8873 100644 --- a/applications/acdc/src/acdc_stats.hrl +++ b/applications/acdc/src/acdc_stats.hrl @@ -7,35 +7,35 @@ -define(MAX_RESULT_SET, kapps_config:get_integer(?CONFIG_CAT, <<"max_result_set">>, 25)). --record(agent_miss, {agent_id :: api_binary() - ,miss_reason :: api_binary() +-record(agent_miss, {agent_id :: kz_term:api_binary() + ,miss_reason :: kz_term:api_binary() ,miss_timestamp = kz_time:now_s() :: pos_integer() }). -type agent_miss() :: #agent_miss{}. -type agent_misses() :: [agent_miss()]. --record(call_stat, {id :: api_binary() | '_' %% call_id::queue_id - ,call_id :: api_binary() | '_' - ,account_id :: api_binary() | '$1' | '_' - ,queue_id :: api_binary() | '$2' | '_' +-record(call_stat, {id :: kz_term:api_binary() | '_' %% call_id::queue_id + ,call_id :: kz_term:api_binary() | '_' + ,account_id :: kz_term:api_binary() | '$1' | '_' + ,queue_id :: kz_term:api_binary() | '$2' | '_' - ,agent_id :: api_binary() | '$3' | '_' % the handling agent + ,agent_id :: kz_term:api_binary() | '$3' | '_' % the handling agent ,entered_timestamp = kz_time:now_s() :: pos_integer() | '$1' | '$5' | '_' - ,abandoned_timestamp :: api_integer() | '_' - ,handled_timestamp :: api_integer() | '_' - ,processed_timestamp :: api_integer() | '_' + ,abandoned_timestamp :: kz_term:api_integer() | '_' + ,handled_timestamp :: kz_term:api_integer() | '_' + ,processed_timestamp :: kz_term:api_integer() | '_' - ,hung_up_by :: api_binary() | '_' + ,hung_up_by :: kz_term:api_binary() | '_' - ,abandoned_reason :: api_binary() | '_' + ,abandoned_reason :: kz_term:api_binary() | '_' ,misses = [] :: agent_misses() | '_' - ,status :: api_binary() | '$1' | '$2' | '$4' | '_' - ,caller_id_name :: api_binary() | '_' - ,caller_id_number :: api_binary() | '_' - ,caller_priority :: api_integer() | '_' + ,status :: kz_term:api_binary() | '$1' | '$2' | '$4' | '_' + ,caller_id_name :: kz_term:api_binary() | '_' + ,caller_id_number :: kz_term:api_binary() | '_' + ,caller_priority :: kz_term:api_integer() | '_' ,is_archived = 'false' :: boolean() | '$2' | '$3' | '_' }). -type call_stat() :: #call_stat{}. @@ -45,17 +45,17 @@ ,<<"connecting">>, <<"connected">> ,<<"wrapup">>, <<"paused">>, <<"outbound">> ]). --record(status_stat, {id :: api_binary() | '_' - ,agent_id :: api_binary() | '$2' | '_' - ,account_id :: api_binary() | '$1' | '_' - ,status :: api_binary() | '$4' | '_' - ,timestamp :: api_pos_integer() | '$1' | '$3' | '$5' | '_' - - ,wait_time :: api_integer() | '_' - ,pause_time :: api_integer() | '_' - ,callid :: api_binary() | '_' - ,caller_id_name :: api_binary() | '_' - ,caller_id_number :: api_binary() | '_' +-record(status_stat, {id :: kz_term:api_binary() | '_' + ,agent_id :: kz_term:api_binary() | '$2' | '_' + ,account_id :: kz_term:api_binary() | '$1' | '_' + ,status :: kz_term:api_binary() | '$4' | '_' + ,timestamp :: kz_term:api_pos_integer() | '$1' | '$3' | '$5' | '_' + + ,wait_time :: kz_term:api_integer() | '_' + ,pause_time :: kz_term:api_integer() | '_' + ,callid :: kz_term:api_binary() | '_' + ,caller_id_name :: kz_term:api_binary() | '_' + ,caller_id_number :: kz_term:api_binary() | '_' ,is_archived = 'false' :: boolean() | '$1' | '$2' | '_' }). -type status_stat() :: #status_stat{}. diff --git a/applications/acdc/src/acdc_stats_etsmgr.erl b/applications/acdc/src/acdc_stats_etsmgr.erl index 2c6b1e783dc..05426a16ca9 100644 --- a/applications/acdc/src/acdc_stats_etsmgr.erl +++ b/applications/acdc/src/acdc_stats_etsmgr.erl @@ -26,8 +26,8 @@ -define(SERVER, ?MODULE). -record(state, {table_id :: ets:tid() | 'undefined' - ,etssrv :: api_pid() - ,give_away_ref :: api_reference() + ,etssrv :: kz_term:api_pid() + ,give_away_ref :: kz_term:api_reference() }). -type state() :: #state{}. @@ -38,7 +38,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(ets:tab(), any()) -> startlink_ret(). +-spec start_link(ets:tab(), any()) -> kz_types:startlink_ret(). start_link(TableId, TableOptions) -> gen_server:start_link(?SERVER, [TableId, TableOptions], []). @@ -74,7 +74,7 @@ init([TableId, TableOptions]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> lager:debug("unhandled call: ~p", [_Request]), {'reply', {'error', 'not_implemented'}, State}. @@ -89,7 +89,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'begin', TableId, TableOptions}, State) -> Tbl = ets:new(TableId, TableOptions), @@ -111,7 +111,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'EXIT', Etssrv, 'killed'}, #state{etssrv=Etssrv}=State) -> lager:debug("ets mgr ~p killed", [Etssrv]), {'noreply', State#state{etssrv='undefined'}}; diff --git a/applications/acdc/src/acdc_stats_sup.erl b/applications/acdc/src/acdc_stats_sup.erl index 0dd07d9d547..4a1aab98ae8 100644 --- a/applications/acdc/src/acdc_stats_sup.erl +++ b/applications/acdc/src/acdc_stats_sup.erl @@ -34,7 +34,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -60,7 +60,7 @@ stats_srv() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 1, diff --git a/applications/acdc/src/acdc_stats_util.erl b/applications/acdc/src/acdc_stats_util.erl index 5482b900723..1fdc19bd7b3 100644 --- a/applications/acdc/src/acdc_stats_util.erl +++ b/applications/acdc/src/acdc_stats_util.erl @@ -20,11 +20,11 @@ -include("acdc.hrl"). -include("acdc_stats.hrl"). --spec wait_time(ne_binary(), kz_json:object()) -> api_integer(). +-spec wait_time(kz_term:ne_binary(), kz_json:object()) -> kz_term:api_integer(). wait_time(<<"paused">>, _) -> 'undefined'; wait_time(_, JObj) -> kz_json:get_integer_value(<<"Wait-Time">>, JObj). --spec pause_time(ne_binary(), kz_json:object()) -> api_integer(). +-spec pause_time(kz_term:ne_binary(), kz_json:object()) -> kz_term:api_integer(). pause_time(<<"paused">>, JObj) -> case kz_json:get_integer_value(<<"Pause-Time">>, JObj) of 'undefined' -> kz_json:get_integer_value(<<"Wait-Time">>, JObj); @@ -32,8 +32,8 @@ pause_time(<<"paused">>, JObj) -> end; pause_time(_, _JObj) -> 'undefined'. --spec caller_id_name(any(), kz_json:object()) -> api_ne_binary(). --spec caller_id_number(any(), kz_json:object()) -> api_integer(). +-spec caller_id_name(any(), kz_json:object()) -> kz_term:api_ne_binary(). +-spec caller_id_number(any(), kz_json:object()) -> kz_term:api_integer(). caller_id_name(_, JObj) -> kz_json:get_value(<<"Caller-ID-Name">>, JObj). caller_id_number(_, JObj) -> @@ -49,6 +49,6 @@ get_query_limit(JObj) -> N -> N end. --spec db_name(ne_binary()) -> ne_binary(). +-spec db_name(kz_term:ne_binary()) -> kz_term:ne_binary(). db_name(Account) -> kz_util:format_account_mod_id(Account). diff --git a/applications/acdc/src/acdc_sup.erl b/applications/acdc/src/acdc_sup.erl index bee1ecf5de8..6aef96196c0 100644 --- a/applications/acdc/src/acdc_sup.erl +++ b/applications/acdc/src/acdc_sup.erl @@ -34,14 +34,14 @@ %% =================================================================== %% API functions %% =================================================================== --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). %% =================================================================== %% Supervisor callbacks %% =================================================================== --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/acdc/src/acdc_util.erl b/applications/acdc/src/acdc_util.erl index 272275522c8..3d1a0c0a1e8 100644 --- a/applications/acdc/src/acdc_util.erl +++ b/applications/acdc/src/acdc_util.erl @@ -33,7 +33,7 @@ ,'usurp_control' ]). --spec queue_presence_update(ne_binary(), ne_binary()) -> 'ok'. +-spec queue_presence_update(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. queue_presence_update(AcctId, QueueId) -> case kapi_acdc_queue:queue_size(AcctId, QueueId) of 0 -> presence_update(AcctId, QueueId, ?PRESENCE_GREEN); @@ -41,15 +41,15 @@ queue_presence_update(AcctId, QueueId) -> _N -> lager:debug("queue size for ~s(~s): ~p", [QueueId, AcctId, _N]) end. --spec agent_presence_update(ne_binary(), ne_binary()) -> 'ok'. +-spec agent_presence_update(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. agent_presence_update(AcctId, AgentId) -> case acdc_agents_sup:find_agent_supervisor(AcctId, AgentId) of 'undefined' -> presence_update(AcctId, AgentId, ?PRESENCE_RED_SOLID); P when is_pid(P) -> presence_update(AcctId, AgentId, ?PRESENCE_GREEN) end. --spec presence_update(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. --spec presence_update(ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec presence_update(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. +-spec presence_update(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. presence_update(AcctId, PresenceId, State) -> presence_update(AcctId, PresenceId, State, kz_term:to_hex_binary(crypto:hash('md5', PresenceId))). presence_update(AcctId, PresenceId, State, CallId) -> @@ -59,7 +59,7 @@ presence_update(AcctId, PresenceId, State, CallId) -> lager:debug("sending presence update '~s' to '~s'", [State, To]), kapps_call_command:presence(State, To, CallId). --spec send_cdr(ne_binary(), kz_json:object()) -> 'ok'. +-spec send_cdr(kz_term:ne_binary(), kz_json:object()) -> 'ok'. send_cdr(Url, JObj) -> send_cdr(Url, JObj, 3). send_cdr('undefined', _JObj, _Retries) -> @@ -80,7 +80,7 @@ send_cdr(Url, JObj, Retries) -> end. %% Returns the list of agents configured for the queue --spec agents_in_queue(ne_binary(), ne_binary()) -> kz_json:path(). +-spec agents_in_queue(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:path(). agents_in_queue(AcctDb, QueueId) -> case kz_datamgr:get_results(AcctDb, <<"queues/agents_listing">>, [{'key', QueueId}]) of {'ok', []} -> []; @@ -88,7 +88,7 @@ agents_in_queue(AcctDb, QueueId) -> {'ok', As} -> [kz_json:get_value(<<"value">>, A) || A <- As] end. --spec agent_devices(ne_binary(), ne_binary()) -> kz_json:objects(). +-spec agent_devices(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:objects(). agent_devices(AcctDb, AgentId) -> case kz_datamgr:get_results(AcctDb, <<"attributes/owned">>, [{'key', [AgentId, <<"device">>]} ,'include_docs' @@ -98,38 +98,38 @@ agent_devices(AcctDb, AgentId) -> {'error', _} -> [] end. --spec get_endpoints(kapps_call:call(), ne_binary() | kazoo_data:get_results_return()) -> +-spec get_endpoints(kapps_call:call(), kz_term:ne_binary() | kazoo_data:get_results_return()) -> kz_json:objects(). get_endpoints(Call, ?NE_BINARY = AgentId) -> Params = kz_json:from_list([{<<"source">>, kz_term:to_binary(?MODULE)}]), kz_endpoints:by_owner_id(AgentId, Params, Call). %% Handles subscribing/unsubscribing from call events --spec bind_to_call_events(api_binary() | {api_binary(), any()} | kapps_call:call()) -> 'ok'. +-spec bind_to_call_events(kz_term:api_binary() | {kz_term:api_binary(), any()} | kapps_call:call()) -> 'ok'. bind_to_call_events(Call) -> bind_to_call_events(Call, self()). --spec bind_to_call_events(api_binary() | {api_binary(), any()} | kapps_call:call(), pid()) -> 'ok'. +-spec bind_to_call_events(kz_term:api_binary() | {kz_term:api_binary(), any()} | kapps_call:call(), pid()) -> 'ok'. bind_to_call_events('undefined', _) -> 'ok'; bind_to_call_events(?NE_BINARY = CallId, Pid) -> gen_listener:add_binding(Pid, 'call', [{'callid', CallId}]); bind_to_call_events({CallId, _}, Pid) -> bind_to_call_events(CallId, Pid); bind_to_call_events(Call, Pid) -> bind_to_call_events(kapps_call:call_id(Call), Pid). --spec unbind_from_call_events(api_binary() | {api_binary(), any()} | kapps_call:call()) -> 'ok'. +-spec unbind_from_call_events(kz_term:api_binary() | {kz_term:api_binary(), any()} | kapps_call:call()) -> 'ok'. unbind_from_call_events(Call) -> unbind_from_call_events(Call, self()). --spec unbind_from_call_events(api_binary() | {api_binary(), any()} | kapps_call:call(), pid()) -> 'ok'. +-spec unbind_from_call_events(kz_term:api_binary() | {kz_term:api_binary(), any()} | kapps_call:call(), pid()) -> 'ok'. unbind_from_call_events('undefined', _Pid) -> 'ok'; unbind_from_call_events(?NE_BINARY = CallId, Pid) -> gen_listener:rm_binding(Pid, 'call', [{'callid', CallId}]); unbind_from_call_events({CallId, _}, Pid) -> unbind_from_call_events(CallId, Pid); unbind_from_call_events(Call, Pid) -> unbind_from_call_events(kapps_call:call_id(Call), Pid). --spec proc_id() -> ne_binary(). --spec proc_id(pid()) -> ne_binary(). --spec proc_id(pid(), atom() | ne_binary()) -> ne_binary(). +-spec proc_id() -> kz_term:ne_binary(). +-spec proc_id(pid()) -> kz_term:ne_binary(). +-spec proc_id(pid(), atom() | kz_term:ne_binary()) -> kz_term:ne_binary(). proc_id() -> proc_id(self()). proc_id(Pid) -> proc_id(Pid, node()). proc_id(Pid, Node) -> list_to_binary([kz_term:to_binary(Node), "-", pid_to_list(Pid)]). diff --git a/applications/acdc/src/cb_acdc_call_stats.erl b/applications/acdc/src/cb_acdc_call_stats.erl index 2af9a13bb71..facdf8e87ec 100644 --- a/applications/acdc/src/cb_acdc_call_stats.erl +++ b/applications/acdc/src/cb_acdc_call_stats.erl @@ -144,13 +144,13 @@ load_stats_summary(Context, _Nouns) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec normalize_acdc_stats(cb_context:context(), ne_binary()) -> ne_binaries() | kz_json:objects(). +-spec normalize_acdc_stats(cb_context:context(), kz_term:ne_binary()) -> kz_term:ne_binaries() | kz_json:objects(). normalize_acdc_stats(Context, <<"csv">>) -> [normalize_stat_to_csv(Context, JObj) || JObj <- cb_context:resp_data(Context)]; normalize_acdc_stats(Context, <<"json">>) -> [kz_json:from_list([{K, F(JObj)} || {K, F} <- ?COLUMNS]) || JObj <- cb_context:resp_data(Context)]. --spec normalize_stat_to_csv(cb_context:context(), kz_json:object()) -> ne_binary(). +-spec normalize_stat_to_csv(cb_context:context(), kz_json:object()) -> kz_term:ne_binary(). normalize_stat_to_csv(Context, JObj) -> CSV = kz_binary:join([F(JObj) || {_, F} <- ?COLUMNS], <<",">>), case cb_context:fetch(Context, 'chunking_started') of diff --git a/applications/acdc/src/cb_agents.erl b/applications/acdc/src/cb_agents.erl index e280391d7f7..b3bc9b4590d 100644 --- a/applications/acdc/src/cb_agents.erl +++ b/applications/acdc/src/cb_agents.erl @@ -224,7 +224,7 @@ post(Context, AgentId, ?QUEUE_STATUS_PATH_TOKEN) -> Context1 end. --spec publish_action(cb_context:context(), ne_binary()) -> 'ok'. +-spec publish_action(cb_context:context(), kz_term:ne_binary()) -> 'ok'. publish_action(Context, AgentId) -> Publisher = case cb_context:req_value(Context, <<"action">>) of <<"logout">> -> fun kapi_acdc_agent:publish_logout_queue/1; @@ -240,7 +240,7 @@ publish_action(Context, AgentId) -> kz_amqp_worker:cast(Props, Publisher). --spec publish_update(cb_context:context(), api_binary(), function()) -> 'ok'. +-spec publish_update(cb_context:context(), kz_term:api_binary(), function()) -> 'ok'. publish_update(Context, AgentId, PubFun) -> Update = props:filter_undefined( [{<<"Account-ID">>, cb_context:account_id(Context)} @@ -270,7 +270,7 @@ fetch_all_agent_statuses(Context) -> ,cb_context:req_value(Context, <<"status">>) ). --spec fetch_agent_status(api_binary(), cb_context:context()) -> cb_context:context(). +-spec fetch_agent_status(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). fetch_agent_status(AgentId, Context) -> case kz_term:is_true(cb_context:req_value(Context, <<"recent">>)) of 'false' -> @@ -299,7 +299,7 @@ fetch_all_current_agent_stats(Context) -> ,cb_context:req_value(Context, <<"agent_id">>) ). --spec fetch_all_current_stats(cb_context:context(), api_binary()) -> cb_context:context(). +-spec fetch_all_current_stats(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). fetch_all_current_stats(Context, AgentId) -> Now = kz_time:now_s(), Yday = Now - ?SECONDS_IN_DAY, @@ -313,7 +313,7 @@ fetch_all_current_stats(Context, AgentId) -> ]), fetch_stats_from_amqp(Context, Req). --spec fetch_current_status(cb_context:context(), api_binary(), api_boolean()) -> cb_context:context(). +-spec fetch_current_status(cb_context:context(), kz_term:api_binary(), kz_term:api_boolean()) -> cb_context:context(). fetch_current_status(Context, AgentId, 'false') -> {'ok', Resp} = acdc_agent_util:most_recent_status(cb_context:account_id(Context), AgentId), crossbar_util:response(Resp, Context); @@ -341,7 +341,7 @@ fetch_current_status(Context, AgentId, 'true') -> crossbar_util:response(StatusJObj, Context) end. --spec fetch_all_current_statuses(cb_context:context(), api_binary(), api_binary()) -> +-spec fetch_all_current_statuses(cb_context:context(), kz_term:api_binary(), kz_term:api_binary()) -> cb_context:context(). fetch_all_current_statuses(Context, AgentId, Status) -> Now = kz_time:now_s(), @@ -404,7 +404,7 @@ fetch_ranged_agent_stats(Context, From, To, 'false') -> lager:debug("ranged query from ~b to ~b of archived stats", [From, To]), Context. --spec fetch_stats_from_amqp(cb_context:context(), kz_proplist()) -> cb_context:context(). +-spec fetch_stats_from_amqp(cb_context:context(), kz_term:proplist()) -> cb_context:context(). fetch_stats_from_amqp(Context, Req) -> case kz_amqp_worker:call(Req ,fun kapi_acdc_stats:publish_current_calls_req/1 @@ -464,7 +464,7 @@ format_stats_fold(Stat, Acc) -> -spec maybe_add_answered(kz_json:object(), kz_json:object()) -> [{kz_json:path(), non_neg_integer()}]. --spec maybe_add_answered(kz_json:object(), kz_json:object(), api_binary()) -> +-spec maybe_add_answered(kz_json:object(), kz_json:object(), kz_term:api_binary()) -> [{kz_json:path(), non_neg_integer()}]. maybe_add_answered(Stat, Acc) -> maybe_add_answered(Stat, Acc, kz_json:get_value(<<"status">>, Stat)). @@ -492,7 +492,7 @@ add_answered(Stat, Acc) -> ,{QAnsweredK, QAnswered + 1} ]. --spec maybe_add_misses(kz_json:object(), kz_json:object(), ne_binary()) -> +-spec maybe_add_misses(kz_json:object(), kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). maybe_add_misses(Stat, Acc, QueueId) -> case kz_json:get_value(<<"misses">>, Stat, []) of @@ -506,7 +506,7 @@ maybe_add_misses(Stat, Acc, QueueId) -> ) end. --spec add_miss(kz_json:object(), kz_json:object(), ne_binary()) -> kz_json:object(). +-spec add_miss(kz_json:object(), kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). add_miss(Miss, Acc, QueueId) -> AgentId = kz_json:get_value(<<"agent_id">>, Miss), MissesK = [AgentId, <<"missed_calls">>], @@ -568,7 +568,7 @@ validate_status_change(Context) -> end. -define(STATUS_CHANGES, [<<"login">>, <<"logout">>, <<"pause">>, <<"resume">>]). --spec validate_status_change(cb_context:context(), api_binary()) -> +-spec validate_status_change(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). validate_status_change(Context, S) -> case lists:member(S, ?STATUS_CHANGES) of @@ -586,7 +586,7 @@ validate_status_change(Context, S) -> ) end. --spec check_for_status_error(cb_context:context(), api_binary()) -> +-spec check_for_status_error(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). check_for_status_error(Context, S) -> case lists:member(S, ?STATUS_CHANGES) of @@ -604,7 +604,7 @@ check_for_status_error(Context, S) -> ) end. --spec validate_status_change_params(cb_context:context(), ne_binary()) -> +-spec validate_status_change_params(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). validate_status_change_params(Context, <<"pause">>) -> Value = cb_context:req_value(Context, <<"timeout">>), diff --git a/applications/acdc/src/cb_queues.erl b/applications/acdc/src/cb_queues.erl index 352d3a5b98f..3a6ff9b695e 100644 --- a/applications/acdc/src/cb_queues.erl +++ b/applications/acdc/src/cb_queues.erl @@ -294,7 +294,7 @@ is_valid_call(Context, Data) -> is_active_call(Context, CallId) end. --spec is_active_call(cb_context:context(), ne_binary()) -> +-spec is_active_call(cb_context:context(), kz_term:ne_binary()) -> 'true' | {'false', cb_context:context()}. is_active_call(Context, CallId) -> @@ -409,7 +409,7 @@ put(Context, QID, ?EAVESDROP_PATH_TOKEN) -> ], eavesdrop_req(Context, Prop). --spec default_eavesdrop_req(cb_context:context()) -> kz_proplist(). +-spec default_eavesdrop_req(cb_context:context()) -> kz_term:proplist(). default_eavesdrop_req(Context) -> [{<<"Eavesdrop-Mode">>, cb_context:req_value(Context, <<"mode">>, <<"listen">>)} ,{<<"Account-ID">>, cb_context:account_id(Context)} @@ -420,7 +420,7 @@ default_eavesdrop_req(Context) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]. --spec eavesdrop_req(cb_context:context(), kz_proplist()) -> cb_context:context(). +-spec eavesdrop_req(cb_context:context(), kz_term:proplist()) -> cb_context:context(). eavesdrop_req(Context, Prop) -> case kapps_util:amqp_pool_request(props:filter_undefined(Prop) ,fun kapi_resource:publish_eavesdrop_req/1 @@ -507,7 +507,7 @@ delete_account(Context, AccountId) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec read(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec read(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). read(Id, Context) -> Context1 = crossbar_doc:load(Id, Context, ?TYPE_CHECK_OPTION(<<"queue">>)), case cb_context:resp_status(Context1) of @@ -521,7 +521,7 @@ read(Id, Context) -> %% %% @end %%-------------------------------------------------------------------- --spec validate_request(api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_request(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_request(QueueId, Context) -> check_queue_schema(QueueId, Context). @@ -531,7 +531,7 @@ validate_request(QueueId, Context) -> %% %% @end %%-------------------------------------------------------------------- --spec validate_patch(api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_patch(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_patch(QueueId, Context) -> crossbar_doc:patch_and_validate(QueueId, Context, fun validate_request/2). @@ -605,7 +605,7 @@ add_queue_to_agents_diff(Id, Context, AgentIds) -> _Status -> Context1 end. --spec maybe_add_queue_to_agent(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec maybe_add_queue_to_agent(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). maybe_add_queue_to_agent(Id, A) -> Qs = case kz_json:get_value(<<"queues">>, A) of L when is_list(L) -> @@ -618,7 +618,7 @@ maybe_add_queue_to_agent(Id, A) -> lager:debug("agent ~s adding queues: ~p", [kz_doc:id(A), Qs]), kz_json:set_value(<<"queues">>, Qs, A). --spec maybe_rm_agents(ne_binary(), cb_context:context(), kz_json:path()) -> cb_context:context(). +-spec maybe_rm_agents(kz_term:ne_binary(), cb_context:context(), kz_json:path()) -> cb_context:context(). maybe_rm_agents(_Id, Context, []) -> lager:debug("no agents to remove from the queue ~s", [_Id]), cb_context:set_resp_status(Context, 'success'); @@ -628,9 +628,9 @@ maybe_rm_agents(Id, Context, AgentIds) -> lager:debug("rm resulted in ~s", [cb_context:resp_status(RMContext1)]), RMContext1. --spec rm_queue_from_agents(ne_binary(), cb_context:context()) -> +-spec rm_queue_from_agents(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). --spec rm_queue_from_agents(ne_binary(), cb_context:context(), kz_json:path()) -> +-spec rm_queue_from_agents(kz_term:ne_binary(), cb_context:context(), kz_json:path()) -> cb_context:context(). rm_queue_from_agents(Id, Context) -> Context1 = load_agent_roster(Id, Context), @@ -655,7 +655,7 @@ rm_queue_from_agents(_Id, Context, _Data) -> ,{fun cb_context:set_doc/2, 'undefined'} ]). --spec maybe_rm_queue_from_agent(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec maybe_rm_queue_from_agent(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). maybe_rm_queue_from_agent(Id, A) -> Qs = kz_json:get_value(<<"queues">>, A, []), kz_json:set_value(<<"queues">>, lists:delete(Id, Qs), A). @@ -740,7 +740,7 @@ fetch_ranged_queue_stats(Context, From, To, 'false') -> lager:debug("ranged query from ~b to ~b of archived stats", [From, To]), Context. --spec fetch_from_amqp(cb_context:context(), kz_proplist()) -> cb_context:context(). +-spec fetch_from_amqp(cb_context:context(), kz_term:proplist()) -> cb_context:context(). fetch_from_amqp(Context, Req) -> case kapps_util:amqp_pool_request(Req ,fun kapi_acdc_stats:publish_current_calls_req/1 @@ -804,7 +804,7 @@ activate_account_for_acdc(Context) -> lager:debug("failed to check acdc activation doc: ~p", [_E]) end. --spec deactivate_account_for_acdc(ne_binary()) -> 'ok'. +-spec deactivate_account_for_acdc(kz_term:ne_binary()) -> 'ok'. deactivate_account_for_acdc(AccountId) -> case kz_datamgr:open_doc(?KZ_ACDC_DB, AccountId) of {'error', _} -> 'ok'; diff --git a/applications/acdc/src/cf_acdc_agent.erl b/applications/acdc/src/cf_acdc_agent.erl index 766c5549a3c..38dfcb7c3ba 100644 --- a/applications/acdc/src/cf_acdc_agent.erl +++ b/applications/acdc/src/cf_acdc_agent.erl @@ -53,7 +53,7 @@ handle(Data, Call) -> lager:info("finished with acdc agent callflow"), cf_exe:continue(Call). --spec find_agent_status(kapps_call:call() | ne_binary(), ne_binary()) -> ne_binary(). +-spec find_agent_status(kapps_call:call() | kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). find_agent_status(?NE_BINARY = AcctId, AgentId) -> fix_agent_status(acdc_agent_util:most_recent_status(AcctId, AgentId)); find_agent_status(Call, AgentId) -> @@ -120,8 +120,8 @@ maybe_pause_agent(Call, _AgentId, FromStatus, _Data) -> lager:info("unable to go from ~s to paused", [FromStatus]), play_agent_invalid(Call). --spec login_agent(kapps_call:call(), ne_binary()) -> api_ne_binary(). --spec login_agent(kapps_call:call(), ne_binary(), kz_json:object()) -> api_ne_binary(). +-spec login_agent(kapps_call:call(), kz_term:ne_binary()) -> kz_term:api_ne_binary(). +-spec login_agent(kapps_call:call(), kz_term:ne_binary(), kz_json:object()) -> kz_term:api_ne_binary(). login_agent(Call, AgentId) -> login_agent(Call, AgentId, kz_json:new()). login_agent(Call, AgentId, Data) -> @@ -144,8 +144,8 @@ login_agent(Call, AgentId, Data) -> <<"failed">> end. --spec logout_agent(kapps_call:call(), ne_binary()) -> 'ok'. --spec logout_agent(kapps_call:call(), ne_binary(), kz_json:object()) -> 'ok'. +-spec logout_agent(kapps_call:call(), kz_term:ne_binary()) -> 'ok'. +-spec logout_agent(kapps_call:call(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. logout_agent(Call, AgentId) -> logout_agent(Call, AgentId, kz_json:new()). logout_agent(Call, AgentId, Data) -> @@ -170,7 +170,7 @@ update_agent_status(Call, AgentId, Data, PubFun) -> update_agent_status(Call, AgentId, Data, PubFun, Timeout) -> send_new_status(Call, AgentId, Data, PubFun, Timeout). --spec send_new_status(kapps_call:call(), ne_binary(), kz_json:object(), kz_amqp_worker:publish_fun(), api_integer()) -> 'ok'. +-spec send_new_status(kapps_call:call(), kz_term:ne_binary(), kz_json:object(), kz_amqp_worker:publish_fun(), kz_term:api_integer()) -> 'ok'. send_new_status(Call, AgentId, Data, PubFun, Timeout) -> Update = props:filter_undefined( [{<<"Account-ID">>, kapps_call:account_id(Call)} @@ -182,10 +182,10 @@ send_new_status(Call, AgentId, Data, PubFun, Timeout) -> ]), PubFun(Update). --spec presence_id(kz_json:object()) -> api_ne_binary(). +-spec presence_id(kz_json:object()) -> kz_term:api_ne_binary(). presence_id(Data) -> kz_json:get_ne_binary_value(<<"presence_id">>, Data). --spec presence_state(kz_json:object()) -> api_ne_binary(). +-spec presence_state(kz_json:object()) -> kz_term:api_ne_binary(). presence_state(Data) -> format_presence_state(kz_json:get_ne_binary_value(<<"presence_state">>, Data)). @@ -199,7 +199,7 @@ format_presence_state(_) -> 'undefined'. -type find_agent_error() :: 'unknown_endpoint' | 'multiple_owners'. -spec find_agent(kapps_call:call()) -> - {'ok', api_binary()} | + {'ok', kz_term:api_binary()} | {'error', find_agent_error()}. find_agent(Call) -> find_agent(Call, kapps_call:authorizing_id(Call)). diff --git a/applications/acdc/src/cf_acdc_member.erl b/applications/acdc/src/cf_acdc_member.erl index 78cc08f7a83..bd6c7f9a501 100644 --- a/applications/acdc/src/cf_acdc_member.erl +++ b/applications/acdc/src/cf_acdc_member.erl @@ -23,8 +23,8 @@ -define(MEMBER_HANGUP, <<"member_hangup">>). -record(member_call, {call :: kapps_call:call() - ,queue_id :: api_binary() - ,config_data = [] :: kz_proplist() + ,queue_id :: kz_term:api_binary() + ,config_data = [] :: kz_term:proplist() ,max_wait = 60 * ?MILLISECONDS_IN_SECOND :: max_wait() }). -type member_call() :: #member_call{}. @@ -69,7 +69,7 @@ handle(Data, Call) -> ,is_queue_full(MaxQueueSize, CurrQueueSize) ). --spec lookup_priority(kz_json:object(), kapps_call:call()) -> api_binary(). +-spec lookup_priority(kz_json:object(), kapps_call:call()) -> kz_term:api_binary(). lookup_priority(Data, Call) -> FromData = kz_json:get_integer_value(<<"priority">>, Data), FromCall = kapps_call:custom_channel_var(<<"Call-Priority">>, Call), @@ -98,7 +98,7 @@ maybe_enter_queue(#member_call{call=Call ). -spec wait_for_bridge(member_call(), max_wait()) -> 'ok'. --spec wait_for_bridge(member_call(), max_wait(), kz_now()) -> 'ok'. +-spec wait_for_bridge(member_call(), max_wait(), kz_time:now()) -> 'ok'. wait_for_bridge(MC, Timeout) -> wait_for_bridge(MC, Timeout, os:timestamp()). wait_for_bridge(#member_call{call=Call}, Timeout, _Start) when Timeout < 0 -> @@ -119,9 +119,9 @@ end_member_call(Call) -> stop_hold_music(Call), cf_exe:continue(Call). --spec process_message(member_call(), max_wait(), kz_now() - ,kz_now(), kz_json:object() - ,{ne_binary(), ne_binary()} +-spec process_message(member_call(), max_wait(), kz_time:now() + ,kz_time:now(), kz_json:object() + ,{kz_term:ne_binary(), kz_term:ne_binary()} ) -> 'ok'. process_message(#member_call{call=Call}, _, Start, _Wait, _JObj, {<<"call_event">>,<<"CHANNEL_BRIDGE">>}) -> lager:info("member was bridged to agent, yay! took ~b s", [kz_time:elapsed_s(Start)]), @@ -177,7 +177,7 @@ max_queue_size(_) -> 0. is_queue_full(0, _) -> 'false'; is_queue_full(MaxQueueSize, CurrQueueSize) -> CurrQueueSize >= MaxQueueSize. --spec cancel_member_call(kapps_call:call(), ne_binary()) -> 'ok'. +-spec cancel_member_call(kapps_call:call(), kz_term:ne_binary()) -> 'ok'. cancel_member_call(Call, <<"timeout">>) -> lager:info("update reason from `timeout` to `member_timeout`"), cancel_member_call(Call, ?MEMBER_TIMEOUT); diff --git a/applications/acdc/src/cf_acdc_queue.erl b/applications/acdc/src/cf_acdc_queue.erl index c7a74641900..89bf47d868c 100644 --- a/applications/acdc/src/cf_acdc_queue.erl +++ b/applications/acdc/src/cf_acdc_queue.erl @@ -78,7 +78,7 @@ send_agent_message(Call, AgentId, QueueId, PubFun) -> ]), PubFun(Prop). --spec update_queues(kapps_call:call(), ne_binary(), ne_binary(), ne_binary()) -> +-spec update_queues(kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | kz_datamgr:data_error(). update_queues(Call, AgentId, QueueId, <<"login">>) -> diff --git a/applications/acdc/src/kapi_acdc_agent.erl b/applications/acdc/src/kapi_acdc_agent.erl index b29924f0349..4518699aaca 100644 --- a/applications/acdc/src/kapi_acdc_agent.erl +++ b/applications/acdc/src/kapi_acdc_agent.erl @@ -63,7 +63,7 @@ ]). -define(SYNC_REQ_TYPES, []). --spec sync_req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec sync_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. sync_req(Props) when is_list(Props) -> case sync_req_v(Props) of 'true' -> kz_api:build_message(Props, ?SYNC_REQ_HEADERS, ?OPTIONAL_SYNC_REQ_HEADERS); @@ -72,14 +72,14 @@ sync_req(Props) when is_list(Props) -> sync_req(JObj) -> sync_req(kz_json:to_proplist(JObj)). --spec sync_req_v(api_terms()) -> boolean(). +-spec sync_req_v(kz_term:api_terms()) -> boolean(). sync_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SYNC_REQ_HEADERS, ?SYNC_REQ_VALUES, ?SYNC_REQ_TYPES); sync_req_v(JObj) -> sync_req_v(kz_json:to_proplist(JObj)). --spec sync_req_routing_key(kz_json:object() | kz_proplist()) -> ne_binary(). --spec sync_req_routing_key(ne_binary(), ne_binary()) -> ne_binary(). +-spec sync_req_routing_key(kz_json:object() | kz_term:proplist()) -> kz_term:ne_binary(). +-spec sync_req_routing_key(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). sync_req_routing_key(Props) when is_list(Props) -> Id = props:get_value(<<"Agent-ID">>, Props, <<"*">>), AcctId = props:get_value(<<"Account-ID">>, Props, <<"*">>), @@ -109,8 +109,8 @@ sync_req_routing_key(AcctId, Id) -> ]). -define(SYNC_RESP_TYPES, []). --spec sync_resp(api_terms()) -> {'ok', iolist()} | - {'error', string()}. +-spec sync_resp(kz_term:api_terms()) -> {'ok', iolist()} | + {'error', string()}. sync_resp(Props) when is_list(Props) -> case sync_resp_v(Props) of 'true' -> kz_api:build_message(Props, ?SYNC_RESP_HEADERS, ?OPTIONAL_SYNC_RESP_HEADERS); @@ -119,7 +119,7 @@ sync_resp(Props) when is_list(Props) -> sync_resp(JObj) -> sync_resp(kz_json:to_proplist(JObj)). --spec sync_resp_v(api_terms()) -> boolean(). +-spec sync_resp_v(kz_term:api_terms()) -> boolean(). sync_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SYNC_RESP_HEADERS, ?SYNC_RESP_VALUES, ?SYNC_RESP_TYPES); sync_resp_v(JObj) -> @@ -141,8 +141,8 @@ sync_resp_v(JObj) -> ]). -define(STATS_REQ_TYPES, []). --spec stats_req(api_terms()) -> {'ok', iolist()} | - {'error', string()}. +-spec stats_req(kz_term:api_terms()) -> {'ok', iolist()} | + {'error', string()}. stats_req(Props) when is_list(Props) -> case stats_req_v(Props) of 'true' -> kz_api:build_message(Props, ?STATS_REQ_HEADERS, ?OPTIONAL_STATS_REQ_HEADERS); @@ -151,14 +151,14 @@ stats_req(Props) when is_list(Props) -> stats_req(JObj) -> stats_req(kz_json:to_proplist(JObj)). --spec stats_req_v(api_terms()) -> boolean(). +-spec stats_req_v(kz_term:api_terms()) -> boolean(). stats_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?STATS_REQ_HEADERS, ?STATS_REQ_VALUES, ?STATS_REQ_TYPES); stats_req_v(JObj) -> stats_req_v(kz_json:to_proplist(JObj)). --spec stats_req_routing_key(kz_json:object() | kz_proplist() | ne_binary()) -> ne_binary(). --spec stats_req_routing_key(ne_binary(), api_binary()) -> ne_binary(). +-spec stats_req_routing_key(kz_json:object() | kz_term:proplist() | kz_term:ne_binary()) -> kz_term:ne_binary(). +-spec stats_req_routing_key(kz_term:ne_binary(), kz_term:api_binary()) -> kz_term:ne_binary(). stats_req_routing_key(Props) when is_list(Props) -> Id = props:get_value(<<"Account-ID">>, Props, <<"*">>), AgentId = props:get_value(<<"Agent-ID">>, Props, <<"*">>), @@ -170,7 +170,7 @@ stats_req_routing_key(JObj) -> AgentId = kz_json:get_value(<<"Agent-ID">>, JObj, <<"*">>), stats_req_routing_key(Id, AgentId). --spec stats_req_publish_key(kz_json:object() | kz_proplist() | ne_binary()) -> ne_binary(). +-spec stats_req_publish_key(kz_json:object() | kz_term:proplist() | kz_term:ne_binary()) -> kz_term:ne_binary(). stats_req_publish_key(Props) when is_list(Props) -> stats_req_routing_key(props:get_value(<<"Account-ID">>, Props) ,props:get_value(<<"Agent-ID">>, Props) @@ -193,7 +193,7 @@ stats_req_routing_key(Id, AgentId) -> ]). -define(STATS_RESP_TYPES, [{<<"Stats">>, fun kz_json:is_json_object/1}]). --spec stats_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec stats_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. stats_resp(Props) when is_list(Props) -> case stats_resp_v(Props) of 'true' -> kz_api:build_message(Props, ?STATS_RESP_HEADERS, ?OPTIONAL_STATS_RESP_HEADERS); @@ -202,7 +202,7 @@ stats_resp(Props) when is_list(Props) -> stats_resp(JObj) -> stats_resp(kz_json:to_proplist(JObj)). --spec stats_resp_v(api_terms()) -> boolean(). +-spec stats_resp_v(kz_term:api_terms()) -> boolean(). stats_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?STATS_RESP_HEADERS, ?STATS_RESP_VALUES, ?STATS_RESP_TYPES); stats_resp_v(JObj) -> @@ -229,7 +229,7 @@ stats_resp_v(JObj) -> -define(LOGIN_QUEUE_VALUES, [{<<"Event-Name">>, <<"login_queue">>} | ?AGENT_VALUES]). -define(LOGOUT_QUEUE_VALUES, [{<<"Event-Name">>, <<"logout_queue">>} | ?AGENT_VALUES]). --spec login(api_terms()) -> +-spec login(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. login(Props) when is_list(Props) -> @@ -240,13 +240,13 @@ login(Props) when is_list(Props) -> login(JObj) -> login(kz_json:to_proplist(JObj)). --spec login_v(api_terms()) -> boolean(). +-spec login_v(kz_term:api_terms()) -> boolean(). login_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?AGENT_HEADERS, ?LOGIN_VALUES, ?AGENT_TYPES); login_v(JObj) -> login_v(kz_json:to_proplist(JObj)). --spec login_queue(api_terms()) -> +-spec login_queue(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. login_queue(Props) when is_list(Props) -> @@ -257,14 +257,14 @@ login_queue(Props) when is_list(Props) -> login_queue(JObj) -> login_queue(kz_json:to_proplist(JObj)). --spec login_queue_v(api_terms()) -> boolean(). +-spec login_queue_v(kz_term:api_terms()) -> boolean(). login_queue_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?AGENT_HEADERS, ?LOGIN_QUEUE_VALUES, ?AGENT_TYPES); login_queue_v(JObj) -> login_queue_v(kz_json:to_proplist(JObj)). --spec logout(api_terms()) -> +-spec logout(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. logout(Props) when is_list(Props) -> @@ -275,13 +275,13 @@ logout(Props) when is_list(Props) -> logout(JObj) -> logout(kz_json:to_proplist(JObj)). --spec logout_v(api_terms()) -> boolean(). +-spec logout_v(kz_term:api_terms()) -> boolean(). logout_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?AGENT_HEADERS, ?LOGOUT_VALUES, ?AGENT_TYPES); logout_v(JObj) -> logout_v(kz_json:to_proplist(JObj)). --spec logout_queue(api_terms()) -> +-spec logout_queue(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. logout_queue(Props) when is_list(Props) -> @@ -292,13 +292,13 @@ logout_queue(Props) when is_list(Props) -> logout_queue(JObj) -> logout_queue(kz_json:to_proplist(JObj)). --spec logout_queue_v(api_terms()) -> boolean(). +-spec logout_queue_v(kz_term:api_terms()) -> boolean(). logout_queue_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?AGENT_HEADERS, ?LOGOUT_QUEUE_VALUES, ?AGENT_TYPES); logout_queue_v(JObj) -> logout_queue_v(kz_json:to_proplist(JObj)). --spec pause(api_terms()) -> +-spec pause(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. pause(Props) when is_list(Props) -> @@ -309,13 +309,13 @@ pause(Props) when is_list(Props) -> pause(JObj) -> pause(kz_json:to_proplist(JObj)). --spec pause_v(api_terms()) -> boolean(). +-spec pause_v(kz_term:api_terms()) -> boolean(). pause_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?AGENT_HEADERS, ?PAUSE_VALUES, ?AGENT_TYPES); pause_v(JObj) -> pause_v(kz_json:to_proplist(JObj)). --spec resume(api_terms()) -> +-spec resume(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. resume(Props) when is_list(Props) -> @@ -325,13 +325,13 @@ resume(Props) when is_list(Props) -> end; resume(JObj) -> resume(kz_json:to_proplist(JObj)). --spec resume_v(api_terms()) -> boolean(). +-spec resume_v(kz_term:api_terms()) -> boolean(). resume_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?AGENT_HEADERS, ?RESUME_VALUES, ?AGENT_TYPES); resume_v(JObj) -> resume_v(kz_json:to_proplist(JObj)). --spec agent_status_routing_key(kz_proplist()) -> ne_binary(). --spec agent_status_routing_key(ne_binary(), ne_binary(), ne_binary()) -> ne_binary(). +-spec agent_status_routing_key(kz_term:proplist()) -> kz_term:ne_binary(). +-spec agent_status_routing_key(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). agent_status_routing_key(Props) when is_list(Props) -> Id = props:get_value(<<"Agent-ID">>, Props, <<"*">>), AcctId = props:get_value(<<"Account-ID">>, Props, <<"*">>), @@ -349,7 +349,7 @@ agent_status_routing_key(AcctId, AgentId, Status) -> ]). -define(LOGIN_RESP_TYPES, []). --spec login_resp(api_terms()) -> +-spec login_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. login_resp(Props) when is_list(Props) -> @@ -360,7 +360,7 @@ login_resp(Props) when is_list(Props) -> login_resp(JObj) -> login_resp(kz_json:to_proplist(JObj)). --spec login_resp_v(api_terms()) -> boolean(). +-spec login_resp_v(kz_term:api_terms()) -> boolean(). login_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?LOGIN_RESP_HEADERS, ?LOGIN_RESP_VALUES, ?LOGIN_RESP_TYPES); login_resp_v(JObj) -> @@ -370,8 +370,8 @@ login_resp_v(JObj) -> %% Bind/Unbind the queue as appropriate %%------------------------------------------------------------------------------ --spec bind_q(binary(), kz_proplist()) -> 'ok'. --spec bind_q(binary(), {ne_binary(), ne_binary(), ne_binary()}, 'undefined' | list()) -> 'ok'. +-spec bind_q(binary(), kz_term:proplist()) -> 'ok'. +-spec bind_q(binary(), {kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()}, 'undefined' | list()) -> 'ok'. bind_q(Q, Props) -> AgentId = props:get_value('agent_id', Props, <<"*">>), AcctId = props:get_value('account_id', Props, <<"*">>), @@ -398,8 +398,8 @@ bind_q(Q, {AcctId, AgentId, _}=Ids, ['stats_req'|T]) -> bind_q(Q, Ids, [_|T]) -> bind_q(Q, Ids, T); bind_q(_, _, []) -> 'ok'. --spec unbind_q(binary(), kz_proplist()) -> 'ok'. --spec unbind_q(binary(), {ne_binary(), ne_binary(), ne_binary()}, 'undefined' | list()) -> 'ok'. +-spec unbind_q(binary(), kz_term:proplist()) -> 'ok'. +-spec unbind_q(binary(), {kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()}, 'undefined' | list()) -> 'ok'. unbind_q(Q, Props) -> AgentId = props:get_value('agent_id', Props, <<"*">>), AcctId = props:get_value('account_id', Props, <<"*">>), @@ -438,16 +438,16 @@ declare_exchanges() -> %%------------------------------------------------------------------------------ %% Publishers for convenience %%------------------------------------------------------------------------------ --spec publish_sync_req(api_terms()) -> 'ok'. --spec publish_sync_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_sync_req(kz_term:api_terms()) -> 'ok'. +-spec publish_sync_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_sync_req(JObj) -> publish_sync_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_sync_req(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?SYNC_REQ_VALUES, fun sync_req/1), amqp_util:kapps_publish(sync_req_routing_key(API), Payload, ContentType). --spec publish_sync_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_sync_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_sync_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_sync_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_sync_resp(Q, JObj) -> publish_sync_resp(Q, JObj, ?DEFAULT_CONTENT_TYPE). publish_sync_resp('undefined', _, _) -> {'error', 'no_destination'}; @@ -455,72 +455,72 @@ publish_sync_resp(Q, API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?SYNC_RESP_VALUES, fun sync_resp/1), amqp_util:targeted_publish(Q, Payload, ContentType). --spec publish_stats_req(api_terms()) -> 'ok'. --spec publish_stats_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_stats_req(kz_term:api_terms()) -> 'ok'. +-spec publish_stats_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_stats_req(JObj) -> publish_stats_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_stats_req(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?STATS_REQ_VALUES, fun stats_req/1), amqp_util:kapps_publish(stats_req_publish_key(API), Payload, ContentType). --spec publish_stats_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_stats_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_stats_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_stats_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_stats_resp(Q, JObj) -> publish_stats_resp(Q, JObj, ?DEFAULT_CONTENT_TYPE). publish_stats_resp(Q, API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?STATS_RESP_VALUES, fun stats_resp/1), amqp_util:targeted_publish(Q, Payload, ContentType). --spec publish_login(api_terms()) -> 'ok'. --spec publish_login(api_terms(), ne_binary()) -> 'ok'. +-spec publish_login(kz_term:api_terms()) -> 'ok'. +-spec publish_login(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_login(JObj) -> publish_login(JObj, ?DEFAULT_CONTENT_TYPE). publish_login(API, ContentType) -> {'ok', Payload} = login((API1 = kz_api:prepare_api_payload(API, ?LOGIN_VALUES))), amqp_util:kapps_publish(agent_status_routing_key(API1), Payload, ContentType). --spec publish_logout(api_terms()) -> 'ok'. --spec publish_logout(api_terms(), ne_binary()) -> 'ok'. +-spec publish_logout(kz_term:api_terms()) -> 'ok'. +-spec publish_logout(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_logout(JObj) -> publish_logout(JObj, ?DEFAULT_CONTENT_TYPE). publish_logout(API, ContentType) -> {'ok', Payload} = logout((API1 = kz_api:prepare_api_payload(API, ?LOGOUT_VALUES))), amqp_util:kapps_publish(agent_status_routing_key(API1), Payload, ContentType). --spec publish_login_queue(api_terms()) -> 'ok'. --spec publish_login_queue(api_terms(), ne_binary()) -> 'ok'. +-spec publish_login_queue(kz_term:api_terms()) -> 'ok'. +-spec publish_login_queue(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_login_queue(JObj) -> publish_login_queue(JObj, ?DEFAULT_CONTENT_TYPE). publish_login_queue(API, ContentType) -> {'ok', Payload} = login_queue((API1 = kz_api:prepare_api_payload(API, ?LOGIN_QUEUE_VALUES))), amqp_util:kapps_publish(agent_status_routing_key(API1), Payload, ContentType). --spec publish_logout_queue(api_terms()) -> 'ok'. --spec publish_logout_queue(api_terms(), ne_binary()) -> 'ok'. +-spec publish_logout_queue(kz_term:api_terms()) -> 'ok'. +-spec publish_logout_queue(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_logout_queue(JObj) -> publish_logout_queue(JObj, ?DEFAULT_CONTENT_TYPE). publish_logout_queue(API, ContentType) -> {'ok', Payload} = logout_queue((API1 = kz_api:prepare_api_payload(API, ?LOGOUT_QUEUE_VALUES))), amqp_util:kapps_publish(agent_status_routing_key(API1), Payload, ContentType). --spec publish_pause(api_terms()) -> 'ok'. --spec publish_pause(api_terms(), ne_binary()) -> 'ok'. +-spec publish_pause(kz_term:api_terms()) -> 'ok'. +-spec publish_pause(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_pause(JObj) -> publish_pause(JObj, ?DEFAULT_CONTENT_TYPE). publish_pause(API, ContentType) -> {'ok', Payload} = pause((API1 = kz_api:prepare_api_payload(API, ?PAUSE_VALUES))), amqp_util:kapps_publish(agent_status_routing_key(API1), Payload, ContentType). --spec publish_resume(api_terms()) -> 'ok'. --spec publish_resume(api_terms(), ne_binary()) -> 'ok'. +-spec publish_resume(kz_term:api_terms()) -> 'ok'. +-spec publish_resume(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_resume(JObj) -> publish_resume(JObj, ?DEFAULT_CONTENT_TYPE). publish_resume(API, ContentType) -> {'ok', Payload} = resume((API1 = kz_api:prepare_api_payload(API, ?RESUME_VALUES))), amqp_util:kapps_publish(agent_status_routing_key(API1), Payload, ContentType). --spec publish_login_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_login_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_login_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_login_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_login_resp(RespQ, JObj) -> publish_login_resp(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_login_resp(RespQ, API, ContentType) -> diff --git a/applications/acdc/src/kapi_acdc_queue.erl b/applications/acdc/src/kapi_acdc_queue.erl index 5e6c9c9920c..8c24b8ca124 100644 --- a/applications/acdc/src/kapi_acdc_queue.erl +++ b/applications/acdc/src/kapi_acdc_queue.erl @@ -75,7 +75,7 @@ ,{<<"Member-Priority">>, fun is_integer/1} ]). --spec member_call(api_terms()) -> +-spec member_call(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. member_call(Props) when is_list(Props) -> @@ -86,14 +86,14 @@ member_call(Props) when is_list(Props) -> member_call(JObj) -> member_call(kz_json:to_proplist(JObj)). --spec member_call_v(api_terms()) -> boolean(). +-spec member_call_v(kz_term:api_terms()) -> boolean(). member_call_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?MEMBER_CALL_HEADERS, ?MEMBER_CALL_VALUES, ?MEMBER_CALL_TYPES); member_call_v(JObj) -> member_call_v(kz_json:to_proplist(JObj)). --spec member_call_routing_key(api_terms()) -> ne_binary(). --spec member_call_routing_key(ne_binary(), ne_binary()) -> ne_binary(). +-spec member_call_routing_key(kz_term:api_terms()) -> kz_term:ne_binary(). +-spec member_call_routing_key(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). member_call_routing_key(Props) when is_list(Props) -> Id = props:get_value(<<"Queue-ID">>, Props, <<"*">>), AcctId = props:get_value(<<"Account-ID">>, Props), @@ -117,7 +117,7 @@ member_call_routing_key(AcctId, QueueId) -> ]). -define(MEMBER_CALL_FAIL_TYPES, []). --spec member_call_failure(api_terms()) -> +-spec member_call_failure(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. member_call_failure(Props) when is_list(Props) -> @@ -128,7 +128,7 @@ member_call_failure(Props) when is_list(Props) -> member_call_failure(JObj) -> member_call_failure(kz_json:to_proplist(JObj)). --spec member_call_failure_v(api_terms()) -> boolean(). +-spec member_call_failure_v(kz_term:api_terms()) -> boolean(). member_call_failure_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?MEMBER_CALL_FAIL_HEADERS, ?MEMBER_CALL_FAIL_VALUES, ?MEMBER_CALL_FAIL_TYPES); member_call_failure_v(JObj) -> @@ -144,7 +144,7 @@ member_call_failure_v(JObj) -> ]). -define(MEMBER_CALL_SUCCESS_TYPES, []). --spec member_call_success(api_terms()) -> +-spec member_call_success(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. member_call_success(Props) when is_list(Props) -> @@ -155,7 +155,7 @@ member_call_success(Props) when is_list(Props) -> member_call_success(JObj) -> member_call_success(kz_json:to_proplist(JObj)). --spec member_call_success_v(api_terms()) -> boolean(). +-spec member_call_success_v(kz_term:api_terms()) -> boolean(). member_call_success_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?MEMBER_CALL_SUCCESS_HEADERS, ?MEMBER_CALL_SUCCESS_VALUES, ?MEMBER_CALL_SUCCESS_TYPES); member_call_success_v(JObj) -> @@ -172,7 +172,7 @@ member_call_success_v(JObj) -> ]). -define(MEMBER_CALL_CANCEL_TYPES, []). --spec member_call_cancel(api_terms()) -> +-spec member_call_cancel(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. member_call_cancel(Props) when is_list(Props) -> @@ -183,14 +183,14 @@ member_call_cancel(Props) when is_list(Props) -> member_call_cancel(JObj) -> member_call_cancel(kz_json:to_proplist(JObj)). --spec member_call_cancel_v(api_terms()) -> boolean(). +-spec member_call_cancel_v(kz_term:api_terms()) -> boolean(). member_call_cancel_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?MEMBER_CALL_CANCEL_HEADERS, ?MEMBER_CALL_CANCEL_VALUES, ?MEMBER_CALL_CANCEL_TYPES); member_call_cancel_v(JObj) -> member_call_cancel_v(kz_json:to_proplist(JObj)). --spec member_call_result_routing_key(api_terms()) -> ne_binary(). --spec member_call_result_routing_key(ne_binary(), ne_binary(), ne_binary()) -> ne_binary(). +-spec member_call_result_routing_key(kz_term:api_terms()) -> kz_term:ne_binary(). +-spec member_call_result_routing_key(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). member_call_result_routing_key(Props) when is_list(Props) -> AcctId = props:get_value(<<"Account-ID">>, Props), QueueId = props:get_value(<<"Queue-ID">>, Props, <<"*">>), @@ -215,7 +215,7 @@ member_call_result_routing_key(AcctId, QueueId, CallId) -> ]). -define(MEMBER_CONNECT_REQ_TYPES, []). --spec member_connect_req(api_terms()) -> +-spec member_connect_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. member_connect_req(Props) when is_list(Props) -> @@ -226,14 +226,14 @@ member_connect_req(Props) when is_list(Props) -> member_connect_req(JObj) -> member_connect_req(kz_json:to_proplist(JObj)). --spec member_connect_req_v(api_terms()) -> boolean(). +-spec member_connect_req_v(kz_term:api_terms()) -> boolean(). member_connect_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?MEMBER_CONNECT_REQ_HEADERS, ?MEMBER_CONNECT_REQ_VALUES, ?MEMBER_CONNECT_REQ_TYPES); member_connect_req_v(JObj) -> member_connect_req_v(kz_json:to_proplist(JObj)). --spec member_connect_req_routing_key(api_terms()) -> ne_binary(). --spec member_connect_req_routing_key(ne_binary(), ne_binary()) -> ne_binary(). +-spec member_connect_req_routing_key(kz_term:api_terms()) -> kz_term:ne_binary(). +-spec member_connect_req_routing_key(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). member_connect_req_routing_key(Props) when is_list(Props) -> Id = props:get_value(<<"Queue-ID">>, Props, <<"*">>), AcctId = props:get_value(<<"Account-ID">>, Props), @@ -255,7 +255,7 @@ member_connect_req_routing_key(AcctId, QID) -> ]). -define(MEMBER_CONNECT_RESP_TYPES, []). --spec member_connect_resp(api_terms()) -> +-spec member_connect_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. member_connect_resp(Props) when is_list(Props) -> @@ -266,7 +266,7 @@ member_connect_resp(Props) when is_list(Props) -> member_connect_resp(JObj) -> member_connect_resp(kz_json:to_proplist(JObj)). --spec member_connect_resp_v(api_terms()) -> boolean(). +-spec member_connect_resp_v(kz_term:api_terms()) -> boolean(). member_connect_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?MEMBER_CONNECT_RESP_HEADERS, ?MEMBER_CONNECT_RESP_VALUES, ?MEMBER_CONNECT_RESP_TYPES); member_connect_resp_v(JObj) -> @@ -287,7 +287,7 @@ member_connect_resp_v(JObj) -> ]). -define(MEMBER_CONNECT_WIN_TYPES, [{<<"Record-Caller">>, fun kz_term:is_boolean/1}]). --spec member_connect_win(api_terms()) -> +-spec member_connect_win(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. member_connect_win(Props) when is_list(Props) -> @@ -298,7 +298,7 @@ member_connect_win(Props) when is_list(Props) -> member_connect_win(JObj) -> member_connect_win(kz_json:to_proplist(JObj)). --spec member_connect_win_v(api_terms()) -> boolean(). +-spec member_connect_win_v(kz_term:api_terms()) -> boolean(). member_connect_win_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?MEMBER_CONNECT_WIN_HEADERS, ?MEMBER_CONNECT_WIN_VALUES, ?MEMBER_CONNECT_WIN_TYPES); member_connect_win_v(JObj) -> @@ -314,7 +314,7 @@ member_connect_win_v(JObj) -> ]). -define(AGENT_TIMEOUT_TYPES, []). --spec agent_timeout(api_terms()) -> +-spec agent_timeout(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. agent_timeout(Props) when is_list(Props) -> @@ -324,7 +324,7 @@ agent_timeout(Props) when is_list(Props) -> end; agent_timeout(JObj) -> agent_timeout(kz_json:to_proplist(JObj)). --spec agent_timeout_v(api_terms()) -> boolean(). +-spec agent_timeout_v(kz_term:api_terms()) -> boolean(). agent_timeout_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?AGENT_TIMEOUT_HEADERS, ?AGENT_TIMEOUT_VALUES, ?AGENT_TIMEOUT_TYPES); agent_timeout_v(JObj) -> @@ -340,7 +340,7 @@ agent_timeout_v(JObj) -> ]). -define(MEMBER_CONNECT_ACCEPTED_TYPES, []). --spec member_connect_accepted(api_terms()) -> +-spec member_connect_accepted(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. member_connect_accepted(Props) when is_list(Props) -> @@ -351,7 +351,7 @@ member_connect_accepted(Props) when is_list(Props) -> member_connect_accepted(JObj) -> member_connect_accepted(kz_json:to_proplist(JObj)). --spec member_connect_accepted_v(api_terms()) -> boolean(). +-spec member_connect_accepted_v(kz_term:api_terms()) -> boolean(). member_connect_accepted_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?MEMBER_CONNECT_ACCEPTED_HEADERS, ?MEMBER_CONNECT_ACCEPTED_VALUES, ?MEMBER_CONNECT_ACCEPTED_TYPES); member_connect_accepted_v(JObj) -> @@ -369,7 +369,7 @@ member_connect_accepted_v(JObj) -> ]). -define(MEMBER_CONNECT_RETRY_TYPES, []). --spec member_connect_retry(api_terms()) -> +-spec member_connect_retry(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. member_connect_retry(Props) when is_list(Props) -> @@ -380,7 +380,7 @@ member_connect_retry(Props) when is_list(Props) -> member_connect_retry(JObj) -> member_connect_retry(kz_json:to_proplist(JObj)). --spec member_connect_retry_v(api_terms()) -> boolean(). +-spec member_connect_retry_v(kz_term:api_terms()) -> boolean(). member_connect_retry_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?MEMBER_CONNECT_RETRY_HEADERS, ?MEMBER_CONNECT_RETRY_VALUES, ?MEMBER_CONNECT_RETRY_TYPES); member_connect_retry_v(JObj) -> @@ -399,7 +399,7 @@ member_connect_retry_v(JObj) -> ]). -define(MEMBER_HUNGUP_TYPES, []). --spec member_hungup(api_terms()) -> +-spec member_hungup(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. member_hungup(Props) when is_list(Props) -> @@ -410,7 +410,7 @@ member_hungup(Props) when is_list(Props) -> member_hungup(JObj) -> member_hungup(kz_json:to_proplist(JObj)). --spec member_hungup_v(api_terms()) -> boolean(). +-spec member_hungup_v(kz_term:api_terms()) -> boolean(). member_hungup_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?MEMBER_HUNGUP_HEADERS, ?MEMBER_HUNGUP_VALUES, ?MEMBER_HUNGUP_TYPES); member_hungup_v(JObj) -> @@ -420,8 +420,8 @@ member_hungup_v(JObj) -> %% Sync Req/Resp %% Depending on the queue strategy, get the other queue's strategy state %%------------------------------------------------------------------------------ --spec sync_req_routing_key(api_terms()) -> ne_binary(). --spec sync_req_routing_key(ne_binary(), ne_binary()) -> ne_binary(). +-spec sync_req_routing_key(kz_term:api_terms()) -> kz_term:ne_binary(). +-spec sync_req_routing_key(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). sync_req_routing_key(Props) when is_list(Props) -> Id = props:get_value(<<"Queue-ID">>, Props, <<"*">>), AcctId = props:get_value(<<"Account-ID">>, Props), @@ -441,7 +441,7 @@ sync_req_routing_key(AcctId, QID) -> ]). -define(SYNC_REQ_TYPES, []). --spec sync_req(api_terms()) -> +-spec sync_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. sync_req(Props) when is_list(Props) -> @@ -452,7 +452,7 @@ sync_req(Props) when is_list(Props) -> sync_req(JObj) -> sync_req(kz_json:to_proplist(JObj)). --spec sync_req_v(api_terms()) -> boolean(). +-spec sync_req_v(kz_term:api_terms()) -> boolean(). sync_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SYNC_REQ_HEADERS, ?SYNC_REQ_VALUES, ?SYNC_REQ_TYPES); sync_req_v(JObj) -> @@ -467,7 +467,7 @@ sync_req_v(JObj) -> ]). -define(SYNC_RESP_TYPES, []). --spec sync_resp(api_terms()) -> +-spec sync_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. sync_resp(Props) when is_list(Props) -> @@ -478,7 +478,7 @@ sync_resp(Props) when is_list(Props) -> sync_resp(JObj) -> sync_resp(kz_json:to_proplist(JObj)). --spec sync_resp_v(api_terms()) -> boolean(). +-spec sync_resp_v(kz_term:api_terms()) -> boolean(). sync_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SYNC_RESP_HEADERS, ?SYNC_RESP_VALUES, ?SYNC_RESP_TYPES); sync_resp_v(JObj) -> @@ -511,10 +511,10 @@ agent_change_routing_key(AcctId, QueueId) -> ,?AGENT_CHANGE_UNAVAILABLE ]). --spec agent_change_available() -> ne_binary(). --spec agent_change_ringing() -> ne_binary(). --spec agent_change_busy() -> ne_binary(). --spec agent_change_unavailable() -> ne_binary(). +-spec agent_change_available() -> kz_term:ne_binary(). +-spec agent_change_ringing() -> kz_term:ne_binary(). +-spec agent_change_busy() -> kz_term:ne_binary(). +-spec agent_change_unavailable() -> kz_term:ne_binary(). agent_change_available() -> ?AGENT_CHANGE_AVAILABLE. agent_change_ringing() -> ?AGENT_CHANGE_RINGING. agent_change_busy() -> ?AGENT_CHANGE_BUSY. @@ -528,7 +528,7 @@ agent_change_unavailable() -> ?AGENT_CHANGE_UNAVAILABLE. ]). -define(AGENT_CHANGE_TYPES, []). --spec agent_change(api_terms()) -> +-spec agent_change(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. agent_change(Prop) when is_list(Prop) -> @@ -538,7 +538,7 @@ agent_change(Prop) when is_list(Prop) -> end; agent_change(JObj) -> agent_change(kz_json:to_proplist(JObj)). --spec agent_change_v(api_terms()) -> boolean(). +-spec agent_change_v(kz_term:api_terms()) -> boolean(). agent_change_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?AGENT_CHANGE_HEADERS, ?AGENT_CHANGE_VALUES, ?AGENT_CHANGE_TYPES); agent_change_v(JObj) -> agent_change_v(kz_json:to_proplist(JObj)). @@ -548,8 +548,8 @@ agent_change_v(JObj) -> agent_change_v(kz_json:to_proplist(JObj)). %%------------------------------------------------------------------------------ %% Queue Position tracking %%------------------------------------------------------------------------------ --spec queue_member_routing_key(api_terms()) -> ne_binary(). --spec queue_member_routing_key(ne_binary(), ne_binary()) -> ne_binary(). +-spec queue_member_routing_key(kz_term:api_terms()) -> kz_term:ne_binary(). +-spec queue_member_routing_key(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). queue_member_routing_key(Props) when is_list(Props) -> Id = props:get_value(<<"Queue-ID">>, Props, <<"*">>), AcctId = props:get_value(<<"Account-ID">>, Props), @@ -569,7 +569,7 @@ queue_member_routing_key(AcctId, QID) -> ]). -define(QUEUE_MEMBER_ADD_TYPES, []). --spec queue_member_add(api_terms()) -> +-spec queue_member_add(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. queue_member_add(Prop) when is_list(Prop) -> @@ -579,7 +579,7 @@ queue_member_add(Prop) when is_list(Prop) -> end; queue_member_add(JObj) -> queue_member_add(kz_json:to_proplist(JObj)). --spec queue_member_add_v(api_terms()) -> boolean(). +-spec queue_member_add_v(kz_term:api_terms()) -> boolean(). queue_member_add_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?QUEUE_MEMBER_ADD_HEADERS, ?QUEUE_MEMBER_ADD_VALUES, ?QUEUE_MEMBER_ADD_TYPES); queue_member_add_v(JObj) -> queue_member_add_v(kz_json:to_proplist(JObj)). @@ -591,7 +591,7 @@ queue_member_add_v(JObj) -> queue_member_add_v(kz_json:to_proplist(JObj)). ]). -define(QUEUE_MEMBER_REMOVE_TYPES, []). --spec queue_member_remove(api_terms()) -> +-spec queue_member_remove(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. queue_member_remove(Prop) when is_list(Prop) -> @@ -601,17 +601,17 @@ queue_member_remove(Prop) when is_list(Prop) -> end; queue_member_remove(JObj) -> queue_member_remove(kz_json:to_proplist(JObj)). --spec queue_member_remove_v(api_terms()) -> boolean(). +-spec queue_member_remove_v(kz_term:api_terms()) -> boolean(). queue_member_remove_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?QUEUE_MEMBER_REMOVE_HEADERS, ?QUEUE_MEMBER_REMOVE_VALUES, ?QUEUE_MEMBER_REMOVE_TYPES); queue_member_remove_v(JObj) -> queue_member_remove_v(kz_json:to_proplist(JObj)). %% Bind/Unbind the queue as appropriate %%------------------------------------------------------------------------------ --spec shared_queue_name(ne_binary(), ne_binary()) -> ne_binary(). +-spec shared_queue_name(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). shared_queue_name(AcctId, QueueId) -> <<"acdc.queue.", AcctId/binary, ".", QueueId/binary>>. --spec queue_size(ne_binary(), ne_binary()) -> integer() | 'undefined'. +-spec queue_size(kz_term:ne_binary(), kz_term:ne_binary()) -> integer() | 'undefined'. queue_size(AcctId, QueueId) -> Q = shared_queue_name(AcctId, QueueId), try amqp_util:new_queue(Q, [{'return_field', 'all'} @@ -636,7 +636,7 @@ queue_size(AcctId, QueueId) -> 'undefined' end. --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Q, Props) -> QID = props:get_value('queue_id', Props, <<"*">>), AcctId = props:get_value('account_id', Props), @@ -671,7 +671,7 @@ bind_q(Q, AcctId, QID, CallId, ['member_addremove'|T]) -> bind_q(Q, AcctId, QID, CallId, [_|T]) -> bind_q(Q, AcctId, QID, CallId, T); bind_q(_, _, _, _, []) -> 'ok'. --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Q, Props) -> QID = props:get_value('queue_id', Props, <<"*">>), AcctId = props:get_value('account_id', Props), @@ -721,8 +721,8 @@ declare_exchanges() -> %%------------------------------------------------------------------------------ %% Publishers for convenience %%------------------------------------------------------------------------------ --spec publish_member_call(api_terms()) -> 'ok'. --spec publish_member_call(api_terms(), ne_binary()) -> 'ok'. +-spec publish_member_call(kz_term:api_terms()) -> 'ok'. +-spec publish_member_call(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_member_call(JObj) -> publish_member_call(JObj, ?DEFAULT_CONTENT_TYPE). publish_member_call(Props, ContentType) when is_list(Props) -> @@ -733,8 +733,8 @@ publish_member_call(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?MEMBER_CALL_VALUES, fun member_call/1), amqp_util:callmgr_publish(Payload, ContentType, member_call_routing_key(API), Props). --spec publish_member_call_cancel(api_terms()) -> 'ok'. --spec publish_member_call_cancel(api_terms(), ne_binary()) -> 'ok'. +-spec publish_member_call_cancel(kz_term:api_terms()) -> 'ok'. +-spec publish_member_call_cancel(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_member_call_cancel(JObj) -> publish_member_call_cancel(JObj, ?DEFAULT_CONTENT_TYPE). publish_member_call_cancel(API, ContentType) -> @@ -742,8 +742,8 @@ publish_member_call_cancel(API, ContentType) -> amqp_util:callmgr_publish(Payload, ContentType, member_call_result_routing_key(API)). -spec publish_shared_member_call(kz_json:object()) -> 'ok'. --spec publish_shared_member_call(ne_binary(), ne_binary(), api_terms()) -> 'ok'. --spec publish_shared_member_call(ne_binary(), ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_shared_member_call(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_shared_member_call(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_shared_member_call(JObj) -> publish_shared_member_call(kz_json:get_value(<<"Account-ID">>, JObj) ,kz_json:get_value(<<"Queue-ID">>, JObj) @@ -761,8 +761,8 @@ publish_shared_member_call(AcctId, QueueId, JObj, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(JObj, ?MEMBER_CALL_VALUES, fun member_call/1), amqp_util:targeted_publish(shared_queue_name(AcctId, QueueId), Payload, ContentType, Props). --spec publish_member_call_failure(ne_binary(), api_terms()) -> 'ok'. --spec publish_member_call_failure(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_member_call_failure(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_member_call_failure(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_member_call_failure(Q, JObj) -> publish_member_call_failure(Q, JObj, ?DEFAULT_CONTENT_TYPE). publish_member_call_failure(Q, API, ContentType) -> @@ -770,8 +770,8 @@ publish_member_call_failure(Q, API, ContentType) -> amqp_util:targeted_publish(Q, Payload, ContentType), amqp_util:callmgr_publish(Payload, ContentType, member_call_result_routing_key(API)). --spec publish_member_call_success(ne_binary(), api_terms()) -> 'ok'. --spec publish_member_call_success(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_member_call_success(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_member_call_success(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_member_call_success(Q, JObj) -> publish_member_call_success(Q, JObj, ?DEFAULT_CONTENT_TYPE). publish_member_call_success(Q, API, ContentType) -> @@ -779,96 +779,96 @@ publish_member_call_success(Q, API, ContentType) -> amqp_util:targeted_publish(Q, Payload, ContentType), amqp_util:callmgr_publish(Payload, ContentType, member_call_result_routing_key(API)). --spec publish_member_connect_req(api_terms()) -> 'ok'. --spec publish_member_connect_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_member_connect_req(kz_term:api_terms()) -> 'ok'. +-spec publish_member_connect_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_member_connect_req(JObj) -> publish_member_connect_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_member_connect_req(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?MEMBER_CONNECT_REQ_VALUES, fun member_connect_req/1), amqp_util:callmgr_publish(Payload, ContentType, member_connect_req_routing_key(API)). --spec publish_member_connect_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_member_connect_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_member_connect_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_member_connect_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_member_connect_resp(Q, JObj) -> publish_member_connect_resp(Q, JObj, ?DEFAULT_CONTENT_TYPE). publish_member_connect_resp(Q, API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?MEMBER_CONNECT_RESP_VALUES, fun member_connect_resp/1), amqp_util:targeted_publish(Q, Payload, ContentType). --spec publish_member_connect_win(ne_binary(), api_terms()) -> 'ok'. --spec publish_member_connect_win(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_member_connect_win(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_member_connect_win(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_member_connect_win(Q, JObj) -> publish_member_connect_win(Q, JObj, ?DEFAULT_CONTENT_TYPE). publish_member_connect_win(Q, API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?MEMBER_CONNECT_WIN_VALUES, fun member_connect_win/1), amqp_util:targeted_publish(Q, Payload, ContentType). --spec publish_agent_timeout(ne_binary(), api_terms()) -> 'ok'. --spec publish_agent_timeout(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_agent_timeout(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_agent_timeout(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_agent_timeout(Q, JObj) -> publish_agent_timeout(Q, JObj, ?DEFAULT_CONTENT_TYPE). publish_agent_timeout(Q, API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?AGENT_TIMEOUT_VALUES, fun agent_timeout/1), amqp_util:targeted_publish(Q, Payload, ContentType). --spec publish_member_connect_accepted(ne_binary(), api_terms()) -> 'ok'. --spec publish_member_connect_accepted(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_member_connect_accepted(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_member_connect_accepted(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_member_connect_accepted(Q, JObj) -> publish_member_connect_accepted(Q, JObj, ?DEFAULT_CONTENT_TYPE). publish_member_connect_accepted(Q, API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?MEMBER_CONNECT_ACCEPTED_VALUES, fun member_connect_accepted/1), amqp_util:targeted_publish(Q, Payload, ContentType). --spec publish_member_connect_retry(ne_binary(), api_terms()) -> 'ok'. --spec publish_member_connect_retry(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_member_connect_retry(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_member_connect_retry(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_member_connect_retry(Q, JObj) -> publish_member_connect_retry(Q, JObj, ?DEFAULT_CONTENT_TYPE). publish_member_connect_retry(Q, API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?MEMBER_CONNECT_RETRY_VALUES, fun member_connect_retry/1), amqp_util:targeted_publish(Q, Payload, ContentType). --spec publish_member_hungup(ne_binary(), api_terms()) -> 'ok'. --spec publish_member_hungup(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_member_hungup(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_member_hungup(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_member_hungup(Q, JObj) -> publish_member_hungup(Q, JObj, ?DEFAULT_CONTENT_TYPE). publish_member_hungup(Q, API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?MEMBER_HUNGUP_VALUES, fun member_hungup/1), amqp_util:targeted_publish(Q, Payload, ContentType). --spec publish_sync_req(api_terms()) -> 'ok'. --spec publish_sync_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_sync_req(kz_term:api_terms()) -> 'ok'. +-spec publish_sync_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_sync_req(JObj) -> publish_sync_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_sync_req(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?SYNC_REQ_VALUES, fun sync_req/1), amqp_util:kapps_publish(sync_req_routing_key(API), Payload, ContentType). --spec publish_sync_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_sync_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_sync_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_sync_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_sync_resp(Q, JObj) -> publish_sync_resp(Q, JObj, ?DEFAULT_CONTENT_TYPE). publish_sync_resp(Q, API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?SYNC_RESP_VALUES, fun sync_resp/1), amqp_util:targeted_publish(Q, Payload, ContentType). --spec publish_agent_change(api_terms()) -> 'ok'. --spec publish_agent_change(api_terms(), ne_binary()) -> 'ok'. +-spec publish_agent_change(kz_term:api_terms()) -> 'ok'. +-spec publish_agent_change(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_agent_change(JObj) -> publish_agent_change(JObj, ?DEFAULT_CONTENT_TYPE). publish_agent_change(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?AGENT_CHANGE_VALUES, fun agent_change/1), amqp_util:kapps_publish(agent_change_publish_key(API), Payload, ContentType). --spec publish_queue_member_add(api_terms()) -> 'ok'. --spec publish_queue_member_add(api_terms(), ne_binary()) -> 'ok'. +-spec publish_queue_member_add(kz_term:api_terms()) -> 'ok'. +-spec publish_queue_member_add(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_queue_member_add(JObj) -> publish_queue_member_add(JObj, ?DEFAULT_CONTENT_TYPE). publish_queue_member_add(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?QUEUE_MEMBER_ADD_VALUES, fun queue_member_add/1), amqp_util:kapps_publish(queue_member_routing_key(API), Payload, ContentType). --spec publish_queue_member_remove(api_terms()) -> 'ok'. --spec publish_queue_member_remove(api_terms(), ne_binary()) -> 'ok'. +-spec publish_queue_member_remove(kz_term:api_terms()) -> 'ok'. +-spec publish_queue_member_remove(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_queue_member_remove(JObj) -> publish_queue_member_remove(JObj, ?DEFAULT_CONTENT_TYPE). publish_queue_member_remove(API, ContentType) -> diff --git a/applications/acdc/src/kapi_acdc_stats.erl b/applications/acdc/src/kapi_acdc_stats.erl index d36f9cc8bc7..4fae51678ac 100644 --- a/applications/acdc/src/kapi_acdc_stats.erl +++ b/applications/acdc/src/kapi_acdc_stats.erl @@ -104,7 +104,7 @@ -define(FLUSH_VALUES, ?CALL_REQ_VALUES(<<"flush">>)). -define(FLUSH_TYPES, []). --spec call_waiting(api_terms()) -> +-spec call_waiting(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. call_waiting(Props) when is_list(Props) -> @@ -115,13 +115,13 @@ call_waiting(Props) when is_list(Props) -> call_waiting(JObj) -> call_waiting(kz_json:to_proplist(JObj)). --spec call_waiting_v(api_terms()) -> boolean(). +-spec call_waiting_v(kz_term:api_terms()) -> boolean(). call_waiting_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CALL_REQ_HEADERS, ?WAITING_VALUES, ?WAITING_TYPES); call_waiting_v(JObj) -> call_waiting_v(kz_json:to_proplist(JObj)). --spec call_missed(api_terms()) -> +-spec call_missed(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. call_missed(Props) when is_list(Props) -> @@ -132,13 +132,13 @@ call_missed(Props) when is_list(Props) -> call_missed(JObj) -> call_missed(kz_json:to_proplist(JObj)). --spec call_missed_v(api_terms()) -> boolean(). +-spec call_missed_v(kz_term:api_terms()) -> boolean(). call_missed_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CALL_REQ_HEADERS, ?MISS_VALUES, ?MISS_TYPES); call_missed_v(JObj) -> call_missed_v(kz_json:to_proplist(JObj)). --spec call_abandoned(api_terms()) -> +-spec call_abandoned(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. call_abandoned(Props) when is_list(Props) -> @@ -149,13 +149,13 @@ call_abandoned(Props) when is_list(Props) -> call_abandoned(JObj) -> call_abandoned(kz_json:to_proplist(JObj)). --spec call_abandoned_v(api_terms()) -> boolean(). +-spec call_abandoned_v(kz_term:api_terms()) -> boolean(). call_abandoned_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CALL_REQ_HEADERS, ?ABANDON_VALUES, ?ABANDON_TYPES); call_abandoned_v(JObj) -> call_abandoned_v(kz_json:to_proplist(JObj)). --spec call_handled(api_terms()) -> +-spec call_handled(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. call_handled(Props) when is_list(Props) -> @@ -166,13 +166,13 @@ call_handled(Props) when is_list(Props) -> call_handled(JObj) -> call_handled(kz_json:to_proplist(JObj)). --spec call_handled_v(api_terms()) -> boolean(). +-spec call_handled_v(kz_term:api_terms()) -> boolean(). call_handled_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CALL_REQ_HEADERS, ?HANDLED_VALUES, ?HANDLED_TYPES); call_handled_v(JObj) -> call_handled_v(kz_json:to_proplist(JObj)). --spec call_processed(api_terms()) -> +-spec call_processed(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. call_processed(Props) when is_list(Props) -> @@ -183,13 +183,13 @@ call_processed(Props) when is_list(Props) -> call_processed(JObj) -> call_processed(kz_json:to_proplist(JObj)). --spec call_processed_v(api_terms()) -> boolean(). +-spec call_processed_v(kz_term:api_terms()) -> boolean(). call_processed_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CALL_REQ_HEADERS, ?PROCESS_VALUES, ?PROCESS_TYPES); call_processed_v(JObj) -> call_processed_v(kz_json:to_proplist(JObj)). --spec call_flush(api_terms()) -> +-spec call_flush(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. call_flush(Props) when is_list(Props) -> @@ -200,7 +200,7 @@ call_flush(Props) when is_list(Props) -> call_flush(JObj) -> call_flush(kz_json:to_proplist(JObj)). --spec call_flush_v(api_terms()) -> boolean(). +-spec call_flush_v(kz_term:api_terms()) -> boolean(). call_flush_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CALL_REQ_HEADERS, ?FLUSH_VALUES, ?FLUSH_TYPES); call_flush_v(JObj) -> @@ -216,7 +216,7 @@ call_flush_v(JObj) -> ]). -define(CURRENT_CALLS_REQ_TYPES, []). --spec current_calls_req(api_terms()) -> +-spec current_calls_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. current_calls_req(Props) when is_list(Props) -> @@ -227,7 +227,7 @@ current_calls_req(Props) when is_list(Props) -> current_calls_req(JObj) -> current_calls_req(kz_json:to_proplist(JObj)). --spec current_calls_req_v(api_terms()) -> boolean(). +-spec current_calls_req_v(kz_term:api_terms()) -> boolean(). current_calls_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CURRENT_CALLS_REQ_HEADERS, ?CURRENT_CALLS_REQ_VALUES, ?CURRENT_CALLS_REQ_TYPES); current_calls_req_v(JObj) -> @@ -240,7 +240,7 @@ current_calls_req_v(JObj) -> ]). -define(CURRENT_CALLS_ERR_TYPES, []). --spec current_calls_err(api_terms()) -> +-spec current_calls_err(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. current_calls_err(Props) when is_list(Props) -> @@ -251,7 +251,7 @@ current_calls_err(Props) when is_list(Props) -> current_calls_err(JObj) -> current_calls_err(kz_json:to_proplist(JObj)). --spec current_calls_err_v(api_terms()) -> boolean(). +-spec current_calls_err_v(kz_term:api_terms()) -> boolean(). current_calls_err_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CURRENT_CALLS_ERR_HEADERS, ?CURRENT_CALLS_ERR_VALUES, ?CURRENT_CALLS_ERR_TYPES); current_calls_err_v(JObj) -> @@ -266,7 +266,7 @@ current_calls_err_v(JObj) -> ]). -define(CURRENT_CALLS_RESP_TYPES, []). --spec current_calls_resp(api_terms()) -> +-spec current_calls_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. current_calls_resp(Props) when is_list(Props) -> @@ -277,7 +277,7 @@ current_calls_resp(Props) when is_list(Props) -> current_calls_resp(JObj) -> current_calls_resp(kz_json:to_proplist(JObj)). --spec current_calls_resp_v(api_terms()) -> boolean(). +-spec current_calls_resp_v(kz_term:api_terms()) -> boolean(). current_calls_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CURRENT_CALLS_RESP_HEADERS, ?CURRENT_CALLS_RESP_VALUES, ?CURRENT_CALLS_RESP_TYPES); current_calls_resp_v(JObj) -> @@ -292,7 +292,7 @@ current_calls_resp_v(JObj) -> ]). -define(STATUS_REQ_TYPES, []). --spec status_req(api_terms()) -> +-spec status_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. status_req(Props) when is_list(Props) -> @@ -303,7 +303,7 @@ status_req(Props) when is_list(Props) -> status_req(JObj) -> status_req(kz_json:to_proplist(JObj)). --spec status_req_v(api_terms()) -> boolean(). +-spec status_req_v(kz_term:api_terms()) -> boolean(). status_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?STATUS_REQ_HEADERS, ?STATUS_REQ_VALUES, ?STATUS_REQ_TYPES); status_req_v(JObj) -> @@ -316,7 +316,7 @@ status_req_v(JObj) -> ]). -define(STATUS_ERR_TYPES, []). --spec status_err(api_terms()) -> +-spec status_err(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. status_err(Props) when is_list(Props) -> @@ -327,7 +327,7 @@ status_err(Props) when is_list(Props) -> status_err(JObj) -> status_err(kz_json:to_proplist(JObj)). --spec status_err_v(api_terms()) -> boolean(). +-spec status_err_v(kz_term:api_terms()) -> boolean(). status_err_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?STATUS_ERR_HEADERS, ?STATUS_ERR_VALUES, ?STATUS_ERR_TYPES); status_err_v(JObj) -> @@ -340,7 +340,7 @@ status_err_v(JObj) -> ]). -define(STATUS_RESP_TYPES, []). --spec status_resp(api_terms()) -> +-spec status_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. status_resp(Props) when is_list(Props) -> @@ -351,7 +351,7 @@ status_resp(Props) when is_list(Props) -> status_resp(JObj) -> status_resp(kz_json:to_proplist(JObj)). --spec status_resp_v(api_terms()) -> boolean(). +-spec status_resp_v(kz_term:api_terms()) -> boolean(). status_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?STATUS_RESP_HEADERS, ?STATUS_RESP_VALUES, ?STATUS_RESP_TYPES); status_resp_v(JObj) -> @@ -366,7 +366,7 @@ status_resp_v(JObj) -> ]). -define(STATUS_TYPES, []). --spec status_update(api_terms()) -> +-spec status_update(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. status_update(Props) when is_list(Props) -> @@ -377,14 +377,14 @@ status_update(Props) when is_list(Props) -> status_update(JObj) -> status_update(kz_json:to_proplist(JObj)). --spec status_update_v(api_terms()) -> boolean(). +-spec status_update_v(kz_term:api_terms()) -> boolean(). status_update_v(Prop) when is_list(Prop) -> EvtName = props:get_value(<<"Status">>, Prop), kz_api:validate(Prop, ?STATUS_HEADERS, ?STATUS_VALUES(EvtName), ?STATUS_TYPES); status_update_v(JObj) -> status_update_v(kz_json:to_proplist(JObj)). --spec status_ready(api_terms()) -> +-spec status_ready(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. status_ready(Props) when is_list(Props) -> @@ -395,13 +395,13 @@ status_ready(Props) when is_list(Props) -> status_ready(JObj) -> status_ready(kz_json:to_proplist(JObj)). --spec status_ready_v(api_terms()) -> boolean(). +-spec status_ready_v(kz_term:api_terms()) -> boolean(). status_ready_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?STATUS_HEADERS, ?STATUS_VALUES(<<"ready">>), ?STATUS_TYPES); status_ready_v(JObj) -> status_ready_v(kz_json:to_proplist(JObj)). --spec status_logged_in(api_terms()) -> +-spec status_logged_in(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. status_logged_in(Props) when is_list(Props) -> @@ -412,13 +412,13 @@ status_logged_in(Props) when is_list(Props) -> status_logged_in(JObj) -> status_logged_in(kz_json:to_proplist(JObj)). --spec status_logged_in_v(api_terms()) -> boolean(). +-spec status_logged_in_v(kz_term:api_terms()) -> boolean(). status_logged_in_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?STATUS_HEADERS, ?STATUS_VALUES(<<"logged_in">>), ?STATUS_TYPES); status_logged_in_v(JObj) -> status_logged_in_v(kz_json:to_proplist(JObj)). --spec status_logged_out(api_terms()) -> +-spec status_logged_out(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. status_logged_out(Props) when is_list(Props) -> @@ -429,13 +429,13 @@ status_logged_out(Props) when is_list(Props) -> status_logged_out(JObj) -> status_logged_out(kz_json:to_proplist(JObj)). --spec status_logged_out_v(api_terms()) -> boolean(). +-spec status_logged_out_v(kz_term:api_terms()) -> boolean(). status_logged_out_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?STATUS_HEADERS, ?STATUS_VALUES(<<"logged_out">>), ?STATUS_TYPES); status_logged_out_v(JObj) -> status_logged_out_v(kz_json:to_proplist(JObj)). --spec status_pending_logged_out(api_terms()) -> +-spec status_pending_logged_out(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. status_pending_logged_out(Props) when is_list(Props) -> @@ -446,13 +446,13 @@ status_pending_logged_out(Props) when is_list(Props) -> status_pending_logged_out(JObj) -> status_pending_logged_out(kz_json:to_proplist(JObj)). --spec status_pending_logged_out_v(api_terms()) -> boolean(). +-spec status_pending_logged_out_v(kz_term:api_terms()) -> boolean(). status_pending_logged_out_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?STATUS_HEADERS, ?STATUS_VALUES(<<"pending_logged_out">>), ?STATUS_TYPES); status_pending_logged_out_v(JObj) -> status_pending_logged_out_v(kz_json:to_proplist(JObj)). --spec status_connecting(api_terms()) -> +-spec status_connecting(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. status_connecting(Props) when is_list(Props) -> @@ -463,13 +463,13 @@ status_connecting(Props) when is_list(Props) -> status_connecting(JObj) -> status_connecting(kz_json:to_proplist(JObj)). --spec status_connecting_v(api_terms()) -> boolean(). +-spec status_connecting_v(kz_term:api_terms()) -> boolean(). status_connecting_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?STATUS_HEADERS, ?STATUS_VALUES(<<"connecting">>), ?STATUS_TYPES); status_connecting_v(JObj) -> status_connecting_v(kz_json:to_proplist(JObj)). --spec status_connected(api_terms()) -> +-spec status_connected(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. status_connected(Props) when is_list(Props) -> @@ -480,13 +480,13 @@ status_connected(Props) when is_list(Props) -> status_connected(JObj) -> status_connected(kz_json:to_proplist(JObj)). --spec status_connected_v(api_terms()) -> boolean(). +-spec status_connected_v(kz_term:api_terms()) -> boolean(). status_connected_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?STATUS_HEADERS, ?STATUS_VALUES(<<"connected">>), ?STATUS_TYPES); status_connected_v(JObj) -> status_connected_v(kz_json:to_proplist(JObj)). --spec status_wrapup(api_terms()) -> +-spec status_wrapup(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. status_wrapup(Props) when is_list(Props) -> @@ -497,13 +497,13 @@ status_wrapup(Props) when is_list(Props) -> status_wrapup(JObj) -> status_wrapup(kz_json:to_proplist(JObj)). --spec status_wrapup_v(api_terms()) -> boolean(). +-spec status_wrapup_v(kz_term:api_terms()) -> boolean(). status_wrapup_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?STATUS_HEADERS, ?STATUS_VALUES(<<"wrapup">>), ?STATUS_TYPES); status_wrapup_v(JObj) -> status_wrapup_v(kz_json:to_proplist(JObj)). --spec status_paused(api_terms()) -> +-spec status_paused(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. status_paused(Props) when is_list(Props) -> @@ -514,13 +514,13 @@ status_paused(Props) when is_list(Props) -> status_paused(JObj) -> status_paused(kz_json:to_proplist(JObj)). --spec status_paused_v(api_terms()) -> boolean(). +-spec status_paused_v(kz_term:api_terms()) -> boolean(). status_paused_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?STATUS_HEADERS, ?STATUS_VALUES(<<"paused">>), ?STATUS_TYPES); status_paused_v(JObj) -> status_paused_v(kz_json:to_proplist(JObj)). --spec status_outbound(api_terms()) -> +-spec status_outbound(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. status_outbound(Props) when is_list(Props) -> @@ -531,13 +531,13 @@ status_outbound(Props) when is_list(Props) -> status_outbound(JObj) -> status_outbound(kz_json:to_proplist(JObj)). --spec status_outbound_v(api_terms()) -> boolean(). +-spec status_outbound_v(kz_term:api_terms()) -> boolean(). status_outbound_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?STATUS_HEADERS, ?STATUS_VALUES(<<"outbound">>), ?STATUS_TYPES); status_outbound_v(JObj) -> status_outbound_v(kz_json:to_proplist(JObj)). --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Q, Props) -> QID = props:get_value('queue_id', Props, <<"*">>), AID = props:get_value('agent_id', Props, <<"*">>), @@ -565,7 +565,7 @@ bind_q(Q, AcctId, QID, AID, [_|L]) -> bind_q(Q, AcctId, QID, AID, L); bind_q(_Q, _AcctId, _QID, _AID, []) -> 'ok'. --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Q, Props) -> QID = props:get_value('queue_id', Props, <<"*">>), AID = props:get_value('agent_id', Props, <<"*">>), @@ -603,48 +603,48 @@ unbind_q(_Q, _AcctId, _QID, _AID, []) -> 'ok'. declare_exchanges() -> amqp_util:kapps_exchange(). --spec publish_call_waiting(api_terms()) -> 'ok'. --spec publish_call_waiting(api_terms(), binary()) -> 'ok'. +-spec publish_call_waiting(kz_term:api_terms()) -> 'ok'. +-spec publish_call_waiting(kz_term:api_terms(), binary()) -> 'ok'. publish_call_waiting(JObj) -> publish_call_waiting(JObj, ?DEFAULT_CONTENT_TYPE). publish_call_waiting(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?WAITING_VALUES, fun call_waiting/1), amqp_util:kapps_publish(call_stat_routing_key(API), Payload, ContentType). --spec publish_call_missed(api_terms()) -> 'ok'. --spec publish_call_missed(api_terms(), binary()) -> 'ok'. +-spec publish_call_missed(kz_term:api_terms()) -> 'ok'. +-spec publish_call_missed(kz_term:api_terms(), binary()) -> 'ok'. publish_call_missed(JObj) -> publish_call_missed(JObj, ?DEFAULT_CONTENT_TYPE). publish_call_missed(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?MISS_VALUES, fun call_missed/1), amqp_util:kapps_publish(call_stat_routing_key(API), Payload, ContentType). --spec publish_call_abandoned(api_terms()) -> 'ok'. --spec publish_call_abandoned(api_terms(), binary()) -> 'ok'. +-spec publish_call_abandoned(kz_term:api_terms()) -> 'ok'. +-spec publish_call_abandoned(kz_term:api_terms(), binary()) -> 'ok'. publish_call_abandoned(JObj) -> publish_call_abandoned(JObj, ?DEFAULT_CONTENT_TYPE). publish_call_abandoned(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?ABANDON_VALUES, fun call_abandoned/1), amqp_util:kapps_publish(call_stat_routing_key(API), Payload, ContentType). --spec publish_call_handled(api_terms()) -> 'ok'. --spec publish_call_handled(api_terms(), binary()) -> 'ok'. +-spec publish_call_handled(kz_term:api_terms()) -> 'ok'. +-spec publish_call_handled(kz_term:api_terms(), binary()) -> 'ok'. publish_call_handled(JObj) -> publish_call_handled(JObj, ?DEFAULT_CONTENT_TYPE). publish_call_handled(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?HANDLED_VALUES, fun call_handled/1), amqp_util:kapps_publish(call_stat_routing_key(API), Payload, ContentType). --spec publish_call_processed(api_terms()) -> 'ok'. --spec publish_call_processed(api_terms(), binary()) -> 'ok'. +-spec publish_call_processed(kz_term:api_terms()) -> 'ok'. +-spec publish_call_processed(kz_term:api_terms(), binary()) -> 'ok'. publish_call_processed(JObj) -> publish_call_processed(JObj, ?DEFAULT_CONTENT_TYPE). publish_call_processed(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?PROCESS_VALUES, fun call_processed/1), amqp_util:kapps_publish(call_stat_routing_key(API), Payload, ContentType). --spec publish_call_flush(api_terms()) -> 'ok'. --spec publish_call_flush(api_terms(), binary()) -> 'ok'. +-spec publish_call_flush(kz_term:api_terms()) -> 'ok'. +-spec publish_call_flush(kz_term:api_terms(), binary()) -> 'ok'. publish_call_flush(JObj) -> publish_call_flush(JObj, ?DEFAULT_CONTENT_TYPE). publish_call_flush(API, ContentType) -> @@ -652,8 +652,8 @@ publish_call_flush(API, ContentType) -> lager:debug("flush payload ~s: ~s", [call_stat_routing_key(API), Payload]), amqp_util:kapps_publish(call_stat_routing_key(API), Payload, ContentType). --spec publish_status_update(api_terms()) -> 'ok'. --spec publish_status_update(api_terms(), binary()) -> 'ok'. +-spec publish_status_update(kz_term:api_terms()) -> 'ok'. +-spec publish_status_update(kz_term:api_terms(), binary()) -> 'ok'. publish_status_update(JObj) -> publish_status_update(JObj, ?DEFAULT_CONTENT_TYPE). publish_status_update(API, ContentType) -> @@ -661,120 +661,120 @@ publish_status_update(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?STATUS_VALUES(EvtName), fun status_update/1), amqp_util:kapps_publish(status_stat_routing_key(API), Payload, ContentType). --spec publish_status_ready(api_terms()) -> 'ok'. --spec publish_status_ready(api_terms(), binary()) -> 'ok'. +-spec publish_status_ready(kz_term:api_terms()) -> 'ok'. +-spec publish_status_ready(kz_term:api_terms(), binary()) -> 'ok'. publish_status_ready(JObj) -> publish_status_ready(JObj, ?DEFAULT_CONTENT_TYPE). publish_status_ready(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?STATUS_VALUES(<<"ready">>), fun status_ready/1), amqp_util:kapps_publish(status_stat_routing_key(API), Payload, ContentType). --spec publish_status_logged_in(api_terms()) -> 'ok'. --spec publish_status_logged_in(api_terms(), binary()) -> 'ok'. +-spec publish_status_logged_in(kz_term:api_terms()) -> 'ok'. +-spec publish_status_logged_in(kz_term:api_terms(), binary()) -> 'ok'. publish_status_logged_in(JObj) -> publish_status_logged_in(JObj, ?DEFAULT_CONTENT_TYPE). publish_status_logged_in(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?STATUS_VALUES(<<"logged_in">>), fun status_logged_in/1), amqp_util:kapps_publish(status_stat_routing_key(API), Payload, ContentType). --spec publish_status_logged_out(api_terms()) -> 'ok'. --spec publish_status_logged_out(api_terms(), binary()) -> 'ok'. +-spec publish_status_logged_out(kz_term:api_terms()) -> 'ok'. +-spec publish_status_logged_out(kz_term:api_terms(), binary()) -> 'ok'. publish_status_logged_out(JObj) -> publish_status_logged_out(JObj, ?DEFAULT_CONTENT_TYPE). publish_status_logged_out(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?STATUS_VALUES(<<"logged_out">>), fun status_logged_out/1), amqp_util:kapps_publish(status_stat_routing_key(API), Payload, ContentType). --spec publish_status_pending_logged_out(api_terms()) -> 'ok'. --spec publish_status_pending_logged_out(api_terms(), ne_binary()) -> 'ok'. +-spec publish_status_pending_logged_out(kz_term:api_terms()) -> 'ok'. +-spec publish_status_pending_logged_out(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_status_pending_logged_out(JObj) -> publish_status_pending_logged_out(JObj, ?DEFAULT_CONTENT_TYPE). publish_status_pending_logged_out(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?STATUS_VALUES(<<"pending_logged_out">>), fun status_pending_logged_out/1), amqp_util:kapps_publish(status_stat_routing_key(API), Payload, ContentType). --spec publish_status_connecting(api_terms()) -> 'ok'. --spec publish_status_connecting(api_terms(), binary()) -> 'ok'. +-spec publish_status_connecting(kz_term:api_terms()) -> 'ok'. +-spec publish_status_connecting(kz_term:api_terms(), binary()) -> 'ok'. publish_status_connecting(JObj) -> publish_status_connecting(JObj, ?DEFAULT_CONTENT_TYPE). publish_status_connecting(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?STATUS_VALUES(<<"connecting">>), fun status_connecting/1), amqp_util:kapps_publish(status_stat_routing_key(API), Payload, ContentType). --spec publish_status_connected(api_terms()) -> 'ok'. --spec publish_status_connected(api_terms(), binary()) -> 'ok'. +-spec publish_status_connected(kz_term:api_terms()) -> 'ok'. +-spec publish_status_connected(kz_term:api_terms(), binary()) -> 'ok'. publish_status_connected(JObj) -> publish_status_connected(JObj, ?DEFAULT_CONTENT_TYPE). publish_status_connected(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?STATUS_VALUES(<<"connected">>), fun status_connected/1), amqp_util:kapps_publish(status_stat_routing_key(API), Payload, ContentType). --spec publish_status_wrapup(api_terms()) -> 'ok'. --spec publish_status_wrapup(api_terms(), binary()) -> 'ok'. +-spec publish_status_wrapup(kz_term:api_terms()) -> 'ok'. +-spec publish_status_wrapup(kz_term:api_terms(), binary()) -> 'ok'. publish_status_wrapup(JObj) -> publish_status_wrapup(JObj, ?DEFAULT_CONTENT_TYPE). publish_status_wrapup(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?STATUS_VALUES(<<"wrapup">>), fun status_wrapup/1), amqp_util:kapps_publish(status_stat_routing_key(API), Payload, ContentType). --spec publish_status_paused(api_terms()) -> 'ok'. --spec publish_status_paused(api_terms(), binary()) -> 'ok'. +-spec publish_status_paused(kz_term:api_terms()) -> 'ok'. +-spec publish_status_paused(kz_term:api_terms(), binary()) -> 'ok'. publish_status_paused(JObj) -> publish_status_paused(JObj, ?DEFAULT_CONTENT_TYPE). publish_status_paused(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?STATUS_VALUES(<<"paused">>), fun status_paused/1), amqp_util:kapps_publish(status_stat_routing_key(API), Payload, ContentType). --spec publish_status_outbound(api_terms()) -> 'ok'. --spec publish_status_outbound(api_terms(), binary()) -> 'ok'. +-spec publish_status_outbound(kz_term:api_terms()) -> 'ok'. +-spec publish_status_outbound(kz_term:api_terms(), binary()) -> 'ok'. publish_status_outbound(JObj) -> publish_status_outbound(JObj, ?DEFAULT_CONTENT_TYPE). publish_status_outbound(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?STATUS_VALUES(<<"outbound">>), fun status_outbound/1), amqp_util:kapps_publish(status_stat_routing_key(API), Payload, ContentType). --spec publish_current_calls_req(api_terms()) -> 'ok'. --spec publish_current_calls_req(api_terms(), binary()) -> 'ok'. +-spec publish_current_calls_req(kz_term:api_terms()) -> 'ok'. +-spec publish_current_calls_req(kz_term:api_terms(), binary()) -> 'ok'. publish_current_calls_req(JObj) -> publish_current_calls_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_current_calls_req(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?CURRENT_CALLS_REQ_VALUES, fun current_calls_req/1), amqp_util:kapps_publish(query_call_stat_routing_key(API), Payload, ContentType). --spec publish_current_calls_err(ne_binary(), api_terms()) -> 'ok'. --spec publish_current_calls_err(ne_binary(), api_terms(), binary()) -> 'ok'. +-spec publish_current_calls_err(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_current_calls_err(kz_term:ne_binary(), kz_term:api_terms(), binary()) -> 'ok'. publish_current_calls_err(RespQ, JObj) -> publish_current_calls_err(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_current_calls_err(RespQ, API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?CURRENT_CALLS_ERR_VALUES, fun current_calls_err/1), amqp_util:targeted_publish(RespQ, Payload, ContentType). --spec publish_current_calls_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_current_calls_resp(ne_binary(), api_terms(), binary()) -> 'ok'. +-spec publish_current_calls_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_current_calls_resp(kz_term:ne_binary(), kz_term:api_terms(), binary()) -> 'ok'. publish_current_calls_resp(RespQ, JObj) -> publish_current_calls_resp(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_current_calls_resp(RespQ, API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?CURRENT_CALLS_RESP_VALUES, fun current_calls_resp/1), amqp_util:targeted_publish(RespQ, Payload, ContentType). --spec publish_status_req(api_terms()) -> 'ok'. --spec publish_status_req(api_terms(), binary()) -> 'ok'. +-spec publish_status_req(kz_term:api_terms()) -> 'ok'. +-spec publish_status_req(kz_term:api_terms(), binary()) -> 'ok'. publish_status_req(JObj) -> publish_status_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_status_req(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?STATUS_REQ_VALUES, fun status_req/1), amqp_util:kapps_publish(query_status_stat_routing_key(API), Payload, ContentType). --spec publish_status_err(ne_binary(), api_terms()) -> 'ok'. --spec publish_status_err(ne_binary(), api_terms(), binary()) -> 'ok'. +-spec publish_status_err(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_status_err(kz_term:ne_binary(), kz_term:api_terms(), binary()) -> 'ok'. publish_status_err(RespQ, JObj) -> publish_status_err(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_status_err(RespQ, API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?STATUS_ERR_VALUES, fun status_err/1), amqp_util:targeted_publish(RespQ, Payload, ContentType). --spec publish_status_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_status_resp(ne_binary(), api_terms(), binary()) -> 'ok'. +-spec publish_status_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_status_resp(kz_term:ne_binary(), kz_term:api_terms(), binary()) -> 'ok'. publish_status_resp(RespQ, JObj) -> publish_status_resp(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_status_resp(RespQ, API, ContentType) -> diff --git a/applications/ananke/src/ananke_app.erl b/applications/ananke/src/ananke_app.erl index 7c0c1437604..f711d2087f8 100644 --- a/applications/ananke/src/ananke_app.erl +++ b/applications/ananke/src/ananke_app.erl @@ -19,7 +19,7 @@ %% Implement the application start behaviour %% @end %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = kapi_self:declare_exchanges(), _ = kapi_notifications:declare_exchanges(), diff --git a/applications/ananke/src/ananke_listener.erl b/applications/ananke/src/ananke_listener.erl index fc22c8dd8bb..64a50a03581 100644 --- a/applications/ananke/src/ananke_listener.erl +++ b/applications/ananke/src/ananke_listener.erl @@ -49,7 +49,7 @@ %% @spec start_link() -> {ok, Pid} | ignore | {error, Error} %% @end %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link({'local', ?SERVER} ,?MODULE @@ -183,9 +183,9 @@ code_change(_OldVsn, State, _Extra) -> %%% Internal functions %%%=================================================================== -type time() :: amqp_cron_task:oneshot() | amqp_cron_task:cron() | amqp_cron_task:sleeper(). --type time_token_value() :: 'all' | integer() | integers(). +-type time_token_value() :: 'all' | integer() | kz_term:integers(). -type amqp_cron_callback() :: {atom(), atom(), list()} | {fun(), list()}. --spec normalize_schedule(kz_json:object()) -> {ne_binary(), time(), amqp_cron_callback()}. +-spec normalize_schedule(kz_json:object()) -> {kz_term:ne_binary(), time(), amqp_cron_callback()}. normalize_schedule(Schedule) -> Action = kz_json:get_value(<<"action">>, Schedule), ActionType = kz_json:get_value(<<"type">>, Action), @@ -233,18 +233,18 @@ time_schedule(Schedule) -> + ?SECONDS_IN_DAY * Days) * ?MILLISECONDS_IN_SECOND} end. --spec schedule({ne_binary(), time(), amqp_cron_task:execargs()}) -> {'ok', pid()} | {'error', any()}. +-spec schedule({kz_term:ne_binary(), time(), amqp_cron_task:execargs()}) -> {'ok', pid()} | {'error', any()}. schedule({Name, Time, Action}) -> lager:info("scheduling ~p", [Name]), amqp_cron:schedule_task(Name, Time, Action). --spec get_time_token_value(kz_json:object()) -> fun(({ne_binary(), any()}) -> time_token_value()). +-spec get_time_token_value(kz_json:object()) -> fun(({kz_term:ne_binary(), any()}) -> time_token_value()). get_time_token_value(JObj) -> fun({TokenName, Default}) -> parse_time_token(TokenName, JObj, Default) end. --spec parse_time_token(ne_binary(), kz_json:object(), time_token_value()) -> time_token_value(). +-spec parse_time_token(kz_term:ne_binary(), kz_json:object(), time_token_value()) -> time_token_value(). parse_time_token(TokenName, Schedule, Default) -> case kz_json:get_value(TokenName, Schedule, Default) of <<"all">> -> 'all'; @@ -253,7 +253,7 @@ parse_time_token(TokenName, Schedule, Default) -> Token -> kz_term:to_integer(Token) end. --spec action_fun(ne_binary(), kz_json:object()) -> amqp_cron_callback(). +-spec action_fun(kz_term:ne_binary(), kz_json:object()) -> amqp_cron_callback(). action_fun(<<"check_voicemail">>, JObj) -> AccountId = kz_json:get_value(<<"account_id">>, JObj), VmboxId = kz_json:get_value(<<"vmbox_id">>, JObj), @@ -263,17 +263,17 @@ action_fun(<<"account_crawl">>, _) -> action_fun(Type, _JObj) -> {fun unknown_type/1, [Type]}. --spec action_name(ne_binary(), kz_json:object(), time()) -> ne_binary(). +-spec action_name(kz_term:ne_binary(), kz_json:object(), time()) -> kz_term:ne_binary(). action_name(ActionType, Action, Times) -> ActionSuffix = action_suffixes(ActionType, Action), kz_binary:join([ActionType | ActionSuffix] ++ [time_suffix(Times)], "-"). --spec action_suffixes(ne_binary(), kz_json:object()) -> ne_binaries(). +-spec action_suffixes(kz_term:ne_binary(), kz_json:object()) -> kz_term:ne_binaries(). action_suffixes(<<"check_voicemail">>, JObj) -> [kz_json:get_value(<<"account_id">>, JObj), kz_json:get_value(<<"vmbox_id">>, JObj)]; action_suffixes(_Type, _JObj) -> []. --spec time_suffix(time()) -> ne_binary(). +-spec time_suffix(time()) -> kz_term:ne_binary(). time_suffix({'cron', {Minutes, Hours, MDays, Months, Weekdays}}) -> Time = [time_tokens_to_binary(T) || T <- [Minutes, Hours, MDays, Months, Weekdays]], kz_binary:join(Time, "-"); @@ -283,12 +283,12 @@ time_suffix({'oneshot', {{Year, Month, Day}, {Hour, Minute, Second}}}) -> time_suffix({'sleeper', MilliSeconds}) -> kz_term:to_binary(MilliSeconds). --spec time_tokens_to_binary(time_token_value()) -> ne_binary(). +-spec time_tokens_to_binary(time_token_value()) -> kz_term:ne_binary(). time_tokens_to_binary('all') -> <<"all">>; time_tokens_to_binary(Tokens) when is_list(Tokens) -> kz_binary:join([kz_term:to_binary(X) || X <- Tokens], ","). --spec unknown_type(api_binary()) -> 'ok'. +-spec unknown_type(kz_term:api_binary()) -> 'ok'. unknown_type(Type) -> lager:warning("no function for type ~p", [Type]). diff --git a/applications/ananke/src/ananke_sup.erl b/applications/ananke/src/ananke_sup.erl index 815b73178d1..974bff12678 100644 --- a/applications/ananke/src/ananke_sup.erl +++ b/applications/ananke/src/ananke_sup.erl @@ -30,7 +30,7 @@ %% Starts the supervisor %% @end %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -47,7 +47,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init([]) -> sup_init_ret(). +-spec init([]) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/ananke/src/ananke_tasks_sup.erl b/applications/ananke/src/ananke_tasks_sup.erl index 8ee85fdc7d7..1d1deac3cd7 100644 --- a/applications/ananke/src/ananke_tasks_sup.erl +++ b/applications/ananke/src/ananke_tasks_sup.erl @@ -33,11 +33,11 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec start_task(any(), atom(), list()) -> ok | sup_startchild_ret(). +-spec start_task(any(), atom(), list()) -> ok | kz_types:sup_startchild_ret(). start_task(Id, Module, Args) -> case supervisor:start_child(?SERVER, ?TASK_WORKER_SPEC(Id, Module, Args)) of {'error', 'already_present'} -> @@ -80,7 +80,7 @@ delete_child(Id, Timeout) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 3, diff --git a/applications/ananke/src/tasks/ananke_callback_worker.erl b/applications/ananke/src/tasks/ananke_callback_worker.erl index 8055a401ed5..3763729fb17 100644 --- a/applications/ananke/src/tasks/ananke_callback_worker.erl +++ b/applications/ananke/src/tasks/ananke_callback_worker.erl @@ -25,16 +25,16 @@ -define(SERVER, ?MODULE). --record(state, {request :: kz_proplist() | 'undefined' - ,timer :: api_reference() +-record(state, {request :: kz_term:proplist() | 'undefined' + ,timer :: kz_term:api_reference() ,schedule :: pos_integers() | 'undefined' ,check = 'true' :: check_fun() }). -type state() :: #state{}. --spec start_link(kz_proplist(), pos_integers()) -> {'ok', pid()} | {'error', any()}. --spec start_link(kz_proplist(), pos_integers(), check_fun()) -> {'ok', pid()} | {'error', any()}. +-spec start_link(kz_term:proplist(), pos_integers()) -> {'ok', pid()} | {'error', any()}. +-spec start_link(kz_term:proplist(), pos_integers(), check_fun()) -> {'ok', pid()} | {'error', any()}. start_link(Req, [_ | _] = Schedule) -> start_link(#state{request = Req, schedule = Schedule}). @@ -124,7 +124,7 @@ check_condition(#state{check = Fun}, _) when is_function(Fun, 0) -> 'stop' end. --spec send_request(state(), kz_proplist()) -> routine_ret(). +-spec send_request(state(), kz_term:proplist()) -> routine_ret(). send_request(State, Req) -> lager:debug("sending originate request"), ReqTimeout = props:get_value(<<"Timeout">>, Req) * ?MILLISECONDS_IN_SECOND, diff --git a/applications/ananke/src/tasks/ananke_vm_callback.erl b/applications/ananke/src/tasks/ananke_vm_callback.erl index 697d7809563..cae36155f74 100644 --- a/applications/ananke/src/tasks/ananke_vm_callback.erl +++ b/applications/ananke/src/tasks/ananke_vm_callback.erl @@ -16,21 +16,21 @@ -include("ananke.hrl"). --record(args, {account_id :: api_binary() - ,user_id :: api_binary() - ,vm_box_id :: api_binary() - ,callback_number :: api_binary() +-record(args, {account_id :: kz_term:api_binary() + ,user_id :: kz_term:api_binary() + ,vm_box_id :: kz_term:api_binary() + ,callback_number :: kz_term:api_binary() ,is_callback_disabled :: boolean() - ,vm_number :: api_binary() + ,vm_number :: kz_term:api_binary() ,schedule :: pos_integers() ,call_timeout :: pos_integer() - ,realm :: api_binary() + ,realm :: kz_term:api_binary() }). -spec init() -> 'ok'. init() -> 'ok'. --spec check(ne_binary(), ne_binary()) -> any(). +-spec check(kz_term:ne_binary(), kz_term:ne_binary()) -> any(). check(AccountId, VMBoxId) -> lager:info("checking vmbox ~p in ~p", [VMBoxId, AccountId]), case has_unread(AccountId, VMBoxId) of @@ -46,12 +46,12 @@ check(AccountId, VMBoxId) -> ) end. --spec has_unread(ne_binary(), ne_binary()) -> boolean(). +-spec has_unread(kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). has_unread(AccountId, VMBoxId) -> {New, _} = kvm_messages:count_non_deleted(AccountId, VMBoxId), New > 0. --spec handle_req(kz_json:object(), kz_proplist()) -> any(). +-spec handle_req(kz_json:object(), kz_term:proplist()) -> any(). handle_req(JObj, Props) -> 'true' = props:get_value(<<"skip_verification">>, Props, 'false') orelse kapi_notifications:voicemail_saved_v(JObj), @@ -99,7 +99,7 @@ handle_req(JObj, Props) -> maybe_start_caller(StartArgs) end. --spec get_voicemail_number(ne_binary(), ne_binary()) -> api_binary(). +-spec get_voicemail_number(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_binary(). get_voicemail_number(AccountDb, Mailbox) -> {'ok', Callflows} = kz_datamgr:get_results(AccountDb ,<<"callflows/crossbar_listing">> @@ -126,14 +126,14 @@ is_voicemail_cf(JObj) -> _ -> is_voicemail_cf(FlowJObj) end. --spec get_cf_flow(kz_json:object()) -> api_object(). +-spec get_cf_flow(kz_json:object()) -> kz_term:api_object(). get_cf_flow(JObj) -> case kz_json:get_value([<<"children">>, <<"_">>], JObj) of 'undefined' -> kz_json:get_value([<<"doc">>, <<"flow">>], JObj); FlowJObj -> FlowJObj end. --spec get_callflow_number(kz_json:object(), ne_binary()) -> api_binary(). +-spec get_callflow_number(kz_json:object(), kz_term:ne_binary()) -> kz_term:api_binary(). get_callflow_number(Callflow, _Mailbox) -> case kz_json:get_value([<<"doc">>, <<"numbers">>], Callflow, ['undefined']) of [] -> 'undefined'; @@ -164,7 +164,7 @@ start_caller(#args{callback_number = Number WorkerArgs = [OriginateReq, Schedule, CheckFun], ananke_tasks_sup:start_task(WorkerId, 'ananke_callback_worker', WorkerArgs). --spec build_originate_req(#args{}) -> kz_proplist(). +-spec build_originate_req(#args{}) -> kz_term:proplist(). build_originate_req(#args{callback_number = CallbackNumber ,vm_number = VMNumber ,account_id = AccountId @@ -215,11 +215,11 @@ build_originate_req(#args{callback_number = CallbackNumber | kz_api:default_headers(<<"resource">>, <<"originate_req">>, ?APP_NAME, ?APP_VERSION) ]). --spec get_first_defined([{ne_binary(), kz_json:object()}]) -> api_binary(). +-spec get_first_defined([{kz_term:ne_binary(), kz_json:object()}]) -> kz_term:api_binary(). get_first_defined(Props) -> get_first_defined(Props, 'undefined'). --spec get_first_defined([{ne_binary(), kz_json:object()}], Default) -> binary() | Default. +-spec get_first_defined([{kz_term:ne_binary(), kz_json:object()}], Default) -> binary() | Default. get_first_defined([], Default) -> Default; get_first_defined([{Keys, JObj} | Rest], Default) -> case kz_json:get_value(Keys, JObj) of diff --git a/applications/blackhole/src/bh_context.erl b/applications/blackhole/src/bh_context.erl index 00946c97b00..a7b0fc06efa 100644 --- a/applications/blackhole/src/bh_context.erl +++ b/applications/blackhole/src/bh_context.erl @@ -59,7 +59,7 @@ %% @end %%-------------------------------------------------------------------- -spec new() -> context(). --spec new(pid(), ne_binary()) -> context(). +-spec new(pid(), kz_term:ne_binary()) -> context(). new()-> #bh_context{}. @@ -131,11 +131,11 @@ setters(Context, Setters) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec auth_token(context()) -> api_binary(). +-spec auth_token(context()) -> kz_term:api_binary(). auth_token(#bh_context{auth_token=AuthToken}) -> AuthToken. --spec set_auth_token(context(), ne_binary()) -> context(). +-spec set_auth_token(context(), kz_term:ne_binary()) -> context(). set_auth_token(#bh_context{}=Context, AuthToken) -> Context#bh_context{auth_token=AuthToken}. @@ -144,11 +144,11 @@ set_auth_token(#bh_context{}=Context, AuthToken) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec auth_account_id(context()) -> api_binary(). +-spec auth_account_id(context()) -> kz_term:api_binary(). auth_account_id(#bh_context{auth_account_id=AuthBy}) -> AuthBy. --spec set_auth_account_id(context(), ne_binary()) -> context(). +-spec set_auth_account_id(context(), kz_term:ne_binary()) -> context(). set_auth_account_id(#bh_context{}=Context, AuthBy) -> Context#bh_context{auth_account_id=AuthBy}. @@ -161,11 +161,11 @@ is_superduper_admin(#bh_context{auth_account_id=AccountId}) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec bindings(context()) -> ne_binaries(). +-spec bindings(context()) -> kz_term:ne_binaries(). bindings(#bh_context{bindings=Bds}) -> Bds. --spec bindings_from_json(kz_json:object()) -> ne_binaries(). +-spec bindings_from_json(kz_json:object()) -> kz_term:ne_binaries(). bindings_from_json(JObj) -> case kz_json:get_value(<<"binding">>, JObj) of 'undefined' -> @@ -178,23 +178,23 @@ bindings_from_json(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec set_bindings(context(), ne_binaries()) -> context(). +-spec set_bindings(context(), kz_term:ne_binaries()) -> context(). set_bindings(Context, Bindings) -> Context#bh_context{bindings=Bindings}. --spec add_binding(context(), ne_binary()) -> context(). +-spec add_binding(context(), kz_term:ne_binary()) -> context(). add_binding(#bh_context{bindings=Bds}=Context, Binding) -> Context#bh_context{bindings=[Binding|Bds]}. --spec add_bindings(context(), ne_binaries()) -> context(). +-spec add_bindings(context(), kz_term:ne_binaries()) -> context(). add_bindings(#bh_context{bindings=Bds}=Context, Bindings) -> Context#bh_context{bindings= Bds ++ Bindings}. --spec remove_binding(context(), ne_binary()) -> context(). +-spec remove_binding(context(), kz_term:ne_binary()) -> context(). remove_binding(#bh_context{bindings=Bds}=Context, Binding) -> Context#bh_context{bindings=lists:delete(Binding, Bds)}. --spec remove_bindings(context(), ne_binaries()) -> context(). +-spec remove_bindings(context(), kz_term:ne_binaries()) -> context(). remove_bindings(#bh_context{bindings=Bds}=Context, Bindings) -> Context#bh_context{bindings= Bds -- Bindings}. @@ -203,7 +203,7 @@ remove_bindings(#bh_context{bindings=Bds}=Context, Bindings) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec is_bound(context(), ne_binary()) -> boolean(). +-spec is_bound(context(), kz_term:ne_binary()) -> boolean(). is_bound(#bh_context{bindings=Bds}, Binding) -> lists:member(Binding, Bds). @@ -212,7 +212,7 @@ is_bound(#bh_context{bindings=Bds}, Binding) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec websocket_pid(context()) -> api_binary(). +-spec websocket_pid(context()) -> kz_term:api_binary(). websocket_pid(#bh_context{websocket_pid=SocketPid}) -> SocketPid. -spec set_websocket_pid(context(), pid()) -> context(). @@ -224,11 +224,11 @@ set_websocket_pid(#bh_context{}=Context, SocketPid) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec websocket_session_id(context()) -> api_binary(). +-spec websocket_session_id(context()) -> kz_term:api_binary(). websocket_session_id(#bh_context{websocket_session_id=SessionId}) -> SessionId. --spec set_websocket_session_id(context(), ne_binary()) -> context(). +-spec set_websocket_session_id(context(), kz_term:ne_binary()) -> context(). set_websocket_session_id(#bh_context{}=Context, SessionId) -> Context#bh_context{websocket_session_id=SessionId}. @@ -237,11 +237,11 @@ set_websocket_session_id(#bh_context{}=Context, SessionId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec timestamp(context()) -> gregorian_seconds(). +-spec timestamp(context()) -> kz_time:gregorian_seconds(). timestamp(#bh_context{timestamp=Timestamp}) -> Timestamp. --spec set_timestamp(context(), gregorian_seconds()) -> context(). +-spec set_timestamp(context(), kz_time:gregorian_seconds()) -> context(). set_timestamp(#bh_context{}=Context, Timestamp) -> Context#bh_context{timestamp=Timestamp}. @@ -250,11 +250,11 @@ set_timestamp(#bh_context{}=Context, Timestamp) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec name(context()) -> ne_binary(). +-spec name(context()) -> kz_term:ne_binary(). name(#bh_context{name=Name}) -> Name. --spec set_name(context(), ne_binary()) -> context(). +-spec set_name(context(), kz_term:ne_binary()) -> context(). set_name(#bh_context{}=Context, Name) -> Context#bh_context{name=Name}. @@ -276,11 +276,11 @@ set_metadata(#bh_context{}=Context, Meta) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec source(context()) -> ne_binary(). +-spec source(context()) -> kz_term:ne_binary(). source(#bh_context{source=Source}) -> Source. --spec set_source(context(), ne_binary()) -> context(). +-spec set_source(context(), kz_term:ne_binary()) -> context(). set_source(#bh_context{}=Context, Source) -> Context#bh_context{source=Source}. @@ -289,11 +289,11 @@ set_source(#bh_context{}=Context, Source) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec destination(context()) -> ne_binary(). +-spec destination(context()) -> kz_term:ne_binary(). destination(#bh_context{destination=Destination}) -> Destination. --spec set_destination(context(), ne_binary()) -> context(). +-spec set_destination(context(), kz_term:ne_binary()) -> context(). set_destination(#bh_context{}=Context, Destination) -> Context#bh_context{destination=Destination}. @@ -302,11 +302,11 @@ set_destination(#bh_context{}=Context, Destination) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec req_id(context()) -> ne_binary(). +-spec req_id(context()) -> kz_term:ne_binary(). req_id(#bh_context{req_id=Id}) -> Id. --spec set_req_id(context(), ne_binary()) -> context(). +-spec set_req_id(context(), kz_term:ne_binary()) -> context(). set_req_id(#bh_context{}=Context, ReqId) -> kz_util:put_callid(ReqId), Context#bh_context{req_id=ReqId}. @@ -335,11 +335,11 @@ setters_fold(F, C) when is_function(F, 1) -> F(C). is_authenticated(#bh_context{auth_account_id='undefined'}) -> 'false'; is_authenticated(_) -> 'true'. --spec add_error(context(), text()) -> context(). +-spec add_error(context(), kz_term:text()) -> context(). add_error(Context, Error) -> add_error(Context, 'error', Error). --spec add_error(context(), 'ok' | 'error' | 'shutdown', text()) -> context(). +-spec add_error(context(), 'ok' | 'error' | 'shutdown', kz_term:text()) -> context(). add_error(#bh_context{errors=Errors}=Context, Result, Error) -> Context#bh_context{result=Result, errors=[kz_term:to_binary(Error) | Errors]}. @@ -363,7 +363,7 @@ success(#bh_context{}) -> 'false'. set_resp_data(#bh_context{}=Context, Data) -> Context#bh_context{resp_data=Data}. --spec set_resp_status(context(), ne_binary()) -> context(). +-spec set_resp_status(context(), kz_term:ne_binary()) -> context(). set_resp_status(#bh_context{}=Context, Status) -> Context#bh_context{resp_status=Status}. @@ -371,6 +371,6 @@ set_resp_status(#bh_context{}=Context, Status) -> resp_data(#bh_context{resp_data=Data}) -> Data. --spec resp_status(context()) -> ne_binary(). +-spec resp_status(context()) -> kz_term:ne_binary(). resp_status(#bh_context{resp_status=Status}) -> Status. diff --git a/applications/blackhole/src/bh_events.erl b/applications/blackhole/src/bh_events.erl index 51d5d11ce9a..41996618104 100644 --- a/applications/blackhole/src/bh_events.erl +++ b/applications/blackhole/src/bh_events.erl @@ -50,7 +50,7 @@ validate(Context, Payload) -> Keys -> validate_data(Context, Payload, Keys) end. --spec validate_data(bh_context:context(), kz_json:object(), ne_binaries()) -> bh_context:context(). +-spec validate_data(bh_context:context(), kz_json:object(), kz_term:ne_binaries()) -> bh_context:context(). validate_data(Context, Payload, Keys) -> case ?SUBSCRIBE_KEYS -- Keys of [] -> validate_subscription(Context, Payload); @@ -72,7 +72,7 @@ validate_subscription(Context, Payload) -> Res = blackhole_bindings:map(Event, [Context, Map]), validate_result(Context, Res). --spec validate_result(bh_context:context(), ne_binaries()) -> bh_context:context(). +-spec validate_result(bh_context:context(), kz_term:ne_binaries()) -> bh_context:context(). validate_result(Context, []) -> Context; validate_result(Context, Res) -> case blackhole_bindings:failed(Res) of @@ -115,14 +115,14 @@ unsubscribe(Context, Payload) -> Bindings -> remove_event_bindings(Context, Bindings) end. --spec event(map(), ne_binary(), kz_json:object()) -> 'ok'. +-spec event(map(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. event(Binding, RK, EventJObj) -> kz_util:put_callid(EventJObj), Name = event_name(EventJObj), NormJObj = kz_json:normalize_jobj(EventJObj), blackhole_data_emitter:event(Binding, RK, Name, NormJObj). --spec event_name(kz_json:object()) -> ne_binary(). +-spec event_name(kz_json:object()) -> kz_term:ne_binary(). event_name(JObj) -> kz_json:get_value(<<"Event-Name">>, JObj). diff --git a/applications/blackhole/src/blackhole.hrl b/applications/blackhole/src/blackhole.hrl index a591d82b37b..48b05f6d2a3 100644 --- a/applications/blackhole/src/blackhole.hrl +++ b/applications/blackhole/src/blackhole.hrl @@ -24,23 +24,23 @@ -define(VERSION_SUPPORTED, [<<"v1">>]). --type bh_subscribe_result() :: {'ok', bh_context:context()} | {'error', ne_binary()}. - --record(bh_context, {auth_token = <<>> :: api_binary() | '_' - ,auth_account_id :: api_binary() | '_' - ,bindings = [] :: ne_binaries() | '_' - ,websocket_session_id :: api_binary() | '_' - ,websocket_pid :: api_pid() | '_' - ,req_id = kz_binary:rand_hex(16) :: ne_binary() | '_' - ,timestamp = kz_time:now_s() :: gregorian_seconds() | '_' - ,name :: api_binary() | '_' +-type bh_subscribe_result() :: {'ok', bh_context:context()} | {'error', kz_term:ne_binary()}. + +-record(bh_context, {auth_token = <<>> :: kz_term:api_binary() | '_' + ,auth_account_id :: kz_term:api_binary() | '_' + ,bindings = [] :: kz_term:ne_binaries() | '_' + ,websocket_session_id :: kz_term:api_binary() | '_' + ,websocket_pid :: kz_term:api_pid() | '_' + ,req_id = kz_binary:rand_hex(16) :: kz_term:ne_binary() | '_' + ,timestamp = kz_time:now_s() :: kz_time:gregorian_seconds() | '_' + ,name :: kz_term:api_binary() | '_' ,metadata :: any() | '_' - ,destination = kz_util:node_hostname() :: ne_binary() | '_' - ,source :: api_binary() | '_' - ,errors = [] :: ne_binaries() | '_' + ,destination = kz_util:node_hostname() :: kz_term:ne_binary() | '_' + ,source :: kz_term:api_binary() | '_' + ,errors = [] :: kz_term:ne_binaries() | '_' ,result = 'ok' :: 'ok' | 'error' | 'shutdown' | '_' ,listeners = [] :: list() | '_' - ,resp_status = <<"success">> :: ne_binary() | '_' + ,resp_status = <<"success">> :: kz_term:ne_binary() | '_' ,resp_data = kz_json:new() :: kz_json:object() | '_' }). diff --git a/applications/blackhole/src/blackhole_app.erl b/applications/blackhole/src/blackhole_app.erl index 164a2f26e3d..e3f9022ca1b 100644 --- a/applications/blackhole/src/blackhole_app.erl +++ b/applications/blackhole/src/blackhole_app.erl @@ -17,7 +17,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> blackhole_sup:start_link(). diff --git a/applications/blackhole/src/blackhole_bindings.erl b/applications/blackhole/src/blackhole_bindings.erl index ad61108827b..163b5c7a8e0 100644 --- a/applications/blackhole/src/blackhole_bindings.erl +++ b/applications/blackhole/src/blackhole_bindings.erl @@ -44,7 +44,7 @@ -include("blackhole.hrl"). --type payload_el() :: bh_context:context() | ne_binary() | map() | kz_json:object(). +-type payload_el() :: bh_context:context() | kz_term:ne_binary() | map() | kz_json:object(). -type payload() :: [payload_el()] | payload_el(). %%%=================================================================== @@ -69,7 +69,7 @@ %% @end %%-------------------------------------------------------------------- -type fold_results() :: payload(). --spec fold(ne_binary(), payload()) -> fold_results(). +-spec fold(kz_term:ne_binary(), payload()) -> fold_results(). fold(Routing, Payload) -> kazoo_bindings:fold(Routing, Payload). @@ -78,11 +78,11 @@ fold(Routing, Payload) -> %% Helper functions for working on a result set of bindings %% @end %%------------------------------------------------------------------- --spec any(kz_proplist()) -> boolean(). +-spec any(kz_term:proplist()) -> boolean(). any(Res) when is_list(Res) -> kazoo_bindings:any(Res, fun check_bool/1). --spec all(kz_proplist()) -> boolean(). +-spec all(kz_term:proplist()) -> boolean(). all(Res) when is_list(Res) -> kazoo_bindings:all(Res, fun check_bool/1). @@ -145,23 +145,23 @@ filter_out_succeeded(Term) -> kz_term:is_empty(Term). -type bind_result() :: 'ok' | {'error', 'exists'}. -type bind_results() :: [bind_result()]. --spec bind(ne_binary() | ne_binaries(), atom(), atom()) -> +-spec bind(kz_term:ne_binary() | kz_term:ne_binaries(), atom(), atom()) -> bind_result() | bind_results(). bind(Bindings, Module, Fun) -> bind(Bindings, Module, Fun, 'undefined'). --spec bind(ne_binary() | ne_binaries(), atom(), atom(), any()) -> +-spec bind(kz_term:ne_binary() | kz_term:ne_binaries(), atom(), atom(), any()) -> bind_result() | bind_results(). bind([_|_]=Bindings, Module, Fun, Payload) -> [bind(Binding, Module, Fun, Payload) || Binding <- Bindings]; bind(Binding, Module, Fun, Payload) when is_binary(Binding) -> kazoo_bindings:bind(Binding, Module, Fun, Payload). --spec unbind(ne_binary() | ne_binaries(), atom(), atom()) -> 'ok'. +-spec unbind(kz_term:ne_binary() | kz_term:ne_binaries(), atom(), atom()) -> 'ok'. unbind(Bindings, Module, Fun) -> unbind(Bindings, Module, Fun, 'undefined'). --spec unbind(ne_binary() | ne_binaries(), atom(), atom(), any()) -> 'ok'. +-spec unbind(kz_term:ne_binary() | kz_term:ne_binaries(), atom(), atom(), any()) -> 'ok'. unbind([_|_]=Bindings, Module, Fun, Payload) -> _ = [unbind(Binding, Module, Fun, Payload) || Binding <- Bindings], 'ok'; @@ -177,23 +177,23 @@ filter(Predicate) -> flush() -> lists:foreach(fun kazoo_bindings:flush_mod/1, modules_loaded()). --spec flush(ne_binary()) -> 'ok'. +-spec flush(kz_term:ne_binary()) -> 'ok'. flush(Binding) -> kazoo_bindings:flush(Binding). --spec flush_mod(ne_binary() | atom()) -> 'ok'. +-spec flush_mod(kz_term:ne_binary() | atom()) -> 'ok'. flush_mod(BHMod) when is_binary(BHMod) -> flush_mod(kz_term:to_atom(BHMod, 'true')); flush_mod(BHMod) -> kazoo_bindings:flush_mod(BHMod). --spec modules_loaded() -> atoms(). +-spec modules_loaded() -> kz_term:atoms(). modules_loaded() -> lists:usort( [Mod || Mod <- kazoo_bindings:modules_loaded(), is_bh_module(Mod) ]). --spec is_bh_module(ne_binary() | atom()) -> boolean(). +-spec is_bh_module(kz_term:ne_binary() | atom()) -> boolean(). is_bh_module(<<"bh_", _/binary>>) -> 'true'; is_bh_module(<<"blackhole_", _/binary>>) -> 'true'; is_bh_module(<<_/binary>>) -> 'false'; @@ -206,14 +206,14 @@ init() -> Mods = lists:usort(blackhole_config:autoload_modules() ++ ?COMMAND_MODULES), lists:foreach(fun init_mod/1, Mods). --spec init_mod(ne_binary() | atom()) -> +-spec init_mod(kz_term:ne_binary() | atom()) -> 'ok' | {'error', 'undefined' | 'unknown'}. init_mod(ModuleName) -> lager:debug("initializing module: ~p", [ModuleName]), maybe_init_mod(ModuleName). --spec maybe_init_mod(ne_binary() | atom()) -> +-spec maybe_init_mod(kz_term:ne_binary() | atom()) -> 'ok' | {'error', 'undefined' | 'unknown'}. maybe_init_mod(ModuleName) -> @@ -233,7 +233,7 @@ maybe_init_mod(ModuleName) -> bindings() -> bindings(<<"blackhole.#">>). --spec bindings(ne_binary()) -> kazoo_bindings:kz_bindings(). +-spec bindings(kz_term:ne_binary()) -> kazoo_bindings:kz_bindings(). bindings(Routing) -> RTOptions = [{'matches', fun bh_match/2}], kazoo_bindings:bindings(Routing, RTOptions). @@ -251,7 +251,7 @@ bindings(Routing) -> %% this is a copy from kazoo_bindings with extra %% check for bh_matches([_ | Bs], [<<"*">>|Rs]) -> %%-------------------------------------------------------------------- --spec bh_matches(ne_binaries(), ne_binaries()) -> boolean(). +-spec bh_matches(kz_term:ne_binaries(), kz_term:ne_binaries()) -> boolean(). %% if both are empty, we made it! bh_matches([], []) -> 'true'; @@ -303,12 +303,12 @@ bh_matches([B | Bs], [B | Rs]) -> bh_matches(_, _) -> 'false'. --spec map(ne_binary(), payload()) -> map_results(). +-spec map(kz_term:ne_binary(), payload()) -> map_results(). map(Routing, Payload) -> RTOptions = [{'matches', fun bh_match/2}], kazoo_bindings:map(Routing, Payload, RTOptions). --spec map(ne_binary(), payload(), kz_bindings()) -> map_results(). +-spec map(kz_term:ne_binary(), payload(), kz_bindings()) -> map_results(). map(Routing, Payload, Bindings) -> RTOptions = [{'matches', fun bh_match/2} ,{'candidates', fun(_) -> Bindings end} diff --git a/applications/blackhole/src/blackhole_config.erl b/applications/blackhole/src/blackhole_config.erl index 3af29bc3343..e5aaa3b07fb 100644 --- a/applications/blackhole/src/blackhole_config.erl +++ b/applications/blackhole/src/blackhole_config.erl @@ -18,18 +18,18 @@ -spec flush() -> 'ok'. flush() -> kapps_config:flush(?CONFIG_CAT). --spec autoload_modules() -> ne_binaries(). +-spec autoload_modules() -> kz_term:ne_binaries(). autoload_modules() -> kapps_config:get(?CONFIG_CAT, <<"autoload_modules">>, ?DEFAULT_MODULES ++ ?COMMAND_MODULES). --spec set_autoload_modules(ne_binaries() | atoms()) -> +-spec set_autoload_modules(kz_term:ne_binaries() | kz_term:atoms()) -> {'ok', kz_json:object()} | 'ok' | {'error', any()}. set_autoload_modules(Modules) -> kapps_config:set(?CONFIG_CAT, <<"autoload_modules">>, Modules). --spec set_default_autoload_modules(ne_binaries() | atoms()) -> +-spec set_default_autoload_modules(kz_term:ne_binaries() | kz_term:atoms()) -> {'ok', kz_json:object()} | 'ok' | {'error', any()}. diff --git a/applications/blackhole/src/blackhole_data_emitter.erl b/applications/blackhole/src/blackhole_data_emitter.erl index cb808d8b5b2..a0806c65688 100644 --- a/applications/blackhole/src/blackhole_data_emitter.erl +++ b/applications/blackhole/src/blackhole_data_emitter.erl @@ -13,7 +13,7 @@ -export([event/4]). -export([reply/4]). --spec event(map(), ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec event(map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. event(Binding, RK, Name, Data) -> #{subscribed_key := SubscribedKey ,subscription_key := SubscriptionKey @@ -29,7 +29,7 @@ event(Binding, RK, Name, Data) -> SessionPid ! {'send_data', kz_json:from_list(Msg)}, 'ok'. --spec reply(pid(), ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec reply(pid(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. reply(SessionPid, RequestId, Status, Data) -> lager:debug("sending reply data: ~s : ~s : ~p", [RequestId, Status, Data]), Msg = [{<<"action">>, <<"reply">>} diff --git a/applications/blackhole/src/blackhole_init.erl b/applications/blackhole/src/blackhole_init.erl index 50dd60dac71..8015a9de95f 100644 --- a/applications/blackhole/src/blackhole_init.erl +++ b/applications/blackhole/src/blackhole_init.erl @@ -31,7 +31,7 @@ api_path() -> %% @public %% @doc Starts the app for inclusion in a supervisor tree %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> kz_util:put_callid(?DEFAULT_LOG_SYSTEM_ID), @@ -48,7 +48,7 @@ start_link() -> -spec on_request(cowboy_req:req()) -> cowboy_req:req(). on_request(Req) -> Req. --spec on_response(cowboy:http_status(), cowboy:http_headers(), text(), cowboy_req:req()) -> +-spec on_response(cowboy:http_status(), cowboy:http_headers(), kz_term:text(), cowboy_req:req()) -> cowboy_req:req(). on_response(_Status, _Headers, _Body, Req) -> Req. @@ -183,7 +183,7 @@ start_ssl(Dispatch) -> lager:warning("failed to start SSL WEBSOCKET server: ~p", [_E]) end. --spec ssl_opts(list()) -> kz_proplist(). +-spec ssl_opts(list()) -> kz_term:proplist(). ssl_opts(RootDir) -> BaseOpts = base_ssl_opts(RootDir), case kapps_config:get_string(?CONFIG_CAT, <<"ssl_ca_cert">>) of @@ -191,7 +191,7 @@ ssl_opts(RootDir) -> SSLCACert -> [{'cacertfile', SSLCACert} | BaseOpts] end. --spec base_ssl_opts(list()) -> kz_proplist(). +-spec base_ssl_opts(list()) -> kz_term:proplist(). base_ssl_opts(RootDir) -> [{'port', kapps_config:get_integer(?CONFIG_CAT, <<"ssl_port">>, 5556)} ,{'certfile', find_file(kapps_config:get_string(?CONFIG_CAT diff --git a/applications/blackhole/src/blackhole_listener.erl b/applications/blackhole/src/blackhole_listener.erl index 0c7d0fd6f2d..e1b9c7d371b 100644 --- a/applications/blackhole/src/blackhole_listener.erl +++ b/applications/blackhole/src/blackhole_listener.erl @@ -53,7 +53,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link({'local', ?SERVER} ,?MODULE @@ -66,7 +66,7 @@ start_link() -> ,[] ). --spec handle_amqp_event(kz_json:object(), kz_proplist(), gen_listener:basic_deliver() | ne_binary()) -> 'ok'. +-spec handle_amqp_event(kz_json:object(), kz_term:proplist(), gen_listener:basic_deliver() | kz_term:ne_binary()) -> 'ok'. handle_amqp_event(EventJObj, _Props, ?MODULE_REQ_ROUTING_KEY) -> handle_module_req(EventJObj); handle_amqp_event(EventJObj, _Props, <<_/binary>> = RoutingKey) -> @@ -81,7 +81,7 @@ handle_amqp_event(EventJObj, Props, BasicDeliver) -> handle_amqp_event(EventJObj, Props, gen_listener:routing_key_used(BasicDeliver)). -spec handle_module_req(kz_json:object()) -> 'ok'. --spec handle_module_req(kz_json:object(), atom(), ne_binary(), boolean()) -> 'ok'. +-spec handle_module_req(kz_json:object(), atom(), kz_term:ne_binary(), boolean()) -> 'ok'. handle_module_req(EventJObj) -> 'true' = kapi_websockets:module_req_v(EventJObj), lager:debug("recv module_req: ~p", [EventJObj]), @@ -128,7 +128,7 @@ maybe_persist(BHModule, 'true', 'ok') -> persist_module(BHModule, Mods) end. --spec persist_module(atom(), ne_binaries()) -> boolean(). +-spec persist_module(atom(), kz_term:ne_binaries()) -> boolean(). persist_module(Module, Mods) -> case blackhole_config:set_default_autoload_modules( [kz_term:to_binary(Module) @@ -152,12 +152,12 @@ send_module_resp(EventJObj, Started, Persisted) -> ServerId = kz_api:server_id(EventJObj), kapi_websockets:publish_module_resp(ServerId, Resp). --spec maybe_start_error(mod_inited()) -> api_ne_binary(). +-spec maybe_start_error(mod_inited()) -> kz_term:api_ne_binary(). maybe_start_error('ok') -> 'undefined'; maybe_start_error('stopped') -> 'undefined'; maybe_start_error({'error', E}) -> kz_term:to_binary(E). --spec send_error_module_resp(kz_json:object(), ne_binary()) -> 'ok'. +-spec send_error_module_resp(kz_json:object(), kz_term:ne_binary()) -> 'ok'. send_error_module_resp(EventJObj, Error) -> Resp = [{<<"Persisted">>, 'false'} ,{<<"Started">>, 'false'} @@ -168,8 +168,8 @@ send_error_module_resp(EventJObj, Error) -> ServerId = kz_api:server_id(EventJObj), kapi_websockets:publish_module_resp(ServerId, Resp). --type bh_amqp_binding() :: {'amqp', atom(), kz_proplist()}. --type bh_hook_binding() :: {'hook', ne_binary()} | {'hook', ne_binary(), ne_binary()}. +-type bh_amqp_binding() :: {'amqp', atom(), kz_term:proplist()}. +-type bh_hook_binding() :: {'hook', kz_term:ne_binary()} | {'hook', kz_term:ne_binary(), kz_term:ne_binary()}. -type bh_event_binding() :: bh_amqp_binding() | bh_hook_binding(). -type bh_event_bindings() :: [bh_event_binding()]. @@ -222,7 +222,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -236,7 +236,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'add_bh_bindings', Bindings}, #state{bindings=ETS}=State) -> _ = add_bh_bindings(ETS, Bindings), {'noreply', State}; @@ -269,7 +269,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(?HOOK_EVT(ne_binary(), ne_binary(), kz_json:object()), state()) -> +-spec handle_info(?HOOK_EVT(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()), state()) -> {'noreply', state()}. handle_info(?HOOK_EVT(AccountId, EventType, JObj), State) -> _ = kz_util:spawn(fun handle_hook_event/3, [AccountId, EventType, JObj]), @@ -285,7 +285,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. @@ -319,11 +319,11 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec encode_call_id(kz_json:object()) -> ne_binary(). +-spec encode_call_id(kz_json:object()) -> kz_term:ne_binary(). encode_call_id(JObj) -> amqp_util:encode(kz_call_event:call_id(JObj)). --spec handle_hook_event(ne_binary(), ne_binary(), kz_json:object()) -> any(). +-spec handle_hook_event(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> any(). handle_hook_event(AccountId, EventType, JObj) -> RK = kz_binary:join([<<"call">> ,AccountId diff --git a/applications/blackhole/src/blackhole_maintenance.erl b/applications/blackhole/src/blackhole_maintenance.erl index 2671c74e600..a45ee12bfa5 100644 --- a/applications/blackhole/src/blackhole_maintenance.erl +++ b/applications/blackhole/src/blackhole_maintenance.erl @@ -21,8 +21,8 @@ %% %% @end %%-------------------------------------------------------------------- --spec start_module(text()) -> 'ok'. --spec start_module(text(), text() | boolean()) -> 'ok'. +-spec start_module(kz_term:text()) -> 'ok'. +-spec start_module(kz_term:text(), kz_term:text() | boolean()) -> 'ok'. start_module(ModuleBin) -> start_module(ModuleBin, 'true'). start_module(ModuleBin, Persist) -> @@ -52,8 +52,8 @@ start_module(ModuleBin, Persist) -> %% %% @end %%-------------------------------------------------------------------- --spec stop_module(text()) -> 'ok'. --spec stop_module(text(), text() | boolean()) -> 'ok'. +-spec stop_module(kz_term:text()) -> 'ok'. +-spec stop_module(kz_term:text(), kz_term:text() | boolean()) -> 'ok'. stop_module(ModuleBin) -> stop_module(ModuleBin, 'true'). stop_module(ModuleBin, Persist) -> @@ -83,7 +83,7 @@ stop_module(ModuleBin, Persist) -> %% %% @end %%-------------------------------------------------------------------- --spec running_modules() -> atoms(). +-spec running_modules() -> kz_term:atoms(). running_modules() -> blackhole_bindings:modules_loaded(). -spec print_module_resp(kz_json:object()) -> 'ok'. diff --git a/applications/blackhole/src/blackhole_socket_handler.erl b/applications/blackhole/src/blackhole_socket_handler.erl index cc2b35b2f58..279e7790829 100644 --- a/applications/blackhole/src/blackhole_socket_handler.erl +++ b/applications/blackhole/src/blackhole_socket_handler.erl @@ -19,7 +19,7 @@ -include("blackhole.hrl"). -spec init(cowboy_req:req(), State) -> - {'ok' | 'cowboy_websocket', cowboy_req:req(), State | {inet:ip_address(), ne_binary()}}. + {'ok' | 'cowboy_websocket', cowboy_req:req(), State | {inet:ip_address(), kz_term:ne_binary()}}. init(Req, HandlerOpts) -> lager:info("handling socket init"), case cowboy_req:parse_header(<<"sec-websocket-protocol">>, Req) of @@ -36,7 +36,7 @@ init(Req, HandlerOpts) -> terminate(_Reason, _Req, _State) -> lager:info("bh socket going down: ~p", [_Reason]). --spec websocket_init({inet:ip_address(), ne_binary()}) -> {'ok', bh_context:context()}. +-spec websocket_init({inet:ip_address(), kz_term:ne_binary()}) -> {'ok', bh_context:context()}. websocket_init({RemoteIP, SessionsId}) -> lager:info("init from ~p(~p)", [RemoteIP, SessionsId]), {'ok', _State} = blackhole_socket_callback:open(self(), SessionsId, RemoteIP). diff --git a/applications/blackhole/src/blackhole_sup.erl b/applications/blackhole/src/blackhole_sup.erl index 366132deddc..9b6fbebc1a8 100644 --- a/applications/blackhole/src/blackhole_sup.erl +++ b/applications/blackhole/src/blackhole_sup.erl @@ -34,7 +34,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -51,7 +51,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/blackhole/src/blackhole_tracking.erl b/applications/blackhole/src/blackhole_tracking.erl index a01d62cd924..0a0ff1cb783 100644 --- a/applications/blackhole/src/blackhole_tracking.erl +++ b/applications/blackhole/src/blackhole_tracking.erl @@ -47,7 +47,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link({'local', ?SERVER} ,?MODULE @@ -65,7 +65,7 @@ start_link() -> %% @doc %% @end %%-------------------------------------------------------------------- --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(ApiJObj, _Props) -> 'true' = kapi_websockets:get_req_v(ApiJObj), kz_util:put_callid(ApiJObj), @@ -120,7 +120,7 @@ update_socket(Context) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_sockets(ne_binary()) -> [bh_context:context(), ...] | {'error', 'not_found'}. +-spec get_sockets(kz_term:ne_binary()) -> [bh_context:context(), ...] | {'error', 'not_found'}. get_sockets(AccountId) -> gen_server:call(?SERVER, {'get_sockets', AccountId}). @@ -129,7 +129,7 @@ get_sockets(AccountId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_socket(ne_binary()) -> {'ok', bh_context:context()} | {'error', 'not_found'}. +-spec get_socket(kz_term:ne_binary()) -> {'ok', bh_context:context()} | {'error', 'not_found'}. get_socket(Id) -> gen_server:call(?SERVER, {'get_socket', Id}). @@ -176,7 +176,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call({'get_sockets', AccountId}, _From, State) -> Pattern = #bh_context{auth_account_id=AccountId, _='_'}, Result = @@ -207,7 +207,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'add_socket', Context}, State) -> _ = ets:insert(State, Context), {noreply, State}; @@ -230,7 +230,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -242,7 +242,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. @@ -285,7 +285,7 @@ code_change(_OldVsn, State, _Extra) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec handle_get_req_data(api_binary(), api_binary(), api_binary()) -> any(). +-spec handle_get_req_data(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary()) -> any(). handle_get_req_data('undefined', 'undefined', Node) -> lager:warning("received undefined blackhole get req ~s", [Node]); handle_get_req_data(AccountId, 'undefined', Node) -> diff --git a/applications/blackhole/src/modules/bh_conference.erl b/applications/blackhole/src/modules/bh_conference.erl index 64968b060e3..35564c9def7 100644 --- a/applications/blackhole/src/modules/bh_conference.erl +++ b/applications/blackhole/src/modules/bh_conference.erl @@ -66,13 +66,13 @@ bindings(_Context, #{account_id := AccountId %%% Internal functions %%%================================================================== --spec command_binding_options(ne_binary()) -> kz_proplist(). +-spec command_binding_options(kz_term:ne_binary()) -> kz_term:proplist(). command_binding_options(ConfId) -> [{'restrict_to', [{'command', ConfId}]} ,'federate' ]. --spec event_binding_options(ne_binary(), ne_binary(), ne_binary()) -> kz_proplist(). +-spec event_binding_options(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:proplist(). event_binding_options(AccountId, ConferenceId, CallId) -> [{'restrict_to', [{'event', [{'account_id', AccountId} ,{'conference_id', ConferenceId} diff --git a/applications/blackhole/src/modules/bh_fax.erl b/applications/blackhole/src/modules/bh_fax.erl index 513cc0aafaf..360ec7b7cb2 100644 --- a/applications/blackhole/src/modules/bh_fax.erl +++ b/applications/blackhole/src/modules/bh_fax.erl @@ -55,8 +55,8 @@ bindings(_Context, #{account_id := AccountId ,listeners => Listeners }. --spec fax_status_bind_options(ne_binary(), ne_binary()) -> - kz_proplist(). +-spec fax_status_bind_options(kz_term:ne_binary(), kz_term:ne_binary()) -> + kz_term:proplist(). fax_status_bind_options(AccountId, FaxId) -> [{'restrict_to', ['status']} ,{'account_id', AccountId} @@ -64,8 +64,8 @@ fax_status_bind_options(AccountId, FaxId) -> ,'federate' ]. --spec fax_object_bind_options(ne_binary(), ne_binary()) -> - kz_proplist(). +-spec fax_object_bind_options(kz_term:ne_binary(), kz_term:ne_binary()) -> + kz_term:proplist(). fax_object_bind_options(MODB, Action) -> [{'keys', [[{'action', Action} ,{'db', MODB} diff --git a/applications/blackhole/src/modules/bh_object.erl b/applications/blackhole/src/modules/bh_object.erl index 62eb090beb9..24cde3c7194 100644 --- a/applications/blackhole/src/modules/bh_object.erl +++ b/applications/blackhole/src/modules/bh_object.erl @@ -84,7 +84,7 @@ listeners(Type, Action, AccountDb, AccountMODB) -> 'false' -> [{'amqp', 'conf', bind_options(Action, Type, AccountDb)}] end. --spec bind_options(ne_binary(), ne_binary(), ne_binary()) -> kz_proplist(). +-spec bind_options(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:proplist(). bind_options(Action, Type, Db) -> [{'action', Action} ,{'db', Db} diff --git a/applications/blackhole/src/modules/bh_skel.erl b/applications/blackhole/src/modules/bh_skel.erl index f0b4b8e6cd4..fc1676f9389 100644 --- a/applications/blackhole/src/modules/bh_skel.erl +++ b/applications/blackhole/src/modules/bh_skel.erl @@ -41,7 +41,7 @@ bindings(_Context, #{account_id := AccountId ,listeners => Listeners }. --spec skel_bind_options(ne_binary(), ne_binary()) -> kz_proplist(). +-spec skel_bind_options(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:proplist(). skel_bind_options(AccountId, MyId) -> [{'restrict_to', ['skel.updates']} ,{'account_id', AccountId} diff --git a/applications/call_inspector/src/analyzers/ci_analysis.erl b/applications/call_inspector/src/analyzers/ci_analysis.erl index aa23a17244e..6f5e194d3ce 100644 --- a/applications/call_inspector/src/analyzers/ci_analysis.erl +++ b/applications/call_inspector/src/analyzers/ci_analysis.erl @@ -32,48 +32,48 @@ -spec new() -> analysis(). new() -> #ci_analysis{}. --spec set_call_id(analysis(), ne_binary()) -> analysis(). +-spec set_call_id(analysis(), kz_term:ne_binary()) -> analysis(). set_call_id(Analysis, CallId) -> Analysis#ci_analysis{call_id=CallId}. --spec call_id(analysis()) -> api_binary(). +-spec call_id(analysis()) -> kz_term:api_binary(). call_id(#ci_analysis{call_id=CallId}) -> CallId. --spec set_originate_type(analysis(), ne_binary()) -> analysis(). +-spec set_originate_type(analysis(), kz_term:ne_binary()) -> analysis(). set_originate_type(Analysis, <<"phone">> = Type) -> Analysis#ci_analysis{originate_type=Type}; set_originate_type(Analysis, <<"carrier">> = Type) -> Analysis#ci_analysis{originate_type=Type}. --spec originate_type(analysis()) -> api_binary(). +-spec originate_type(analysis()) -> kz_term:api_binary(). originate_type(#ci_analysis{originate_type=Type}) -> Type. --spec set_terminate_type(analysis(), ne_binary()) -> analysis(). +-spec set_terminate_type(analysis(), kz_term:ne_binary()) -> analysis(). set_terminate_type(Analysis, <<"phone">> = Type) -> Analysis#ci_analysis{terminate_type=Type}; set_terminate_type(Analysis, <<"carrier">> = Type) -> Analysis#ci_analysis{terminate_type=Type}. --spec terminate_type(analysis()) -> api_binary(). +-spec terminate_type(analysis()) -> kz_term:api_binary(). terminate_type(#ci_analysis{terminate_type=Type}) -> Type. --spec set_failure_location(analysis(), ne_binary()) -> analysis(). +-spec set_failure_location(analysis(), kz_term:ne_binary()) -> analysis(). set_failure_location(Analysis, <<"origination">> = Location) -> Analysis#ci_analysis{failure_location=Location}; set_failure_location(Analysis, <<"termination">> = Location) -> Analysis#ci_analysis{failure_location=Location}. --spec failure_location(analysis()) -> api_binary(). +-spec failure_location(analysis()) -> kz_term:api_binary(). failure_location(#ci_analysis{failure_location=Location}) -> Location. --spec set_reason(analysis(), ne_binary()) -> analysis(). +-spec set_reason(analysis(), kz_term:ne_binary()) -> analysis(). set_reason(Analysis, Reason) -> Analysis#ci_analysis{reason=Reason}. --spec reason(analysis()) -> api_binary(). +-spec reason(analysis()) -> kz_term:api_binary(). reason(#ci_analysis{reason=Reason}) -> Reason. diff --git a/applications/call_inspector/src/analyzers/ci_analyzers.erl b/applications/call_inspector/src/analyzers/ci_analyzers.erl index f734049c52d..283f622bddd 100644 --- a/applications/call_inspector/src/analyzers/ci_analyzers.erl +++ b/applications/call_inspector/src/analyzers/ci_analyzers.erl @@ -12,6 +12,6 @@ -include("call_inspector.hrl"). --spec new_chunk(ne_binary(), ci_chunk:chunk()) -> 'ok'. +-spec new_chunk(kz_term:ne_binary(), ci_chunk:chunk()) -> 'ok'. new_chunk(_CallId, _Chunk) -> 'ok'. diff --git a/applications/call_inspector/src/analyzers/ci_analyzers_sup.erl b/applications/call_inspector/src/analyzers/ci_analyzers_sup.erl index 7dfae1a1776..b27afc440b1 100644 --- a/applications/call_inspector/src/analyzers/ci_analyzers_sup.erl +++ b/applications/call_inspector/src/analyzers/ci_analyzers_sup.erl @@ -27,7 +27,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -44,7 +44,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, diff --git a/applications/call_inspector/src/call_inspector_app.erl b/applications/call_inspector/src/call_inspector_app.erl index 504e8e3cc29..c6476b68df4 100644 --- a/applications/call_inspector/src/call_inspector_app.erl +++ b/applications/call_inspector/src/call_inspector_app.erl @@ -17,7 +17,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = declare_exchanges(), call_inspector_sup:start_link(). diff --git a/applications/call_inspector/src/call_inspector_maintenance.erl b/applications/call_inspector/src/call_inspector_maintenance.erl index 65f33105a2e..feb88f2c91a 100644 --- a/applications/call_inspector/src/call_inspector_maintenance.erl +++ b/applications/call_inspector/src/call_inspector_maintenance.erl @@ -31,7 +31,7 @@ list_active_parsers() -> lists:foreach(fun (Id) -> io:format("~p\n", [Id]) end, Ids), 'no_return'. --spec stop_active_parser(text()) -> 'ok'. +-spec stop_active_parser(kz_term:text()) -> 'ok'. stop_active_parser(Id) when not is_atom(Id) -> stop_active_parser( @@ -43,7 +43,7 @@ stop_active_parser(Id) when is_atom(Id) -> ci_parsers_sup:stop_child(Id). --spec start_freeswitch_parser(text(), text(), text()) -> 'no_return'. +-spec start_freeswitch_parser(kz_term:text(), kz_term:text(), kz_term:text()) -> 'no_return'. start_freeswitch_parser(Filename, LogIP, LogPort) -> Args = [{'parser_args', Filename, kz_term:to_binary(LogIP), kz_term:to_integer(LogPort)}], case ci_parsers_sup:start_child('ci_parser_freeswitch', Args) of @@ -55,7 +55,7 @@ start_freeswitch_parser(Filename, LogIP, LogPort) -> 'no_return' end. --spec start_kamailio_parser(text(), text(), text()) -> 'no_return'. +-spec start_kamailio_parser(kz_term:text(), kz_term:text(), kz_term:text()) -> 'no_return'. start_kamailio_parser(Filename, LogIP, LogPort) -> Args = [{'parser_args', Filename, kz_term:to_binary(LogIP), kz_term:to_integer(LogPort)}], case ci_parsers_sup:start_child('ci_parser_kamailio', Args) of @@ -67,7 +67,7 @@ start_kamailio_parser(Filename, LogIP, LogPort) -> 'no_return' end. --spec start_hep_parser(text(), text()) -> 'no_return'. +-spec start_hep_parser(kz_term:text(), kz_term:text()) -> 'no_return'. start_hep_parser(IP, Port) -> Args = [{'parser_args', kz_term:to_binary(IP), kz_term:to_integer(Port)}], case ci_parsers_sup:start_child('ci_parser_hep', Args) of @@ -82,10 +82,10 @@ start_hep_parser(IP, Port) -> -spec flush() -> 'ok'. flush() -> ci_datastore:flush(). --spec flush(text()) -> 'ok'. +-spec flush(kz_term:text()) -> 'ok'. flush(CallId) -> ci_datastore:flush(CallId). --spec callid_details(text()) -> 'no_return'. +-spec callid_details(kz_term:text()) -> 'no_return'. callid_details(CallId) -> Props = [{<<"Call-ID">>, kz_term:to_binary(CallId)} | kz_api:default_headers(?APP_NAME, ?APP_VERSION) @@ -106,7 +106,7 @@ callid_details(CallId) -> end, no_return. --spec inspect_call_id(ne_binary()) -> no_return. +-spec inspect_call_id(kz_term:ne_binary()) -> no_return. inspect_call_id(CallId) -> Req = [{<<"Call-ID">>, CallId} | kz_api:default_headers(?APP_NAME, ?APP_VERSION) diff --git a/applications/call_inspector/src/call_inspector_sup.erl b/applications/call_inspector/src/call_inspector_sup.erl index f45c0bf6425..4f361e10a29 100644 --- a/applications/call_inspector/src/call_inspector_sup.erl +++ b/applications/call_inspector/src/call_inspector_sup.erl @@ -31,7 +31,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -48,7 +48,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/call_inspector/src/ci_datastore.erl b/applications/call_inspector/src/ci_datastore.erl index 03e0878d38d..54f8ab3d90e 100644 --- a/applications/call_inspector/src/ci_datastore.erl +++ b/applications/call_inspector/src/ci_datastore.erl @@ -37,8 +37,8 @@ -record(state, {}). -type state() :: #state{}. --record(object, {call_id :: ne_binary() - ,timestamp = kz_time:now_s() :: gregorian_seconds() +-record(object, {call_id :: kz_term:ne_binary() + ,timestamp = kz_time:now_s() :: kz_time:gregorian_seconds() ,type :: chunk | analysis ,value :: ci_chunk:chunk() | ci_analysis:analysis() }). @@ -59,7 +59,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_server:start_link({'local', ?SERVER}, ?MODULE, [], []). @@ -75,7 +75,7 @@ store_analysis(Analysis) -> CallId = ci_analysis:call_id(Analysis), gen_server:cast(?SERVER, {'store_analysis', CallId, Analysis}). --spec callid_exists(ne_binary()) -> boolean(). +-spec callid_exists(kz_term:ne_binary()) -> boolean(). callid_exists(CallId) -> File = make_name(CallId), Exists = filelib:is_file(File), @@ -83,7 +83,7 @@ callid_exists(CallId) -> orelse lager:debug("~s not stored here", [CallId]), Exists. --spec lookup_callid(ne_binary()) -> data(). +-spec lookup_callid(kz_term:ne_binary()) -> data(). lookup_callid(CallId) -> Props = lists:foldl(fun lookup_callid_fold/2 ,[{'chunks', []} @@ -105,7 +105,7 @@ lookup_callid_fold(#object{type='analysis', value=Analysis}, P) -> flush() -> gen_server:cast(?SERVER, 'flush'). --spec flush(ne_binary()) -> 'ok'. +-spec flush(kz_term:ne_binary()) -> 'ok'. flush(CallId) -> gen_server:cast(?SERVER, {'flush', CallId}). @@ -137,7 +137,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(atom(), any(), state()) -> handle_call_ret(). +-spec handle_call(atom(), any(), state()) -> kz_types:handle_call_ret(). handle_call(_Request, _From, State) -> lager:debug("unhandled handle_call executed ~p~p", [_Request, _From]), Reply = 'ok', @@ -153,7 +153,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'store_chunk', CallId, Chunk}, State) -> Object = #object{call_id=CallId ,type='chunk' @@ -189,7 +189,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> lager:debug("unhandled message: ~p", [_Info]), {'noreply', State}. @@ -226,7 +226,7 @@ code_change(_OldVsn, State, _Extra) -> %%% Internal functions %%%=================================================================== --spec make_name(ne_binary()) -> file:filename(). +-spec make_name(kz_term:ne_binary()) -> file:filename(). make_name(CallId) -> <> = kz_binary:md5(CallId), filename:join([?CI_DIR, D1, D2, Rest]). @@ -243,7 +243,7 @@ insert_object(#object{call_id = CallId} = Object) -> IoData = io_lib:fwrite("~p.\n", [Object]), kz_util:write_file(Path, IoData, ['append']). --spec lookup_objects(ne_binary()) -> [object()]. +-spec lookup_objects(kz_term:ne_binary()) -> [object()]. lookup_objects(CallId) -> Path = make_name(CallId), case filelib:is_file(Path) of diff --git a/applications/call_inspector/src/ci_filter_req.erl b/applications/call_inspector/src/ci_filter_req.erl index 78fa450232b..d561206de6d 100644 --- a/applications/call_inspector/src/ci_filter_req.erl +++ b/applications/call_inspector/src/ci_filter_req.erl @@ -12,7 +12,7 @@ -include("call_inspector.hrl"). --spec handle_req(kz_json:object(), kz_proplist()) -> ok. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> ok. handle_req(JObj, _Props) -> true = kapi_inspector:filter_req_v(JObj), CallIds = [CallId diff --git a/applications/call_inspector/src/ci_listener.erl b/applications/call_inspector/src/ci_listener.erl index 3d7b311acfa..709853deca2 100644 --- a/applications/call_inspector/src/ci_listener.erl +++ b/applications/call_inspector/src/ci_listener.erl @@ -44,7 +44,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER ,[{'bindings', ?BINDINGS} @@ -86,7 +86,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -100,7 +100,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _QueueNAme}}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'is_consuming', _IsConsuming}}, State) -> @@ -118,7 +118,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -130,7 +130,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/call_inspector/src/ci_lookup_req.erl b/applications/call_inspector/src/ci_lookup_req.erl index d0d0fe95229..88a3d1b0366 100644 --- a/applications/call_inspector/src/ci_lookup_req.erl +++ b/applications/call_inspector/src/ci_lookup_req.erl @@ -12,7 +12,7 @@ -include("call_inspector.hrl"). --spec handle_req(kz_json:object(), kz_proplist()) -> ok. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> ok. handle_req(JObj, _) -> true = kapi_inspector:lookup_req_v(JObj), Props = ci_datastore:lookup_callid(kz_json:get_value(<<"Call-ID">>, JObj)), diff --git a/applications/call_inspector/src/parsers/ci_chunk.erl b/applications/call_inspector/src/parsers/ci_chunk.erl index 5be6b2ec96b..a6d2184b928 100644 --- a/applications/call_inspector/src/parsers/ci_chunk.erl +++ b/applications/call_inspector/src/parsers/ci_chunk.erl @@ -35,17 +35,17 @@ - export([pick_ref_parser/1]). -endif. --record(ci_chunk, {call_id :: api_ne_binary() - ,data = [] :: ne_binaries() - ,timestamp :: api_float() - ,ref_timestamp :: api_float() - ,src_ip :: api_ne_binary() - ,src_port :: api_pos_integer() - ,dst_ip :: api_ne_binary() - ,dst_port :: api_pos_integer() - ,parser :: api_ne_binary() - ,label :: api_ne_binary() - ,c_seq :: api_ne_binary() %% Parsing Kamailio logs: this can be undefined (DON'T parse them) +-record(ci_chunk, {call_id :: kz_term:api_ne_binary() + ,data = [] :: kz_term:ne_binaries() + ,timestamp :: kz_term:api_float() + ,ref_timestamp :: kz_term:api_float() + ,src_ip :: kz_term:api_ne_binary() + ,src_port :: kz_term:api_pos_integer() + ,dst_ip :: kz_term:api_ne_binary() + ,dst_port :: kz_term:api_pos_integer() + ,parser :: kz_term:api_ne_binary() + ,label :: kz_term:api_ne_binary() + ,c_seq :: kz_term:api_ne_binary() %% Parsing Kamailio logs: this can be undefined (DON'T parse them) }). -type chunk() :: #ci_chunk{}. @@ -74,63 +74,63 @@ setters(#ci_chunk{}=Chunk, Setters) -> NewChunk = lists:foldl(Apply, Chunk, Setters), NewChunk#ci_chunk{ref_timestamp = ci_parsers_util:timestamp()}. --spec call_id(chunk(), ne_binary()) -> chunk(). +-spec call_id(chunk(), kz_term:ne_binary()) -> chunk(). ?SETTER(call_id). --spec call_id(chunk()) -> api_binary(). +-spec call_id(chunk()) -> kz_term:api_binary(). ?GETTER(call_id). --spec data(chunk(), ne_binaries()) -> chunk(). +-spec data(chunk(), kz_term:ne_binaries()) -> chunk(). ?SETTER(data). --spec data(chunk()) -> ne_binaries(). +-spec data(chunk()) -> kz_term:ne_binaries(). ?GETTER(data). --spec append_data(chunk(), ne_binary()) -> chunk(). +-spec append_data(chunk(), kz_term:ne_binary()) -> chunk(). append_data(#ci_chunk{data=D}=Chunk, Data) -> Chunk#ci_chunk{data=[Data|D]}. --spec timestamp(chunk(), api_float()) -> chunk(). +-spec timestamp(chunk(), kz_term:api_float()) -> chunk(). ?SETTER(timestamp). --spec timestamp(chunk()) -> api_float(). +-spec timestamp(chunk()) -> kz_term:api_float(). ?GETTER(timestamp). -spec ref_timestamp(chunk()) -> float(). ?GETTER(ref_timestamp). --spec src_ip(chunk(), ne_binary()) -> chunk(). +-spec src_ip(chunk(), kz_term:ne_binary()) -> chunk(). src_ip(#ci_chunk{}=Chunk, Val) -> Chunk#ci_chunk{src_ip = resolve(Val)}. --spec src_ip(chunk()) -> api_binary(). +-spec src_ip(chunk()) -> kz_term:api_binary(). ?GETTER(src_ip). -spec src_port(chunk(), pos_integer()) -> chunk(). ?SETTER(src_port). --spec src_port(chunk()) -> api_pos_integer(). +-spec src_port(chunk()) -> kz_term:api_pos_integer(). ?GETTER(src_port). --spec dst_ip(chunk(), ne_binary()) -> chunk(). +-spec dst_ip(chunk(), kz_term:ne_binary()) -> chunk(). dst_ip(#ci_chunk{}=Chunk, Val) -> Chunk#ci_chunk{dst_ip = resolve(Val)}. --spec dst_ip(chunk()) -> api_binary(). +-spec dst_ip(chunk()) -> kz_term:api_binary(). ?GETTER(dst_ip). -spec dst_port(chunk(), pos_integer()) -> chunk(). ?SETTER(dst_port). --spec dst_port(chunk()) -> api_pos_integer(). +-spec dst_port(chunk()) -> kz_term:api_pos_integer(). ?GETTER(dst_port). -spec parser(chunk(), atom()) -> chunk(). parser(#ci_chunk{}=Chunk, Parser) -> Chunk#ci_chunk{parser = kz_term:to_binary(Parser)}. --spec parser(chunk()) -> api_binary(). +-spec parser(chunk()) -> kz_term:api_binary(). ?GETTER(parser). --spec label(chunk(), ne_binary()) -> chunk(). +-spec label(chunk(), kz_term:ne_binary()) -> chunk(). ?SETTER(label). --spec label(chunk()) -> api_binary(). +-spec label(chunk()) -> kz_term:api_binary(). ?GETTER(label). --spec c_seq(chunk(), ne_binary()) -> chunk(). +-spec c_seq(chunk(), kz_term:ne_binary()) -> chunk(). ?SETTER(c_seq). --spec c_seq(chunk()) -> api_binary(). +-spec c_seq(chunk()) -> kz_term:api_binary(). ?GETTER(c_seq). -spec to_json(chunk()) -> kz_json:object(). @@ -165,14 +165,14 @@ from_json(JObj) -> ,c_seq = kz_json:get_value(<<"c_seq">>, JObj) }. --spec src(chunk() | ne_binary()) -> ne_binary() | {ne_binary(), pos_integer()}. +-spec src(chunk() | kz_term:ne_binary()) -> kz_term:ne_binary() | {kz_term:ne_binary(), pos_integer()}. src(#ci_chunk{src_ip = Ip, src_port = Port}) -> <>; src(Bin = <<_/binary>>) -> [IP, Port] = binary:split(Bin, <<":">>), {IP, kz_term:to_integer(Port)}. --spec dst(chunk() | ne_binary()) -> ne_binary() | {ne_binary(), pos_integer()}. +-spec dst(chunk() | kz_term:ne_binary()) -> kz_term:ne_binary() | {kz_term:ne_binary(), pos_integer()}. dst(#ci_chunk{dst_ip = Ip, dst_port = Port}) -> <>; dst(Bin = <<_/binary>>) -> @@ -191,7 +191,7 @@ is_chunk(_) -> 'false'. %% `Chunks` needs to be ordered (e.g. using reorder_dialog/1). %% @end %%-------------------------------------------------------------------- --spec get_dialog_entities([chunk()]) -> ne_binaries(). +-spec get_dialog_entities([chunk()]) -> kz_term:ne_binaries(). get_dialog_entities(Chunks) -> get_dialog_entities(Chunks, []). get_dialog_entities([], Acc) -> @@ -220,14 +220,14 @@ reorder_dialog(Chunks) -> lager:debug("reordering '~s' using parser '~s'", [call_id(hd(Chunks)), RefParser]), do_reorder_dialog(RefParser, Chunks). --spec pick_ref_parser([chunk()]) -> ne_binary(). +-spec pick_ref_parser([chunk()]) -> kz_term:ne_binary(). pick_ref_parser(Chunks) -> GroupedByParser = group_by(fun parser/1, Chunks), Counted = lists:keymap(fun erlang:length/1, 2, GroupedByParser), {RefParser,_Max} = lists:last(lists:keysort(2, Counted)), RefParser. --spec do_reorder_dialog(ne_binary(), [chunk()]) -> [chunk()]. +-spec do_reorder_dialog(kz_term:ne_binary(), [chunk()]) -> [chunk()]. do_reorder_dialog(RefParser, Chunks) -> GroupedByCSeq = lists:keysort(1, group_by(fun c_seq_number/1, Chunks)), lists:flatmap(fun({_CSeq, ByCSeq}) -> @@ -243,7 +243,7 @@ do_reorder_dialog(RefParser, Chunks) -> ,GroupedByCSeq ). --spec sort_split_uniq(ne_binary(), [chunk()]) -> {[chunk()], [chunk()]}. +-spec sort_split_uniq(kz_term:ne_binary(), [chunk()]) -> {[chunk()], [chunk()]}. sort_split_uniq(RefParser, Chunks) -> Grouper = fun (Chunk) -> RefParser =:= parser(Chunk) end, {InOrder, Others} = lists:partition(Grouper, sort_by_timestamp(Chunks)), @@ -332,7 +332,7 @@ is_duplicate([], _) -> is_duplicate([_|Chunks], Chunk) -> is_duplicate(Chunks, Chunk). --spec c_seq_number(chunk()) -> ne_binary(). +-spec c_seq_number(chunk()) -> kz_term:ne_binary(). c_seq_number(Chunk) -> [Number, _Tag] = binary:split(c_seq(Chunk), <<$\s>>), Number. @@ -354,5 +354,5 @@ group_as_dict(Fun, List) -> end, lists:foldl(F, dict:new(), List). --spec resolve(ne_binary()) -> ne_binary(). +-spec resolve(kz_term:ne_binary()) -> kz_term:ne_binary(). resolve(IP) -> IP. diff --git a/applications/call_inspector/src/parsers/ci_parser_freeswitch.erl b/applications/call_inspector/src/parsers/ci_parser_freeswitch.erl index cba8a5f0b42..295be8645a8 100644 --- a/applications/call_inspector/src/parsers/ci_parser_freeswitch.erl +++ b/applications/call_inspector/src/parsers/ci_parser_freeswitch.erl @@ -27,9 +27,9 @@ -record(state, {parser_id :: atom() ,logfile :: file:name() ,iodevice :: file:io_device() - ,logip :: ne_binary() + ,logip :: kz_term:ne_binary() ,logport :: pos_integer() - ,timer :: api_reference() + ,timer :: kz_term:api_reference() ,counter :: pos_integer() }). -type state() :: #state{}. @@ -41,7 +41,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link([ci_parsers_util:parser_args()]) -> startlink_ret(). +-spec start_link([ci_parsers_util:parser_args()]) -> kz_types:startlink_ret(). start_link([Arg]=Args) -> ServerName = ci_parsers_util:make_name(Arg), gen_server:start_link({'local', ServerName}, ?MODULE, Args, []). @@ -61,7 +61,7 @@ start_link([Arg]=Args) -> %% {stop, Reason} %% @end %%-------------------------------------------------------------------- --spec init({'parser_args', file:filename_all(), ne_binary(), pos_integer()}) -> +-spec init({'parser_args', file:filename_all(), kz_term:ne_binary(), pos_integer()}) -> {'ok', state()} | {'stop', any()}. init({'parser_args', LogFile, LogIP, LogPort} = Args) -> @@ -97,7 +97,7 @@ init({'parser_args', LogFile, LogIP, LogPort} = Args) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(atom(), any(), state()) -> handle_call_ret(). +-spec handle_call(atom(), any(), state()) -> kz_types:handle_call_ret(). handle_call(_Request, _From, State) -> lager:debug("unhandled handle_call executed ~p~p", [_Request, _From]), Reply = 'ok', @@ -113,7 +113,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> lager:debug("unhandled handle_cast ~p", [_Msg]), {'noreply', State}. @@ -128,7 +128,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info('start_parsing', State=#state{parser_id = ParserId ,iodevice = IoDevice ,logip = LogIP @@ -184,7 +184,7 @@ code_change(_OldVsn, State, _Extra) -> %%% Internal functions %%%=================================================================== --spec extract_chunks(atom(), file:io_device(), ne_binary(), pos_integer(), pos_integer()) -> pos_integer(). +-spec extract_chunks(atom(), file:io_device(), kz_term:ne_binary(), pos_integer(), pos_integer()) -> pos_integer(). extract_chunks(ParserId, Dev, LogIP, LogPort, Counter) -> case extract_chunk(Dev, buffer()) of [] -> Counter; @@ -193,9 +193,9 @@ extract_chunks(ParserId, Dev, LogIP, LogPort, Counter) -> extract_chunks(ParserId, Dev, LogIP, LogPort, NewCounter) end. --type buffer() :: [binary() | {'timestamp', api_number()}]. +-type buffer() :: [binary() | {'timestamp', kz_term:api_number()}]. --spec make_and_store_chunk(atom(), ne_binary(), pos_integer(), pos_integer(), buffer()) -> pos_integer(). +-spec make_and_store_chunk(atom(), kz_term:ne_binary(), pos_integer(), pos_integer(), buffer()) -> pos_integer(). make_and_store_chunk(ParserId, LogIP, LogPort, Counter, Data00) -> Apply = fun (Fun, Arg) -> Fun(Arg) end, {Timestamp, Data0, NewCounter} = @@ -278,7 +278,7 @@ buffer(Buffer) -> []. --spec set_legs(ne_binary(), pos_integer(), ci_chunk:chunk(), [ne_binary()]) -> +-spec set_legs(kz_term:ne_binary(), pos_integer(), ci_chunk:chunk(), [kz_term:ne_binary()]) -> ci_chunk:chunk(). set_legs(LogIP, LogPort, Chunk, [FirstLine|_Lines]) -> case FirstLine of @@ -301,16 +301,16 @@ set_legs(LogIP, LogPort, Chunk, [FirstLine|_Lines]) -> ] ). --spec ip(ne_binary()) -> ne_binary(). +-spec ip(kz_term:ne_binary()) -> kz_term:ne_binary(). ip(Bin) -> %% 15 = Look ahead inside longest IPv4 possible extract_ahead(<<"/[">>, 4*3+3, <<"]:">>, Bin). --spec get_port(ne_binary()) -> ne_binary(). +-spec get_port(kz_term:ne_binary()) -> kz_term:ne_binary(). get_port(Bin) -> extract_ahead(<<"]:">>, 6, <<" at ">>, Bin). --spec extract_ahead(ne_binary(), pos_integer(), ne_binary(), binary()) -> api_binary(). +-spec extract_ahead(kz_term:ne_binary(), pos_integer(), kz_term:ne_binary(), binary()) -> kz_term:api_binary(). extract_ahead(Lhs, Span, Rhs, Bin) -> case binary:match(Bin, Lhs) of {StartS, StartP} -> @@ -324,11 +324,11 @@ extract_ahead(Lhs, Span, Rhs, Bin) -> 'undefined' end. --spec label([ne_binary()]) -> ne_binary(). +-spec label([kz_term:ne_binary()]) -> kz_term:ne_binary(). label(Data) -> lists:nth(2, Data). --spec remove_whitespace_lines([binary()]) -> [ne_binary()]. +-spec remove_whitespace_lines([binary()]) -> [kz_term:ne_binary()]. remove_whitespace_lines(Data) -> [Line || Line <- Data, not all_whitespace(Line)]. @@ -340,7 +340,7 @@ all_whitespace(<<$\n, Rest/binary>>) -> all_whitespace(<<>>) -> 'true'; all_whitespace(_) -> 'false'. --spec strip_truncating_pieces([ne_binary()]) -> [ne_binary()]. +-spec strip_truncating_pieces([kz_term:ne_binary()]) -> [kz_term:ne_binary()]. strip_truncating_pieces(Data) -> [case re:run(Line, "(\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d{6} \\[[A-Z]+\\] )") of {'match', [{Offset,_}|_]} -> kz_binary:truncate_right(Line, Offset); @@ -349,35 +349,35 @@ strip_truncating_pieces(Data) -> || Line <- Data ]. --spec remove_unrelated_lines([ne_binary()]) -> [ne_binary()]. +-spec remove_unrelated_lines([kz_term:ne_binary()]) -> [kz_term:ne_binary()]. remove_unrelated_lines([FirstLine|Lines]) -> [FirstLine | do_remove_unrelated_lines(Lines)]. --spec do_remove_unrelated_lines([ne_binary()]) -> [ne_binary()]. +-spec do_remove_unrelated_lines([kz_term:ne_binary()]) -> [kz_term:ne_binary()]. do_remove_unrelated_lines([]) -> []; do_remove_unrelated_lines([<<" ", _/binary>>=Line|Lines]) -> [Line | do_remove_unrelated_lines(Lines)]; do_remove_unrelated_lines([_|Lines]) -> do_remove_unrelated_lines(Lines). --spec unwrap_lines([ne_binary()]) -> [ne_binary()]. +-spec unwrap_lines([kz_term:ne_binary()]) -> [kz_term:ne_binary()]. unwrap_lines([FirstLine|Lines]) -> [unwrap_first_line(FirstLine)] ++ [unwrap(Line) || Line <- Lines]. --spec unwrap_first_line(ne_binary()) -> ne_binary(). +-spec unwrap_first_line(kz_term:ne_binary()) -> kz_term:ne_binary(). unwrap_first_line(FirstLine) -> Rm = length(":\n"), Sz = byte_size(FirstLine) - Rm, <> = FirstLine, Line. --spec unwrap(ne_binary()) -> ne_binary(). +-spec unwrap(kz_term:ne_binary()) -> kz_term:ne_binary(). unwrap(Line) -> Sz = byte_size(Line) - length(" ") - length("\n"), <<" ", Data:Sz/binary, _:1/binary>> = Line, Data. --spec remove_dashes([ne_binary()]) -> [ne_binary()]. +-spec remove_dashes([kz_term:ne_binary()]) -> [kz_term:ne_binary()]. remove_dashes([]) -> []; remove_dashes([Line|Lines]) -> case binary:split(Line, <<"#012 --">>) of diff --git a/applications/call_inspector/src/parsers/ci_parser_hep.erl b/applications/call_inspector/src/parsers/ci_parser_hep.erl index ab0942a798a..5ca444855c0 100644 --- a/applications/call_inspector/src/parsers/ci_parser_hep.erl +++ b/applications/call_inspector/src/parsers/ci_parser_hep.erl @@ -26,7 +26,7 @@ -record(state, {parser_id :: atom() ,socket :: gen_udp:socket() - ,listen_ip :: ne_binary() + ,listen_ip :: kz_term:ne_binary() ,listen_port :: pos_integer() }). -type state() :: #state{}. @@ -38,7 +38,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link([ci_parsers_util:parser_args()]) -> startlink_ret(). +-spec start_link([ci_parsers_util:parser_args()]) -> kz_types:startlink_ret(). start_link([Arg]=Args) -> ServerName = ci_parsers_util:make_name(Arg), gen_server:start_link({'local', ServerName}, ?MODULE, Args, []). @@ -58,7 +58,7 @@ start_link([Arg]=Args) -> %% {stop, Reason} %% @end %%-------------------------------------------------------------------- --spec init({'parser_args', ne_binary(), pos_integer()}) -> {'ok', state()}. +-spec init({'parser_args', kz_term:ne_binary(), pos_integer()}) -> {'ok', state()}. init({'parser_args', IP, Port} = Args) -> ParserId = ci_parsers_util:make_name(Args), _ = kz_util:put_callid(ParserId), @@ -86,7 +86,7 @@ init({'parser_args', IP, Port} = Args) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(atom(), any(), state()) -> handle_call_ret(). +-spec handle_call(atom(), any(), state()) -> kz_types:handle_call_ret(). handle_call(_Request, _From, State) -> lager:debug("unhandled handle_call executed ~p~p", [_Request, _From]), Reply = 'ok', @@ -102,7 +102,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> lager:debug("unhandled handle_cast ~p", [_Msg]), {'noreply', State}. @@ -117,7 +117,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'udp', _Socket, _IPTuple, _InPortNo, Packet}, State) -> {'ok', Hep} = hep:decode(Packet), make_and_store_chunk(State#state.parser_id, Hep), @@ -178,7 +178,7 @@ make_and_store_chunk(ParserId, Hep) -> lager:debug("parsed chunk ~s", [ci_chunk:call_id(Chunk)]), ci_datastore:store_chunk(Chunk). --spec ip(inet:ip4_address() | inet:ip6_address()) -> ne_binary(). +-spec ip(inet:ip4_address() | inet:ip6_address()) -> kz_term:ne_binary(). ip({92,_,_,_}=IP) -> lager:debug("look we hit this terrible case again!"), ip(setelement(1, IP, 192)); diff --git a/applications/call_inspector/src/parsers/ci_parser_kamailio.erl b/applications/call_inspector/src/parsers/ci_parser_kamailio.erl index 741a9dc59e4..ad85a774d7f 100644 --- a/applications/call_inspector/src/parsers/ci_parser_kamailio.erl +++ b/applications/call_inspector/src/parsers/ci_parser_kamailio.erl @@ -27,9 +27,9 @@ -record(state, {parser_id :: atom() ,logfile :: file:name() ,iodevice :: file:io_device() - ,logip :: ne_binary() + ,logip :: kz_term:ne_binary() ,logport :: pos_integer() - ,timer :: api_reference() + ,timer :: kz_term:api_reference() ,counter :: pos_integer() }). -type state() :: #state{}. @@ -41,7 +41,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(ne_binary() | list()) -> startlink_ret(). +-spec start_link(kz_term:ne_binary() | list()) -> kz_types:startlink_ret(). start_link(Args) -> ServerName = ci_parsers_util:make_name(Args), gen_server:start_link({'local', ServerName}, ?MODULE, Args, []). @@ -61,7 +61,7 @@ start_link(Args) -> %% {stop, Reason} %% @end %%-------------------------------------------------------------------- --spec init({'parser_args', file:filename_all(), ne_binary(), pos_integer()}) -> +-spec init({'parser_args', file:filename_all(), kz_term:ne_binary(), pos_integer()}) -> {'ok', state()} | {'stop', any()}. init({'parser_args', LogFile, LogIP, LogPort} = Args) -> @@ -97,7 +97,7 @@ init({'parser_args', LogFile, LogIP, LogPort} = Args) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(atom(), any(), state()) -> handle_call_ret(). +-spec handle_call(atom(), any(), state()) -> kz_types:handle_call_ret(). handle_call(_Request, _From, State) -> lager:debug("unhandled handle_call executed ~p~p", [_Request, _From]), Reply = 'ok', @@ -113,7 +113,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> lager:debug("unhandled handle_cast ~p", [_Msg]), {'noreply', State}. @@ -128,7 +128,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info('start_parsing', State=#state{parser_id = ParserId ,iodevice = IoDevice ,logip = LogIP @@ -184,7 +184,7 @@ code_change(_OldVsn, State, _Extra) -> %%% Internal functions %%%=================================================================== --spec extract_chunks(atom(), file:io_device(), ne_binary(), pos_integer(), pos_integer()) -> pos_integer(). +-spec extract_chunks(atom(), file:io_device(), kz_term:ne_binary(), pos_integer(), pos_integer()) -> pos_integer(). extract_chunks(ParserId, Dev, LogIP, LogPort, Counter) -> case extract_chunk(Dev) of [] -> Counter; @@ -199,11 +199,11 @@ extract_chunks(ParserId, Dev, LogIP, LogPort, Counter) -> lists:foldl(StoreEach, Counter, Buffers) end. --type key() :: {'callid', ne_binary()}. --type datum() :: ne_binary() | {'timestamp', ne_binary()}. +-type key() :: {'callid', kz_term:ne_binary()}. +-type datum() :: kz_term:ne_binary() | {'timestamp', kz_term:ne_binary()}. -type data() :: [datum()]. --spec make_and_store_chunk(atom(), ne_binary(), pos_integer(), ne_binary(), pos_integer(), data()) -> +-spec make_and_store_chunk(atom(), kz_term:ne_binary(), pos_integer(), kz_term:ne_binary(), pos_integer(), data()) -> pos_integer(). make_and_store_chunk(ParserId, LogIP, LogPort, Callid, Counter, Data0) -> {Data, Ts} = cleanse_data_and_get_timestamp(Data0), @@ -254,7 +254,7 @@ extract_chunk(Dev) -> end end. --spec acc(ne_binary(), data(), file:io_device(), key()) -> {key(), data()}. +-spec acc(kz_term:ne_binary(), data(), file:io_device(), key()) -> {key(), data()}. acc(<<"start|",_/binary>>=Logged, Buffer, Dev, Key) -> put(Key, [Logged]), case Buffer of @@ -282,7 +282,7 @@ acc(<<"stop|",_/binary>>=Logged, Buffer, _Dev, Key) -> erase(Key), {Key, [Logged|Buffer]}. --type cleanse_acc() :: {ne_binaries(), api_number()}. +-type cleanse_acc() :: {kz_term:ne_binaries(), kz_term:api_number()}. -spec cleanse_data_and_get_timestamp(data()) -> cleanse_acc(). cleanse_data_and_get_timestamp(Data0) -> @@ -324,19 +324,19 @@ dump_buffers() -> {'buffers', Buffers} end. --spec unwrap(ne_binary()) -> ne_binary(). +-spec unwrap(kz_term:ne_binary()) -> kz_term:ne_binary(). unwrap(Bin0) -> case binary:split(Bin0, <<"|">>) of [_Tag, Bin] -> Bin; [RawTimestamp] -> RawTimestamp end. --spec rm_newline(ne_binary()) -> ne_binary(). +-spec rm_newline(kz_term:ne_binary()) -> kz_term:ne_binary(). rm_newline(Line0) -> [Line, <<>>] = binary:split(Line0, <<"\n">>), Line. --spec label(ne_binary()) -> api_binary(). +-spec label(kz_term:ne_binary()) -> kz_term:api_binary(). label(<<"received internal reply ", Label/binary>>) -> Label; label(<<"received ", _Protocol:3/binary, " request ", Label/binary>>) -> Label; label(<<"external reply ", Label/binary>>) -> Label; @@ -344,7 +344,7 @@ label(<<"received failure reply ", Label/binary>>) -> Label; label(<<"received ", Label/binary>>) -> Label; label(_Other) -> 'undefined'. --spec from(ne_binaries(), Default) -> ne_binary() | Default. +-spec from(kz_term:ne_binaries(), Default) -> kz_term:ne_binary() | Default. from([], Default) -> Default; from([<<"start|received internal reply", _/binary>>|_Data], Default) -> Default; from([<<"log|external reply", _/binary>>|_Data], Default) -> Default; @@ -353,14 +353,14 @@ from([<<"log|source ", From/binary>>|_Data], Default) -> from([_Line|Lines], Default) -> from(Lines, Default). --spec get_ip(ne_binary(), Default) -> ne_binary() | Default. +-spec get_ip(kz_term:ne_binary(), Default) -> kz_term:ne_binary() | Default. get_ip(Bin, Default) -> case binary:split(Bin, <<":">>) of [IP, _Port] -> IP; _Else -> Default %% Unexpected case end. --spec to(ne_binaries(), Default) -> ne_binary() | Default. +-spec to(kz_term:ne_binaries(), Default) -> kz_term:ne_binary() | Default. to([], Default) -> Default; to([<<"start|received internal reply",_/binary>>|Data], Default) -> to(Data, Default); @@ -370,7 +370,7 @@ to([<<"pass|",To/binary>>|_Data], Default) -> to([_Datum|Data], Default) -> to(Data, Default). --spec from_port(ne_binaries(), Default) -> ne_binary() | Default. +-spec from_port(kz_term:ne_binaries(), Default) -> kz_term:ne_binary() | Default. from_port([], Default) -> Default; from_port([<<"start|received internal reply", _/binary>>|_Data], Default) -> Default; from_port([<<"log|external reply", _/binary>>|_Data], Default) -> Default; @@ -379,14 +379,14 @@ from_port([<<"log|source ", From/binary>>|_Data], Default) -> from_port([_Line|Lines], Default) -> from_port(Lines, Default). --spec get_port(ne_binary(), Default) -> ne_binary() | Default. +-spec get_port(kz_term:ne_binary(), Default) -> kz_term:ne_binary() | Default. get_port(Bin, Default) -> case binary:split(Bin, <<":">>) of [_IP, Port] -> Port; _Else -> Default %% Unexpected case end. --spec to_port(ne_binaries(), Default) -> ne_binary() | Default. +-spec to_port(kz_term:ne_binaries(), Default) -> kz_term:ne_binary() | Default. to_port([], Default) -> Default; to_port([<<"start|received internal reply",_/binary>>|Data], Default) -> to_port(Data, Default); @@ -397,7 +397,7 @@ to_port([_Datum|Data], Default) -> to(Data, Default). --spec c_seq(ne_binaries()) -> api_binary(). +-spec c_seq(kz_term:ne_binaries()) -> kz_term:api_binary(). c_seq([<<"cseq ", CSeq/binary>>|_Data]) -> CSeq; c_seq([]) -> 'undefined'; c_seq([_Datum|Data]) -> c_seq(Data). diff --git a/applications/call_inspector/src/parsers/ci_parsers_sup.erl b/applications/call_inspector/src/parsers/ci_parsers_sup.erl index 987e3beab16..e4b769ef688 100644 --- a/applications/call_inspector/src/parsers/ci_parsers_sup.erl +++ b/applications/call_inspector/src/parsers/ci_parsers_sup.erl @@ -48,7 +48,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -65,7 +65,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, diff --git a/applications/call_inspector/src/parsers/ci_parsers_util.erl b/applications/call_inspector/src/parsers/ci_parsers_util.erl index e41307cf8b4..4a33885f07c 100644 --- a/applications/call_inspector/src/parsers/ci_parsers_util.erl +++ b/applications/call_inspector/src/parsers/ci_parsers_util.erl @@ -33,7 +33,7 @@ timestamp() -> kz_term:to_integer(Micro) / ?MICROSECONDS_IN_SECOND + kz_time:now_s(). --spec timestamp(ne_binary() | kz_now()) -> api_float(). +-spec timestamp(kz_term:ne_binary() | kz_time:now()) -> kz_term:api_float(). timestamp(< parse_interval() -> 2 * ?MILLISECONDS_IN_SECOND. %% Milliseconds --type parser_args() :: {'parser_args', ne_binary(), any()} | - {'parser_args', file:filename_all(), ne_binary(), any()}. +-type parser_args() :: {'parser_args', kz_term:ne_binary(), any()} | + {'parser_args', file:filename_all(), kz_term:ne_binary(), any()}. --spec make_name(ne_binary() | parser_args()) -> atom(). +-spec make_name(kz_term:ne_binary() | parser_args()) -> atom(). make_name(Bin) when is_binary(Bin) -> binary_to_atom(Bin, 'utf8'); @@ -80,27 +80,27 @@ make_name({'parser_args', Filename, _IP, _Port}) -> FName = filename:absname(Filename), make_name(kz_term:to_binary(FName)). --spec call_id(ne_binaries()) -> ne_binary(). +-spec call_id(kz_term:ne_binaries()) -> kz_term:ne_binary(). call_id(Data) -> sip_field([<<"Call-ID">>, <<"i">>], Data). %% @doc Gets the CSeq field from SIP transaction data. %% To use with HEP or FreeSwitch data; Kamailio has another format! --spec c_seq(ne_binaries()) -> ne_binary(). +-spec c_seq(kz_term:ne_binaries()) -> kz_term:ne_binary(). c_seq(Data) -> sip_field([<<"CSeq">>], Data). --spec to(ne_binaries()) -> ne_binary(). +-spec to(kz_term:ne_binaries()) -> kz_term:ne_binary(). to(Data) -> sip_field([<<"To">>], Data). --spec from(ne_binaries()) -> ne_binary(). +-spec from(kz_term:ne_binaries()) -> kz_term:ne_binary(). from(Data) -> sip_field([<<"From">>], Data). %% Internals --spec sip_field(ne_binaries(), ne_binaries()) -> api_binary(). +-spec sip_field(kz_term:ne_binaries(), kz_term:ne_binaries()) -> kz_term:api_binary(). sip_field(_Fields, []) -> 'undefined'; sip_field(Fields, [Data|Rest]) -> @@ -114,7 +114,7 @@ sip_field(Fields, [Data|Rest]) -> Value end. --spec try_all(ne_binary(), ne_binary()) -> 'false' | ne_binary(). +-spec try_all(kz_term:ne_binary(), kz_term:ne_binary()) -> 'false' | kz_term:ne_binary(). try_all(Data, Field) -> FieldSz = byte_size(Field), case Data of diff --git a/applications/callflow/src/callflow_app.erl b/applications/callflow/src/callflow_app.erl index 013eee4d7db..1d4dc10a42c 100644 --- a/applications/callflow/src/callflow_app.erl +++ b/applications/callflow/src/callflow_app.erl @@ -21,7 +21,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = declare_exchanges(), callflow_sup:start_link(). diff --git a/applications/callflow/src/callflow_maintenance.erl b/applications/callflow/src/callflow_maintenance.erl index 5a976ddf271..e5eec79d017 100644 --- a/applications/callflow/src/callflow_maintenance.erl +++ b/applications/callflow/src/callflow_maintenance.erl @@ -40,14 +40,14 @@ %% %% @end %%-------------------------------------------------------------------- --spec lookup_endpoint(ne_binary()) -> 'no_return'. +-spec lookup_endpoint(kz_term:ne_binary()) -> 'no_return'. lookup_endpoint(URI) -> case binary:split(URI, <<"@">>) of [Username, Realm] -> lookup_endpoint(Username, Realm); _Else -> io:format("invalid SIP URI~n", []) end. --spec lookup_endpoint(ne_binary(), ne_binary()) -> 'no_return'. +-spec lookup_endpoint(kz_term:ne_binary(), kz_term:ne_binary()) -> 'no_return'. lookup_endpoint(Username, Realm) -> _ = case kapps_util:get_account_by_realm(Realm) of {'ok', AccountDb} -> @@ -136,13 +136,13 @@ refresh(Account) -> migrate_recorded_names() -> migrate_recorded_names(kapps_util:get_all_accounts()). --spec migrate_recorded_names(ne_binaries()) -> 'no_return'. +-spec migrate_recorded_names(kz_term:ne_binaries()) -> 'no_return'. migrate_recorded_names([]) -> 'no_return'; migrate_recorded_names([Account|Accounts]) -> _ = (catch migrate_recorded_name(Account)), migrate_recorded_names(Accounts). --spec migrate_recorded_name(ne_binary()) -> any(). +-spec migrate_recorded_name(kz_term:ne_binary()) -> any(). migrate_recorded_name(Db) -> lager:info("migrating all name recordings from vmboxes w/ owner_id in ~s", [Db]), @@ -155,8 +155,8 @@ migrate_recorded_name(Db) -> ] end. --spec do_recorded_name_migration(ne_binary(), kz_json:object()) -> any(). --spec do_recorded_name_migration(ne_binary(), kz_json:object(), api_binary()) -> any(). +-spec do_recorded_name_migration(kz_term:ne_binary(), kz_json:object()) -> any(). +-spec do_recorded_name_migration(kz_term:ne_binary(), kz_json:object(), kz_term:api_binary()) -> any(). do_recorded_name_migration(Db, VMBox) -> VMBoxId = kz_doc:id(VMBox), case kz_json:get_value(?RECORDED_NAME_KEY, VMBox) of @@ -191,7 +191,7 @@ do_recorded_name_migration(Db, MediaId, OwnerId) -> %% @end %%-------------------------------------------------------------------- -spec migrate_menus() -> ['done' | 'error',...]. --spec migrate_menus(ne_binary()) -> 'done' | 'error'. +-spec migrate_menus(kz_term:ne_binary()) -> 'done' | 'error'. migrate_menus() -> [migrate_menus(Account) || Account <- kapps_util:get_all_accounts('raw')]. migrate_menus(Account) -> @@ -277,21 +277,21 @@ update_doc(Key, Value, Id, Db) -> %% @end %%-------------------------------------------------------------------- --spec account_set_classifier_inherit(ne_binary(), ne_binary()) -> 'ok'. +-spec account_set_classifier_inherit(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. account_set_classifier_inherit(Classifier, Account) -> {'ok', AccountDb} = kapps_util:get_accounts_by_name(kz_util:normalize_account_name(Account)), set_account_classifier_action(<<"inherit">>, Classifier, AccountDb). --spec account_set_classifier_deny(ne_binary(), ne_binary()) -> 'ok'. +-spec account_set_classifier_deny(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. account_set_classifier_deny(Classifier, Account) -> {'ok', AccountDb} = kapps_util:get_accounts_by_name(kz_util:normalize_account_name(Account)), set_account_classifier_action(<<"deny">>, Classifier, AccountDb). --spec all_accounts_set_classifier_inherit(ne_binary()) -> 'ok'. +-spec all_accounts_set_classifier_inherit(kz_term:ne_binary()) -> 'ok'. all_accounts_set_classifier_inherit(Classifier) -> all_accounts_set_classifier(<<"inherit">>, Classifier). --spec all_accounts_set_classifier_deny(ne_binary()) -> 'ok'. +-spec all_accounts_set_classifier_deny(kz_term:ne_binary()) -> 'ok'. all_accounts_set_classifier_deny(Classifier) -> all_accounts_set_classifier(<<"deny">>, Classifier). @@ -301,7 +301,7 @@ all_accounts_set_classifier_deny(Classifier) -> %% %% @end %%-------------------------------------------------------------------- --spec set_account_classifier_action(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec set_account_classifier_action(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. set_account_classifier_action(Action, Classifier, AccountDb) -> 'true' = is_classifier(Classifier), io:format("found account: ~p", [kz_account:fetch_name(AccountDb)]), @@ -332,11 +332,11 @@ all_accounts_set_classifier(Action, Classifier) -> %% @end %%-------------------------------------------------------------------- --spec device_classifier_inherit(ne_binary(), ne_binary()) -> 'ok'. +-spec device_classifier_inherit(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. device_classifier_inherit(Classifier, Uri) -> set_device_classifier_action(<<"inherit">>, Classifier, Uri). --spec device_classifier_deny(ne_binary(), ne_binary()) -> 'ok'. +-spec device_classifier_deny(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. device_classifier_deny(Classifier, Uri) -> set_device_classifier_action(<<"deny">>, Classifier, Uri). @@ -346,7 +346,7 @@ device_classifier_deny(Classifier, Uri) -> %% %% @end %%-------------------------------------------------------------------- --spec set_device_classifier_action(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec set_device_classifier_action(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. set_device_classifier_action(Action, Classifier, Uri) -> 'true' = is_classifier(Classifier), [User, Realm] = binary:split(Uri, <<"@">>), @@ -363,7 +363,7 @@ set_device_classifier_action(Action, Classifier, Uri) -> %% Checks if classifier defined in system_config -> number_manager doc %% @end %%-------------------------------------------------------------------- --spec is_classifier(ne_binary()) -> boolean(). +-spec is_classifier(kz_term:ne_binary()) -> boolean(). is_classifier(Classifier) -> Classifiers = kz_json:get_keys(knm_converters:available_classifiers()), case lists:member(Classifier, Classifiers) of @@ -380,7 +380,7 @@ is_classifier(Classifier) -> %% Usage: sup callflow_maintenance list_account_restrictions accountname %% @end %%-------------------------------------------------------------------- --spec list_account_restrictions(ne_binary()) -> 'ok'. +-spec list_account_restrictions(kz_term:ne_binary()) -> 'ok'. list_account_restrictions(Account) -> {'ok', AccountDb} = kapps_util:get_accounts_by_name(kz_util:normalize_account_name(Account)), DbNameEncoded = kz_util:format_account_id(AccountDb,'encoded'), @@ -390,7 +390,7 @@ list_account_restrictions(Account) -> print_devices_level_call_restrictions(DbNameEncoded), print_trunkstore_call_restrictions(DbNameEncoded). --spec print_call_restrictions(ne_binary(), ne_binary()) -> 'ok'. +-spec print_call_restrictions(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. print_call_restrictions(DbName, DocId) -> case kz_datamgr:open_doc(DbName, DocId) of {'ok', JObj} -> @@ -402,7 +402,7 @@ print_call_restrictions(DbName, DocId) -> io:format("An error occurred: ~p\n", [E]) end. --spec print_users_level_call_restrictions(ne_binary()) -> 'ok'. +-spec print_users_level_call_restrictions(kz_term:ne_binary()) -> 'ok'. print_users_level_call_restrictions(DbName) -> case kz_datamgr:get_results(DbName, <<"users/crossbar_listing">>) of {'ok', JObj} -> @@ -416,7 +416,7 @@ print_users_level_call_restrictions(DbName) -> io:format("An error occurred: ~p", [E]) end. --spec print_devices_level_call_restrictions(ne_binary()) -> 'ok'. +-spec print_devices_level_call_restrictions(kz_term:ne_binary()) -> 'ok'. print_devices_level_call_restrictions(DbName) -> case kz_datamgr:get_results(DbName, <<"devices/crossbar_listing">>) of {'ok', JObj} -> @@ -430,7 +430,7 @@ print_devices_level_call_restrictions(DbName) -> io:format("An error occurred: ~p", [E]) end. --spec print_trunkstore_call_restrictions(ne_binary()) -> 'ok'. +-spec print_trunkstore_call_restrictions(kz_term:ne_binary()) -> 'ok'. print_trunkstore_call_restrictions(DbName) -> case kz_datamgr:get_results(DbName, <<"trunkstore/lookup_user_flags">>) of {'ok', JObj} -> @@ -456,7 +456,7 @@ print_trunkstore_call_restrictions(DbName) -> update_feature_codes() -> lists:foreach(fun update_feature_codes/1, kapps_util:get_all_accounts()). --spec update_feature_codes(ne_binary()) -> 'ok'. +-spec update_feature_codes(kz_term:ne_binary()) -> 'ok'. update_feature_codes(Account) when not is_binary(Account) -> update_feature_codes(kz_term:to_binary(Account)); diff --git a/applications/callflow/src/callflow_sup.erl b/applications/callflow/src/callflow_sup.erl index 7a13013acec..226d1a91946 100644 --- a/applications/callflow/src/callflow_sup.erl +++ b/applications/callflow/src/callflow_sup.erl @@ -50,7 +50,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -74,7 +74,7 @@ listener_proc() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/callflow/src/cf_event_handler_sup.erl b/applications/callflow/src/cf_event_handler_sup.erl index 4bd161ba51d..11ddcb6ff20 100644 --- a/applications/callflow/src/cf_event_handler_sup.erl +++ b/applications/callflow/src/cf_event_handler_sup.erl @@ -32,19 +32,19 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec new(any(), atom(), list()) -> sup_startchild_ret(). +-spec new(any(), atom(), list()) -> kz_types:sup_startchild_ret(). new(Name, M, A) -> supervisor:start_child(?SERVER, ?WORKER_NAME_ARGS_TYPE(Name, M, A, 'temporary')). --spec workers() -> pids(). +-spec workers() -> kz_term:pids(). workers() -> [Pid || {_, Pid, 'worker', [_]} <- supervisor:which_children(?SERVER)]. --spec worker(ne_binary()) -> api_pid(). +-spec worker(kz_term:ne_binary()) -> kz_term:api_pid(). worker(Name) -> case [Pid || {Worker, Pid, 'worker', [_]} <- supervisor:which_children(?SERVER), Worker =:= Name] of [] -> 'undefined'; @@ -64,7 +64,7 @@ worker(Name) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 0, diff --git a/applications/callflow/src/cf_exe.erl b/applications/callflow/src/cf_exe.erl index 408dad9dd52..46ec3ce7954 100644 --- a/applications/callflow/src/cf_exe.erl +++ b/applications/callflow/src/cf_exe.erl @@ -65,10 +65,10 @@ -record(state, {call = kapps_call:new() :: kapps_call:call() ,flow = kz_json:new() :: kz_json:object() ,flows = [] :: kz_json:objects() - ,cf_module_pid :: api_pid_ref() - ,cf_module_old_pid :: api_pid_ref() - ,status = <<"sane">> :: ne_binary() - ,queue :: api_ne_binary() + ,cf_module_pid :: kz_term:api_pid_ref() + ,cf_module_old_pid :: kz_term:api_pid_ref() + ,status = <<"sane">> :: kz_term:ne_binary() + ,queue :: kz_term:api_ne_binary() ,self = self() :: pid() ,stop_on_destroy = 'true' :: boolean() ,destroyed = 'false' :: boolean() @@ -84,7 +84,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(kapps_call:call()) -> startlink_ret(). +-spec start_link(kapps_call:call()) -> kz_types:startlink_ret(). start_link(Call) -> CallId = kapps_call:call_id(Call), Bindings = [{'call', [{'callid', CallId}]} @@ -120,7 +120,7 @@ update_call(Call, Routines) -> gen_server:call(Srv, {'update_call', Routines}). -spec continue(kapps_call:call() | pid()) -> 'ok'. --spec continue(ne_binary(), kapps_call:call() | pid()) -> 'ok'. +-spec continue(kz_term:ne_binary(), kapps_call:call() | pid()) -> 'ok'. continue(Srv) -> continue(?DEFAULT_CHILD_KEY, Srv). continue(Key, Srv) when is_pid(Srv) -> @@ -143,8 +143,8 @@ branch(Flow, Call) -> Srv = kapps_call:kvs_fetch('consumer_pid', Call), branch(Flow, Srv). --spec next(kapps_call:call() | pid()) -> api_object(). --spec next(ne_binary(), kapps_call:call() | pid()) -> api_object(). +-spec next(kapps_call:call() | pid()) -> kz_term:api_object(). +-spec next(kz_term:ne_binary(), kapps_call:call() | pid()) -> kz_term:api_object(). next(Srv) -> next(?DEFAULT_CHILD_KEY, Srv). next(Key, Srv) when is_pid(Srv) -> @@ -172,7 +172,7 @@ remove_termination_handler(Call, {_,_,_}=Handler) -> remove_termination_handler(kapps_call:kvs_fetch('consumer_pid', Call), Handler). -spec stop(kapps_call:call() | pid()) -> 'ok'. --spec stop(kapps_call:call() | pid(), api_ne_binary()) -> 'ok'. +-spec stop(kapps_call:call() | pid(), kz_term:api_ne_binary()) -> 'ok'. stop(Srv) -> stop(Srv, 'undefined'). @@ -224,7 +224,7 @@ continue_on_destroy(Call) -> Srv = kapps_call:kvs_fetch('consumer_pid', Call), continue_on_destroy(Srv). --spec callid_update(ne_binary(), kapps_call:call() | pid()) -> 'ok'. +-spec callid_update(kz_term:ne_binary(), kapps_call:call() | pid()) -> 'ok'. callid_update(CallId, Srv) when is_pid(Srv) -> gen_listener:cast(Srv, {'callid_update', CallId}); callid_update(CallId, Call) -> @@ -238,8 +238,8 @@ is_channel_destroyed(Call) -> Srv = kapps_call:kvs_fetch('consumer_pid', Call), is_channel_destroyed(Srv). --spec callid(kapps_call:call() | pid()) -> ne_binary(). --spec callid(api_binary(), kapps_call:call() | pid()) -> ne_binary(). +-spec callid(kapps_call:call() | pid()) -> kz_term:ne_binary(). +-spec callid(kz_term:api_binary(), kapps_call:call() | pid()) -> kz_term:ne_binary(). callid(Srv) when is_pid(Srv) -> CallId = gen_server:call(Srv, 'callid', 1000), @@ -252,15 +252,15 @@ callid(Call) -> callid(_, Call) -> callid(Call). --spec queue_name(kapps_call:call() | pid()) -> ne_binary(). +-spec queue_name(kapps_call:call() | pid()) -> kz_term:ne_binary(). queue_name(Srv) when is_pid(Srv) -> gen_listener:queue_name(Srv); queue_name(Call) -> Srv = kapps_call:kvs_fetch('consumer_pid', Call), queue_name(Srv). --spec control_queue(kapps_call:call() | pid()) -> ne_binary(). --spec control_queue(api_binary(), kapps_call:call() | pid()) -> ne_binary(). +-spec control_queue(kapps_call:call() | pid()) -> kz_term:ne_binary(). +-spec control_queue(kz_term:api_binary(), kapps_call:call() | pid()) -> kz_term:ne_binary(). control_queue(Srv) when is_pid(Srv) -> gen_listener:call(Srv, 'control_queue_name'); control_queue(Call) -> control_queue(kapps_call:kvs_fetch('consumer_pid', Call)). @@ -284,7 +284,7 @@ get_all_branch_keys(Call) -> -spec attempt(kapps_call:call() | pid()) -> {'attempt_resp', 'ok'} | {'attempt_resp', {'error', any()}}. --spec attempt(ne_binary(), kapps_call:call() | pid()) -> +-spec attempt(kz_term:ne_binary(), kapps_call:call() | pid()) -> {'attempt_resp', 'ok'} | {'attempt_resp', {'error', any()}}. attempt(Srv) -> attempt(?DEFAULT_CHILD_KEY, Srv). @@ -302,13 +302,13 @@ wildcard_is_empty(Call) -> Srv = kapps_call:kvs_fetch('consumer_pid', Call), wildcard_is_empty(Srv). --spec amqp_send(pid() | kapps_call:call(), api_terms(), kz_amqp_worker:publish_fun()) -> 'ok'. +-spec amqp_send(pid() | kapps_call:call(), kz_term:api_terms(), kz_amqp_worker:publish_fun()) -> 'ok'. amqp_send(Srv, API, PubFun) when is_pid(Srv), is_function(PubFun, 1) -> gen_listener:cast(Srv, {'amqp_send', API, PubFun}); amqp_send(Call, API, PubFun) when is_function(PubFun, 1) -> amqp_send(kapps_call:kvs_fetch('consumer_pid', Call), API, PubFun). --spec amqp_call(pid() | kapps_call:call(), api_terms(), kz_amqp_worker:publish_fun(), kz_amqp_worker:validate_fun()) -> 'ok'. +-spec amqp_call(pid() | kapps_call:call(), kz_term:api_terms(), kz_amqp_worker:publish_fun(), kz_amqp_worker:validate_fun()) -> 'ok'. amqp_call(Srv, API, PubFun, VerifyFun) when is_pid(Srv), is_function(PubFun, 1) -> gen_listener:call(Srv, {'amqp_call', API, PubFun, VerifyFun}); amqp_call(Call, API, PubFun, VerifyFun) when is_function(PubFun, 1) -> @@ -353,7 +353,7 @@ init([Call]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call('is_channel_destroyed', _From, State) -> {'reply', State#state.destroyed, State}; handle_call({'update_call', Routines}, _From, #state{call=Call}=State) -> @@ -421,7 +421,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'set_call', Call}, State) -> {'noreply', State#state{call=Call}}; handle_cast({'continue', _}, #state{stop_on_destroy='true' @@ -545,7 +545,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'DOWN', Ref, 'process', Pid, 'normal'}, #state{cf_module_pid={Pid, Ref} ,call=Call }=State) -> @@ -718,7 +718,7 @@ launch_cf_module(#state{call=Call ,call=kapps_call:exec(Routines, Call) }. --spec maybe_start_cf_module(ne_binary(), kz_json:object(), kapps_call:call()) -> +-spec maybe_start_cf_module(kz_term:ne_binary(), kz_json:object(), kapps_call:call()) -> {{pid() | 'undefined', reference() | atom()} | 'undefined', atom()}. maybe_start_cf_module(ModuleBin, Data, Call) -> CFModule = kz_term:to_atom(ModuleBin, 'true'), @@ -747,7 +747,7 @@ cf_module_not_found(Call) -> %% @end %%-------------------------------------------------------------------- -spec spawn_cf_module(CFModule, kz_json:object(), kapps_call:call()) -> - {pid_ref(), CFModule}. + {kz_term:pid_ref(), CFModule}. spawn_cf_module(CFModule, Data, Call) -> AMQPConsumer = kz_amqp_channel:consumer_pid(), {kz_util:spawn_monitor(fun cf_module_task/4, [CFModule, Data, Call, AMQPConsumer]) @@ -777,11 +777,11 @@ cf_module_task(CFModule, Data, Call, AMQPConsumer) -> %% a hangup command without relying on the (now terminated) cf_exe. %% @end %%-------------------------------------------------------------------- --spec amqp_send_message(api_terms(), kz_amqp_worker:publish_fun(), ne_binary()) -> 'ok'. +-spec amqp_send_message(kz_term:api_terms(), kz_amqp_worker:publish_fun(), kz_term:ne_binary()) -> 'ok'. amqp_send_message(API, PubFun, Q) -> PubFun(add_server_id(Q, API)). --spec amqp_call_message(api_terms(), kz_amqp_worker:publish_fun(), kz_amqp_worker:validate_fun(), ne_binary()) -> +-spec amqp_call_message(kz_term:api_terms(), kz_amqp_worker:publish_fun(), kz_amqp_worker:validate_fun(), kz_term:ne_binary()) -> kz_amqp_worker:request_return(). amqp_call_message(API, PubFun, VerifyFun, Q) -> Routines = [{fun add_server_id/2, Q} @@ -790,7 +790,7 @@ amqp_call_message(API, PubFun, VerifyFun, Q) -> Request = kz_api:exec(Routines, API), kz_amqp_worker:call(Request, PubFun, VerifyFun). --spec send_command(kz_proplist(), api_binary(), api_binary()) -> 'ok'. +-spec send_command(kz_term:proplist(), kz_term:api_binary(), kz_term:api_binary()) -> 'ok'. send_command(_, 'undefined', _) -> lager:debug("no control queue to send command to"); send_command(_, _, 'undefined') -> lager:debug("no call id to send command to"); send_command(Command, ControlQ, CallId) -> @@ -799,13 +799,13 @@ send_command(Command, ControlQ, CallId) -> ], kz_amqp_worker:cast(Props, fun(P) -> kapi_dialplan:publish_command(ControlQ, P) end). --spec add_server_id(ne_binary(), api_terms()) -> api_terms(). +-spec add_server_id(kz_term:ne_binary(), kz_term:api_terms()) -> kz_term:api_terms(). add_server_id(Q, API) when is_list(API) -> [{<<"Server-ID">>, Q} | props:delete(<<"Server-ID">>, API)]; add_server_id(Q, API) -> kz_json:set_value(<<"Server-ID">>, Q, API). --spec add_message_id(api_terms()) -> api_terms(). +-spec add_message_id(kz_term:api_terms()) -> kz_term:api_terms(). add_message_id(API) when is_list(API) -> [{<<"Msg-ID">>, kz_binary:rand_hex(16)} | props:delete(<<"Msg-ID">>, API)]; add_message_id(API) -> @@ -825,7 +825,7 @@ log_call_information(Call) -> end, lager:info("authorizing id ~s", [kapps_call:authorizing_id(Call)]). --spec handle_channel_destroyed(pid(), pids(), kz_json:object(), kapps_call:call(), list()) -> 'ok'. +-spec handle_channel_destroyed(pid(), kz_term:pids(), kz_json:object(), kapps_call:call(), list()) -> 'ok'. handle_channel_destroyed(Self, Notify, JObj, Call, DestoryHandlers) -> channel_destroyed(Self), relay_message(Notify, JObj), @@ -840,7 +840,7 @@ handle_channel_transfer(Call, JObj) -> 'false' -> 'ok' end. --spec handle_channel_replaced(kapps_call:call(), kz_json:object(), pids()) -> 'ok'. +-spec handle_channel_replaced(kapps_call:call(), kz_json:object(), kz_term:pids()) -> 'ok'. handle_channel_replaced(Call, JObj, Notify) -> OrgFetchId = kapps_call:custom_channel_var(<<"Fetch-ID">>, Call), NewFetchId = kz_json:get_value([<<"Custom-Channel-Vars">>, <<"Fetch-ID">>], JObj), @@ -852,7 +852,7 @@ handle_channel_replaced(Call, JObj, Notify) -> 'false' -> 'ok' end. --spec handle_channel_bridged(pid(), pids(), kz_json:object(), kapps_call:call()) -> 'ok'. +-spec handle_channel_bridged(pid(), kz_term:pids(), kz_json:object(), kapps_call:call()) -> 'ok'. handle_channel_bridged(Self, Notify, JObj, Call) -> gen_listener:cast(Self, {set_call, kapps_call:set_call_bridged('true', Call)}), relay_message(Notify, JObj). @@ -866,7 +866,7 @@ handle_usurp(Self, Call, JObj) -> 'true' -> 'ok' end. --spec handle_error(ne_binary(), pids(), kz_json:object()) -> 'ok'. +-spec handle_error(kz_term:ne_binary(), kz_term:pids(), kz_json:object()) -> 'ok'. handle_error(CallId, Notify, JObj) -> case kz_json:get_value([<<"Request">>, <<"Call-ID">>], JObj) of CallId -> relay_message(Notify, JObj); @@ -874,7 +874,7 @@ handle_error(CallId, Notify, JObj) -> _Else -> 'ok' end. --spec relay_message(pids(), kz_json:object()) -> 'ok'. +-spec relay_message(kz_term:pids(), kz_json:object()) -> 'ok'. relay_message(Notify, Message) -> _ = [kapps_call_command:relay_event(Pid, Message) || Pid <- Notify, @@ -887,12 +887,12 @@ maybe_run_destory_handlers(Call, JObj, Handlers) -> _ = [erlang:apply(M, F, [Call, JObj | Args]) || {M, F, Args} <- Handlers], 'ok'. --spec get_pid({pid(), reference()} | 'undefined') -> api_pid(). +-spec get_pid({pid(), reference()} | 'undefined') -> kz_term:api_pid(). get_pid({Pid, _}) when is_pid(Pid) -> Pid; get_pid(_) -> 'undefined'. -spec hangup_call(kapps_call:call()) -> 'ok'. --spec hangup_call(kapps_call:call(), api_ne_binary()) -> 'ok'. +-spec hangup_call(kapps_call:call(), kz_term:api_ne_binary()) -> 'ok'. hangup_call(Call) -> hangup_call(Call, 'undefined'). hangup_call(Call, Cause) -> @@ -904,7 +904,7 @@ hangup_call(Call, Cause) -> ], send_command(Cmd, kapps_call:control_queue_direct(Call), kapps_call:call_id_direct(Call)). --spec handle_channel_pivoted(server_ref(), api_pid_ref(), kz_call_event:doc(), kapps_call:call()) -> 'ok'. +-spec handle_channel_pivoted(kz_types:server_ref(), kz_term:api_pid_ref(), kz_call_event:doc(), kapps_call:call()) -> 'ok'. handle_channel_pivoted(Self, PidRef, JObj, Call) -> case kz_json:get_ne_binary_value(<<"Application-Data">>, JObj) of 'undefined' -> lager:info("no app data to pivot"); @@ -915,7 +915,7 @@ handle_channel_pivoted(Self, PidRef, JObj, Call) -> continue_with_flow(kz_json:decode(FlowBin), Self) end. --spec maybe_stop_action(api_pid_ref()) -> 'ok'. +-spec maybe_stop_action(kz_term:api_pid_ref()) -> 'ok'. maybe_stop_action({Pid, _Ref}) -> exit(Pid, 'normal'); maybe_stop_action('undefined') -> 'ok'. diff --git a/applications/callflow/src/cf_exe_sup.erl b/applications/callflow/src/cf_exe_sup.erl index 2cdea99f7a2..679c7685943 100644 --- a/applications/callflow/src/cf_exe_sup.erl +++ b/applications/callflow/src/cf_exe_sup.erl @@ -32,15 +32,15 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec new(kapps_call:call()) -> sup_startchild_ret(). +-spec new(kapps_call:call()) -> kz_types:sup_startchild_ret(). new(Call) -> supervisor:start_child(?SERVER, [Call]). --spec workers() -> pids(). +-spec workers() -> kz_term:pids(). workers() -> [Pid || {_, Pid, 'worker', [_]} <- supervisor:which_children(?SERVER)]. @@ -57,7 +57,7 @@ workers() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 0, diff --git a/applications/callflow/src/cf_flow.erl b/applications/callflow/src/cf_flow.erl index ee6bdee88db..c6c366da798 100644 --- a/applications/callflow/src/cf_flow.erl +++ b/applications/callflow/src/cf_flow.erl @@ -14,9 +14,9 @@ -include("callflow.hrl"). -include_lib("kazoo_stdlib/include/kazoo_json.hrl"). --record(pattern, {flow_id :: ne_binary() +-record(pattern, {flow_id :: kz_term:ne_binary() ,has_groups :: boolean() - ,names = [] :: ne_binaries() + ,names = [] :: kz_term:ne_binaries() ,regex :: re:mp() }). @@ -35,7 +35,7 @@ lookup(Call) -> lookup(kapps_call:request_user(Call), kapps_call:account_id(Call)). --spec lookup(ne_binary(), ne_binary()) -> lookup_ret(). +-spec lookup(kz_term:ne_binary(), kz_term:ne_binary()) -> lookup_ret(). lookup(Number, AccountId) when not is_binary(Number) -> lookup(kz_term:to_binary(Number), AccountId); lookup(<<>>, _) -> @@ -46,11 +46,11 @@ lookup(Number, AccountId) -> {'error', 'not_found'} -> do_lookup(Number, AccountId) end. --spec return_callflow_doc(ne_binary(), ne_binary()) -> lookup_ret(). +-spec return_callflow_doc(kz_term:ne_binary(), kz_term:ne_binary()) -> lookup_ret(). return_callflow_doc(FlowId, AccountId) -> return_callflow_doc(FlowId, AccountId, []). --spec return_callflow_doc(ne_binary(), ne_binary(), kz_proplist()) -> lookup_ret(). +-spec return_callflow_doc(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> lookup_ret(). return_callflow_doc(FlowId, AccountId, Props) -> Db = kz_util:format_account_db(AccountId), case kz_datamgr:open_cache_doc(Db, FlowId) of @@ -67,7 +67,7 @@ contains_no_match(Doc) -> 'false' end, kzd_callflow:numbers(Doc)). --spec do_lookup(ne_binary(), ne_binary()) -> lookup_ret(). +-spec do_lookup(kz_term:ne_binary(), kz_term:ne_binary()) -> lookup_ret(). do_lookup(Number, AccountId) -> Db = kz_util:format_account_db(AccountId), lager:info("searching for callflow in ~s to satisfy '~s'", [Db, Number]), @@ -86,7 +86,7 @@ do_lookup(Number, AccountId) -> cache_callflow_number(Number, AccountId, Flow) end. --spec cache_callflow_number(ne_binary(), ne_binary(), kzd_callflow:doc()) -> lookup_ret(). +-spec cache_callflow_number(kz_term:ne_binary(), kz_term:ne_binary(), kzd_callflow:doc()) -> lookup_ret(). cache_callflow_number(Number, AccountId, Flow) -> AccountDb = kz_util:format_account_db(AccountId), CacheOptions = [{'origin', [{'db', AccountDb, <<"callflow">>}]} @@ -95,7 +95,7 @@ cache_callflow_number(Number, AccountId, Flow) -> kz_cache:store_local(?CACHE_NAME, ?CF_FLOW_CACHE_KEY(Number, AccountId), kz_doc:id(Flow), CacheOptions), {'ok', Flow, contains_no_match(Flow)}. --spec maybe_use_nomatch(ne_binary(), ne_binary()) -> lookup_ret(). +-spec maybe_use_nomatch(kz_term:ne_binary(), kz_term:ne_binary()) -> lookup_ret(). %% only route to nomatch when Number is all digits and/or + maybe_use_nomatch(<<"+", Number/binary>>, AccountId) -> maybe_use_nomatch(Number, AccountId); @@ -111,14 +111,14 @@ maybe_use_nomatch(Number, AccountId) -> is_digit(X) when X >= $0, X =< $9 -> 'true'; is_digit(_) -> 'false'. --spec fetch_patterns(ne_binary()) -> {'ok', patterns()} | {'error', 'not_found'}. +-spec fetch_patterns(kz_term:ne_binary()) -> {'ok', patterns()} | {'error', 'not_found'}. fetch_patterns(AccountId)-> case kz_cache:fetch_local(?CACHE_NAME, ?CF_PATTERN_CACHE_KEY(AccountId)) of {'ok', _Patterns}= OK -> OK; {'error', 'not_found'} -> load_patterns(AccountId) end. --spec load_patterns(ne_binary()) -> {'ok', patterns()} | {'error', 'not_found'}. +-spec load_patterns(kz_term:ne_binary()) -> {'ok', patterns()} | {'error', 'not_found'}. load_patterns(AccountId) -> Db = kz_util:format_account_db(AccountId), case kz_datamgr:get_results(Db, ?LIST_BY_PATTERN, ['include_docs']) of @@ -151,15 +151,15 @@ compile_patterns(AccountId, [JObj | JObjs], Acc) -> compile_patterns(AccountId, JObjs, Acc) end. --spec cache_patterns(ne_binary(), patterns()) -> {'ok', patterns()}. +-spec cache_patterns(kz_term:ne_binary(), patterns()) -> {'ok', patterns()}. cache_patterns(AccountId, Patterns) -> AccountDb = kz_util:format_account_db(AccountId), CacheOptions = [{'origin', [{'db', AccountDb, <<"callflow">>}]}], kz_cache:store_local(?CACHE_NAME, ?CF_PATTERN_CACHE_KEY(AccountId), Patterns, CacheOptions), {'ok', Patterns}. --spec lookup_patterns(ne_binary(), ne_binary()) -> - {'ok', {kz_json:object(), api_binary()}} | +-spec lookup_patterns(kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', {kz_json:object(), kz_term:api_binary()}} | {'error', any()}. lookup_patterns(Number, AccountId) -> case fetch_patterns(AccountId) of @@ -172,7 +172,7 @@ lookup_patterns(Number, AccountId) -> %% @doc %% @end %%----------------------------------------------------------------------------- --spec lookup_callflow_patterns(patterns(), ne_binary(), ne_binary()) -> lookup_ret(). +-spec lookup_callflow_patterns(patterns(), kz_term:ne_binary(), kz_term:ne_binary()) -> lookup_ret(). lookup_callflow_patterns(Patterns, Number, AccountId) -> case test_callflow_patterns(Patterns, Number) of 'no_match' -> maybe_use_nomatch(Number, AccountId); @@ -184,7 +184,7 @@ lookup_callflow_patterns(Patterns, Number, AccountId) -> return_callflow_doc(FlowId, AccountId, props:filter_empty(Props)) end. --spec get_captured_names(ne_binary(), pattern()) -> kz_proplist(). +-spec get_captured_names(kz_term:ne_binary(), pattern()) -> kz_term:proplist(). get_captured_names(_Number, #pattern{names=[]}) -> []; get_captured_names(Number, #pattern{regex=Regex, names=Names}) -> case re:run(Number, Regex, [{'capture', 'all_names', 'binary'}]) of @@ -194,11 +194,11 @@ get_captured_names(Number, #pattern{regex=Regex, names=Names}) -> -type test_pattern_acc() :: {binary(), pattern() | 'undefined'}. --spec test_callflow_patterns(patterns(), ne_binary()) -> 'no_match' | test_pattern_acc(). +-spec test_callflow_patterns(patterns(), kz_term:ne_binary()) -> 'no_match' | test_pattern_acc(). test_callflow_patterns(Patterns, Number) -> test_callflow_patterns(Patterns, Number, {<<>>, 'undefined'}). --spec test_callflow_patterns(patterns(), ne_binary(), test_pattern_acc()) -> +-spec test_callflow_patterns(patterns(), kz_term:ne_binary(), test_pattern_acc()) -> 'no_match' | test_pattern_acc(). test_callflow_patterns([], _, {_, 'undefined'}) -> 'no_match'; test_callflow_patterns([], _, Result) -> Result; diff --git a/applications/callflow/src/cf_listener.erl b/applications/callflow/src/cf_listener.erl index a31f638900b..8c4cad9fc17 100644 --- a/applications/callflow/src/cf_listener.erl +++ b/applications/callflow/src/cf_listener.erl @@ -45,7 +45,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'responders', ?RESPONDERS} ,{'bindings', ?BINDINGS} @@ -89,7 +89,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Msg, _From, State) -> {'noreply', State}. @@ -103,7 +103,7 @@ handle_call(_Msg, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _QueueNAme}}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'is_consuming', _IsConsuming}}, State) -> @@ -121,7 +121,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> lager:info("unhandled message: ~p", [_Info]), {'noreply', State}. @@ -134,7 +134,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Props} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/callflow/src/cf_route_req.erl b/applications/callflow/src/cf_route_req.erl index 5b97c454844..8e52fb1e319 100644 --- a/applications/callflow/src/cf_route_req.erl +++ b/applications/callflow/src/cf_route_req.erl @@ -20,7 +20,7 @@ -define(ROUTE_WIN_TIMEOUT_KEY, <<"route_win_timeout">>). -define(ROUTE_WIN_TIMEOUT, kapps_config:get_integer(?CF_CONFIG_CAT, ?ROUTE_WIN_TIMEOUT_KEY, ?DEFAULT_ROUTE_WIN_TIMEOUT)). --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, Props) -> _ = kz_util:put_callid(JObj), 'true' = kapi_route:req_v(JObj), @@ -51,7 +51,7 @@ handle_req(JObj, Props) -> lager:debug("callflow not handling fetch-id ~s", [kapi_route:fetch_id(JObj)]) end. --spec maybe_prepend_preflow(kz_json:object(), kz_proplist() +-spec maybe_prepend_preflow(kz_json:object(), kz_term:proplist() ,kapps_call:call(), kzd_callflow:doc() ,boolean() ) -> 'ok'. @@ -72,7 +72,7 @@ maybe_prepend_preflow(JObj, Props, Call, Callflow, NoMatch) -> end end. --spec maybe_reply_to_req(kz_json:object(), kz_proplist() +-spec maybe_reply_to_req(kz_json:object(), kz_term:proplist() ,kapps_call:call(), kz_json:object(), boolean()) -> 'ok'. maybe_reply_to_req(JObj, Props, Call, Flow, NoMatch) -> lager:info("callflow ~s in ~s satisfies request for ~s", [kz_doc:id(Flow) @@ -104,14 +104,14 @@ has_tokens(Call, Flow) -> end. -spec bucket_info(kapps_call:call(), kz_json:object()) -> - {ne_binary(), pos_integer()}. + {kz_term:ne_binary(), pos_integer()}. bucket_info(Call, Flow) -> case kz_json:get_value(<<"pvt_bucket_name">>, Flow) of 'undefined' -> {bucket_name_from_call(Call, Flow), bucket_cost(Flow)}; Name -> {Name, bucket_cost(Flow)} end. --spec bucket_name_from_call(kapps_call:call(), kz_json:object()) -> ne_binary(). +-spec bucket_name_from_call(kapps_call:call(), kz_json:object()) -> kz_term:ne_binary(). bucket_name_from_call(Call, Flow) -> <<(kapps_call:account_id(Call))/binary, ":", (kz_doc:id(Flow))/binary>>. @@ -212,7 +212,7 @@ send_route_response(Flow, JObj, Call) -> lager:info("callflow didn't received a route win, exiting : ~p", [_E]) end. --spec get_transfer_media(kz_json:object(), kz_json:object()) -> api_binary(). +-spec get_transfer_media(kz_json:object(), kz_json:object()) -> kz_term:api_binary(). get_transfer_media(Flow, JObj) -> case kz_json:get_value([<<"ringback">>, <<"transfer">>], Flow) of 'undefined' -> @@ -220,7 +220,7 @@ get_transfer_media(Flow, JObj) -> MediaId -> MediaId end. --spec get_ringback_media(kz_json:object(), kz_json:object()) -> api_binary(). +-spec get_ringback_media(kz_json:object(), kz_json:object()) -> kz_term:api_binary(). get_ringback_media(Flow, JObj) -> case kz_json:get_value([<<"ringback">>, <<"early">>], Flow) of 'undefined' -> @@ -234,7 +234,7 @@ get_ringback_media(Flow, JObj) -> %% %% @end %%----------------------------------------------------------------------------- --spec pre_park_action(kapps_call:call()) -> ne_binary(). +-spec pre_park_action(kapps_call:call()) -> kz_term:ne_binary(). pre_park_action(Call) -> case kapps_config:get_is_true(?CF_CONFIG_CAT, <<"ring_ready_offnet">>, 'true') andalso kapps_call:inception(Call) =/= 'undefined' @@ -251,7 +251,7 @@ pre_park_action(Call) -> %% process %% @end %%----------------------------------------------------------------------------- --spec update_call(kz_json:object(), boolean(), ne_binary(), kapps_call:call()) -> +-spec update_call(kz_json:object(), boolean(), kz_term:ne_binary(), kapps_call:call()) -> kapps_call:call(). update_call(Flow, NoMatch, ControllerQ, Call) -> Props = [{'cf_flow_id', kz_doc:id(Flow)} @@ -286,7 +286,7 @@ maybe_referred_call(Call) -> maybe_device_redirected(Call) -> maybe_fix_restrictions(get_redirected_by(Call), Call). --spec maybe_fix_restrictions(api_binary(), kapps_call:call()) -> kapps_call:call(). +-spec maybe_fix_restrictions(kz_term:api_binary(), kapps_call:call()) -> kapps_call:call(). maybe_fix_restrictions('undefined', Call) -> Call; maybe_fix_restrictions(Device, Call) -> case cf_util:endpoint_id_by_sip_username(kapps_call:account_db(Call), Device) of @@ -296,17 +296,17 @@ maybe_fix_restrictions(Device, Call) -> kapps_call:remove_custom_channel_vars(Keys, Call) end. --spec get_referred_by(kapps_call:call()) -> api_binary(). +-spec get_referred_by(kapps_call:call()) -> kz_term:api_binary(). get_referred_by(Call) -> ReferredBy = kapps_call:custom_channel_var(<<"Referred-By">>, Call), extract_sip_username(ReferredBy). --spec get_redirected_by(kapps_call:call()) -> api_binary(). +-spec get_redirected_by(kapps_call:call()) -> kz_term:api_binary(). get_redirected_by(Call) -> RedirectedBy = kapps_call:custom_channel_var(<<"Redirected-By">>, Call), extract_sip_username(RedirectedBy). --spec is_valid_endpoint(api_binary(), kapps_call:call()) -> boolean(). +-spec is_valid_endpoint(kz_term:api_binary(), kapps_call:call()) -> boolean(). is_valid_endpoint('undefined', _) -> 'false'; is_valid_endpoint(Contact, Call) -> ReOptions = [{'capture', [1], 'binary'}], @@ -319,7 +319,7 @@ is_valid_endpoint(Contact, Call) -> _ -> 'false' end. --spec extract_sip_username(api_binary()) -> api_binary(). +-spec extract_sip_username(kz_term:api_binary()) -> kz_term:api_binary(). extract_sip_username('undefined') -> 'undefined'; extract_sip_username(Contact) -> ReOptions = [{'capture', [1], 'binary'}], diff --git a/applications/callflow/src/cf_route_resume.erl b/applications/callflow/src/cf_route_resume.erl index fa059f06f6e..0d8c3e0a119 100644 --- a/applications/callflow/src/cf_route_resume.erl +++ b/applications/callflow/src/cf_route_resume.erl @@ -12,7 +12,7 @@ -include("callflow.hrl"). --spec handle_req(kz_json:object(), kz_proplist()) -> kapps_call:call(). +-spec handle_req(kz_json:object(), kz_term:proplist()) -> kapps_call:call(). handle_req(JObj, _Props) -> 'true' = kapi_callflow:resume_v(JObj), Call0 = kapps_call:from_json(kz_json:get_json_value(<<"Call">>, JObj)), diff --git a/applications/callflow/src/cf_route_win.erl b/applications/callflow/src/cf_route_win.erl index 56f8c46af50..49302f1c000 100644 --- a/applications/callflow/src/cf_route_win.erl +++ b/applications/callflow/src/cf_route_win.erl @@ -52,7 +52,7 @@ should_restrict_call(Call) -> EndpointId = kapps_call:kvs_fetch(?RESTRICTED_ENDPOINT_KEY, DefaultEndpointId, Call), should_restrict_call(EndpointId, Call). --spec should_restrict_call(api_ne_binary(), kapps_call:call()) -> boolean(). +-spec should_restrict_call(kz_term:api_ne_binary(), kapps_call:call()) -> boolean(). should_restrict_call('undefined', _Call) -> 'false'; should_restrict_call(EndpointId, Call) -> case kz_endpoint:get(EndpointId, Call) of @@ -113,7 +113,7 @@ maybe_classification_restriction(JObj, Call) -> ), kz_json:get_value([<<"call_restriction">>, Classification, <<"action">>], JObj) =:= <<"deny">>. --spec find_request(kapps_call:call()) -> ne_binary(). +-spec find_request(kapps_call:call()) -> kz_term:ne_binary(). find_request(Call) -> case kapps_call:kvs_fetch('cf_capture_group', Call) of 'undefined' -> @@ -157,7 +157,7 @@ get_caller_groups(Groups, JObj, Call) -> ,Ids ). --spec maybe_device_groups_intersect(ne_binary(), sets:set(), kz_json:objects(), kapps_call:call()) -> boolean(). +-spec maybe_device_groups_intersect(kz_term:ne_binary(), sets:set(), kz_json:objects(), kapps_call:call()) -> boolean(). maybe_device_groups_intersect(CalleeId, CallerGroups, Groups, Call) -> CalleeGroups = get_group_associations(CalleeId, Groups), case sets:size(sets:intersection(CallerGroups, CalleeGroups)) =:= 0 of @@ -175,11 +175,11 @@ maybe_device_groups_intersect(CalleeId, CallerGroups, Groups, Call) -> sets:size(sets:intersection(CallerGroups, UsersGroups)) =:= 0 end. --spec get_group_associations(ne_binary(), kz_json:objects()) -> sets:set(). +-spec get_group_associations(kz_term:ne_binary(), kz_json:objects()) -> sets:set(). get_group_associations(Id, Groups) -> get_group_associations(Id, Groups, sets:new()). --spec get_group_associations(ne_binary(), kz_json:objects(), sets:set()) -> sets:set(). +-spec get_group_associations(kz_term:ne_binary(), kz_json:objects(), sets:set()) -> sets:set(). get_group_associations(Id, Groups, Set) -> lists:foldl(fun(Group, S) -> case kz_json:get_value([<<"value">>, Id], Group) of @@ -188,7 +188,7 @@ get_group_associations(Id, Groups, Set) -> end end, Set, Groups). --spec get_callee_extension_info(kapps_call:call()) -> {ne_binary(), ne_binary()} | 'undefined'. +-spec get_callee_extension_info(kapps_call:call()) -> {kz_term:ne_binary(), kz_term:ne_binary()} | 'undefined'. get_callee_extension_info(Call) -> Flow = kapps_call:kvs_fetch('cf_flow', Call), FirstModule = kz_json:get_ne_binary_value(<<"module">>, Flow), @@ -284,7 +284,7 @@ update_ccvs(Call) -> kapps_call:set_custom_channel_vars(Props, Call). -spec maybe_start_metaflow(kapps_call:call()) -> kapps_call:call(). --spec maybe_start_metaflow(kapps_call:call(), api_binary()) -> kapps_call:call(). +-spec maybe_start_metaflow(kapps_call:call(), kz_term:api_binary()) -> kapps_call:call(). maybe_start_metaflow(Call) -> maybe_start_metaflow(Call, kapps_call:custom_channel_var(<<"Metaflow-App">>, Call)). @@ -295,7 +295,7 @@ maybe_start_metaflow(Call, App) -> lager:debug("metaflow app ~s", [App]), Call. --spec maybe_start_endpoint_metaflow(kapps_call:call(), api_binary()) -> 'ok'. +-spec maybe_start_endpoint_metaflow(kapps_call:call(), kz_term:api_binary()) -> 'ok'. maybe_start_endpoint_metaflow(_Call, 'undefined') -> 'ok'; maybe_start_endpoint_metaflow(Call, EndpointId) -> lager:debug("looking up endpoint for ~s", [EndpointId]), @@ -318,7 +318,7 @@ maybe_start_recording(Call) -> ], kapps_call:exec(Routines, Call). --spec maybe_start_account_recording(ne_binary(), ne_binary(), kapps_call:call()) -> kapps_call:call(). +-spec maybe_start_account_recording(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> kapps_call:call(). maybe_start_account_recording(From, To, Call) -> {'ok', Endpoint} = kz_endpoint:get(kapps_call:account_id(Call), Call), case maybe_start_call_recording(?ACCOUNT_INBOUND_RECORDING(From) @@ -340,7 +340,7 @@ maybe_start_account_recording(From, To, Call) -> NewCall -> kapps_call:set_is_recording('true', NewCall) end. --spec maybe_start_endpoint_recording(ne_binary(), ne_binary, kapps_call:call()) -> kapps_call:call(). +-spec maybe_start_endpoint_recording(kz_term:ne_binary(), ne_binary, kapps_call:call()) -> kapps_call:call(). maybe_start_endpoint_recording(<<"onnet">>, To, Call) -> DefaultEndpointId = kapps_call:authorizing_id(Call), EndpointId = kapps_call:kvs_fetch(?RESTRICTED_ENDPOINT_KEY, DefaultEndpointId, Call), @@ -348,7 +348,7 @@ maybe_start_endpoint_recording(<<"onnet">>, To, Call) -> maybe_start_endpoint_recording(_, _, Call) -> Call. --spec maybe_start_onnet_endpoint_recording(api_binary(), ne_binary(), kapps_call:call()) -> kapps_call:call(). +-spec maybe_start_onnet_endpoint_recording(kz_term:api_binary(), kz_term:ne_binary(), kapps_call:call()) -> kapps_call:call(). maybe_start_onnet_endpoint_recording('undefined', _To, Call) -> Call; maybe_start_onnet_endpoint_recording(EndpointId, To, Call) -> case kz_endpoint:get(EndpointId, Call) of @@ -362,11 +362,11 @@ maybe_start_onnet_endpoint_recording(EndpointId, To, Call) -> _ -> Call end. --spec maybe_start_call_recording(ne_binaries(), ne_binary(), kz_json:object(), kapps_call:call()) -> kapps_call:call(). +-spec maybe_start_call_recording(kz_term:ne_binaries(), kz_term:ne_binary(), kz_json:object(), kapps_call:call()) -> kapps_call:call(). maybe_start_call_recording(Key, Label, Endpoint, Call) -> maybe_start_call_recording(kz_json:get_json_value(Key, Endpoint), Label, Call). --spec maybe_start_call_recording(api_object(), ne_binary(), kapps_call:call()) -> kapps_call:call(). +-spec maybe_start_call_recording(kz_term:api_object(), kz_term:ne_binary(), kapps_call:call()) -> kapps_call:call(). maybe_start_call_recording('undefined', _, Call) -> Call; maybe_start_call_recording(Data, Label, Call) -> @@ -375,7 +375,7 @@ maybe_start_call_recording(Data, Label, Call) -> 'false' -> kapps_call:start_recording(kz_json:set_value(<<"origin">>, Label, Data), Call) end. --spec get_incoming_security(kapps_call:call()) -> kz_proplist(). +-spec get_incoming_security(kapps_call:call()) -> kz_term:proplist(). get_incoming_security(Call) -> case kz_endpoint:get(Call) of {'error', _R} -> []; diff --git a/applications/callflow/src/cf_shared_listener.erl b/applications/callflow/src/cf_shared_listener.erl index d292a6f9451..e4e02538680 100644 --- a/applications/callflow/src/cf_shared_listener.erl +++ b/applications/callflow/src/cf_shared_listener.erl @@ -59,7 +59,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'responders', ?RESPONDERS} ,{'bindings', ?BINDINGS} @@ -97,7 +97,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Msg, _From, State) -> {'noreply', State}. @@ -111,7 +111,7 @@ handle_call(_Msg, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> {'noreply', State}. @@ -125,7 +125,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> lager:debug("unhandled message: ~p", [_Info]), {'noreply', State}. @@ -138,7 +138,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Props} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/callflow/src/cf_singular_call_hooks.erl b/applications/callflow/src/cf_singular_call_hooks.erl index 839167ee30f..151c842295c 100644 --- a/applications/callflow/src/cf_singular_call_hooks.erl +++ b/applications/callflow/src/cf_singular_call_hooks.erl @@ -209,10 +209,10 @@ call_is_singular(Call) -> %% @doc %% Gets where the call was started. If kapps_call returns undefined, it was on net. %% -%% @spec get_inception(kapps_call:call()) -> ne_binary(). +%% @spec get_inception(kapps_call:call()) -> kz_term:ne_binary(). %% @end %%-------------------------------------------------------------------- --spec get_inception(kapps_call:call()) -> ne_binary(). +-spec get_inception(kapps_call:call()) -> kz_term:ne_binary(). get_inception(Call) -> case kapps_call:inception(Call) of 'undefined' -> <<"onnet">>; @@ -224,9 +224,9 @@ get_inception(Call) -> %% @doc %% Gets the singular call hook URL from the configuration (may be cached). %% -%% @spec get_hook_url() -> ne_binary(). +%% @spec get_hook_url() -> kz_term:ne_binary(). %% @end %%-------------------------------------------------------------------- --spec get_hook_url() -> ne_binary(). +-spec get_hook_url() -> kz_term:ne_binary(). get_hook_url() -> kapps_config:get_binary(?CF_CONFIG_CAT, <<"singular_call_hook_url">>, <<"">>). diff --git a/applications/callflow/src/cf_singular_call_hooks_listener.erl b/applications/callflow/src/cf_singular_call_hooks_listener.erl index 03cc44180a4..c6562721e9f 100644 --- a/applications/callflow/src/cf_singular_call_hooks_listener.erl +++ b/applications/callflow/src/cf_singular_call_hooks_listener.erl @@ -51,7 +51,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the listener and binds to the call channel destroy events %%-------------------------------------------------------------------- --spec start_link(kapps_call:call()) -> startlink_ret(). +-spec start_link(kapps_call:call()) -> kz_types:startlink_ret(). start_link(Call) -> gen_listener:start_link(?SERVER, [{'bindings', ?BINDINGS(kapps_call:call_id(Call))} ,{'responders', ?RESPONDERS} @@ -67,7 +67,7 @@ start_link(Call) -> %% CHANNEL_DESTROY. %% @end %%-------------------------------------------------------------------- --spec handle_call_event(kz_json:object(), kz_proplist()) -> any(). +-spec handle_call_event(kz_json:object(), kz_term:proplist()) -> any(). handle_call_event(JObj, Props) -> case kz_util:get_event_type(JObj) of {<<"call_event">>, <<"CHANNEL_DESTROY">>} -> diff --git a/applications/callflow/src/cf_task.erl b/applications/callflow/src/cf_task.erl index 063a7a899de..c1a47de830c 100644 --- a/applications/callflow/src/cf_task.erl +++ b/applications/callflow/src/cf_task.erl @@ -28,9 +28,9 @@ -record(state, {call :: kapps_call:call() ,callback :: fun() ,args :: list() - ,pid :: api_pid() - ,ref :: api_reference() - ,queue :: api_binary() + ,pid :: kz_term:api_pid() + ,ref :: kz_term:api_reference() + ,queue :: kz_term:api_binary() }). -type state() :: #state{}. @@ -49,7 +49,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the listener and binds to the call channel destroy events %%-------------------------------------------------------------------- --spec start_link(kapps_call:call(), fun(), list()) -> startlink_ret(). +-spec start_link(kapps_call:call(), fun(), list()) -> kz_types:startlink_ret(). start_link(Call, Fun, Args) -> gen_listener:start_link(?SERVER ,[{'bindings', ?BINDINGS(kapps_call:call_id(Call))} @@ -68,7 +68,7 @@ start_link(Call, Fun, Args) -> %% CHANNEL_DESTROY. %% @end %%-------------------------------------------------------------------- --spec relay_amqp(kz_json:object(), kz_proplist()) -> any(). +-spec relay_amqp(kz_json:object(), kz_term:proplist()) -> any(). relay_amqp(JObj, Props) -> Pid = props:get_value('cf_task_pid', Props), kapps_call_command:relay_event(Pid, JObj). @@ -146,7 +146,7 @@ handle_info(Info, State) -> %% Allows listener to pass options to handlers %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), state()) -> {'reply', kz_proplist()}. +-spec handle_event(kz_json:object(), state()) -> {'reply', kz_term:proplist()}. handle_event(_JObj, #state{pid='undefined'}) -> 'ignore'; handle_event(_JObj, #state{pid=Pid}) -> {'reply', [{'cf_task_pid', Pid}]}. @@ -185,7 +185,7 @@ launch_task(#state{queue=Q State#state{pid=Pid, ref=Ref}. %% @private --spec task_launched(api_binary(), kapps_call:call(), fun(), list(), pid()) -> any(). +-spec task_launched(kz_term:api_binary(), kapps_call:call(), fun(), list(), pid()) -> any(). task_launched(Q, Call, Callback, Args, Parent) -> kapps_call:put_callid(Call), kz_amqp_channel:consumer_pid(Parent), diff --git a/applications/callflow/src/cf_util.erl b/applications/callflow/src/cf_util.erl index 09cc229e5e7..1afa2559fab 100644 --- a/applications/callflow/src/cf_util.erl +++ b/applications/callflow/src/cf_util.erl @@ -65,7 +65,7 @@ %% %% @end %%-------------------------------------------------------------------- --spec presence_probe(kz_json:object(), kz_proplist()) -> any(). +-spec presence_probe(kz_json:object(), kz_term:proplist()) -> any(). presence_probe(JObj, _Props) -> 'true' = kapi_presence:probe_v(JObj), Username = kz_json:get_value(<<"Username">>, JObj), @@ -77,7 +77,7 @@ presence_probe(JObj, _Props) -> Fun(Username, Realm) =:= 'not_found' end, ProbeRepliers). --spec presence_parking_slot(ne_binary(), ne_binary()) -> 'ok' | 'not_found'. +-spec presence_parking_slot(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | 'not_found'. presence_parking_slot(Username, Realm) -> case kapps_util:get_account_by_realm(Realm) of {'ok', AccountDb} -> @@ -85,7 +85,7 @@ presence_parking_slot(Username, Realm) -> _E -> 'not_found' end. --spec maybe_presence_parking_slot_resp(ne_binary(), ne_binary(), ne_binary()) -> 'ok' | 'not_found'. +-spec maybe_presence_parking_slot_resp(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | 'not_found'. maybe_presence_parking_slot_resp(Username, Realm, AccountDb) -> case kz_cache:fetch_local(?CACHE_NAME, ?PARKING_PRESENCE_KEY(AccountDb, Username)) of {'ok', 'false'} -> 'not_found'; @@ -95,7 +95,7 @@ maybe_presence_parking_slot_resp(Username, Realm, AccountDb) -> maybe_presence_parking_flow(Username, Realm, AccountDb) end. --spec maybe_presence_parking_flow(ne_binary(), ne_binary(), ne_binary()) -> 'ok' | 'not_found'. +-spec maybe_presence_parking_flow(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | 'not_found'. maybe_presence_parking_flow(Username, Realm, AccountDb) -> AccountId = kz_util:format_account_id(AccountDb, 'raw'), _ = cf_flow:lookup(Username, AccountId), @@ -113,25 +113,25 @@ maybe_presence_parking_flow(Username, Realm, AccountDb) -> end end. --spec presence_parking_slot_resp(ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec presence_parking_slot_resp(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. presence_parking_slot_resp(Username, Realm, AccountDb, SlotNumber) -> cf_park:update_presence(SlotNumber, <>, AccountDb). --spec manual_presence(ne_binary(), ne_binary()) -> 'ok' | 'not_found'. +-spec manual_presence(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | 'not_found'. manual_presence(Username, Realm) -> case kapps_util:get_account_by_realm(Realm) of {'ok', AccountDb} -> check_manual_presence(Username, Realm, AccountDb); _E -> 'not_found' end. --spec check_manual_presence(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec check_manual_presence(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. check_manual_presence(Username, Realm, AccountDb) -> case kz_cache:fetch_local(?CACHE_NAME, ?MANUAL_PRESENCE_KEY(AccountDb)) of {'ok', JObj} -> manual_presence_resp(Username, Realm, JObj); {'error', 'not_found'} -> fetch_manual_presence_doc(Username, Realm, AccountDb) end. --spec fetch_manual_presence_doc(ne_binary(), ne_binary(), ne_binary()) -> 'ok' | 'not_found'. +-spec fetch_manual_presence_doc(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | 'not_found'. fetch_manual_presence_doc(Username, Realm, AccountDb) -> case kz_datamgr:open_doc(AccountDb, ?MANUAL_PRESENCE_DOC) of {'ok', JObj} -> @@ -144,7 +144,7 @@ fetch_manual_presence_doc(Username, Realm, AccountDb) -> {'error', _} -> 'not_found' end. --spec manual_presence_resp(ne_binary(), ne_binary(), kz_json:object()) -> 'ok' | 'not_found'. +-spec manual_presence_resp(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok' | 'not_found'. manual_presence_resp(Username, Realm, JObj) -> PresenceId = <>, case kz_json:get_value(PresenceId, JObj) of @@ -164,13 +164,13 @@ manual_presence_resp(Username, Realm, JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec presence_mwi_query(kz_json:object(), kz_proplist()) -> 'ok'. +-spec presence_mwi_query(kz_json:object(), kz_term:proplist()) -> 'ok'. presence_mwi_query(JObj, _Props) -> 'true' = kapi_presence:mwi_query_v(JObj), _ = kz_util:put_callid(JObj), mwi_query(JObj). --spec notification_register(kz_json:object(), kz_proplist()) -> 'ok'. +-spec notification_register(kz_json:object(), kz_term:proplist()) -> 'ok'. notification_register(JObj, _Props) -> 'true' = kapi_notifications:register_v(JObj), _ = kz_util:put_callid(JObj), @@ -187,7 +187,7 @@ mwi_query(JObj) -> _Else -> 'ok' end. --spec maybe_vm_mwi_resp(api_binary(), ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec maybe_vm_mwi_resp(kz_term:api_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. maybe_vm_mwi_resp('undefined', _Realm, _AccountDb, _JObj) -> 'ok'; maybe_vm_mwi_resp(<<_/binary>> = VMNumber, Realm, AccountDb, JObj) -> case mailbox(AccountDb, VMNumber) of @@ -195,12 +195,12 @@ maybe_vm_mwi_resp(<<_/binary>> = VMNumber, Realm, AccountDb, JObj) -> {'error', _} -> mwi_resp(VMNumber, Realm, AccountDb, JObj) end. --spec vm_mwi_resp(kz_json:object(), ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec vm_mwi_resp(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. vm_mwi_resp(Doc, VMNumber, Realm, JObj) -> {New, Saved} = vm_count(Doc), kz_endpoint:send_mwi_update(New, Saved, VMNumber, Realm, JObj). --spec mwi_resp(ne_binary(), ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec mwi_resp(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. mwi_resp(Username, Realm, AccountDb, JObj) -> case owner_ids_by_sip_username(AccountDb, Username) of {'ok', [<<_/binary>> = OwnerId]} -> @@ -208,7 +208,7 @@ mwi_resp(Username, Realm, AccountDb, JObj) -> _Else -> 'ok' end. --spec mwi_resp(ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec mwi_resp(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. mwi_resp(Username, Realm, OwnerId, AccountDb, JObj) -> {New, Saved} = vm_count_by_owner(AccountDb, OwnerId), kz_endpoint:send_mwi_update(New, Saved, Username, Realm, JObj). @@ -219,14 +219,14 @@ mwi_resp(Username, Realm, OwnerId, AccountDb, JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec unsolicited_owner_mwi_update(api_binary(), api_binary()) -> +-spec unsolicited_owner_mwi_update(kz_term:api_binary(), kz_term:api_binary()) -> 'ok' | {'error', atom()} | kz_datamgr:data_error(). unsolicited_owner_mwi_update(AccountDb, OwnerId) -> kz_endpoint:unsolicited_owner_mwi_update(AccountDb, OwnerId). --spec unsolicited_endpoint_mwi_update(api_binary(), api_binary()) -> +-spec unsolicited_endpoint_mwi_update(kz_term:api_binary(), kz_term:api_binary()) -> 'ok' | {'error', any()}. unsolicited_endpoint_mwi_update(AccountDb, EndpointId) -> kz_endpoint:unsolicited_endpoint_mwi_update(AccountDb, EndpointId). @@ -237,7 +237,7 @@ unsolicited_endpoint_mwi_update(AccountDb, EndpointId) -> %% %% @end %%-------------------------------------------------------------------- --spec alpha_to_dialpad(ne_binary()) -> ne_binary(). +-spec alpha_to_dialpad(kz_term:ne_binary()) -> kz_term:ne_binary(). alpha_to_dialpad(Value) -> << <<(dialpad_digit(C))>> || <> <= kz_term:to_lower_binary(Value), is_alpha(C) >>. @@ -292,8 +292,8 @@ dialpad_digit(WXYZ) when WXYZ =:= $w %% %% @end %%-------------------------------------------------------------------- --spec owner_ids_by_sip_username(ne_binary(), ne_binary()) -> - {'ok', ne_binaries()} | +-spec owner_ids_by_sip_username(kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binaries()} | {'error', any()}. owner_ids_by_sip_username(AccountDb, Username) -> case kz_cache:peek_local(?CACHE_NAME, ?SIP_USER_OWNERS_KEY(AccountDb, Username)) of @@ -302,8 +302,8 @@ owner_ids_by_sip_username(AccountDb, Username) -> get_owner_ids_by_sip_username(AccountDb, Username) end. --spec get_owner_ids_by_sip_username(ne_binary(), ne_binary()) -> - {'ok', ne_binaries()} | +-spec get_owner_ids_by_sip_username(kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binaries()} | {'error', any()}. get_owner_ids_by_sip_username(AccountDb, Username) -> ViewOptions = [{'key', Username}], @@ -325,8 +325,8 @@ get_owner_ids_by_sip_username(AccountDb, Username) -> %% %% @end %%-------------------------------------------------------------------- --spec endpoint_id_by_sip_username(ne_binary(), ne_binary()) -> - {'ok', ne_binary()} | +-spec endpoint_id_by_sip_username(kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | {'error', 'not_found'}. endpoint_id_by_sip_username(AccountDb, Username) -> case kz_cache:peek_local(?CACHE_NAME, ?SIP_ENDPOINT_ID_KEY(AccountDb, Username)) of @@ -335,8 +335,8 @@ endpoint_id_by_sip_username(AccountDb, Username) -> get_endpoint_id_by_sip_username(AccountDb, Username) end. --spec get_endpoint_id_by_sip_username(ne_binary(), ne_binary()) -> - {'ok', ne_binary()} | +-spec get_endpoint_id_by_sip_username(kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | {'error', 'not_found'}. get_endpoint_id_by_sip_username(AccountDb, Username) -> ViewOptions = [{'key', Username}], @@ -357,8 +357,8 @@ get_endpoint_id_by_sip_username(AccountDb, Username) -> %% %% @end %%----------------------------------------------------------------------------- --spec get_operator_callflow(ne_binary()) -> {'ok', kz_json:object()} | - kz_datamgr:data_error(). +-spec get_operator_callflow(kz_term:ne_binary()) -> {'ok', kz_json:object()} | + kz_datamgr:data_error(). get_operator_callflow(Account) -> AccountDb = kz_util:format_account_db(Account), Options = [{'key', ?OPERATOR_KEY} @@ -380,7 +380,7 @@ get_operator_callflow(Account) -> %% certain actions, like cf_offnet and cf_resources %% @end %%-------------------------------------------------------------------- --spec handle_bridge_failure({'fail', kz_json:object()} | api_binary(), kapps_call:call()) -> +-spec handle_bridge_failure({'fail', kz_json:object()} | kz_term:api_binary(), kapps_call:call()) -> 'ok' | 'not_found'. handle_bridge_failure({'fail', Reason}, Call) -> {Cause, Code} = kapps_util:get_call_termination_reason(Reason), @@ -396,7 +396,7 @@ handle_bridge_failure(Failure, Call) -> 'not_found' end. --spec handle_bridge_failure(api_binary(), api_binary(), kapps_call:call()) -> +-spec handle_bridge_failure(kz_term:api_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok' | 'not_found'. handle_bridge_failure(Cause, Code, Call) -> lager:info("attempting to find failure branch for ~s:~s", [Code, Cause]), @@ -413,7 +413,7 @@ handle_bridge_failure(Cause, Code, Call) -> %% Send and wait for a call failure cause response %% @end %%-------------------------------------------------------------------- --spec send_default_response(ne_binary(), kapps_call:call()) -> 'ok'. +-spec send_default_response(kz_term:ne_binary(), kapps_call:call()) -> 'ok'. send_default_response(Cause, Call) -> case cf_exe:wildcard_is_empty(Call) of 'false' -> lager:debug("non-empty wildcard; not sending ~s", [Cause]); @@ -427,7 +427,7 @@ send_default_response(Cause, Call) -> end end. --spec apply_dialplan(ne_binary(), api_object()) -> ne_binary(). +-spec apply_dialplan(kz_term:ne_binary(), kz_term:api_object()) -> kz_term:ne_binary(). apply_dialplan(N, 'undefined') -> N; apply_dialplan(Number, DialPlan) -> Regexs = kz_json:get_keys(DialPlan), @@ -436,7 +436,7 @@ apply_dialplan(Number, DialPlan) -> _ -> maybe_apply_dialplan(Regexs, DialPlan, Number) end. --spec maybe_apply_dialplan(kz_json:path(), kz_json:object(), ne_binary()) -> ne_binary(). +-spec maybe_apply_dialplan(kz_json:path(), kz_json:object(), kz_term:ne_binary()) -> kz_term:ne_binary(). maybe_apply_dialplan([], _, Number) -> Number; maybe_apply_dialplan([<<"system">>], DialPlan, Number) -> SystemDialPlans = load_system_dialplans(kz_json:get_value(<<"system">>, DialPlan)), @@ -450,7 +450,7 @@ maybe_apply_dialplan([Key|_]=Keys, DialPlan, Number) -> Regex -> apply_dialplan(Regex, Keys, DialPlan, Number) end. --spec apply_dialplan(ne_binary(), kz_json:path(), kz_json:object(), ne_binary()) -> ne_binary(). +-spec apply_dialplan(kz_term:ne_binary(), kz_json:path(), kz_json:object(), kz_term:ne_binary()) -> kz_term:ne_binary(). apply_dialplan(Regex, [Key|Keys], DialPlan, Number) -> case re:run(Number, Regex, [{'capture', 'all', 'binary'}]) of 'nomatch' -> @@ -470,14 +470,14 @@ apply_dialplan(Regex, [Key|Keys], DialPlan, Number) -> end end. --spec load_system_dialplans(ne_binaries()) -> kz_json:object(). +-spec load_system_dialplans(kz_term:ne_binaries()) -> kz_json:object(). load_system_dialplans(Names) -> LowerNames = [kz_term:to_lower_binary(Name) || Name <- Names], Plans = kapps_config:get_all_kvs(<<"dialplans">>), lists:foldl(fold_system_dialplans(LowerNames), kz_json:new(), Plans). --spec fold_system_dialplans(ne_binaries()) -> - fun(({ne_binary(), kz_json:object()}, kz_json:object()) -> kz_json:object()). +-spec fold_system_dialplans(kz_term:ne_binaries()) -> + fun(({kz_term:ne_binary(), kz_json:object()}, kz_json:object()) -> kz_json:object()). fold_system_dialplans(Names) -> fun({Key, Val}, Acc) when is_list(Val) -> lists:foldl(fun(ValElem, A) -> maybe_dialplan_suits({Key, ValElem}, A, Names) end, Acc, Val); @@ -485,7 +485,7 @@ fold_system_dialplans(Names) -> maybe_dialplan_suits({Key, Val}, Acc, Names) end. --spec maybe_dialplan_suits({ne_binary(), kz_json:object()} ,kz_json:object(), ne_binaries()) -> kz_json:object(). +-spec maybe_dialplan_suits({kz_term:ne_binary(), kz_json:object()} ,kz_json:object(), kz_term:ne_binaries()) -> kz_json:object(). maybe_dialplan_suits({Key, Val}=KV, Acc, Names) -> Name = kz_term:to_lower_binary(kz_json:get_value(<<"name">>, Val)), case lists:member(Name, Names) of @@ -493,7 +493,7 @@ maybe_dialplan_suits({Key, Val}=KV, Acc, Names) -> 'false' -> maybe_system_dialplan_name(KV, Acc, Names) end. --spec maybe_system_dialplan_name({ne_binary(), kz_json:object()} ,kz_json:object(), ne_binaries()) -> kz_json:object(). +-spec maybe_system_dialplan_name({kz_term:ne_binary(), kz_json:object()} ,kz_json:object(), kz_term:ne_binaries()) -> kz_json:object(). maybe_system_dialplan_name({Key, Val}, Acc, Names) -> Name = kz_term:to_lower_binary(Key), case lists:member(Name, Names) of @@ -503,7 +503,7 @@ maybe_system_dialplan_name({Key, Val}, Acc, Names) -> 'false' -> Acc end. --spec index_of(ne_binary(), list()) -> api_integer(). +-spec index_of(kz_term:ne_binary(), list()) -> kz_term:api_integer(). index_of(Value, List) -> Map = lists:zip(List, lists:seq(1, length(List))), case dict:find(Value, dict:from_list(Map)) of @@ -526,23 +526,23 @@ start_event_listener(Call, Mod, Args) -> {'error', _R} end. --spec event_listener_name(kapps_call:call(), atom() | ne_binary()) -> ne_binary(). +-spec event_listener_name(kapps_call:call(), atom() | kz_term:ne_binary()) -> kz_term:ne_binary(). event_listener_name(Call, Module) -> <<(kapps_call:call_id_direct(Call))/binary, "-", (kz_term:to_binary(Module))/binary>>. --spec caller_belongs_to_group(ne_binary(), kapps_call:call()) -> boolean(). +-spec caller_belongs_to_group(kz_term:ne_binary(), kapps_call:call()) -> boolean(). caller_belongs_to_group(GroupId, Call) -> maybe_belongs_to_group(kapps_call:authorizing_id(Call), GroupId, Call). --spec maybe_belongs_to_group(ne_binary(), ne_binary(), kapps_call:call()) -> boolean(). +-spec maybe_belongs_to_group(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> boolean(). maybe_belongs_to_group(TargetId, GroupId, Call) -> lists:member(TargetId, find_group_endpoints(GroupId, Call)). --spec caller_belongs_to_user(ne_binary(), kapps_call:call()) -> boolean(). +-spec caller_belongs_to_user(kz_term:ne_binary(), kapps_call:call()) -> boolean(). caller_belongs_to_user(UserId, Call) -> lists:member(kapps_call:authorizing_id(Call), find_user_endpoints([UserId],[],Call)). --spec find_group_endpoints(ne_binary(), kapps_call:call()) -> ne_binaries(). +-spec find_group_endpoints(kz_term:ne_binary(), kapps_call:call()) -> kz_term:ne_binaries(). find_group_endpoints(GroupId, Call) -> GroupsJObj = kz_attributes:groups(Call), case [kz_json:get_value(<<"value">>, JObj) @@ -556,8 +556,8 @@ find_group_endpoints(GroupId, Call) -> find_endpoints(Ids, GroupEndpoints, Call) end. --spec find_endpoints(ne_binaries(), kz_json:object(), kapps_call:call()) -> - ne_binaries(). +-spec find_endpoints(kz_term:ne_binaries(), kz_json:object(), kapps_call:call()) -> + kz_term:ne_binaries(). find_endpoints(Ids, GroupEndpoints, Call) -> {DeviceIds, UserIds} = lists:partition(fun(Id) -> @@ -565,14 +565,14 @@ find_endpoints(Ids, GroupEndpoints, Call) -> end, Ids), find_user_endpoints(UserIds, lists:sort(DeviceIds), Call). --spec find_user_endpoints(ne_binaries(), ne_binaries(), kapps_call:call()) -> - ne_binaries(). +-spec find_user_endpoints(kz_term:ne_binaries(), kz_term:ne_binaries(), kapps_call:call()) -> + kz_term:ne_binaries(). find_user_endpoints([], DeviceIds, _) -> DeviceIds; find_user_endpoints(UserIds, DeviceIds, Call) -> UserDeviceIds = kz_attributes:owned_by(UserIds, <<"device">>, Call), lists:merge(lists:sort(UserDeviceIds), DeviceIds). --spec find_channels(ne_binaries(), kapps_call:call()) -> kz_json:objects(). +-spec find_channels(kz_term:ne_binaries(), kapps_call:call()) -> kz_json:objects(). find_channels(Usernames, Call) -> Realm = kz_account:fetch_realm(kapps_call:account_id(Call)), lager:debug("finding channels for realm ~p, usernames ~p", [Realm, Usernames]), @@ -591,7 +591,7 @@ find_channels(Usernames, Call) -> [] end. --spec check_value_of_fields(kz_proplist(), boolean(), kz_json:object(), kapps_call:call()) -> +-spec check_value_of_fields(kz_term:proplist(), boolean(), kz_json:object(), kapps_call:call()) -> boolean(). check_value_of_fields(Perms, Def, Data, Call) -> case lists:dropwhile(fun({K, _F}) -> @@ -604,22 +604,22 @@ check_value_of_fields(Perms, Def, Data, Call) -> [{K, F}|_] -> F(kz_json:get_value(K, Data), Call) end. --spec sip_users_from_device_ids(ne_binaries(), kapps_call:call()) -> ne_binaries(). +-spec sip_users_from_device_ids(kz_term:ne_binaries(), kapps_call:call()) -> kz_term:ne_binaries(). sip_users_from_device_ids(EndpointIds, Call) -> lists:foldl(fun(EID, Acc) -> sip_users_from_device_id(EID, Acc, Call) end ,[] ,EndpointIds ). --spec sip_users_from_device_id(ne_binary(), ne_binaries(), kapps_call:call()) -> - ne_binaries(). +-spec sip_users_from_device_id(kz_term:ne_binary(), kz_term:ne_binaries(), kapps_call:call()) -> + kz_term:ne_binaries(). sip_users_from_device_id(EndpointId, Acc, Call) -> case sip_user_from_device_id(EndpointId, Call) of 'undefined' -> Acc; Username -> [Username|Acc] end. --spec sip_user_from_device_id(ne_binary(), kapps_call:call()) -> api_binary(). +-spec sip_user_from_device_id(kz_term:ne_binary(), kapps_call:call()) -> kz_term:api_binary(). sip_user_from_device_id(EndpointId, Call) -> case kz_endpoint:get(EndpointId, Call) of {'error', _} -> 'undefined'; @@ -627,7 +627,7 @@ sip_user_from_device_id(EndpointId, Call) -> kz_device:sip_username(Endpoint) end. --spec wait_for_noop(kapps_call:call(), ne_binary()) -> +-spec wait_for_noop(kapps_call:call(), kz_term:ne_binary()) -> {'ok', kapps_call:call()} | {'error', 'channel_hungup' | kz_json:object()}. wait_for_noop(Call, NoopId) -> @@ -639,7 +639,7 @@ wait_for_noop(Call, NoopId) -> {'ok', Call} end. --spec process_event(kapps_call:call(), ne_binary(), kz_json:object()) -> +-spec process_event(kapps_call:call(), kz_term:ne_binary(), kz_json:object()) -> {'ok', kapps_call:call()} | {'error', any()}. process_event(Call, NoopId, JObj) -> @@ -672,7 +672,7 @@ process_event(Call, NoopId, JObj) -> wait_for_noop(Call, NoopId) end. --spec get_timezone(kz_json:object(), kapps_call:call()) -> ne_binary(). +-spec get_timezone(kz_json:object(), kapps_call:call()) -> kz_term:ne_binary(). get_timezone(JObj, Call) -> case kz_json:get_ne_binary_value(<<"timezone">>, JObj) of 'undefined' -> kz_account:timezone(kapps_call:account_id(Call)); @@ -690,8 +690,8 @@ start_task(Fun, Args, Call) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec mailbox(ne_binary(), ne_binary()) -> {'ok', kz_json:object()} | - {'error', any()}. +-spec mailbox(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | + {'error', any()}. mailbox(AccountDb, VMNumber) -> try kz_term:to_integer(VMNumber) of Number -> maybe_cached_mailbox(AccountDb, Number) @@ -699,16 +699,16 @@ mailbox(AccountDb, VMNumber) -> _E:_R -> {'error', 'not_found'} end. --spec maybe_cached_mailbox(ne_binary(), integer()) -> {'ok', kz_json:object()} | - {'error', any()}. +-spec maybe_cached_mailbox(kz_term:ne_binary(), integer()) -> {'ok', kz_json:object()} | + {'error', any()}. maybe_cached_mailbox(AccountDb, VMNumber) -> case kz_cache:peek_local(?CACHE_NAME, ?VM_CACHE_KEY(AccountDb, VMNumber)) of {'ok', _}=Ok -> Ok; {'error', 'not_found'} -> get_mailbox(AccountDb, VMNumber) end. --spec get_mailbox(ne_binary(), integer()) -> {'ok', kz_json:object()} | - {'error', any()}. +-spec get_mailbox(kz_term:ne_binary(), integer()) -> {'ok', kz_json:object()} | + {'error', any()}. get_mailbox(AccountDb, VMNumber) -> ViewOptions = [{'key', VMNumber}, 'include_docs'], case kz_datamgr:get_single_result(AccountDb, <<"vmboxes/listing_by_mailbox">>, ViewOptions) of @@ -737,7 +737,7 @@ vm_count(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec vm_count_by_owner(ne_binary(), ne_binary()) -> {non_neg_integer(), non_neg_integer()}. +-spec vm_count_by_owner(kz_term:ne_binary(), kz_term:ne_binary()) -> {non_neg_integer(), non_neg_integer()}. vm_count_by_owner(<<_/binary>> = AccountDb, <<_/binary>> = OwnerId) -> kvm_messages:count_by_owner(AccountDb, OwnerId). diff --git a/applications/callflow/src/module/cf_after_bridge.erl b/applications/callflow/src/module/cf_after_bridge.erl index 596c2db1ab7..492b715c8fc 100644 --- a/applications/callflow/src/module/cf_after_bridge.erl +++ b/applications/callflow/src/module/cf_after_bridge.erl @@ -34,7 +34,7 @@ handle(Data, Call) -> kapps_call_command:set(Action, kz_json:new(), Call), cf_exe:continue(Call). --spec build_action(ne_binary(), ne_binary()) -> kz_json:object(). +-spec build_action(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). build_action(<<"park">>, ShouldPark) -> kz_json:from_list([{<<"Park-After-Pickup">>, kz_term:is_true(ShouldPark)}]); build_action(<<"hangup">>, ShouldHangup) -> diff --git a/applications/callflow/src/module/cf_branch_variable.erl b/applications/callflow/src/module/cf_branch_variable.erl index cd840b8636f..650b642ad16 100644 --- a/applications/callflow/src/module/cf_branch_variable.erl +++ b/applications/callflow/src/module/cf_branch_variable.erl @@ -24,7 +24,7 @@ -export([handle/2]). --type variable_key() :: api_ne_binary() | api_ne_binaries(). +-type variable_key() :: kz_term:api_ne_binary() | kz_term:api_ne_binaries(). %%-------------------------------------------------------------------- %% @public @@ -56,7 +56,7 @@ maybe_branch_to_named_child(ChildName, Call) -> %% user and device, it search in merged attributes in endpoint. %% @end %%-------------------------------------------------------------------- --spec find_child_in_scope(ne_binary(), variable_key(), kapps_call:call()) -> api_binary(). +-spec find_child_in_scope(kz_term:ne_binary(), variable_key(), kapps_call:call()) -> kz_term:api_binary(). find_child_in_scope(_Scope, 'undefined', _Call) -> lager:warning("no variable is specified"), 'undefined'; @@ -101,7 +101,7 @@ find_child_in_scope(<<"merged">>, Variable, Call) -> %% name of the callflow branch. %% @end %%-------------------------------------------------------------------- --spec find_child_in_doc(api_binary(), ne_binary(), kapps_call:call()) -> api_binary(). +-spec find_child_in_doc(kz_term:api_binary(), kz_term:ne_binary(), kapps_call:call()) -> kz_term:api_binary(). find_child_in_doc('undefined', _Variable, _Call) -> lager:debug("could not find document for current scope"), 'undefined'; @@ -122,12 +122,12 @@ find_child_in_doc(DocId, Variable, Call) -> %% fall back to the default children '_'. %% @end %%-------------------------------------------------------------------- --spec find_child_in_branch(any(), kapps_call:call()) -> api_binary(). +-spec find_child_in_branch(any(), kapps_call:call()) -> kz_term:api_binary(). find_child_in_branch(ChildName, Call) -> {'branch_keys', Keys} = cf_exe:get_branch_keys(Call), find_child_in_branch(ChildName, Call, Keys). --spec find_child_in_branch(any(), kapps_call:call(), kz_json:paths()) -> api_binary(). +-spec find_child_in_branch(any(), kapps_call:call(), kz_json:paths()) -> kz_term:api_binary(). find_child_in_branch('undefined', _Call, _Keys) -> 'undefined'; find_child_in_branch(?NE_BINARY = ChildName, _Call, Keys) -> case lists:member(ChildName, Keys) of @@ -146,7 +146,7 @@ find_child_in_branch(ChildName, Call, Keys) -> %% Utility Funcations --spec device_owner(kapps_call:call()) -> ne_binary(). +-spec device_owner(kapps_call:call()) -> kz_term:ne_binary(). device_owner(Call) -> DeviceId = kapps_call:authorizing_id(Call), case kz_datamgr:open_cache_doc(kapps_call:account_db(Call), DeviceId) of diff --git a/applications/callflow/src/module/cf_call_forward.erl b/applications/callflow/src/module/cf_call_forward.erl index 2aed45a907e..88a0b86097f 100644 --- a/applications/callflow/src/module/cf_call_forward.erl +++ b/applications/callflow/src/module/cf_call_forward.erl @@ -25,15 +25,15 @@ -record(keys, {menu_toggle_cf = kapps_config:get_ne_binary(?MOD_CONFIG_CAT, [<<"keys">>, <<"menu_toggle_option">>], <<"1">>) - :: ne_binary() + :: kz_term:ne_binary() ,menu_change_number = kapps_config:get_ne_binary(?MOD_CONFIG_CAT, [<<"keys">>, <<"menu_change_number">>], <<"2">>) - :: ne_binary() + :: kz_term:ne_binary() }). -type keys() :: #keys{}. -record(callfwd, {keys = #keys{} :: keys() - ,doc_id :: api_ne_binary() + ,doc_id :: kz_term:api_ne_binary() ,enabled = 'false' :: boolean() ,number = <<>> :: binary() ,require_keypress = 'true' :: boolean() @@ -80,7 +80,7 @@ handle(Data, Call) -> %% This function provides a menu with the call forwarding options %% @end %%-------------------------------------------------------------------- --spec cf_menu(callfwd(), ne_binary(), kapps_call:call()) -> callfwd(). +-spec cf_menu(callfwd(), kz_term:ne_binary(), kapps_call:call()) -> callfwd(). cf_menu(#callfwd{keys=#keys{menu_toggle_cf=Toggle ,menu_change_number=ChangeNum } @@ -124,7 +124,7 @@ cf_menu(#callfwd{keys=#keys{menu_toggle_cf=Toggle %% not, and disabling it if it is %% @end %%-------------------------------------------------------------------- --spec cf_toggle(callfwd(), api_binary(), kapps_call:call()) -> callfwd(). +-spec cf_toggle(callfwd(), kz_term:api_binary(), kapps_call:call()) -> callfwd(). cf_toggle(#callfwd{enabled='false' ,number=Number }=CF, _, Call) when is_binary(Number), Number =/= <<>> -> @@ -147,7 +147,7 @@ cf_toggle(CF, _, Call) -> %% document to enable call forwarding %% @end %%-------------------------------------------------------------------- --spec cf_activate(callfwd(), api_binary(), kapps_call:call()) -> callfwd(). +-spec cf_activate(callfwd(), kz_term:api_binary(), kapps_call:call()) -> callfwd(). cf_activate(CF1, CaptureGroup, Call) when is_atom(CaptureGroup); CaptureGroup =:= <<>> -> lager:info("activating call forwarding to '~s'", [CaptureGroup]), CF2 = #callfwd{number=Number} = cf_update_number(CF1, CaptureGroup, Call), @@ -188,7 +188,7 @@ cf_deactivate(CF, Call) -> %% document with a new number %% @end %%-------------------------------------------------------------------- --spec cf_update_number(callfwd(), api_binary(), kapps_call:call()) -> callfwd(). +-spec cf_update_number(callfwd(), kz_term:api_binary(), kapps_call:call()) -> callfwd(). cf_update_number(#callfwd{interdigit_timeout=Interdigit}=CF, CaptureGroup, Call) when is_atom(CaptureGroup); CaptureGroup =:= <<>> -> EnterNumber = kapps_call:get_prompt(Call, <<"cf-enter_number">>), @@ -226,7 +226,7 @@ cf_update_number(CF, CaptureGroup, _) -> %% @end %%-------------------------------------------------------------------- -spec update_callfwd(callfwd(), kapps_call:call()) -> - {'ok', api_object()} | + {'ok', kz_term:api_object()} | {'error', atom()}. update_callfwd('undefined', _Call) -> {'ok', 'undefined'}; update_callfwd(#callfwd{doc_id=Id @@ -275,7 +275,7 @@ get_call_forward(Call) -> end, maybe_get_call_forward(Call, OwnerId). --spec maybe_get_call_forward(kapps_call:call(), api_binary()) -> +-spec maybe_get_call_forward(kapps_call:call(), kz_term:api_binary()) -> callfwd() | {'error', callfwd()}. maybe_get_call_forward(_Call, 'undefined') -> diff --git a/applications/callflow/src/module/cf_call_waiting.erl b/applications/callflow/src/module/cf_call_waiting.erl index 1ce7ae2311a..2d6120c317b 100644 --- a/applications/callflow/src/module/cf_call_waiting.erl +++ b/applications/callflow/src/module/cf_call_waiting.erl @@ -23,13 +23,13 @@ -record(call_waiting, {enabled = 'true' :: boolean() ,jobj = kz_json:new() :: kz_json:object() - ,account_db :: api_binary() - ,action :: ne_binary() + ,account_db :: kz_term:api_binary() + ,action :: kz_term:ne_binary() }). -type call_waiting() :: #call_waiting{}. -type switch_fun() :: fun((boolean()) -> boolean()). --spec actions() -> kz_proplist_kv(ne_binary(), switch_fun()). +-spec actions() -> kz_term:proplist_kv(kz_term:ne_binary(), switch_fun()). actions() -> [{<<"toggle">>, fun (Enabled) -> not Enabled end} ,{<<"activate">>, fun (_Enabled) -> 'true' end} @@ -75,13 +75,13 @@ maybe_build_call_waiting_record(Data, Call) -> } end. --spec get_doc_id(ne_binary(), kapps_call:call()) -> api_binary(). +-spec get_doc_id(kz_term:ne_binary(), kapps_call:call()) -> kz_term:api_binary(). get_doc_id(<<"user">>, Call) -> kapps_call:owner_id(Call); get_doc_id(<<"device">>, Call) -> kapps_call:authorizing_id(Call). --spec maybe_get_doc(api_binary(), api_binary()) -> kz_jobj_return(). +-spec maybe_get_doc(kz_term:api_binary(), kz_term:api_binary()) -> kz_term:jobj_return(). maybe_get_doc(_, 'undefined') -> {'error', 'no_device_id'}; maybe_get_doc('undefined', _) -> diff --git a/applications/callflow/src/module/cf_camping_feature.erl b/applications/callflow/src/module/cf_camping_feature.erl index fe21d1cd842..c61c85d071a 100644 --- a/applications/callflow/src/module/cf_camping_feature.erl +++ b/applications/callflow/src/module/cf_camping_feature.erl @@ -35,9 +35,9 @@ -record(state, {callflow :: kz_json:object() ,is_no_match :: boolean() - ,id :: api_ne_binary() - ,type :: api_ne_binary() - ,number :: ne_binary() + ,id :: kz_term:api_ne_binary() + ,type :: kz_term:api_ne_binary() + ,number :: kz_term:ne_binary() ,channels = [] :: kz_json:objects() ,config :: kz_json:object() }). @@ -153,8 +153,8 @@ handle(Data, Call) -> cf_exe:stop(Call) end. --spec get_sip_usernames_for_target(ne_binary(), ne_binary(), kapps_call:call()) -> - ne_binaries(). +-spec get_sip_usernames_for_target(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> + kz_term:ne_binaries(). get_sip_usernames_for_target(TargetId, TargetType, Call) -> Targets = case TargetType of <<"user">> -> kz_attributes:owned_by(TargetId, <<"device">>, Call); @@ -170,7 +170,7 @@ get_sip_usernames_for_target(TargetId, TargetType, Call) -> 'undefined' =/= SIPUsername ]. --spec get_device_sip_username(ne_binary(), ne_binary()) -> api_ne_binary(). +-spec get_device_sip_username(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_ne_binary(). get_device_sip_username(AccountDb, DeviceId) -> {'ok', JObj} = kz_datamgr:open_cache_doc(AccountDb, DeviceId), kz_device:sip_username(JObj). diff --git a/applications/callflow/src/module/cf_check_cid.erl b/applications/callflow/src/module/cf_check_cid.erl index 0f698037e53..77b166b7a32 100644 --- a/applications/callflow/src/module/cf_check_cid.erl +++ b/applications/callflow/src/module/cf_check_cid.erl @@ -65,14 +65,14 @@ handle(Data, Call) -> %% Handle a caller id "match" condition %% @end %%-------------------------------------------------------------------- --spec handle_match(kz_json:object(), kapps_call:call(), ne_binary()) -> 'ok'. +-spec handle_match(kz_json:object(), kapps_call:call(), kz_term:ne_binary()) -> 'ok'. handle_match(Data, Call, CallerIdNumber) -> case kz_json:is_true(<<"use_absolute_mode">>, Data, 'false') of 'true' -> maybe_branch_on_caller_id(Data, Call, CallerIdNumber); 'false' -> maybe_branch_on_regex(Data, Call) end. --spec maybe_branch_on_caller_id(kz_json:object(), kapps_call:call(), ne_binary()) -> 'ok'. +-spec maybe_branch_on_caller_id(kz_json:object(), kapps_call:call(), kz_term:ne_binary()) -> 'ok'. maybe_branch_on_caller_id(Data, Call, CallerIdNumber) -> case is_callflow_child(CallerIdNumber, Call) of 'true' -> update_caller_identity(Data, Call); @@ -105,7 +105,7 @@ handle_no_match(Call) -> %% Check if the given node name is a callflow child %% @end %%-------------------------------------------------------------------- --spec is_callflow_child(ne_binary(), kapps_call:call()) -> boolean(). +-spec is_callflow_child(kz_term:ne_binary(), kapps_call:call()) -> boolean(). is_callflow_child(Name, Call) -> lager:debug("Looking for callflow child ~s", [Name]), case cf_exe:attempt(Name, Call) of @@ -145,7 +145,7 @@ update_caller_identity(Data, Call) -> %% @doc validate that all required parameters are defined %% @end %%-------------------------------------------------------------------- --spec is_valid_caller_identity(api_binary(), api_binary(), api_binary()) -> boolean(). +-spec is_valid_caller_identity(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary()) -> boolean(). is_valid_caller_identity('undefined', _Number, _UserId) -> 'false'; is_valid_caller_identity(_Name, 'undefined', _UserId) -> 'false'; is_valid_caller_identity(_Name, _Number, 'undefined') -> 'false'; diff --git a/applications/callflow/src/module/cf_cidlistmatch.erl b/applications/callflow/src/module/cf_cidlistmatch.erl index ce97527786a..1be5c57e3d1 100644 --- a/applications/callflow/src/module/cf_cidlistmatch.erl +++ b/applications/callflow/src/module/cf_cidlistmatch.erl @@ -42,7 +42,7 @@ handle(Data, Call) -> 'false' -> handle_no_match(Call) end. --spec is_matching_prefix(ne_binary(), ne_binary(), ne_binary()) -> boolean(). +-spec is_matching_prefix(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_matching_prefix(AccountDb, ListId, Number) -> NumberPrefixes = build_keys(Number), Keys = [[ListId, X] || X <- NumberPrefixes], @@ -51,7 +51,7 @@ is_matching_prefix(AccountDb, ListId, Number) -> _ -> 'false' end. --spec is_matching_regexp(ne_binary(), ne_binary(), ne_binary()) -> boolean(). +-spec is_matching_regexp(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_matching_regexp(AccountDb, ListId, Number) -> case kz_datamgr:get_results(AccountDb, <<"lists/regexps_in_list">>, [{'key', ListId}]) of {'ok', Regexps} -> @@ -61,7 +61,7 @@ is_matching_regexp(AccountDb, ListId, Number) -> 'false' end. --spec match_regexps(binaries(), ne_binary()) -> boolean(). +-spec match_regexps(kz_term:binaries(), kz_term:ne_binary()) -> boolean(). match_regexps([Pattern | Rest], Number) -> case re:run(Number, Pattern) of {'match', _} -> 'true'; @@ -70,13 +70,13 @@ match_regexps([Pattern | Rest], Number) -> match_regexps([], _Number) -> 'false'. %% TODO: this function from hon_util, may be place it somewhere in library? --spec build_keys(binary()) -> binaries(). +-spec build_keys(binary()) -> kz_term:binaries(). build_keys(<<"+", E164/binary>>) -> build_keys(E164); build_keys(<>) -> build_keys(Rest, D, [D]). --spec build_keys(binary(), binary(), binaries()) -> binaries(). +-spec build_keys(binary(), binary(), kz_term:binaries()) -> kz_term:binaries(). build_keys(<>, Prefix, Acc) -> build_keys(Rest, <>, [<> | Acc]); build_keys(<<>>, _, Acc) -> Acc. @@ -113,7 +113,7 @@ handle_no_match(Call) -> %% Check if the given node name is a callflow child %% @end %%-------------------------------------------------------------------- --spec is_callflow_child(ne_binary(), kapps_call:call()) -> boolean(). +-spec is_callflow_child(kz_term:ne_binary(), kapps_call:call()) -> boolean(). is_callflow_child(Name, Call) -> lager:debug("Looking for callflow child ~s", [Name]), case cf_exe:attempt(Name, Call) of diff --git a/applications/callflow/src/module/cf_collect_dtmf.erl b/applications/callflow/src/module/cf_collect_dtmf.erl index 43e8e31e769..a76b96c1b24 100644 --- a/applications/callflow/src/module/cf_collect_dtmf.erl +++ b/applications/callflow/src/module/cf_collect_dtmf.erl @@ -83,7 +83,7 @@ collect_more_digits(Data, Call, AlreadyCollected, MaxDigits) -> lager:debug("failed to collect DTMF: ~p", [_E]) end. --spec truncate_after_terminator(binary(), ne_binaries()) -> binary(). +-spec truncate_after_terminator(binary(), kz_term:ne_binaries()) -> binary(). truncate_after_terminator(AlreadyCollected, Terminators) -> hd(binary:split(AlreadyCollected, Terminators)). @@ -97,7 +97,7 @@ truncate_after_terminator_test_() -> ]. -endif. --spec collection_name(kz_json:object()) -> ne_binary(). +-spec collection_name(kz_json:object()) -> kz_term:ne_binary(). collection_name(Data) -> case kz_json:get_value(<<"collection_name">>, Data) of <<_/binary>> = Name -> Name; @@ -125,7 +125,7 @@ interdigit(Data) -> N when N > 0 -> N end. --spec terminators(kz_json:object()) -> ne_binaries(). +-spec terminators(kz_json:object()) -> kz_term:ne_binaries(). terminators(Data) -> case kz_json:get_first_defined([<<"terminator">>, <<"terminators">>], Data) of 'undefined' -> [<<"#">>]; diff --git a/applications/callflow/src/module/cf_directory.erl b/applications/callflow/src/module/cf_directory.erl index cfc722df032..1720bb12f94 100644 --- a/applications/callflow/src/module/cf_directory.erl +++ b/applications/callflow/src/module/cf_directory.erl @@ -74,13 +74,13 @@ %%------------------------------------------------------------------------------ %% Records %%------------------------------------------------------------------------------ --record(directory_user, {first_name :: ne_binary() - ,last_name :: ne_binary() - ,full_name :: ne_binary() - ,first_last_keys :: ne_binary() % DTMF-version of first, last - ,last_first_keys :: ne_binary() % DTMF-version of last, first - ,callflow_id :: ne_binary() % what callflow to use on match - ,name_audio_id :: api_binary() % pre-recorded audio of user's name +-record(directory_user, {first_name :: kz_term:ne_binary() + ,last_name :: kz_term:ne_binary() + ,full_name :: kz_term:ne_binary() + ,first_last_keys :: kz_term:ne_binary() % DTMF-version of first, last + ,last_first_keys :: kz_term:ne_binary() % DTMF-version of last, first + ,callflow_id :: kz_term:ne_binary() % what callflow to use on match + ,name_audio_id :: kz_term:api_binary() % pre-recorded audio of user's name }). -type directory_user() :: #directory_user{}. -type directory_users() :: [directory_user()]. @@ -250,7 +250,7 @@ maybe_match_user(Call, U, MatchNum, Loop) -> cf_exe:stop(Call) end. --spec interpret_user_match_dtmf(ne_binary()) -> dtmf_action(). +-spec interpret_user_match_dtmf(kz_term:ne_binary()) -> dtmf_action(). interpret_user_match_dtmf(?DTMF_RESULT_CONNECT) -> 'route'; interpret_user_match_dtmf(?DTMF_RESULT_NEXT) -> 'next'; interpret_user_match_dtmf(?DTMF_RESULT_START) -> 'start_over'; @@ -282,7 +282,7 @@ play_user(Call, UsernameTuple, _MatchNum) -> ,{'prompt', ?PROMPT_RESULT_MENU} ]). --spec play_invalid(kapps_call:call()) -> ne_binary(). +-spec play_invalid(kapps_call:call()) -> kz_term:ne_binary(). play_invalid(Call) -> kapps_call_command:audio_macro([{'prompt', ?PROMPT_INVALID_KEY}], Call). @@ -305,7 +305,7 @@ username_audio_macro(Call, User) -> MediaID -> maybe_play_media(Call, User, MediaID) end. --spec maybe_play_media(kapps_call:call(), directory_user(), api_binary()) -> +-spec maybe_play_media(kapps_call:call(), directory_user(), kz_term:api_binary()) -> kapps_call_command:audio_macro_prompt(). maybe_play_media(Call, User, MediaId) -> AccountDb = kapps_call:account_db(Call), @@ -319,7 +319,7 @@ maybe_play_media(Call, User, MediaId) -> {'error', _} -> {'tts', <<39, (full_name(User))/binary, 39>>} end. --spec play_directory_instructions(kapps_call:call(), 'first' | 'last' | ne_binary()) -> +-spec play_directory_instructions(kapps_call:call(), 'first' | 'last' | kz_term:ne_binary()) -> {'ok', binary()} | {'error', atom()}. play_directory_instructions(Call, 'first') -> @@ -327,11 +327,11 @@ play_directory_instructions(Call, 'first') -> play_directory_instructions(Call, 'last') -> play_and_collect(Call, [{'prompt', ?PROMPT_ENTER_PERSON_LASTNAME}]). --spec play_no_users(kapps_call:call()) -> ne_binary(). % noop id +-spec play_no_users(kapps_call:call()) -> kz_term:ne_binary(). % noop id play_no_users(Call) -> kapps_call_command:audio_macro([{'prompt', ?PROMPT_NO_MORE_RESULTS}], Call). --spec play_no_users_found(kapps_call:call()) -> ne_binary(). % noop id +-spec play_no_users_found(kapps_call:call()) -> kz_term:ne_binary(). % noop id play_no_users_found(Call) -> kapps_call_command:audio_macro([{'prompt', ?PROMPT_NO_RESULTS_FOUND}], Call). @@ -385,11 +385,11 @@ media_name(#directory_user{name_audio_id = ID}) -> ID. %%------------------------------------------------------------------------------ %% Utility Functions %%------------------------------------------------------------------------------ --spec get_sort_by(ne_binary()) -> 'first' | 'last'. +-spec get_sort_by(kz_term:ne_binary()) -> 'first' | 'last'. get_sort_by(<<"first", _/binary>>) -> 'first'; get_sort_by(_) -> 'last'. --spec get_directory_listing(ne_binary(), ne_binary()) -> +-spec get_directory_listing(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', directory_users()} | {'error', any()}. get_directory_listing(Db, DirId) -> @@ -405,7 +405,7 @@ get_directory_listing(Db, DirId) -> E end. --spec get_directory_user(kz_json:object(), ne_binary()) -> directory_user(). +-spec get_directory_user(kz_json:object(), kz_term:ne_binary()) -> directory_user(). get_directory_user(U, CallflowId) -> First = kz_json:get_value(<<"first_name">>, U), Last = kz_json:get_value(<<"last_name">>, U), @@ -421,7 +421,7 @@ get_directory_user(U, CallflowId) -> }. --spec filter_users(directory_users(), ne_binary(), 'last' | 'first') -> directory_users(). +-spec filter_users(directory_users(), kz_term:ne_binary(), 'last' | 'first') -> directory_users(). filter_users(Users, DTMFs, 'last') -> lager:info("filtering users by ~s", [DTMFs]), Size = byte_size(DTMFs), @@ -457,7 +457,7 @@ filter_users(Users, DTMFs, 'first') -> ) ). --spec maybe_dtmf_matches(ne_binary(), pos_integer(), ne_binary()) -> boolean(). +-spec maybe_dtmf_matches(kz_term:ne_binary(), pos_integer(), kz_term:ne_binary()) -> boolean(). maybe_dtmf_matches(_, 0, _) -> 'false'; maybe_dtmf_matches(_, Size, User) when byte_size(User) < Size -> 'false'; maybe_dtmf_matches(DTMFs, Size, User) -> diff --git a/applications/callflow/src/module/cf_disa.erl b/applications/callflow/src/module/cf_disa.erl index c45f09051c1..c36ebe76a36 100644 --- a/applications/callflow/src/module/cf_disa.erl +++ b/applications/callflow/src/module/cf_disa.erl @@ -125,14 +125,14 @@ maybe_route_to_callflow(Data, Call, Retries, Interdigit, Number) -> %% for this module will be resulted to an empty binary) %% @end %%-------------------------------------------------------------------- --spec collect_destination_number(kapps_call:call(), kz_json:object(), pos_integer()) -> ne_binary(). +-spec collect_destination_number(kapps_call:call(), kz_json:object(), pos_integer()) -> kz_term:ne_binary(). collect_destination_number(Call, Data, Interdigit) -> MaxDigits = kz_json:get_integer_value(<<"max_digits">>, Data, 15), Timeout = kapps_call_command:default_collect_timeout(), lager:debug("collecting max ~p digits for destination number", [MaxDigits]), try_collect_destination_number(Call, Interdigit, MaxDigits, Timeout). --spec try_collect_destination_number(kapps_call:call(), pos_integer(), pos_integer(), pos_integer()) -> ne_binary(). +-spec try_collect_destination_number(kapps_call:call(), pos_integer(), pos_integer(), pos_integer()) -> kz_term:ne_binary(). try_collect_destination_number(Call, Interdigit, MaxDigits, Timeout) -> case kapps_call_command:collect_digits(MaxDigits, Timeout, Interdigit, Call) of {'ok', <<>>} -> try_collect_destination_number(Call, Interdigit, MaxDigits, Timeout); @@ -147,7 +147,7 @@ try_collect_destination_number(Call, Interdigit, MaxDigits, Timeout) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec maybe_restrict_call(kz_json:object(), kapps_call:call(), ne_binary(), kz_json:object()) -> 'ok'. +-spec maybe_restrict_call(kz_json:object(), kapps_call:call(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. maybe_restrict_call(Data, Call, Number, Flow) -> case should_restrict_call(Data, Call, Number) of 'true' -> @@ -236,7 +236,7 @@ keep_original_cid(Call) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec set_cid(ne_binary(), ne_binary(), kapps_call:call()) -> kapps_call:call(). +-spec set_cid(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> kapps_call:call(). set_cid(Number, Name, Call) -> Props = [{<<"Retain-CID">>, 'true'} ,{<<"Caller-ID-Number">>, Number} @@ -253,7 +253,7 @@ set_cid(Number, Name, Call) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec should_restrict_call(kz_json:object(), kapps_call:call(), ne_binary()) -> boolean(). +-spec should_restrict_call(kz_json:object(), kapps_call:call(), kz_term:ne_binary()) -> boolean(). should_restrict_call(Data, Call, Number) -> case kz_json:is_true(<<"enforce_call_restriction">>, Data, 'false') of 'false' -> 'false'; @@ -265,7 +265,7 @@ should_restrict_call(Data, Call, Number) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec should_restrict_call_by_account(kapps_call:call(), ne_binary()) -> boolean(). +-spec should_restrict_call_by_account(kapps_call:call(), kz_term:ne_binary()) -> boolean(). should_restrict_call_by_account(Call, Number) -> case kz_account:fetch(kapps_call:account_id(Call)) of {'error', _} -> 'false'; diff --git a/applications/callflow/src/module/cf_do_not_disturb.erl b/applications/callflow/src/module/cf_do_not_disturb.erl index 86e1ec72a60..908793ecb68 100644 --- a/applications/callflow/src/module/cf_do_not_disturb.erl +++ b/applications/callflow/src/module/cf_do_not_disturb.erl @@ -18,7 +18,7 @@ -record(dnd, {enabled = 'false' :: boolean() ,jobj = kz_json:new() :: kz_json:object() - ,account_db :: api_binary() + ,account_db :: kz_term:api_binary() }). -type dnd() :: #dnd{}. @@ -59,7 +59,7 @@ maybe_build_dnd_record(Data, Call) -> }} end. --spec maybe_get_data_id(ne_binary(), kz_json:object(), kapps_call:call()) -> kz_jobj_return(). +-spec maybe_get_data_id(kz_term:ne_binary(), kz_json:object(), kapps_call:call()) -> kz_term:jobj_return(). maybe_get_data_id(AccountDb, Data, Call) -> Id = kz_json:get_ne_binary_value(<<"id">>, Data), case maybe_get_doc(AccountDb, Id) of @@ -69,7 +69,7 @@ maybe_get_data_id(AccountDb, Data, Call) -> {'ok', _}=Ok -> Ok end. --spec maybe_get_owner(ne_binary(), kapps_call:call()) -> kz_jobj_return(). +-spec maybe_get_owner(kz_term:ne_binary(), kapps_call:call()) -> kz_term:jobj_return(). maybe_get_owner(AccountDb, Call) -> OwnerId = kapps_call:owner_id(Call), case maybe_get_doc(AccountDb, OwnerId) of @@ -79,12 +79,12 @@ maybe_get_owner(AccountDb, Call) -> {'ok', _}=Ok -> Ok end. --spec maybe_get_authorizing_device(ne_binary(), kapps_call:call()) -> kz_jobj_return(). +-spec maybe_get_authorizing_device(kz_term:ne_binary(), kapps_call:call()) -> kz_term:jobj_return(). maybe_get_authorizing_device(AccountDb, Call) -> AuthorizingId = kapps_call:authorizing_id(Call), maybe_get_doc(AccountDb, AuthorizingId). --spec maybe_get_doc(api_binary(), api_binary()) -> kz_jobj_return(). +-spec maybe_get_doc(kz_term:api_binary(), kz_term:api_binary()) -> kz_term:jobj_return(). maybe_get_doc(_, 'undefined') -> {'error', 'no_device_id'}; maybe_get_doc('undefined', _) -> @@ -104,7 +104,7 @@ maybe_get_doc(AccountDb, Id) -> E end. --spec maybe_execute_action(ne_binary(), dnd(), kapps_call:call()) -> any(). +-spec maybe_execute_action(kz_term:ne_binary(), dnd(), kapps_call:call()) -> any(). maybe_execute_action(<<"activate">>, #dnd{enabled='true'}, Call) -> lager:info("dnd is already enabled on this document", []), kapps_call_command:b_prompt(<<"dnd-activated">>, Call); @@ -141,7 +141,7 @@ deactivate_dnd(#dnd{jobj=JObj {'ok', _} -> kapps_call_command:b_prompt(<<"dnd-deactivated">>, Call) end. --spec maybe_update_doc(boolean(), kz_json:object(), ne_binary()) -> kz_jobj_return(). +-spec maybe_update_doc(boolean(), kz_json:object(), kz_term:ne_binary()) -> kz_term:jobj_return(). maybe_update_doc(Enabled, JObj, AccountDb) -> Updated = kz_json:set_value([<<"do_not_disturb">>, <<"enabled">>], Enabled, JObj), case kz_datamgr:save_doc(AccountDb, Updated) of diff --git a/applications/callflow/src/module/cf_dynamic_cid.erl b/applications/callflow/src/module/cf_dynamic_cid.erl index 3b6b7c3c128..7d39808cfa1 100644 --- a/applications/callflow/src/module/cf_dynamic_cid.erl +++ b/applications/callflow/src/module/cf_dynamic_cid.erl @@ -31,13 +31,13 @@ -record(prompts ,{accept_tone = kapps_config:get_ne_binary(?MOD_CONFIG_CAT, <<"accept_prompt">>, <<"tone_stream://%(250,50,440)">>) - :: ne_binary() - ,reject_tone = kz_media_util:get_prompt(?REJECT_PROMPT) :: api_ne_binary() + :: kz_term:ne_binary() + ,reject_tone = kz_media_util:get_prompt(?REJECT_PROMPT) :: kz_term:api_ne_binary() ,default_prompt = kz_media_util:get_prompt( kapps_config:get_ne_binary(?MOD_CONFIG_CAT, <<"default_prompt">>, <<"dynamic-cid-enter_cid">>) ) - :: ne_binary() + :: kz_term:ne_binary() }). -type prompts() :: #prompts{}. @@ -45,11 +45,11 @@ ,{prompts = #prompts{} :: prompts() ,default_max_digits = kapps_config:get_integer(?MOD_CONFIG_CAT, <<"max_digits">>, 10) :: integer() ,default_min_digits = kapps_config:get_integer(?MOD_CONFIG_CAT, <<"min_digits">>, 10) :: integer() - ,default_whitelist = kapps_config:get_binary(?MOD_CONFIG_CAT, <<"whitelist_regex">>, <<"\\d+">>) :: ne_binary() + ,default_whitelist = kapps_config:get_binary(?MOD_CONFIG_CAT, <<"whitelist_regex">>, <<"\\d+">>) :: kz_term:ne_binary() } ). --type cid() :: {ne_binary(), ne_binary()}. +-type cid() :: {kz_term:ne_binary(), kz_term:ne_binary()}. %%-------------------------------------------------------------------- %% @public @@ -58,7 +58,7 @@ %% @end %%-------------------------------------------------------------------- -spec handle(kz_json:object(), kapps_call:call()) -> 'ok'. --spec handle(kz_json:object(), kapps_call:call(), api_ne_binary(), api_ne_binary()) -> 'ok'. +-spec handle(kz_json:object(), kapps_call:call(), kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> 'ok'. handle(Data, Call) -> CaptureGroup = kapps_call:kvs_fetch('cf_capture_group', Call), Action = kz_json:get_ne_binary_value(<<"action">>, Data), @@ -86,7 +86,7 @@ handle(Data, Call, _Manual, CaptureGroup) -> %% Handle manual mode of dynamic cid %% @end %%-------------------------------------------------------------------- --spec handle_manual(kz_json:object(), kapps_call:call(), api_ne_binary()) -> 'ok'. +-spec handle_manual(kz_json:object(), kapps_call:call(), kz_term:api_ne_binary()) -> 'ok'. handle_manual(Data, Call, CaptureGroup) -> CID = collect_cid_number(Data, Call), update_call(Call, CID, CaptureGroup), @@ -99,7 +99,7 @@ handle_manual(Data, Call, CaptureGroup) -> %% Handle static mode of dynamic cid %% @end %%-------------------------------------------------------------------- --spec handle_static(kz_json:object(), kapps_call:call(), api_ne_binary()) -> 'ok'. +-spec handle_static(kz_json:object(), kapps_call:call(), kz_term:api_ne_binary()) -> 'ok'. handle_static(Data, Call, CaptureGroup) -> {CIDName, CIDNumber} = get_static_cid_entry(Data, Call), update_call(Call, CIDNumber, CIDName, CaptureGroup), @@ -110,7 +110,7 @@ handle_static(Data, Call, CaptureGroup) -> %% @doc Read CID info from a list of CID defined in database %% @end %%-------------------------------------------------------------------- --type list_cid_entry() :: {ne_binary(), ne_binary(), ne_binary()} | +-type list_cid_entry() :: {kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()} | {'error', kz_datamgr:data_error()}. -spec handle_list(kz_json:object(), kapps_call:call()) -> 'ok'. @@ -129,7 +129,7 @@ maybe_proceed_with_call(_, _, Call) -> _ = kapps_call_command:prompt(<<"fault-can_not_be_completed_at_this_time">>, Call), kapps_call_command:queued_hangup(Call). --spec proceed_with_call(ne_binary(), ne_binary(), binary(), kz_json:object(), kapps_call:call()) -> 'ok'. +-spec proceed_with_call(kz_term:ne_binary(), kz_term:ne_binary(), binary(), kz_json:object(), kapps_call:call()) -> 'ok'. proceed_with_call(NewCallerIdName, NewCallerIdNumber, Dest, Data, Call) -> update_call(Call, NewCallerIdNumber, NewCallerIdName, Dest), Number = knm_converters:normalize(Dest), @@ -142,7 +142,7 @@ proceed_with_call(NewCallerIdName, NewCallerIdNumber, Dest, Data, Call) -> %% request, to and callee_number %% @end %%-------------------------------------------------------------------- --spec update_call(kapps_call:call(), ne_binary(), api_ne_binary()) -> 'ok'. +-spec update_call(kapps_call:call(), kz_term:ne_binary(), kz_term:api_ne_binary()) -> 'ok'. update_call(Call, CIDNumber, CaptureGroup) -> Updates = [{fun kapps_call:kvs_store/3, 'dynamic_cid', CIDNumber} ,{fun kapps_call:set_caller_id_number/2, CIDNumber} @@ -158,7 +158,7 @@ update_call(Call, CIDNumber, CaptureGroup) -> %% @doc Same as update_call/3, but also sets caller id name %% @end %%-------------------------------------------------------------------- --spec update_call(kapps_call:call(), ne_binary(), ne_binary(), api_ne_binary()) -> 'ok'. +-spec update_call(kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_ne_binary()) -> 'ok'. update_call(Call, CIDNumber, CIDName, CaptureGroup) -> Updates = [{fun kapps_call:kvs_store/3, 'dynamic_cid', {CIDNumber, CIDName}} ,{fun kapps_call:set_caller_id_number/2, CIDNumber} @@ -179,7 +179,7 @@ update_call(Call, CIDNumber, CIDName, CaptureGroup) -> %% @doc If CaptureGroup exists correct request, to and callee_id_number %% @end %%-------------------------------------------------------------------- --spec maybe_strip_features_code(kapps_call:call(), api_ne_binary()) -> 'ok'. +-spec maybe_strip_features_code(kapps_call:call(), kz_term:api_ne_binary()) -> 'ok'. maybe_strip_features_code(Call, 'undefined') -> cf_exe:set_call(Call); maybe_strip_features_code(Call, CaptureGroup) -> @@ -200,7 +200,7 @@ maybe_strip_features_code(Call, CaptureGroup) -> %% @doc Lookup callflow and continue with the call %% @end %%-------------------------------------------------------------------- --spec maybe_route_to_callflow(kz_json:object(), kapps_call:call(), ne_binary()) -> 'ok'. +-spec maybe_route_to_callflow(kz_json:object(), kapps_call:call(), kz_term:ne_binary()) -> 'ok'. maybe_route_to_callflow(Data, Call, Number) -> case cf_flow:lookup(Number, kapps_call:account_id(Call)) of {'ok', Flow, 'true'} -> @@ -216,7 +216,7 @@ maybe_route_to_callflow(Data, Call, Number) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec maybe_restrict_call(kz_json:object(), kapps_call:call(), ne_binary(), kzd_callflow:doc()) -> 'ok'. +-spec maybe_restrict_call(kz_json:object(), kapps_call:call(), kz_term:ne_binary(), kzd_callflow:doc()) -> 'ok'. maybe_restrict_call(Data, Call, Number, Flow) -> case should_restrict_call(Data, Call, Number) of 'true' -> @@ -234,7 +234,7 @@ maybe_restrict_call(Data, Call, Number, Flow) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec should_restrict_call(kz_json:object(), kapps_call:call(), ne_binary()) -> +-spec should_restrict_call(kz_json:object(), kapps_call:call(), kz_term:ne_binary()) -> boolean(). should_restrict_call(Data, Call, Number) -> case kz_json:is_true(<<"enforce_call_restriction">>, Data, 'true') of @@ -249,7 +249,7 @@ should_restrict_call(Data, Call, Number) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec should_restrict_call(kapps_call:call(), ne_binary()) -> boolean(). +-spec should_restrict_call(kapps_call:call(), kz_term:ne_binary()) -> boolean(). should_restrict_call(Call, Number) -> case kz_endpoint:get(Call) of {'error', _} -> 'false'; @@ -264,7 +264,7 @@ should_restrict_call(Call, Number) -> %% @doc Collect CID number from user %% @end %%-------------------------------------------------------------------- --spec collect_cid_number(kz_json:object(), kapps_call:call()) -> ne_binary(). +-spec collect_cid_number(kz_json:object(), kapps_call:call()) -> kz_term:ne_binary(). collect_cid_number(Data, Call) -> DynamicCID = #dynamic_cid{}, Prompts = DynamicCID#dynamic_cid.prompts, @@ -351,7 +351,7 @@ get_list_entry(Data, Call) -> E end. --spec find_key_and_dest(kz_json:object(), kz_json:object(), kapps_call:call()) -> {ne_binary(), ne_binary()}. +-spec find_key_and_dest(kz_json:object(), kz_json:object(), kapps_call:call()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. find_key_and_dest(ListJObj, Data, Call) -> case kz_json:get_ne_binary_value(<<"idx_name">>, Data) of 'undefined' -> find_key_and_dest(ListJObj, Call); @@ -362,7 +362,7 @@ find_key_and_dest(ListJObj, Data, Call) -> {CIDKey, Dest} end. --spec find_key_and_dest(kz_json:object(), kapps_call:call()) -> {ne_binary(), ne_binary()}. +-spec find_key_and_dest(kz_json:object(), kapps_call:call()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. find_key_and_dest(ListJObj, Call) -> LengthDigits = kz_json:get_integer_value(<<"length">>, ListJObj, 2), lager:debug("digit length to limit lookup key in number: ~p", [LengthDigits]), @@ -406,7 +406,7 @@ cid_key_lookup(CIDKey, Entries, Call) -> maybe_set_default_cid('undefined', 'undefined', Call) end. --spec cidkey_wanted(binary(), kz_json:object(), kz_proplist()) -> kz_proplist(). +-spec cidkey_wanted(binary(), kz_json:object(), kz_term:proplist()) -> kz_term:proplist(). cidkey_wanted(CIDKey, Entry, Acc) -> case kz_json:get_binary_value([<<"value">>, <<"cid_key">>], Entry) == CIDKey of 'true' -> Acc ++ [{kz_json:get_ne_binary_value([<<"value">>, <<"cid_name">>], Entry) @@ -420,7 +420,7 @@ cidkey_wanted(CIDKey, Entry, Acc) -> %% @doc Play reject prompt if any of the caller id are empty %% @end %%-------------------------------------------------------------------- --spec maybe_set_default_cid(api_ne_binary(), api_ne_binary(), kapps_call:call()) -> cid(). +-spec maybe_set_default_cid(kz_term:api_ne_binary(), kz_term:api_ne_binary(), kapps_call:call()) -> cid(). maybe_set_default_cid('undefined', 'undefined', Call) -> lager:debug("empty cid entry, set to default value"), play_reject_prompt(Call), diff --git a/applications/callflow/src/module/cf_eavesdrop.erl b/applications/callflow/src/module/cf_eavesdrop.erl index 3063bf0f948..b57b032dcbf 100644 --- a/applications/callflow/src/module/cf_eavesdrop.erl +++ b/applications/callflow/src/module/cf_eavesdrop.erl @@ -49,7 +49,7 @@ handle(Data, Call) -> end, cf_exe:stop(Call). --spec fields_to_check() -> kz_proplist(). +-spec fields_to_check() -> kz_term:proplist(). fields_to_check() -> [{<<"approved_device_id">>, fun(Id, Call) -> Id == kapps_call:authorizing_id(Call) end} ,{<<"approved_user_id">>, fun cf_util:caller_belongs_to_user/2} @@ -61,7 +61,7 @@ fields_to_check() -> maybe_allowed_to_eavesdrop(Data, Call) -> cf_util:check_value_of_fields(fields_to_check(), 'false', Data, Call). --spec eavesdrop_channel(ne_binaries(), kapps_call:call()) -> 'ok'. +-spec eavesdrop_channel(kz_term:ne_binaries(), kapps_call:call()) -> 'ok'. eavesdrop_channel(Usernames, Call) -> case cf_util:find_channels(Usernames, Call) of [] -> no_channels(Call); @@ -91,7 +91,7 @@ eavesdrop_a_channel(Channels, Call) -> end. -type channels() :: {kz_json:objects(), kz_json:objects()}. --type channel_sort_acc() :: {ne_binary(), ne_binary(), channels()}. +-type channel_sort_acc() :: {kz_term:ne_binary(), kz_term:ne_binary(), channels()}. -spec channels_sort(kz_json:object(), channel_sort_acc()) -> channel_sort_acc(). channels_sort(Channel, {MyUUID, MyMediaServer, {Local, Remote}} = Acc) -> @@ -142,7 +142,7 @@ verify_call_is_active(Call) -> lager:debug("failed to get status: ~p", [_E]) end. --spec eavesdrop_cmd(ne_binary()) -> kz_proplist(). +-spec eavesdrop_cmd(kz_term:ne_binary()) -> kz_term:proplist(). eavesdrop_cmd(TargetCallId) -> [{<<"Application-Name">>, <<"eavesdrop">>} ,{<<"Target-Call-ID">>, TargetCallId} @@ -150,7 +150,7 @@ eavesdrop_cmd(TargetCallId) -> ]. -spec find_sip_endpoints(kz_json:object(), kapps_call:call()) -> - ne_binaries(). + kz_term:ne_binaries(). find_sip_endpoints(Data, Call) -> case kz_json:get_ne_binary_value(<<"device_id">>, Data) of 'undefined' -> @@ -161,8 +161,8 @@ find_sip_endpoints(Data, Call) -> sip_users_from_endpoints([DeviceId], Call) end. --spec sip_users_from_endpoints(ne_binaries(), kapps_call:call()) -> - ne_binaries(). +-spec sip_users_from_endpoints(kz_term:ne_binaries(), kapps_call:call()) -> + kz_term:ne_binaries(). sip_users_from_endpoints(EndpointIds, Call) -> lists:foldl(fun(EndpointId, Acc) -> case sip_user_of_endpoint(EndpointId, Call) of @@ -171,7 +171,7 @@ sip_users_from_endpoints(EndpointIds, Call) -> end end, [], EndpointIds). --spec sip_user_of_endpoint(ne_binary(), kapps_call:call()) -> api_binary(). +-spec sip_user_of_endpoint(kz_term:ne_binary(), kapps_call:call()) -> kz_term:api_binary(). sip_user_of_endpoint(EndpointId, Call) -> case kz_endpoint:get(EndpointId, Call) of {'error', _} -> 'undefined'; diff --git a/applications/callflow/src/module/cf_eavesdrop_feature.erl b/applications/callflow/src/module/cf_eavesdrop_feature.erl index 219e452c058..927cdf8b3a1 100644 --- a/applications/callflow/src/module/cf_eavesdrop_feature.erl +++ b/applications/callflow/src/module/cf_eavesdrop_feature.erl @@ -58,14 +58,14 @@ handle(Data, Call) -> cf_exe:stop(Call) end. --spec fields_to_check() -> kz_proplist(). +-spec fields_to_check() -> kz_term:proplist(). fields_to_check() -> [{<<"approved_device_id">>, fun(Id, Call) -> Id == kapps_call:authorizing_id(Call) end} ,{<<"approved_user_id">>, fun cf_util:caller_belongs_to_user/2} ,{<<"approved_group_id">>, fun cf_util:caller_belongs_to_group/2} ]. --type target() :: {'ok', ne_binary(), ne_binary()} | 'error'. +-type target() :: {'ok', kz_term:ne_binary(), kz_term:ne_binary()} | 'error'. -spec build_data(target(), kapps_call:call()) -> kz_json:object(). build_data('error', _Call) -> kz_json:new(); @@ -77,8 +77,8 @@ build_data({'ok', TargetId, _TargetType}, Call) -> lager:debug("unknown target type ~s for ~s", [TargetId, _TargetType]), build_flow_data(Call, []). --spec build_flow_data(kapps_call:call(), kz_proplist()) -> kz_json:object(). --spec build_flow_data(kapps_call:call(), kz_proplist(), api_binary()) -> kz_json:object(). +-spec build_flow_data(kapps_call:call(), kz_term:proplist()) -> kz_json:object(). +-spec build_flow_data(kapps_call:call(), kz_term:proplist(), kz_term:api_binary()) -> kz_json:object(). build_flow_data(Call, Data) -> build_flow_data(Call, Data, kapps_call:authorizing_type(Call)). @@ -96,7 +96,7 @@ build_flow_data(_Call, Data, _AuthorizingType) -> lager:debug("unhandled authorizing type ~s", [_AuthorizingType]), kz_json:from_list(Data). --spec get_target_for_extension(ne_binary(), kapps_call:call()) -> +-spec get_target_for_extension(kz_term:ne_binary(), kapps_call:call()) -> target(). get_target_for_extension(Exten, Call) -> case cf_flow:lookup(Exten, kapps_call:account_id(Call)) of @@ -105,7 +105,7 @@ get_target_for_extension(Exten, Call) -> {'error', _} -> 'error' end. --spec maybe_correct_target(target(), api_binary(), kapps_call:call()) -> +-spec maybe_correct_target(target(), kz_term:api_binary(), kapps_call:call()) -> boolean(). maybe_correct_target(_Target, 'undefined', _Call) -> 'true'; @@ -114,7 +114,7 @@ maybe_correct_target('error', _GroupId, _Call) -> maybe_correct_target({'ok', TargetId, _}, GroupId, Call) -> lists:member(TargetId, find_group_members(GroupId, Call)). --spec find_group_members(ne_binary(), kapps_call:call()) -> ne_binaries(). +-spec find_group_members(kz_term:ne_binary(), kapps_call:call()) -> kz_term:ne_binaries(). find_group_members(GroupId, Call) -> case kz_datamgr:open_cache_doc(kapps_call:account_db(Call), GroupId) of {'error', _E} -> []; @@ -122,8 +122,8 @@ find_group_members(GroupId, Call) -> kz_json:get_keys(<<"endpoints">>, GroupJObj) end. --spec lookup_endpoint(api_object()) -> target(). --spec lookup_endpoint(kz_json:object(), api_binary()) -> target(). +-spec lookup_endpoint(kz_term:api_object()) -> target(). +-spec lookup_endpoint(kz_json:object(), kz_term:api_binary()) -> target(). lookup_endpoint('undefined') -> 'error'; lookup_endpoint(Flow) -> lookup_endpoint(Flow, kz_json:get_ne_binary_value(<<"module">>, Flow)). diff --git a/applications/callflow/src/module/cf_faxbox.erl b/applications/callflow/src/module/cf_faxbox.erl index c10aa26081c..e939f2c5fcd 100644 --- a/applications/callflow/src/module/cf_faxbox.erl +++ b/applications/callflow/src/module/cf_faxbox.erl @@ -40,7 +40,7 @@ handle(Data, Call) -> kapi_fax:publish_req(Props), cf_exe:control_usurped(Call). --spec lookup_fax_option(kapps_call:call(), kz_json:object()) -> ne_binary(). +-spec lookup_fax_option(kapps_call:call(), kz_json:object()) -> kz_term:ne_binary(). lookup_fax_option(Call, Data) -> FaxBoxId = get_faxbox_id(Data), DefaultFaxBoxOption = case kz_datamgr:open_cache_doc(kapps_call:account_db(Call), FaxBoxId) of @@ -49,7 +49,7 @@ lookup_fax_option(Call, Data) -> end, kz_json:get_value(?FAX_OPTION, Data, DefaultFaxBoxOption). --spec get_faxbox_id(kz_json:object()) -> api_binary(). +-spec get_faxbox_id(kz_json:object()) -> kz_term:api_binary(). get_faxbox_id(JObj) -> case kz_json:get_ne_binary_value(<<"id">>, JObj) of 'undefined' -> kz_json:get_ne_binary_value(<<"faxbox_id">>, JObj); diff --git a/applications/callflow/src/module/cf_flush_dtmf.erl b/applications/callflow/src/module/cf_flush_dtmf.erl index 1d38e8d13d1..0a2741deacc 100644 --- a/applications/callflow/src/module/cf_flush_dtmf.erl +++ b/applications/callflow/src/module/cf_flush_dtmf.erl @@ -27,6 +27,6 @@ handle(Data, Call) -> Collection = collection_name(Data), cf_exe:continue(kapps_call:set_dtmf_collection('undefined', Collection, Call)). --spec collection_name(kz_json:object()) -> ne_binary(). +-spec collection_name(kz_json:object()) -> kz_term:ne_binary(). collection_name(Data) -> kz_json:get_ne_binary_value(<<"collection_name">>, Data, <<"default">>). diff --git a/applications/callflow/src/module/cf_group.erl b/applications/callflow/src/module/cf_group.erl index c42a41cbbf4..d4c830aa4fd 100644 --- a/applications/callflow/src/module/cf_group.erl +++ b/applications/callflow/src/module/cf_group.erl @@ -92,9 +92,9 @@ build_endpoints(JObj, Call) -> ] ). --type endpoints_acc() :: [{ne_binary(), {'ok', kz_json:objects()}}]. +-type endpoints_acc() :: [{kz_term:ne_binary(), {'ok', kz_json:objects()}}]. --spec build_device_endpoints(endpoints_acc(), kz_proplist(), kapps_call:call()) -> +-spec build_device_endpoints(endpoints_acc(), kz_term:proplist(), kapps_call:call()) -> endpoints_acc(). build_device_endpoints(Endpoints, [], _) -> Endpoints; build_device_endpoints(Endpoints, [{MemberId, Member} | Members], Call) -> @@ -109,7 +109,7 @@ build_device_endpoints(Endpoints, [{MemberId, Member} | Members], Call) -> 'false' -> build_device_endpoints(Endpoints, Members, Call) end. --spec build_user_endpoints(endpoints_acc(), kz_proplist(), kapps_call:call()) -> endpoints_acc(). +-spec build_user_endpoints(endpoints_acc(), kz_term:proplist(), kapps_call:call()) -> endpoints_acc(). build_user_endpoints(Endpoints, [], _) -> Endpoints; build_user_endpoints(Endpoints, [{MemberId, Member} | Members], Call) -> case <<"user">> =:= kz_json:get_value(<<"type">>, Member, <<"user">>) of diff --git a/applications/callflow/src/module/cf_group_pickup.erl b/applications/callflow/src/module/cf_group_pickup.erl index 1cf94862ae1..6849247fb17 100644 --- a/applications/callflow/src/module/cf_group_pickup.erl +++ b/applications/callflow/src/module/cf_group_pickup.erl @@ -66,15 +66,15 @@ maybe_allowed_to_intercept(Data, Call) -> DeviceId == kapps_call:authorizing_id(Call) end. --spec maybe_belongs_to_user(ne_binary(), kapps_call:call()) -> boolean(). +-spec maybe_belongs_to_user(kz_term:ne_binary(), kapps_call:call()) -> boolean(). maybe_belongs_to_user(UserId, Call) -> lists:member(kapps_call:authorizing_id(Call), find_user_endpoints([UserId],[],Call)). --spec maybe_belongs_to_group(ne_binary(), kapps_call:call()) -> boolean(). +-spec maybe_belongs_to_group(kz_term:ne_binary(), kapps_call:call()) -> boolean(). maybe_belongs_to_group(GroupId, Call) -> lists:member(kapps_call:authorizing_id(Call), find_group_endpoints(GroupId, Call)). --spec connect_to_ringing_channel(ne_binaries(), kapps_call:call()) -> 'ok'. +-spec connect_to_ringing_channel(kz_term:ne_binaries(), kapps_call:call()) -> 'ok'. connect_to_ringing_channel(DeviceIds, Call) -> case find_channels(DeviceIds) of [] -> no_channels_ringing(Call); @@ -101,10 +101,10 @@ connect_to_a_channel(Channels, Call) -> intercept_call(LocalUUID, Call) end. --spec sort_channels(kz_json:objects(), ne_binary(), ne_binary()) -> - {ne_binaries(), ne_binaries()}. --spec sort_channels(kz_json:objects(), ne_binary(), ne_binary(), {ne_binaries(), ne_binaries()}) -> - {ne_binaries(), ne_binaries()}. +-spec sort_channels(kz_json:objects(), kz_term:ne_binary(), kz_term:ne_binary()) -> + {kz_term:ne_binaries(), kz_term:ne_binaries()}. +-spec sort_channels(kz_json:objects(), kz_term:ne_binary(), kz_term:ne_binary(), {kz_term:ne_binaries(), kz_term:ne_binaries()}) -> + {kz_term:ne_binaries(), kz_term:ne_binaries()}. sort_channels(Channels, MyUUID, MyMediaServer) -> sort_channels(Channels, MyUUID, MyMediaServer, {[], []}). sort_channels([], _MyUUID, _MyMediaServer, Acc) -> Acc; @@ -121,8 +121,8 @@ sort_channels([Channel|Channels], MyUUID, MyMediaServer, Acc) -> maybe_add_unanswered_leg(Channels, MyUUID, MyMediaServer, Acc, Channel) end. --spec maybe_add_unanswered_leg(kz_json:objects(), ne_binary(), ne_binary(), {ne_binaries(), ne_binaries()}, kz_json:object()) -> - {ne_binaries(), ne_binaries()}. +-spec maybe_add_unanswered_leg(kz_json:objects(), kz_term:ne_binary(), kz_term:ne_binary(), {kz_term:ne_binaries(), kz_term:ne_binaries()}, kz_json:object()) -> + {kz_term:ne_binaries(), kz_term:ne_binaries()}. maybe_add_unanswered_leg(Channels, MyUUID, MyMediaServer, {Local, Remote}=Acc, Channel) -> case kz_json:get_ne_binary_value(<<"node">>, Channel) of MyMediaServer -> @@ -136,14 +136,14 @@ maybe_add_unanswered_leg(Channels, MyUUID, MyMediaServer, {Local, Remote}=Acc, C sort_channels(Channels, MyUUID, MyMediaServer, {Local, maybe_add_other_leg(Channel, Remote)}) end. --spec maybe_add_other_leg(kz_json:object(), ne_binaries()) -> ne_binaries(). +-spec maybe_add_other_leg(kz_json:object(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). maybe_add_other_leg(Channel, Legs) -> case kz_json:get_ne_binary_value(<<"other_leg">>, Channel) of 'undefined' -> Legs; Leg -> [Leg | Legs] end. --spec intercept_call(ne_binary(), kapps_call:call()) -> 'ok'. +-spec intercept_call(kz_term:ne_binary(), kapps_call:call()) -> 'ok'. intercept_call(UUID, Call) -> _ = kapps_call_command:send_command(pickup_cmd(UUID), Call), case wait_for_pickup(Call) of @@ -155,7 +155,7 @@ intercept_call(UUID, Call) -> lager:debug("hangup recv") end. --spec pickup_cmd(ne_binary()) -> kz_proplist(). +-spec pickup_cmd(kz_term:ne_binary()) -> kz_term:proplist(). pickup_cmd(TargetCallId) -> [{<<"Application-Name">>, <<"call_pickup">>} ,{<<"Target-Call-ID">>, TargetCallId} @@ -175,7 +175,7 @@ wait_for_pickup(Call) -> E end. --spec pickup_event(kapps_call:call(), {ne_binary(), ne_binary()}, kz_json:object()) -> +-spec pickup_event(kapps_call:call(), {kz_term:ne_binary(), kz_term:ne_binary()}, kz_json:object()) -> {'error', 'failed' | 'timeout'} | 'ok'. pickup_event(_Call, {<<"error">>, <<"dialplan">>}, Evt) -> @@ -187,7 +187,7 @@ pickup_event(Call, _Type, _Evt) -> lager:debug("unhandled evt ~p", [_Type]), wait_for_pickup(Call). --spec find_channels(ne_binaries()) -> kz_json:objects(). +-spec find_channels(kz_term:ne_binaries()) -> kz_json:objects(). find_channels(DeviceIds) -> lager:debug("finding channels for devices ids ~p", [DeviceIds]), Req = [{<<"Authorizing-IDs">>, DeviceIds} @@ -210,7 +210,7 @@ find_channels(DeviceIds) -> end. -spec find_sip_endpoints(kz_json:object(), kapps_call:call()) -> - ne_binaries(). + kz_term:ne_binaries(). find_sip_endpoints(Data, Call) -> case kz_json:get_ne_binary_value(<<"device_id">>, Data) of 'undefined' -> @@ -222,11 +222,11 @@ find_sip_endpoints(Data, Call) -> DeviceId -> [DeviceId] end. --spec find_sip_users(api_binary(), kapps_call:call()) -> ne_binaries(). +-spec find_sip_users(kz_term:api_binary(), kapps_call:call()) -> kz_term:ne_binaries(). find_sip_users(GroupId, Call) when is_binary(GroupId) -> find_group_endpoints(GroupId, Call). --spec find_group_endpoints(ne_binary(), kapps_call:call()) -> ne_binaries(). +-spec find_group_endpoints(kz_term:ne_binary(), kapps_call:call()) -> kz_term:ne_binaries(). find_group_endpoints(GroupId, Call) -> GroupsJObj = kz_attributes:groups(Call), case [kz_json:get_value(<<"value">>, JObj) @@ -240,8 +240,8 @@ find_group_endpoints(GroupId, Call) -> find_endpoints(Ids, GroupEndpoints, Call) end. --spec find_endpoints(ne_binaries(), kz_json:object(), kapps_call:call()) -> - ne_binaries(). +-spec find_endpoints(kz_term:ne_binaries(), kz_json:object(), kapps_call:call()) -> + kz_term:ne_binaries(). find_endpoints(Ids, GroupEndpoints, Call) -> {DeviceIds, UserIds} = lists:partition(fun(Id) -> @@ -249,8 +249,8 @@ find_endpoints(Ids, GroupEndpoints, Call) -> end, Ids), find_user_endpoints(UserIds, lists:sort(DeviceIds), Call). --spec find_user_endpoints(ne_binaries(), ne_binaries(), kapps_call:call()) -> - ne_binaries(). +-spec find_user_endpoints(kz_term:ne_binaries(), kz_term:ne_binaries(), kapps_call:call()) -> + kz_term:ne_binaries(). find_user_endpoints([], DeviceIds, _) -> DeviceIds; find_user_endpoints(UserIds, DeviceIds, Call) -> UserDeviceIds = kz_attributes:owned_by(UserIds, <<"device">>, Call), diff --git a/applications/callflow/src/module/cf_group_pickup_feature.erl b/applications/callflow/src/module/cf_group_pickup_feature.erl index 4e1ed02136c..fc2372bd753 100644 --- a/applications/callflow/src/module/cf_group_pickup_feature.erl +++ b/applications/callflow/src/module/cf_group_pickup_feature.erl @@ -76,9 +76,9 @@ handle(Data, Call) -> cf_exe:stop(Call) end. --spec build_pickup_params(ne_binary(), ne_binary(), kapps_call:call()) -> - {'ok', kz_proplist()} | - {'error', ne_binary()}. +-spec build_pickup_params(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> + {'ok', kz_term:proplist()} | + {'error', kz_term:ne_binary()}. build_pickup_params(Number, <<"device">>, Call) -> AccountDb = kapps_call:account_db(Call), case cf_util:endpoint_id_by_sip_username(AccountDb, Number) of @@ -105,9 +105,9 @@ build_pickup_params(_ ,'undefined', _) -> build_pickup_params(_, Other, _) -> {'error', <>}. --spec params_from_data(ne_binary(), kz_json:object(), kapps_call:call()) -> - {'ok', kz_proplist()} | - {'error', ne_binary()}. +-spec params_from_data(kz_term:ne_binary(), kz_json:object(), kapps_call:call()) -> + {'ok', kz_term:proplist()} | + {'error', kz_term:ne_binary()}. params_from_data(<<"user">>, Data, _Call) -> EndpointId = kz_json:get_ne_binary_value(<<"id">>, Data), {'ok', [{<<"user_id">>, EndpointId}]}; diff --git a/applications/callflow/src/module/cf_hotdesk.erl b/applications/callflow/src/module/cf_hotdesk.erl index 8b4b2f830f3..532854deba1 100644 --- a/applications/callflow/src/module/cf_hotdesk.erl +++ b/applications/callflow/src/module/cf_hotdesk.erl @@ -25,12 +25,12 @@ -define(HOTDESK_ID_LENGTH, kapps_config:get_integer(?HD_CONFIG_CAT, <<"max_hotdesk_id_length">>, 10)). -record(hotdesk, {enabled = 'false' :: boolean() - ,hotdesk_id :: api_binary() - ,pin :: api_binary() + ,hotdesk_id :: kz_term:api_binary() + ,pin :: kz_term:api_binary() ,require_pin = 'false' :: boolean() ,keep_logged_in_elsewhere = 'false' :: boolean() - ,owner_id :: api_binary() - ,endpoint_ids = [] :: ne_binaries() + ,owner_id :: kz_term:api_binary() + ,endpoint_ids = [] :: kz_term:ne_binaries() ,interdigit_timeout = kapps_call_command:default_interdigit_timeout() :: pos_integer() }). -type hotdesk() :: #hotdesk{}. @@ -64,7 +64,7 @@ hotdesk_id(Data, <<"logout">>, Call) -> hotdesk_id(Data, _, _) -> kz_json:get_ne_binary_value(<<"id">>, Data). --spec handle_action(ne_binary(), hotdesk(), kapps_call:call()) -> 'ok'. +-spec handle_action(kz_term:ne_binary(), hotdesk(), kapps_call:call()) -> 'ok'. handle_action(<<"bridge">>, #hotdesk{enabled='false'}, Call) -> cf_exe:continue(Call); handle_action(<<"bridge">>, Hotdesk, Call) -> @@ -191,7 +191,7 @@ maybe_logout_elsewhere(Hotdesk, Call) -> get_authorizing_id(Hotdesk, Call) -> login_authorizing_id(kapps_call:authorizing_id(Call), Hotdesk, Call). --spec login_authorizing_id(api_binary(), hotdesk(), kapps_call:call()) -> +-spec login_authorizing_id(kz_term:api_binary(), hotdesk(), kapps_call:call()) -> kapps_api_std_return(). login_authorizing_id('undefined', _, Call) -> kapps_call_command:b_prompt(<<"hotdesk-abort">>, Call), @@ -239,7 +239,7 @@ maybe_keep_logged_in_elsewhere(Hotdesk, Call) -> H = remove_from_endpoints(Hotdesk, Call), logged_out(H, Call). --spec keep_logged_in_elsewhere(api_binary(), hotdesk(), kapps_call:call()) -> +-spec keep_logged_in_elsewhere(kz_term:api_binary(), hotdesk(), kapps_call:call()) -> kapps_api_std_return(). keep_logged_in_elsewhere('undefined', Hotdesk, Call) -> logged_out(Hotdesk, Call); @@ -271,7 +271,7 @@ logged_out(_, Call) -> %% mailbox record %% @end %%-------------------------------------------------------------------- --spec get_hotdesk_profile(api_binary(), kz_json:object(), kapps_call:call()) -> +-spec get_hotdesk_profile(kz_term:api_binary(), kz_json:object(), kapps_call:call()) -> hotdesk() | {'error', any()}. get_hotdesk_profile('undefined', Data, Call) -> @@ -320,7 +320,7 @@ find_hotdesk_profile(Call, Data, Max, Loop) -> E end. --spec lookup_hotdesk_id(ne_binary(), kz_json:object(), kapps_call:call()) -> +-spec lookup_hotdesk_id(kz_term:ne_binary(), kz_json:object(), kapps_call:call()) -> hotdesk() | {'error', any()}. lookup_hotdesk_id(HotdeskId, Data, Call) -> @@ -365,8 +365,8 @@ remove_from_endpoints(#hotdesk{endpoint_ids=[EndpointId|Endpoints] _ = update_hotdesk_endpoint(AccountDb, EndpointId, Fun), remove_from_endpoints(Hotdesk#hotdesk{endpoint_ids=Endpoints}, Call). --spec update_hotdesk_endpoint(ne_binary(), api_binary() | kz_json:object(), function()) -> - kz_jobj_return(). +-spec update_hotdesk_endpoint(kz_term:ne_binary(), kz_term:api_binary() | kz_json:object(), function()) -> + kz_term:jobj_return(). update_hotdesk_endpoint(_, 'undefined', _) -> {'error', 'not_found'}; update_hotdesk_endpoint(AccountDb, EndpointId, Fun) when is_binary(EndpointId) -> case kz_datamgr:open_doc(AccountDb, EndpointId) of @@ -388,7 +388,7 @@ update_hotdesk_endpoint(AccountDb, JObj, Fun) -> E end. --spec get_endpoint_ids(ne_binary(), kapps_call:call()) -> ne_binaries(). +-spec get_endpoint_ids(kz_term:ne_binary(), kapps_call:call()) -> kz_term:ne_binaries(). get_endpoint_ids(OwnerId, Call) -> AccountDb = kapps_call:account_db(Call), ViewOptions = [{'key', OwnerId}], diff --git a/applications/callflow/src/module/cf_intercept.erl b/applications/callflow/src/module/cf_intercept.erl index 642cc6f9c99..c613041f73d 100644 --- a/applications/callflow/src/module/cf_intercept.erl +++ b/applications/callflow/src/module/cf_intercept.erl @@ -71,7 +71,7 @@ is_caller_same_user(Data, Call, CallerDeviceJObj) -> _UserId -> 'false' end. --spec is_device_same_user(kapps_call:call(), ne_binary(), api_binary()) -> boolean(). +-spec is_device_same_user(kapps_call:call(), kz_term:ne_binary(), kz_term:api_binary()) -> boolean(). is_device_same_user(_Call, _OwnerId, 'undefined') -> 'false'; is_device_same_user(Call, OwnerId, DeviceId) -> case kz_datamgr:open_cache_doc(kapps_call:account_db(Call), DeviceId) of @@ -100,7 +100,7 @@ is_caller_same_group(Data, Call, CallerDeviceJObj) -> GroupId = kz_json:get_ne_binary_value(<<"group_id">>, Data), is_owner_same_group(Call, DeviceId, OwnerId, GroupId). --spec is_owner_same_group(kapps_call:call(), ne_binary(), ne_binary(), api_binary()) -> boolean(). +-spec is_owner_same_group(kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary()) -> boolean(). is_owner_same_group(_Call, _DeviceId, _OwnerId, 'undefined') -> 'false'; is_owner_same_group(Call, DeviceId, OwnerId, GroupId) -> case kz_datamgr:open_cache_doc(kapps_call:account_db(Call), GroupId) of @@ -155,7 +155,7 @@ maybe_approved_group(Data, Call) -> GroupId -> {'ok', cf_util:caller_belongs_to_group(GroupId, Call)} end. --spec find_group_endpoints(ne_binary(), kapps_call:call()) -> ne_binaries(). +-spec find_group_endpoints(kz_term:ne_binary(), kapps_call:call()) -> kz_term:ne_binaries(). find_group_endpoints(GroupId, Call) -> GroupsJObj = kz_attributes:groups(Call), case [kz_json:get_json_value(<<"value">>, JObj) @@ -169,7 +169,7 @@ find_group_endpoints(GroupId, Call) -> cf_util:find_endpoints(Ids, GroupEndpoints, Call) end. --spec connect_to_channel(ne_binaries(), kapps_call:call()) -> 'ok'. +-spec connect_to_channel(kz_term:ne_binaries(), kapps_call:call()) -> 'ok'. connect_to_channel(Usernames, Call) -> case cf_util:find_channels(Usernames, Call) of [] -> no_channels(Call); @@ -196,10 +196,10 @@ connect_to_a_channel(Channels, Call) -> intercept_call(LocalUUID, Call) end. --spec sort_channels(kz_json:objects(), ne_binary(), ne_binary()) -> - {ne_binaries(), ne_binaries()}. --spec sort_channels(kz_json:objects(), ne_binary(), ne_binary(), {ne_binaries(), ne_binaries()}) -> - {ne_binaries(), ne_binaries()}. +-spec sort_channels(kz_json:objects(), kz_term:ne_binary(), kz_term:ne_binary()) -> + {kz_term:ne_binaries(), kz_term:ne_binaries()}. +-spec sort_channels(kz_json:objects(), kz_term:ne_binary(), kz_term:ne_binary(), {kz_term:ne_binaries(), kz_term:ne_binaries()}) -> + {kz_term:ne_binaries(), kz_term:ne_binaries()}. sort_channels(Channels, MyUUID, MyMediaServer) -> sort_channels(Channels, MyUUID, MyMediaServer, {[], []}). sort_channels([], _MyUUID, _MyMediaServer, Acc) -> Acc; @@ -211,8 +211,8 @@ sort_channels([Channel|Channels], MyUUID, MyMediaServer, Acc) -> ]), maybe_add_leg(Channels, MyUUID, MyMediaServer, Acc, Channel). --spec maybe_add_leg(kz_json:objects(), ne_binary(), ne_binary(), {ne_binaries(), ne_binaries()}, kz_json:object()) -> - {ne_binaries(), ne_binaries()}. +-spec maybe_add_leg(kz_json:objects(), kz_term:ne_binary(), kz_term:ne_binary(), {kz_term:ne_binaries(), kz_term:ne_binaries()}, kz_json:object()) -> + {kz_term:ne_binaries(), kz_term:ne_binaries()}. maybe_add_leg(Channels, MyUUID, MyMediaServer, {Local, Remote}=Acc, Channel) -> case kz_json:get_ne_binary_value(<<"node">>, Channel) of MyMediaServer -> @@ -226,14 +226,14 @@ maybe_add_leg(Channels, MyUUID, MyMediaServer, {Local, Remote}=Acc, Channel) -> sort_channels(Channels, MyUUID, MyMediaServer, {Local, maybe_add_other_leg(Channel, Remote)}) end. --spec maybe_add_other_leg(kz_json:object(), ne_binaries()) -> ne_binaries(). +-spec maybe_add_other_leg(kz_json:object(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). maybe_add_other_leg(Channel, Legs) -> case kz_json:get_ne_binary_value(<<"other_leg">>, Channel) of 'undefined' -> Legs; Leg -> [Leg | Legs] end. --spec intercept_call(ne_binary(), kapps_call:call()) -> 'ok'. +-spec intercept_call(kz_term:ne_binary(), kapps_call:call()) -> 'ok'. intercept_call(UUID, Call) -> _ = kapps_call_command:send_command(intercept_cmd(UUID), Call), case wait_for_intercept(Call) of @@ -245,7 +245,7 @@ intercept_call(UUID, Call) -> lager:debug("hangup recv") end. --spec intercept_cmd(ne_binary()) -> kz_proplist(). +-spec intercept_cmd(kz_term:ne_binary()) -> kz_term:proplist(). intercept_cmd(TargetCallId) -> [{<<"Application-Name">>, <<"call_pickup">>} ,{<<"Target-Call-ID">>, TargetCallId} @@ -266,7 +266,7 @@ wait_for_intercept(Call) -> E end. --spec intercept_event(kapps_call:call(), {ne_binary(), ne_binary()}, kz_json:object()) -> +-spec intercept_event(kapps_call:call(), {kz_term:ne_binary(), kz_term:ne_binary()}, kz_json:object()) -> {'error', 'failed' | 'timeout'} | 'ok'. intercept_event(_Call, {<<"error">>, <<"dialplan">>}, Evt) -> @@ -279,7 +279,7 @@ intercept_event(Call, _Type, _Evt) -> wait_for_intercept(Call). -spec find_sip_endpoints(kz_json:object(), kapps_call:call()) -> - ne_binaries(). + kz_term:ne_binaries(). find_sip_endpoints(Data, Call) -> case kz_json:get_ne_binary_value(<<"device_id">>, Data) of 'undefined' -> find_user_endpoints(Data, Call); @@ -287,7 +287,7 @@ find_sip_endpoints(Data, Call) -> cf_util:sip_users_from_device_ids([DeviceId], Call) end. --spec find_user_endpoints(kz_json:object(), kapps_call:call()) -> ne_binaries(). +-spec find_user_endpoints(kz_json:object(), kapps_call:call()) -> kz_term:ne_binaries(). find_user_endpoints(Data, Call) -> case kz_json:get_ne_binary_value(<<"user_id">>, Data) of 'undefined' -> @@ -298,7 +298,7 @@ find_user_endpoints(Data, Call) -> ) end. --spec find_sip_users(ne_binary(), kapps_call:call()) -> ne_binaries(). +-spec find_sip_users(kz_term:ne_binary(), kapps_call:call()) -> kz_term:ne_binaries(). find_sip_users(GroupId, Call) -> cf_util:sip_users_from_device_ids(find_group_endpoints(GroupId, Call), Call). diff --git a/applications/callflow/src/module/cf_intercept_feature.erl b/applications/callflow/src/module/cf_intercept_feature.erl index f48c448833f..1ee0aca7572 100644 --- a/applications/callflow/src/module/cf_intercept_feature.erl +++ b/applications/callflow/src/module/cf_intercept_feature.erl @@ -70,7 +70,7 @@ handle(Data, Call) -> cf_exe:stop(Call) end. --spec maybe_intercept(kz_json:object(), kapps_call:call(), kz_proplist()) -> 'ok'. +-spec maybe_intercept(kz_json:object(), kapps_call:call(), kz_term:proplist()) -> 'ok'. maybe_intercept(Data, Call, Params) -> case intercept_restrictions(Data) of [] -> maybe_intercept(Call, Params); @@ -78,7 +78,7 @@ maybe_intercept(Data, Call, Params) -> cf_intercept:handle(kz_json:from_list(SParams ++ Params), Call) end. --spec maybe_intercept(kapps_call:call(), kz_proplist()) -> 'ok'. +-spec maybe_intercept(kapps_call:call(), kz_term:proplist()) -> 'ok'. maybe_intercept(Call, Params) -> case maybe_allowed_to_intercept(Call, Params) of 'true' -> @@ -88,7 +88,7 @@ maybe_intercept(Call, Params) -> cf_exe:stop(Call) end. --spec intercept_restrictions(kz_json:object()) -> kz_proplist(). +-spec intercept_restrictions(kz_json:object()) -> kz_term:proplist(). intercept_restrictions(Data) -> props:filter_undefined( [{<<"approved_device_id">>, kz_json:get_ne_binary_value(<<"approved_device_id">>, Data)} @@ -96,7 +96,7 @@ intercept_restrictions(Data) -> ,{<<"approved_group_id">>, kz_json:get_ne_binary_value(<<"approved_group_id">>, Data)} ]). --spec maybe_allowed_to_intercept(kapps_call:call(), kz_proplist()) -> boolean(). +-spec maybe_allowed_to_intercept(kapps_call:call(), kz_term:proplist()) -> boolean(). maybe_allowed_to_intercept(Call, Props) -> case kz_datamgr:open_cache_doc(kapps_call:account_db(Call), kapps_call:authorizing_id(Call)) of {'ok', DeviceDoc} -> @@ -106,7 +106,7 @@ maybe_allowed_to_intercept(Call, Props) -> 'false' end. --spec maybe_allowed_to_intercept(kapps_call:call(), kz_proplist(), kz_json:object()) -> boolean(). +-spec maybe_allowed_to_intercept(kapps_call:call(), kz_term:proplist(), kz_json:object()) -> boolean(). maybe_allowed_to_intercept(Call, Props, DeviceDoc) -> case props:get_value(<<"user_id">>, Props) of 'undefined' -> @@ -114,11 +114,11 @@ maybe_allowed_to_intercept(Call, Props, DeviceDoc) -> UserId -> UserId =:= kz_json:get_value(<<"owner_id">>, DeviceDoc) end. --spec can_device_intercept(kapps_call:call(), kz_proplist(), kz_json:object()) -> boolean(). +-spec can_device_intercept(kapps_call:call(), kz_term:proplist(), kz_json:object()) -> boolean(). can_device_intercept(Call, Props, DeviceDoc) -> device_has_same_owner(Call, DeviceDoc, props:get_value(<<"device_id">>, Props)). --spec device_has_same_owner(kapps_call:call(), kz_json:object(), api_binary()) -> boolean(). +-spec device_has_same_owner(kapps_call:call(), kz_json:object(), kz_term:api_binary()) -> boolean(). device_has_same_owner(_Call, _Device, 'undefined') -> 'false'; device_has_same_owner(Call, DeviceDoc, TargetDeviceId) -> case kz_datamgr:open_cache_doc(kapps_call:account_db(Call), TargetDeviceId) of @@ -130,9 +130,9 @@ device_has_same_owner(Call, DeviceDoc, TargetDeviceId) -> 'false' end. --spec build_intercept_params(ne_binary(), ne_binary(), kapps_call:call()) -> - {'ok', kz_proplist()} | - {'error', ne_binary()}. +-spec build_intercept_params(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> + {'ok', kz_term:proplist()} | + {'error', kz_term:ne_binary()}. build_intercept_params(Number, <<"device">>, Call) -> AccountDb = kapps_call:account_db(Call), case cf_util:endpoint_id_by_sip_username(AccountDb, Number) of @@ -153,9 +153,9 @@ build_intercept_params(_ ,'undefined', _) -> build_intercept_params(_, Other, _) -> {'error', <>}. --spec params_from_data(ne_binary(), kz_json:object(), kapps_call:call()) -> - {'ok', kz_proplist()} | - {'error', ne_binary()}. +-spec params_from_data(kz_term:ne_binary(), kz_json:object(), kapps_call:call()) -> + {'ok', kz_term:proplist()} | + {'error', kz_term:ne_binary()}. params_from_data(<<"user">>, Data, _Call) -> EndpointId = kz_doc:id(Data), {'ok', [{<<"user_id">>, EndpointId}]}; diff --git a/applications/callflow/src/module/cf_lookupcidname.erl b/applications/callflow/src/module/cf_lookupcidname.erl index e44b4922292..5374dd3af18 100644 --- a/applications/callflow/src/module/cf_lookupcidname.erl +++ b/applications/callflow/src/module/cf_lookupcidname.erl @@ -34,21 +34,21 @@ handle(Data, Call) -> end, handle_caller_name(Call, CallerName). --spec handle_caller_name(kapps_call:call(), api_ne_binary()) -> 'ok'. +-spec handle_caller_name(kapps_call:call(), kz_term:api_ne_binary()) -> 'ok'. handle_caller_name(Call, 'undefined') -> cf_exe:continue(Call); handle_caller_name(Call, CallerName) -> lager:info("setting caller name to ~p", [CallerName]), cf_exe:continue(kapps_call:set_caller_id_name(CallerName, Call)). --type match_number_result() :: {'stop', api_binary()} | 'continue'. --spec match_number_in_lists(ne_binary(), ne_binary(), ne_binaries()) -> +-type match_number_result() :: {'stop', kz_term:api_binary()} | 'continue'. +-spec match_number_in_lists(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binaries()) -> match_number_result(). match_number_in_lists(AccountDb, Number, Lists) -> Prefixes = build_keys(Number), match_prefixes_in_lists(AccountDb, Prefixes, Lists). --spec match_prefixes_in_lists(ne_binary(), ne_binaries(), ne_binaries()) -> +-spec match_prefixes_in_lists(kz_term:ne_binary(), kz_term:ne_binaries(), kz_term:ne_binaries()) -> match_number_result(). match_prefixes_in_lists(AccountDb, Prefixes, [ListId | Rest]) -> case match_prefixes_in_list(AccountDb, Prefixes, ListId) of @@ -59,7 +59,7 @@ match_prefixes_in_lists(_AccountDb, _Number, []) -> lager:debug("no matching prefix"), 'continue'. --spec match_prefixes_in_list(ne_binary(), ne_binaries(), ne_binary()) -> +-spec match_prefixes_in_list(kz_term:ne_binary(), kz_term:ne_binaries(), kz_term:ne_binary()) -> match_number_result(). match_prefixes_in_list(AccountDb, Prefixes, ListId) -> Keys = [[ListId, Prefix] || Prefix <- Prefixes], @@ -93,19 +93,19 @@ get_prefix(JObj) -> kz_json:get_ne_binary_value(<<"number">>, Doc, kz_json:get_ne_binary_value(<<"prefix">>, Doc)). %% TODO: this function from hon_util, may be place it somewhere in library? --spec build_keys(ne_binary()) -> binaries(). +-spec build_keys(kz_term:ne_binary()) -> kz_term:binaries(). build_keys(<<"+", E164/binary>>) -> build_keys(E164); build_keys(<>) -> build_keys(Rest, D, [D]). --spec build_keys(binary(), binary(), ne_binaries()) -> ne_binaries(). +-spec build_keys(binary(), binary(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). build_keys(<>, Prefix, Acc) -> build_keys(Rest, <>, [<> | Acc]); build_keys(<<>>, _, Acc) -> Acc. --spec match_regexp_in_list(ne_binary(), ne_binary(), ne_binary()) -> - 'continue' | {'stop', api_binary()}. +-spec match_regexp_in_list(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> + 'continue' | {'stop', kz_term:api_binary()}. match_regexp_in_list(AccountDb, Number, ListId) when is_binary(ListId) -> case fetch_regexes(AccountDb, ListId) of {'ok', Regexps} -> @@ -115,7 +115,7 @@ match_regexp_in_list(AccountDb, Number, ListId) when is_binary(ListId) -> 'continue' end. --spec fetch_regexes(ne_binary(), ne_binary()) -> +-spec fetch_regexes(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:objects()} | {'error', any()}. fetch_regexes(AccountDb, ListId) -> @@ -126,8 +126,8 @@ fetch_regexes(AccountDb, ListId) -> ] ). --spec match_regexp_in_lists(ne_binary(), ne_binary(), ne_binary() | ne_binaries()) -> - api_ne_binary(). +-spec match_regexp_in_lists(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary() | kz_term:ne_binaries()) -> + kz_term:api_ne_binary(). match_regexp_in_lists(AccountDb, Number, [ListId | Rest]) -> case match_regexp_in_list(AccountDb, Number, ListId) of 'continue' -> match_regexp_in_lists(AccountDb, Number, Rest); @@ -136,9 +136,9 @@ match_regexp_in_lists(AccountDb, Number, [ListId | Rest]) -> match_regexp_in_lists(_, _, []) -> 'undefined'. --spec match_regexp(kz_json:objects(), ne_binary()) -> +-spec match_regexp(kz_json:objects(), kz_term:ne_binary()) -> 'continue' | - {'stop', api_binary()}. + {'stop', kz_term:api_binary()}. match_regexp([Re | Rest], Number) -> case re:run(Number, kz_json:get_value(<<"value">>, Re)) of 'nomatch' -> match_regexp(Rest, Number); diff --git a/applications/callflow/src/module/cf_manual_presence.erl b/applications/callflow/src/module/cf_manual_presence.erl index 53beada82ae..18c3903ead7 100644 --- a/applications/callflow/src/module/cf_manual_presence.erl +++ b/applications/callflow/src/module/cf_manual_presence.erl @@ -29,7 +29,7 @@ handle(Data, Call) -> update_presence(Status, PresenceId, Call), cf_exe:continue(Call). --spec update_presence(ne_binary(), ne_binary(), kapps_call:call()) -> 'ok'. +-spec update_presence(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> 'ok'. update_presence(<<"idle">>, PresenceId, Call) -> _ = kz_datamgr:update_doc(kapps_call:account_db(Call), ?MANUAL_PRESENCE_DOC, [{PresenceId, <<"terminated">>}]), kapps_call_command:presence(<<"terminated">>, PresenceId, kz_term:to_hex_binary(crypto:hash(md5, PresenceId))); diff --git a/applications/callflow/src/module/cf_menu.erl b/applications/callflow/src/module/cf_menu.erl index e179acf9860..1d00871ee62 100644 --- a/applications/callflow/src/module/cf_menu.erl +++ b/applications/callflow/src/module/cf_menu.erl @@ -19,14 +19,14 @@ -define(MOD_CONFIG_CAT, <<(?CF_CONFIG_CAT)/binary, ".menu">>). --record(menu_keys, {save = <<"1">> :: ne_binary() %% Record Review - ,listen = <<"2">> :: ne_binary() - ,record = <<"3">> :: ne_binary() +-record(menu_keys, {save = <<"1">> :: kz_term:ne_binary() %% Record Review + ,listen = <<"2">> :: kz_term:ne_binary() + ,record = <<"3">> :: kz_term:ne_binary() }). -type menu_keys() :: #menu_keys{}. -define(MENU_KEY_LENGTH, 1). --record(cf_menu_data, {menu_id :: api_ne_binary() +-record(cf_menu_data, {menu_id :: kz_term:api_ne_binary() ,name = <<>> :: binary() ,retries = 3 :: pos_integer() ,timeout = 10000 :: pos_integer() @@ -36,10 +36,10 @@ ,hunt_allow = <<>> :: binary() ,record_pin = <<>> :: binary() ,record_from_offnet = 'false' :: boolean() - ,greeting_id :: api_ne_binary() - ,exit_media = 'true' :: boolean() | ne_binary() - ,transfer_media = 'true' :: boolean() | ne_binary() - ,invalid_media = 'true' :: boolean() | ne_binary() + ,greeting_id :: kz_term:api_ne_binary() + ,exit_media = 'true' :: boolean() | kz_term:ne_binary() + ,transfer_media = 'true' :: boolean() | kz_term:ne_binary() + ,invalid_media = 'true' :: boolean() | kz_term:ne_binary() ,keys = #menu_keys{} :: menu_keys() ,interdigit_timeout = kapps_call_command:default_interdigit_timeout() :: pos_integer() }). @@ -147,7 +147,7 @@ menu_handle_no_digits(#cf_menu_data{retries=Retries}=Menu, Call) -> %% The primary sequence logic to route the collected digits %% @end %%-------------------------------------------------------------------- --spec try_match_digits(ne_binary(), menu(), kapps_call:call()) -> boolean(). +-spec try_match_digits(kz_term:ne_binary(), menu(), kapps_call:call()) -> boolean(). try_match_digits(Digits, Menu, Call) -> lager:info("trying to match digits ~s", [Digits]), is_callflow_child(Digits, Menu, Call) @@ -163,7 +163,7 @@ try_match_digits(Digits, Menu, Call) -> %% Check if the digits are a exact match for the auto-attendant children %% @end %%-------------------------------------------------------------------- --spec is_callflow_child(ne_binary(), menu(), kapps_call:call()) -> boolean(). +-spec is_callflow_child(kz_term:ne_binary(), menu(), kapps_call:call()) -> boolean(). is_callflow_child(Digits, _, Call) -> case cf_exe:attempt(Digits, Call) of {'attempt_resp', 'ok'} -> @@ -178,7 +178,7 @@ is_callflow_child(Digits, _, Call) -> %% Check if hunting is enabled %% @end %%-------------------------------------------------------------------- --spec is_hunt_enabled(ne_binary(), menu(), kapps_call:call()) -> boolean(). +-spec is_hunt_enabled(kz_term:ne_binary(), menu(), kapps_call:call()) -> boolean(). is_hunt_enabled(_, #cf_menu_data{hunt=Hunt}, _) -> Hunt. @@ -188,7 +188,7 @@ is_hunt_enabled(_, #cf_menu_data{hunt=Hunt}, _) -> %% Check whitelist hunt digit patterns %% @end %%-------------------------------------------------------------------- --spec is_hunt_allowed(ne_binary(), menu(), kapps_call:call()) -> boolean(). +-spec is_hunt_allowed(kz_term:ne_binary(), menu(), kapps_call:call()) -> boolean(). is_hunt_allowed(_, #cf_menu_data{hunt_allow = <<>>}, _) -> lager:info("hunt_allow implicitly accepted digits"), 'true'; @@ -212,7 +212,7 @@ is_hunt_allowed(Digits, #cf_menu_data{hunt_allow=RegEx}, _) -> %% Check blacklisted hunt digit patterns %% @end %%-------------------------------------------------------------------- --spec is_hunt_denied(ne_binary(), menu(), kapps_call:call()) -> boolean(). +-spec is_hunt_denied(kz_term:ne_binary(), menu(), kapps_call:call()) -> boolean(). is_hunt_denied(_, #cf_menu_data{hunt_deny = <<>>}, _) -> lager:info("hunt_deny implicitly accepted digits"), 'false'; @@ -236,7 +236,7 @@ is_hunt_denied(Digits, #cf_menu_data{hunt_deny=RegEx}, _) -> %% Hunt for a callflow with these numbers %% @end %%-------------------------------------------------------------------- --spec hunt_for_callflow(ne_binary(), menu(), kapps_call:call()) -> boolean(). +-spec hunt_for_callflow(kz_term:ne_binary(), menu(), kapps_call:call()) -> boolean(). hunt_for_callflow(Digits, Menu, Call) -> AccountId = kapps_call:account_id(Call), lager:info("hunting for ~s in account ~s", [Digits, AccountId]), @@ -355,7 +355,7 @@ play_exit_prompt(#cf_menu_data{exit_media=Id}, Call) -> %% %% @end %%-------------------------------------------------------------------- --spec get_prompt(menu(), kapps_call:call()) -> ne_binary(). +-spec get_prompt(menu(), kapps_call:call()) -> kz_term:ne_binary(). get_prompt(#cf_menu_data{greeting_id='undefined'}, Call) -> kapps_call:get_prompt(Call, <<"menu-no_prompt">>); get_prompt(#cf_menu_data{greeting_id = <<"local_stream://", _/binary>> = ID}, _) -> @@ -368,7 +368,7 @@ get_prompt(#cf_menu_data{greeting_id=Id}, Call) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec store_recording(ne_binary(), ne_binary(), kapps_call:call()) -> +-spec store_recording(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> {'ok', kz_json:object()} | {'error', kz_json:object()}. store_recording(AttachmentName, MediaId, Call) -> @@ -387,7 +387,7 @@ store_recording(AttachmentName, MediaId, Call) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_new_attachment_url(binary(), binary(), kapps_call:call()) -> ne_binary(). +-spec get_new_attachment_url(binary(), binary(), kapps_call:call()) -> kz_term:ne_binary(). get_new_attachment_url(AttachmentName, MediaId, Call) -> AccountDb = kapps_call:account_db(Call), _ = case kz_datamgr:open_cache_doc(AccountDb, MediaId) of @@ -397,7 +397,7 @@ get_new_attachment_url(AttachmentName, MediaId, Call) -> end, kz_media_url:store(AccountDb, MediaId, AttachmentName). --spec maybe_delete_attachments(ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec maybe_delete_attachments(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. maybe_delete_attachments(AccountDb, _MediaId, JObj) -> case kz_doc:maybe_remove_attachments(JObj) of {'false', _} -> 'ok'; @@ -411,7 +411,7 @@ maybe_delete_attachments(AccountDb, _MediaId, JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec tmp_file() -> ne_binary(). +-spec tmp_file() -> kz_term:ne_binary(). tmp_file() -> <<(kz_term:to_hex_binary(crypto:strong_rand_bytes(16)))/binary, ".mp3">>. @@ -421,7 +421,7 @@ tmp_file() -> %% %% @end %%-------------------------------------------------------------------- --spec review_recording(ne_binary(), menu(), kapps_call:call()) -> +-spec review_recording(kz_term:ne_binary(), menu(), kapps_call:call()) -> {'ok', 'record' | 'save' | 'no_selection'}. review_recording(MediaName, #cf_menu_data{keys=#menu_keys{listen=ListenKey ,record=RecordKey @@ -450,7 +450,7 @@ review_recording(MediaName, #cf_menu_data{keys=#menu_keys{listen=ListenKey %% @doc %% @end %%-------------------------------------------------------------------- --spec recording_media_doc(ne_binary(), menu(), kapps_call:call()) -> ne_binary(). +-spec recording_media_doc(kz_term:ne_binary(), menu(), kapps_call:call()) -> kz_term:ne_binary(). recording_media_doc(Type, #cf_menu_data{name=MenuName ,menu_id=Id }, Call) -> @@ -472,9 +472,9 @@ recording_media_doc(Type, #cf_menu_data{name=MenuName %% %% @end %%-------------------------------------------------------------------- --spec update_doc(text(), kz_json:json_term(), menu() | ne_binary(), kapps_call:call() | ne_binary()) -> +-spec update_doc(kz_term:text(), kz_json:json_term(), menu() | kz_term:ne_binary(), kapps_call:call() | kz_term:ne_binary()) -> 'ok' | {'error', atom()}. --spec update_doc(kz_proplist(), ne_binary(), kapps_call:call() | ne_binary()) -> +-spec update_doc(kz_term:proplist(), kz_term:ne_binary(), kapps_call:call() | kz_term:ne_binary()) -> 'ok' | {'error', atom()}. update_doc(Key, Value, #cf_menu_data{menu_id=Id}, Db) -> update_doc(Key, Value, Id, Db); diff --git a/applications/callflow/src/module/cf_missed_call_alert.erl b/applications/callflow/src/module/cf_missed_call_alert.erl index 6c3eb35b2e7..351aaea91bf 100644 --- a/applications/callflow/src/module/cf_missed_call_alert.erl +++ b/applications/callflow/src/module/cf_missed_call_alert.erl @@ -34,7 +34,7 @@ handle(Data, Call) -> %% from a resource external to kazoo %% @end %%-------------------------------------------------------------------- --spec maybe_add_handle(kz_json:object(), kapps_call:call(), api_binary()) -> kapps_call:call(). +-spec maybe_add_handle(kz_json:object(), kapps_call:call(), kz_term:api_binary()) -> kapps_call:call(). maybe_add_handle(Data, Call, 'undefined') -> lager:debug("inbound call from another account, adding termination handler..."), add_handler(Data, Call); @@ -76,7 +76,7 @@ should_handle_termination(Call) -> not kapps_call:call_bridged(Call) andalso not kapps_call:message_left(Call). --spec send_missed_alert(kapps_call:call(), kz_json:object(), api_ne_binaries()) -> 'ok'. +-spec send_missed_alert(kapps_call:call(), kz_json:object(), kz_term:api_ne_binaries()) -> 'ok'. send_missed_alert(Call, Notify, Emails) -> lager:debug("trying to publish missed_call_alert for call-id ~s", [kapps_call:call_id_direct(Call)]), Props = props:filter_undefined( @@ -103,7 +103,7 @@ send_missed_alert(Call, Notify, Emails) -> %% @doc Try to find email addressed using module's data object %% @end %%-------------------------------------------------------------------- --spec find_email_addresses(kapps_call:call(), kz_json:objects()) -> ne_binaries(). +-spec find_email_addresses(kapps_call:call(), kz_json:objects()) -> kz_term:ne_binaries(). find_email_addresses(Call, Recipients) -> AccountDb = kz_util:format_account_db(kapps_call:account_id(Call)), lager:debug("call went unanswered and left no voicemail message, finding configured email addresses"), @@ -123,7 +123,7 @@ find_email_addresses(Call, Recipients) -> %% addresses from %% @end %%-------------------------------------------------------------------- --spec find_email_addresses_by_type(ne_binary(), kz_json:object(), api_binary()) -> ne_binaries(). +-spec find_email_addresses_by_type(kz_term:ne_binary(), kz_json:object(), kz_term:api_binary()) -> kz_term:ne_binaries(). find_email_addresses_by_type(AccountDb, JObj, <<"email">>) -> get_email_addresses(AccountDb, kz_json:get_value(<<"id">>, JObj)); find_email_addresses_by_type(AccountDb, JObj, <<"user">>) -> @@ -136,7 +136,7 @@ find_email_addresses_by_type(_AccountDb, _JObj, _) -> %% @doc an email or a list of emails %% @end %%-------------------------------------------------------------------- --spec get_email_addresses(ne_binary(), api_binary() | ne_binaries()) -> ne_binaries(). +-spec get_email_addresses(kz_term:ne_binary(), kz_term:api_binary() | kz_term:ne_binaries()) -> kz_term:ne_binaries(). get_email_addresses(_AccountDb, 'undefined') -> []; get_email_addresses(_AccountDb, <<_/binary>>=Email) -> [Email]; get_email_addresses(_AccountDb, Emails) when is_list(Emails) -> @@ -149,13 +149,13 @@ get_email_addresses(_AccountDb, _) -> []. %% addresses from %% @end %%-------------------------------------------------------------------- --spec find_users_addresses(ne_binary(), api_binary() | ne_binaries()) -> ne_binaries(). +-spec find_users_addresses(kz_term:ne_binary(), kz_term:api_binary() | kz_term:ne_binaries()) -> kz_term:ne_binaries(). find_users_addresses(_AccountDb, 'undefined') -> []; find_users_addresses(AccountDb, <<_/binary>>=UserId) -> bulk_read_emails(AccountDb, [UserId]); find_users_addresses(AccountDb, Ids) when is_list(Ids) -> bulk_read_emails(AccountDb, Ids); find_users_addresses(_AccountDb, _) -> []. --spec bulk_read_emails(ne_binary(), ne_binaries()) -> ne_binaries(). +-spec bulk_read_emails(kz_term:ne_binary(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). bulk_read_emails(AccountDb, Ids) -> case kz_datamgr:open_docs(AccountDb, Ids) of {'ok', JObjs} -> diff --git a/applications/callflow/src/module/cf_move.erl b/applications/callflow/src/module/cf_move.erl index 662c8e61196..7dcc336803f 100644 --- a/applications/callflow/src/module/cf_move.erl +++ b/applications/callflow/src/module/cf_move.erl @@ -42,7 +42,7 @@ handle(_Data, Call) -> end, cf_exe:stop(Call). --spec get_channels(ne_binary(), kapps_call:call()) -> dict:dict(). +-spec get_channels(kz_term:ne_binary(), kapps_call:call()) -> dict:dict(). get_channels(OwnerId, Call) -> DeviceIds = kz_attributes:owned_by(OwnerId, <<"device">>, Call), lager:debug("devices owned by ~p: ~p", [OwnerId, DeviceIds]), diff --git a/applications/callflow/src/module/cf_nomorobo.erl b/applications/callflow/src/module/cf_nomorobo.erl index c5bc958956f..29b8e6f6bed 100644 --- a/applications/callflow/src/module/cf_nomorobo.erl +++ b/applications/callflow/src/module/cf_nomorobo.erl @@ -64,7 +64,7 @@ handle(Data, Call) -> end. -spec nomorobo_score(kz_json:object(), kapps_call:call()) -> - api_integer(). + kz_term:api_integer(). nomorobo_score(Data, Call) -> URI = nomorobo_uri(Call), @@ -85,7 +85,7 @@ nomorobo_score(Data, Call) -> 'undefined' end. --spec nomorobo_req(ne_binary(), kz_json:object()) -> kz_http:ret(). +-spec nomorobo_req(kz_term:ne_binary(), kz_json:object()) -> kz_http:ret(). nomorobo_req(URI, Data) -> Username = kz_json:get_binary_value(<<"username">>, Data), Password = kz_json:get_binary_value(<<"password">>, Data), @@ -95,7 +95,7 @@ nomorobo_req(URI, Data) -> kz_http:get(kz_term:to_list(URI), [], Options). --spec nomorobo_uri(kapps_call:call()) -> ne_binary(). +-spec nomorobo_uri(kapps_call:call()) -> kz_term:ne_binary(). nomorobo_uri(Call) -> lists:foldl(fun uri_replace/2 ,?URL @@ -103,10 +103,10 @@ nomorobo_uri(Call) -> ,{<<"{FROM}">>, knm_converters:to_npan(kapps_call:caller_id_number(Call))} ]). --spec uri_replace({ne_binary(), ne_binary()}, ne_binary()) -> ne_binary(). +-spec uri_replace({kz_term:ne_binary(), kz_term:ne_binary()}, kz_term:ne_binary()) -> kz_term:ne_binary(). uri_replace({S, R}, U) -> binary:replace(U, S, R). --spec nomorobo_score_from_resp(binary()) -> api_integer(). +-spec nomorobo_score_from_resp(binary()) -> kz_term:api_integer(). nomorobo_score_from_resp(Body) -> try kz_json:decode(Body) of JObj -> trunc(kz_json:get_float_value(<<"score">>, JObj) * 10) @@ -124,11 +124,11 @@ continue_to_score(Call, Score) -> lager:info("attempting to branch to '~s' from score '~p'", [Branch, Score]), cf_exe:continue(Branch, Call). --spec nomorobo_branch(integer(), integers()) -> ne_binary(). +-spec nomorobo_branch(integer(), kz_term:integers()) -> kz_term:ne_binary(). nomorobo_branch(Score, [Lo|Keys]) -> branch_to_binary(nomorobo_branch(Score, Lo, Keys)). --spec branch_to_binary(integer()) -> ne_binary(). +-spec branch_to_binary(integer()) -> kz_term:ne_binary(). branch_to_binary(-1) -> ?DEFAULT_CHILD_KEY; branch_to_binary(I) -> kz_term:to_binary(I). @@ -152,8 +152,8 @@ continue_to_default(Call) -> cf_exe:stop(Call) end. --spec nomorobo_branches({'branch_keys', ne_binaries()}) -> integers(). --spec nomorobo_branches(ne_binaries(), integers()) -> integers(). +-spec nomorobo_branches({'branch_keys', kz_term:ne_binaries()}) -> kz_term:integers(). +-spec nomorobo_branches(kz_term:ne_binaries(), kz_term:integers()) -> kz_term:integers(). nomorobo_branches({'branch_keys', Keys}) -> nomorobo_branches(Keys, []). diff --git a/applications/callflow/src/module/cf_page_group.erl b/applications/callflow/src/module/cf_page_group.erl index ff77c548573..e1c2c24f7d0 100644 --- a/applications/callflow/src/module/cf_page_group.erl +++ b/applications/callflow/src/module/cf_page_group.erl @@ -75,7 +75,7 @@ send_page(Endpoints, Timeout, CCVs, Options, Call) -> ,Call ). --spec get_endpoints(api_objects(), kapps_call:call()) -> kz_json:objects(). +-spec get_endpoints(kz_term:api_objects(), kapps_call:call()) -> kz_json:objects(). get_endpoints(undefined, Call) -> get_endpoints([], Call); get_endpoints(Members, Call) -> S = self(), @@ -97,7 +97,7 @@ get_endpoints(Members, Call) -> end, [], Builders). -spec resolve_endpoint_ids(kz_json:objects(), kapps_call:call()) -> - [{ne_binary(), kz_json:object()}]. + [{kz_term:ne_binary(), kz_json:object()}]. resolve_endpoint_ids(Members, Call) -> [{Id, kz_json:set_value(<<"source">>, kz_term:to_binary(?MODULE), Member)} || {Type, Id, Member} <- resolve_endpoint_ids(Members, [], Call) @@ -105,7 +105,7 @@ resolve_endpoint_ids(Members, Call) -> ,Id =/= kapps_call:authorizing_id(Call) ]. --type endpoint_intermediate() :: {ne_binary(), ne_binary(), api_object()}. +-type endpoint_intermediate() :: {kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_object()}. -type endpoint_intermediates() :: [endpoint_intermediate()]. -spec resolve_endpoint_ids(kz_json:objects(), endpoint_intermediates(), kapps_call:call()) -> endpoint_intermediates(). @@ -141,7 +141,7 @@ resolve_endpoint_ids([Member|Members], EndpointIds, Call) -> resolve_endpoint_ids(Members, [{Type, Id, Member}|EndpointIds], Call) end. --spec get_group_members(kz_json:object(), ne_binary(), kapps_call:call()) -> +-spec get_group_members(kz_json:object(), kz_term:ne_binary(), kapps_call:call()) -> kz_json:objects(). get_group_members(Member, Id, Call) -> AccountDb = kapps_call:account_db(Call), diff --git a/applications/callflow/src/module/cf_park.erl b/applications/callflow/src/module/cf_park.erl index ac8bc61efaf..d581ed6920b 100644 --- a/applications/callflow/src/module/cf_park.erl +++ b/applications/callflow/src/module/cf_park.erl @@ -44,7 +44,7 @@ %% call originator. %% @end %%-------------------------------------------------------------------- --spec update_presence(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec update_presence(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. update_presence(SlotNumber, _PresenceId, AccountDb) -> case get_slot(SlotNumber, AccountDb) of {'ok', Slot} -> update_presence(Slot); @@ -75,7 +75,7 @@ handle(Data, Call) -> handle_replaces(Data, Call, Replaces) end. --spec handle_replaces(kz_json:object(), kapps_call:call(), ne_binary()) -> +-spec handle_replaces(kz_json:object(), kapps_call:call(), kz_term:ne_binary()) -> 'ok' | {'error', 'timeout' | 'failed'}. handle_replaces(Data, Call, Replaces) -> @@ -83,13 +83,13 @@ handle_replaces(Data, Call, Replaces) -> {'ok', FoundInSlotNumber, Slot} = update_call_id(Replaces, Call), wait_for_pickup(FoundInSlotNumber, Slot, Data, Call). --spec handle_nomatch(kz_json:object(), kapps_call:call(), ne_binary(), kz_json:object(), ne_binary(), ne_binary()) -> 'ok'. +-spec handle_nomatch(kz_json:object(), kapps_call:call(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. handle_nomatch(Data, Call, PresenceType, ParkedCalls, SlotNumber, ReferredTo) -> lager:info("call was the result of a blind transfer, assuming intention was to park"), Slot = create_slot('undefined', PresenceType, SlotNumber, Data, 'false', Call), park_call(SlotNumber, Slot, ParkedCalls, ReferredTo, Data, Call). --spec handle_nomatch_with_empty_referred_to(kz_json:object(), kapps_call:call(), ne_binary(), kz_json:object(), ne_binary()) -> 'ok'. +-spec handle_nomatch_with_empty_referred_to(kz_json:object(), kapps_call:call(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> 'ok'. handle_nomatch_with_empty_referred_to(Data, Call, PresenceType, ParkedCalls, SlotNumber) -> lager:info("call was the result of a direct dial"), case kz_json:get_ne_binary_value(<<"action">>, Data, <<"park">>) of @@ -122,7 +122,7 @@ handle_nomatch_with_empty_referred_to(Data, Call, PresenceType, ParkedCalls, Slo end end. --spec direct_park(ne_binary(), kz_json:object(), kz_json:object(), kz_json:object(), kapps_call:call()) -> 'ok'. +-spec direct_park(kz_term:ne_binary(), kz_json:object(), kz_json:object(), kz_json:object(), kapps_call:call()) -> 'ok'. direct_park(SlotNumber, Slot, ParkedCalls, Data, Call) -> case save_slot(SlotNumber, Slot, ParkedCalls, Call) of {'ok', _} -> parked_call(SlotNumber, Slot, Data, Call); @@ -137,13 +137,13 @@ direct_park(SlotNumber, Slot, ParkedCalls, Data, Call) -> %% Determine the appropriate action to retrieve a parked call %% @end %%-------------------------------------------------------------------- --spec retrieve(ne_binary(), kapps_call:call()) -> +-spec retrieve(kz_term:ne_binary(), kapps_call:call()) -> {'ok', 'channel_hungup'} | {'error', 'slot_empty' | 'timeout' | 'failed'}. retrieve(SlotNumber, Call) -> retrieve(SlotNumber, get_slot(SlotNumber, kapps_call:account_db(Call)), 1, Call). --spec retrieve(ne_binary(), {'ok', kz_json:object()} | {'error', any()}, integer(), kapps_call:call()) -> +-spec retrieve(kz_term:ne_binary(), {'ok', kz_json:object()} | {'error', any()}, integer(), kapps_call:call()) -> {'ok', 'channel_hungup'} | {'error', 'slot_empty' | 'timeout' | 'failed'}. retrieve(SlotNumber, {'error', _}, _Try, _Call) -> @@ -174,7 +174,7 @@ retrieve(SlotNumber, {'ok', Slot}, Try, Call) -> {'error', _}=E -> E end. --spec maybe_retrieve_slot(kz_json:object()) -> {'retry' | 'ok', ne_binary()} | {'error', 'slot_empty'}. +-spec maybe_retrieve_slot(kz_json:object()) -> {'retry' | 'ok', kz_term:ne_binary()} | {'error', 'slot_empty'}. maybe_retrieve_slot(Slot) -> ParkedCall = kz_json:get_ne_binary_value(<<"Call-ID">>, Slot), case kz_json:is_true(<<"Attended">>, Slot) of @@ -183,7 +183,7 @@ maybe_retrieve_slot(Slot) -> 'false' -> {'error', 'slot_empty'} end. --spec retrieve_slot(ne_binary(), kapps_call:call()) -> +-spec retrieve_slot(kz_term:ne_binary(), kapps_call:call()) -> 'ok' | {'error', 'timeout' | 'failed'}. retrieve_slot(ParkedCall, Call) -> @@ -191,7 +191,7 @@ retrieve_slot(ParkedCall, Call) -> _ = send_pickup(ParkedCall, Call), wait_for_pickup(Call). --spec send_pickup(ne_binary(), kapps_call:call()) -> 'ok'. +-spec send_pickup(kz_term:ne_binary(), kapps_call:call()) -> 'ok'. send_pickup(ParkedCall, Call) -> Req = [{<<"Unbridged-Only">>, 'true'} ,{<<"Application-Name">>, <<"call_pickup">>} @@ -214,7 +214,7 @@ wait_for_pickup(Call) -> E end. --spec pickup_event(kapps_call:call(), {ne_binary(), ne_binary()}, kz_json:object()) -> +-spec pickup_event(kapps_call:call(), {kz_term:ne_binary(), kz_term:ne_binary()}, kz_json:object()) -> 'ok' | {'error', 'failed'}. pickup_event(_Call, {<<"error">>, <<"dialplan">>}, Evt) -> @@ -231,7 +231,7 @@ pickup_event(Call, _Type, _Evt) -> %% Determine the appropriate action to park the current call scenario %% @end %%-------------------------------------------------------------------- --spec park_call(ne_binary(), kz_json:object(), kz_json:object(), api_binary(), kz_json:object(), kapps_call:call()) -> 'ok'. +-spec park_call(kz_term:ne_binary(), kz_json:object(), kz_json:object(), kz_term:api_binary(), kz_json:object(), kapps_call:call()) -> 'ok'. park_call(SlotNumber, Slot, ParkedCalls, ReferredTo, Data, Call) -> lager:info("attempting to park call in slot ~s", [SlotNumber]), case {ReferredTo, save_slot(SlotNumber, Slot, ParkedCalls, Call)} of @@ -273,7 +273,7 @@ park_call(SlotNumber, Slot, ParkedCalls, ReferredTo, Data, Call) -> {_, {'ok', _}} -> parked_call(SlotNumber, Slot, Data, Call) end. --spec parked_call(ne_binary(), kz_json:object(), kz_json:object(), kapps_call:call()) -> 'ok'. +-spec parked_call(kz_term:ne_binary(), kz_json:object(), kz_json:object(), kapps_call:call()) -> 'ok'. parked_call(SlotNumber, Slot, Data, Call) -> ParkedCallId = kz_json:get_ne_binary_value(<<"Call-ID">>, Slot), lager:info("call ~s parked in slot ~s", [ParkedCallId, SlotNumber]), @@ -294,7 +294,7 @@ wait_for_hangup(Call) -> %% Builds the json object representing the call in the parking slot %% @end %%-------------------------------------------------------------------- --spec create_slot(api_binary(), ne_binary(), ne_binary(), kz_json:object(), boolean(), kapps_call:call()) -> kz_json:object(). +-spec create_slot(kz_term:api_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), boolean(), kapps_call:call()) -> kz_json:object(). create_slot(ParkerCallId, PresenceType, SlotNumber, Data, Attended, Call) -> CallId = cf_exe:callid(Call), RingbackId = maybe_get_ringback_id(Call), @@ -321,14 +321,14 @@ create_slot(ParkerCallId, PresenceType, SlotNumber, Data, Attended, Call) -> ,{?PRESENCE_TYPE_KEY, PresenceType} ]). --spec slot_presence_id(ne_binary(), kz_json:object(), kapps_call:call()) -> ne_binary(). +-spec slot_presence_id(kz_term:ne_binary(), kz_json:object(), kapps_call:call()) -> kz_term:ne_binary(). slot_presence_id(SlotNumber, Data, Call) -> case kz_json:is_true(<<"custom_presence_id">>, Data, 'false') of 'true' -> maybe_custom_slot_presence_id(SlotNumber, Data, Call); 'false' -> slot_presence_id(SlotNumber, Call) end. --spec slot_presence_id(ne_binary(), kapps_call:call()) -> ne_binary(). +-spec slot_presence_id(kz_term:ne_binary(), kapps_call:call()) -> kz_term:ne_binary(). slot_presence_id(SlotNumber, Call) -> User = kapps_call:request_user(Call), case kapps_call:kvs_fetch('cf_capture_group', <<>>, Call) of @@ -336,14 +336,14 @@ slot_presence_id(SlotNumber, Call) -> _Other -> <> end. --spec maybe_custom_slot_presence_id(ne_binary(), kz_json:object(), kapps_call:call()) -> ne_binary(). +-spec maybe_custom_slot_presence_id(kz_term:ne_binary(), kz_json:object(), kapps_call:call()) -> kz_term:ne_binary(). maybe_custom_slot_presence_id(SlotNumber, Data, Call) -> case kz_json:get_ne_binary_value(<<"presence_id">>, slot_configuration(Data, SlotNumber)) of 'undefined' -> maybe_custom_presence_id(Data, Call); PresenceId -> PresenceId end. --spec maybe_custom_presence_id(kz_json:object(), kapps_call:call()) -> ne_binary(). +-spec maybe_custom_presence_id(kz_json:object(), kapps_call:call()) -> kz_term:ne_binary(). maybe_custom_presence_id(Data, Call) -> case kz_json:get_ne_binary_value(<<"presence_id">>, Data) of 'undefined' -> kapps_call:request_user(Call); @@ -357,7 +357,7 @@ maybe_custom_presence_id(Data, Call) -> %% was provided %% @end %%-------------------------------------------------------------------- --spec get_slot_number(kz_json:object(), api_binary()) -> ne_binary(). +-spec get_slot_number(kz_json:object(), kz_term:api_binary()) -> kz_term:ne_binary(). get_slot_number(_, CaptureGroup) when byte_size(CaptureGroup) > 0 -> CaptureGroup; get_slot_number(ParkedCalls, _) -> @@ -383,7 +383,7 @@ find_slot_number([A|[B|_]=Slots]) -> %% and tries again, determining the new slot. %% @end %%-------------------------------------------------------------------- --spec save_slot(ne_binary(), kz_json:object(), kz_json:object(), kapps_call:call()) -> +-spec save_slot(kz_term:ne_binary(), kz_json:object(), kz_json:object(), kapps_call:call()) -> {'ok', kz_json:object()} | {'error', atom()}. save_slot(SlotNumber, Slot, ParkedCalls, Call) -> @@ -408,7 +408,7 @@ save_slot(SlotNumber, Slot, ParkedCalls, Call) -> end end. --spec do_save_slot(ne_binary(), kz_json:object(), kapps_call:call()) -> +-spec do_save_slot(kz_term:ne_binary(), kz_json:object(), kapps_call:call()) -> {'ok', kz_json:object()} | {'error', atom()}. do_save_slot(SlotNumber, Slot, Call) -> @@ -433,8 +433,8 @@ do_save_slot(SlotNumber, Slot, Call) -> %% actuall "A-Leg". Find the old callid and update it with the new one. %% @end %%-------------------------------------------------------------------- --spec update_call_id(ne_binary(), kapps_call:call()) -> - {'ok', ne_binary(), kz_json:object()}. +-spec update_call_id(kz_term:ne_binary(), kapps_call:call()) -> + {'ok', kz_term:ne_binary(), kz_json:object()}. update_call_id(Replaces, Call) -> CallId = cf_exe:callid(Call), lager:info("update parked call id ~s with new call id ~s", [Replaces, CallId]), @@ -491,7 +491,7 @@ maybe_set_hold_media(JObj, Call) -> maybe_set_hold_media_from_ringback(JObj, Call, RingbackId) end. --spec maybe_set_hold_media_from_ringback(kz_json:object(), kapps_call:call(), ne_binary()) -> kz_json:object(). +-spec maybe_set_hold_media_from_ringback(kz_json:object(), kapps_call:call(), kz_term:ne_binary()) -> kz_json:object(). maybe_set_hold_media_from_ringback(JObj, Call, RingbackId) -> case kz_attributes:moh_attributes(RingbackId, <<"media_id">>, Call) of 'undefined' -> JObj; @@ -499,7 +499,7 @@ maybe_set_hold_media_from_ringback(JObj, Call, RingbackId) -> kz_json:set_value(<<"Hold-Media">>, RingbackHoldMedia, JObj) end. --spec maybe_get_ringback_id(kapps_call:call()) -> api_binary(). +-spec maybe_get_ringback_id(kapps_call:call()) -> kz_term:api_binary(). maybe_get_ringback_id(Call) -> Referred = kapps_call:custom_channel_var(<<"Referred-By">>, Call), ReOptions = [{'capture', [1], 'binary'}], @@ -515,7 +515,7 @@ maybe_get_ringback_id(Call) -> %% the list does not exist then it returns an new empty instance %% @end %%-------------------------------------------------------------------- --spec get_parked_calls(kapps_call:call() | ne_binary()) -> kz_json:object(). +-spec get_parked_calls(kapps_call:call() | kz_term:ne_binary()) -> kz_json:object(). get_parked_calls(?NE_BINARY = AccountDb) -> Options = ['include_docs' ,{'doc_type', ?PARKED_CALL_DOC_TYPE} @@ -532,14 +532,14 @@ load_parked_calls(JObjs) -> Slots = [load_parked_call(JObj) || JObj <- JObjs], kz_json:from_list([{<<"slots">>, kz_json:from_list(Slots)}]). --spec load_parked_call(kz_json:object()) -> {ne_binary(), kz_json:object()}. +-spec load_parked_call(kz_json:object()) -> {kz_term:ne_binary(), kz_json:object()}. load_parked_call(JObj) -> Doc = kz_json:get_json_value(<<"doc">>, JObj), <<"parking-slot-", SlotNumber/binary>> = kz_doc:id(Doc), Slot = kz_json:get_json_value(<<"slot">>, Doc), {SlotNumber, kz_json:set_value(<<"pvt_fields">>, kz_doc:private_fields(Doc), Slot)}. --spec maybe_cleanup_slot(ne_binary(), kapps_call:call(), ne_binary()) -> 'ok'. +-spec maybe_cleanup_slot(kz_term:ne_binary(), kapps_call:call(), kz_term:ne_binary()) -> 'ok'. maybe_cleanup_slot(SlotNumber, Call, OldCallId) -> _ = kz_util:put_callid(OldCallId), ParkedCalls = get_parked_calls(Call), @@ -554,7 +554,7 @@ maybe_cleanup_slot(SlotNumber, Call, OldCallId) -> maybe_cleanup_slot(SlotNumber, OldCallId, ParkedCallId, AccountDb) end. --spec maybe_cleanup_slot(ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec maybe_cleanup_slot(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. maybe_cleanup_slot(SlotNumber, CallId, CallId, AccountDb) -> lager:info("callid (~p) in parking slot ~p has not changed, cleaning up...", [CallId, SlotNumber]), cleanup_slot(SlotNumber, CallId, AccountDb); @@ -568,7 +568,7 @@ maybe_cleanup_slot(_SlotNumber, _OldCallId, _NewCallId, _AccountDb) -> %% %% @end %%-------------------------------------------------------------------- --spec cleanup_slot(ne_binary(), ne_binary(), ne_binary()) -> +-spec cleanup_slot(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. cleanup_slot(SlotNumber, ParkedCallId, AccountDb) -> @@ -601,7 +601,7 @@ cleanup_slot(SlotNumber, ParkedCallId, AccountDb) -> %% %% @end %%-------------------------------------------------------------------- --spec wait_for_pickup(ne_binary(), kz_json:object(), kz_json:object(), kapps_call:call()) -> 'ok'. +-spec wait_for_pickup(kz_term:ne_binary(), kz_json:object(), kz_json:object(), kapps_call:call()) -> 'ok'. wait_for_pickup(SlotNumber, Slot, Data, Call) -> RingbackId = kz_json:get_ne_binary_value(<<"Ringback-ID">>, Slot), HoldMedia = kz_json:get_ne_binary_value(<<"Hold-Media">>, Slot), @@ -669,19 +669,19 @@ wait_for_pickup(SlotNumber, Slot, Data, Call) -> cf_exe:stop(Call) end. --spec ringback_timeout(kz_json:object(), ne_binary()) -> integer(). +-spec ringback_timeout(kz_json:object(), kz_term:ne_binary()) -> integer(). ringback_timeout(Data, SlotNumber) -> JObj = slot_configuration(Data, SlotNumber), DefaultRingbackTime = kz_json:get_integer_value(<<"default_ringback_timeout">>, Data, ?DEFAULT_RINGBACK_TM), kz_json:get_integer_value(<<"ringback_timeout">>, JObj, DefaultRingbackTime). --spec callback_timeout(kz_json:object(), ne_binary()) -> integer(). +-spec callback_timeout(kz_json:object(), kz_term:ne_binary()) -> integer(). callback_timeout(Data, SlotNumber) -> JObj = slot_configuration(Data, SlotNumber), DefaultCallbackTime = kz_json:get_integer_value(<<"default_callback_timeout">>, Data, ?DEFAULT_CALLBACK_TM), kz_json:get_integer_value(<<"callback_timeout">>, JObj, DefaultCallbackTime). --spec unanswered_action(ne_binary(), kz_json:object(), kz_json:object(), kapps_call:call()) -> 'ok'. +-spec unanswered_action(kz_term:ne_binary(), kz_json:object(), kz_json:object(), kapps_call:call()) -> 'ok'. unanswered_action(SlotNumber, Slot, Data, Call) -> case cf_exe:next(SlotNumber, Call) of 'undefined' -> wait_for_pickup(SlotNumber, Slot, Data, Call); @@ -691,7 +691,7 @@ unanswered_action(SlotNumber, Slot, Data, Call) -> cf_exe:continue(SlotNumber, Call) end. --spec presence_type(ne_binary(), kz_json:object(), kapps_call:call()) -> ne_binary(). +-spec presence_type(kz_term:ne_binary(), kz_json:object(), kapps_call:call()) -> kz_term:ne_binary(). presence_type(SlotNumber, Data, Call) -> JObj = slot_configuration(Data, SlotNumber), DefaultPresenceType = @@ -705,7 +705,7 @@ presence_type(SlotNumber, Data, Call) -> slots_configuration(Data) -> kz_json:get_json_value(<<"slots">>, Data, kz_json:new()). --spec slot_configuration(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec slot_configuration(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). slot_configuration(Data, SlotNumber) -> kz_json:get_json_value(SlotNumber, slots_configuration(Data), kz_json:new()). @@ -715,7 +715,7 @@ slot_configuration(Data, SlotNumber) -> %% Ringback the device that parked the call %% @end %%-------------------------------------------------------------------- --spec get_endpoint_id(api_binary(), kapps_call:call()) -> api_binary(). +-spec get_endpoint_id(kz_term:api_binary(), kapps_call:call()) -> kz_term:api_binary(). get_endpoint_id('undefined', _) -> 'undefined'; get_endpoint_id(Username, Call) -> AccountDb = kapps_call:account_db(Call), @@ -732,7 +732,7 @@ get_endpoint_id(Username, Call) -> %%-------------------------------------------------------------------- -type ringback_parker_result() :: 'answered' | 'intercepted' | 'failed' | 'channel_hungup'. --spec ringback_parker(api_binary(), ne_binary(), kz_json:object(), kz_json:object(), kapps_call:call()) -> ringback_parker_result(). +-spec ringback_parker(kz_term:api_binary(), kz_term:ne_binary(), kz_json:object(), kz_json:object(), kapps_call:call()) -> ringback_parker_result(). ringback_parker('undefined', _, _, _, _) -> 'failed'; ringback_parker(EndpointId, SlotNumber, Slot, Data, Call0) -> CalleeNumber = kz_json:get_value(<<"CID-Number">>, Slot), @@ -773,7 +773,7 @@ set_command(ChannelVars) -> ], kz_json:from_list(Command). --spec wait_for_ringback(kz_timeout(), kapps_call:call()) -> ringback_parker_result(). +-spec wait_for_ringback(timeout(), kapps_call:call()) -> ringback_parker_result(). wait_for_ringback(Timeout, Call) -> case wait_for_parker(Timeout, Call) of {'ok', JObj} -> @@ -802,13 +802,13 @@ wait_for_ringback(Timeout, Call) -> -type wait_for_parker_result() :: {'ok' | 'fail' | 'error', kz_json:object()}. -type receive_event_result() :: {'ok', kz_json:object()} | {'error', 'timeout'}. --spec wait_for_parker(kz_timeout(), kapps_call:call()) -> wait_for_parker_result(). +-spec wait_for_parker(timeout(), kapps_call:call()) -> wait_for_parker_result(). wait_for_parker(Timeout, Call) -> Start = os:timestamp(), lager:debug("waiting for parker for ~p ms", [Timeout]), wait_for_parker(Timeout, Call, Start, kapps_call_command:receive_event(Timeout)). --spec wait_for_parker(kz_timeout(), kapps_call:call(), kz_now(), receive_event_result()) -> wait_for_parker_result(). +-spec wait_for_parker(timeout(), kapps_call:call(), kz_time:now(), receive_event_result()) -> wait_for_parker_result(). wait_for_parker(_Timeout, _Call, _Start, {'error', 'timeout'}=E) -> E; wait_for_parker(Timeout, Call, Start, {'ok', JObj}) -> Disposition = kz_json:get_value(<<"Disposition">>, JObj), @@ -847,12 +847,12 @@ expires(<<"early">>) -> 3600; expires(<<"confirmed">>) -> 3600; expires(<<"terminated">>) -> 10. --spec update_presence(api_object()) -> 'ok'. +-spec update_presence(kz_term:api_object()) -> 'ok'. update_presence('undefined') -> 'ok'; update_presence(Slot) -> update_presence(kz_json:get_ne_binary_value(?PRESENCE_TYPE_KEY, Slot, <<"early">>), Slot). --spec update_presence(ne_binary(), api_object()) -> 'ok'. +-spec update_presence(kz_term:ne_binary(), kz_term:api_object()) -> 'ok'. update_presence(_State, 'undefined') -> 'ok'; update_presence(State, Slot) -> PresenceUser = kz_json:get_ne_binary_value(<<"Presence-User">>, Slot), @@ -898,7 +898,7 @@ update_presence(State, Slot) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec publish_parked(kapps_call:call(), ne_binary()) -> 'ok'. +-spec publish_parked(kapps_call:call(), kz_term:ne_binary()) -> 'ok'. publish_parked(Call, SlotNumber) -> publish_event(Call, SlotNumber, <<"PARK_PARKED">>). @@ -907,7 +907,7 @@ publish_parked(Call, SlotNumber) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec publish_retrieved(kapps_call:call(), ne_binary()) -> 'ok'. +-spec publish_retrieved(kapps_call:call(), kz_term:ne_binary()) -> 'ok'. publish_retrieved(Call, SlotNumber) -> publish_event(Call, SlotNumber, <<"PARK_RETRIEVED">>). @@ -916,7 +916,7 @@ publish_retrieved(Call, SlotNumber) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec publish_abandoned(kapps_call:call(), ne_binary()) -> 'ok'. +-spec publish_abandoned(kapps_call:call(), kz_term:ne_binary()) -> 'ok'. publish_abandoned(Call, Slot) -> publish_event(Call, Slot, <<"PARK_ABANDONED">>). @@ -925,7 +925,7 @@ publish_abandoned(Call, Slot) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec publish_event(kapps_call:call(), ne_binary(), ne_binary()) -> 'ok'. +-spec publish_event(kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. publish_event(Call, SlotNumber, Event) -> Cmd = [{<<"Call-ID">>, kapps_call:call_id(Call)} ,{<<"Callee-ID-Name">>, kapps_call:callee_id_name(Call)} @@ -939,7 +939,7 @@ publish_event(Call, SlotNumber, Event) -> ], kapi_call:publish_event(Cmd). --spec slot_doc(ne_binary(), kz_json:object(), kapps_call:call()) -> kz_json:object(). +-spec slot_doc(kz_term:ne_binary(), kz_json:object(), kapps_call:call()) -> kz_json:object(). slot_doc(SlotNumber, Slot, Call) -> AccountDb = kapps_call:account_db(Call), Doc = case kz_json:get_json_value(<<"pvt_fields">>, Slot) of @@ -952,7 +952,7 @@ slot_doc(SlotNumber, Slot, Call) -> ], kz_doc:update_pvt_parameters(Doc, AccountDb, Options). --spec get_slot(ne_binary(), ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. +-spec get_slot(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. get_slot(SlotNumber, AccountDb) -> DocId = ?SLOT_DOC_ID(SlotNumber), case kz_datamgr:open_doc(AccountDb, {?PARKED_CALL_DOC_TYPE, DocId}) of diff --git a/applications/callflow/src/module/cf_play.erl b/applications/callflow/src/module/cf_play.erl index 496d3eeab62..8e0d94fdde0 100644 --- a/applications/callflow/src/module/cf_play.erl +++ b/applications/callflow/src/module/cf_play.erl @@ -45,7 +45,7 @@ handle_noop_recv(Call, {'error', _E}) -> lager:debug("failure playing: ~p", [_E]), cf_exe:continue(Call). --spec play(kz_json:object(), kapps_call:call(), ne_binary()) -> ne_binary(). +-spec play(kz_json:object(), kapps_call:call(), kz_term:ne_binary()) -> kz_term:ne_binary(). play(Data, Call, Media) -> case kz_json:is_false(<<"answer">>, Data) of 'true' -> 'ok'; diff --git a/applications/callflow/src/module/cf_prepend_cid.erl b/applications/callflow/src/module/cf_prepend_cid.erl index a936feff195..46bbadccfcc 100644 --- a/applications/callflow/src/module/cf_prepend_cid.erl +++ b/applications/callflow/src/module/cf_prepend_cid.erl @@ -20,7 +20,7 @@ handle(Data, Call) -> handle(Data, Call, kz_json:get_ne_binary_value(<<"action">>, Data, <<"prepend">>)). --spec handle(kz_json:object(), kapps_call:call(), ne_binary()) -> 'ok'. +-spec handle(kz_json:object(), kapps_call:call(), kz_term:ne_binary()) -> 'ok'. handle(_Data, Call, <<"reset">>) -> lager:info("reset prepend cid"), set_values('undefined', 'undefined', Call); @@ -44,7 +44,7 @@ handle(Data, Call, <<"prepend">>) -> lager:info("update prepend cid to <~s> ~s", [Name, Number]), set_values(Name, Number, Call). --spec set_values(api_ne_binary(), api_ne_binary(), kapps_call:call()) -> 'ok'. +-spec set_values(kz_term:api_ne_binary(), kz_term:api_ne_binary(), kapps_call:call()) -> 'ok'. set_values(Name, Number, Call) -> Updates = [fun(C) -> kapps_call:kvs_store('prepend_cid_number', Number, C) end ,fun(C) -> kapps_call:kvs_store('prepend_cid_name', Name, C) end diff --git a/applications/callflow/src/module/cf_privacy.erl b/applications/callflow/src/module/cf_privacy.erl index cd673a5b3fb..40693f95a73 100644 --- a/applications/callflow/src/module/cf_privacy.erl +++ b/applications/callflow/src/module/cf_privacy.erl @@ -29,7 +29,7 @@ handle(Data, Call) -> cf_exe:stop(Call) end. --spec update_call(ne_binary(), {'ok', kapps_call:call()}, ne_binary()) -> 'ok'. +-spec update_call(kz_term:ne_binary(), {'ok', kapps_call:call()}, kz_term:ne_binary()) -> 'ok'. update_call(CaptureGroup, {'ok', Call}, Mode) -> Normalize = knm_converters:normalize(CaptureGroup), CCVs = ccvs_by_privacy_mode(Mode), @@ -42,7 +42,7 @@ update_call(CaptureGroup, {'ok', Call}, Mode) -> ], cf_exe:set_call(kapps_call:exec(Routines, Call)). --spec ccvs_by_privacy_mode(api_ne_binary()) -> kz_proplist(). +-spec ccvs_by_privacy_mode(kz_term:api_ne_binary()) -> kz_term:proplist(). ccvs_by_privacy_mode('undefined') -> ccvs_by_privacy_mode(<<"full">>); ccvs_by_privacy_mode(<<"full">>) -> diff --git a/applications/callflow/src/module/cf_record_call.erl b/applications/callflow/src/module/cf_record_call.erl index af6dbad16c1..84c0ad966bd 100644 --- a/applications/callflow/src/module/cf_record_call.erl +++ b/applications/callflow/src/module/cf_record_call.erl @@ -23,7 +23,7 @@ %% @end %%-------------------------------------------------------------------- -spec handle(kz_json:object(), kapps_call:call()) -> 'ok'. --spec handle(kz_json:object(), kapps_call:call(), ne_binary()) -> kapps_call:call(). +-spec handle(kz_json:object(), kapps_call:call(), kz_term:ne_binary()) -> kapps_call:call(). handle(Data0, Call) -> Label = kz_json:get_ne_binary_value(<<"label">>, Data0, kapps_call:kvs_fetch('cf_flow_name', Call)), Origin = <<"callflow : ", Label/binary>>, @@ -38,7 +38,7 @@ handle(Data, Call, <<"start">>) -> handle(_Data, Call, <<"stop">>) -> cf_exe:update_call(kapps_call:stop_recording(Call)). --spec get_action(kz_json:object()) -> ne_binary(). +-spec get_action(kz_json:object()) -> kz_term:ne_binary(). get_action(Data) -> case kz_json:get_ne_binary_value(<<"action">>, Data) of <<"stop">> -> <<"stop">>; diff --git a/applications/callflow/src/module/cf_record_caller.erl b/applications/callflow/src/module/cf_record_caller.erl index 4ce737c3496..212d6654fcf 100644 --- a/applications/callflow/src/module/cf_record_caller.erl +++ b/applications/callflow/src/module/cf_record_caller.erl @@ -38,7 +38,7 @@ handle(Data, Call) -> cf_exe:continue(Call) end. --spec record_caller(kz_json:object(), kapps_call:call(), ne_binary()) -> 'ok'. +-spec record_caller(kz_json:object(), kapps_call:call(), kz_term:ne_binary()) -> 'ok'. record_caller(Data, Call, Url) -> kapps_call_command:answer_now(Call), @@ -54,7 +54,7 @@ record_caller(Data, Call, Url) -> ), lager:debug("recording ended"). --spec set_recording_url(kz_json:object(), kapps_call:call(), ne_binary(), ne_binary()) -> any(). +-spec set_recording_url(kz_json:object(), kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary()) -> any(). set_recording_url(Data, Call, Url, MediaName) -> lager:debug("store to ~s to ~s", [MediaName, Url]), diff --git a/applications/callflow/src/module/cf_resources.erl b/applications/callflow/src/module/cf_resources.erl index d56b16b88b1..0eebadc37dd 100644 --- a/applications/callflow/src/module/cf_resources.erl +++ b/applications/callflow/src/module/cf_resources.erl @@ -58,7 +58,7 @@ handle(Data, Call) -> {Cause, Code} -> handle_bridge_failure(Cause, Code, Call) end. --spec handle_bridge_failure(api_binary(), api_binary(), kapps_call:call()) -> 'ok'. +-spec handle_bridge_failure(kz_term:api_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. handle_bridge_failure(Cause, Code, Call) -> lager:info("offnet request error, attempting to find failure branch for ~s:~s", [Code, Cause]), case cf_util:handle_bridge_failure(Cause, Code, Call) of @@ -74,7 +74,7 @@ handle_bridge_failure(Cause, Code, Call) -> %% %% @end %%-------------------------------------------------------------------- --spec build_offnet_request(kz_json:object(), kapps_call:call()) -> kz_proplist(). +-spec build_offnet_request(kz_json:object(), kapps_call:call()) -> kz_term:proplist(). build_offnet_request(Data, Call) -> {ECIDNum, ECIDName} = kz_attributes:caller_id(<<"emergency">>, Call), {CIDNumber, CIDName} = get_caller_id(Data, Call), @@ -124,12 +124,12 @@ get_channel_vars(Call) -> ), kz_json:from_list(CCVs). --spec add_privacy_flags(kapps_call:call(), kz_proplist()) -> kz_proplist(). +-spec add_privacy_flags(kapps_call:call(), kz_term:proplist()) -> kz_term:proplist(). add_privacy_flags(Call, Acc) -> CCVs = kapps_call:custom_channel_vars(Call), kz_privacy:flags(CCVs) ++ Acc. --spec maybe_require_ignore_early_media(kapps_call:call(), kz_proplist()) -> kz_proplist(). +-spec maybe_require_ignore_early_media(kapps_call:call(), kz_term:proplist()) -> kz_term:proplist(). maybe_require_ignore_early_media(Call, Acc) -> [{<<"Require-Ignore-Early-Media">>, kapps_call:custom_channel_var(<<"Require-Ignore-Early-Media">>, Call)} | Acc]. @@ -138,14 +138,14 @@ get_bypass_e164(Data) -> kz_json:is_true(<<"do_not_normalize">>, Data) orelse kz_json:is_true(<<"bypass_e164">>, Data). --spec get_from_uri_realm(kz_json:object(), kapps_call:call()) -> api_binary(). +-spec get_from_uri_realm(kz_json:object(), kapps_call:call()) -> kz_term:api_binary(). get_from_uri_realm(Data, Call) -> case kz_json:get_ne_binary_value(<<"from_uri_realm">>, Data) of 'undefined' -> maybe_get_call_from_realm(Call); Realm -> Realm end. --spec maybe_get_call_from_realm(kapps_call:call()) -> api_ne_binary(). +-spec maybe_get_call_from_realm(kapps_call:call()) -> kz_term:api_ne_binary(). maybe_get_call_from_realm(Call) -> case kapps_call:from_realm(Call) of <<"norealm">> -> @@ -153,7 +153,7 @@ maybe_get_call_from_realm(Call) -> Realm -> Realm end. --spec maybe_set_bridge_generate_comfort_noise(kapps_call:call(), kz_proplist()) -> kz_proplist(). +-spec maybe_set_bridge_generate_comfort_noise(kapps_call:call(), kz_term:proplist()) -> kz_term:proplist(). maybe_set_bridge_generate_comfort_noise(Call, Acc) -> case kz_endpoint:get(Call) of {'ok', Endpoint} -> @@ -163,19 +163,19 @@ maybe_set_bridge_generate_comfort_noise(Call, Acc) -> Acc end. --spec maybe_has_comfort_noise_option_enabled(kz_json:object(), kz_proplist()) -> kz_proplist(). +-spec maybe_has_comfort_noise_option_enabled(kz_json:object(), kz_term:proplist()) -> kz_term:proplist(). maybe_has_comfort_noise_option_enabled(Endpoint, Acc) -> case kz_json:is_true([<<"media">>, <<"bridge_generate_comfort_noise">>], Endpoint) of 'true' -> [{<<"Bridge-Generate-Comfort-Noise">>, 'true'} | Acc]; 'false' -> Acc end. --spec get_caller_id(kz_json:object(), kapps_call:call()) -> {api_binary(), api_binary()}. +-spec get_caller_id(kz_json:object(), kapps_call:call()) -> {kz_term:api_binary(), kz_term:api_binary()}. get_caller_id(Data, Call) -> Type = kz_json:get_value(<<"caller_id_type">>, Data, <<"external">>), kz_attributes:caller_id(Type, Call). --spec get_hunt_account_id(kz_json:object(), kapps_call:call()) -> api_binary(). +-spec get_hunt_account_id(kz_json:object(), kapps_call:call()) -> kz_term:api_binary(). get_hunt_account_id(Data, Call) -> case kz_json:is_true(<<"use_local_resources">>, Data, 'true') of 'false' -> 'undefined'; @@ -184,14 +184,14 @@ get_hunt_account_id(Data, Call) -> kz_json:get_ne_binary_value(<<"hunt_account_id">>, Data, AccountId) end. --spec get_to_did(kz_json:object(), kapps_call:call()) -> ne_binary(). +-spec get_to_did(kz_json:object(), kapps_call:call()) -> kz_term:ne_binary(). get_to_did(Data, Call) -> case kz_json:get_ne_binary_value(<<"to_did">>, Data) of 'undefined' -> get_request_did(Data, Call); ToDID -> ToDID end. --spec get_request_did(kz_json:object(), kapps_call:call()) -> ne_binary(). +-spec get_request_did(kz_json:object(), kapps_call:call()) -> kz_term:ne_binary(). get_request_did(Data, Call) -> case kz_json:is_true(<<"do_not_normalize">>, Data) of 'true' -> get_original_request_user(Call); @@ -206,7 +206,7 @@ get_request_did(Data, Call) -> end end. --spec maybe_apply_dialplan(kz_json:object(), kz_json:object(), kapps_call:call()) -> ne_binary(). +-spec maybe_apply_dialplan(kz_json:object(), kz_json:object(), kapps_call:call()) -> kz_term:ne_binary(). maybe_apply_dialplan(Endpoint, Data, Call) -> case kz_json:get_value(<<"dial_plan">>, Endpoint, []) of [] -> maybe_bypass_e164(Data, Call); @@ -216,20 +216,20 @@ maybe_apply_dialplan(Endpoint, Data, Call) -> cf_util:apply_dialplan(RequestUser, DialPlan) end. --spec maybe_bypass_e164(kz_json:object(), kapps_call:call()) -> ne_binary(). +-spec maybe_bypass_e164(kz_json:object(), kapps_call:call()) -> kz_term:ne_binary(). maybe_bypass_e164(Data, Call) -> case kz_json:is_true(<<"bypass_e164">>, Data) of 'true' -> get_original_request_user(Call); 'false' -> kapps_call:request_user(Call) end. --spec get_original_request_user(kapps_call:call()) -> ne_binary(). +-spec get_original_request_user(kapps_call:call()) -> kz_term:ne_binary(). get_original_request_user(Call) -> Request = kapps_call:request(Call), [RequestUser, _] = binary:split(Request, <<"@">>), RequestUser. --spec get_sip_headers(kz_json:object(), kapps_call:call()) -> api_object(). +-spec get_sip_headers(kz_json:object(), kapps_call:call()) -> kz_term:api_object(). get_sip_headers(Data, Call) -> Routines = [fun(J) -> maybe_emit_account_id(J, Data, Call) end ,fun(J) -> maybe_include_diversions(J, Call) end @@ -248,7 +248,7 @@ get_sip_headers(Data, Call) -> 'false' -> JObj end. --spec maybe_merge(api_object(), api_object()) -> kz_json:object(). +-spec maybe_merge(kz_term:api_object(), kz_term:api_object()) -> kz_json:object(). maybe_merge(JObj1, 'undefined') -> JObj1; maybe_merge('undefined', JObj2) -> JObj2; maybe_merge(JObj1, JObj2) -> kz_json:merge_jobjs(JObj1, JObj2). @@ -272,18 +272,18 @@ maybe_emit_account_id(JObj, Data, Call) -> kz_json:set_value(<<"X-Account-ID">>, kapps_call:account_id(Call), JObj) end. --spec get_ignore_early_media(kz_json:object()) -> api_binary(). +-spec get_ignore_early_media(kz_json:object()) -> kz_term:api_binary(). get_ignore_early_media(Data) -> kz_term:to_binary(kz_json:is_true(<<"ignore_early_media">>, Data, 'false')). --spec get_t38_enabled(kapps_call:call()) -> api_boolean(). +-spec get_t38_enabled(kapps_call:call()) -> kz_term:api_boolean(). get_t38_enabled(Call) -> case kz_endpoint:get(Call) of {'ok', JObj} -> kz_json:is_true([<<"media">>, <<"fax_option">>], JObj); {'error', _} -> 'undefined' end. --spec get_flags(kz_json:object(), kapps_call:call()) -> api_binaries(). +-spec get_flags(kz_json:object(), kapps_call:call()) -> kz_term:api_binaries(). get_flags(Data, Call) -> Flags = kz_attributes:get_flags(?APP_NAME, Call), Routines = [fun get_flow_flags/3 @@ -291,23 +291,23 @@ get_flags(Data, Call) -> ], lists:foldl(fun(F, A) -> F(Data, Call, A) end, Flags, Routines). --spec get_flow_flags(kz_json:object(), kapps_call:call(), ne_binaries()) -> - ne_binaries(). +-spec get_flow_flags(kz_json:object(), kapps_call:call(), kz_term:ne_binaries()) -> + kz_term:ne_binaries(). get_flow_flags(Data, _Call, Flags) -> case kz_json:get_list_value(<<"outbound_flags">>, Data, []) of [] -> Flags; FlowFlags -> FlowFlags ++ Flags end. --spec get_flow_dynamic_flags(kz_json:object(), kapps_call:call(), ne_binaries()) -> - ne_binaries(). +-spec get_flow_dynamic_flags(kz_json:object(), kapps_call:call(), kz_term:ne_binaries()) -> + kz_term:ne_binaries(). get_flow_dynamic_flags(Data, Call, Flags) -> case kz_json:get_list_value(<<"dynamic_flags">>, Data) of 'undefined' -> Flags; DynamicFlags -> kz_attributes:process_dynamic_flags(DynamicFlags, Flags, Call) end. --spec get_inception(kapps_call:call()) -> api_binary(). +-spec get_inception(kapps_call:call()) -> kz_term:api_binary(). get_inception(Call) -> kz_json:get_value(<<"Inception">>, kapps_call:custom_channel_vars(Call)). @@ -317,7 +317,7 @@ get_inception(Call) -> %% Consume Erlang messages and return on offnet response %% @end %%-------------------------------------------------------------------- --spec wait_for_stepswitch(kapps_call:call()) -> {ne_binary(), api_binary()}. +-spec wait_for_stepswitch(kapps_call:call()) -> {kz_term:ne_binary(), kz_term:api_binary()}. wait_for_stepswitch(Call) -> case kapps_call_command:receive_event(?DEFAULT_EVENT_WAIT, 'true') of {'ok', JObj} -> diff --git a/applications/callflow/src/module/cf_ring_group.erl b/applications/callflow/src/module/cf_ring_group.erl index 8cf851ec7b6..02c56aad321 100644 --- a/applications/callflow/src/module/cf_ring_group.erl +++ b/applications/callflow/src/module/cf_ring_group.erl @@ -45,7 +45,7 @@ maybe_set_alert(Data, Call) -> kapps_call:kvs_store(<<"Override-Ringtone">>, Alert, Call) end. --spec custom_alert_path(api_ne_binary()) -> ne_binary(). +-spec custom_alert_path(kz_term:api_ne_binary()) -> kz_term:ne_binary(). custom_alert_path('undefined') -> <<"internal">>; custom_alert_path(_Inception) -> <<"external">>. @@ -113,7 +113,7 @@ attempt_endpoints(Endpoints, Data, Call) -> get_endpoints(Data, Call) -> receive_endpoints(start_builders(Data, Call)). --spec receive_endpoints(pids()) -> kz_json:objects(). +-spec receive_endpoints(kz_term:pids()) -> kz_json:objects(). receive_endpoints(Builders) -> lists:foldl(fun receive_endpoint_fold/2, [], Builders). @@ -125,13 +125,13 @@ receive_endpoint_fold(Pid, Acc) -> {Pid, _} -> Acc end. --spec start_builders(kz_json:object(), kapps_call:call()) -> pids(). +-spec start_builders(kz_json:object(), kapps_call:call()) -> kz_term:pids(). start_builders(Data, Call) -> [start_builder(EndpointId, Member, Call) || {EndpointId, Member} <- resolve_endpoint_ids(Data, Call) ]. --spec start_builder(ne_binary(), kz_json:object(), kapps_call:call()) -> pid(). +-spec start_builder(kz_term:ne_binary(), kz_json:object(), kapps_call:call()) -> pid(). start_builder(EndpointId, Member, Call) -> S = self(), kz_util:spawn( @@ -146,10 +146,10 @@ is_member_active(Member) -> DisableUntil = kz_json:get_value(<<"disable_until">>, Member, 0), calendar:datetime_to_gregorian_seconds(calendar:universal_time()) > DisableUntil. --type endpoint() :: {ne_binary(), kz_json:object()}. +-type endpoint() :: {kz_term:ne_binary(), kz_json:object()}. -type endpoints() :: [endpoint()]. --type weighted_endpoint() :: {integer(), {ne_binary(), kz_json:object()}}. +-type weighted_endpoint() :: {integer(), {kz_term:ne_binary(), kz_json:object()}}. -type weighted_endpoints() :: [weighted_endpoint()]. -spec resolve_endpoint_ids(kz_json:object(), kapps_call:call()) -> endpoints(). @@ -170,7 +170,7 @@ resolve_endpoint_ids(Data, Call) -> Strategy = strategy(Data), order_endpoints(Strategy, FilteredEndpoints). --spec order_endpoints(ne_binary(), weighted_endpoints()) -> endpoints(). +-spec order_endpoints(kz_term:ne_binary(), weighted_endpoints()) -> endpoints(). order_endpoints(Method, Endpoints) when Method =:= ?DIAL_METHOD_SIMUL orelse Method =:= ?DIAL_METHOD_SINGLE -> @@ -178,7 +178,7 @@ order_endpoints(Method, Endpoints) order_endpoints(<<"weighted_random">>, Endpoints) -> weighted_random_sort(Endpoints). --type endpoint_intermediate() :: {ne_binary(), ne_binary(), group_weight(), api_object()}. +-type endpoint_intermediate() :: {kz_term:ne_binary(), kz_term:ne_binary(), group_weight(), kz_term:api_object()}. -type endpoint_intermediates() :: [endpoint_intermediate()]. -spec resolve_endpoint_ids(kz_json:objects(), endpoint_intermediates(), kz_json:object(), kapps_call:call()) -> @@ -214,7 +214,7 @@ resolve_endpoint_id(Member, EndpointIds, Data, Call) -> [{Type, Id, Weight, Member}|EndpointIds] end. --spec get_user_endpoint_ids(kz_json:object(), endpoint_intermediates(), ne_binary(), group_weight(), kapps_call:call()) -> +-spec get_user_endpoint_ids(kz_json:object(), endpoint_intermediates(), kz_term:ne_binary(), group_weight(), kapps_call:call()) -> endpoint_intermediates(). get_user_endpoint_ids(Member, EndpointIds, Id, GroupWeight, Call) -> lists:foldr(fun(EndpointId, Acc) -> @@ -228,7 +228,7 @@ get_user_endpoint_ids(Member, EndpointIds, Id, GroupWeight, Call) -> ,kz_attributes:owned_by(Id, <<"device">>, Call) ). --spec get_group_members(kz_json:object(), ne_binary(), group_weight(), kz_json:object(), kapps_call:call()) -> kz_json:objects(). +-spec get_group_members(kz_json:object(), kz_term:ne_binary(), group_weight(), kz_json:object(), kapps_call:call()) -> kz_json:objects(). get_group_members(Member, Id, GroupWeight, Data, Call) -> AccountDb = kapps_call:account_db(Call), case kz_datamgr:open_cache_doc(AccountDb, Id) of @@ -285,7 +285,7 @@ order_group_member_fold(Key, Endpoint, Acc, GroupWeight, Member) -> orddict:store(Weight, GroupMember, Acc) end. --spec create_group_member(ne_binary(), kz_json:object(), group_weight(), kz_json:object()) -> +-spec create_group_member(kz_term:ne_binary(), kz_json:object(), group_weight(), kz_json:object()) -> kz_json:object(). create_group_member(Key, Endpoint, GroupWeight, Member) -> DefaultDelay = kz_json:get_integer_value(<<"delay">>, Member), @@ -351,11 +351,11 @@ group_weight(Endpoint, Default) -> N -> N end. --spec strategy(kz_json:object()) -> ne_binary(). +-spec strategy(kz_json:object()) -> kz_term:ne_binary(). strategy(Data) -> kz_json:get_binary_value(<<"strategy">>, Data, ?DIAL_METHOD_SIMUL). --spec freeswitch_strategy(kz_json:object()) -> ne_binary(). +-spec freeswitch_strategy(kz_json:object()) -> kz_term:ne_binary(). freeswitch_strategy(Data) -> case strategy(Data) of ?DIAL_METHOD_SIMUL -> ?DIAL_METHOD_SIMUL; diff --git a/applications/callflow/src/module/cf_ring_group_toggle.erl b/applications/callflow/src/module/cf_ring_group_toggle.erl index e65d447e9b7..9ca33096b03 100644 --- a/applications/callflow/src/module/cf_ring_group_toggle.erl +++ b/applications/callflow/src/module/cf_ring_group_toggle.erl @@ -97,7 +97,7 @@ alter_endpoints(Module, Call, DisableUntil) -> kapps_call_command:play(Media, Call), kz_json:set_value(EndpointsPath, EndPoints, Module). --spec maybe_alter_disable_until(ne_binary(), kz_json:object(), kapps_call:call(), integer()) -> {boolean(), kz_json:object()}. +-spec maybe_alter_disable_until(kz_term:ne_binary(), kz_json:object(), kapps_call:call(), integer()) -> {boolean(), kz_json:object()}. maybe_alter_disable_until(<<"user">>, Endpoint, Call, DisableUntil) -> lager:debug("comparing owner ~p, to endpoint ~p", [kapps_call:owner_id(Call), Endpoint]), case kapps_call:owner_id(Call) diff --git a/applications/callflow/src/module/cf_route_to_cid.erl b/applications/callflow/src/module/cf_route_to_cid.erl index 8f8f56ced4c..890bc4d3a8b 100644 --- a/applications/callflow/src/module/cf_route_to_cid.erl +++ b/applications/callflow/src/module/cf_route_to_cid.erl @@ -39,7 +39,7 @@ handle(Data, Call) -> endpoints_lookup(Data, Call) -> cid_type_based_lookup(Data, Call, kz_json:get_list_value(<<"cid_types">>, Data, [])). --spec cid_type_based_lookup(kz_json:object(), kapps_call:call(), ne_binaries()) -> +-spec cid_type_based_lookup(kz_json:object(), kapps_call:call(), kz_term:ne_binaries()) -> kz_json:objects(). cid_type_based_lookup(Data, Call, []) -> lager:info("no CID type restrictions"), @@ -70,7 +70,7 @@ maybe_filter_results(Data, JObjs) -> ) ]. --spec endpoint_format(ne_binary(), ne_binary(), kz_json:object()) -> kz_json:object(). +-spec endpoint_format(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). endpoint_format(EndpointId, EndpointType, Data) -> Values = [{<<"endpoint_type">>, EndpointType} ,{<<"id">>, EndpointId} diff --git a/applications/callflow/src/module/cf_set_cid.erl b/applications/callflow/src/module/cf_set_cid.erl index 1eecc139285..0a66a46fe97 100644 --- a/applications/callflow/src/module/cf_set_cid.erl +++ b/applications/callflow/src/module/cf_set_cid.erl @@ -34,13 +34,13 @@ handle(Data, Call) -> cf_exe:continue(Call1). --spec set_cid_name(api_binary(), kapps_call:call()) -> kapps_call:call(). +-spec set_cid_name(kz_term:api_binary(), kapps_call:call()) -> kapps_call:call(). set_cid_name(<<>>, Call) -> kapps_call:kvs_erase('rewrite_cid_name', Call); set_cid_name(Name, Call) -> kapps_call:kvs_store('rewrite_cid_name', Name, Call). --spec set_cid_number(api_binary(), kapps_call:call()) -> kapps_call:call(). +-spec set_cid_number(kz_term:api_binary(), kapps_call:call()) -> kapps_call:call(). set_cid_number(<<>>, Call) -> kapps_call:kvs_erase('rewrite_cid_number', Call); set_cid_number(Number, Call) -> diff --git a/applications/callflow/src/module/cf_set_variable.erl b/applications/callflow/src/module/cf_set_variable.erl index 98c7cb7e3ff..57e20e142ab 100644 --- a/applications/callflow/src/module/cf_set_variable.erl +++ b/applications/callflow/src/module/cf_set_variable.erl @@ -20,7 +20,7 @@ -export([handle/2]). --spec name_mapping() -> kz_proplist(). +-spec name_mapping() -> kz_term:proplist(). name_mapping() -> [{<<"call_priority">>, <<"Call-Priority">>}]. @@ -40,7 +40,7 @@ handle(Data, Call) -> cf_exe:set_call(Call1), cf_exe:continue(Call1). --spec set_variable(api_binary(), api_binary(), ne_binary(), kapps_call:call()) -> 'ok'. +-spec set_variable(kz_term:api_binary(), kz_term:api_binary(), kz_term:ne_binary(), kapps_call:call()) -> 'ok'. set_variable('undefined', _Value, _Channel, _Call) -> lager:warning("can not set variable without name!"); set_variable(_Name, 'undefined', _Channel, _Call) -> @@ -50,7 +50,7 @@ set_variable(Name, Value, Channel, Call) -> Var = kz_json:from_list([{Name, Value}]), execute_set_var(Var, Channel, Call). --spec execute_set_var(kz_json:object(), ne_binary(), kapps_call:call()) -> 'ok'. +-spec execute_set_var(kz_json:object(), kz_term:ne_binary(), kapps_call:call()) -> 'ok'. execute_set_var(Var, <<"a">>, Call) -> kapps_call_command:set(Var, 'undefined', Call); execute_set_var(Var, <<"both">>, Call) -> diff --git a/applications/callflow/src/module/cf_sleep.erl b/applications/callflow/src/module/cf_sleep.erl index 0349edca10d..8da79e36d5f 100644 --- a/applications/callflow/src/module/cf_sleep.erl +++ b/applications/callflow/src/module/cf_sleep.erl @@ -42,7 +42,7 @@ get_duration_ms(Data) -> Unit = kz_json:get_ne_binary_value(<<"unit">>, Data, <<"s">>), duration_to_ms(Duration, Unit). --spec duration_to_ms(integer(), ne_binary()) -> non_neg_integer(). +-spec duration_to_ms(integer(), kz_term:ne_binary()) -> non_neg_integer(). duration_to_ms(Duration, <<"ms">>) -> constrain_duration(Duration); duration_to_ms(Duration, <<"s">>) -> diff --git a/applications/callflow/src/module/cf_temporal_route.erl b/applications/callflow/src/module/cf_temporal_route.erl index 3050c7096c5..c775ea612e0 100644 --- a/applications/callflow/src/module/cf_temporal_route.erl +++ b/applications/callflow/src/module/cf_temporal_route.erl @@ -137,14 +137,14 @@ get_temporal_rules(#temporal{local_sec=LSec }, Call) -> get_temporal_rules(Routes, LSec, kapps_call:account_db(Call), TZ, []). --spec get_temporal_rules(kz_json:path(), non_neg_integer(), ne_binary(), ne_binary(), rules()) -> rules(). +-spec get_temporal_rules(kz_json:path(), non_neg_integer(), kz_term:ne_binary(), kz_term:ne_binary(), rules()) -> rules(). get_temporal_rules(Routes, LSec, AccountDb, TZ, Rules) when is_binary(TZ) -> Now = localtime:utc_to_local(calendar:universal_time() ,kz_term:to_list(TZ) ), get_temporal_rules(Routes, LSec, AccountDb, TZ, Now, Rules). --spec get_temporal_rules(routes(), non_neg_integer(), ne_binary(), ne_binary(), kz_datetime(), rules()) -> +-spec get_temporal_rules(routes(), non_neg_integer(), kz_term:ne_binary(), kz_term:ne_binary(), kz_time:datetime(), rules()) -> rules(). get_temporal_rules([], _, _, _, _, Rules) -> lists:reverse(Rules); get_temporal_rules([{Route, Id}|Routes], LSec, AccountDb, TZ, Now, Rules) -> @@ -156,7 +156,7 @@ get_temporal_rules([{Route, Id}|Routes], LSec, AccountDb, TZ, Now, Rules) -> maybe_build_rule(Routes, LSec, AccountDb, TZ, Now, Rules, Id, JObj) end. --spec maybe_build_rule(routes(), non_neg_integer(), ne_binary(), ne_binary(), kz_datetime(), rules(), ne_binary(), kz_json:object()) -> rules(). +-spec maybe_build_rule(routes(), non_neg_integer(), kz_term:ne_binary(), kz_term:ne_binary(), kz_time:datetime(), rules(), kz_term:ne_binary(), kz_json:object()) -> rules(). maybe_build_rule(Routes, LSec, AccountDb, TZ, Now, Rules, Id, JObj) -> StartDate = kz_date:from_gregorian_seconds(kz_json:get_integer_value(<<"start_date">>, JObj, LSec), TZ), RuleName = kz_json:get_ne_binary_value(<<"name">>, JObj, ?RULE_DEFAULT_NAME), @@ -169,7 +169,7 @@ maybe_build_rule(Routes, LSec, AccountDb, TZ, Now, Rules, Id, JObj) -> get_temporal_rules(Routes, LSec, AccountDb, TZ, Now, [build_rule(Id, JObj, StartDate, RuleName) | Rules]) end. --spec build_rule(ne_binary(), kz_json:object(), kz_date(), ne_binary()) -> rule(). +-spec build_rule(kz_term:ne_binary(), kz_json:object(), kz_time:date(), kz_term:ne_binary()) -> rule(). build_rule(Id, JObj, StartDate, RuleName) -> #rule{cycle = kz_json:get_binary_value(<<"cycle">>, JObj, ?RULE_DEFAULT_CYCLE) ,days = days_in_rule(JObj) @@ -274,7 +274,7 @@ interdigit_timeout(Data) -> %% Loads rules set from account db. %% @end %%-------------------------------------------------------------------- --spec get_rule_set(route() | ne_binary(), kapps_call:call()) -> ne_binaries(). +-spec get_rule_set(route() | kz_term:ne_binary(), kapps_call:call()) -> kz_term:ne_binaries(). get_rule_set({Id, Id}, Call) -> get_rule_set(Id, Call); @@ -454,7 +454,7 @@ load_current_time(#temporal{timezone=Timezone}=Temporal)-> %% - 1,2,3..31 %% @end %%-------------------------------------------------------------------- --spec next_rule_date(rule(), kz_date()) -> kz_date(). +-spec next_rule_date(rule(), kz_time:date()) -> kz_time:date(). next_rule_date(#rule{cycle = <<"date">> ,start_date=Date0 } @@ -615,7 +615,7 @@ next_rule_date(#rule{cycle = <<"monthly">> Date; %% false: %% In an 'inactive' month - %% {kz_date(), integer()}: + %% {kz_time:date(), integer()}: %% We have already passed the last occurance of the DOW _ -> find_ordinal_weekday(Y0, M0 + Offset + I0, Weekday, Ordinal) @@ -755,7 +755,7 @@ next_rule_date(#rule{cycle = <<"yearly">> %% It is possible for this function to cross month/year boundaries. %% @end %%-------------------------------------------------------------------- --spec find_ordinal_weekday(kz_year(), improper_month(), wday(), strict_ordinal()) -> kz_date(). +-spec find_ordinal_weekday(kz_time:year(), improper_month(), wday(), strict_ordinal()) -> kz_time:date(). find_ordinal_weekday(Y1, M1, Weekday, Ordinal) when M1 =:= 13 -> find_ordinal_weekday(Y1 + 1, 1, Weekday, Ordinal); find_ordinal_weekday(Y1, M1, Weekday, Ordinal) when M1 > 12 -> @@ -783,7 +783,7 @@ find_ordinal_weekday(Y1, M1, Weekday, Ordinal) -> %% occurance MUST be in the third week. %% @end %%-------------------------------------------------------------------- --spec find_last_weekday(improper_date(), wday()) -> kz_date(). +-spec find_last_weekday(improper_date(), wday()) -> kz_time:date(). find_last_weekday({Y, M, D}, Weekday) when M =:= 13 -> find_last_weekday({Y + 1, 1, D}, Weekday); find_last_weekday({Y, M, D}, Weekday) when M > 12 -> @@ -803,7 +803,7 @@ find_last_weekday({Y, M, _}, Weekday) -> %% function will explode on occasion. %% @end %%-------------------------------------------------------------------- --spec date_of_dow(kz_year(), improper_month(), wday(), strict_ordinal()) -> kz_date(). +-spec date_of_dow(kz_time:year(), improper_month(), wday(), strict_ordinal()) -> kz_time:date(). date_of_dow(Year, 1, Weekday, Ordinal) -> date_of_dow(Year - 1, 13, Weekday, Ordinal); date_of_dow(Year, Month, Weekday, Ordinal) -> @@ -836,13 +836,13 @@ date_of_dow(Year, Month, Weekday, Ordinal) -> %% All while remaining ISO 8601 compliant. %% @end %%-------------------------------------------------------------------- --spec iso_week_difference(kz_date(), kz_date()) -> non_neg_integer(). +-spec iso_week_difference(kz_time:date(), kz_time:date()) -> non_neg_integer(). iso_week_difference({Y0, M0, D0}, {Y1, M1, D1}) -> DS0 = calendar:date_to_gregorian_days(kz_date:from_iso_week(calendar:iso_week_number({Y0, M0, D0}))), DS1 = calendar:date_to_gregorian_days(kz_date:from_iso_week(calendar:iso_week_number({Y1, M1, D1}))), trunc( abs( DS0 - DS1 ) / 7 ). --spec find_active_days(ne_binaries(), kz_day()) -> [kz_daynum()]. +-spec find_active_days(kz_term:ne_binaries(), kz_time:day()) -> [kz_time:daynum()]. find_active_days(Weekdays, DOW0) -> [DOW1 || DOW1 <- [kz_date:wday_to_dow(D) || D <- Weekdays], diff --git a/applications/callflow/src/module/cf_temporal_route.hrl b/applications/callflow/src/module/cf_temporal_route.hrl index 255955ec764..0f8b4fdcc35 100644 --- a/applications/callflow/src/module/cf_temporal_route.hrl +++ b/applications/callflow/src/module/cf_temporal_route.hrl @@ -4,27 +4,27 @@ -type improper_month() :: non_neg_integer(). -type improper_day() :: non_neg_integer(). --type improper_date() :: {kz_year(), improper_month(), improper_day()}. +-type improper_date() :: {kz_time:year(), improper_month(), improper_day()}. -type strict_ordinal() :: binary(). %%<<"first">> | <<"second">> | <<"third">> | <<"fourth">> | <<"fifth">>. -type broad_ordinal() :: binary(). %%<<"every">> | <<"last">>. -type ordinal() :: strict_ordinal() | broad_ordinal(). %% <<"monday">> | <<"tuesday">> | <<"wensday">> | <<"wednesday">> | <<"thursday">> %% | <<"friday">> | <<"saturday">> | <<"sunday">>. --type wday() :: ne_binary(). +-type wday() :: kz_term:ne_binary(). -type cycle_type() :: binary(). %%<<"date">> | <<"daily">> | <<"weekly">> | <<"monthly">> | <<"yearly">>. --record(keys, {enable = <<"1">> :: ne_binary() - ,disable = <<"2">> :: ne_binary() - ,reset = <<"3">> :: ne_binary() +-record(keys, {enable = <<"1">> :: kz_term:ne_binary() + ,disable = <<"2">> :: kz_term:ne_binary() + ,reset = <<"3">> :: kz_term:ne_binary() }). -type keys() :: #keys{}. --record(prompts, {marked_disabled = <<"temporal-marked_disabled">> :: ne_binary() - ,marked_enabled = <<"temporal-marked_enabled">> :: ne_binary() - ,marker_reset = <<"temporal-marker_reset">> :: ne_binary() - ,main_menu = <<"temporal-menu">> :: ne_binary() +-record(prompts, {marked_disabled = <<"temporal-marked_disabled">> :: kz_term:ne_binary() + ,marked_enabled = <<"temporal-marked_enabled">> :: kz_term:ne_binary() + ,marker_reset = <<"temporal-marker_reset">> :: kz_term:ne_binary() + ,main_menu = <<"temporal-menu">> :: kz_term:ne_binary() }). -type prompts() :: #prompts{}. @@ -40,15 +40,15 @@ -define(RULE_DEFAULT_WTIME_STOP, ?SECONDS_IN_DAY). -record(rule, {id = <<>> :: binary() - ,enabled :: api_boolean() + ,enabled :: kz_term:api_boolean() ,name = ?RULE_DEFAULT_NAME :: binary() ,cycle = ?RULE_DEFAULT_CYCLE :: cycle_type() ,interval = ?RULE_DEFAULT_INTERVAL :: non_neg_integer() - ,days = ?RULE_DEFAULT_DAYS :: [kz_day()] + ,days = ?RULE_DEFAULT_DAYS :: [kz_time:day()] ,wdays = ?RULE_DEFAULT_WDAYS :: [wday()] ,ordinal = ?RULE_DEFAULT_ORDINAL :: ordinal() - ,month = ?RULE_DEFAULT_MONTH :: kz_month() - ,start_date = ?RULE_DEFAULT_START_DATE :: kz_date() + ,month = ?RULE_DEFAULT_MONTH :: kz_time:month() + ,start_date = ?RULE_DEFAULT_START_DATE :: kz_time:date() ,wtime_start = ?RULE_DEFAULT_WTIME_START :: non_neg_integer() ,wtime_stop = ?RULE_DEFAULT_WTIME_STOP :: non_neg_integer() }). @@ -56,14 +56,14 @@ -type rule() :: #rule{}. -type rules() :: [rule()]. --type route() :: {ne_binary(), ne_binary()}. +-type route() :: {kz_term:ne_binary(), kz_term:ne_binary()}. -type routes() :: [route()]. -record(temporal, {local_sec = 0 :: non_neg_integer() - ,local_date = {2011, 1, 1} :: kz_date() - ,local_time = {0, 0, 0} :: kz_time() + ,local_date = {2011, 1, 1} :: kz_time:date() + ,local_time = {0, 0, 0} :: kz_time:time() ,routes = [] :: routes() - ,timezone :: api_binary() + ,timezone :: kz_term:api_binary() ,prompts = #prompts{} :: prompts() ,keys = #keys{} :: keys() ,interdigit_timeout = kapps_call_command:default_interdigit_timeout() :: pos_integer() diff --git a/applications/callflow/src/module/cf_user.erl b/applications/callflow/src/module/cf_user.erl index 08f8c744516..4787f3c74f9 100644 --- a/applications/callflow/src/module/cf_user.erl +++ b/applications/callflow/src/module/cf_user.erl @@ -62,7 +62,7 @@ maybe_handle_bridge_failure(Reason, Call) -> %% json object used in the bridge API %% @end %%-------------------------------------------------------------------- --spec get_endpoints(api_binary(), kz_json:object(), kapps_call:call()) -> +-spec get_endpoints(kz_term:api_binary(), kz_json:object(), kapps_call:call()) -> kz_json:objects(). get_endpoints('undefined', _, _) -> []; get_endpoints(UserId, Data, Call) -> diff --git a/applications/callflow/src/module/cf_voicemail.erl b/applications/callflow/src/module/cf_voicemail.erl index ba85c8b9e6e..41b1fb6cbf7 100644 --- a/applications/callflow/src/module/cf_voicemail.erl +++ b/applications/callflow/src/module/cf_voicemail.erl @@ -94,58 +94,58 @@ -define(DEFAULT_FIND_BOX_PROMPT, <<"vm-enter_id">>). --record(keys, {operator = <<"0">> :: ne_binary() +-record(keys, {operator = <<"0">> :: kz_term:ne_binary() %% Compose Voicemail - ,login = <<"*">> :: ne_binary() + ,login = <<"*">> :: kz_term:ne_binary() %% Record Review - ,save = <<"1">> :: ne_binary() - ,listen = <<"2">> :: ne_binary() - ,record = <<"3">> :: ne_binary() + ,save = <<"1">> :: kz_term:ne_binary() + ,listen = <<"2">> :: kz_term:ne_binary() + ,record = <<"3">> :: kz_term:ne_binary() %% Main Menu - ,hear_new = <<"1">> :: ne_binary() - ,hear_saved = <<"2">> :: ne_binary() - ,configure = <<"5">> :: ne_binary() - ,exit = <<"#">> :: ne_binary() + ,hear_new = <<"1">> :: kz_term:ne_binary() + ,hear_saved = <<"2">> :: kz_term:ne_binary() + ,configure = <<"5">> :: kz_term:ne_binary() + ,exit = <<"#">> :: kz_term:ne_binary() %% Config Menu - ,rec_unavailable = <<"1">> :: ne_binary() - ,rec_name = <<"2">> :: ne_binary() - ,set_pin = <<"3">> :: ne_binary() - ,rec_temporary_unavailable = <<"4">> :: ne_binary() - ,del_temporary_unavailable = <<"5">> :: ne_binary() - ,return_main = <<"0">> :: ne_binary() + ,rec_unavailable = <<"1">> :: kz_term:ne_binary() + ,rec_name = <<"2">> :: kz_term:ne_binary() + ,set_pin = <<"3">> :: kz_term:ne_binary() + ,rec_temporary_unavailable = <<"4">> :: kz_term:ne_binary() + ,del_temporary_unavailable = <<"5">> :: kz_term:ne_binary() + ,return_main = <<"0">> :: kz_term:ne_binary() %% Post playbak - ,keep = <<"1">> :: ne_binary() - ,replay = <<"2">> :: ne_binary() - ,forward = <<"3">> :: ne_binary() - ,prev = <<"4">> :: ne_binary() - ,next = <<"6">> :: ne_binary() - ,delete = <<"7">> :: ne_binary() + ,keep = <<"1">> :: kz_term:ne_binary() + ,replay = <<"2">> :: kz_term:ne_binary() + ,forward = <<"3">> :: kz_term:ne_binary() + ,prev = <<"4">> :: kz_term:ne_binary() + ,next = <<"6">> :: kz_term:ne_binary() + ,delete = <<"7">> :: kz_term:ne_binary() %% Greeting or instructions - ,continue = 'undefined' :: api_ne_binary() + ,continue = 'undefined' :: kz_term:api_ne_binary() }). -type vm_keys() :: #keys{}. -define(KEY_LENGTH, 1). --record(mailbox, {mailbox_id :: api_ne_binary() +-record(mailbox, {mailbox_id :: kz_term:api_ne_binary() ,mailbox_number = <<>> :: binary() ,exists = 'false' :: boolean() ,skip_instructions = 'false' :: boolean() ,skip_greeting = 'false' :: boolean() - ,unavailable_media_id :: api_ne_binary() - ,temporary_unavailable_media_id :: api_ne_binary() - ,name_media_id :: api_ne_binary() + ,unavailable_media_id :: kz_term:api_ne_binary() + ,temporary_unavailable_media_id :: kz_term:api_ne_binary() + ,name_media_id :: kz_term:api_ne_binary() ,pin = <<>> :: binary() - ,timezone :: api_ne_binary() + ,timezone :: kz_term:api_ne_binary() ,max_login_attempts = ?MAX_LOGIN_ATTEMPTS :: non_neg_integer() ,require_pin = 'false' :: boolean() ,check_if_owner = 'true' :: boolean() - ,owner_id :: api_ne_binary() + ,owner_id :: kz_term:api_ne_binary() ,is_setup = 'false' :: boolean() ,message_count = 0 :: non_neg_integer() ,max_message_count = 0 :: non_neg_integer() @@ -153,15 +153,15 @@ ,min_message_length = ?MAILBOX_DEFAULT_MSG_MIN_LENGTH :: pos_integer() ,keys = #keys{} :: vm_keys() ,transcribe_voicemail = 'false' :: boolean() - ,notifications :: api_object() + ,notifications :: kz_term:api_object() ,after_notify_action = 'nothing' :: 'nothing' | 'delete' | 'save' ,interdigit_timeout = kapps_call_command:default_interdigit_timeout() :: pos_integer() ,play_greeting_intro = 'false' :: boolean() ,use_person_not_available = 'false' :: boolean() ,not_configurable = 'false' :: boolean() - ,account_db :: api_ne_binary() - ,media_extension :: api_ne_binary() - ,forward_type :: api_ne_binary() + ,account_db :: kz_term:api_ne_binary() + ,media_extension :: kz_term:api_ne_binary() + ,forward_type :: kz_term:api_ne_binary() }). -type mailbox() :: #mailbox{}. @@ -284,7 +284,7 @@ check_mailbox(#mailbox{pin=Pin %% %% @end %%-------------------------------------------------------------------- --spec find_mailbox(mailbox(), kapps_call:call(), ne_binary(), non_neg_integer()) -> +-spec find_mailbox(mailbox(), kapps_call:call(), kz_term:ne_binary(), non_neg_integer()) -> {'ok', mailbox(), non_neg_integer()} | {'error', 'not_found'}. @@ -351,7 +351,7 @@ find_mailbox_by_number(BoxNum, Call) -> Error -> Error end. --spec find_destination_mailbox(mailbox(), kapps_call:call(), ne_binary(), non_neg_integer()) -> mailbox(). +-spec find_destination_mailbox(mailbox(), kapps_call:call(), kz_term:ne_binary(), non_neg_integer()) -> mailbox(). find_destination_mailbox(#mailbox{max_login_attempts=MaxLoginAttempts}, Call, _SrcBoxId, Loop) when Loop > MaxLoginAttempts -> lager:info("maximum number of invalid attempts to find destination mailbox"), @@ -465,7 +465,7 @@ compose_voicemail(#mailbox{keys=#keys{login=Login %% %% @end %%-------------------------------------------------------------------- --spec play_greeting_intro(mailbox(), kapps_call:call()) -> ne_binary() | 'ok'. +-spec play_greeting_intro(mailbox(), kapps_call:call()) -> kz_term:ne_binary() | 'ok'. play_greeting_intro(#mailbox{play_greeting_intro='true'}, Call) -> kapps_call_command:audio_macro([{'prompt', <<"vm-greeting_intro">>}], Call); play_greeting_intro(_, _) -> 'ok'. @@ -476,7 +476,7 @@ play_greeting_intro(_, _) -> 'ok'. %% %% @end %%-------------------------------------------------------------------- --spec play_greeting(mailbox(), kapps_call:call()) -> ne_binary() | 'ok'. +-spec play_greeting(mailbox(), kapps_call:call()) -> kz_term:ne_binary() | 'ok'. play_greeting(#mailbox{skip_greeting='true'}, _Call) -> 'ok'; play_greeting(#mailbox{temporary_unavailable_media_id= <<_/binary>> = MediaId} ,Call @@ -510,7 +510,7 @@ play_greeting(#mailbox{unavailable_media_id=MediaId}, Call) -> %% %% @end %%-------------------------------------------------------------------- --spec play_instructions(mailbox(), kapps_call:call()) -> ne_binary() | 'ok'. +-spec play_instructions(mailbox(), kapps_call:call()) -> kz_term:ne_binary() | 'ok'. play_instructions(#mailbox{skip_instructions='true'}, _) -> 'ok'; play_instructions(#mailbox{skip_instructions='false'}, Call) -> kapps_call_command:prompt(<<"vm-record_message">>, Call). @@ -521,7 +521,7 @@ play_instructions(#mailbox{skip_instructions='false'}, Call) -> %% %% @end %%-------------------------------------------------------------------- --spec record_voicemail(ne_binary(), mailbox(), kapps_call:call()) -> 'ok'. +-spec record_voicemail(kz_term:ne_binary(), mailbox(), kapps_call:call()) -> 'ok'. record_voicemail(AttachmentName, #mailbox{max_message_length=MaxMessageLength ,media_extension=Ext }=Box, Call) -> @@ -730,7 +730,7 @@ main_menu(#mailbox{keys=#keys{hear_new=HearNew %% %% @end %%-------------------------------------------------------------------- --spec message_count_prompts(integer(), integer()) -> kz_proplist(). +-spec message_count_prompts(integer(), integer()) -> kz_term:proplist(). message_count_prompts(0, 0) -> [{'prompt', <<"vm-no_messages">>}]; message_count_prompts(1, 0) -> @@ -916,7 +916,7 @@ forward_message_menu(#mailbox{interdigit_timeout=Interdigit}=DestBox, Call) -> _ -> forward_message_menu(DestBox, Call) end. --spec compose_forward_message(kz_json:object(), ne_binary(), mailbox(), kapps_call:call()) -> 'ok'. +-spec compose_forward_message(kz_json:object(), kz_term:ne_binary(), mailbox(), kapps_call:call()) -> 'ok'. compose_forward_message(Message, SrcBoxId, #mailbox{media_extension=Ext}=DestBox, Call) -> lager:debug("playing forwarding instructions to caller"), _ = play_instructions(DestBox, Call), @@ -934,7 +934,7 @@ compose_forward_message(Message, SrcBoxId, #mailbox{media_extension=Ext}=DestBox lager:info("error while playing voicemail greeting: ~p", [_R]) end. --spec record_forward(ne_binary(), kz_json:object(), ne_binary(), mailbox(), kapps_call:call()) -> 'ok'. +-spec record_forward(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary(), mailbox(), kapps_call:call()) -> 'ok'. record_forward(AttachmentName, Message, SrcBoxId, #mailbox{media_extension=Ext ,max_message_length=MaxMessageLength }=DestBox, Call) -> @@ -965,7 +965,7 @@ record_forward(AttachmentName, Message, SrcBoxId, #mailbox{media_extension=Ext lager:info("error while attempting to record a foward message: ~p", [_R]) end. --spec forward_message(api_ne_binary(), non_neg_integer(), kz_json:object(), ne_binary(), mailbox(), kapps_call:call()) -> 'ok'. +-spec forward_message(kz_term:api_ne_binary(), non_neg_integer(), kz_json:object(), kz_term:ne_binary(), mailbox(), kapps_call:call()) -> 'ok'. forward_message(AttachmentName, Length, Message, SrcBoxId, #mailbox{mailbox_number=BoxNum ,mailbox_id=BoxId ,timezone=Timezone @@ -1166,7 +1166,7 @@ handle_config_selection(#mailbox{}=Box %% Recording the temporary greeting to override the common greeting %% @end %%-------------------------------------------------------------------- --spec record_temporary_unavailable_greeting(ne_binary(), mailbox(), kapps_call:call()) -> +-spec record_temporary_unavailable_greeting(kz_term:ne_binary(), mailbox(), kapps_call:call()) -> 'ok' | mailbox(). record_temporary_unavailable_greeting(AttachmentName ,#mailbox{temporary_unavailable_media_id='undefined'}=Box @@ -1189,7 +1189,7 @@ record_temporary_unavailable_greeting(AttachmentName, Box, Call) -> %% by a new recorded version. %% @end %%-------------------------------------------------------------------- --spec overwrite_temporary_unavailable_greeting(ne_binary(), mailbox(), kapps_call:call()) -> +-spec overwrite_temporary_unavailable_greeting(kz_term:ne_binary(), mailbox(), kapps_call:call()) -> 'ok' | mailbox(). overwrite_temporary_unavailable_greeting(AttachmentName ,#mailbox{temporary_unavailable_media_id=MediaId @@ -1246,7 +1246,7 @@ delete_temporary_unavailable_greeting(Box, Call) -> 'ok' = update_doc([<<"media">>, <<"temporary_unavailable">>], 'undefined', Box, Call), Box#mailbox{temporary_unavailable_media_id='undefined'}. --spec record_unavailable_greeting(ne_binary(), mailbox(), kapps_call:call()) -> +-spec record_unavailable_greeting(kz_term:ne_binary(), mailbox(), kapps_call:call()) -> 'ok' | mailbox(). record_unavailable_greeting(AttachmentName, #mailbox{unavailable_media_id='undefined'}=Box, Call) -> MediaId = recording_media_doc(<<"unavailable greeting">>, Box, Call), @@ -1257,7 +1257,7 @@ record_unavailable_greeting(AttachmentName, #mailbox{unavailable_media_id=MediaI _ -> overwrite_unavailable_greeting(AttachmentName, Box, Call) end. --spec check_media_source(ne_binary(), mailbox(), kapps_call:call(), kz_json:object()) -> +-spec check_media_source(kz_term:ne_binary(), mailbox(), kapps_call:call(), kz_json:object()) -> 'ok' | mailbox(). check_media_source(AttachmentName, Box, Call, JObj) -> case kz_json:get_ne_binary_value(<<"media_source">>, JObj) of @@ -1270,7 +1270,7 @@ check_media_source(AttachmentName, Box, Call, JObj) -> overwrite_unavailable_greeting(AttachmentName, Box, Call) end. --spec overwrite_unavailable_greeting(ne_binary(), mailbox(), kapps_call:call()) -> +-spec overwrite_unavailable_greeting(kz_term:ne_binary(), mailbox(), kapps_call:call()) -> 'ok' | mailbox(). overwrite_unavailable_greeting(AttachmentName, #mailbox{unavailable_media_id=MediaId ,media_extension=Ext @@ -1311,9 +1311,9 @@ overwrite_unavailable_greeting(AttachmentName, #mailbox{unavailable_media_id=Med %% %% @end %%-------------------------------------------------------------------- --spec record_name(ne_binary(), mailbox(), kapps_call:call()) -> +-spec record_name(kz_term:ne_binary(), mailbox(), kapps_call:call()) -> 'ok' | mailbox(). --spec record_name(ne_binary(), mailbox(), kapps_call:call(), ne_binary()) -> +-spec record_name(kz_term:ne_binary(), mailbox(), kapps_call:call(), kz_term:ne_binary()) -> 'ok' | mailbox(). record_name(AttachmentName, #mailbox{owner_id='undefined' ,name_media_id='undefined' @@ -1464,7 +1464,7 @@ confirm_new_pin(Interdigit, Call) -> NoopId = kapps_call_command:prompt(<<"vm-enter_new_pin_confirm">>, Call), collect_pin(Interdigit, Call, NoopId). --spec collect_pin(pos_integer(), kapps_call:call(), ne_binary()) -> +-spec collect_pin(pos_integer(), kapps_call:call(), kz_term:ne_binary()) -> {'ok', binary()} | {'error', any()}. collect_pin(Interdigit, Call, NoopId) -> @@ -1480,7 +1480,7 @@ collect_pin(Interdigit, Call, NoopId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec new_message(ne_binary(), non_neg_integer(), mailbox(), kapps_call:call()) -> any(). +-spec new_message(kz_term:ne_binary(), non_neg_integer(), mailbox(), kapps_call:call()) -> any(). new_message(_, Length, #mailbox{min_message_length=MinLength}, _) when Length < MinLength -> lager:info("attachment length is ~B and must be larger than ~B to be stored", [Length, MinLength]); @@ -1625,10 +1625,10 @@ max_message_count(Call) -> MMC -> MMC end. --spec owner_info(ne_binary(), kz_json:object()) -> - {api_binary(), api_binary()}. --spec owner_info(ne_binary(), kz_json:object(), api_binary()) -> - {api_binary(), api_binary()}. +-spec owner_info(kz_term:ne_binary(), kz_json:object()) -> + {kz_term:api_binary(), kz_term:api_binary()}. +-spec owner_info(kz_term:ne_binary(), kz_json:object(), kz_term:api_binary()) -> + {kz_term:api_binary(), kz_term:api_binary()}. owner_info(AccountDb, MailboxJObj) -> owner_info(AccountDb, MailboxJObj, kz_json:get_ne_value(<<"owner_id">>, MailboxJObj)). @@ -1682,7 +1682,7 @@ populate_keys(Call) -> %% %% @end %%-------------------------------------------------------------------- --spec get_mailbox_doc(ne_binary(), api_binary(), kz_json:object(), kapps_call:call()) -> +-spec get_mailbox_doc(kz_term:ne_binary(), kz_term:api_binary(), kz_json:object(), kapps_call:call()) -> {'ok', kz_json:object()} | {'error', any()}. get_mailbox_doc(Db, Id, Data, Call) -> @@ -1710,7 +1710,7 @@ get_mailbox_doc(Db, Id, Data, Call) -> -spec get_user_mailbox_doc(kz_json:object(), kapps_call:call()) -> {'ok', kz_json:object()} | {'error', any()}. --spec get_user_mailbox_doc(kz_json:object(), kapps_call:call(), api_binary()) -> +-spec get_user_mailbox_doc(kz_json:object(), kapps_call:call(), kz_term:api_binary()) -> {'ok', kz_json:object()} | {'error', any()}. get_user_mailbox_doc(Data, Call) -> @@ -1761,7 +1761,7 @@ maybe_match_callerid(Boxes, Data, Call) -> try_match_callerid(Boxes, CallerId) end. --spec try_match_callerid(kz_json:objects(), ne_binary()) -> +-spec try_match_callerid(kz_json:objects(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. try_match_callerid([], _CallerId) -> @@ -1782,10 +1782,10 @@ try_match_callerid([Box|Boxes], CallerId) -> %% %% @end %%-------------------------------------------------------------------- --spec review_recording(ne_binary(), boolean(), mailbox(), kapps_call:call()) -> +-spec review_recording(kz_term:ne_binary(), boolean(), mailbox(), kapps_call:call()) -> {'ok', 'record' | 'save' | 'no_selection'} | {'branch', kz_json:object()}. --spec review_recording(ne_binary(), boolean(), mailbox(), kapps_call:call(), integer()) -> +-spec review_recording(kz_term:ne_binary(), boolean(), mailbox(), kapps_call:call(), integer()) -> {'ok', 'record' | 'save' | 'no_selection'} | {'branch', kz_json:object()}. @@ -1843,7 +1843,7 @@ review_recording(AttachmentName, AllowOperator %% @doc %% @end %%-------------------------------------------------------------------- --spec store_recording(ne_binary(), non_neg_integer(), ne_binary(), mailbox(), kapps_call:call()) -> 'ok' | {'error', kapps_call:call()}. +-spec store_recording(kz_term:ne_binary(), non_neg_integer(), kz_term:ne_binary(), mailbox(), kapps_call:call()) -> 'ok' | {'error', kapps_call:call()}. store_recording(_, Length, _, #mailbox{min_message_length=MinLength}, _) when Length < MinLength -> lager:info("attachment length is ~B and must be larger than ~B to be stored", [Length, MinLength]); @@ -1859,8 +1859,8 @@ store_recording(AttachmentName, _Length, DocId, Box, Call) -> {'error', kapps_call:kvs_store('error_details', {'error', E}, Call1)} end. --spec get_new_attachment_url(ne_binary(), ne_binary(), mailbox(), kapps_call:call()) -> - ne_binary(). +-spec get_new_attachment_url(kz_term:ne_binary(), kz_term:ne_binary(), mailbox(), kapps_call:call()) -> + kz_term:ne_binary(). get_new_attachment_url(AttachmentName, MediaId, #mailbox{owner_id=OwnerId}, Call) -> AccountDb = kapps_call:account_db(Call), _ = case kz_datamgr:open_doc(AccountDb, MediaId) of @@ -1871,7 +1871,7 @@ get_new_attachment_url(AttachmentName, MediaId, #mailbox{owner_id=OwnerId}, Call Opts = props:filter_undefined([{'doc_owner', OwnerId}]), kz_media_url:store(AccountDb, {<<"media">>, MediaId}, AttachmentName, Opts). --spec maybe_remove_attachments(ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec maybe_remove_attachments(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. maybe_remove_attachments(AccountDb, MediaId, JObj) -> case kz_doc:maybe_remove_attachments(JObj) of {'false', _} -> 'ok'; @@ -1901,7 +1901,7 @@ min_recording_length(Call) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec recording_media_doc(ne_binary(), mailbox(), kapps_call:call()) -> ne_binary(). +-spec recording_media_doc(kz_term:ne_binary(), mailbox(), kapps_call:call()) -> kz_term:ne_binary(). recording_media_doc(Recording, #mailbox{mailbox_number=BoxNum ,mailbox_id=Id ,owner_id=OwnerId @@ -1929,8 +1929,8 @@ recording_media_doc(Recording, #mailbox{mailbox_number=BoxNum %%-------------------------------------------------------------------- -spec update_doc(kz_json:path() ,kz_json:api_json_term() - ,mailbox() | ne_binary() - ,kapps_call:call() | ne_binary() + ,mailbox() | kz_term:ne_binary() + ,kapps_call:call() | kz_term:ne_binary() ) -> 'ok' | {'error', atom()}. @@ -1959,7 +1959,7 @@ update_doc(Key, Value, Id, Call) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec tmp_file(ne_binary()) -> ne_binary(). +-spec tmp_file(kz_term:ne_binary()) -> kz_term:ne_binary(). tmp_file(Ext) -> <<(kz_binary:rand_hex(16))/binary, ".", Ext/binary>>. @@ -1970,7 +1970,7 @@ tmp_file(Ext) -> %% encoded Unix epoch in the provided timezone %% @end %%-------------------------------------------------------------------- --spec get_unix_epoch(integer(), ne_binary()) -> ne_binary(). +-spec get_unix_epoch(integer(), kz_term:ne_binary()) -> kz_term:ne_binary(). get_unix_epoch(Epoch, Timezone) -> UtcDateTime = calendar:gregorian_seconds_to_datetime(Epoch), LocalDateTime = localtime:utc_to_local(UtcDateTime, Timezone), @@ -1991,7 +1991,7 @@ find_max_message_length([JObj | T]) -> _ -> find_max_message_length(T) end. --spec is_owner(kapps_call:call(), ne_binary()) -> boolean(). +-spec is_owner(kapps_call:call(), kz_term:ne_binary()) -> boolean(). is_owner(Call, OwnerId) -> case kapps_call:owner_id(Call) of <<>> -> 'false'; @@ -2016,7 +2016,7 @@ send_mwi_update(#mailbox{owner_id=OwnerId _ = kz_util:spawn(fun send_mwi_update/4, [New, Saved, BoxNumber, Call]), lager:debug("sent MWI updates for vmbox ~s in account ~s (~b/~b)", [BoxNumber, kapps_call:account_id(Call), New, Saved]). --spec send_mwi_update(non_neg_integer(), non_neg_integer(), ne_binary(), kapps_call:call()) -> 'ok'. +-spec send_mwi_update(non_neg_integer(), non_neg_integer(), kz_term:ne_binary(), kapps_call:call()) -> 'ok'. send_mwi_update(New, Saved, BoxNumber, Call) -> Realm = kapps_call:account_realm(Call), Command = [{<<"To">>, <>} diff --git a/applications/camper/src/camper_app.erl b/applications/camper/src/camper_app.erl index 41531f36b1d..9b87186af0b 100644 --- a/applications/camper/src/camper_app.erl +++ b/applications/camper/src/camper_app.erl @@ -29,7 +29,7 @@ %% top supervisor of the tree. %% @end %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> camper_sup:start_link(). diff --git a/applications/camper/src/camper_init.erl b/applications/camper/src/camper_init.erl index 2089ef767c0..0e673d77bb4 100644 --- a/applications/camper/src/camper_init.erl +++ b/applications/camper/src/camper_init.erl @@ -16,7 +16,7 @@ %% @public %% @doc Starts the app for inclusion in a supervisor tree %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> _ = declare_exchanges(), 'ignore'. diff --git a/applications/camper/src/camper_offnet_handler.erl b/applications/camper/src/camper_offnet_handler.erl index f30b332f525..a322769970a 100644 --- a/applications/camper/src/camper_offnet_handler.erl +++ b/applications/camper/src/camper_offnet_handler.erl @@ -31,16 +31,16 @@ -define(SERVER, ?MODULE). --record(state, {exten :: api_binary() +-record(state, {exten :: kz_term:api_binary() ,stored_call :: kapps_call:call() - ,queue :: api_binary() + ,queue :: kz_term:api_binary() ,n_try :: non_neg_integer() ,max_tries :: non_neg_integer() ,try_after :: non_neg_integer() ,stop_timer :: 'undefined' | timer:tref() - ,parked_call :: api_binary() - ,offnet_ctl_q :: api_binary() - ,moh :: api_binary() + ,parked_call :: kz_term:api_binary() + ,offnet_ctl_q :: kz_term:api_binary() + ,moh :: kz_term:api_binary() }). -type state() :: #state{}. @@ -62,7 +62,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(list()) -> startlink_ret(). +-spec start_link(list()) -> kz_types:startlink_ret(). start_link(Args) -> gen_listener:start_link(?SERVER, [{'responders', ?RESPONDERS} ,{'bindings', ?BINDINGS} @@ -120,7 +120,7 @@ init([JObj]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> lager:debug("unhandled request from ~p: ~p", [_From, _Request]), {'reply', {'error', 'not_implemented'}, State}. @@ -135,7 +135,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', Q}}, #state{queue = 'undefined'} = S) -> gen_listener:cast(self(), 'count'), {'noreply', S#state{queue = Q}}; @@ -224,7 +224,7 @@ add_request(JObj) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> lager:debug("unhandled msg: ~p", [_Info]), {'noreply', State}. @@ -233,7 +233,7 @@ handle_info(_Info, State) -> handle_event(_JObj, _State) -> {'reply', []}. --spec handle_resource_response(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_resource_response(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_resource_response(JObj, Props) -> Srv = props:get_value('server', Props), CallId = kz_json:get_value(<<"Call-ID">>, JObj), @@ -295,7 +295,7 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec build_bridge_request(ne_binary(), kapps_call:call(), ne_binary()) -> kz_proplist(). +-spec build_bridge_request(kz_term:ne_binary(), kapps_call:call(), kz_term:ne_binary()) -> kz_term:proplist(). build_bridge_request(ParkedCallId, Call, Q) -> CIDNumber = kapps_call:kvs_fetch('cf_capture_group', Call), MsgId = kz_binary:rand_hex(6), @@ -320,11 +320,11 @@ build_bridge_request(ParkedCallId, Call, Q) -> | kz_api:default_headers(Q, ?APP_NAME, ?APP_VERSION) ]). --spec originate_park(ne_binary(), kapps_call:call(), ne_binary()) -> 'ok'. +-spec originate_park(kz_term:ne_binary(), kapps_call:call(), kz_term:ne_binary()) -> 'ok'. originate_park(<<_/binary>> = Exten, Call, <<_/binary>> = Q) -> kapi_offnet_resource:publish_req(build_offnet_request(Exten, Call, Q)). --spec handle_originate_ready(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_originate_ready(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_originate_ready(JObj, Props) -> Srv = props:get_value('server', Props), case {kz_json:get_value(<<"Event-Category">>, JObj) @@ -345,7 +345,7 @@ handle_originate_ready(JObj, Props) -> _Ev -> lager:info("unkown event: ~p", [_Ev]) end. --spec build_offnet_request(ne_binary(), kapps_call:call(), ne_binary()) -> kz_proplist(). +-spec build_offnet_request(kz_term:ne_binary(), kapps_call:call(), kz_term:ne_binary()) -> kz_term:proplist(). build_offnet_request(Exten, Call, Q) -> {ECIDNum, ECIDName} = kz_attributes:caller_id(<<"emergency">>, Call), {CIDNumber, CIDName} = kz_attributes:caller_id(<<"external">>, Call), diff --git a/applications/camper/src/camper_offnet_sup.erl b/applications/camper/src/camper_offnet_sup.erl index 00853be6dcc..fccdcddefb0 100644 --- a/applications/camper/src/camper_offnet_sup.erl +++ b/applications/camper/src/camper_offnet_sup.erl @@ -31,11 +31,11 @@ %%-------------------------------------------------------------------- %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec new(kz_json:object()) -> sup_startchild_ret(). +-spec new(kz_json:object()) -> kz_types:sup_startchild_ret(). new(JObj) -> supervisor:start_child(?SERVER, [JObj]). @@ -52,7 +52,7 @@ new(JObj) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 5, diff --git a/applications/camper/src/camper_onnet_handler.erl b/applications/camper/src/camper_onnet_handler.erl index 304e9e25bb6..929ac4e6cbb 100644 --- a/applications/camper/src/camper_onnet_handler.erl +++ b/applications/camper/src/camper_onnet_handler.erl @@ -31,7 +31,7 @@ -record('state', {'requests' = dict:new() :: dict:dict() ,'requestor_queues' = dict:new() :: dict:dict() ,'sipnames' = dict:new() :: dict:dict() - ,'account_db' :: api_ne_binary() + ,'account_db' :: kz_term:api_ne_binary() }). -type state() :: #state{}. @@ -47,7 +47,7 @@ get_requestor_queues(#state{'requestor_queues' = Val}) -> get_sipnames(#state{'sipnames' = Val}) -> Val. --spec get_account_db(state()) -> ne_binary(). +-spec get_account_db(state()) -> kz_term:ne_binary(). get_account_db(#state{'account_db' = Val}) -> Val. @@ -63,7 +63,7 @@ set_requestor_queues(S, Val) -> add_request(JObj) -> gen_server:cast(?SERVER, {'add_request', JObj}). --spec available_device(ne_binary(), ne_binary()) -> 'ok'. +-spec available_device(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. available_device(AccountId, SIPName) -> gen_server:cast(?SERVER, {'available_device', AccountId, SIPName}). @@ -71,7 +71,7 @@ available_device(AccountId, SIPName) -> %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_server:start_link({'local', ?SERVER}, ?MODULE, [], []). @@ -95,7 +95,7 @@ init([]) -> %% Handling call messages %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -105,7 +105,7 @@ handle_call(_Request, _From, State) -> %% Handling cast messages %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'add_request', JObj}, GlobalState) -> AccountDb = kz_json:get_value(<<"Account-DB">>, JObj), AccountId = kz_util:format_account_id(AccountDb, 'raw'), @@ -151,7 +151,7 @@ handle_cast(_Msg, State) -> lager:debug("unhandled cast: ~p", [_Msg]), {'noreply', State}. --spec with_state(ne_binary(), dict:dict(), fun((state()) -> state())) -> dict:dict(). +-spec with_state(kz_term:ne_binary(), dict:dict(), fun((state()) -> state())) -> dict:dict(). with_state(AccountId, Global, F) -> Local = case dict:find(AccountId, Global) of {'ok', #state{}=S} -> S; @@ -162,7 +162,7 @@ with_state(AccountId, Global, F) -> end, dict:store(AccountId, F(Local), Global). --spec maybe_handle_request(ne_binary(), queue:queue(), state()) -> state(). +-spec maybe_handle_request(kz_term:ne_binary(), queue:queue(), state()) -> state(). maybe_handle_request(SIPName, Q, Local) -> case queue:out(Q) of {{'value', Requestor}, NewQ} -> @@ -174,7 +174,7 @@ maybe_handle_request(SIPName, Q, Local) -> Local end. --spec handle_request(ne_binary(), {ne_binary(), ne_binary()}, state()) -> state(). +-spec handle_request(kz_term:ne_binary(), {kz_term:ne_binary(), kz_term:ne_binary()}, state()) -> state(). handle_request(SIPName, Requestor, Local) -> Reqs = get_requests(Local), case dict:find({SIPName, Requestor}, Reqs) of @@ -194,7 +194,7 @@ handle_request(SIPName, Requestor, Local) -> Local end. --spec originate_call({ne_binary(), ne_binary()}, ne_binary(), ne_binary()) -> 'ok'. +-spec originate_call({kz_term:ne_binary(), kz_term:ne_binary()}, kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. originate_call({Id, Type}, Exten, AccountDb) -> Routines = [fun(C) -> kapps_call:set_account_db(AccountDb, C) end ,fun(C) -> kapps_call:set_account_id(kz_util:format_account_id(AccountDb, 'raw'), C) end @@ -209,7 +209,7 @@ originate_call({Id, Type}, Exten, AccountDb) -> originate_quickcall(Endpoints, Exten, Call) end. --spec originate_quickcall(kz_json:objects(), ne_binary(), kapps_call:call()) -> 'ok'. +-spec originate_quickcall(kz_json:objects(), kz_term:ne_binary(), kapps_call:call()) -> 'ok'. originate_quickcall(Endpoints, Exten, Call) -> CCVs = [{<<"Account-ID">>, kapps_call:account_id(Call)} ,{<<"Retain-CID">>, <<"true">>} @@ -235,7 +235,7 @@ originate_quickcall(Endpoints, Exten, Call) -> kapi_resource:publish_originate_req(props:filter_undefined(Request)), lager:debug("Originate request published"). --spec get_endpoints(kapps_call:call(), ne_binary(), ne_binary()) -> kz_json:objects(). +-spec get_endpoints(kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:objects(). get_endpoints(Call, EndpointId, Type) when Type =:= <<"device">>; Type =:= <<"mobile">> -> Properties = kz_json:from_list([{<<"can_call_self">>, 'true'} @@ -261,7 +261,7 @@ get_endpoints(Call, UserId, <<"user">>) -> get_endpoints(_, _, _) -> []. --spec clear_request(ne_binary(), ne_binary(), state()) -> state(). +-spec clear_request(kz_term:ne_binary(), kz_term:ne_binary(), state()) -> state(). clear_request(Requestor, Exten, Local) -> {'ok', SIPNames} = dict:find(Exten, get_sipnames(Local)), lists:foldl(fun(SIPName, Acc) -> @@ -276,7 +276,7 @@ clear_request(Requestor, Exten, Local) -> ,SIPNames ). --spec make_requests(ne_binaries(), {ne_binary(), ne_binary()}, ne_binary(), non_neg_integer()) -> dict:dict(). +-spec make_requests(kz_term:ne_binaries(), {kz_term:ne_binary(), kz_term:ne_binary()}, kz_term:ne_binary(), non_neg_integer()) -> dict:dict(). make_requests(SIPNames, Requestor, Exten, Timeout) -> R = [{SIPName, Requestor} || SIPName <- SIPNames], {_, Seconds, _} = os:timestamp(), @@ -287,7 +287,7 @@ make_requests(SIPNames, Requestor, Exten, Timeout) -> ,R ). --spec maybe_update_queues(ne_binaries(), {ne_binary(), ne_binary()}, dict:dict()) -> dict:dict(). +-spec maybe_update_queues(kz_term:ne_binaries(), {kz_term:ne_binary(), kz_term:ne_binary()}, dict:dict()) -> dict:dict(). maybe_update_queues(SIPNames, Requestor, Queues) -> lists:foldl(fun(SIPName, Acc) -> Q = case dict:find(SIPName, Acc) of @@ -313,7 +313,7 @@ maybe_update_queues(SIPNames, Requestor, Queues) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(?HOOK_EVT(_AccountId, _, JObj), State) -> AcctId = kz_json:get_value([<<"Custom-Channel-Vars">>, <<"Account-ID">>], JObj), SIPName = kz_json:get_value([<<"Custom-Channel-Vars">>, <<"Username">>], JObj), diff --git a/applications/camper/src/camper_request_listener.erl b/applications/camper/src/camper_request_listener.erl index 03f63b09b74..b5b0a2f2631 100644 --- a/applications/camper/src/camper_request_listener.erl +++ b/applications/camper/src/camper_request_listener.erl @@ -49,7 +49,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'responders', ?RESPONDERS} ,{'bindings', ?BINDINGS} @@ -68,7 +68,7 @@ start_link() -> %% %% @end %%-------------------------------------------------------------------- --spec handle_camper_req(kz_json:object(), kz_proplist(), gen_listener:basic_deliver()) -> any(). +-spec handle_camper_req(kz_json:object(), kz_term:proplist(), gen_listener:basic_deliver()) -> any(). handle_camper_req(JObj, _Props, #'basic.deliver'{'routing_key' = Key}) -> case binary:split(Key, <<".">>, ['global']) of [_, ?APP_NAME, <<"offnet">>] -> @@ -113,7 +113,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -127,7 +127,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener',{'created_queue',_QueueName}}, State) -> {'noreply', State}; handle_cast({'gen_listener',{'is_consuming',_IsConsuming}}, State) -> @@ -146,7 +146,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> lager:info("unhandled msg: ~p", [_Info]), {'noreply', State}. diff --git a/applications/camper/src/camper_sup.erl b/applications/camper/src/camper_sup.erl index 735816f6bc4..f6140f2feb3 100644 --- a/applications/camper/src/camper_sup.erl +++ b/applications/camper/src/camper_sup.erl @@ -33,7 +33,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -50,7 +50,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/cccp/src/cb_cccps.erl b/applications/cccp/src/cb_cccps.erl index f46b5a0ddb5..bc7b4e6ec0f 100644 --- a/applications/cccp/src/cb_cccps.erl +++ b/applications/cccp/src/cb_cccps.erl @@ -139,7 +139,7 @@ validate_cccp(Context, Id, ?HTTP_POST) -> validate_cccp(Context, Id, ?HTTP_DELETE) -> read(Id, Context). --spec send_new_camping(kz_json:object(), ne_binary()) -> 'ok'. +-spec send_new_camping(kz_json:object(), kz_term:ne_binary()) -> 'ok'. send_new_camping(JObj, AccountId) -> Req = [{<<"Camping-Request">>, JObj} ,{<<"Account-ID">>, AccountId} @@ -210,7 +210,7 @@ create(Context) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec read(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec read(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). read(Id, Context) -> crossbar_doc:load(Id, Context, ?TYPE_CHECK_OPTION(<<"cccp">>)). @@ -221,7 +221,7 @@ read(Id, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec update(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec update(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). update(Id, Context) -> OnSuccess = fun(C) -> on_successful_validation(Id, C) end, cb_context:validate_request_data(<<"cccps">>, Context, OnSuccess). @@ -243,7 +243,7 @@ summary(Context) -> %% %% @end %%-------------------------------------------------------------------- --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> cb_context:set_doc(Context, kz_doc:set_type(cb_context:doc(Context), <<"cccp">>)); on_successful_validation(Id, Context) -> @@ -300,7 +300,7 @@ error_pin_exists(Context) -> ,Context ). --spec error_number_is_not_reconcilable(cb_context:context(), ne_binary()) -> +-spec error_number_is_not_reconcilable(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). error_number_is_not_reconcilable(Context, CID) -> cb_context:add_validation_error(<<"cccp">> @@ -338,7 +338,7 @@ unique_pin(Context) -> _ -> 'false' end. --spec authorize_listing(ne_binary(), ne_binary()) -> +-spec authorize_listing(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object() | kz_json:objects()} | 'empty' | 'error'. diff --git a/applications/cccp/src/cccp.hrl b/applications/cccp/src/cccp.hrl index 50eae48e188..bccb58b093e 100644 --- a/applications/cccp/src/cccp.hrl +++ b/applications/cccp/src/cccp.hrl @@ -10,21 +10,21 @@ -define(CCCP_CONFIG_CAT, <<"cccp">>). --record(state, {a_leg_name :: api_ne_binary() - ,a_leg_number :: api_ne_binary() - ,b_leg_number :: api_ne_binary() +-record(state, {a_leg_name :: kz_term:api_ne_binary() + ,a_leg_number :: kz_term:api_ne_binary() + ,b_leg_number :: kz_term:api_ne_binary() ,call = kapps_call:new() :: kapps_call:call() - ,account_id :: api_ne_binary() - ,authorizing_id :: api_ne_binary() - ,queue :: api_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() + ,account_id :: kz_term:api_ne_binary() + ,authorizing_id :: kz_term:api_ne_binary() + ,queue :: kz_term:api_binary() + ,parked_call_id :: kz_term:api_ne_binary() + ,offnet_ctl_q :: kz_term:api_ne_binary() + ,auth_doc_id :: kz_term:api_ne_binary() + ,media_id :: kz_term:api_ne_binary() + ,retain_cid :: kz_term:api_ne_binary() ,self = self() :: pid() - ,consumer_pid :: api_pid() - ,callback_delay :: api_integer() + ,consumer_pid :: kz_term:api_pid() + ,callback_delay :: kz_term:api_integer() }). -type state() :: #state{}. diff --git a/applications/cccp/src/cccp_app.erl b/applications/cccp/src/cccp_app.erl index 6bba6629eae..b17c8e14743 100644 --- a/applications/cccp/src/cccp_app.erl +++ b/applications/cccp/src/cccp_app.erl @@ -18,7 +18,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = declare_exchanges(), cccp_sup:start_link(). diff --git a/applications/cccp/src/cccp_callback_listener.erl b/applications/cccp/src/cccp_callback_listener.erl index a32b580e99b..29b7ce06ef0 100644 --- a/applications/cccp/src/cccp_callback_listener.erl +++ b/applications/cccp/src/cccp_callback_listener.erl @@ -39,7 +39,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(list()) -> startlink_ret(). +-spec start_link(list()) -> kz_types:startlink_ret(). start_link(JObj) -> gen_listener:start_link(?SERVER, [{'responders', ?RESPONDERS} ,{'bindings', ?BINDINGS} @@ -92,7 +92,7 @@ init([JObj]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -106,7 +106,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', Q}}, #state{queue='undefined'}=S) -> gen_listener:cast(self(), 'originate_park'), {'noreply', S#state{queue = Q}}; @@ -139,7 +139,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -214,7 +214,7 @@ originate_park(#state{account_id=AccountId gen_listener:cast(self(), 'stop_callback') end. --spec handle_resource_response(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_resource_response(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_resource_response(JObj, Props) -> Srv = props:get_value('server', Props), CallId = kz_json:get_value(<<"Call-ID">>, JObj), @@ -254,7 +254,7 @@ handle_originate_response(JObj, Props) -> _ -> 'ok' end. --spec bridge_to_final_destination(ne_binary(), ne_binary(), state()) -> 'ok'. +-spec bridge_to_final_destination(kz_term:ne_binary(), kz_term:ne_binary(), state()) -> 'ok'. bridge_to_final_destination(CallId, ToDID, #state{offnet_ctl_q=CtrlQ ,account_id=AccountId ,authorizing_id=AuthorizingId @@ -269,7 +269,7 @@ bridge_to_final_destination(CallId, ToDID, #state{offnet_ctl_q=CtrlQ _ -> cccp_util:store_last_dialed(ToDID, AccountDocId) end. --spec b_leg_number(kz_proplist()) -> ne_binary(). +-spec b_leg_number(kz_term:proplist()) -> kz_term:ne_binary(). b_leg_number(Props) -> case props:get_value('b_leg_number', Props) of 'undefined' -> @@ -285,7 +285,7 @@ b_leg_number(Props) -> BLegNumber end. --spec maybe_make_announcement_to_a_leg(kz_proplist()) -> 'ok'. +-spec maybe_make_announcement_to_a_leg(kz_term:proplist()) -> 'ok'. maybe_make_announcement_to_a_leg(Props) -> case props:get_value('media_id', Props) of <> -> @@ -297,11 +297,11 @@ maybe_make_announcement_to_a_leg(Props) -> _ -> 'ok' end. --spec call(kz_proplist()) -> kapps_call:call(). +-spec call(kz_term:proplist()) -> kapps_call:call(). call(Props) -> props:get_value('call', Props). --spec maybe_handle_doc_id(ne_binary(), kz_proplist()) -> 'ok'. +-spec maybe_handle_doc_id(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. maybe_handle_doc_id(DocId, Props) -> AccountDb = kz_util:format_account_id(props:get_value('account_id', Props), 'encoded'), case kz_datamgr:open_cache_doc(AccountDb, DocId) of @@ -309,7 +309,7 @@ maybe_handle_doc_id(DocId, Props) -> {'ok', JObj} -> maybe_handle_doc(JObj, Props) end. --spec maybe_handle_doc(kz_json:object(), kz_proplist()) -> 'ok'. +-spec maybe_handle_doc(kz_json:object(), kz_term:proplist()) -> 'ok'. maybe_handle_doc(JObj, Props) -> Call = call(Props), case kz_doc:type(JObj) of diff --git a/applications/cccp/src/cccp_callback_sup.erl b/applications/cccp/src/cccp_callback_sup.erl index b774dbdb3b2..859857a5adb 100644 --- a/applications/cccp/src/cccp_callback_sup.erl +++ b/applications/cccp/src/cccp_callback_sup.erl @@ -31,11 +31,11 @@ %%-------------------------------------------------------------------- %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec new(kz_json:object()) -> sup_startchild_ret(). +-spec new(kz_json:object()) -> kz_types:sup_startchild_ret(). new(JObj) -> supervisor:start_child(?SERVER, [JObj]). @@ -52,7 +52,7 @@ new(JObj) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 5, diff --git a/applications/cccp/src/cccp_handlers.erl b/applications/cccp/src/cccp_handlers.erl index 19220e549cd..07e432b5157 100644 --- a/applications/cccp/src/cccp_handlers.erl +++ b/applications/cccp/src/cccp_handlers.erl @@ -20,7 +20,7 @@ -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(). +-spec handle_route_req(kz_json:object(), kz_term:proplist()) -> any(). handle_route_req(JObj, Props) -> 'true' = kapi_route:req_v(JObj), Call = kapps_call:from_route_req(JObj), @@ -32,7 +32,7 @@ handle_route_req(JObj, Props) -> _ -> 'ok' end. --spec park_call(kz_json:object(), kz_proplist(), kapps_call:call()) -> 'ok'. +-spec park_call(kz_json:object(), kz_term:proplist(), kapps_call:call()) -> 'ok'. park_call(JObj, Props, Call) -> Q = props:get_value('queue', Props), Resp = props:filter_undefined([{<<"Msg-ID">>, kz_json:get_value(<<"Msg-ID">>, JObj)} @@ -44,7 +44,7 @@ park_call(JObj, Props, Call) -> kapps_util:amqp_pool_send(Resp, Publisher), kapps_call:cache(Call, ?APP_NAME). --spec handle_route_win(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_route_win(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_route_win(JObj, _Props) -> 'true' = kapi_route:win_v(JObj), CallId = kz_json:get_value(<<"Call-ID">>, JObj), @@ -56,7 +56,7 @@ handle_route_win(JObj, _Props) -> lager:debug("Unable to find call record during route_win") end. --spec handle_config_change(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_config_change(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_config_change(_JObj, _Props) -> 'ok'. diff --git a/applications/cccp/src/cccp_listener.erl b/applications/cccp/src/cccp_listener.erl index 8e8b85c5480..29a90daec50 100644 --- a/applications/cccp/src/cccp_listener.erl +++ b/applications/cccp/src/cccp_listener.erl @@ -42,7 +42,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'bindings', ?BINDINGS} ,{'responders', ?RESPONDERS} @@ -86,7 +86,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -100,7 +100,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _QueueNAme}}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'is_consuming', _IsConsuming}}, State) -> @@ -118,7 +118,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -130,7 +130,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. @@ -170,7 +170,7 @@ validate_sysconfig() -> validate_sysconfig(<<"cccp_cb_number">>), validate_sysconfig(<<"cccp_cc_number">>). --spec validate_sysconfig(ne_binary()) -> 'ok'. +-spec validate_sysconfig(kz_term:ne_binary()) -> 'ok'. validate_sysconfig(Key) -> 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]); diff --git a/applications/cccp/src/cccp_platform_listener.erl b/applications/cccp/src/cccp_platform_listener.erl index 17c85afafe6..6ba2889f478 100644 --- a/applications/cccp/src/cccp_platform_listener.erl +++ b/applications/cccp/src/cccp_platform_listener.erl @@ -39,7 +39,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(kapps_call:call()) -> startlink_ret(). +-spec start_link(kapps_call:call()) -> kz_types:startlink_ret(). start_link(Call) -> CallId = kapps_call:call_id(Call), Bindings = [{'call', [{'callid', CallId}]} @@ -86,7 +86,7 @@ init([Call]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -100,7 +100,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener',{'created_queue',Queue}}, #state{call=Call}=State) -> {'noreply', State#state{call=kapps_call:set_controller_queue(Queue, Call)}}; handle_cast({'gen_listener',{'is_consuming', 'true'}}, #state{call=Call}=State) -> @@ -123,7 +123,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -166,7 +166,7 @@ terminate(_Reason, _State) -> code_change(_OldVsn, State, _Extra) -> {'ok', State}. --spec handle_answer(kz_json:object(), kz_proplist()) -> ok. +-spec handle_answer(kz_json:object(), kz_term:proplist()) -> ok. handle_answer(JObj, Props) -> Srv = props:get_value('server', Props), case kz_util:get_event_type(JObj) of @@ -236,7 +236,7 @@ pin_collect(Call, Retries) -> pin_collect(Call, Retries - 1) end. --spec handle_entered_pin(kapps_call:call(), integer(), ne_binary()) -> 'ok'. +-spec handle_entered_pin(kapps_call:call(), integer(), kz_term:ne_binary()) -> 'ok'. handle_entered_pin(Call, Retries, EnteredPin) -> case cccp_util:authorize(EnteredPin, <<"cccps/pin_listing">>) of {'ok', AuthJObj} -> diff --git a/applications/cccp/src/cccp_platform_sup.erl b/applications/cccp/src/cccp_platform_sup.erl index 38a6bb52c2d..ec560918cdd 100644 --- a/applications/cccp/src/cccp_platform_sup.erl +++ b/applications/cccp/src/cccp_platform_sup.erl @@ -31,11 +31,11 @@ %%-------------------------------------------------------------------- %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec new(kapps_call:call()) -> sup_startchild_ret(). +-spec new(kapps_call:call()) -> kz_types:sup_startchild_ret(). new(Call) -> supervisor:start_child(?SERVER, [Call]). @@ -52,7 +52,7 @@ new(Call) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 5, diff --git a/applications/cccp/src/cccp_shared_listener.erl b/applications/cccp/src/cccp_shared_listener.erl index a7f4652d789..d4fcad210f9 100644 --- a/applications/cccp/src/cccp_shared_listener.erl +++ b/applications/cccp/src/cccp_shared_listener.erl @@ -43,7 +43,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'bindings', ?BINDINGS} ,{'responders', ?RESPONDERS} @@ -52,7 +52,7 @@ start_link() -> ,{'consume_options', ?CONSUME_OPTIONS} % optional to include ], []). --spec handle_camping_req(kapi_camping:req(), kz_proplist()) -> 'ok'. +-spec handle_camping_req(kapi_camping:req(), kz_term:proplist()) -> 'ok'. handle_camping_req(JObj, _Props) -> 'true' = kapi_camping:req_v(JObj), CampingData = kz_json:get_json_value(<<"Camping-Request">>, JObj), @@ -92,7 +92,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -106,7 +106,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _QueueNAme}}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'is_consuming', _IsConsuming}}, State) -> @@ -124,7 +124,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -136,7 +136,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/cccp/src/cccp_sup.erl b/applications/cccp/src/cccp_sup.erl index 4d0f36b2181..80ab3732380 100644 --- a/applications/cccp/src/cccp_sup.erl +++ b/applications/cccp/src/cccp_sup.erl @@ -32,7 +32,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -49,7 +49,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/cccp/src/cccp_util.erl b/applications/cccp/src/cccp_util.erl index 9f39a2dbe3f..e4ee0eb6046 100644 --- a/applications/cccp/src/cccp_util.erl +++ b/applications/cccp/src/cccp_util.erl @@ -25,14 +25,14 @@ -define(DEFAULT_CALLEE_REGEX, <<"^\\+?\\d{7,}$">>). --spec relay_amqp(kz_json:object(), kz_proplist()) -> 'ok'. +-spec relay_amqp(kz_json:object(), kz_term:proplist()) -> 'ok'. relay_amqp(JObj, Props) -> case kapps_call:kvs_fetch('consumer_pid', props:get_value('call', Props)) of Pid when is_pid(Pid) -> kapps_call_command:relay_event(Pid, JObj); _ -> 'ok' end. --spec handle_disconnect(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_disconnect(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_disconnect(JObj, Props) -> case (<<"CHANNEL_EXECUTE_COMPLETE">> =:= kz_json:get_value(<<"Event-Name">>, JObj)) andalso is_binary(kz_json:get_value(<<"Hangup-Code">>, JObj)) @@ -62,7 +62,7 @@ handle_disconnect_cause(JObj, Call) -> kapps_call_command:queued_hangup(Call) end. --spec authorize(ne_binary(), ne_binary()) -> +-spec authorize(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | 'empty' | 'error'. @@ -77,10 +77,10 @@ authorize(Value, View) -> end. -spec get_number(kapps_call:call()) -> - {'num_to_dial', ne_binary()} | + {'num_to_dial', kz_term:ne_binary()} | 'ok'. -spec get_number(kapps_call:call(), integer()) -> - {'num_to_dial', ne_binary()} | + {'num_to_dial', kz_term:ne_binary()} | 'ok'. get_number(Call) -> get_number(Call, 3). @@ -102,7 +102,7 @@ get_number(Call, Retries) -> get_number(Call, Retries - 1) end. --spec verify_entered_number(ne_binary(), kapps_call:call(), integer()) -> 'ok'. +-spec verify_entered_number(kz_term:ne_binary(), kapps_call:call(), integer()) -> 'ok'. verify_entered_number(EnteredNumber, Call, Retries) -> Number = knm_converters:normalize(re:replace(EnteredNumber, "[^0-9]", "", ['global', {'return', 'binary'}])), case cccp_allowed_callee(Number) of @@ -115,7 +115,7 @@ verify_entered_number(EnteredNumber, Call, Retries) -> end. -spec get_last_dialed_number(kapps_call:call()) -> - {'num_to_dial', ne_binary()} | + {'num_to_dial', kz_term:ne_binary()} | 'ok'. get_last_dialed_number(Call) -> DocId = kapps_call:kvs_fetch('auth_doc_id', Call), @@ -129,14 +129,14 @@ get_last_dialed_number(Call) -> check_restrictions(LastDialed, Call) end. --spec store_last_dialed(ne_binary(), ne_binary()) -> 'ok'. +-spec store_last_dialed(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. store_last_dialed(Number, DocId) -> {'ok', Doc} = kz_datamgr:update_doc(?KZ_CCCPS_DB, DocId, [{<<"pvt_last_dialed">>, Number}]), _ = kz_datamgr:update_doc(kz_doc:account_db(Doc), DocId, [{<<"pvt_last_dialed">>, Number}]), 'ok'. --spec check_restrictions(ne_binary(), kapps_call:call()) -> - {'num_to_dial', ne_binary()} | +-spec check_restrictions(kz_term:ne_binary(), kapps_call:call()) -> + {'num_to_dial', kz_term:ne_binary()} | 'ok'. check_restrictions(Number, Call) -> DocId = kapps_call:kvs_fetch('auth_doc_id', Call), @@ -151,7 +151,7 @@ check_restrictions(Number, Call) -> is_user_restricted(Number, kz_json:get_value(<<"user_id">>, Doc), AccountDb, Call) end. --spec is_number_restricted(ne_binary(), ne_binary(), ne_binary()) -> boolean(). +-spec is_number_restricted(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_number_restricted(Number, DocId, AccountDb) -> case kz_datamgr:open_cache_doc(AccountDb, DocId) of {'error', _} -> 'false'; @@ -160,8 +160,8 @@ is_number_restricted(Number, DocId, AccountDb) -> kz_json:get_value([<<"call_restriction">>, Classification, <<"action">>], JObj) =:= <<"deny">> end. --spec is_user_restricted(ne_binary(), ne_binary(), ne_binary(), kapps_call:call()) -> - {'num_to_dial', ne_binary()} | +-spec is_user_restricted(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> + {'num_to_dial', kz_term:ne_binary()} | 'ok'. is_user_restricted(Number, UserId, AccountDb, Call) -> case is_number_restricted(Number, UserId, AccountDb) of @@ -177,7 +177,7 @@ hangup_unauthorized_call(Call) -> kapps_call_command:prompt(<<"cf-unauthorized_call">>, Call), kapps_call_command:queued_hangup(Call). --spec cccp_allowed_callee(ne_binary()) -> boolean(). +-spec cccp_allowed_callee(kz_term:ne_binary()) -> boolean(). cccp_allowed_callee(Number) -> Regex = kapps_config:get_binary(?CCCP_CONFIG_CAT, <<"allowed_callee_regex">>, ?DEFAULT_CALLEE_REGEX), case re:run(Number, Regex) of @@ -189,7 +189,7 @@ cccp_allowed_callee(Number) -> 'true' end. --spec build_request(api_binary(), api_binary(), api_binary(), api_binary(), api_binary(), api_binary(), api_binary(), ne_binary(),binary(),binary()) -> kz_proplist(). +-spec build_request(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:ne_binary(),binary(),binary()) -> kz_term:proplist(). build_request(CallId, ToDID, AuthorizingId, Q, CtrlQ, AccountId, Action, RetainCID, RetainName, RetainNumber) -> Realm = kz_account:fetch_realm(AccountId), CCVs = props:filter_undefined([{<<"Account-ID">>, AccountId} @@ -232,13 +232,13 @@ build_request(CallId, ToDID, AuthorizingId, Q, CtrlQ, AccountId, Action, RetainC | kz_api:default_headers(Q, <<"resource">>, <<"originate_req">>, ?APP_NAME, ?APP_VERSION) ]). --spec bridge(ne_binary(), ne_binary(), ne_binary(), ne_binary(), ne_binary(), ne_binary(), binary(), binary()) -> 'ok'. +-spec bridge(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), binary(), binary()) -> 'ok'. bridge(CallId, ToDID, AuthorizingId, CtrlQ, AccountId, RetainCID, RetainName, RetainNumber) -> Req = build_request(CallId, ToDID, AuthorizingId, 'undefined', CtrlQ, AccountId, <<"bridge">>, RetainCID, RetainName, RetainNumber), kapi_resource:publish_originate_req(Req). --spec compose_cid(ne_binary(), ne_binary(), binary(), binary(), ne_binary()) -> - {api_binary(), api_binary()}. +-spec compose_cid(kz_term:ne_binary(), kz_term:ne_binary(), binary(), binary(), kz_term:ne_binary()) -> + {kz_term:api_binary(), kz_term:api_binary()}. compose_cid(ToDID, RetainCID, RetainNumber, RetainName, AccountId) -> case RetainCID of <<"true">> -> @@ -247,7 +247,7 @@ compose_cid(ToDID, RetainCID, RetainNumber, RetainName, AccountId) -> {'undefined','undefined'} end. --spec maybe_outbound_call(ne_binary(), binary(), binary(), ne_binary()) -> +-spec maybe_outbound_call(kz_term:ne_binary(), binary(), binary(), kz_term:ne_binary()) -> {binary(), binary()}. maybe_outbound_call(ToDID, RetainNumber, RetainName, AccountId) -> case knm_converters:is_reconcilable(ToDID) of @@ -262,22 +262,22 @@ maybe_outbound_call(ToDID, RetainNumber, RetainName, AccountId) -> end end. --spec maybe_cid_name(api_ne_binary(), api_ne_binary()) -> api_ne_binary(). +-spec maybe_cid_name(kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> kz_term:api_ne_binary(). maybe_cid_name(<>, _) -> Name; maybe_cid_name(_, Number) -> Number. --spec build_presence(api_ne_binary(), ne_binary()) -> api_ne_binary(). +-spec build_presence(kz_term:api_ne_binary(), kz_term:ne_binary()) -> kz_term:api_ne_binary(). build_presence(<>, Realm) -> <>; build_presence(_, _) -> 'undefined'. --spec current_account_outbound_directions(ne_binary()) -> ne_binaries(). +-spec current_account_outbound_directions(kz_term:ne_binary()) -> kz_term:ne_binaries(). current_account_outbound_directions(AccountId) -> [kz_json:get_ne_binary_value(<<"destination">>, Channel) || Channel <- current_account_channels(AccountId), <<"outbound">> =:= kz_json:get_ne_binary_value(<<"direction">>, Channel) ]. --spec count_user_legs(ne_binary(), ne_binary()) -> integer(). +-spec count_user_legs(kz_term:ne_binary(), kz_term:ne_binary()) -> integer(). count_user_legs(UserId, AccountId) -> lists:foldl(fun(Channel, Acc) -> is_user_channel(Channel, UserId) + Acc @@ -286,14 +286,14 @@ count_user_legs(UserId, AccountId) -> ,current_account_channels(AccountId) ). --spec is_user_channel(kz_json:object(), ne_binary()) -> integer(). +-spec is_user_channel(kz_json:object(), kz_term:ne_binary()) -> integer(). is_user_channel(Channel, UserId) -> case kz_json:get_ne_binary_value(<<"authorizing_id">>, Channel) of UserId -> 1; _ -> 0 end. --spec current_account_channels(ne_binary()) -> kz_json:objects(). +-spec current_account_channels(kz_term:ne_binary()) -> kz_json:objects(). current_account_channels(AccountId) -> Req = [{<<"Realm">>, kz_account:fetch_realm(AccountId)} ,{<<"Usernames">>, []} diff --git a/applications/cdr/src/cdr.hrl b/applications/cdr/src/cdr.hrl index 73949ff0719..24ddba33ab2 100644 --- a/applications/cdr/src/cdr.hrl +++ b/applications/cdr/src/cdr.hrl @@ -9,8 +9,8 @@ -define(APP_VERSION, <<"4.0.0">>). -define(CONFIG_CAT, ?APP_NAME). --type account_id() :: ne_binary(). --type account_db() :: ne_binary(). +-type account_id() :: kz_term:ne_binary(). +-type account_db() :: kz_term:ne_binary(). -define(CDR_HRL, 'true'). -endif. diff --git a/applications/cdr/src/cdr_app.erl b/applications/cdr/src/cdr_app.erl index ad1f5d93674..5ee76703a7a 100644 --- a/applications/cdr/src/cdr_app.erl +++ b/applications/cdr/src/cdr_app.erl @@ -22,7 +22,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_StartType, _StartArgs) -> _ = declare_exchanges(), _ = kz_datamgr:revise_doc_from_file(?KZ_ANONYMOUS_CDR_DB, 'cdr', <<"cdr.json">>), diff --git a/applications/cdr/src/cdr_channel_destroy.erl b/applications/cdr/src/cdr_channel_destroy.erl index 0dac1a74cc8..98fdcf721e8 100644 --- a/applications/cdr/src/cdr_channel_destroy.erl +++ b/applications/cdr/src/cdr_channel_destroy.erl @@ -27,7 +27,7 @@ -define(CHANNEL_VARS, <<"Custom-Channel-Vars">>). -define(CCV(Key), [?CHANNEL_VARS, Key]). --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Props) -> 'true' = kapi_call:event_v(JObj), _ = kz_util:put_callid(JObj), @@ -67,7 +67,7 @@ maybe_ignore_loopback(JObj) -> <<"ignoring cdr request for loopback channel">> }. --spec is_normal_hangup_cause(api_binary()) -> boolean(). +-spec is_normal_hangup_cause(kz_term:api_binary()) -> boolean(). is_normal_hangup_cause('undefined') -> 'true'; is_normal_hangup_cause(<<"NORMAL", _/binary>>) -> 'true'; is_normal_hangup_cause(_) -> 'false'. @@ -78,7 +78,7 @@ handle_req(JObj) -> Timestamp = kz_call_event:timestamp(JObj), prepare_and_save(AccountId, Timestamp, JObj). --spec prepare_and_save(account_id(), gregorian_seconds(), kz_json:object()) -> 'ok'. +-spec prepare_and_save(account_id(), kz_time:gregorian_seconds(), kz_json:object()) -> 'ok'. prepare_and_save(AccountId, Timestamp, JObj) -> Routines = [fun update_pvt_parameters/3 ,fun update_ccvs/3 @@ -96,7 +96,7 @@ prepare_and_save(AccountId, Timestamp, JObj) -> ), 'ok'. --spec update_pvt_parameters(api_binary(), gregorian_seconds(), kz_json:object()) -> kz_json:object(). +-spec update_pvt_parameters(kz_term:api_binary(), kz_time:gregorian_seconds(), kz_json:object()) -> kz_json:object(). update_pvt_parameters('undefined', _, JObj) -> Props = [{'type', 'cdr'} ,{'crossbar_doc_vsn', 2} @@ -110,7 +110,7 @@ update_pvt_parameters(AccountId, Timestamp, JObj) -> ], kz_doc:update_pvt_parameters(JObj, AccountMODb, Props). --spec update_ccvs(api_binary(), gregorian_seconds(), kz_json:object()) -> kz_json:object(). +-spec update_ccvs(kz_term:api_binary(), kz_time:gregorian_seconds(), kz_json:object()) -> kz_json:object(). update_ccvs(_, _, JObj) -> CCVs = kz_call_event:custom_channel_vars(JObj, kz_json:new()), {UpdatedJobj, UpdatedCCVs} = @@ -131,7 +131,7 @@ update_ccvs_foldl(Key, Value, {JObj, CCVs}=Acc) -> } end. --spec set_doc_id(api_binary(), gregorian_seconds(), kz_json:object()) -> kz_json:object(). +-spec set_doc_id(kz_term:api_binary(), kz_time:gregorian_seconds(), kz_json:object()) -> kz_json:object(). set_doc_id(_, Timestamp, JObj) -> CallId = kz_call_event:call_id(JObj), %% we should consider this because there is a lost channel in case of @@ -140,19 +140,19 @@ set_doc_id(_, Timestamp, JObj) -> DocId = cdr_util:get_cdr_doc_id(Timestamp, CallId), kz_doc:set_id(JObj, DocId). --spec set_call_priority(api_binary(), gregorian_seconds(), kz_json:object()) -> kz_json:object(). +-spec set_call_priority(kz_term:api_binary(), kz_time:gregorian_seconds(), kz_json:object()) -> kz_json:object(). set_call_priority(_AccountId, _Timestamp, JObj) -> maybe_leak_ccv(JObj, <<"Call-Priority">>). --spec set_recording_url(api_binary(), gregorian_seconds(), kz_json:object()) -> kz_json:object(). +-spec set_recording_url(kz_term:api_binary(), kz_time:gregorian_seconds(), kz_json:object()) -> kz_json:object(). set_recording_url(_AccountId, _Timestamp, JObj) -> maybe_leak_ccv(JObj, <<"Recording-Url">>). --spec maybe_set_e164_destination(api_binary(), gregorian_seconds(), kz_json:object()) -> kz_json:object(). +-spec maybe_set_e164_destination(kz_term:api_binary(), kz_time:gregorian_seconds(), kz_json:object()) -> kz_json:object(). maybe_set_e164_destination(_AccountId, _Timestamp, JObj) -> maybe_leak_ccv(JObj, <<"E164-Destination">>). --spec is_conference(api_binary(), gregorian_seconds(), kz_json:object()) -> kz_json:object(). +-spec is_conference(kz_term:api_binary(), kz_time:gregorian_seconds(), kz_json:object()) -> kz_json:object(). is_conference(_AccountId, _Timestamp, JObj) -> maybe_leak_ccv(JObj, <<"Is-Conference">>, {fun kz_json:is_true/3, 'false'}). @@ -171,7 +171,7 @@ maybe_leak_ccv(JObj, Key, {GetFun, Default}) -> ) end. --spec set_interaction(api_binary(), gregorian_seconds(), kz_json:object()) -> +-spec set_interaction(kz_term:api_binary(), kz_time:gregorian_seconds(), kz_json:object()) -> kz_json:object(). set_interaction(_AccountId, _Timestamp, JObj) -> Interaction = kz_call_event:custom_channel_var(JObj, <>, ?CALL_INTERACTION_DEFAULT), @@ -187,7 +187,7 @@ set_interaction(_AccountId, _Timestamp, JObj) -> ,kz_json:delete_key(?CCV(<>), kz_doc:set_id(JObj, DocId)) ). --spec save_cdr(api_binary(), gregorian_seconds(), kz_json:object()) -> kz_json:object(). +-spec save_cdr(kz_term:api_binary(), kz_time:gregorian_seconds(), kz_json:object()) -> kz_json:object(). save_cdr(_, _, JObj) -> CDRDb = kz_doc:account_db(JObj), case cdr_util:save_cdr(CDRDb, kz_json:normalize_jobj(JObj)) of diff --git a/applications/cdr/src/cdr_listener.erl b/applications/cdr/src/cdr_listener.erl index 923dc24de06..6e4ebde3ea9 100644 --- a/applications/cdr/src/cdr_listener.erl +++ b/applications/cdr/src/cdr_listener.erl @@ -30,7 +30,7 @@ -record(state, {counter = #{} :: map()}). -type state() :: #state{}. --type counter_element() :: {gregorian_seconds(), non_neg_integer()}. +-type counter_element() :: {kz_time:gregorian_seconds(), non_neg_integer()}. -define(SERVER, ?MODULE). @@ -53,7 +53,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'responders', ?RESPONDERS} ,{'bindings', ?BINDINGS} @@ -97,7 +97,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -111,7 +111,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> {'noreply', State}. @@ -125,7 +125,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info('timeout', #state{counter = Counter} = State) -> _ = erlang:send_after(?REFRESH_TIMEOUT * ?MILLISECONDS_IN_SECOND, self(), 'timeout'), case ?REFRESH_ENABLED of @@ -193,7 +193,7 @@ refresh_views(Counter) -> _ = maybe_spawn_refresh_process(RefreshList), NewCounter. --spec handle_account(map(), api_binary()) -> map(). +-spec handle_account(map(), kz_term:api_binary()) -> map(). handle_account(Counter, 'undefined') -> Counter; handle_account(Counter, AccountId) -> RefreshThreshold = ?REFRESH_THRESHOLD, @@ -209,17 +209,17 @@ handle_account(Counter, AccountId) -> value({ok, Value}) -> Value; value(_) -> {kz_time:now_s(), 0}. --spec update_account_view(ne_binary(), gregorian_seconds(), gregorian_seconds()) -> any(). +-spec update_account_view(kz_term:ne_binary(), kz_time:gregorian_seconds(), kz_time:gregorian_seconds()) -> any(). update_account_view(AccountId, From, To) -> Dbs = kazoo_modb:get_range(AccountId, From, To), lager:info("refresh cdr view account:~p db:~p from:~p to:~p", [AccountId, Dbs, From, To]), [ kz_datamgr:get_results(Db, ?VIEW_TO_UPDATE, [{startkey, From}, {endkey, To}]) || Db <- Dbs ]. --spec update_accounts_view([{ne_binary(), gregorian_seconds(), gregorian_seconds()}]) -> any(). +-spec update_accounts_view([{kz_term:ne_binary(), kz_time:gregorian_seconds(), kz_time:gregorian_seconds()}]) -> any(). update_accounts_view(UpdateList) -> [ update_account_view(AccountId, From, To) || {AccountId, From, To} <- UpdateList ]. --spec maybe_spawn_refresh_process([{ne_binary(), gregorian_seconds(), gregorian_seconds()}]) -> any(). +-spec maybe_spawn_refresh_process([{kz_term:ne_binary(), kz_time:gregorian_seconds(), kz_time:gregorian_seconds()}]) -> any(). maybe_spawn_refresh_process([]) -> ok; maybe_spawn_refresh_process(RefreshList) -> _ = kz_util:spawn(fun update_accounts_view/1, [RefreshList]). diff --git a/applications/cdr/src/cdr_sup.erl b/applications/cdr/src/cdr_sup.erl index 6771f153df4..311aa768b9b 100644 --- a/applications/cdr/src/cdr_sup.erl +++ b/applications/cdr/src/cdr_sup.erl @@ -28,7 +28,7 @@ %% API functions %% =================================================================== --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -36,7 +36,7 @@ start_link() -> %% Supervisor callbacks %% =================================================================== --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/cdr/src/cdr_util.erl b/applications/cdr/src/cdr_util.erl index 9e800c0d0f8..9ce54eb7f9a 100644 --- a/applications/cdr/src/cdr_util.erl +++ b/applications/cdr/src/cdr_util.erl @@ -18,12 +18,12 @@ %%%=================================================================== %%% API %%%=================================================================== --spec get_cdr_doc_id(pos_integer(), api_binary()) -> ne_binary(). +-spec get_cdr_doc_id(pos_integer(), kz_term:api_binary()) -> kz_term:ne_binary(). get_cdr_doc_id(Timestamp, CallId) -> {{Year, Month, _}, _} = calendar:gregorian_seconds_to_datetime(Timestamp), get_cdr_doc_id(Year, Month, CallId). --spec get_cdr_doc_id(pos_integer(), pos_integer(), api_binary()) -> ne_binary(). +-spec get_cdr_doc_id(pos_integer(), pos_integer(), kz_term:api_binary()) -> kz_term:ne_binary(). get_cdr_doc_id(Year, Month, CallId) -> <<(kz_term:to_binary(Year))/binary ,(kz_date:pad_month(Month))/binary @@ -31,7 +31,7 @@ get_cdr_doc_id(Year, Month, CallId) -> ,CallId/binary >>. --spec save_cdr(api_binary(), kz_json:object()) -> 'ok' | {'error', max_save_retries}. +-spec save_cdr(kz_term:api_binary(), kz_json:object()) -> 'ok' | {'error', max_save_retries}. save_cdr(?KZ_ANONYMOUS_CDR_DB=Db, Doc) -> case kapps_config:get_is_true(?CONFIG_CAT, <<"store_anonymous">>, 'false') of 'false' -> lager:debug("ignoring storage for anonymous cdr"); @@ -40,7 +40,7 @@ save_cdr(?KZ_ANONYMOUS_CDR_DB=Db, Doc) -> save_cdr(AccountMOD, Doc) -> do_save_cdr(AccountMOD, Doc). --spec do_save_cdr(api_binary(), kz_json:object()) -> 'ok' | {'error', max_save_retries}. +-spec do_save_cdr(kz_term:api_binary(), kz_json:object()) -> 'ok' | {'error', max_save_retries}. do_save_cdr(AccountMODb, Doc) -> case kazoo_modb:save_doc(AccountMODb, Doc, [{'max_retries', 3}]) of {'ok', _}-> 'ok'; diff --git a/applications/cdr/src/csv_util.erl b/applications/cdr/src/csv_util.erl index 299680e9679..f9372a0cc6a 100644 --- a/applications/cdr/src/csv_util.erl +++ b/applications/cdr/src/csv_util.erl @@ -33,7 +33,7 @@ json_objs_to_csv([], _) -> []; json_objs_to_csv(JObjs, _) -> kz_json:encode(JObjs). --spec test_convert(ne_binary()) -> 'ok' | {'error', any()}. +-spec test_convert(kz_term:ne_binary()) -> 'ok' | {'error', any()}. test_convert(AccountDb) -> ViewOptions = ['include_docs'], case kz_datamgr:get_results(AccountDb, <<"cdrs/crossbar_listing">>, ViewOptions) of diff --git a/applications/conference/src/conf_authn_req.erl b/applications/conference/src/conf_authn_req.erl index 0f1172fc293..599a5f2d3f8 100644 --- a/applications/conference/src/conf_authn_req.erl +++ b/applications/conference/src/conf_authn_req.erl @@ -11,7 +11,7 @@ -include("conference.hrl"). --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Props) -> 'true' = kapi_authn:req_v(JObj), _ = kz_util:put_callid(JObj), @@ -24,7 +24,7 @@ handle_req(JObj, _Props) -> _Else -> 'ok' end. --spec send_authn_resp(ne_binary(), kz_json:object()) -> 'ok'. +-spec send_authn_resp(kz_term:ne_binary(), kz_json:object()) -> 'ok'. send_authn_resp(Password, JObj) -> Resp = props:filter_undefined( [{<<"Msg-ID">>, kz_json:get_value(<<"Msg-ID">>, JObj)} diff --git a/applications/conference/src/conf_config_req.erl b/applications/conference/src/conf_config_req.erl index 1fd06549e2a..0877d50204a 100644 --- a/applications/conference/src/conf_config_req.erl +++ b/applications/conference/src/conf_config_req.erl @@ -11,14 +11,14 @@ -include("conference.hrl"). --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Options) -> 'true' = kapi_conference:config_req_v(JObj), Request = kz_json:get_ne_value(<<"Request">>, JObj), lager:debug("~s profile request received", [Request]), handle_request(Request, JObj). --spec handle_request(ne_binary(), kz_json:object()) -> 'ok'. +-spec handle_request(kz_term:ne_binary(), kz_json:object()) -> 'ok'. handle_request(<<"Conference">>, JObj) -> %% NOTE: if this is not an internal page or default %% conf_participant:send_conference_command will ensure @@ -45,14 +45,14 @@ handle_request(<<"Controls">>, JObj) -> ,requested_controls_name(JObj) ). --spec fetch_profile_config(kz_json:object(), ne_binary()) -> 'ok'. +-spec fetch_profile_config(kz_json:object(), kz_term:ne_binary()) -> 'ok'. fetch_profile_config(JObj, ProfileName) -> case binary:split(ProfileName, <<"_">>) of [AccountId, ConferenceId] -> fetch_profile_config(JObj, AccountId, ConferenceId); _Else -> fetch_profile_config(JObj, 'undefined', ProfileName) end. --spec fetch_profile_config(kz_json:object(), api_ne_binary(), ne_binary()) -> 'ok'. +-spec fetch_profile_config(kz_json:object(), kz_term:api_ne_binary(), kz_term:ne_binary()) -> 'ok'. fetch_profile_config(JObj, _, ?PAGE_PROFILE_NAME = ProfileName) -> fetch_profile_config(JObj, 'undefined', ProfileName, page_profile()); fetch_profile_config(JObj, _, ?DEFAULT_PROFILE_NAME = ProfileName) -> @@ -68,7 +68,7 @@ fetch_profile_config(JObj, AccountId, ConferenceId) -> Config = kapps_account_config:get_global(AccountId, ?CONFIG_CAT, [<<"profiles">>, Profile]), fetch_profile_config(JObj, Conference, ConferenceId, Config). --spec fetch_profile_config(kz_json:object(), 'undefined' | kapps_conference:conference(), api_ne_binary(), api_object()) -> 'ok'. +-spec fetch_profile_config(kz_json:object(), 'undefined' | kapps_conference:conference(), kz_term:api_ne_binary(), kz_term:api_object()) -> 'ok'. fetch_profile_config(JObj, Conference, ProfileName, 'undefined') -> lager:debug("no profile defined for ~s, using default", [ProfileName]), fetch_profile_config(JObj, Conference, ProfileName, default_profile()); @@ -95,7 +95,7 @@ fetch_profile_config(JObj, Conference, ProfileName, Profile) -> ], kapi_conference:publish_config_resp(ServerId, props:filter_undefined(Resp)). --spec fetch_controls_config(kz_json:object(), ne_binary(), ne_binary()) -> 'ok'. +-spec fetch_controls_config(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. fetch_controls_config(JObj, ConferenceId, ControlsName) -> case binary:split(ControlsName, <<"_">>) of [?PAGE_PROFILE_NAME = PageProfile, _] -> @@ -112,7 +112,7 @@ fetch_controls_config(JObj, ConferenceId, ControlsName) -> fetch_controls_config(JObj, ConferenceId, 'undefined', ControlsName) end. --spec fetch_controls_config(kz_json:object(), ne_binary(), api_ne_binary(), ne_binary()) -> 'ok'. +-spec fetch_controls_config(kz_json:object(), kz_term:ne_binary(), kz_term:api_ne_binary(), kz_term:ne_binary()) -> 'ok'. fetch_controls_config(JObj, ConferenceId, 'undefined', ControlsName) -> lager:debug("returning ~s controls profile for ~s", [ControlsName, ConferenceId]), ServerId = kz_api:server_id(JObj), @@ -145,7 +145,7 @@ fetch_controls_config(JObj, ConferenceId, AccountId, ControlsType) -> ], kapi_conference:publish_config_resp(ServerId, Resp). --spec get_conference_controls_name(ne_binary(), kapps_conference:conference()) -> ne_binary(). +-spec get_conference_controls_name(kz_term:ne_binary(), kapps_conference:conference()) -> kz_term:ne_binary(). get_conference_controls_name(<<"caller-controls">>, Conference) -> kapps_conference:caller_controls(Conference); get_conference_controls_name(<<"moderator-controls">>, Conference) -> @@ -167,7 +167,7 @@ page_profile() -> ,kz_json:from_list(?PAGE_PROFILE_CONFIG) ). --spec profiles(kapps_conference:conference(), ne_binary(), kz_json:object()) -> kz_json:object(). +-spec profiles(kapps_conference:conference(), kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). profiles(Conference, ProfileName, Profile) -> Routines = [fun add_conference_params/2 ,fun fix_entry_tones/2 @@ -200,7 +200,7 @@ fix_exit_tones(Conference, Profile) -> 'false' -> remove_tone(Key, Profile) end. --spec ensure_tone(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec ensure_tone(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). ensure_tone(Key, Profile) -> case kz_json:get_ne_value(Key, Profile) of 'undefined' -> @@ -212,19 +212,19 @@ ensure_tone(Key, Profile) -> Profile end. --spec remove_tone(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec remove_tone(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). remove_tone(Key, Profile) -> lager:debug("remove tone ~s", [Key]), kz_json:delete_key(Key, Profile). --spec max_participants(kapps_conference:conference()) -> api_binary(). +-spec max_participants(kapps_conference:conference()) -> kz_term:api_binary(). max_participants(Conference) -> case kapps_conference:max_participants(Conference) of N when is_integer(N), N > 1 -> N; _Else -> 'undefined' end. --spec max_members_sound(kapps_conference:conference()) -> api_binary(). +-spec max_members_sound(kapps_conference:conference()) -> kz_term:api_binary(). max_members_sound(Conference) -> case kapps_conference:max_members_media(Conference) of 'undefined' -> @@ -235,7 +235,7 @@ max_members_sound(Conference) -> Media -> Media end. --spec get_conference(ne_binary(), ne_binary()) -> kapps_conference:conference(). +-spec get_conference(kz_term:ne_binary(), kz_term:ne_binary()) -> kapps_conference:conference(). get_conference(?MATCH_ACCOUNT_RAW(AccountId), ConferenceId) -> case kz_datamgr:open_cache_doc(kz_util:format_account_db(AccountId), ConferenceId) of {'ok', JObj} -> kapps_conference:from_conference_doc(JObj); @@ -252,19 +252,19 @@ get_conference(AccountId, ConferenceId) -> ], kapps_conference:update(Routines, kapps_conference:new()). --spec get_control_profile(ne_binary()) -> kz_json:objects(). +-spec get_control_profile(kz_term:ne_binary()) -> kz_json:objects(). get_control_profile(ProfileName) -> kapps_config:get(?CONFIG_CAT, [<<"caller-controls">>, ProfileName], ?DEFAULT_CONTROLS). --spec get_control_profile(ne_binary(), ne_binary()) -> kz_json:objects(). +-spec get_control_profile(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:objects(). get_control_profile(?MATCH_ACCOUNT_RAW(AccountId), ProfileName) -> kapps_account_config:get_global(AccountId, ?CONFIG_CAT, [<<"caller-controls">>, ProfileName], ?DEFAULT_CONTROLS); get_control_profile(_AccountId, ProfileName) -> lager:info("account id '~s' not valid, getting system config instead"), get_control_profile(ProfileName). --spec advertise(ne_binary()) -> api_object(). --spec advertise(ne_binary(), api_object()) -> api_object(). +-spec advertise(kz_term:ne_binary()) -> kz_term:api_object(). +-spec advertise(kz_term:ne_binary(), kz_term:api_object()) -> kz_term:api_object(). advertise(?DEFAULT_PROFILE_NAME = ProfileName) -> advertise(ProfileName, ?ADVERTISE(ProfileName, ?DEFAULT_ADVERTISE_CONFIG)); advertise(?PAGE_PROFILE_NAME = ProfileName) -> @@ -275,8 +275,8 @@ advertise(ProfileName) -> advertise(_ProfileName, 'undefined') -> 'undefined'; advertise(ProfileName, Advertise) -> kz_json:from_list([{ProfileName, Advertise}]). --spec chat_permissions(ne_binary()) -> api_object(). --spec chat_permissions(ne_binary(), api_object()) -> api_object(). +-spec chat_permissions(kz_term:ne_binary()) -> kz_term:api_object(). +-spec chat_permissions(kz_term:ne_binary(), kz_term:api_object()) -> kz_term:api_object(). chat_permissions(?DEFAULT_PROFILE_NAME = ProfileName) -> chat_permissions(ProfileName, ?CHAT_PERMISSIONS(ProfileName, ?DEFAULT_CHAT_CONFIG)); chat_permissions(?PAGE_PROFILE_NAME= ProfileName) -> @@ -287,10 +287,10 @@ chat_permissions(ProfileName) -> chat_permissions(_ProfileName, 'undefined') -> 'undefined'; chat_permissions(ProfileName, Chat) -> kz_json:from_list([{ProfileName, Chat}]). --spec requested_profile_name(kz_json:object()) -> ne_binary(). +-spec requested_profile_name(kz_json:object()) -> kz_term:ne_binary(). requested_profile_name(JObj) -> kz_json:get_ne_value(<<"Profile">>, JObj, ?DEFAULT_PROFILE_NAME). --spec requested_controls_name(kz_json:object()) -> ne_binary(). +-spec requested_controls_name(kz_json:object()) -> kz_term:ne_binary(). requested_controls_name(JObj) -> kz_json:get_ne_value(<<"Controls">>, JObj, ?DEFAULT_PROFILE_NAME). diff --git a/applications/conference/src/conf_discovery_req.erl b/applications/conference/src/conf_discovery_req.erl index 841a3d4b61b..a81d3d59ee3 100644 --- a/applications/conference/src/conf_discovery_req.erl +++ b/applications/conference/src/conf_discovery_req.erl @@ -11,7 +11,7 @@ -include("conference.hrl"). --spec handle_req(kz_json:object(), kz_proplist()) -> any(). +-spec handle_req(kz_json:object(), kz_term:proplist()) -> any(). handle_req(JObj, _Options) -> 'true' = kapi_conference:discovery_req_v(JObj), Call = kapps_call:from_json(kz_json:get_value(<<"Call">>, JObj)), @@ -119,7 +119,7 @@ maybe_collect_member_pin(Conference, Call, Srv) -> collect_conference_pin('false', Conference, Call, Srv) end. --spec collect_conference_pin(api_boolean(), kapps_conference:conference(), kapps_call:call(), pid()) -> 'ok'. +-spec collect_conference_pin(kz_term:api_boolean(), kapps_conference:conference(), kapps_call:call(), pid()) -> 'ok'. collect_conference_pin(Type, Conference, Call, Srv) -> case validate_conference_pin(Type, Conference, Call, 1) of {'ok', C} -> @@ -261,13 +261,13 @@ add_participant_to_conference(JObj, Conference, Call, Srv) -> -spec discovery_failed(kapps_call:call(), pid() | 'undefined') -> 'ok'. discovery_failed(Call, _) -> kapps_call_command:hangup(Call). --spec validate_conference_id(api_ne_binary(), kapps_call:call()) -> +-spec validate_conference_id(kz_term:api_ne_binary(), kapps_call:call()) -> {'ok', kapps_conference:conference()} | {'error', any()}. validate_conference_id(ConferenceId, Call) -> validate_conference_id(ConferenceId, Call, 1). --spec validate_conference_id(api_ne_binary(), kapps_call:call(), pos_integer()) -> +-spec validate_conference_id(kz_term:api_ne_binary(), kapps_call:call(), pos_integer()) -> {'ok', kapps_conference:conference()} | {'error', any()}. validate_conference_id('undefined', Call, Loop) when Loop > 3 -> @@ -314,7 +314,7 @@ validate_collected_conference_id(Call, Loop, Digits) -> validate_conference_id('undefined', Call, Loop + 1) end. --spec validate_conference_pin(api_boolean(), kapps_conference:conference(), kapps_call:call(), pos_integer()) -> +-spec validate_conference_pin(kz_term:api_boolean(), kapps_conference:conference(), kapps_call:call(), pos_integer()) -> {'ok', kapps_conference:conference()} | {'error', any()}. validate_conference_pin(_, _, Call, Loop) when Loop > 3-> @@ -439,7 +439,7 @@ get_pin_timeout(Conference) -> JObj = kapps_conference:conference_doc(Conference), kz_json:get_value(<<"pin_timeout">>, JObj, get_account_pin_timeout(AccountId)). --spec get_account_pin_timeout(ne_binary()) -> pos_integer(). +-spec get_account_pin_timeout(kz_term:ne_binary()) -> pos_integer(). get_account_pin_timeout(AccountId) -> kapps_account_config:get_global(AccountId, ?CONFIG_CAT, <<"pin_timeout">>, ?COLLECT_PIN_DEFAULT_TIMEOUT). diff --git a/applications/conference/src/conf_participant.erl b/applications/conference/src/conf_participant.erl index 59ecda94ded..78e214d70a6 100644 --- a/applications/conference/src/conf_participant.erl +++ b/applications/conference/src/conf_participant.erl @@ -66,7 +66,7 @@ ,muted = 'false' :: boolean() ,deaf = 'false' :: boolean() ,waiting_for_mod = 'false' :: boolean() - ,call_event_consumers = [] :: pids() + ,call_event_consumers = [] :: kz_term:pids() ,in_conference = 'false' :: boolean() ,join_attempts = 0 :: non_neg_integer() ,conference :: kapps_conference:conference() | 'undefined' @@ -85,7 +85,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(kapps_call:call()) -> startlink_ret(). +-spec start_link(kapps_call:call()) -> kz_types:startlink_ret(). start_link(Call) -> CallId = kapps_call:call_id(Call), Bindings = [{'call', [{'callid', CallId}]} @@ -146,13 +146,13 @@ toggle_deaf(Srv) -> gen_listener:cast(Srv, 'toggle_deaf'). -spec hangup(pid()) -> 'ok'. hangup(Srv) -> gen_listener:cast(Srv, 'hangup'). --spec dtmf(pid(), ne_binary()) -> 'ok'. +-spec dtmf(pid(), kz_term:ne_binary()) -> 'ok'. dtmf(Srv, Digit) -> gen_listener:cast(Srv,{'dtmf', Digit}). -spec consume_call_events(pid()) -> 'ok'. consume_call_events(Srv) -> gen_listener:cast(Srv, {'add_consumer', self()}). --spec relay_amqp(kz_json:object(), kz_proplist()) -> 'ok'. +-spec relay_amqp(kz_json:object(), kz_term:proplist()) -> 'ok'. relay_amqp(JObj, Props) -> _ = [kapps_call_command:relay_event(Pid, JObj) || Pid <- props:get_value('call_event_consumers', Props, []), @@ -166,7 +166,7 @@ relay_amqp(JObj, Props) -> dtmf(Srv, Digit) end. --spec handle_conference_error(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_conference_error(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_conference_error(JObj, Props) -> 'true' = kapi_conference:conference_error_v(JObj), lager:debug("conference error: ~p", [JObj]), @@ -220,7 +220,7 @@ start_sanity_check_timer(Timeout) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), participant()) -> handle_call_ret_state(participant()). +-spec handle_call(any(), kz_term:pid_ref(), participant()) -> kz_types:handle_call_ret_state(participant()). handle_call({'get_conference'}, _, #participant{conference='undefined'}=P) -> {'reply', {'error', 'not_provided'}, P}; handle_call({'get_conference'}, _, #participant{conference=Conf}=P) -> @@ -244,7 +244,7 @@ handle_call(_Request, _, P) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), participant()) -> handle_cast_ret_state(participant()). +-spec handle_cast(any(), participant()) -> kz_types:handle_cast_ret_state(participant()). handle_cast('hungup', Participant) -> {'stop', {'shutdown', 'hungup'}, Participant}; handle_cast('pivoted', Participant) -> @@ -331,7 +331,7 @@ handle_cast(_Cast, Participant) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), participant()) -> handle_info_ret_state(participant()). +-spec handle_info(any(), participant()) -> kz_types:handle_info_ret_state(participant()). handle_info({'EXIT', Consumer, _R}, #participant{call_event_consumers=Consumers}=P) -> lager:debug("call event consumer ~p died: ~p", [Consumer, _R]), Cs = [C || C <- Consumers, C =/= Consumer], @@ -384,7 +384,7 @@ handle_event(JObj, #participant{call_event_consumers=Consumers end, {'reply', [{'call_event_consumers', Consumers}]}. --spec handle_channel_replaced(kz_json:object(), server_ref()) -> 'ok'. +-spec handle_channel_replaced(kz_json:object(), kz_types:server_ref()) -> 'ok'. handle_channel_replaced(JObj, Srv) -> NewCallId = kz_call_event:replaced_by(JObj), lager:info("channel has been replaced with ~s", [NewCallId]), @@ -453,7 +453,7 @@ log_conference_join('true'=_Moderator, ParticipantId, Conference) -> log_conference_join('false'=_Moderator, ParticipantId, Conference) -> lager:debug("caller has joined the local conference ~s as member ~p", [kapps_conference:name(Conference), ParticipantId]). --spec sync_participant(ne_binary(), kz_json:objects(), kapps_call:call(), participant()) -> participant(). +-spec sync_participant(kz_term:ne_binary(), kz_json:objects(), kapps_call:call(), participant()) -> participant(). sync_participant(<<"add-member">>, JObj, Call, Participant) -> sync_participant(JObj, Call, Participant); sync_participant(<<"conference-destroyed">>, _JObj, _Call, Participant) -> Participant; @@ -490,7 +490,7 @@ sync_participant(JObj, _Call, #participant{in_conference='true'}=Participant) -> ,deaf=Deaf }. --spec notify_requestor(ne_binary(), non_neg_integer(), kz_json:object(), ne_binary()) -> 'ok'. +-spec notify_requestor(kz_term:ne_binary(), non_neg_integer(), kz_json:object(), kz_term:ne_binary()) -> 'ok'. notify_requestor(MyQ, MyId, DiscoveryEvent, ConferenceId) -> case kz_api:server_id(DiscoveryEvent) of 'undefined' -> 'ok'; @@ -504,7 +504,7 @@ notify_requestor(MyQ, MyId, DiscoveryEvent, ConferenceId) -> kz_amqp_worker:cast(Resp, Publisher) end. --spec bridge_to_conference(ne_binary(), kapps_conference:conference(), kapps_call:call(), conf_pronounced_name:name_pronounced()) -> 'ok'. +-spec bridge_to_conference(kz_term:ne_binary(), kapps_conference:conference(), kapps_call:call(), conf_pronounced_name:name_pronounced()) -> 'ok'. bridge_to_conference(Route, Conference, Call, Name) -> lager:debug("bridging to conference running at '~s'", [Route]), Endpoint = kz_json:from_list([{<<"Invite-Format">>, <<"route">>} @@ -536,14 +536,14 @@ bridge_to_conference(Route, Conference, Call, Name) -> unbridge_from_conference(Call) -> kapps_call_command:unbridge(Call, 'undefined'). --spec get_account_realm(kapps_call:call()) -> ne_binary(). +-spec get_account_realm(kapps_call:call()) -> kz_term:ne_binary(). get_account_realm(Call) -> case kz_account:fetch_realm(kapps_call:account_id(Call)) of 'undefined' -> <<"unknown">>; Realm -> Realm end. --spec name_pronounced_headers(conf_pronounced_name:name_pronounced()) -> kz_proplist(). +-spec name_pronounced_headers(conf_pronounced_name:name_pronounced()) -> kz_term:proplist(). name_pronounced_headers('undefined') -> []; name_pronounced_headers({_, AccountId, MediaId}) -> [{<<"X-Conf-Values-Pronounced-Name-Account-ID">>, AccountId} @@ -578,7 +578,7 @@ is_deaf(Conference) -> 'false' -> kapps_conference:member_join_deaf(Conference) end. --spec handle_conference_event(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_conference_event(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_conference_event(JObj, Props) -> Srv = props:get_value('server', Props), gen_listener:cast(Srv, {'sync_participant', JObj}). @@ -607,14 +607,14 @@ set_enter_exit_sounds({_, AccountId, MediaId}, #participant{conference=Conferenc kapps_call_command:media_macro(Sounds, Call). %% @private --spec play_exit_tone(boolean(), kapps_conference:conference()) -> api_binary(). +-spec play_exit_tone(boolean(), kapps_conference:conference()) -> kz_term:api_binary(). play_exit_tone('false', Conference) -> play_exit_tone_media(?EXIT_TONE(kapps_conference:account_id(Conference)), Conference); play_exit_tone('true', Conference) -> play_exit_tone_media(?MOD_EXIT_TONE(kapps_conference:account_id(Conference)), Conference). %% @private --spec play_exit_tone_media(ne_binary(), kapps_conference:conference()) -> api_binary(). +-spec play_exit_tone_media(kz_term:ne_binary(), kapps_conference:conference()) -> kz_term:api_binary(). play_exit_tone_media(Tone, Conference) -> case kapps_conference:play_exit_tone(Conference) of 'false' -> 'undefined'; @@ -623,13 +623,13 @@ play_exit_tone_media(Tone, Conference) -> end. %% @private --spec play_entry_tone(boolean(), kapps_conference:conference()) -> api_binary(). +-spec play_entry_tone(boolean(), kapps_conference:conference()) -> kz_term:api_binary(). play_entry_tone('false', Conference) -> play_entry_tone_media(?ENTRY_TONE(kapps_conference:account_id(Conference)), Conference); play_entry_tone('true', Conference) -> play_entry_tone_media(?MOD_ENTRY_TONE(kapps_conference:account_id(Conference)), Conference). --spec play_entry_tone_media(ne_binary(), kapps_conference:conference()) -> api_binary(). +-spec play_entry_tone_media(kz_term:ne_binary(), kapps_conference:conference()) -> kz_term:api_binary(). play_entry_tone_media(Tone, Conference) -> case kapps_conference:play_entry_tone(Conference) of 'false' -> 'false'; diff --git a/applications/conference/src/conf_participant_req.erl b/applications/conference/src/conf_participant_req.erl index a3a7d8fa76f..479a26a4241 100644 --- a/applications/conference/src/conf_participant_req.erl +++ b/applications/conference/src/conf_participant_req.erl @@ -11,7 +11,7 @@ -include("conference.hrl"). --spec handle_req(kz_json:object(), kz_proplist()) -> any(). +-spec handle_req(kz_json:object(), kz_term:proplist()) -> any(). handle_req(JObj, _Options) -> 'true' = kapi_conference:add_participant_v(JObj), Call = kapps_call:from_json(JObj), diff --git a/applications/conference/src/conf_participant_sup.erl b/applications/conference/src/conf_participant_sup.erl index 8e8db4142e9..060db3cad94 100644 --- a/applications/conference/src/conf_participant_sup.erl +++ b/applications/conference/src/conf_participant_sup.erl @@ -30,11 +30,11 @@ %%-------------------------------------------------------------------- %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec start_participant(kapps_call:call()) -> sup_startchild_ret(). +-spec start_participant(kapps_call:call()) -> kz_types:sup_startchild_ret(). start_participant(Call) -> supervisor:start_child(?SERVER, [Call]). @@ -51,7 +51,7 @@ start_participant(Call) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 0, diff --git a/applications/conference/src/conf_pronounced_name.erl b/applications/conference/src/conf_pronounced_name.erl index f074a5a765f..dca9215f4d5 100644 --- a/applications/conference/src/conf_pronounced_name.erl +++ b/applications/conference/src/conf_pronounced_name.erl @@ -13,8 +13,8 @@ -include("conference.hrl"). --type name_pronounced_media() :: {atom(), ne_binary(), ne_binary()}. --type name_pronounced_ids() :: {atom(), ne_binary(), ne_binary()} | +-type name_pronounced_media() :: {atom(), kz_term:ne_binary(), kz_term:ne_binary()}. +-type name_pronounced_ids() :: {atom(), kz_term:ne_binary(), kz_term:ne_binary()} | name_pronounced_media(). -type name_pronounced() :: name_pronounced_ids() | 'undefined'. @@ -22,7 +22,7 @@ -define(PRONOUNCED_NAME_KEY, [<<"name_pronounced">>, <<"media_id">>]). --spec get_user_id(kapps_call:call()) -> api_binary(). +-spec get_user_id(kapps_call:call()) -> kz_term:api_binary(). get_user_id(Call) -> case kapps_call:authorizing_type(Call) of <<"user">> -> kapps_call:authorizing_id(Call); @@ -31,7 +31,7 @@ get_user_id(Call) -> _Type -> 'undefined' end. --spec get_user_id_from_device(kapps_call:call()) -> api_binary(). +-spec get_user_id_from_device(kapps_call:call()) -> kz_term:api_binary(). get_user_id_from_device(Call) -> case kz_datamgr:open_cache_doc(kapps_call:account_db(Call) ,kapps_call:authorizing_id(Call) @@ -48,7 +48,7 @@ lookup_name(Call) -> UserId -> lookup_user_name(Call, UserId) end. --spec lookup_user_name(kapps_call:call(), ne_binary()) -> name_pronounced_media() | 'undefined'. +-spec lookup_user_name(kapps_call:call(), kz_term:ne_binary()) -> name_pronounced_media() | 'undefined'. lookup_user_name(Call, UserId) -> case kz_datamgr:open_cache_doc(kapps_call:account_db(Call), UserId) of {'ok', UserDoc} -> @@ -89,7 +89,7 @@ user_discards_or_not_error({'ok', Digit}) -> user_discards_or_not_error(_) -> 'false'. --spec record_name(ne_binary(), kapps_call:call()) -> kapps_call_command:collect_digits_return(). +-spec record_name(kz_term:ne_binary(), kapps_call:call()) -> kapps_call_command:collect_digits_return(). record_name(RecordName, Call) -> lager:debug("recording name"), Tone = kz_json:from_list([{<<"Frequencies">>, [<<"440">>]} @@ -108,7 +108,7 @@ record_name(RecordName, Call) -> {'ok', <<"1">>} end. --spec prepare_media_doc(ne_binary(), kapps_call:call()) -> api_binary(). +-spec prepare_media_doc(kz_term:ne_binary(), kapps_call:call()) -> kz_term:api_binary(). prepare_media_doc(RecordName, Call) -> UserId = get_user_id(Call), AccountDb = kapps_call:account_db(Call), @@ -127,7 +127,7 @@ prepare_media_doc(RecordName, Call) -> _ -> 'undefined' end. --spec save_recording(ne_binary(), ne_binary(), kapps_call:call()) -> name_pronounced_ids(). +-spec save_recording(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> name_pronounced_ids(). save_recording(RecordName, MediaDocId, Call) -> UserId = get_user_id(Call), AccountDb = kapps_call:account_db(Call), @@ -144,14 +144,14 @@ save_recording(RecordName, MediaDocId, Call) -> {'temp_doc_id', AccountId, MediaDocId} end. --spec save_pronounced_name(ne_binary(), kapps_call:call()) -> name_pronounced(). +-spec save_pronounced_name(kz_term:ne_binary(), kapps_call:call()) -> name_pronounced(). save_pronounced_name(RecordName, Call) -> case prepare_media_doc(RecordName, Call) of 'undefined' -> 'undefined'; MediaDocId -> save_recording(RecordName, MediaDocId, Call) end. --spec get_new_attachment_url(ne_binary(), ne_binary(), kapps_call:call()) -> ne_binary(). +-spec get_new_attachment_url(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> kz_term:ne_binary(). get_new_attachment_url(AttachmentName, MediaId, Call) -> AccountDb = kapps_call:account_db(Call), _ = case kz_datamgr:open_doc(AccountDb, MediaId) of @@ -171,7 +171,7 @@ maybe_remove_attachments(Call, JObj) -> ) end. --spec review(ne_binary(), kapps_call:call()) -> kapps_call_command:collect_digits_return(). +-spec review(kz_term:ne_binary(), kapps_call:call()) -> kapps_call_command:collect_digits_return(). review(RecordName, Call) -> lager:debug("review record"), NoopId = kapps_call_command:audio_macro([{'prompt', <<"conf-your_announcment">>} diff --git a/applications/conference/src/conf_route_req.erl b/applications/conference/src/conf_route_req.erl index 8cf13d533a4..bccfc410086 100644 --- a/applications/conference/src/conf_route_req.erl +++ b/applications/conference/src/conf_route_req.erl @@ -15,7 +15,7 @@ -define(ROUTE_WIN_TIMEOUT_KEY, <<"route_win_timeout">>). -define(ROUTE_WIN_TIMEOUT, kapps_config:get_integer(?CONFIG_CAT, ?ROUTE_WIN_TIMEOUT_KEY, ?DEFAULT_ROUTE_WIN_TIMEOUT)). --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Props) -> 'true' = kapi_route:req_v(JObj), kz_util:put_callid(JObj), @@ -68,7 +68,7 @@ start_participant(Call, Conference) -> _Else -> kapps_call_command:hangup(Call) end. --spec join_local(kapps_call:call(), kapps_conference:conference(), server_ref()) -> 'ok'. +-spec join_local(kapps_call:call(), kapps_conference:conference(), kz_types:server_ref()) -> 'ok'. join_local(Call, Conference, Participant) -> IsModerator = kz_term:is_true(kapps_call:custom_sip_header(<<"X-Conf-Flags-Moderator">>, Call)), Routines = [{fun kapps_conference:set_moderator/2, IsModerator} @@ -81,8 +81,8 @@ join_local(Call, Conference, Participant) -> kapps_call_command:answer(Call), conf_participant:join_local(Participant). --spec maybe_set_name_pronounced(kapps_call:call(), server_ref()) -> 'ok'. --spec maybe_set_name_pronounced(kz_json:api_json_term(), kz_json:api_json_term(), server_ref()) -> 'ok'. +-spec maybe_set_name_pronounced(kapps_call:call(), kz_types:server_ref()) -> 'ok'. +-spec maybe_set_name_pronounced(kz_json:api_json_term(), kz_json:api_json_term(), kz_types:server_ref()) -> 'ok'. maybe_set_name_pronounced(Call, Participant) -> AccountId = kapps_call:custom_sip_header(<<"X-Conf-Values-Pronounced-Name-Account-ID">>, Call), MediaId = kapps_call:custom_sip_header(<<"X-Conf-Values-Pronounced-Name-Media-ID">>, Call), @@ -112,7 +112,7 @@ find_conference(Call, AccountDb) -> Error end. --spec find_account_db(kapps_call:call()) -> api_binary(). +-spec find_account_db(kapps_call:call()) -> kz_term:api_binary(). find_account_db(Call) -> Realm = kapps_call:to_realm(Call), case kapps_util:get_account_by_realm(Realm) of diff --git a/applications/conference/src/conference_app.erl b/applications/conference/src/conference_app.erl index c8ccbc48157..741f7c18b49 100644 --- a/applications/conference/src/conference_app.erl +++ b/applications/conference/src/conference_app.erl @@ -21,7 +21,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_StartType, _StartArgs) -> _ = declare_exchanges(), conference_sup:start_link(). diff --git a/applications/conference/src/conference_listener.erl b/applications/conference/src/conference_listener.erl index 62f7ac95a9f..0157ec6bc05 100644 --- a/applications/conference/src/conference_listener.erl +++ b/applications/conference/src/conference_listener.erl @@ -41,7 +41,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'bindings', ?BINDINGS} ,{'responders', ?RESPONDERS} @@ -83,7 +83,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -97,7 +97,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _QueueNAme}}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'is_consuming', _IsConsuming}}, State) -> @@ -115,7 +115,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -127,7 +127,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/conference/src/conference_maintenance.erl b/applications/conference/src/conference_maintenance.erl index 15f8936b024..26167223229 100644 --- a/applications/conference/src/conference_maintenance.erl +++ b/applications/conference/src/conference_maintenance.erl @@ -33,7 +33,7 @@ blocking_refresh() -> %% @end %%-------------------------------------------------------------------- -spec refresh() -> 'started'. --spec refresh(text()) -> 'ok'. +-spec refresh(kz_term:text()) -> 'ok'. refresh() -> _ = kz_util:spawn(fun blocking_refresh/0), diff --git a/applications/conference/src/conference_shared_listener.erl b/applications/conference/src/conference_shared_listener.erl index c7be375f68d..b94c84096a7 100644 --- a/applications/conference/src/conference_shared_listener.erl +++ b/applications/conference/src/conference_shared_listener.erl @@ -50,7 +50,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'bindings', ?BINDINGS} ,{'responders', ?RESPONDERS} @@ -92,7 +92,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -106,7 +106,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _QueueNAme}}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'is_consuming', _IsConsuming}}, State) -> @@ -124,7 +124,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -136,7 +136,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/conference/src/conference_sup.erl b/applications/conference/src/conference_sup.erl index 634ff327c9e..41257b861f5 100644 --- a/applications/conference/src/conference_sup.erl +++ b/applications/conference/src/conference_sup.erl @@ -34,7 +34,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -51,7 +51,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/conference/src/kapi_conf_participant.erl b/applications/conference/src/kapi_conf_participant.erl index 4621c9b3824..e04810366d9 100644 --- a/applications/conference/src/kapi_conf_participant.erl +++ b/applications/conference/src/kapi_conf_participant.erl @@ -24,7 +24,7 @@ ]). -define(DIALPLAN_REQ_TYPES, []). --spec dialplan_req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec dialplan_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. dialplan_req(Prop) when is_list(Prop) -> case dialplan_req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?DIALPLAN_REQ_HEADERS, ?OPTIONAL_DIALPLAN_REQ_HEADERS); @@ -58,8 +58,8 @@ declare_exchanges() -> %% Publish to the participant %% @end %%-------------------------------------------------------------------- --spec publish_dialplan_req(ne_binary(), api_terms()) -> 'ok'. --spec publish_dialplan_req(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_dialplan_req(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_dialplan_req(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_dialplan_req(Queue, JObj) -> publish_dialplan_req(Queue, JObj, ?DEFAULT_CONTENT_TYPE). publish_dialplan_req(Queue, Req, ContentType) -> diff --git a/applications/crossbar/priv/port-request-scheduled-schema.escript b/applications/crossbar/priv/port-request-scheduled-schema.escript index 2a701e7f619..53c4c395069 100755 --- a/applications/crossbar/priv/port-request-scheduled-schema.escript +++ b/applications/crossbar/priv/port-request-scheduled-schema.escript @@ -24,7 +24,7 @@ main(_) -> unique_values(Dict) -> dict:fold(fun unique_values_fold/3, sets:new(), Dict). --type enum() :: sets:set(ne_binary()). +-type enum() :: sets:set(kz_term:ne_binary()). -spec unique_values_fold(nonempty_string(), [nonempty_string()], enum()) -> enum(). unique_values_fold(_Key, Value, Acc) -> Values = [kz_term:to_binary(V) || V <- Value], diff --git a/applications/crossbar/src/api_resource.erl b/applications/crossbar/src/api_resource.erl index 851d55b3642..215da7e339e 100644 --- a/applications/crossbar/src/api_resource.erl +++ b/applications/crossbar/src/api_resource.erl @@ -46,12 +46,12 @@ %%%=================================================================== %%% Startup and shutdown of request %%%=================================================================== --spec init(cowboy_req:req(), kz_proplist()) -> +-spec init(cowboy_req:req(), kz_term:proplist()) -> {'cowboy_rest', cowboy_req:req(), cb_context:context()}. init(Req, Opts) -> rest_init(Req, Opts). --spec rest_init(cowboy_req:req(), kz_proplist()) -> +-spec rest_init(cowboy_req:req(), kz_term:proplist()) -> {'cowboy_rest', cowboy_req:req(), cb_context:context()}. rest_init(Req, Opts) -> maybe_trace(Req), @@ -101,7 +101,7 @@ rest_init(Req, Opts) -> } end. --spec get_request_id(cowboy_req:req()) -> ne_binary(). +-spec get_request_id(cowboy_req:req()) -> kz_term:ne_binary(). get_request_id(Req) -> ReqId = case cowboy_req:header(<<"x-request-id">>, Req) of 'undefined' -> kz_datamgr:get_uuid(); @@ -110,14 +110,14 @@ get_request_id(Req) -> kz_util:put_callid(ReqId), ReqId. --spec get_profile_id(cowbow_req:req()) -> api_ne_binary(). +-spec get_profile_id(cowbow_req:req()) -> kz_term:api_ne_binary(). get_profile_id(Req) -> case cowboy_req:header(<<"x-profile-id">>, Req) of 'undefined' -> 'undefined'; ProfId -> kz_term:to_binary(ProfId) end. --spec get_client_ip(cowboy_req:req()) -> ne_binary(). +-spec get_client_ip(cowboy_req:req()) -> kz_term:ne_binary(). get_client_ip(Req) -> {Peer, _PeerPort} = cowboy_req:peer(Req), case cowboy_req:header(<<"x-forwarded-for">>, Req) of @@ -172,9 +172,9 @@ maybe_decode_start_key(Context) -> metrics() -> {kz_util:bin_usage(), kz_util:mem_usage()}. --spec find_version(ne_binary()) -> ne_binary(). --spec find_version(ne_binary(), cowboy_req:req()) -> - ne_binary(). +-spec find_version(kz_term:ne_binary()) -> kz_term:ne_binary(). +-spec find_version(kz_term:ne_binary(), cowboy_req:req()) -> + kz_term:ne_binary(). find_version(Path, Req) -> case cowboy_req:binding('version', Req) of 'undefined' -> find_version(Path); @@ -189,7 +189,7 @@ find_version(Path) -> [Ver | _] -> to_version(Ver) end. --spec to_version(ne_binary()) -> ne_binary(). +-spec to_version(kz_term:ne_binary()) -> kz_term:ne_binary(). to_version(<<"v", Int/binary>>=Version) -> try kz_term:to_integer(Int) of _ -> Version @@ -198,12 +198,12 @@ to_version(<<"v", Int/binary>>=Version) -> end; to_version(_) -> ?VERSION_1. --spec maybe_allow_proxy_req(ne_binary(), ne_binary()) -> ne_binary(). +-spec maybe_allow_proxy_req(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). maybe_allow_proxy_req(Peer, ForwardIP) -> ShouldCheck = kapps_config:get_is_true(?APP_NAME, <<"check_reverse_proxies">>, 'true'), maybe_allow_proxy_req(Peer, ForwardIP, ShouldCheck). --spec maybe_allow_proxy_req(ne_binary(), ne_binary(), boolean()) -> ne_binary(). +-spec maybe_allow_proxy_req(kz_term:ne_binary(), kz_term:ne_binary(), boolean()) -> kz_term:ne_binary(). maybe_allow_proxy_req(_Peer, ForwardIP, 'false') -> ForwardIP; maybe_allow_proxy_req(Peer, ForwardIP, 'true') -> @@ -218,8 +218,8 @@ maybe_allow_proxy_req(Peer, ForwardIP, 'true') -> Peer end. --spec is_proxied(ne_binary()) -> boolean(). --spec is_proxied(ne_binary(), ne_binaries()) -> boolean(). +-spec is_proxied(kz_term:ne_binary()) -> boolean(). +-spec is_proxied(kz_term:ne_binary(), kz_term:ne_binaries()) -> boolean(). is_proxied(Peer) -> Proxies = kapps_config:get_ne_binaries(?APP_NAME, <<"reverse_proxies">>, [<<"127.0.0.1">>]), is_proxied(Peer, Proxies). @@ -229,7 +229,7 @@ is_proxied(Peer, [Proxy|Rest]) -> kz_network_utils:verify_cidr(Peer, kz_network_utils:to_cidr(Proxy)) orelse is_proxied(Peer, Rest). --spec find_path(cowboy_req:req(), kz_proplist()) -> ne_binary(). +-spec find_path(cowboy_req:req(), kz_term:proplist()) -> kz_term:ne_binary(). find_path(Req, Opts) -> case props:get_value('magic_path', Opts) of 'undefined' -> cowboy_req:path(Req); @@ -262,8 +262,8 @@ rest_terminate(Req, Context, Verb) -> _ = api_util:finish_request(Req, Context), 'ok'. --spec pretty_metric(integer()) -> ne_binary(). --spec pretty_metric(integer(), boolean()) -> ne_binary(). +-spec pretty_metric(integer()) -> kz_term:ne_binary(). +-spec pretty_metric(integer(), boolean()) -> kz_term:ne_binary(). pretty_metric(N) -> pretty_metric(N, kapps_config:get_is_true(?CONFIG_CAT, <<"pretty_metrics">>, 'true')). @@ -470,8 +470,8 @@ options(Req0, Context) -> {'ok', Req0, Context} end. --type content_type_callbacks() :: [{{ne_binary(), ne_binary(), kz_proplist()}, atom()} | - {ne_binary(), atom()} +-type content_type_callbacks() :: [{{kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()}, atom()} | + {kz_term:ne_binary(), atom()} ]. -spec content_types_provided(cowboy_req:req(), cb_context:context()) -> {content_type_callbacks(), cowboy_req:req(), cb_context:context()}. @@ -604,7 +604,7 @@ content_type_accepted_fold({_,_,_}=EncType, Acc, Fun, _CT) -> [{EncType, Fun} | Acc]. -spec languages_provided(cowboy_req:req(), cb_context:context()) -> - {ne_binaries(), cowboy_req:req(), cb_context:context()}. + {kz_term:ne_binaries(), cowboy_req:req(), cb_context:context()}. languages_provided(Req0, Context0) -> lager:debug("run: languages_provided"), @@ -757,7 +757,7 @@ from_form(Req0, Context0) -> -spec create_from_response(cowboy_req:req(), cb_context:context()) -> {boolean(), cowboy_req:req(), cb_context:context()}. --spec create_from_response(cowboy_req:req(), cb_context:context(), api_binary()) -> +-spec create_from_response(cowboy_req:req(), cb_context:context(), kz_term:api_binary()) -> {boolean(), cowboy_req:req(), cb_context:context()}. create_from_response(Req, Context) -> create_from_response(Req, Context, cb_context:req_header(Context, <<"accept">>)). @@ -779,7 +779,7 @@ create_from_response(Req, Context, Accept) -> end. -spec to_json(cowboy_req:req(), cb_context:context()) -> - {iolist() | ne_binary() | 'stop', cowboy_req:req(), cb_context:context()}. + {iolist() | kz_term:ne_binary() | 'stop', cowboy_req:req(), cb_context:context()}. to_json(Req, Context) -> to_json(Req, Context, accept_override(Context)). @@ -808,7 +808,7 @@ to_json(Req, Context, Accept) -> -spec to_binary(cowboy_req:req(), cb_context:context()) -> {binary() | 'stop', cowboy_req:req(), cb_context:context()}. --spec to_binary(cowboy_req:req(), cb_context:context(), api_ne_binary()) -> +-spec to_binary(cowboy_req:req(), cb_context:context(), kz_term:api_ne_binary()) -> {binary() | 'stop', cowboy_req:req(), cb_context:context()}. to_binary(Req, Context) -> to_binary(Req, Context, accept_override(Context)). @@ -848,9 +848,9 @@ to_binary(Req, Context, Accept) -> (?MODULE):Fun(Req, Context) end. --type range_response() :: {ne_binary(), pos_integer(), pos_integer(), pos_integer(), pos_integer()}. +-type range_response() :: {kz_term:ne_binary(), pos_integer(), pos_integer(), pos_integer(), pos_integer()}. --spec get_range(ne_binary(), binary()) -> range_response(). +-spec get_range(kz_term:ne_binary(), binary()) -> range_response(). get_range(Data, <<>>) -> FileLength = size(Data), {Data, 0, FileLength-1, FileLength, FileLength}; @@ -877,8 +877,8 @@ send_file(Req, Context) -> lager:debug("run: send_file"), api_util:create_pull_response(Req, Context, fun api_util:create_resp_file/2). --spec to_fun(cb_context:context(), ne_binary(), atom()) -> atom(). --spec to_fun(cb_context:context(), ne_binary(), ne_binary(), atom()) -> atom(). +-spec to_fun(cb_context:context(), kz_term:ne_binary(), atom()) -> atom(). +-spec to_fun(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary(), atom()) -> atom(). to_fun(Context, Accept, Default) -> case binary:split(Accept, <<"/">>) of [Major, Minor] -> to_fun(Context, Major, Minor, Default); @@ -894,7 +894,7 @@ to_fun(Context, Major, Minor, Default) -> [F|_] -> F end. --spec accept_matches_provided(ne_binary(), ne_binary(), kz_proplist()) -> boolean(). +-spec accept_matches_provided(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> boolean(). accept_matches_provided(Major, Minor, CTPs) -> lists:any(fun({Pri, Sec}) -> Pri =:= Major @@ -937,8 +937,8 @@ to_pdf(Req, Context, RespData) -> ,Context }. --spec to_chunk(ne_binary(), cowboy_req:req(), cb_context:context()) -> - {iolist() | ne_binary() | 'stop', cowboy_req:req(), cb_context:context()}. +-spec to_chunk(kz_term:ne_binary(), cowboy_req:req(), cb_context:context()) -> + {iolist() | kz_term:ne_binary() | 'stop', cowboy_req:req(), cb_context:context()}. to_chunk(ToFun, Req, Context) -> EventName = to_fun_event_name(ToFun, Context), next_chunk_fold(#{start_key => 'undefined' @@ -953,7 +953,7 @@ to_chunk(ToFun, Req, Context) -> ,event_name => EventName }). --spec next_chunk_fold(map()) -> {iolist() | ne_binary() | 'stop', cowboy_req:req(), cb_context:context()}. +-spec next_chunk_fold(map()) -> {iolist() | kz_term:ne_binary() | 'stop', cowboy_req:req(), cb_context:context()}. next_chunk_fold(#{chunking_finished := 'true' ,chunking_started := StartedChunk ,context := Context @@ -1017,7 +1017,7 @@ next_chunk_fold(#{chunking_started := StartedChunk %% (<>) of you're response. %% @end %%-------------------------------------------------------------------- --spec process_chunk(map()) -> {iolist() | ne_binary() | 'stop', cowboy_req:req(), cb_context:context()}. +-spec process_chunk(map()) -> {iolist() | kz_term:ne_binary() | 'stop', cowboy_req:req(), cb_context:context()}. process_chunk(#{context := Context ,cowboy_req := Req ,chunk_response_type := ToFun @@ -1057,7 +1057,7 @@ reset_context_between_chunks(Context, StartedChunk) -> ] ). --spec send_chunk_response(ne_binary(), cowboy_req:req(), cb_context:context()) -> +-spec send_chunk_response(kz_term:ne_binary(), cowboy_req:req(), cb_context:context()) -> {boolean(), cowboy_req:req()}. send_chunk_response(<<"to_json">>, Req, Context) -> api_util:create_json_chunk_response(Req, Context); @@ -1073,7 +1073,7 @@ send_chunk_response(<<"to_csv">>, Req, Context) -> %% handling the errors in the Context. %% @end %%-------------------------------------------------------------------- --spec finish_chunked_response(map()) -> {iolist() | ne_binary() | 'stop', cowboy_req:req(), cb_context:context()}. +-spec finish_chunked_response(map()) -> {iolist() | kz_term:ne_binary() | 'stop', cowboy_req:req(), cb_context:context()}. %% chunk is not started, return whatever error's or response data in Context finish_chunked_response(#{chunking_started := 'false' ,context := Context @@ -1105,13 +1105,13 @@ finish_chunked_response(#{total_queried := TotalQueried api_util:close_chunk_json_envelope(Req, cb_context:set_resp_envelope(Context, Paging)), {'stop', Req, Context}. --spec to_fun_event_name(ne_binary(), cb_contextL:context()) -> ne_binary(). +-spec to_fun_event_name(kz_term:ne_binary(), cb_contextL:context()) -> kz_term:ne_binary(). to_fun_event_name(ToThing, Context) -> [{Mod, _Params}|_] = cb_context:req_nouns(Context), Verb = cb_context:req_verb(Context), api_util:create_event_name(Context, [ToThing, kz_term:to_lower_binary(Verb), Mod]). --spec accept_override(cb_context:context()) -> api_ne_binary(). +-spec accept_override(cb_context:context()) -> kz_term:api_ne_binary(). accept_override(Context) -> cb_context:req_value(Context, <<"accept">>). @@ -1121,7 +1121,7 @@ multiple_choices(Req, Context) -> {'false', Req, Context}. -spec generate_etag(cowboy_req:req(), cb_context:context()) -> - {api_ne_binary(), cowboy_req:req(), cb_context:context()}. + {kz_term:api_ne_binary(), cowboy_req:req(), cb_context:context()}. generate_etag(Req0, Context0) -> Event = api_util:create_event_name(Context0, <<"etag">>), {Req1, Context1} = crossbar_bindings:fold(Event, {Req0, Context0}), @@ -1137,7 +1137,7 @@ generate_etag(Req0, Context0) -> end. -spec expires(cowboy_req:req(), cb_context:context()) -> - {kz_datetime(), cowboy_req:req(), cb_context:context()}. + {kz_time:datetime(), cowboy_req:req(), cb_context:context()}. expires(Req, Context) -> Event = api_util:create_event_name(Context, <<"expires">>), crossbar_bindings:fold(Event, {cb_context:resp_expires(Context), Req, Context}). diff --git a/applications/crossbar/src/api_util.erl b/applications/crossbar/src/api_util.erl index 61a2a11e566..322f6ee2b4a 100644 --- a/applications/crossbar/src/api_util.erl +++ b/applications/crossbar/src/api_util.erl @@ -68,7 +68,7 @@ -type stop_return() :: {'stop', cowboy_req:req(), cb_context:context()}. -type resp_file() :: {integer(), send_file_fun()}. --type resp_content_return() :: {ne_binary() | iolist() | resp_file(), cowboy_req:req()}. +-type resp_content_return() :: {kz_term:ne_binary() | iolist() | resp_file(), cowboy_req:req()}. -type resp_content_fun() :: fun((cowboy_req:req(), cb_context:context()) -> resp_content_return()). -type send_file_fun() :: fun((any(), module()) -> ok). -type pull_file_resp() :: {'stream', integer(), send_file_fun()}. @@ -98,7 +98,7 @@ is_cors_preflight(Req) -> %% @end %%-------------------------------------------------------------------- -spec is_cors_request(cowboy_req:req()) -> boolean(). --spec is_cors_request(cowboy_req:req(), ne_binaries()) -> boolean(). +-spec is_cors_request(cowboy_req:req(), kz_term:ne_binaries()) -> boolean(). is_cors_request(Req) -> ReqHdrs = [<<"origin">>, <<"access-control-request-method">>, <<"access-control-request-headers">>], is_cors_request(Req, ReqHdrs). @@ -138,7 +138,7 @@ add_cors_headers(Req, Context) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_cors_headers(ne_binaries()) -> kz_proplist(). +-spec get_cors_headers(kz_term:ne_binaries()) -> kz_term:proplist(). get_cors_headers(Allow) -> [{<<"access-control-allow-origin">>, <<"*">>} ,{<<"access-control-allow-methods">>, kz_binary:join(Allow, <<", ">>)} @@ -159,7 +159,7 @@ get_req_data(Context, Req0) -> -spec get_query_string_data(cowboy_req:req()) -> {kz_json:object(), cowboy_req:req()}. --spec get_query_string_data(kz_proplist(), cowboy_req:req()) -> +-spec get_query_string_data(kz_term:proplist(), cowboy_req:req()) -> {kz_json:object(), cowboy_req:req()}. get_query_string_data(Req) -> QS = cowboy_req:parse_qs(Req), @@ -172,7 +172,7 @@ get_query_string_data(QS0, Req) -> lager:debug("query string: ~p", [kz_json:encode(QS)]), {QS, Req}. --spec get_content_type(cowboy_req:req()) -> api_ne_binary(). +-spec get_content_type(cowboy_req:req()) -> kz_term:api_ne_binary(). get_content_type(Req) -> case cowboy_req:parse_header(<<"content-type">>, Req) of 'undefined' -> 'undefined'; @@ -257,7 +257,7 @@ handle_url_encoded_body(Context, Req, QS, ReqBody, JObj) -> set_request_data_in_context(Context, Req, JObj, QS) end. --spec set_request_data_in_context(cb_context:context(), cowboy_req:req(), api_object(), kz_json:object()) -> +-spec set_request_data_in_context(cb_context:context(), cowboy_req:req(), kz_term:api_object(), kz_json:object()) -> {cb_context:context(), cowboy_req:req()} | stop_return(). set_request_data_in_context(Context, Req, 'undefined', QS) -> @@ -286,7 +286,7 @@ set_valid_data_in_context(Context, JObj, QS) -> ], cb_context:setters(Context, Setters). --spec try_json(ne_binary(), kz_json:object(), cb_context:context(), cowboy_req:req()) -> +-spec try_json(kz_term:ne_binary(), kz_json:object(), cb_context:context(), cowboy_req:req()) -> {cb_context:context(), cowboy_req:req()} | stop_return(). try_json(ReqBody, QS, Context, Req) -> @@ -303,7 +303,7 @@ try_json(ReqBody, QS, Context, Req) -> -spec stop_on_invalid_envelope(cowboy_req:req(), cb_context:context()) -> stop_return(). --spec stop_on_invalid_envelope(ne_binary(), cowboy_req:req(), cb_context:context()) -> +-spec stop_on_invalid_envelope(kz_term:ne_binary(), cowboy_req:req(), cb_context:context()) -> stop_return(). stop_on_invalid_envelope(Msg, Req, Context) -> ?MODULE:stop(Req @@ -321,7 +321,7 @@ stop_on_invalid_envelope(Msg, Req, Context) -> stop_on_invalid_envelope(Req, Context) -> stop_on_invalid_envelope(?DEFAULT_JSON_ERROR_MSG, Req, Context). --spec get_url_encoded_body(ne_binary()) -> kz_json:object(). +-spec get_url_encoded_body(kz_term:ne_binary()) -> kz_json:object(). get_url_encoded_body(ReqBody) -> kz_json:from_list(cow_qs:parse_qs(ReqBody)). @@ -345,7 +345,7 @@ extract_multipart(Context, Req, QS) -> ,QS ). --spec extract_file(cb_context:context(), ne_binary(), cowboy_req:req()) -> +-spec extract_file(cb_context:context(), kz_term:ne_binary(), cowboy_req:req()) -> {cb_context:context(), cowboy_req:req()} | stop_return(). extract_file(Context, ContentType, Req0) -> @@ -355,7 +355,7 @@ extract_file(Context, ContentType, Req0) -> extract_file_body(Context, ContentType, Req0) end. --spec extract_file_part_body(cb_context:context(), ne_binary(), cowboy_req:req()) -> +-spec extract_file_part_body(cb_context:context(), kz_term:ne_binary(), cowboy_req:req()) -> {cb_context:context(), cowboy_req:req()} | stop_return(). extract_file_part_body(Context, ContentType, Req0) -> @@ -366,7 +366,7 @@ extract_file_part_body(Context, ContentType, Req0) -> handle_file_contents(Context, ContentType, Req1, FileContents) end. --spec extract_file_body(cb_context:context(), ne_binary(), cowboy_req:req()) -> +-spec extract_file_body(cb_context:context(), kz_term:ne_binary(), cowboy_req:req()) -> {cb_context:context(), cowboy_req:req()} | stop_return(). extract_file_body(Context, ContentType, Req0) -> @@ -395,7 +395,7 @@ handle_max_filesize_exceeded(Context, Req1) -> ?MODULE:stop(Req1, Context1). --spec handle_file_contents(cb_context:context(), ne_binary(), cowboy_req:req(), binary()) -> +-spec handle_file_contents(cb_context:context(), kz_term:ne_binary(), cowboy_req:req(), binary()) -> {cb_context:context(), cowboy_req:req()} | stop_return(). handle_file_contents(Context, ContentType, Req, FileContents) -> @@ -419,7 +419,7 @@ handle_file_contents(Context, ContentType, Req, FileContents) -> {cb_context:set_req_files(Context, [{Filename, FileJObj}]), Req} end. --spec uploaded_filename(cb_context:context()) -> ne_binary(). +-spec uploaded_filename(cb_context:context()) -> kz_term:ne_binary(). uploaded_filename(Context) -> case cb_context:req_value(Context, <<"filename">>) of 'undefined' -> default_filename(); @@ -428,11 +428,11 @@ uploaded_filename(Context) -> Filename end. --spec default_filename() -> ne_binary(). +-spec default_filename() -> kz_term:ne_binary(). default_filename() -> <<"uploaded_file_", (kz_term:to_binary(kz_time:now_s()))/binary>>. --spec decode_base64(cb_context:context(), ne_binary(), cowboy_req:req()) -> +-spec decode_base64(cb_context:context(), kz_term:ne_binary(), cowboy_req:req()) -> {cb_context:context(), cowboy_req:req()} | stop_return(). decode_base64(Context, CT, Req0) -> @@ -499,8 +499,8 @@ get_request_body(_Req0, _Body, {'more', _, Req1}) -> get_request_body(_Req0, Body, {'ok', Data, Req1}) -> {iolist_to_binary([Body, Data]), Req1}. --type get_json_return() :: {api_object(), cowboy_req:req()} | - {{'malformed', ne_binary()}, cowboy_req:req()}. +-type get_json_return() :: {kz_term:api_object(), cowboy_req:req()} | + {{'malformed', kz_term:ne_binary()}, cowboy_req:req()}. -spec get_json_body(binary(), cowboy_req:req()) -> get_json_return(). get_json_body(<<>>, Req) -> {'undefined', Req}; @@ -560,7 +560,7 @@ validate_request_envelope(Envelope) -> {'error', Errors} -> Errors end. --spec get_http_verb(http_method(), cb_context:context()) -> ne_binary(). +-spec get_http_verb(http_method(), cb_context:context()) -> kz_term:ne_binary(). get_http_verb(Method, Context) -> case cb_context:req_value(Context, <<"verb">>) of 'undefined' -> Method; @@ -579,7 +579,7 @@ get_http_verb(Method, Context) -> %% @end %%-------------------------------------------------------------------- --spec path_tokens(cb_context:context()) -> ne_binaries(). +-spec path_tokens(cb_context:context()) -> kz_term:ne_binaries(). path_tokens(Context) -> Api = cb_context:api_version(Context), case cb_context:path_tokens(Context) of @@ -587,7 +587,7 @@ path_tokens(Context) -> [Api | Tokens] -> Tokens end. --type cb_mod_with_tokens() :: {ne_binary(), path_tokens()}. +-type cb_mod_with_tokens() :: {kz_term:ne_binary(), path_tokens()}. -type cb_mods_with_tokens() :: [cb_mod_with_tokens()]. -spec parse_path_tokens(cb_context:context(), path_tokens()) -> @@ -628,7 +628,7 @@ parse_path_tokens(Context, [Mod|T], Events) -> parse_path_tokens(Context, List2, [{Mod, Params} | Events]) end. --spec is_cb_module(cb_context:context(), ne_binary()) -> boolean(). +-spec is_cb_module(cb_context:context(), kz_term:ne_binary()) -> boolean(). is_cb_module(Context, Elem) -> try (kz_term:to_atom(<<"cb_", Elem/binary>>)):module_info('exports') of _ -> 'true' @@ -637,7 +637,7 @@ is_cb_module(Context, Elem) -> _E:_R -> is_cb_module_version(Context, Elem) end. --spec is_cb_module_version(cb_context:context(), ne_binary()) -> boolean(). +-spec is_cb_module_version(cb_context:context(), kz_term:ne_binary()) -> boolean(). is_cb_module_version(Context, Elem) -> case cb_context:is_context(Context) of 'false' -> 'false'; @@ -669,7 +669,7 @@ is_cb_module_version(Context, Elem) -> %% 'POST' from the allowed methods. %% @end %%-------------------------------------------------------------------- --spec allow_methods([http_methods(),...], ne_binary(), http_method()) -> http_methods(). +-spec allow_methods([http_methods(),...], kz_term:ne_binary(), http_method()) -> http_methods(). allow_methods(Responses, ReqVerb, HttpVerb) -> case crossbar_bindings:succeeded(Responses) of [] -> []; @@ -685,12 +685,12 @@ allow_methods(Responses, ReqVerb, HttpVerb) -> allow_methods_fold(Response, Acc) -> sets:union(Acc, sets:from_list(uppercase_all(Response))). --spec uppercase_all(ne_binaries() | atoms()) -> ne_binaries(). +-spec uppercase_all(kz_term:ne_binaries() | kz_term:atoms()) -> kz_term:ne_binaries(). uppercase_all(L) when is_list(L) -> [kz_term:to_upper_binary(kz_term:to_binary(I)) || I <- L]. %% insert 'POST' if Verb is in Allowed; otherwise remove 'POST'. --spec maybe_add_post_method(ne_binary(), http_method(), http_methods()) -> http_methods(). +-spec maybe_add_post_method(kz_term:ne_binary(), http_method(), http_methods()) -> http_methods(). maybe_add_post_method(?HTTP_POST, ?HTTP_POST, Allowed) -> Allowed; maybe_add_post_method(Verb, ?HTTP_POST, Allowed) -> @@ -776,7 +776,7 @@ is_authentic(Req, Context, _ReqVerb, [{Mod, Params} | _ReqNouns]) -> ?MODULE:stop(Req, Context2) end. --spec prefer_new_context(kz_proplist(), cowboy_req:req(), cb_context:context()) -> +-spec prefer_new_context(kz_term:proplist(), cowboy_req:req(), cb_context:context()) -> {'true', cowboy_req:req(), cb_context:context()} | stop_return(). prefer_new_context(Results, Req, Context) -> @@ -833,9 +833,9 @@ get_authorization_token(Req, Context) -> {Req, set_auth_context(Context, Authorization)} end. --spec set_auth_context(cb_context:context(), ne_binary() | {ne_binary(), atom()}) -> +-spec set_auth_context(cb_context:context(), kz_term:ne_binary() | {kz_term:ne_binary(), atom()}) -> cb_context:context(). --spec set_auth_context(cb_context:context(), ne_binary(), atom()) -> +-spec set_auth_context(cb_context:context(), kz_term:ne_binary(), atom()) -> cb_context:context(). set_auth_context(Context, {Token, TokenType}) -> set_auth_context(Context, Token, TokenType); @@ -848,7 +848,7 @@ set_auth_context(Context, Token, TokenType) -> ] ). --spec get_authorization_token_type(ne_binary()) -> {ne_binary(), atom()}. +-spec get_authorization_token_type(kz_term:ne_binary()) -> {kz_term:ne_binary(), atom()}. get_authorization_token_type(<<"Basic ", Token/binary>>) -> {Token, 'basic'}; get_authorization_token_type(<<"Bearer ", Token/binary>>) -> {Token, 'oauth'}; get_authorization_token_type(Token) -> {Token, 'unknown'}. @@ -988,7 +988,7 @@ is_known_content_type(Req, Context, CT, CTAs) -> lager:debug("is ~p acceptable content type: ~s", [CT, IsAcceptable]), {IsAcceptable, Req, cb_context:set_content_types_accepted(Context, CTAs)}. --spec fold_in_content_type({ne_binary(), ne_binary()}, list()) -> list(). +-spec fold_in_content_type({kz_term:ne_binary(), kz_term:ne_binary()}, list()) -> list(). fold_in_content_type({Type, Sub}, Acc) -> [{Type, Sub, []} | Acc]. @@ -1121,7 +1121,7 @@ succeeded(Context) -> cb_context:resp_status(Context) =:= 'success'. -spec execute_request(cowboy_req:req(), cb_context:context()) -> {boolean() | 'stop', cowboy_req:req(), cb_context:context()}. --spec execute_request(cowboy_req:req(), cb_context:context(), ne_binary(), ne_binaries(), http_method()) -> +-spec execute_request(cowboy_req:req(), cb_context:context(), kz_term:ne_binary(), kz_term:ne_binaries(), http_method()) -> {boolean() | 'stop', cowboy_req:req(), cb_context:context()}. execute_request(Req, Context) -> case cb_context:req_nouns(Context) of @@ -1195,7 +1195,7 @@ finish_request(_Req, Context) -> %% @end %%-------------------------------------------------------------------- -spec create_resp_content(cowboy_req:req(), cb_context:context()) -> - {ne_binary() | iolist(), cowboy_req:req()}. + {kz_term:ne_binary() | iolist(), cowboy_req:req()}. create_resp_content(Req0, Context) -> Resp = create_resp_envelope(Context), Options = get_encode_options(Context), @@ -1229,7 +1229,7 @@ get_encode_options(Context) -> end. -spec create_csv_resp_content(cowboy_req:req(), cb_context:context()) -> - {ne_binary() | iolist(), cowboy_req:req()}. + {kz_term:ne_binary() | iolist(), cowboy_req:req()}. create_csv_resp_content(Req, Context) -> Content = csv_body(cb_context:resp_data(Context)), ContextHeaders = cb_context:resp_headers(Context), @@ -1308,7 +1308,7 @@ create_csv_chunk_response(Req, Context) -> end. %% @public --spec init_chunk_stream(cowboy_req:req(), ne_binary()) -> cowboy_req:req(). +-spec init_chunk_stream(cowboy_req:req(), kz_term:ne_binary()) -> cowboy_req:req(). init_chunk_stream(Req, <<"to_json">>) -> Headers = cowboy_req:resp_headers(Req), Req1 = cowboy_req:stream_reply(200, Headers, Req), @@ -1321,7 +1321,7 @@ init_chunk_stream(Req, <<"to_csv">>) -> Headers = maps:merge(Headers0, cowboy_req:resp_headers(Req)), cowboy_req:stream_reply(200, Headers, Req). --spec csv_body(ne_binary() | kz_json:object() | kz_json:objects()) -> iolist(). +-spec csv_body(kz_term:ne_binary() | kz_json:object() | kz_json:objects()) -> iolist(). csv_body(Body=?NE_BINARY) -> Body; csv_body(JObjs) when is_list(JObjs) -> FlattenJObjs = [kz_json:flatten(JObj, 'binary_join') || JObj <- JObjs], @@ -1365,7 +1365,7 @@ create_push_response(Req0, Context, Fun) -> %% is pulling data (like GET) %% @end %%-------------------------------------------------------------------- --type pull_response() :: text() | resp_file(). +-type pull_response() :: kz_term:text() | resp_file(). -spec create_pull_response(cowboy_req:req(), cb_context:context()) -> {pull_response(), cowboy_req:req(), cb_context:context()} | @@ -1384,7 +1384,7 @@ create_pull_response(Req0, Context, Fun) -> 'true' -> {maybe_set_pull_response_stream(Content), Req2, Context} end. --spec maybe_set_pull_response_stream(text() | resp_file()) -> text() | pull_file_resp(). +-spec maybe_set_pull_response_stream(kz_term:text() | resp_file()) -> kz_term:text() | pull_file_resp(). maybe_set_pull_response_stream({FileLength, TransportFun}) when is_integer(FileLength) andalso is_function(TransportFun, 2) -> @@ -1472,11 +1472,11 @@ encode_start_keys(Resp, 'true') -> ,[<<"start_key">>, <<"next_start_key">>] ). --spec encode_start_key(kz_json:path()) -> ne_binary(). +-spec encode_start_key(kz_json:path()) -> kz_term:ne_binary(). encode_start_key(StartKey) -> kz_base64url:encode(erlang:term_to_binary(StartKey)). --spec decode_start_key(ne_binary()) -> kz_json:path(). +-spec decode_start_key(kz_term:ne_binary()) -> kz_json:path(). decode_start_key(Encoded) -> try erlang:binary_to_term(kz_base64url:decode(Encoded)) catch _:_ -> Encoded @@ -1501,7 +1501,7 @@ set_resp_headers(Req0, #{}=Headers) -> set_resp_headers(Req0, Context) -> set_resp_headers(Req0, cb_context:resp_headers(Context)). --spec fix_header(text(), text(), cowboy_req:req()) -> +-spec fix_header(kz_term:text(), kz_term:text(), cowboy_req:req()) -> {binary(), binary()}. fix_header(<<"Location">>, Path, Req) -> {<<"location">>, crossbar_util:get_path(Req, Path)}; @@ -1528,7 +1528,7 @@ stop(Req0, Context) -> Req5 = cowboy_req:reply(StatusCode, Req4), {'stop', Req5, cb_context:set_resp_status(Context, 'stop')}. --spec create_event_name(cb_context:context(), ne_binary() | ne_binaries()) -> ne_binary(). +-spec create_event_name(cb_context:context(), kz_term:ne_binary() | kz_term:ne_binaries()) -> kz_term:ne_binary(). create_event_name(Context, Segments) when is_list(Segments) -> create_event_name(Context, kz_binary:join(Segments, <<".">>)); create_event_name(Context, Name) -> diff --git a/applications/crossbar/src/cb_apps_maintenance.erl b/applications/crossbar/src/cb_apps_maintenance.erl index ac153be9d8c..ccb6462c4a3 100644 --- a/applications/crossbar/src/cb_apps_maintenance.erl +++ b/applications/crossbar/src/cb_apps_maintenance.erl @@ -17,7 +17,7 @@ %% @doc %% @end %%-------------------------------------------------------------------- --spec migrate(ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. +-spec migrate(kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. migrate(Account) when is_binary(Account) -> case kz_account:fetch(Account) of {'error', _R}=Error -> Error; @@ -40,7 +40,7 @@ migrate(Account) when is_binary(Account) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec save(ne_binary(), kz_json:object(), kz_json:object()) -> {'ok', kz_json:object()} | {'error', any()}. +-spec save(kz_term:ne_binary(), kz_json:object(), kz_json:object()) -> {'ok', kz_json:object()} | {'error', any()}. save(Account, Doc, AccountDoc) -> AccountDb = kz_util:format_account_id(Account, 'encoded'), case kz_datamgr:save_doc(AccountDb, Doc) of @@ -56,7 +56,7 @@ save(Account, Doc, AccountDoc) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec save_account(ne_binary(), kz_json:object()) -> 'ok'. +-spec save_account(kz_term:ne_binary(), kz_json:object()) -> 'ok'. save_account(Account, AccountDoc) -> AccountDb = kz_util:format_account_id(Account, 'encoded'), case kz_datamgr:ensure_saved(AccountDb, kz_json:delete_key(<<"apps">>, AccountDoc)) of diff --git a/applications/crossbar/src/cb_apps_util.erl b/applications/crossbar/src/cb_apps_util.erl index f54a71c5211..df755be7250 100644 --- a/applications/crossbar/src/cb_apps_util.erl +++ b/applications/crossbar/src/cb_apps_util.erl @@ -24,11 +24,11 @@ %% Get allowed apps from service plans %% @end %%-------------------------------------------------------------------- --spec allowed_apps(ne_binary()) -> kz_json:objects(). +-spec allowed_apps(kz_term:ne_binary()) -> kz_json:objects(). allowed_apps(AccountId) -> allowed_apps(AccountId, 'undefined'). --spec allowed_apps(ne_binary(), api_ne_binary()) -> kz_json:objects(). +-spec allowed_apps(kz_term:ne_binary(), kz_term:api_ne_binary()) -> kz_json:objects(). allowed_apps(AccountId, UserId) -> case find_service_plan_with_apps(AccountId) of 'undefined' -> @@ -39,7 +39,7 @@ allowed_apps(AccountId, UserId) -> filter_apps(AccountId, UserId, Apps) end. --spec authorized_apps(ne_binary(), ne_binary()) -> kz_json:objects(). +-spec authorized_apps(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:objects(). authorized_apps(AccountId, UserId) -> allowed_apps(AccountId, UserId). @@ -49,7 +49,7 @@ authorized_apps(AccountId, UserId) -> %% Get app object if allowed %% @end %%-------------------------------------------------------------------- --spec allowed_app(ne_binary(), ne_binary()) -> api_object(). +-spec allowed_app(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_object(). allowed_app(AccountId, AppId) -> case [App || App <- allowed_apps(AccountId), AppId =:= kzd_app:id(App) @@ -81,7 +81,7 @@ load_default_apps() -> %% @doc %% @end %%-------------------------------------------------------------------- --spec create_apps_store_doc(ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. +-spec create_apps_store_doc(kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. create_apps_store_doc(Account) -> Doc = kzd_apps_store:new(Account), kz_datamgr:save_doc(kz_util:format_account_db(Account), Doc). @@ -95,7 +95,7 @@ create_apps_store_doc(Account) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_apps_store_doc(ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. +-spec get_apps_store_doc(kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. get_apps_store_doc(Account) -> case kzd_apps_store:fetch(Account) of {'error', 'not_found'} -> @@ -106,12 +106,12 @@ get_apps_store_doc(Account) -> %% @private %% @doc Find the first Service plan in Account or Account's reseller %% hierarchy which has ui_apps or has ui_apps._all --spec find_service_plan_with_apps(ne_binary()) -> api_object(). +-spec find_service_plan_with_apps(kz_term:ne_binary()) -> kz_term:api_object(). find_service_plan_with_apps(AccountId) -> ResellerId = kz_services:find_reseller_id(AccountId), find_service_plan_with_apps(AccountId, ResellerId). --spec find_service_plan_with_apps(ne_binary(), api_binary()) -> api_object(). +-spec find_service_plan_with_apps(kz_term:ne_binary(), kz_term:api_binary()) -> kz_term:api_object(). find_service_plan_with_apps(AccountId, 'undefined') -> lager:debug("reseller account is undefined, checking account ~s service plan", [AccountId]), check_service_plan(AccountId); @@ -137,7 +137,7 @@ find_service_plan_with_apps(AccountId, ResellerId) -> ServicePlan end. --spec check_service_plan(ne_binary()) -> api_object(). +-spec check_service_plan(kz_term:ne_binary()) -> kz_term:api_object(). check_service_plan(AccountId) -> ServicePlan = kz_services:service_plan_json(AccountId), case has_all_or_apps_in_service_plan(ServicePlan) of @@ -165,7 +165,7 @@ is_show_all_in_service_plan_enabled(ServicePlan) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec filter_apps(ne_binary(), api_ne_binary(), kz_json:objects()) -> kz_json:objects(). +-spec filter_apps(kz_term:ne_binary(), kz_term:api_ne_binary(), kz_json:objects()) -> kz_json:objects(). filter_apps(AccountId, UserId, Apps) -> case get_apps_store_doc(AccountId) of {'ok', Doc} -> filter_apps(AccountId, UserId, Apps, Doc); @@ -174,7 +174,7 @@ filter_apps(AccountId, UserId, Apps) -> filter_apps(AccountId, UserId, Apps, kz_json:new()) end. --spec filter_apps(ne_binary(), api_ne_binary(), kz_json:objects(), kz_json:object()) -> kz_json:objects(). +-spec filter_apps(kz_term:ne_binary(), kz_term:api_ne_binary(), kz_json:objects(), kz_json:object()) -> kz_json:objects(). filter_apps(AccountId, UserId, Apps, AppStoreJObj) -> [add_permissions(App, AppStoreJObj) || App <- Apps, @@ -188,7 +188,7 @@ filter_apps(AccountId, UserId, Apps, AppStoreJObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec is_authorized(ne_binary(), api_ne_binary(), ne_binary(), kz_json:object()) -> boolean(). +-spec is_authorized(kz_term:ne_binary(), kz_term:api_ne_binary(), kz_term:ne_binary(), kz_json:object()) -> boolean(). is_authorized(_, 'undefined', _, _) -> 'true'; is_authorized(AccountId, UserId, AppId, AppStoreJObj) -> @@ -207,7 +207,7 @@ is_authorized(AccountId, UserId, AppId, AppStoreJObj) -> 'false' end. --spec get_specific_ids(kz_json:objects()) -> ne_binaries(). +-spec get_specific_ids(kz_json:objects()) -> kz_term:ne_binaries(). get_specific_ids(Users) -> [Id || User <- Users, (Id = kz_doc:id(User)) =/= 'undefined' @@ -242,8 +242,8 @@ is_blacklisted(App, JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec is_filtered(ne_binary(), kz_json:object()) -> boolean(). --spec is_filtered(ne_binary(), kz_json:object(), ne_binary()) -> boolean(). +-spec is_filtered(kz_term:ne_binary(), kz_json:object()) -> boolean(). +-spec is_filtered(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> boolean(). is_filtered(AccountId, App) -> is_filtered(AccountId, App, kzd_app:name(App)). @@ -269,7 +269,7 @@ is_filtered(_AccountId, _App, _AppName) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec maybe_set_account(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec maybe_set_account(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). maybe_set_account(Account, Doc) -> JObj = kz_json:get_value(<<"doc">>, Doc), case 'undefined' =:= kz_doc:account_db(JObj) @@ -284,7 +284,7 @@ maybe_set_account(Account, Doc) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec set_account(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec set_account(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). set_account(Account, JObj) -> AccountDb = kz_util:format_account_db(Account), Corrected = @@ -318,7 +318,7 @@ get_plan_apps(ServicePlan) -> find_enabled_apps(PlanAppsJObj) -> kz_json:foldl(fun find_enabled_apps_fold/3, [], PlanAppsJObj). --spec find_enabled_apps_fold(ne_binary(), kzd_item_plan:doc(), kz_json:objects()) -> kz_json:objects(). +-spec find_enabled_apps_fold(kz_term:ne_binary(), kzd_item_plan:doc(), kz_json:objects()) -> kz_json:objects(). find_enabled_apps_fold(AppName, PlanApp, Acc) -> AppId = kz_json:get_value(<<"app_id">>, PlanApp), case kzd_item_plan:is_enabled(PlanApp) @@ -334,7 +334,7 @@ find_enabled_apps_fold(AppName, PlanApp, Acc) -> [kz_json:delete_key(<<"published">>, AppJObj) | Acc] end. --spec find_app(ne_binary(), kz_json:object()) -> api_object(). +-spec find_app(kz_term:ne_binary(), kz_json:object()) -> kz_term:api_object(). find_app(AppId, PlanApp) -> Account = kz_json:get_first_defined([<<"account_db">> ,<<"account_id">> diff --git a/applications/crossbar/src/cb_context.erl b/applications/crossbar/src/cb_context.erl index 351087b8d98..4ee50df7312 100644 --- a/applications/crossbar/src/cb_context.erl +++ b/applications/crossbar/src/cb_context.erl @@ -170,24 +170,24 @@ set_accepting_charges(#cb_context{req_json = ReqJObj} = Context) -> set_req_json(Context, NewReqJObj). %% Accessors --spec account_id(context()) -> api_ne_binary(). --spec account_name(context()) -> api_ne_binary(). --spec account_db(context()) -> api_ne_binary(). --spec user_id(context()) -> api_ne_binary(). --spec device_id(context()) -> api_ne_binary(). --spec reseller_id(context()) -> api_ne_binary(). --spec account_modb(context()) -> api_ne_binary(). --spec account_modb(context(), kz_now() | kz_timeout()) -> api_ne_binary(). --spec account_modb(context(), kz_year(), kz_month()) -> api_ne_binary(). --spec account_realm(context()) -> api_ne_binary(). --spec account_doc(context()) -> api_object(). --spec profile_id(context()) -> api_ne_binary(). +-spec account_id(context()) -> kz_term:api_ne_binary(). +-spec account_name(context()) -> kz_term:api_ne_binary(). +-spec account_db(context()) -> kz_term:api_ne_binary(). +-spec user_id(context()) -> kz_term:api_ne_binary(). +-spec device_id(context()) -> kz_term:api_ne_binary(). +-spec reseller_id(context()) -> kz_term:api_ne_binary(). +-spec account_modb(context()) -> kz_term:api_ne_binary(). +-spec account_modb(context(), kz_time:now() | timeout()) -> kz_term:api_ne_binary(). +-spec account_modb(context(), kz_time:year(), kz_time:month()) -> kz_term:api_ne_binary(). +-spec account_realm(context()) -> kz_term:api_ne_binary(). +-spec account_doc(context()) -> kz_term:api_object(). +-spec profile_id(context()) -> kz_term:api_ne_binary(). -spec is_authenticated(context()) -> boolean(). -spec auth_token_type(context()) -> 'x-auth-token' | 'basic' | 'oauth' | 'unknown'. --spec auth_token(context()) -> api_ne_binary(). --spec auth_doc(context()) -> api_object(). --spec auth_account_id(context()) -> api_ne_binary(). --spec auth_user_id(context()) -> api_ne_binary(). +-spec auth_token(context()) -> kz_term:api_ne_binary(). +-spec auth_doc(context()) -> kz_term:api_object(). +-spec auth_account_id(context()) -> kz_term:api_ne_binary(). +-spec auth_user_id(context()) -> kz_term:api_ne_binary(). -spec req_verb(context()) -> http_method(). -spec req_data(context()) -> kz_json:json_term(). -spec req_files(context()) -> req_files(). @@ -195,21 +195,21 @@ set_accepting_charges(#cb_context{req_json = ReqJObj} = Context) -> -spec req_headers(context()) -> cowboy:http_headers(). -spec req_header(context(), binary()) -> iodata() | 'undefined'. -spec query_string(context()) -> kz_json:object(). --spec req_param(context(), ne_binary()) -> kz_json:api_json_term(). --spec req_param(context(), ne_binary(), Default) -> kz_json:json_term() | Default. --spec client_ip(context()) -> api_ne_binary(). --spec req_id(context()) -> ne_binary(). --spec auth_account_doc(context()) -> api_object(). --spec doc(context()) -> api_object() | kz_json:objects(). --spec load_merge_bypass(context()) -> api_object(). --spec start(context()) -> kz_now(). +-spec req_param(context(), kz_term:ne_binary()) -> kz_json:api_json_term(). +-spec req_param(context(), kz_term:ne_binary(), Default) -> kz_json:json_term() | Default. +-spec client_ip(context()) -> kz_term:api_ne_binary(). +-spec req_id(context()) -> kz_term:ne_binary(). +-spec auth_account_doc(context()) -> kz_term:api_object(). +-spec doc(context()) -> kz_term:api_object() | kz_json:objects(). +-spec load_merge_bypass(context()) -> kz_term:api_object(). +-spec start(context()) -> kz_time:now(). -spec resp_file(context()) -> binary(). -spec resp_data(context()) -> resp_data(). -spec resp_status(context()) -> crossbar_status(). --spec resp_expires(context()) -> kz_datetime(). +-spec resp_expires(context()) -> kz_time:datetime(). -spec resp_headers(context()) -> cowboy:http_headers(). --spec api_version(context()) -> ne_binary(). --spec resp_etag(context()) -> 'automatic' | string() | api_binary(). +-spec api_version(context()) -> kz_term:ne_binary(). +-spec resp_etag(context()) -> 'automatic' | string() | kz_term:api_binary(). -spec resp_envelope(context()) -> kz_json:object(). -spec allow_methods(context()) -> http_methods(). -spec allowed_methods(context()) -> http_methods(). @@ -217,11 +217,11 @@ set_accepting_charges(#cb_context{req_json = ReqJObj} = Context) -> -spec req_json(context()) -> kz_json:object(). -spec content_types_accepted(context()) -> crossbar_content_handlers(). -spec content_types_provided(context()) -> crossbar_content_handlers(). --spec languages_provided(context()) -> ne_binaries(). --spec encodings_provided(context()) -> ne_binaries(). +-spec languages_provided(context()) -> kz_term:ne_binaries(). +-spec encodings_provided(context()) -> kz_term:ne_binaries(). -spec validation_errors(context()) -> kz_json:object(). --spec resp_error_code(context()) -> api_integer(). --spec resp_error_msg(context()) -> api_ne_binary(). +-spec resp_error_code(context()) -> kz_term:api_integer(). +-spec resp_error_msg(context()) -> kz_term:api_ne_binary(). account_id(#cb_context{account_id=AcctId}) -> AcctId. @@ -262,7 +262,7 @@ is_authenticated(#cb_context{}) -> 'true'. %% Returns true if the request contains a system admin module. %% @end %%-------------------------------------------------------------------- --spec is_superduper_admin(api_ne_binary() | context()) -> boolean(). +-spec is_superduper_admin(kz_term:api_ne_binary() | context()) -> boolean(). is_superduper_admin('undefined') -> 'false'; is_superduper_admin(AccountId=?NE_BINARY) -> lager:debug("checking for superduper admin: ~s", [AccountId]), @@ -346,7 +346,7 @@ pretty_print(#cb_context{pretty_print = PrettyPrint}) -> PrettyPrint. path_token(Token) -> kz_util:uri_decode(Token). --spec path_tokens(context()) -> ne_binaries(). +-spec path_tokens(context()) -> kz_term:ne_binaries(). path_tokens(#cb_context{raw_path=Path}) -> [path_token(kz_util:uri_decode(Token)) || Token <- binary:split(Path, <<"/">>, ['global', 'trim']) @@ -372,11 +372,11 @@ should_paginate(#cb_context{should_paginate=Should}) -> Should. pagination_page_size() -> ?PAGINATION_PAGE_SIZE. --spec pagination_page_size(context()) -> api_pos_integer(). +-spec pagination_page_size(context()) -> kz_term:api_pos_integer(). pagination_page_size(Context) -> pagination_page_size(Context, api_version(Context)). --spec pagination_page_size(context(), ne_binary()) -> api_pos_integer(). +-spec pagination_page_size(context(), kz_term:ne_binary()) -> kz_term:api_pos_integer(). pagination_page_size(_Context, ?VERSION_1) -> 'undefined'; pagination_page_size(Context, _Version) -> case req_value(Context, <<"page_size">>) of @@ -420,57 +420,57 @@ setters_fold({F, V}, C) -> F(C, V); setters_fold({F, K, V}, C) -> F(C, K, V); setters_fold(F, C) when is_function(F, 1) -> F(C). --spec set_account_id(context(), ne_binary()) -> context(). --spec set_account_db(context(), ne_binary()) -> context(). --spec set_user_id(context(), ne_binary()) -> context(). --spec set_device_id(context(), ne_binary()) -> context(). --spec set_auth_token(context(), ne_binary()) -> context(). +-spec set_account_id(context(), kz_term:ne_binary()) -> context(). +-spec set_account_db(context(), kz_term:ne_binary()) -> context(). +-spec set_user_id(context(), kz_term:ne_binary()) -> context(). +-spec set_device_id(context(), kz_term:ne_binary()) -> context(). +-spec set_auth_token(context(), kz_term:ne_binary()) -> context(). -spec set_auth_doc(context(), kz_json:object()) -> context(). --spec set_auth_account_id(context(), ne_binary()) -> context(). +-spec set_auth_account_id(context(), kz_term:ne_binary()) -> context(). -spec set_req_verb(context(), http_method()) -> context(). -spec set_req_data(context(), kz_json:json_term()) -> context(). -spec set_req_files(context(), req_files()) -> context(). -spec set_req_nouns(context(), req_nouns()) -> context(). -spec set_req_headers(context(), cowboy:http_headers()) -> context(). --spec set_req_header(context(), ne_binary(), iodata()) -> context(). +-spec set_req_header(context(), kz_term:ne_binary(), iodata()) -> context(). -spec set_query_string(context(), kz_json:object()) -> context(). --spec set_req_id(context(), ne_binary()) -> context(). +-spec set_req_id(context(), kz_term:ne_binary()) -> context(). -spec set_doc(context(), kz_json:api_json_term() | kz_json:objects()) -> context(). --spec set_load_merge_bypass(context(), api_ne_binary()) -> context(). --spec set_start(context(), kz_now()) -> context(). --spec set_resp_file(context(), api_binary()) -> context(). +-spec set_load_merge_bypass(context(), kz_term:api_ne_binary()) -> context(). +-spec set_start(context(), kz_time:now()) -> context(). +-spec set_resp_file(context(), kz_term:api_binary()) -> context(). -spec set_resp_data(context(), resp_data()) -> context(). -spec set_resp_status(context(), crossbar_status()) -> context(). --spec set_resp_expires(context(), kz_datetime()) -> context(). --spec set_api_version(context(), ne_binary() | pos_integer()) -> context(). --spec set_resp_etag(context(), api_binary()) -> context(). +-spec set_resp_expires(context(), kz_time:datetime()) -> context(). +-spec set_api_version(context(), kz_term:ne_binary() | pos_integer()) -> context(). +-spec set_resp_etag(context(), kz_term:api_binary()) -> context(). -spec set_resp_envelope(context(), kz_json:object()) -> context(). -spec set_resp_headers(context(), cowboy:http_headers()) -> context(). -spec add_resp_headers(context(), cowboy:http_headers()) -> context(). --spec set_resp_header(context(), ne_binary(), ne_binary()) -> context(). --spec add_resp_header(context(), ne_binary(), ne_binary()) -> context(). +-spec set_resp_header(context(), kz_term:ne_binary(), kz_term:ne_binary()) -> context(). +-spec add_resp_header(context(), kz_term:ne_binary(), kz_term:ne_binary()) -> context(). -spec set_allow_methods(context(), http_methods()) -> context(). -spec set_allowed_methods(context(), http_methods()) -> context(). -spec set_method(context(), http_method()) -> context(). -spec set_req_json(context(), kz_json:object()) -> context(). -spec set_content_types_accepted(context(), crossbar_content_handlers()) -> context(). -spec set_content_types_provided(context(), crossbar_content_handlers()) -> context(). --spec set_languages_provided(context(), ne_binaries()) -> context(). --spec set_encodings_provided(context(), ne_binaries()) -> context(). +-spec set_languages_provided(context(), kz_term:ne_binaries()) -> context(). +-spec set_encodings_provided(context(), kz_term:ne_binaries()) -> context(). -spec set_resp_error_code(context(), integer()) -> context(). --spec set_resp_error_msg(context(), api_ne_binary()) -> context(). +-spec set_resp_error_msg(context(), kz_term:api_ne_binary()) -> context(). -spec set_magic_pathed(context(), boolean()) -> context(). -spec set_should_paginate(context(), boolean()) -> context(). -spec set_validation_errors(context(), kz_json:object()) -> context(). -spec set_port(context(), integer()) -> context(). -spec set_raw_path(context(), binary()) -> context(). -spec set_raw_qs(context(), binary()) -> context(). --spec set_client_ip(context(), ne_binary()) -> context(). --spec set_profile_id(context(), ne_binary()) -> context(). --spec set_account_name(context(), api_ne_binary()) -> context(). --spec set_reseller_id(context(), api_ne_binary()) -> context(). --spec set_account_modb(context(), kz_year() | ne_binary(), kz_month() | ne_binary()) -> context(). --spec set_account_modb(context(), ne_binary(), kz_year() | ne_binary(), kz_month() | ne_binary()) -> context(). +-spec set_client_ip(context(), kz_term:ne_binary()) -> context(). +-spec set_profile_id(context(), kz_term:ne_binary()) -> context(). +-spec set_account_name(context(), kz_term:api_ne_binary()) -> context(). +-spec set_reseller_id(context(), kz_term:api_ne_binary()) -> context(). +-spec set_account_modb(context(), kz_time:year() | kz_term:ne_binary(), kz_time:month() | kz_term:ne_binary()) -> context(). +-spec set_account_modb(context(), kz_term:ne_binary(), kz_time:year() | kz_term:ne_binary(), kz_time:month() | kz_term:ne_binary()) -> context(). -spec set_auth_token_type(context(), 'x-auth-token' | 'basic' | 'oauth' | 'unknown') -> context(). set_account_id(#cb_context{}=Context, AcctId) -> @@ -594,7 +594,7 @@ set_pretty_print(#cb_context{}=Context, Value) -> set_raw_path(#cb_context{}=Context, Value) -> Context#cb_context{raw_path = Value}. --spec raw_qs(context()) -> api_ne_binary(). +-spec raw_qs(context()) -> kz_term:api_ne_binary(). raw_qs(#cb_context{raw_qs=QS}) -> QS. set_raw_qs(#cb_context{}=Context, Value) -> @@ -630,7 +630,7 @@ add_content_types_accepted(#cb_context{content_types_accepted=CTAs}=Context, [_| add_content_types_accepted(#cb_context{}=Context, {_, _}=NewCTA) -> add_content_types_provided(Context,[NewCTA]). --spec add_attachment_content_type(context(), ne_binary(), ne_binary()) -> context(). +-spec add_attachment_content_type(context(), kz_term:ne_binary(), kz_term:ne_binary()) -> context(). add_attachment_content_type(#cb_context{}=Context, DocId, AttachmentId) -> Context1 = crossbar_doc:load(DocId, Context, ?TYPE_CHECK_OPTION_ANY), case resp_status(Context1) of @@ -639,7 +639,7 @@ add_attachment_content_type(#cb_context{}=Context, DocId, AttachmentId) -> _Status -> Context1 end. --spec maybe_add_content_type_provided(context(), ne_binary()) -> context(). +-spec maybe_add_content_type_provided(context(), kz_term:ne_binary()) -> context(). maybe_add_content_type_provided(Context, AttachmentId) -> case kz_doc:attachment_content_type(doc(Context), AttachmentId) of 'undefined' -> Context; @@ -721,7 +721,7 @@ import_errors(#cb_context{}=Context) -> end. -spec response(context()) -> {ok, kz_json:object()} | - {error, {pos_integer(), ne_binary(), kz_json:object()}}. + {error, {pos_integer(), kz_term:ne_binary(), kz_json:object()}}. response(#cb_context{resp_status='success' ,resp_data=JObj }) -> @@ -750,13 +750,13 @@ response(#cb_context{resp_error_code=Code %%-------------------------------------------------------------------- -type after_fun() :: fun((context()) -> context()) | 'undefined'. --spec validate_request_data(ne_binary() | api_object(), context()) -> +-spec validate_request_data(kz_term:ne_binary() | kz_term:api_object(), context()) -> context(). --spec validate_request_data(ne_binary() | api_object(), context(), after_fun()) -> +-spec validate_request_data(kz_term:ne_binary() | kz_term:api_object(), context(), after_fun()) -> context(). --spec validate_request_data(ne_binary() | api_object(), context(), after_fun(), after_fun()) -> +-spec validate_request_data(kz_term:ne_binary() | kz_term:api_object(), context(), after_fun(), after_fun()) -> context(). --spec validate_request_data(ne_binary() | api_object(), context(), after_fun(), after_fun(), boolean()) -> +-spec validate_request_data(kz_term:ne_binary() | kz_term:api_object(), context(), after_fun(), after_fun(), boolean()) -> context(). validate_request_data(SchemaId, Context) -> validate_request_data(SchemaId, Context, 'undefined'). @@ -868,7 +868,7 @@ passed(Context) -> Id -> set_doc(Context1, kz_doc:set_id(doc(Context1), Id)) end. --spec find_schema(ne_binary()) -> api_object(). +-spec find_schema(kz_term:ne_binary()) -> kz_term:api_object(). find_schema(Schema=?NE_BINARY) -> case kz_json_schema:load(Schema) of {'ok', SchemaJObj} -> SchemaJObj; @@ -884,8 +884,8 @@ find_schema(Schema=?NE_BINARY) -> %% @end %%-------------------------------------------------------------------- -spec add_system_error(atom() | binary(), context()) -> context(). --spec add_system_error(atom() | binary(), ne_binary() | kz_json:object(), context()) -> context(). --spec add_system_error(integer(), atom() | ne_binary(), ne_binary() | kz_json:object(), context()) -> context(). +-spec add_system_error(atom() | binary(), kz_term:ne_binary() | kz_json:object(), context()) -> context(). +-spec add_system_error(integer(), atom() | kz_term:ne_binary(), kz_term:ne_binary() | kz_json:object(), context()) -> context(). add_system_error('too_many_requests', Context) -> build_system_error(429, 'too_many_requests', <<"too many requests">>, Context); add_system_error('no_credit', Context) -> @@ -979,7 +979,7 @@ add_system_error(Code, Error, JObj, Context) -> %% %% @end %%-------------------------------------------------------------------- --spec build_system_error(integer(), atom() | ne_binary(), ne_binary() | kz_json:object(), context()) -> context(). +-spec build_system_error(integer(), atom() | kz_term:ne_binary(), kz_term:ne_binary() | kz_json:object(), context()) -> context(). build_system_error(Code, Error, <<_/binary>> = Message, Context) -> build_system_error(Code, Error, kz_json:from_list([{<<"message">>, Message}]), Context); build_system_error(Code, Error, JObj, Context) -> @@ -997,7 +997,7 @@ build_system_error(Code, Error, JObj, Context) -> %% Add a validation error to the list of request errors %% @end %%-------------------------------------------------------------------- --spec add_validation_error(kz_json:path(), ne_binary(), ne_binary() | kz_json:object(), context()) -> +-spec add_validation_error(kz_json:path(), kz_term:ne_binary(), kz_term:ne_binary() | kz_json:object(), context()) -> context(). add_validation_error(<<_/binary>> = Property, Code, Message, Context) -> add_validation_error([Property], Code, Message, Context); @@ -1022,7 +1022,7 @@ add_validation_error(Property, Code, Message, Context) -> ,resp_error_msg=maybe_update_error_message(resp_error_msg(Context), ErrorMessage) }. --spec maybe_update_error_message(ne_binary(), ne_binary()) -> ne_binary(). +-spec maybe_update_error_message(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). maybe_update_error_message(_Old, <<"init failed">>) -> <<"validation error">>; maybe_update_error_message(Msg, Msg) -> Msg; maybe_update_error_message(_Old, New) -> New. @@ -1094,7 +1094,7 @@ system_properties(Context) -> ] ]). --spec system_error(context(), ne_binary()) -> context(). +-spec system_error(context(), kz_term:ne_binary()) -> context(). system_error(Context, Error) -> Notify = props:filter_undefined( [{<<"Subject">>, <<"System Alert: API Error - ", Error/binary>>} diff --git a/applications/crossbar/src/cb_devices_utils.erl b/applications/crossbar/src/cb_devices_utils.erl index ebad6426390..e8ed1d51f97 100644 --- a/applications/crossbar/src/cb_devices_utils.erl +++ b/applications/crossbar/src/cb_devices_utils.erl @@ -20,7 +20,7 @@ %% Check if the device sip ip is unique %% @end %%-------------------------------------------------------------------- --spec is_ip_unique(ne_binary(), ne_binary()) -> boolean(). +-spec is_ip_unique(kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_ip_unique(IP, DeviceId) -> is_ip_acl_unique(IP, DeviceId) andalso is_ip_sip_auth_unique(IP, DeviceId). @@ -31,14 +31,14 @@ is_ip_unique(IP, DeviceId) -> %% %% @end %%-------------------------------------------------------------------- --spec is_ip_acl_unique(ne_binary(), ne_binary()) -> boolean(). +-spec is_ip_acl_unique(kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_ip_acl_unique(IP, DeviceId) -> lists:all( fun(JObj) -> is_ip_unique(JObj, IP, DeviceId) end ,get_all_acl_ips() ). --spec is_ip_unique(kz_json:object(), ne_binary(), ne_binary()) -> boolean(). +-spec is_ip_unique(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_ip_unique(JObj, IP, DeviceId) -> case kz_json:get_value(?AUTHZ_ID, JObj) of DeviceId -> 'true'; @@ -52,7 +52,7 @@ is_ip_unique(JObj, IP, DeviceId) -> %% %% @end %%-------------------------------------------------------------------- --spec is_ip_sip_auth_unique(ne_binary(), ne_binary()) -> boolean(). +-spec is_ip_sip_auth_unique(kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_ip_sip_auth_unique(IP, DeviceId) -> case kapps_util:get_ccvs_by_ip(IP) of {'ok', CCVs} -> props:get_value(<<"Authorizing-ID">>, CCVs) =:= DeviceId; diff --git a/applications/crossbar/src/cb_mobile_manager.erl b/applications/crossbar/src/cb_mobile_manager.erl index 94cca90c0c0..6b8a5b3ec8f 100644 --- a/applications/crossbar/src/cb_mobile_manager.erl +++ b/applications/crossbar/src/cb_mobile_manager.erl @@ -59,7 +59,7 @@ handle_resp(_Error) -> %% %% @end %%-------------------------------------------------------------------- --spec req_uri(ne_binaries()) -> api_list(). +-spec req_uri(kz_term:ne_binaries()) -> kz_term:api_list(). req_uri(ExplodedPath) -> case kapps_config:get_binary(?MOD_CONFIG_CAT, <<"url">>) of 'undefined' -> 'undefined'; @@ -74,7 +74,7 @@ req_uri(ExplodedPath) -> %% %% @end %%-------------------------------------------------------------------- --spec req_headers(ne_binary()) -> kz_proplist(). +-spec req_headers(kz_term:ne_binary()) -> kz_term:proplist(). req_headers(AuthToken) -> props:filter_undefined( [{"content-type", "application/json"} diff --git a/applications/crossbar/src/crossbar.hrl b/applications/crossbar/src/crossbar.hrl index 846b2ac610f..b46adf64cce 100644 --- a/applications/crossbar/src/crossbar.hrl +++ b/applications/crossbar/src/crossbar.hrl @@ -138,13 +138,13 @@ ,content_types_accepted = [] :: crossbar_content_handlers() ,allowed_methods = ?ALLOWED_METHODS :: http_methods() ,allow_methods = ?ALLOWED_METHODS :: http_methods() - ,languages_provided = [<<"en">>, <<"en-us">>, <<"en-gb">>] :: ne_binaries() %% english by default - ,charsets_provided = [<<"iso-8859-1">>] :: ne_binaries() %% all charsets provided - ,encodings_provided = [<<"gzip;q=1.0">>,<<"identity;q=0.5">>] :: ne_binaries() %% gzip and identity - ,auth_token = 'undefined' :: api_ne_binary() + ,languages_provided = [<<"en">>, <<"en-us">>, <<"en-gb">>] :: kz_term:ne_binaries() %% english by default + ,charsets_provided = [<<"iso-8859-1">>] :: kz_term:ne_binaries() %% all charsets provided + ,encodings_provided = [<<"gzip;q=1.0">>,<<"identity;q=0.5">>] :: kz_term:ne_binaries() %% gzip and identity + ,auth_token = 'undefined' :: kz_term:api_ne_binary() ,auth_token_type = 'x-auth-token' :: 'x-auth-token' | 'basic' | 'oauth' | 'unknown' - ,auth_account_id :: api_ne_binary() - ,auth_doc :: api_object() + ,auth_account_id :: kz_term:api_ne_binary() + ,auth_doc :: kz_term:api_object() ,req_verb = ?HTTP_GET :: http_method() % see ?ALLOWED_METHODS ,req_nouns = [{<<"404">>, []}] :: req_nouns() % {module, [id]} most typical ,req_json = kz_json:new() :: req_json() @@ -152,38 +152,38 @@ ,req_data = kz_json:new() :: kz_json:json_term() % the "data" from the request JSON envelope ,req_headers = #{} :: cowboy:http_headers() ,query_json = kz_json:new() :: kz_json:object() - ,account_id :: api_ne_binary() - ,account_name :: api_ne_binary() - ,user_id :: api_ne_binary() % Will be loaded in validate stage for endpoints such as /accounts/{acct-id}/users/{user-id}/* - ,device_id :: api_ne_binary() % Will be loaded in validate stage for endpoints such as /accounts/{acct-id}/devices/{device-id}/* - ,reseller_id :: api_ne_binary() - ,db_name :: api_binary() | ne_binaries() - ,doc :: api_object() | kz_json:objects() + ,account_id :: kz_term:api_ne_binary() + ,account_name :: kz_term:api_ne_binary() + ,user_id :: kz_term:api_ne_binary() % Will be loaded in validate stage for endpoints such as /accounts/{acct-id}/users/{user-id}/* + ,device_id :: kz_term:api_ne_binary() % Will be loaded in validate stage for endpoints such as /accounts/{acct-id}/devices/{device-id}/* + ,reseller_id :: kz_term:api_ne_binary() + ,db_name :: kz_term:api_binary() | kz_term:ne_binaries() + ,doc :: kz_term:api_object() | kz_json:objects() ,pretty_print = 'false' :: boolean() - ,resp_expires = {{1999,1,1},{0,0,0}} :: kz_datetime() - ,resp_etag :: 'automatic' | string() | api_binary() + ,resp_expires = {{1999,1,1},{0,0,0}} :: kz_time:datetime() + ,resp_etag :: 'automatic' | string() | kz_term:api_binary() ,resp_status = 'error' :: crossbar_status() - ,resp_error_msg :: api_ne_binary() - ,resp_error_code :: api_integer() + ,resp_error_msg :: kz_term:api_ne_binary() + ,resp_error_code :: kz_term:api_integer() ,resp_file = <<>> :: binary() ,resp_data :: resp_data() ,resp_headers = #{} :: cowboy:http_headers() %% allow the modules to set headers (like Location: XXX to get a 201 response code) ,resp_envelope = kz_json:new() :: kz_json:object() - ,start = os:timestamp() :: kz_now() + ,start = os:timestamp() :: kz_time:now() ,req_id = ?DEFAULT_LOG_SYSTEM_ID :: binary() - ,storage = [] :: kz_proplist() + ,storage = [] :: kz_term:proplist() ,raw_host = <<>> :: binary() ,port = 8000 :: integer() ,raw_path = <<>> :: binary() ,raw_qs = <<>> :: binary() ,method = ?HTTP_GET :: http_method() ,validation_errors = kz_json:new() :: kz_json:object() - ,client_ip = <<"127.0.0.1">> :: api_ne_binary() - ,load_merge_bypass :: api_object() - ,profile_id :: api_ne_binary() - ,api_version = ?VERSION_1 :: ne_binary() + ,client_ip = <<"127.0.0.1">> :: kz_term:api_ne_binary() + ,load_merge_bypass :: kz_term:api_object() + ,profile_id :: kz_term:api_ne_binary() + ,api_version = ?VERSION_1 :: kz_term:ne_binary() ,magic_pathed = 'false' :: boolean() - ,should_paginate :: api_boolean() + ,should_paginate :: kz_term:api_boolean() ,host_url = <<>> :: binary() }). diff --git a/applications/crossbar/src/crossbar_app.erl b/applications/crossbar/src/crossbar_app.erl index a30bcae8a4b..30d5bfb7f5d 100644 --- a/applications/crossbar/src/crossbar_app.erl +++ b/applications/crossbar/src/crossbar_app.erl @@ -20,7 +20,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_StartType, _StartArgs) -> declare_exchanges(), _ = kapps_maintenance:bind('migrate', 'crossbar_maintenance', 'migrate'), diff --git a/applications/crossbar/src/crossbar_auth.erl b/applications/crossbar/src/crossbar_auth.erl index 551d96ca167..4d9d554996d 100644 --- a/applications/crossbar/src/crossbar_auth.erl +++ b/applications/crossbar/src/crossbar_auth.erl @@ -59,7 +59,7 @@ create_auth_token(Context, AuthModule) -> create_auth_token(Context, Method, JObj) end. --spec create_auth_token(cb_context:context(), ne_binary(), kz_json:object()) -> +-spec create_auth_token(cb_context:context(), kz_term:ne_binary(), kz_json:object()) -> cb_context:context(). create_auth_token(Context, Method, JObj) -> Data = cb_context:req_data(Context), @@ -123,8 +123,8 @@ create_auth_token(Context, Method, JObj) -> cb_context:add_system_error(401, 'invalid_credentials', MFAReq, Context) end. --spec maybe_create_token(cb_context:context(), kz_proplist(), kz_json:object(), ne_binary(), boolean()) -> - {'ok', ne_binary()} | +-spec maybe_create_token(cb_context:context(), kz_term:proplist(), kz_json:object(), kz_term:ne_binary(), boolean()) -> + {'ok', kz_term:ne_binary()} | {'error', any()} | {'error', any(), any()}. maybe_create_token(_Context, Claims, _AuthConfig, _Method, 'false') -> @@ -156,9 +156,9 @@ maybe_create_token(Context, Claims, AuthConfig, Method, 'true') -> {'error', 401, _MFAReq}=Retry -> Retry end. --spec validate_auth_token(map() | ne_binary()) -> +-spec validate_auth_token(map() | kz_term:ne_binary()) -> {ok, kz_json:object()} | {error, any()}. --spec validate_auth_token(map() | ne_binary(), kz_proplist()) -> +-spec validate_auth_token(map() | kz_term:ne_binary(), kz_term:proplist()) -> {ok, kz_json:object()} | {error, any()}. validate_auth_token(Token) -> validate_auth_token(Token, []). @@ -169,11 +169,11 @@ validate_auth_token(Token, Options) -> Other -> Other end. --spec authorize_auth_token(map() | ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. +-spec authorize_auth_token(map() | kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. authorize_auth_token(Token) -> kz_auth:authorize_token(Token). --spec maybe_db_token(map() | ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. +-spec maybe_db_token(map() | kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. maybe_db_token(AuthToken) -> kz_datamgr:open_cache_doc(?KZ_TOKEN_DB, AuthToken). @@ -195,7 +195,7 @@ reset_identity_secret(Context) -> %% authentication configuration %% @end %%-------------------------------------------------------------------- --spec get_account_config(api_ne_binary()) -> kz_json:object(). +-spec get_account_config(kz_term:api_ne_binary()) -> kz_json:object(). get_account_config(AccountId) -> kapps_account_config:get_hierarchy(AccountId, ?AUTH_CONFIG_CAT, <<"auth_modules">>, ?DEFAULT_AUTH_CONFIG). @@ -204,7 +204,7 @@ get_inherited_config(Context) -> AccountId = cb_context:account_id(Context), get_inherited_config(AccountId, kz_services:is_reseller(AccountId)). --spec get_inherited_config(ne_binary(), boolean()) -> kz_json:object(). +-spec get_inherited_config(kz_term:ne_binary(), boolean()) -> kz_json:object(). get_inherited_config(_, 'true') -> kapps_config:get_json(?AUTH_CONFIG_CAT, <<"auth_modules">>); get_inherited_config(AccountId, 'false') -> @@ -213,15 +213,15 @@ get_inherited_config(AccountId, 'false') -> %% @private %% Utility func to generate method's config path --spec method_config_path(ne_binary(), ne_binary()) -> kz_json:path(). +-spec method_config_path(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:path(). method_config_path(Method, Key) -> [Method, Key]. %% @private %% Utility func to generate method's multi-factor config path --spec method_mfa_path(ne_binary(), ne_binary()) -> kz_json:path(). +-spec method_mfa_path(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:path(). method_mfa_path(Method, Key) -> [Method, <<"multi_factor">>, Key]. --spec token_auth_expiry(ne_binary(), kz_json:object()) -> non_neg_integer(). +-spec token_auth_expiry(kz_term:ne_binary(), kz_json:object()) -> non_neg_integer(). token_auth_expiry(Method, AuthConfig) -> Path = method_config_path(Method, <<"token_auth_expiry_s">>), case kz_json:get_integer_value(Path, AuthConfig, 0) of @@ -241,7 +241,7 @@ token_auth_expiry(Method, AuthConfig) -> %% Check if is authenticator module is enabled or not %% @end %%-------------------------------------------------------------------- --spec is_auth_module_enabled(ne_binary(), kz_json:object()) -> boolean(). +-spec is_auth_module_enabled(kz_term:ne_binary(), kz_json:object()) -> boolean(). is_auth_module_enabled(Method, Config) -> kz_json:is_true(method_config_path(Method, <<"enabled">>), Config, 'true'). @@ -251,7 +251,7 @@ is_auth_module_enabled(Method, Config) -> %% Checks if authenticator module is configured to do multi factor auth %% @end %%-------------------------------------------------------------------- --spec is_multi_factor_enabled(kz_proplist(), kz_json:object()) -> boolean(). +-spec is_multi_factor_enabled(kz_term:proplist(), kz_json:object()) -> boolean(). is_multi_factor_enabled(Claims, AuthConfig) -> MasterId = master_account_id(), Method = props:get_ne_binary_value(<<"method">>, Claims), @@ -276,13 +276,13 @@ is_multi_factor_enabled(Claims, AuthConfig) -> %% * If account ids are not same, return 'include_subaccounts' boolean %% @end %%-------------------------------------------------------------------- --spec multi_factor_allowed_for_account(api_binary(), api_binary(), api_binary(), boolean()) -> boolean(). +-spec multi_factor_allowed_for_account(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), boolean()) -> boolean(). multi_factor_allowed_for_account(?NE_BINARY=Master, ?NE_BINARY=Master, _, _) -> 'true'; multi_factor_allowed_for_account(_Master, _ClaimAccountId, 'undefined', _) -> 'true'; multi_factor_allowed_for_account(_Master, AccountId, AccountId, _) -> 'true'; multi_factor_allowed_for_account(_Master, _ClaimAccountId, _ParentAccount, IncludeSubAcc) -> IncludeSubAcc. --spec master_account_id() -> api_ne_binary(). +-spec master_account_id() -> kz_term:api_ne_binary(). master_account_id() -> case kapps_util:get_master_account_id() of {'ok', Id} -> Id; @@ -297,15 +297,15 @@ master_account_id() -> %% Log successful authentication if configured to do so %% @end %%-------------------------------------------------------------------- --spec log_success_auth(atom() | ne_binary(), ne_binary(), ne_binary(), cb_context:context()) -> 'ok'. +-spec log_success_auth(atom() | kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), cb_context:context()) -> 'ok'. log_success_auth(AuthModule, AuthType, Reason, Context) -> log_success_auth(AuthModule, AuthType, Reason, Context, 'undefined', 'undefined'). --spec log_success_auth(atom() | ne_binary(), ne_binary(), ne_binary(), cb_context:context(), api_binary()) -> 'ok'. +-spec log_success_auth(atom() | kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), cb_context:context(), kz_term:api_binary()) -> 'ok'. log_success_auth(AuthModule, AuthType, Reason, Context, AccountId) -> log_success_auth(AuthModule, AuthType, Reason, Context, AccountId, 'undefined'). --spec log_success_auth(atom() | ne_binary(), ne_binary(), ne_binary(), cb_context:context(), api_binary(), api_object()) -> 'ok'. +-spec log_success_auth(atom() | kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), cb_context:context(), kz_term:api_binary(), kz_term:api_object()) -> 'ok'. log_success_auth(AuthModule, AuthType, Reason, Context, 'undefined', AuthConfig) -> case cb_context:account_id(Context) of 'undefined' -> 'ok'; @@ -327,15 +327,15 @@ log_success_auth(AuthModule, AuthType, Reason, Context, AccountId, AuthConfig) - %% Log failed authentication if configured to do so %% @end %%-------------------------------------------------------------------- --spec log_failed_auth(atom() | ne_binary(), ne_binary(), ne_binary(), cb_context:context()) -> 'ok'. +-spec log_failed_auth(atom() | kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), cb_context:context()) -> 'ok'. log_failed_auth(AuthModule, AuthType, Reason, Context) -> log_failed_auth(AuthModule, AuthType, Reason, Context, 'undefined', 'undefined'). --spec log_failed_auth(atom() | ne_binary(), ne_binary(), ne_binary(), cb_context:context(), api_binary()) -> 'ok'. +-spec log_failed_auth(atom() | kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), cb_context:context(), kz_term:api_binary()) -> 'ok'. log_failed_auth(AuthModule, AuthType, Reason, Context, AccountId) -> log_failed_auth(AuthModule, AuthType, Reason, Context, AccountId, 'undefined'). --spec log_failed_auth(atom() | ne_binary(), ne_binary(), ne_binary(), cb_context:context(), api_binary(), api_object()) -> 'ok'. +-spec log_failed_auth(atom() | kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), cb_context:context(), kz_term:api_binary(), kz_term:api_object()) -> 'ok'. log_failed_auth(AuthModule, AuthType, Reason, Context, 'undefined', AuthConfig) -> case cb_context:account_id(Context) of 'undefined' -> 'ok'; @@ -351,13 +351,13 @@ log_failed_auth(AuthModule, AuthType, Reason, Context, AccountId, AuthConfig) -> log_attempts(Context, AccountId, Method, <<"failed">>, AuthType, Reason) end. --spec is_log_type_enabled(ne_binary(), ne_binary(), kz_json:object()) -> boolean(). +-spec is_log_type_enabled(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> boolean(). is_log_type_enabled(<<"failed">>, Method, AuthConfig) -> kz_json:is_true(method_config_path(Method, <<"log_failed_attempts">>), AuthConfig); is_log_type_enabled(<<"success">>, Method, AuthConfig) -> kz_json:is_true(method_config_path(Method, <<"log_successful_attempts">>), AuthConfig). --spec log_attempts(cb_context:context(), ne_binary(), ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec log_attempts(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. log_attempts(Context, AccountId, Method, Status, AuthType, Reason) -> Now = kz_time:now_s(), MODB = kz_util:format_account_mod_id(AccountId, Now), @@ -381,7 +381,7 @@ log_attempts(Context, AccountId, Method, Status, AuthType, Reason) -> _ = kazoo_modb:save_doc(MODB, maybe_add_metadata(cb_context:doc(Context), Doc)), 'ok'. --spec maybe_add_metadata(api_object(), kz_json:object()) -> kz_json:object(). +-spec maybe_add_metadata(kz_term:api_object(), kz_json:object()) -> kz_json:object(). maybe_add_metadata(ContextDoc, Doc) -> case kz_term:is_empty(ContextDoc) of 'true' -> Doc; diff --git a/applications/crossbar/src/crossbar_bindings.erl b/applications/crossbar/src/crossbar_bindings.erl index 0ac1c7595c5..c6d4a39e5c7 100644 --- a/applications/crossbar/src/crossbar_bindings.erl +++ b/applications/crossbar/src/crossbar_bindings.erl @@ -45,10 +45,10 @@ -type payload() :: path_tokens() | % mapping over path tokens in URI [cb_context:context() | path_token() | 'undefined',...] | cb_context:context() | - {cb_context:context(), kz_proplist()} | % v1_resource:rest_init/2 + {cb_context:context(), kz_term:proplist()} | % v1_resource:rest_init/2 {'error', _} | % v1_util:execute_request/2 {kz_json:path(), cb_context:context(), path_tokens()} | - {kz_datetime(), cowboy_req:req(), cb_context:context()} | % v1_resource:expires/2 + {kz_time:datetime(), cowboy_req:req(), cb_context:context()} | % v1_resource:expires/2 {cowboy_req:req(), cb_context:context()}. % mapping over the request/context records %%%=================================================================== @@ -66,12 +66,12 @@ http_methods() | {boolean() | 'stop', cb_context:context()} ]. --spec map(ne_binary(), payload()) -> map_results(). +-spec map(kz_term:ne_binary(), payload()) -> map_results(). map(Routing, Payload) -> lager:debug("mapping ~s", [Routing]), kazoo_bindings:map(Routing, Payload). --spec pmap(ne_binary(), payload()) -> map_results(). +-spec pmap(kz_term:ne_binary(), payload()) -> map_results(). pmap(Routing, Payload) -> lager:debug("pmapping ~s", [Routing]), kazoo_bindings:pmap(Routing, Payload). @@ -84,7 +84,7 @@ pmap(Routing, Payload) -> %% @end %%-------------------------------------------------------------------- -type fold_results() :: payload(). --spec fold(ne_binary(), payload()) -> fold_results(). +-spec fold(kz_term:ne_binary(), payload()) -> fold_results(). fold(Routing, Payload) -> lager:debug("folding ~s", [Routing]), kazoo_bindings:fold(Routing, Payload). @@ -94,11 +94,11 @@ fold(Routing, Payload) -> %% Helper functions for working on a result set of bindings %% @end %%------------------------------------------------------------------- --spec any(kz_proplist()) -> boolean(). +-spec any(kz_term:proplist()) -> boolean(). any(Res) when is_list(Res) -> kazoo_bindings:any(Res, fun check_bool/1). --spec all(kz_proplist()) -> boolean(). +-spec all(kz_term:proplist()) -> boolean(). all(Res) when is_list(Res) -> kazoo_bindings:all(Res, fun check_bool/1). @@ -114,7 +114,7 @@ succeeded(Res) when is_list(Res) -> failed(Res) when is_list(Res) -> kazoo_bindings:failed(Res, fun filter_out_succeeded/1). --spec matches(ne_binaries(), ne_binaries()) -> boolean(). +-spec matches(kz_term:ne_binaries(), kz_term:ne_binaries()) -> boolean(). matches([], _) -> 'false'; matches([R|Restrictions], Tokens) -> Restriction = [cow_qs:urldecode(T) || T <- binary:split(R, <<"/">>, ['global', 'trim'])], @@ -162,7 +162,7 @@ filter_out_succeeded(Term) -> kz_term:is_empty(Term). -type bind_result() :: 'ok' | {'error', 'exists'}. -type bind_results() :: [bind_result()]. --spec bind(ne_binary(), atom(), atom()) -> +-spec bind(kz_term:ne_binary(), atom(), atom()) -> bind_result() | bind_results(). bind(Binding=?NE_BINARY, Module, Fun) -> kazoo_bindings:bind(Binding, Module, Fun). @@ -171,20 +171,20 @@ bind(Binding=?NE_BINARY, Module, Fun) -> flush() -> lists:foreach(fun kazoo_bindings:flush_mod/1, modules_loaded()). --spec flush(ne_binary()) -> 'ok'. +-spec flush(kz_term:ne_binary()) -> 'ok'. flush(Binding) -> kazoo_bindings:flush(Binding). -spec flush_mod(atom()) -> 'ok'. flush_mod(CBMod) -> kazoo_bindings:flush_mod(CBMod). --spec modules_loaded() -> atoms(). +-spec modules_loaded() -> kz_term:atoms(). modules_loaded() -> lists:usort( [Mod || Mod <- kazoo_bindings:modules_loaded(), is_cb_module(Mod) ]). --spec is_cb_module(ne_binary() | atom()) -> boolean(). +-spec is_cb_module(kz_term:ne_binary() | atom()) -> boolean(). is_cb_module(<<"cb_", _/binary>>) -> 'true'; is_cb_module(<<"crossbar_", _/binary>>) -> 'true'; is_cb_module(<<_/binary>>) -> 'false'; @@ -204,7 +204,7 @@ init() -> AutoloadModules = crossbar_config:autoload_modules(?DEFAULT_MODULES), lists:foreach(fun maybe_init_mod/1, AutoloadModules). --spec maybe_init_mod(ne_binary() | atom()) -> 'ok'. +-spec maybe_init_mod(kz_term:ne_binary() | atom()) -> 'ok'. maybe_init_mod(Mod) -> case crossbar_init:start_mod(Mod) of 'ok' -> 'ok'; diff --git a/applications/crossbar/src/crossbar_config.erl b/applications/crossbar/src/crossbar_config.erl index 87d3a917394..098e61e5b98 100644 --- a/applications/crossbar/src/crossbar_config.erl +++ b/applications/crossbar/src/crossbar_config.erl @@ -19,8 +19,8 @@ -spec flush() -> 'ok'. flush() -> kapps_config:flush(?CONFIG_CAT). --spec autoload_modules() -> ne_binaries(). --spec autoload_modules(ne_binaries() | atoms()) -> ne_binaries(). +-spec autoload_modules() -> kz_term:ne_binaries(). +-spec autoload_modules(kz_term:ne_binaries() | kz_term:atoms()) -> kz_term:ne_binaries(). autoload_modules() -> autoload_modules(?DEFAULT_MODULES). @@ -28,7 +28,7 @@ autoload_modules(Default) -> Modules = kapps_config:get(?CONFIG_CAT, <<"autoload_modules">>, Default), remove_versioned_modules(Modules). --spec remove_versioned_modules(binaries() | atoms()) -> binaries(). +-spec remove_versioned_modules(kz_term:binaries() | kz_term:atoms()) -> kz_term:binaries(). remove_versioned_modules(Modules) -> lists:usort(lists:map(fun remove_module_version/1, Modules)). @@ -47,10 +47,10 @@ maybe_remove_module_version("2v_" ++ Module) -> maybe_remove_module_version(Module) -> list_to_binary(lists:reverse(Module)). --spec set_autoload_modules(ne_binaries() | atoms()) -> {'ok', kz_json:object()}. +-spec set_autoload_modules(kz_term:ne_binaries() | kz_term:atoms()) -> {'ok', kz_json:object()}. set_autoload_modules(Modules) -> kapps_config:set(?CONFIG_CAT, <<"autoload_modules">>, Modules). --spec set_default_autoload_modules(ne_binaries() | atoms()) -> {'ok', kz_json:object()}. +-spec set_default_autoload_modules(kz_term:ne_binaries() | kz_term:atoms()) -> {'ok', kz_json:object()}. set_default_autoload_modules(Modules) -> kapps_config:set_default(?CONFIG_CAT, <<"autoload_modules">>, Modules). diff --git a/applications/crossbar/src/crossbar_default_handler.erl b/applications/crossbar/src/crossbar_default_handler.erl index 09d59c243c8..aa4cc43607a 100644 --- a/applications/crossbar/src/crossbar_default_handler.erl +++ b/applications/crossbar/src/crossbar_default_handler.erl @@ -22,7 +22,7 @@ ,<<"/:version/accounts/:account_id/presence/:reportid">> ]). --spec init(cowboy_req:req(), kz_proplist()) -> +-spec init(cowboy_req:req(), kz_term:proplist()) -> {'ok', cowboy_req:req(), 'undefined'}. init(Req, HandlerOpts) -> kz_util:put_callid(?DEFAULT_LOG_SYSTEM_ID), diff --git a/applications/crossbar/src/crossbar_doc.erl b/applications/crossbar/src/crossbar_doc.erl index 6877cc12767..ea37760b545 100644 --- a/applications/crossbar/src/crossbar_doc.erl +++ b/applications/crossbar/src/crossbar_doc.erl @@ -59,26 +59,26 @@ -type startkey_fun() :: 'undefined' | fun((cb_context:context()) -> startkey()) | - fun((kz_proplist(), cb_context:context()) -> startkey()). + fun((kz_term:proplist(), cb_context:context()) -> startkey()). -type view_options() :: kazoo_data:view_options() | - [{'databases', ne_binaries()} | + [{'databases', kz_term:ne_binaries()} | {'startkey_fun', startkey_fun()} ]. --type load_option() :: {?OPTION_EXPECTED_TYPE, ne_binary()} | +-type load_option() :: {?OPTION_EXPECTED_TYPE, kz_term:ne_binary()} | {'use_cache', boolean()}. -type load_options() :: kazoo_data:view_options() | [load_option()]. --record(load_view_params, {view :: api_binary() +-record(load_view_params, {view :: kz_term:api_binary() ,view_options = [] :: view_options() ,context :: cb_context:context() ,start_key :: startkey() ,should_paginate :: boolean() - ,page_size :: non_neg_integer() | api_binary() + ,page_size :: non_neg_integer() | kz_term:api_binary() ,filter_fun :: filter_fun() - ,dbs = [] :: ne_binaries() + ,dbs = [] :: kz_term:ne_binaries() ,direction = 'ascending' :: direction() }). -type load_view_params() :: #load_view_params{}. @@ -92,7 +92,7 @@ %% Failure here returns 410, 500, or 503 %% @end %%-------------------------------------------------------------------- --spec current_doc_vsn() -> ne_binary(). +-spec current_doc_vsn() -> kz_term:ne_binary(). current_doc_vsn() -> ?CROSSBAR_DOC_VSN. %%-------------------------------------------------------------------- @@ -108,7 +108,7 @@ current_doc_vsn() -> ?CROSSBAR_DOC_VSN. cb_context:context(). -spec load(kazoo_data:docid() | kazoo_data:docids(), cb_context:context(), load_options()) -> cb_context:context(). --spec load(ne_binary() | ne_binaries(), cb_context:context(), load_options(), crossbar_status()) -> +-spec load(kz_term:ne_binary() | kz_term:ne_binaries(), cb_context:context(), load_options(), crossbar_status()) -> cb_context:context(). load({DocType, DocId}, Context) -> @@ -151,7 +151,7 @@ load([_|_]=IDs, Context, Options, _RespStatus) -> end end. --spec maybe_open_cache_doc(ne_binary(), kazoo_data:docid(), kz_proplist()) -> +-spec maybe_open_cache_doc(kz_term:ne_binary(), kazoo_data:docid(), kz_term:proplist()) -> {'ok', kz_json:object()} | kz_datamgr:data_error(). maybe_open_cache_doc(DbName, DocId, Options) -> @@ -160,7 +160,7 @@ maybe_open_cache_doc(DbName, DocId, Options) -> false -> kz_datamgr:open_doc(DbName, DocId, Options) end. --spec maybe_open_cache_docs(ne_binary(), kazoo_data:docids(), kz_proplist()) -> +-spec maybe_open_cache_docs(kz_term:ne_binary(), kazoo_data:docids(), kz_term:proplist()) -> {'ok', kz_json:objects()} | kz_datamgr:data_error(). maybe_open_cache_docs(DbName, DocIds, Options) -> @@ -181,7 +181,7 @@ maybe_open_cache_docs(DbName, DocIds, Options) -> %% it will return `true`. %% @end %%-------------------------------------------------------------------- --spec check_document_type(cb_context:context(), kz_json:object() | kz_json:objects(), kz_proplist()) -> +-spec check_document_type(cb_context:context(), kz_json:object() | kz_json:objects(), kz_term:proplist()) -> boolean(). check_document_type(_Context, [], _Options) -> true; check_document_type(Context, [_|_]=JObjs, Options) -> @@ -194,7 +194,7 @@ check_document_type(Context, JObj, Options) -> ReqType = normalize_requested_resource_name(Noun), document_type_match(JObjType, ExpectedType, ReqType). --spec document_type_match(api_binary(), api_binary(), ne_binary()) -> boolean(). +-spec document_type_match(kz_term:api_binary(), kz_term:api_binary(), kz_term:ne_binary()) -> boolean(). document_type_match('undefined', _ExpectedType, _ReqType) -> lager:debug("document doesn't have type, requested type is ~p", [_ReqType]), 'true'; @@ -212,14 +212,14 @@ document_type_match(_JObjType, _ExpectedType, _ReqType) -> ), 'false'. --spec normalize_requested_resource_name(ne_binary()) -> ne_binary(). +-spec normalize_requested_resource_name(kz_term:ne_binary()) -> kz_term:ne_binary(). normalize_requested_resource_name(Name) -> case props:get_value(Name, ?SPECIAL_EXPECTED_TYPE) of 'undefined' -> depluralize_resource_name(Name); Special -> Special end. --spec depluralize_resource_name(ne_binary()) -> ne_binary(). +-spec depluralize_resource_name(kz_term:ne_binary()) -> kz_term:ne_binary(). depluralize_resource_name(Name) -> Size = byte_size(Name) - 1, case Name of @@ -256,13 +256,13 @@ handle_successful_load(Context, JObj, 'false') -> %% Failure here returns 410, 500, or 503 %% @end %%-------------------------------------------------------------------- --spec load_merge(ne_binary(), cb_context:context()) -> +-spec load_merge(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). --spec load_merge(ne_binary(), cb_context:context(), kz_proplist()) -> +-spec load_merge(kz_term:ne_binary(), cb_context:context(), kz_term:proplist()) -> cb_context:context(). --spec load_merge(ne_binary(), kz_json:object(), cb_context:context(), kz_proplist()) -> +-spec load_merge(kz_term:ne_binary(), kz_json:object(), cb_context:context(), kz_term:proplist()) -> cb_context:context(). --spec load_merge(ne_binary(), kz_json:object(), cb_context:context(), kz_proplist(), api_object()) -> +-spec load_merge(kz_term:ne_binary(), kz_json:object(), cb_context:context(), kz_term:proplist(), kz_term:api_object()) -> cb_context:context(). load_merge(DocId, Context) -> @@ -286,11 +286,11 @@ load_merge(DocId, DataJObj, Context, Options, 'undefined') -> load_merge(_DocId, _DataJObj, Context, _Options, BypassJObj) -> handle_datamgr_success(BypassJObj, Context). --type validate_fun() :: fun((ne_binary(), cb_context:context()) -> cb_context:context()). +-type validate_fun() :: fun((kz_term:ne_binary(), cb_context:context()) -> cb_context:context()). --spec patch_and_validate(ne_binary(), cb_context:context(), validate_fun()) -> +-spec patch_and_validate(kz_term:ne_binary(), cb_context:context(), validate_fun()) -> cb_context:context(). --spec patch_and_validate(ne_binary(), cb_context:context(), validate_fun(), load_options()) -> +-spec patch_and_validate(kz_term:ne_binary(), cb_context:context(), validate_fun(), load_options()) -> cb_context:context(). patch_and_validate(Id, Context, ValidateFun) -> patch_and_validate(Id, Context, ValidateFun, ?TYPE_CHECK_OPTION_ANY). @@ -299,7 +299,7 @@ patch_and_validate(Id, Context, ValidateFun, LoadOptions) -> Context1 = load(Id, Context, LoadOptions), patch_and_validate_doc(Id, Context1, ValidateFun, cb_context:resp_status(Context1)). --spec patch_and_validate_doc(ne_binary(), cb_context:context(), validate_fun(), crossbar_status()) -> +-spec patch_and_validate_doc(kz_term:ne_binary(), cb_context:context(), validate_fun(), crossbar_status()) -> cb_context:context(). patch_and_validate_doc(Id, Context, ValidateFun, 'success') -> PatchedJObj = patch_the_doc(cb_context:req_data(Context), cb_context:doc(Context)), @@ -322,13 +322,13 @@ patch_the_doc(RequestData, ExistingDoc) -> %% Failure here returns 500 or 503 %% @end %%-------------------------------------------------------------------- --spec load_view(ne_binary() | 'all_docs', kz_proplist(), cb_context:context()) -> +-spec load_view(kz_term:ne_binary() | 'all_docs', kz_term:proplist(), cb_context:context()) -> cb_context:context(). --spec load_view(ne_binary() | 'all_docs', kz_proplist(), cb_context:context(), kz_json:json_term() | filter_fun()) -> +-spec load_view(kz_term:ne_binary() | 'all_docs', kz_term:proplist(), cb_context:context(), kz_json:json_term() | filter_fun()) -> cb_context:context(). --spec load_view(ne_binary() | 'all_docs', kz_proplist(), cb_context:context(), kz_json:json_term(), pos_integer()) -> +-spec load_view(kz_term:ne_binary() | 'all_docs', kz_term:proplist(), cb_context:context(), kz_json:json_term(), pos_integer()) -> cb_context:context(). --spec load_view(ne_binary() | 'all_docs', kz_proplist(), cb_context:context(), kz_json:json_term(), pos_integer(), filter_fun()) -> +-spec load_view(kz_term:ne_binary() | 'all_docs', kz_term:proplist(), cb_context:context(), kz_json:json_term(), pos_integer(), filter_fun()) -> cb_context:context(). load_view(View, Options, Context) -> load_view(View, Options, Context @@ -368,7 +368,7 @@ load_view(View, Options, Context, StartKey, PageSize, FilterFun) -> ,direction = view_sort_direction(Options) }). --spec view_sort_direction(kz_proplist()) -> direction(). +-spec view_sort_direction(kz_term:proplist()) -> direction(). view_sort_direction(Options) -> case props:get_value('descending', Options) of 'true' -> 'descending'; @@ -452,8 +452,8 @@ load_view(#load_view_params{view = View ) end. --spec limit_by_page_size(api_binary() | pos_integer()) -> api_pos_integer(). --spec limit_by_page_size(cb_context:context(), api_binary() | pos_integer()) -> api_pos_integer(). +-spec limit_by_page_size(kz_term:api_binary() | pos_integer()) -> kz_term:api_pos_integer(). +-spec limit_by_page_size(cb_context:context(), kz_term:api_binary() | pos_integer()) -> kz_term:api_pos_integer(). limit_by_page_size('undefined') -> 'undefined'; limit_by_page_size(N) when is_integer(N) -> N+1; limit_by_page_size(<<_/binary>> = B) -> limit_by_page_size(kz_term:to_integer(B)). @@ -467,7 +467,7 @@ limit_by_page_size(Context, PageSize) -> end. -spec start_key(cb_context:context()) -> kz_json:api_json_term(). --spec start_key(kz_proplist(), cb_context:context()) -> kz_json:api_json_term(). +-spec start_key(kz_term:proplist(), cb_context:context()) -> kz_json:api_json_term(). start_key(Context) -> cb_context:req_value(Context, <<"start_key">>). @@ -478,7 +478,7 @@ start_key(Options, Context) -> Fun when is_function(Fun, 1) -> Fun(Context) end. --spec start_key_fun(kz_proplist(), cb_context:context()) -> kz_json:api_json_term(). +-spec start_key_fun(kz_term:proplist(), cb_context:context()) -> kz_json:api_json_term(). start_key_fun(Options, Context) -> case props:get_value('startkey', Options) of 'undefined' -> @@ -527,7 +527,7 @@ load_docs(Context, Filter) %% Failure here returns 500 or 503 %% @end %%-------------------------------------------------------------------- --spec load_attachment({ne_binary(), ne_binary()} | kazoo_data:docid() | kz_json:object(), ne_binary(), kz_proplist(), cb_context:context()) -> +-spec load_attachment({kz_term:ne_binary(), kz_term:ne_binary()} | kazoo_data:docid() | kz_json:object(), kz_term:ne_binary(), kz_term:proplist(), cb_context:context()) -> cb_context:context(). load_attachment({DocType, DocId}, AName, Options, Context) -> load_attachment(DocId, AName, [{'doc_type', DocType} | Options], Context); @@ -559,9 +559,9 @@ load_attachment(Doc, AName, Options, Context) -> %%-------------------------------------------------------------------- -spec save(cb_context:context()) -> cb_context:context(). --spec save(cb_context:context(), kz_proplist()) -> +-spec save(cb_context:context(), kz_term:proplist()) -> cb_context:context(). --spec save(cb_context:context(), kz_json:object() | kz_json:objects(), kz_proplist()) -> +-spec save(cb_context:context(), kz_json:object() | kz_json:objects(), kz_term:proplist()) -> cb_context:context(). save(Context) -> @@ -606,9 +606,9 @@ save(Context, JObj, Options) -> %%-------------------------------------------------------------------- -spec ensure_saved(cb_context:context()) -> cb_context:context(). --spec ensure_saved(cb_context:context(), kz_proplist()) -> +-spec ensure_saved(cb_context:context(), kz_term:proplist()) -> cb_context:context(). --spec ensure_saved(cb_context:context(), kz_json:object() | kz_json:objects(), kz_proplist()) -> +-spec ensure_saved(cb_context:context(), kz_json:object() | kz_json:objects(), kz_term:proplist()) -> cb_context:context(). ensure_saved(Context) -> @@ -637,7 +637,7 @@ ensure_saved(Context, JObj, Options) -> %% Failure here returns 500 or 503 %% @end %%-------------------------------------------------------------------- --spec save_attachment(ne_binary(), ne_binary(), ne_binary(), cb_context:context()) -> cb_context:context(). +-spec save_attachment(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). save_attachment(DocId, AName, Contents, Context) -> save_attachment(DocId, AName, Contents, Context, []). @@ -649,7 +649,7 @@ save_attachment(DocId, AName, Contents, Context) -> %% Failure here returns 500 or 503 %% @end %%-------------------------------------------------------------------- --spec save_attachment(ne_binary(), ne_binary(), ne_binary(), cb_context:context(), kz_proplist()) -> +-spec save_attachment(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), cb_context:context(), kz_term:proplist()) -> cb_context:context(). save_attachment(DocId, Name, Contents, Context, Options) -> Opts1 = case props:get_value('rev', Options) of @@ -700,7 +700,7 @@ save_attachment(DocId, Name, Contents, Context, Options) -> ]) end. --spec maybe_delete_doc(cb_context:context(), ne_binary()) -> +-spec maybe_delete_doc(cb_context:context(), kz_term:ne_binary()) -> {'ok', _} | {'error', any()}. maybe_delete_doc(Context, DocId) -> @@ -743,7 +743,7 @@ delete(Context, ?HARD_DELETE) -> lager:info("hard-deleting doc ~s", [kz_doc:id(Doc)]), do_delete(Context, Doc, fun kz_datamgr:del_doc/2). --spec soft_delete(cb_context:context(), api_binary()) -> cb_context:context(). +-spec soft_delete(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). soft_delete(Context, Rev) -> lager:debug("soft deleting with rev ~s", [Rev]), JObj1 = lists:foldl(fun({F, V}, J) -> F(J, V) end @@ -753,7 +753,7 @@ soft_delete(Context, Rev) -> ]), do_delete(Context, JObj1, fun kz_datamgr:save_doc/2). --type delete_fun() :: fun((ne_binary(), kz_json:object() | ne_binary()) -> +-type delete_fun() :: fun((kz_term:ne_binary(), kz_json:object() | kz_term:ne_binary()) -> {'ok', kz_json:object() | kz_json:objects()} | kz_datamgr:data_error()). @@ -787,7 +787,7 @@ do_delete(Context, JObj, CouchFun) -> %% Failure here returns 500 or 503 %% @end %%-------------------------------------------------------------------- --spec delete_attachment(ne_binary(), ne_binary(), cb_context:context()) -> +-spec delete_attachment(kz_term:ne_binary(), kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). delete_attachment(DocId, AName, Context) -> case kz_datamgr:delete_attachment(cb_context:account_db(Context), DocId, AName) of @@ -809,8 +809,8 @@ delete_attachment(DocId, AName, Context) -> %% document into a usable ETag for the response %% @end %%-------------------------------------------------------------------- --spec rev_to_etag(kz_json:object() | kz_json:objects() | ne_binary()) -> - 'automatic' | api_string(). +-spec rev_to_etag(kz_json:object() | kz_json:objects() | kz_term:ne_binary()) -> + 'automatic' | kz_term:api_string(). rev_to_etag([_|_])-> 'automatic'; rev_to_etag([]) -> 'undefined'; rev_to_etag(Rev) when is_binary(Rev) -> kz_term:to_list(Rev); @@ -826,7 +826,7 @@ rev_to_etag(JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec update_pagination_envelope_params(cb_context:context(), any(), api_non_neg_integer()) -> +-spec update_pagination_envelope_params(cb_context:context(), any(), kz_term:api_non_neg_integer()) -> cb_context:context(). update_pagination_envelope_params(Context, StartKey, PageSize) -> update_pagination_envelope_params(Context @@ -836,7 +836,7 @@ update_pagination_envelope_params(Context, StartKey, PageSize) -> ,cb_context:should_paginate(Context) ). --spec update_pagination_envelope_params(cb_context:context(), any(), api_non_neg_integer(), api_binary()) -> +-spec update_pagination_envelope_params(cb_context:context(), any(), kz_term:api_non_neg_integer(), kz_term:api_binary()) -> cb_context:context(). update_pagination_envelope_params(Context, StartKey, PageSize, NextStartKey) -> update_pagination_envelope_params(Context @@ -846,7 +846,7 @@ update_pagination_envelope_params(Context, StartKey, PageSize, NextStartKey) -> ,cb_context:should_paginate(Context) ). --spec update_pagination_envelope_params(cb_context:context(), any(), api_non_neg_integer(), api_binary(), boolean()) -> +-spec update_pagination_envelope_params(cb_context:context(), any(), kz_term:api_non_neg_integer(), kz_term:api_binary(), boolean()) -> cb_context:context(). update_pagination_envelope_params(Context, _StartKey, _PageSize, _NextStartKey, 'false') -> lager:debug("pagination disabled, removing resp envelope keys"), @@ -870,7 +870,7 @@ update_pagination_envelope_params(Context, StartKey, PageSize, NextStartKey, 'tr ), cb_context:set_resp_envelope(Context, NewRespEnvelope). --spec handle_datamgr_pagination_success(kz_json:objects(), api_pos_integer(), ne_binary(), load_view_params()) -> +-spec handle_datamgr_pagination_success(kz_json:objects(), kz_term:api_pos_integer(), kz_term:ne_binary(), load_view_params()) -> cb_context:context(). %% If v1, just append results and try next database handle_datamgr_pagination_success(JObjs @@ -1106,7 +1106,7 @@ version_specific_success(JObjs, Context, _Version) -> %% %% @end %%-------------------------------------------------------------------- --spec handle_datamgr_errors(kz_datamgr:data_errors(), api_ne_binary() | api_ne_binaries(), cb_context:context()) -> +-spec handle_datamgr_errors(kz_datamgr:data_errors(), kz_term:api_ne_binary() | kz_term:api_ne_binaries(), cb_context:context()) -> cb_context:context(). handle_datamgr_errors('invalid_db_name', _, Context) -> lager:debug("datastore ~s not_found", [cb_context:account_db(Context)]), @@ -1216,7 +1216,7 @@ add_pvt_auth(JObj, Context) -> add_pvt_alphanum_name(JObj, Context) -> add_pvt_alphanum_name(JObj, Context, kz_json:get_value(<<"name">>, JObj), kz_doc:type(JObj)). --spec add_pvt_alphanum_name(kz_json:object(), cb_context:context(), api_binary(), ne_binary()) -> kz_json:object(). +-spec add_pvt_alphanum_name(kz_json:object(), cb_context:context(), kz_term:api_binary(), kz_term:ne_binary()) -> kz_json:object(). add_pvt_alphanum_name(JObj, _, 'undefined', <<"user">>) -> Name = case {kz_json:get_ne_binary_value(<<"first_name">>, JObj) ,kz_json:get_ne_binary_value(<<"last_name">>, JObj) diff --git a/applications/crossbar/src/crossbar_filter.erl b/applications/crossbar/src/crossbar_filter.erl index 6b409f86dce..5ae1d46aa54 100644 --- a/applications/crossbar/src/crossbar_filter.erl +++ b/applications/crossbar/src/crossbar_filter.erl @@ -82,7 +82,7 @@ is_defined(Context) -> %% crossbar_view to not add `include_docs` if only they are defined. %% @end %%-------------------------------------------------------------------- --spec is_only_time_filter(cb_context:context(), ne_binary()) -> boolean(). +-spec is_only_time_filter(cb_context:context(), kz_term:ne_binary()) -> boolean(). is_only_time_filter(Context, FilterKey) -> Fun = fun({<<"created_from">>, _}) -> 'true'; ({<<"created_to">>, _}) -> 'true'; @@ -100,11 +100,11 @@ is_only_time_filter(Context, FilterKey) -> %% Returns 'true' if all of the requested props are found, 'false' if one is not found %% @end %%-------------------------------------------------------------------- --spec by_doc(api_object(), cb_context:context()) -> boolean(). +-spec by_doc(kz_term:api_object(), cb_context:context()) -> boolean(). by_doc(Doc, Context) -> by_doc(Doc, Context, is_defined(Context)). --spec by_doc(api_object(), cb_context:context(), boolean()) -> boolean(). +-spec by_doc(kz_term:api_object(), cb_context:context(), boolean()) -> boolean(). by_doc(_, _, 'false') -> 'true'; by_doc('undefined', _, 'true') -> @@ -190,7 +190,7 @@ is_filter_key(_) -> 'false'. filter_doc_by_querystring(Doc, QueryString) -> kz_json:all(fun({K, V}) -> should_filter_doc(Doc, K, V) end, QueryString). --spec should_filter_doc(kz_json:object(), ne_binary(), kz_json:json_term()) -> boolean(). +-spec should_filter_doc(kz_json:object(), kz_term:ne_binary(), kz_json:json_term()) -> boolean(). should_filter_doc(Doc, K, V) -> try filter_prop(Doc, K, V) of 'undefined' -> 'true'; @@ -207,7 +207,7 @@ should_filter_doc(Doc, K, V) -> %% Returns 'true' or 'false' if the prop is found inside the doc %% @end %%-------------------------------------------------------------------- --spec filter_prop(kz_json:object(), ne_binary(), any()) -> api_boolean(). +-spec filter_prop(kz_json:object(), kz_term:ne_binary(), any()) -> kz_term:api_boolean(). filter_prop(Doc, <<"filter_not_", Key/binary>>, Val) -> not should_filter(Doc, Key, Val); filter_prop(Doc, <<"filter_", Key/binary>>, Val) -> @@ -237,8 +237,8 @@ upperbound(DocTimestamp, QSTimestamp) -> lowerbound(DocTimestamp, QSTimestamp) -> QSTimestamp =< DocTimestamp. --spec should_filter(binary(), ne_binary()) -> boolean(). --spec should_filter(kz_json:object(), ne_binary(), kz_json:json_term()) -> boolean(). +-spec should_filter(binary(), kz_term:ne_binary()) -> boolean(). +-spec should_filter(kz_json:object(), kz_term:ne_binary(), kz_json:json_term()) -> boolean(). should_filter(Val, Val) -> 'true'; should_filter(Val, FilterVal) -> try kz_json:unsafe_decode(FilterVal) of @@ -257,16 +257,16 @@ should_filter(Doc, Key, Val) -> ,kz_term:to_binary(Val) ). --spec has_key(kz_json:object(), ne_binary()) -> boolean(). +-spec has_key(kz_json:object(), kz_term:ne_binary()) -> boolean(). has_key(Doc, Key) -> Keys = binary_key_to_json_key(Key), kz_json:get_value(Keys, Doc) =/= 'undefined'. --spec has_value(kz_json:object(), ne_binary()) -> boolean(). +-spec has_value(kz_json:object(), kz_term:ne_binary()) -> boolean(). has_value(Doc, Key) -> Keys = binary_key_to_json_key(Key), kz_json:get_ne_value(Keys, Doc) =/= 'undefined'. --spec binary_key_to_json_key(ne_binary()) -> ne_binaries(). +-spec binary_key_to_json_key(kz_term:ne_binary()) -> kz_term:ne_binaries(). binary_key_to_json_key(Key) -> binary:split(Key, <<".">>, ['global']). diff --git a/applications/crossbar/src/crossbar_freeswitch.erl b/applications/crossbar/src/crossbar_freeswitch.erl index f2b30c239b5..9c1df8f1c31 100644 --- a/applications/crossbar/src/crossbar_freeswitch.erl +++ b/applications/crossbar/src/crossbar_freeswitch.erl @@ -50,9 +50,9 @@ -define(AUTHN_TIMEOUT, 5 * ?MILLISECONDS_IN_SECOND). --record(state, {config = 'undefined' :: api_binary() +-record(state, {config = 'undefined' :: kz_term:api_binary() ,is_running = 'false' :: boolean() - ,monitor :: api_reference() + ,monitor :: kz_term:api_reference() ,hourly_timer = hourly_timer() :: reference() }). -type state() :: #state{}. @@ -71,7 +71,7 @@ reset() -> %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_server:start_link(?SERVER, [], []). @@ -98,7 +98,7 @@ init([]) -> %% Handling call messages %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call('current', _From, #state{config='undefined'}=State) -> {'reply', {'error', 'no_file'}, State}; handle_call('current', _From, #state{config=Config}=State) -> @@ -113,7 +113,7 @@ handle_call(_Request, _From, State) -> %% Handling cast messages %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('periodic_build', #state{is_running='true'}=State) -> {'noreply', State}; handle_cast('periodic_build', #state{is_running='false'}=State) -> @@ -148,7 +148,7 @@ handle_cast(_Msg, State) -> %% Handling all non call/cast messages %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'DOWN', MonitorRef, 'process', _, 'normal'}, #state{monitor=MonitorRef}=State) -> {'noreply', State#state{is_running='false'}}; handle_info({'DOWN', MonitorRef, _, _Pid, _Reason}, #state{monitor=MonitorRef}=State) -> @@ -239,14 +239,14 @@ process_realms() -> ], 'ok'. --spec process_realms(api_binaries(), ne_binary(), atom()) -> 'ok'. +-spec process_realms(kz_term:api_binaries(), kz_term:ne_binary(), atom()) -> 'ok'. process_realms('undefined', _Dir, _Module) -> 'ok'; process_realms([], _, _) -> 'ok'; process_realms([Realm | Realms], Dir, Module) -> process_realm(Realm, Dir, Module), process_realms(Realms, Dir, Module). --spec process_realm(ne_binary(), ne_binary(), atom()) -> 'ok'. +-spec process_realm(kz_term:ne_binary(), kz_term:ne_binary(), atom()) -> 'ok'. process_realm(Realm, Dir, Module) -> Props = [{<<"realm">>, Realm}], WorkDir = get(<<"WorkDir">>), @@ -272,7 +272,7 @@ build_freeswitch(Pid) -> kz_util:delete_dir(kz_term:to_list(WorkDir)), gen_server:cast(Pid, {'completed', File}). --spec crawl_numbers_db(ne_binary()) -> 'ok'. +-spec crawl_numbers_db(kz_term:ne_binary()) -> 'ok'. crawl_numbers_db(NumberDb) -> lager:debug("getting all numbers from ~s",[NumberDb]), Db = kz_term:to_binary(http_uri:encode(kz_term:to_list(NumberDb))), @@ -289,7 +289,7 @@ crawl_numbers_db(NumberDb) -> lager:debug("~s getting number docs from ~s: ~p", [_E, Db, _R]) end. --spec get_numbers(kz_json:objects()) -> ne_binaries(). +-spec get_numbers(kz_json:objects()) -> kz_term:ne_binaries(). get_numbers(JObjs) -> [Number || JObj <- JObjs, @@ -299,7 +299,7 @@ get_numbers(JObjs) -> end ]. --spec maybe_export_numbers(ne_binary(), ne_binaries()) -> 'ok'. +-spec maybe_export_numbers(kz_term:ne_binary(), kz_term:ne_binaries()) -> 'ok'. maybe_export_numbers(_, []) -> 'ok'; maybe_export_numbers(Db, [Number|Numbers]) -> _ = case kz_datamgr:open_doc(Db, Number) of @@ -313,7 +313,7 @@ maybe_export_numbers(Db, [Number|Numbers]) -> end, maybe_export_numbers(Db, Numbers). --spec maybe_export_number(ne_binary(), api_binary(), api_binary()) -> 'ok'. +-spec maybe_export_number(kz_term:ne_binary(), kz_term:api_binary(), kz_term:api_binary()) -> 'ok'. maybe_export_number(Number, ?NUMBER_STATE_IN_SERVICE, AccountId) -> AccountDb = kz_util:format_account_id(AccountId, 'encoded'), ViewOptions = [{'key', Number} @@ -336,7 +336,7 @@ maybe_export_number(Number, ?NUMBER_STATE_IN_SERVICE, AccountId) -> end; maybe_export_number(_, _, _) -> 'ok'. --spec process_callflows(ne_binary(), ne_binary(), kz_json:objects()) -> 'ok'. +-spec process_callflows(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:objects()) -> 'ok'. process_callflows(_, _, []) -> 'ok'; process_callflows(Number, AccountId, [JObj | JObjs]) -> FlowId = kz_doc:id(JObj), @@ -346,7 +346,7 @@ process_callflows(Number, AccountId, [JObj | JObjs]) -> process_callflow(Number, AccountId, Flow), process_callflows(Number, AccountId, JObjs). --spec process_callflow(ne_binary(), ne_binary(), api_object()) -> 'ok'. +-spec process_callflow(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_object()) -> 'ok'. process_callflow(_, _, 'undefined') -> 'ok'; process_callflow(Number, AccountId, Flow) -> Module = kz_json:get_value(<<"module">>, Flow), @@ -359,7 +359,7 @@ process_callflow(Number, AccountId, Flow) -> _ -> Children end). --spec process_callflow(ne_binary(), ne_binary(), ne_binary(), api_binary()) -> 'ok'. +-spec process_callflow(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary()) -> 'ok'. process_callflow(_, _, _, 'undefined') -> 'ok'; process_callflow(Number, AccountId, <<"device">>, DeviceId) -> lager:debug("found device ~s associated with ~s", [DeviceId, Number]), @@ -389,7 +389,7 @@ process_callflow(Number, AccountId, <<"user">>, UserId) -> end; process_callflow(_, _, _, _) -> 'ok'. --spec process_device(ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec process_device(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. process_device(Number, AccountId, JObj) -> AccountRealm = kz_account:fetch_realm(AccountId), Realm = kz_device:sip_realm(JObj, AccountRealm), @@ -404,7 +404,7 @@ process_device(Number, AccountId, JObj) -> ,[Username, Realm, AccountId, _R]) end. --spec props_for_rendering(ne_binary(), ne_binary(), ne_binary(), kz_json:object()) -> kz_proplist(). +-spec props_for_rendering(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> kz_term:proplist(). props_for_rendering(Number, Username, Realm, Auth) -> props:filter_empty( kz_json:recursive_to_proplist( @@ -438,7 +438,7 @@ normalize(JObj) -> ) )). --spec render_templates(ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_proplist()) -> 'ok'. +-spec render_templates(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. render_templates(Number, AccountId, Username, Realm, Props) -> Templates = [{"directory", ?FS_DIRECTORY} ,{"chatplan", ?FS_CHATPLAN} @@ -450,7 +450,7 @@ render_templates(Number, AccountId, Username, Realm, Props) -> ], 'ok'. --spec render_template(ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_proplist(), file:name_all(), atom()) -> 'ok'. +-spec render_template(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist(), file:name_all(), atom()) -> 'ok'. render_template(Number, AccountId, Username, Realm, Props, Dir, Module) -> maybe_accumulate_realm(lists:member(Realm, get(<<"Realms">>)), Realm), WorkDir = get(<<"WorkDir">>), @@ -464,13 +464,13 @@ render_template(Number, AccountId, Username, Realm, Props, Dir, Module) -> ,[Module, Number, AccountId, _R]) end. --spec maybe_accumulate_realm(boolean(), ne_binary()) -> any(). +-spec maybe_accumulate_realm(boolean(), kz_term:ne_binary()) -> any(). maybe_accumulate_realm('true', _) -> 'ok'; maybe_accumulate_realm('false', Realm) -> put(<<"Realms">>, [Realm | get(<<"Realms">>)]). --spec query_registrar(ne_binary(), ne_binary()) -> {'ok', kz_json:object()} - | {'error', any()}. +-spec query_registrar(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} + | {'error', any()}. query_registrar(Realm, Username) -> FullUser = <>, Req = [{<<"To">>, FullUser} @@ -505,7 +505,7 @@ compile_templates() -> compile_template(Module) -> compile_template(Module, kapps_config:get_binary(?MOD_CONFIG_CAT, kz_term:to_binary(Module))). --spec compile_template(atom(), api_binary()) -> 'ok'. +-spec compile_template(atom(), kz_term:api_binary()) -> 'ok'. compile_template(Module, 'undefined') -> {'ok', Contents} = file:read_file(template_file(Module)), kapps_config:set(?MOD_CONFIG_CAT, kz_term:to_binary(Module), Contents), @@ -523,15 +523,15 @@ xml_file_name(?FS_DIALPLAN) -> "dialplan.xml"; xml_file_name(?FS_CHATPLAN) -> "chatplan.xml"; xml_file_name(?FS_DIRECTORY) -> "directory.xml". --spec xml_file_from_config(?FS_CHATPLAN | ?FS_DIALPLAN | ?FS_DIRECTORY) -> ne_binary(). --spec xml_file_from_config(?FS_CHATPLAN | ?FS_DIALPLAN | ?FS_DIRECTORY, ne_binary()) -> ne_binary(). +-spec xml_file_from_config(?FS_CHATPLAN | ?FS_DIALPLAN | ?FS_DIRECTORY) -> kz_term:ne_binary(). +-spec xml_file_from_config(?FS_CHATPLAN | ?FS_DIALPLAN | ?FS_DIRECTORY, kz_term:ne_binary()) -> kz_term:ne_binary(). xml_file_from_config(Module) -> KeyName = <<(kz_term:to_binary(Module))/binary,"_top_dir_file_content">>, xml_file_from_config(Module, KeyName). xml_file_from_config(Module, KeyName) -> xml_file_from_config(Module, kapps_config:get_binary(?MOD_CONFIG_CAT, KeyName), KeyName). --spec xml_file_from_config(atom(), api_binary(), ne_binary()) -> ne_binary(). +-spec xml_file_from_config(atom(), kz_term:api_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). xml_file_from_config(Module, 'undefined', KeyName) -> {'ok', Contents} = file:read_file(xml_file(Module)), kapps_config:set(?MOD_CONFIG_CAT, KeyName, Contents), diff --git a/applications/crossbar/src/crossbar_init.erl b/applications/crossbar/src/crossbar_init.erl index 0049c96c7aa..68a959c9301 100644 --- a/applications/crossbar/src/crossbar_init.erl +++ b/applications/crossbar/src/crossbar_init.erl @@ -34,8 +34,8 @@ api_path() -> api_version_constraint() -> {'version', fun api_version_constraint/2}. --spec api_version_constraint('forward', ne_binary()) -> - {'ok', ne_binary()} | +-spec api_version_constraint('forward', kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | {'error', 'not_a_version'}. api_version_constraint('forward', <<"v", ApiVersion/binary>>=Vsn) -> try kz_term:to_integer(ApiVersion) of @@ -57,7 +57,7 @@ api_version_constraint('forward', NotVersion) -> %% @public %% @doc Starts the app for inclusion in a supervisor tree %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> kz_util:put_callid(?DEFAULT_LOG_SYSTEM_ID), @@ -102,14 +102,14 @@ start_mod(CBMod) when is_atom(CBMod) -> start_mod(CBMod) -> start_mod(kz_term:to_binary(CBMod)). --spec maybe_start_mod_versions(ne_binaries(), ne_binary() | atom()) -> 'ok'. +-spec maybe_start_mod_versions(kz_term:ne_binaries(), kz_term:ne_binary() | atom()) -> 'ok'. maybe_start_mod_versions(Versions, Mod) -> case lists:all(fun(Version) -> start_mod_version(Version, Mod) end, Versions) of 'true' -> 'ok'; 'false' -> {'error', 'no_modules_started'} end. --spec start_mod_version(ne_binary(), ne_binary() | atom()) -> boolean(). +-spec start_mod_version(kz_term:ne_binary(), kz_term:ne_binary() | atom()) -> boolean(). start_mod_version(Version, Mod) -> Module = <<(kz_term:to_binary(Mod))/binary , "_", (kz_term:to_binary(Version))/binary @@ -150,11 +150,11 @@ do_stop_mod(CBMod) -> maybe_stop_mod_versions(?VERSION_SUPPORTED, CBMod) end. --spec maybe_stop_mod_versions(ne_binaries(), ne_binary() | atom()) -> 'ok'. +-spec maybe_stop_mod_versions(kz_term:ne_binaries(), kz_term:ne_binary() | atom()) -> 'ok'. maybe_stop_mod_versions(Versions, Mod) -> lists:foreach(fun(Version) -> stop_mod_version(Version, Mod) end, Versions). --spec stop_mod_version(ne_binary(), ne_binary() | atom()) -> boolean(). +-spec stop_mod_version(kz_term:ne_binary(), kz_term:ne_binary() | atom()) -> boolean(). stop_mod_version(Version, Mod) -> Module = <<(kz_term:to_binary(Mod))/binary , "_", (kz_term:to_binary(Version))/binary @@ -178,7 +178,7 @@ stop_mod_version(Version, Mod) -> -spec on_request(cowboy_req:req()) -> cowboy_req:req(). on_request(Req) -> Req. --spec on_response(cowboy:http_status(), cowboy:http_headers(), text(), cowboy_req:req()) -> +-spec on_response(cowboy:http_status(), cowboy:http_headers(), kz_term:text(), cowboy_req:req()) -> cowboy_req:req(). on_response(_Status, _Headers, _Body, Req) -> Req. @@ -313,7 +313,7 @@ start_ssl(Dispatch) -> lager:warning("failed to start SSL API server: ~p", [_E]) end. --spec ssl_opts(list()) -> kz_proplist(). +-spec ssl_opts(list()) -> kz_term:proplist(). ssl_opts(RootDir) -> BaseOpts = base_ssl_opts(RootDir), case kapps_config:get_string(?CONFIG_CAT, <<"ssl_ca_cert">>) of @@ -321,7 +321,7 @@ ssl_opts(RootDir) -> SSLCACert -> [{'cacertfile', SSLCACert} | BaseOpts] end. --spec base_ssl_opts(list()) -> kz_proplist(). +-spec base_ssl_opts(list()) -> kz_term:proplist(). base_ssl_opts(RootDir) -> [{'port', kapps_config:get_integer(?CONFIG_CAT, <<"ssl_port">>, 8443)} ,{'certfile', find_file(kapps_config:get_string(?CONFIG_CAT diff --git a/applications/crossbar/src/crossbar_maintenance.erl b/applications/crossbar/src/crossbar_maintenance.erl index 495d2d96d93..af4931961cb 100644 --- a/applications/crossbar/src/crossbar_maintenance.erl +++ b/applications/crossbar/src/crossbar_maintenance.erl @@ -52,7 +52,7 @@ -include("crossbar.hrl"). -include_lib("kazoo/include/kz_system_config.hrl"). --type input_term() :: atom() | string() | ne_binary(). +-type input_term() :: atom() | string() | kz_term:ne_binary(). %%-------------------------------------------------------------------- %% @public @@ -64,7 +64,7 @@ migrate() -> migrate(kapps_util:get_all_accounts()). --spec migrate(ne_binaries()) -> 'no_return'. +-spec migrate(kz_term:ne_binaries()) -> 'no_return'. migrate(Accounts) -> _ = migrate_accounts_data(Accounts), @@ -81,7 +81,7 @@ migrate(Accounts) -> (not lists:member(Module, CurrentModules)) ]). --spec remove_deprecated_modules(atoms(), atoms()) -> atoms(). +-spec remove_deprecated_modules(kz_term:atoms(), kz_term:atoms()) -> kz_term:atoms(). remove_deprecated_modules(Modules, Deprecated) -> case lists:foldl(fun lists:delete/2, Modules, Deprecated) of Modules -> Modules; @@ -95,13 +95,13 @@ remove_deprecated_modules(Modules, Deprecated) -> migrate_accounts_data() -> migrate_accounts_data(kapps_util:get_all_accounts()). --spec migrate_accounts_data(ne_binaries()) -> 'no_return'. +-spec migrate_accounts_data(kz_term:ne_binaries()) -> 'no_return'. migrate_accounts_data([]) -> 'no_return'; migrate_accounts_data([Account|Accounts]) -> _ = migrate_account_data(Account), migrate_accounts_data(Accounts). --spec migrate_account_data(ne_binary()) -> 'no_return'. +-spec migrate_account_data(kz_term:ne_binary()) -> 'no_return'. migrate_account_data(Account) -> _ = cb_clicktocall:maybe_migrate_history(Account), _ = migrate_ring_group_callflow(Account), @@ -110,7 +110,7 @@ migrate_account_data(Account) -> _ = cb_apps_maintenance:migrate(Account), 'no_return'. --spec add_missing_modules(atoms(), atoms()) -> 'no_return'. +-spec add_missing_modules(kz_term:atoms(), kz_term:atoms()) -> 'no_return'. add_missing_modules(_, []) -> 'no_return'; add_missing_modules(Modules, MissingModules) -> io:format(" saving autoload_modules with missing modules added: ~p~n", [MissingModules]), @@ -143,14 +143,14 @@ flush() -> %% %% @end %%-------------------------------------------------------------------- --spec start_module(text()) -> 'ok'. +-spec start_module(kz_term:text()) -> 'ok'. start_module(Module) -> case crossbar_init:start_mod(Module) of 'ok' -> maybe_autoload_module(kz_term:to_binary(Module)); {'error', Error} -> io:format("failed to start ~s: ~p~n", [Module, Error]) end. --spec maybe_autoload_module(ne_binary()) -> 'ok'. +-spec maybe_autoload_module(kz_term:ne_binary()) -> 'ok'. maybe_autoload_module(Module) -> Mods = crossbar_config:autoload_modules(), case lists:member(Module, Mods) of @@ -161,7 +161,7 @@ maybe_autoload_module(Module) -> io:format("started and added ~s to autoloaded modules~n", [Module]) end. --spec persist_module(ne_binary(), ne_binaries()) -> 'ok'. +-spec persist_module(kz_term:ne_binary(), kz_term:ne_binaries()) -> 'ok'. persist_module(Module, Mods) -> {'ok', _} = crossbar_config:set_default_autoload_modules( [kz_term:to_binary(Module) @@ -175,7 +175,7 @@ persist_module(Module, Mods) -> %% %% @end %%-------------------------------------------------------------------- --spec stop_module(text()) -> 'ok'. +-spec stop_module(kz_term:text()) -> 'ok'. stop_module(Module) -> 'ok' = crossbar_init:stop_mod(Module), Mods = crossbar_config:autoload_modules(), @@ -188,7 +188,7 @@ stop_module(Module) -> %% %% @end %%-------------------------------------------------------------------- --spec running_modules() -> atoms(). +-spec running_modules() -> kz_term:atoms(). running_modules() -> crossbar_bindings:modules_loaded(). %%-------------------------------------------------------------------- @@ -197,7 +197,7 @@ running_modules() -> crossbar_bindings:modules_loaded(). %% %% @end %%-------------------------------------------------------------------- --spec find_account_by_number(input_term()) -> {'ok', ne_binary()} | +-spec find_account_by_number(input_term()) -> {'ok', kz_term:ne_binary()} | {'error', any()}. find_account_by_number(Number) when not is_binary(Number) -> find_account_by_number(kz_term:to_binary(Number)); @@ -224,8 +224,8 @@ find_account_by_number(Number) -> %% @end %%-------------------------------------------------------------------- -spec find_account_by_name(input_term()) -> - {'ok', ne_binary()} | - {'multiples', [ne_binary(),...]} | + {'ok', kz_term:ne_binary()} | + {'multiples', [kz_term:ne_binary(),...]} | {'error', any()}. find_account_by_name(Name) when not is_binary(Name) -> find_account_by_name(kz_term:to_binary(Name)); @@ -252,8 +252,8 @@ find_account_by_name(Name) -> %% @end %%-------------------------------------------------------------------- -spec find_account_by_realm(input_term()) -> - {'ok', ne_binary()} | - {'multiples', [ne_binary(),...]} | + {'ok', kz_term:ne_binary()} | + {'multiples', [kz_term:ne_binary(),...]} | {'error', any()}. find_account_by_realm(Realm) when not is_binary(Realm) -> find_account_by_realm(kz_term:to_binary(Realm)); @@ -280,7 +280,7 @@ find_account_by_realm(Realm) -> %% @end %%-------------------------------------------------------------------- -spec find_account_by_id(input_term()) -> - {'ok', ne_binary()} | + {'ok', kz_term:ne_binary()} | {'error', any()}. find_account_by_id(Id) when is_binary(Id) -> print_account_info(kz_util:format_account_id(Id, 'encoded')); @@ -444,7 +444,7 @@ create_account_and_user(Account, User) -> create_fold({F, V}, {'ok', C}) -> F(V, C); create_fold(F, {'ok', C}) -> F(C). --spec update_system_config(ne_binary()) -> 'ok'. +-spec update_system_config(kz_term:ne_binary()) -> 'ok'. update_system_config(AccountId) -> kapps_config:set(?KZ_SYSTEM_CONFIG_ACCOUNT, <<"master_account_id">>, AccountId), io:format("updated master account id in system_config.~s~n", [?KZ_SYSTEM_CONFIG_ACCOUNT]). @@ -488,8 +488,8 @@ db_system_config_exists() -> db_system_schemas_exists() -> db_exists(?KZ_SCHEMA_DB). --spec db_exists(ne_binary()) -> 'true'. --spec db_exists(ne_binary(), boolean()) -> 'true'. +-spec db_exists(kz_term:ne_binary()) -> 'true'. +-spec db_exists(kz_term:ne_binary(), boolean()) -> 'true'. db_exists(Database) -> db_exists(Database, 'true'). @@ -515,14 +515,14 @@ do_schemas_exist() -> ], lists:all(fun does_schema_exist/1, Schemas). --spec does_schema_exist(ne_binary()) -> boolean(). +-spec does_schema_exist(kz_term:ne_binary()) -> boolean(). does_schema_exist(Schema) -> case kz_json_schema:load(Schema) of {'ok', SchemaJObj} -> maybe_load_refs(SchemaJObj); {'error', 'not_found'} -> maybe_fload(Schema) end. --spec maybe_fload(ne_binary()) -> boolean(). +-spec maybe_fload(kz_term:ne_binary()) -> boolean(). maybe_fload(Schema) -> case kz_json_schema:fload(Schema) of {'ok', SchemaJObj} -> @@ -651,8 +651,8 @@ create_user(Context) -> throw(Errors) end. --spec print_account_info(ne_binary()) -> {'ok', ne_binary()}. --spec print_account_info(ne_binary(), ne_binary()) -> {'ok', ne_binary()}. +-spec print_account_info(kz_term:ne_binary()) -> {'ok', kz_term:ne_binary()}. +-spec print_account_info(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_term:ne_binary()}. print_account_info(AccountDb) -> AccountId = kz_util:format_account_id(AccountDb, 'raw'), print_account_info(AccountDb, AccountId). @@ -677,13 +677,13 @@ print_account_info(AccountDb, AccountId) -> %% %% @end %%-------------------------------------------------------------------- --spec move_account(ne_binary(), ne_binary()) -> 'ok'. +-spec move_account(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. move_account(Account, ToAccount) -> AccountId = kz_util:format_account_id(Account, 'raw'), ToAccountId = kz_util:format_account_id(ToAccount, 'raw'), maybe_move_account(AccountId, ToAccountId). --spec maybe_move_account(ne_binary(), ne_binary()) -> 'ok'. +-spec maybe_move_account(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. maybe_move_account(AccountId, AccountId) -> io:format("can not move to the same account~n"); maybe_move_account(AccountId, ToAccountId) -> @@ -700,20 +700,20 @@ maybe_move_account(AccountId, ToAccountId) -> %% @end %%-------------------------------------------------------------------- -spec descendants_count() -> 'ok'. --spec descendants_count(ne_binary()) -> 'ok'. +-spec descendants_count(kz_term:ne_binary()) -> 'ok'. descendants_count() -> crossbar_util:descendants_count(). descendants_count(AccountId) -> crossbar_util:descendants_count(AccountId). --spec migrate_ring_group_callflow(ne_binary()) -> 'ok'. +-spec migrate_ring_group_callflow(kz_term:ne_binary()) -> 'ok'. migrate_ring_group_callflow(Account) -> lists:foreach(fun create_new_ring_group_callflow/1 ,get_migrateable_ring_group_callflows(Account) ). --spec get_migrateable_ring_group_callflows(ne_binary()) -> kz_json:objects(). +-spec get_migrateable_ring_group_callflows(kz_term:ne_binary()) -> kz_json:objects(). get_migrateable_ring_group_callflows(Account) -> AccountDb = kz_util:format_account_id(Account, 'encoded'), case kz_datamgr:get_all_results(AccountDb, <<"callflows/crossbar_listing">>) of @@ -724,14 +724,14 @@ get_migrateable_ring_group_callflows(Account) -> get_migrateable_ring_group_callflows(AccountDb, JObjs) end. --spec get_migrateable_ring_group_callflows(ne_binary(), kz_json:objects()) -> kz_json:objects(). +-spec get_migrateable_ring_group_callflows(kz_term:ne_binary(), kz_json:objects()) -> kz_json:objects(). get_migrateable_ring_group_callflows(AccountDb, JObjs) -> lists:foldl(fun(JObj, Acc) -> get_migrateable_ring_group_callflow(JObj, Acc, AccountDb) end ,[] ,JObjs ). --spec get_migrateable_ring_group_callflow(kz_json:object(), kz_json:objects(), ne_binary()) -> +-spec get_migrateable_ring_group_callflow(kz_json:object(), kz_json:objects(), kz_term:ne_binary()) -> kz_json:objects(). get_migrateable_ring_group_callflow(JObj, Acc, AccountDb) -> case {kz_json:get_ne_binary_value([<<"value">>, <<"group_id">>], JObj) @@ -835,7 +835,7 @@ save_new_ring_group_callflow(JObj, NewCallflow, AccountDb) -> update_old_ring_group_callflow(JObj, NewJObj) end. --spec check_if_callflow_exist(ne_binary(), ne_binary()) -> boolean(). +-spec check_if_callflow_exist(kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). check_if_callflow_exist(AccountDb, Name) -> case kz_datamgr:get_all_results(AccountDb, <<"callflows/crossbar_listing">>) of {'error', _M} -> @@ -902,7 +902,7 @@ save_old_ring_group(JObj, NewCallflow) -> init_apps(AppsPath) -> init_apps(AppsPath, 'undefined'). --spec init_apps(file:name(), api_binary()) -> 'ok'. +-spec init_apps(file:name(), kz_term:api_binary()) -> 'ok'. init_apps(AppsPath, AppUrl) -> Apps = find_apps(AppsPath), InitApp = fun(App) -> init_app(App, AppUrl) end, @@ -922,7 +922,7 @@ find_apps(AppsPath) -> init_app(AppPath) -> init_app(AppPath, 'undefined'). --spec init_app(file:filename_all(), api_binary()) -> 'ok'. +-spec init_app(file:filename_all(), kz_term:api_binary()) -> 'ok'. init_app(AppPath, AppUrl) -> io:format("trying to init app from ~s~n", [AppPath]), try find_metadata(AppPath) of @@ -938,14 +938,14 @@ init_app(AppPath, AppUrl) -> io:format(" failed to find metadata in ~s: ~p~n", [AppPath, _E]) end. --spec maybe_set_api_url(api_binary(), kz_json:object()) -> kz_json:object(). +-spec maybe_set_api_url(kz_term:api_binary(), kz_json:object()) -> kz_json:object(). maybe_set_api_url('undefined', MetaData) -> kz_json:delete_key(<<"api_url">>, MetaData); maybe_set_api_url(AppUrl, MetaData) -> kz_json:set_value(<<"api_url">>, AppUrl, MetaData). -spec maybe_create_app(file:filename_all(), kz_json:object()) -> 'ok'. --spec maybe_create_app(file:filename_all(), kz_json:object(), ne_binary()) -> 'ok'. +-spec maybe_create_app(file:filename_all(), kz_json:object(), kz_term:ne_binary()) -> 'ok'. maybe_create_app(AppPath, MetaData) -> {'ok', MasterAccountDb} = kapps_util:get_master_account_db(), maybe_create_app(AppPath, MetaData, MasterAccountDb). @@ -960,7 +960,7 @@ maybe_create_app(AppPath, MetaData, MasterAccountDb) -> {'error', _E} -> io:format(" failed to find app ~s: ~p", [AppName, _E]) end. --spec maybe_update_app(file:filename_all(), kz_json:object(), ne_binary(), kz_json:object()) -> no_return. +-spec maybe_update_app(file:filename_all(), kz_json:object(), kz_term:ne_binary(), kz_json:object()) -> no_return. maybe_update_app(AppPath, MetaData, MasterAccountDb, AppJObj) -> ApiUrlKey = <<"api_url">>, CurrentDocId = kzd_app:id(AppJObj), @@ -978,13 +978,13 @@ maybe_update_app(AppPath, MetaData, MasterAccountDb, AppJObj) -> 'ok' = delete_old_images(CurrentDocId, MetaData, MasterAccountDb), maybe_add_images(AppPath, CurrentDocId, MetaData, MasterAccountDb). --spec find_app(ne_binary(), ne_binary()) -> {'ok', kz_json:object()} | - {'error', any()}. +-spec find_app(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | + {'error', any()}. find_app(Db, Name) -> ViewOptions = [{'key', Name}], kz_datamgr:get_single_result(Db, ?CB_APPS_STORE_LIST, ViewOptions). --spec create_app(file:filename_all(), kz_json:object(), ne_binary()) -> 'ok'. +-spec create_app(file:filename_all(), kz_json:object(), kz_term:ne_binary()) -> 'ok'. create_app(AppPath, MetaData, MasterAccountDb) -> Doc0 = kz_doc:update_pvt_parameters(MetaData, MasterAccountDb, [{'type', <<"app">>}]), Doc = kz_json:delete_key(<<"source_url">>, Doc0), @@ -998,13 +998,13 @@ create_app(AppPath, MetaData, MasterAccountDb) -> ,[kzd_app:name(MetaData), MasterAccountDb, _E]) end. --spec delete_old_images(ne_binary(), kz_json:object(), ne_binary()) -> 'ok'. +-spec delete_old_images(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> 'ok'. delete_old_images(AppId, MetaData, MasterAccountDb) -> F = fun (X) -> safe_delete_image(MasterAccountDb, AppId, X) end, lists:foreach(F, [kzd_app:icon(MetaData)]), lists:foreach(F, kzd_app:screenshots(MetaData)). --spec safe_delete_image(ne_binary(), ne_binary(), api_binary()) -> 'ok'. +-spec safe_delete_image(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary()) -> 'ok'. safe_delete_image(_AccountDb, _AppId, 'undefined') -> 'ok'; safe_delete_image(AccountDb, AppId, Image) -> case kz_datamgr:fetch_attachment(AccountDb, AppId, Image) of @@ -1013,7 +1013,7 @@ safe_delete_image(AccountDb, AppId, Image) -> kz_datamgr:delete_attachment(AccountDb, AppId, Image) end. --spec maybe_add_images(file:filename_all(), ne_binary(), kz_json:object(), ne_binary()) -> no_return. +-spec maybe_add_images(file:filename_all(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> no_return. maybe_add_images(AppPath, ?NE_BINARY=AppId, MetaData, MasterAccountDb) -> Icon = kzd_app:icon(MetaData), Screenshots = kzd_app:screenshots(MetaData), @@ -1035,7 +1035,7 @@ update_screenshots(AppId, MA, SShotPaths) -> -type image_path() :: {file:filename_all(), file:filename_all()}. -type image_paths() :: [image_path()]. --spec update_images(ne_binary(), ne_binary(), image_paths(), ne_binary()) -> 'ok'. +-spec update_images(kz_term:ne_binary(), kz_term:ne_binary(), image_paths(), kz_term:ne_binary()) -> 'ok'. update_images(AppId, MasterAccountDb, ImagePaths, Type) -> try read_images(ImagePaths) of {'ok', Images} -> add_images(AppId, MasterAccountDb, Images) @@ -1046,14 +1046,14 @@ update_images(AppId, MasterAccountDb, ImagePaths, Type) -> io:format(" failed to load ~s in ~s: ~p~n", [Type, AppId, _E]) end. --spec add_images(ne_binary(), ne_binary(), kz_proplist()) -> 'ok'. +-spec add_images(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. add_images(AppId, MasterAccountDb, Images) -> _ = [add_image(AppId, MasterAccountDb, ImageId, ImageData) || {ImageId, ImageData} <- Images ], 'ok'. --spec add_image(ne_binary(), ne_binary(), file:filename_all(), binary()) -> 'ok'. +-spec add_image(kz_term:ne_binary(), kz_term:ne_binary(), file:filename_all(), binary()) -> 'ok'. add_image(AppId, MasterAccountDb, ImageId, ImageData) -> case kz_datamgr:put_attachment(MasterAccountDb, AppId, ImageId, ImageData) of {'ok', _} -> io:format(" saved ~s to ~s~n", [ImageId, AppId]); @@ -1074,7 +1074,7 @@ read_image(File) -> -spec find_metadata(file:filename_all()) -> {'ok', kz_json:object()} | - {'invalid_data', kz_proplist()}. + {'invalid_data', kz_term:proplist()}. find_metadata(AppPath) -> {'ok', JSON} = file:read_file(filename:join([AppPath, <<"metadata">>, <<"app.json">>])), {'ok', Schema} = kz_json_schema:load(<<"app">>), @@ -1093,7 +1093,7 @@ apps() -> end, no_return. --spec app(ne_binary()) -> no_return. +-spec app(kz_term:ne_binary()) -> no_return. app(AppNameOrId) -> {ok, MA} = kapps_util:get_master_account_db(), case find_app(MA, AppNameOrId) of @@ -1149,14 +1149,14 @@ update_app(AppId, Path, Value) -> end, no_return. --spec set_app_field(ne_binary(), ne_binary(), ne_binary()) -> no_return. +-spec set_app_field(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> no_return. set_app_field(AppId, Field, Value) -> update_app(AppId, [Field], Value). --spec set_app_label(ne_binary(), ne_binary()) -> no_return. --spec set_app_description(ne_binary(), ne_binary()) -> no_return. --spec set_app_extended_description(ne_binary(), ne_binary()) -> no_return. --spec set_app_features(ne_binary(), ne_binary()) -> no_return. +-spec set_app_label(kz_term:ne_binary(), kz_term:ne_binary()) -> no_return. +-spec set_app_description(kz_term:ne_binary(), kz_term:ne_binary()) -> no_return. +-spec set_app_extended_description(kz_term:ne_binary(), kz_term:ne_binary()) -> no_return. +-spec set_app_features(kz_term:ne_binary(), kz_term:ne_binary()) -> no_return. set_app_label(AppId, Value) -> update_app(AppId, [<<"i18n">>, <<"en-US">>, <<"label">>], Value). set_app_description(AppId, Value) -> @@ -1169,14 +1169,14 @@ set_app_features(AppId, Value) -> ], update_app(AppId, [<<"i18n">>, <<"en-US">>, <<"features">>], Values). --spec set_app_icon(ne_binary(), ne_binary()) -> no_return. +-spec set_app_icon(kz_term:ne_binary(), kz_term:ne_binary()) -> no_return. set_app_icon(AppId, PathToPNGIcon) -> {ok, MA} = kapps_util:get_master_account_db(), io:format("Processing...\n"), Icon = {filename:basename(PathToPNGIcon), PathToPNGIcon}, update_icon(AppId, MA, Icon). --spec set_app_screenshots(ne_binary(), ne_binary()) -> no_return. +-spec set_app_screenshots(kz_term:ne_binary(), kz_term:ne_binary()) -> no_return. set_app_screenshots(AppId, PathToScreenshotsFolder) -> {ok, MA} = kapps_util:get_master_account_db(), io:format("Processing...\n"), diff --git a/applications/crossbar/src/crossbar_module_sup.erl b/applications/crossbar/src/crossbar_module_sup.erl index 20ce72778ae..7e9f88dbb41 100644 --- a/applications/crossbar/src/crossbar_module_sup.erl +++ b/applications/crossbar/src/crossbar_module_sup.erl @@ -30,12 +30,12 @@ %%-------------------------------------------------------------------- %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec start_child(module()) -> sup_startchild_ret(). --spec start_child(module(), 'worker' | 'supervisor') -> sup_startchild_ret(). +-spec start_child(module()) -> kz_types:sup_startchild_ret(). +-spec start_child(module(), 'worker' | 'supervisor') -> kz_types:sup_startchild_ret(). start_child(Mod) -> start_child(Mod, 'worker'). start_child(Mod, 'worker') -> @@ -56,7 +56,7 @@ start_child(Mod, 'supervisor') -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 1000, diff --git a/applications/crossbar/src/crossbar_services.erl b/applications/crossbar/src/crossbar_services.erl index af91ad1e000..c106054c1d7 100644 --- a/applications/crossbar/src/crossbar_services.erl +++ b/applications/crossbar/src/crossbar_services.erl @@ -23,7 +23,7 @@ -type callback() :: fun(() -> cb_context:context()). -spec maybe_dry_run(cb_context:context(), callback()) -> cb_context:context(). --spec maybe_dry_run(cb_context:context(), callback(), ne_binary() | kz_proplist()) -> +-spec maybe_dry_run(cb_context:context(), callback(), kz_term:ne_binary() | kz_term:proplist()) -> cb_context:context(). maybe_dry_run(Context, Callback) -> Type = kz_doc:type(cb_context:doc(Context)), @@ -35,7 +35,7 @@ maybe_dry_run(Context, Callback, Props) -> Type = props:get_ne_binary_value(<<"type">>, Props), maybe_dry_run(Context, Callback, Type, Props, cb_context:accepting_charges(Context)). --spec maybe_dry_run(cb_context:context(), callback(), ne_binary(), kz_proplist(), boolean()) -> +-spec maybe_dry_run(cb_context:context(), callback(), kz_term:ne_binary(), kz_term:proplist(), boolean()) -> cb_context:context(). maybe_dry_run(Context, Callback, Type, Props, 'true') -> UpdatedServices = calc_service_updates(Context, Type, Props), @@ -166,9 +166,9 @@ dry_run(Services) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec calc_service_updates(cb_context:context(), ne_binary()) -> +-spec calc_service_updates(cb_context:context(), kz_term:ne_binary()) -> kz_services:services() | 'undefined'. --spec calc_service_updates(cb_context:context(), ne_binary(), kz_proplist()) -> +-spec calc_service_updates(cb_context:context(), kz_term:ne_binary(), kz_term:proplist()) -> kz_services:services() | 'undefined'. calc_service_updates(Context, <<"device">>) -> DeviceType = kz_device:device_type(cb_context:doc(Context)), @@ -227,7 +227,7 @@ calc_service_updates(_Context, _Type, _Props) -> lager:warning("unknown type ~p, cannot execute dry run", [_Type]), 'undefined'. --spec create_port_number(ne_binary(), ne_binaries()) -> knm_phone_number:knm_phone_number(). +-spec create_port_number(kz_term:ne_binary(), kz_term:ne_binaries()) -> knm_phone_number:knm_phone_number(). create_port_number(Number, Features) -> JObj = kz_json:from_list([{<<"_id">>, Number} ,{<<"features">>, Features} diff --git a/applications/crossbar/src/crossbar_sup.erl b/applications/crossbar/src/crossbar_sup.erl index 499f2f40515..97d5bd80612 100644 --- a/applications/crossbar/src/crossbar_sup.erl +++ b/applications/crossbar/src/crossbar_sup.erl @@ -43,7 +43,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -89,7 +89,7 @@ upgrade() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), {'ok', {{'one_for_one', 10, 10}, ?CHILDREN}}. diff --git a/applications/crossbar/src/crossbar_types.hrl b/applications/crossbar/src/crossbar_types.hrl index 6ffd3aafd57..f8ab31b1ede 100644 --- a/applications/crossbar/src/crossbar_types.hrl +++ b/applications/crossbar/src/crossbar_types.hrl @@ -6,28 +6,28 @@ -define(SOFT_DELETE, 'true'). -type crossbar_status() :: 'success' | 'error' | 'fatal' | 'stop'. --type crossbar_module_result() :: {crossbar_status(), kz_proplist()} | - {crossbar_status(), kz_proplist(), string()} | - {crossbar_status(), kz_proplist(), string(), integer()}. +-type crossbar_module_result() :: {crossbar_status(), kz_term:proplist()} | + {crossbar_status(), kz_term:proplist(), string()} | + {crossbar_status(), kz_term:proplist(), string(), integer()}. --type path_token() :: ne_binary(). +-type path_token() :: kz_term:ne_binary(). -type path_tokens() :: [path_token()]. -type resp_data() :: kz_json:object() | kz_json:objects() | kz_json:json_term() | kz_json:json_proplist() | - api_binary() | ne_binaries() | + kz_term:api_binary() | kz_term:ne_binaries() | map(). %% {file_name, {"contents":<>, "headers":{"content-type":"", "content-length":1}}} --type req_file() :: {ne_binary(), kz_json:object()}. +-type req_file() :: {kz_term:ne_binary(), kz_json:object()}. -type req_files() :: [req_file()]. -type req_json() :: kz_json:object() | {'malformed', binary()}. --type req_noun() :: {ne_binary(), ne_binaries()}. +-type req_noun() :: {kz_term:ne_binary(), kz_term:ne_binaries()}. -type req_nouns() :: [req_noun()]. %% {Type, SubType, Options} --type content_type() :: {ne_binary(), ne_binary(), '*' | kz_proplist()} | ne_binary(). +-type content_type() :: {kz_term:ne_binary(), kz_term:ne_binary(), '*' | kz_term:proplist()} | kz_term:ne_binary(). -type media_value() :: {content_type(), non_neg_integer(), list()}. -type media_values() :: [media_value()]. @@ -39,11 +39,11 @@ -define(MEDIA_VALUE(Type, SubType), ?MEDIA_VALUE(Type, SubType, 1000, [], [])). %% {handler_fun, {type, sub_type}} => {to_json, [{<<"application">>, <<"json">>}]} --type crossbar_content_handler() :: {atom(), kz_proplist()}. +-type crossbar_content_handler() :: {atom(), kz_term:proplist()}. -type crossbar_content_handlers() :: [crossbar_content_handler()]. --type http_method() :: ne_binary(). %% HTTP Verbs in UPPERCASE --type http_methods() :: ne_binaries(). +-type http_method() :: kz_term:ne_binary(). %% HTTP Verbs in UPPERCASE +-type http_methods() :: kz_term:ne_binaries(). -type req_verb() :: http_method(). -type validator() :: 'required' | 'not_empty' | 'is_type' @@ -56,7 +56,7 @@ -type validation_error() :: jesse_error:error_reason(). -type validation_errors() :: [validation_error()]. --type couch_doc_path() :: ne_binaries(). +-type couch_doc_path() :: kz_term:ne_binaries(). -type couch_schema() :: [{couch_doc_path(), validator_rules()}]. -type cb_cowboy_payload() :: {cowboy_req:req(), cb_context:context()}. diff --git a/applications/crossbar/src/crossbar_util.erl b/applications/crossbar/src/crossbar_util.erl index 256921a5d3c..50cc7f2f2aa 100644 --- a/applications/crossbar/src/crossbar_util.erl +++ b/applications/crossbar/src/crossbar_util.erl @@ -102,16 +102,16 @@ response(JTerm, Context) -> create_response('success', 'undefined', 'undefined', JTerm, Context). --spec response_202(api_ne_binary(), cb_context:context()) -> +-spec response_202(kz_term:api_ne_binary(), cb_context:context()) -> cb_context:context(). --spec response_202(api_ne_binary(), kz_json:json_term(), cb_context:context()) -> +-spec response_202(kz_term:api_ne_binary(), kz_json:json_term(), cb_context:context()) -> cb_context:context(). response_202(Msg, Context) -> response_202(Msg, Msg, Context). response_202(Msg, JTerm, Context) -> create_response('success', Msg, 202, JTerm, Context). --spec response_400(ne_binary(), kz_json:json_term(), cb_context:context()) -> +-spec response_400(kz_term:ne_binary(), kz_json:json_term(), cb_context:context()) -> cb_context:context(). response_400(Message, Data, Context) -> create_response('error', Message, 400, Data, Context). @@ -132,7 +132,7 @@ response_402(Data, Context) -> %% fatal or error. %% @end %%-------------------------------------------------------------------- --spec response(fails(), api_ne_binary(), cb_context:context()) -> +-spec response(fails(), kz_term:api_ne_binary(), cb_context:context()) -> cb_context:context(). response('error', Msg, Context) -> create_response('error', Msg, 500, kz_json:new(), Context); @@ -146,7 +146,7 @@ response('fatal', Msg, Context) -> %% of type fatal or error. %% @end %%-------------------------------------------------------------------- --spec response(fails(), api_ne_binary(), api_integer(), cb_context:context()) -> +-spec response(fails(), kz_term:api_ne_binary(), kz_term:api_integer(), cb_context:context()) -> cb_context:context(). response('error', Msg, Code, Context) -> create_response('error', Msg, Code, kz_json:new(), Context); @@ -160,7 +160,7 @@ response('fatal', Msg, Code, Context) -> %% of type fatal or error with additional data %% @end %%-------------------------------------------------------------------- --spec response(fails(), api_ne_binary(), api_integer(), kz_json:json_term(), cb_context:context()) -> cb_context:context(). +-spec response(fails(), kz_term:api_ne_binary(), kz_term:api_integer(), kz_json:json_term(), cb_context:context()) -> cb_context:context(). response('error', Msg, Code, JTerm, Context) -> create_response('error', Msg, Code, JTerm, Context); response('fatal', Msg, Code, JTerm, Context) -> @@ -174,7 +174,7 @@ response('fatal', Msg, Code, JTerm, Context) -> %% other parameters. %% @end %%-------------------------------------------------------------------- --spec create_response(crossbar_status(), api_ne_binary(), api_integer() +-spec create_response(crossbar_status(), kz_term:api_ne_binary(), kz_term:api_integer() ,kz_json:json_term(), cb_context:context() ) -> cb_context:context(). create_response(Status, Msg, Code, JTerm, Context) -> @@ -218,9 +218,9 @@ response_faulty_request(Context) -> response_deprecated(Context) -> create_response('error', <<"deprecated">>, 410, kz_json:new(), Context). --spec response_deprecated_redirect(cb_context:context(), ne_binary()) -> +-spec response_deprecated_redirect(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). --spec response_deprecated_redirect(cb_context:context(), ne_binary(), kz_json:object()) -> +-spec response_deprecated_redirect(cb_context:context(), kz_term:ne_binary(), kz_json:object()) -> cb_context:context(). response_deprecated_redirect(Context, RedirectUrl) -> response_deprecated_redirect(Context, RedirectUrl, kz_json:new()). @@ -229,12 +229,12 @@ response_deprecated_redirect(Context, RedirectUrl, JObj) -> ,cb_context:add_resp_header(Context, <<"Location">>, RedirectUrl) ). --spec response_redirect(cb_context:context(), ne_binary(), kz_json:object()) -> +-spec response_redirect(cb_context:context(), kz_term:ne_binary(), kz_json:object()) -> cb_context:context(). response_redirect(Context, RedirectUrl, JObj) -> response_redirect(Context, RedirectUrl, JObj, 301). --spec response_redirect(cb_context:context(), ne_binary(), kz_json:object(), pos_integer()) -> +-spec response_redirect(cb_context:context(), kz_term:ne_binary(), kz_json:object(), pos_integer()) -> cb_context:context(). response_redirect(Context, RedirectUrl, JObj, Redirect) -> create_response('error', <<"redirect">>, Redirect, JObj @@ -249,7 +249,7 @@ response_redirect(Context, RedirectUrl, JObj, Redirect) -> %% a softer not found now. %% @end %%-------------------------------------------------------------------- --spec response_bad_identifier(atom() | ne_binary(), cb_context:context()) -> +-spec response_bad_identifier(atom() | kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). response_bad_identifier(Id, Context) when is_atom(Id) -> response('error', <<"bad identifier">>, 404, [kz_term:to_binary(Id)], Context); @@ -334,7 +334,7 @@ response_db_missing(Context) -> response_db_fatal(Context) -> response('fatal', <<"datastore fatal error">>, 503, Context). --spec flush_registrations(ne_binary() | cb_context:context()) -> 'ok'. +-spec flush_registrations(kz_term:ne_binary() | cb_context:context()) -> 'ok'. flush_registrations(<<_/binary>> = Realm) -> FlushCmd = [{<<"Realm">>, Realm} | kz_api:default_headers(?APP_NAME, ?APP_VERSION) @@ -343,7 +343,7 @@ flush_registrations(<<_/binary>> = Realm) -> flush_registrations(Context) -> flush_registrations(kz_account:fetch_realm(cb_context:account_id(Context))). --spec flush_registration(api_binary(), ne_binary() | cb_context:context()) -> 'ok'. +-spec flush_registration(kz_term:api_binary(), kz_term:ne_binary() | cb_context:context()) -> 'ok'. flush_registration('undefined', _Realm) -> lager:debug("did not flush registration: username is undefined"); flush_registration(Username, <<_/binary>> = Realm) -> @@ -378,7 +378,7 @@ flush_registration(Context) -> _ = lists:foldl(Fun, 'next', Routins), 'ok'. --spec maybe_flush_registration_on_password(api_binary(), kz_json:object(), kz_json:object()) -> 'ok' | 'next'. +-spec maybe_flush_registration_on_password(kz_term:api_binary(), kz_json:object(), kz_json:object()) -> 'ok' | 'next'. maybe_flush_registration_on_password(Realm, OldDevice, NewDevice) -> case kz_device:sip_password(OldDevice) =:= kz_device:sip_password(NewDevice) of 'true' -> 'next'; @@ -387,7 +387,7 @@ maybe_flush_registration_on_password(Realm, OldDevice, NewDevice) -> flush_registration(kz_device:sip_username(OldDevice), Realm) end. --spec maybe_flush_registration_on_username(api_binary(), kz_json:object(), kz_json:object()) -> 'ok' | 'next'. +-spec maybe_flush_registration_on_username(kz_term:api_binary(), kz_json:object(), kz_json:object()) -> 'ok' | 'next'. maybe_flush_registration_on_username(Realm, OldDevice, NewDevice) -> OldUsername = kz_device:sip_username(OldDevice), @@ -399,7 +399,7 @@ maybe_flush_registration_on_username(Realm, OldDevice, NewDevice) -> flush_registration(NewUsername, Realm) end. --spec maybe_flush_registration_on_ownerid(api_binary(), kz_json:object(), kz_json:object()) -> 'ok' | 'next'. +-spec maybe_flush_registration_on_ownerid(kz_term:api_binary(), kz_json:object(), kz_json:object()) -> 'ok' | 'next'. maybe_flush_registration_on_ownerid(Realm, OldDevice, NewDevice) -> OldOwnerId = kz_device:owner_id(OldDevice), @@ -410,7 +410,7 @@ maybe_flush_registration_on_ownerid(Realm, OldDevice, NewDevice) -> flush_registration(kz_device:sip_username(OldDevice), Realm) end. --spec maybe_flush_registration_on_enabled(api_binary(), kz_json:object(), kz_json:object()) -> 'ok' | 'next'. +-spec maybe_flush_registration_on_enabled(kz_term:api_binary(), kz_json:object(), kz_json:object()) -> 'ok' | 'next'. maybe_flush_registration_on_enabled(Realm, OldDevice, NewDevice) -> OldEnabled = kz_device:enabled(OldDevice), @@ -421,7 +421,7 @@ maybe_flush_registration_on_enabled(Realm, OldDevice, NewDevice) -> flush_registration(kz_device:sip_username(OldDevice), Realm) end. --spec maybe_flush_registration_on_deleted(api_binary(), kz_json:object(), kz_json:object()) -> 'ok' | 'next'. +-spec maybe_flush_registration_on_deleted(kz_term:api_binary(), kz_json:object(), kz_json:object()) -> 'ok' | 'next'. maybe_flush_registration_on_deleted(Realm, _OldDevice, NewDevice) -> case kz_doc:is_soft_deleted(NewDevice) orelse kz_doc:is_deleted(NewDevice) @@ -437,10 +437,10 @@ maybe_flush_registration_on_deleted(Realm, _OldDevice, NewDevice) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec move_account(ne_binary(), ne_binary()) -> +-spec move_account(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. --spec move_account(ne_binary(), kz_json:object(), ne_binary(), ne_binaries()) -> +-spec move_account(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary(), kz_term:ne_binaries()) -> {'ok', kz_json:object()} | {'error', any()}. move_account(?MATCH_ACCOUNT_RAW(AccountId), ToAccount=?NE_BINARY) -> @@ -473,9 +473,9 @@ move_account(AccountId, JObj, ToAccount, ToTree) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec validate_move(ne_binary(), ne_binary()) -> +-spec validate_move(kz_term:ne_binary(), kz_term:ne_binary()) -> {'error', any()} | - {'ok', kz_json:object(), ne_binaries()}. + {'ok', kz_json:object(), kz_term:ne_binaries()}. validate_move(AccountId, ToAccount) -> case kz_account:fetch(AccountId) of {'error', _E}=Error -> Error; @@ -492,13 +492,13 @@ validate_move(AccountId, ToAccount) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec move_descendants(ne_binary(), ne_binaries(), ne_binary()) -> +-spec move_descendants(kz_term:ne_binary(), kz_term:ne_binaries(), kz_term:ne_binary()) -> {'ok', 'done'} | {'error', any()}. move_descendants(?MATCH_ACCOUNT_RAW(AccountId), Tree, NewResellerId) -> update_descendants_tree(get_descendants(AccountId), Tree, NewResellerId, AccountId). --spec update_descendants_tree(ne_binaries(), ne_binaries(), ne_binary(), ne_binary()) -> +-spec update_descendants_tree(kz_term:ne_binaries(), kz_term:ne_binaries(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', 'done'} | {'error', any()}. update_descendants_tree([], _, _, _) -> {'ok', 'done'}; @@ -531,7 +531,7 @@ update_descendants_tree([Descendant|Descendants], Tree, NewResellerId, MovedAcco %% @doc %% @end %%-------------------------------------------------------------------- --spec move_service(ne_binary(), ne_binaries(), ne_binary(), api_boolean()) -> +-spec move_service(kz_term:ne_binary(), kz_term:ne_binaries(), kz_term:ne_binary(), kz_term:api_boolean()) -> {'ok', kz_json:object()} | {'error', any()}. move_service(AccountId, NewTree, NewResellerId, Dirty) -> @@ -555,7 +555,7 @@ move_service(AccountId, NewTree, NewResellerId, Dirty) -> %% Return all descendants of the account id %% @end %%-------------------------------------------------------------------- --spec get_descendants(ne_binary()) -> ne_binaries(). +-spec get_descendants(kz_term:ne_binary()) -> kz_term:ne_binaries(). get_descendants(?MATCH_ACCOUNT_RAW(AccountId)) -> kapps_util:account_descendants(AccountId) -- [AccountId]. @@ -564,7 +564,7 @@ get_descendants(?MATCH_ACCOUNT_RAW(AccountId)) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_tree(ne_binary()) -> ne_binaries(). +-spec get_tree(kz_term:ne_binary()) -> kz_term:ne_binaries(). get_tree(<<_/binary>> = Account) -> case kz_account:fetch(Account) of {'ok', JObj} -> kz_account:tree(JObj); @@ -595,7 +595,7 @@ replicate_account_definition(JObj) -> %% Flag all descendants of the account id as disabled %% @end %%-------------------------------------------------------------------- --spec disable_account(api_binary()) -> 'ok' | {'error', any()}. +-spec disable_account(kz_term:api_binary()) -> 'ok' | {'error', any()}. disable_account('undefined') -> 'ok'; disable_account(AccountId) -> ViewOptions = [{'startkey', [AccountId]} @@ -616,7 +616,7 @@ disable_account(AccountId) -> %% Flag all descendants of the account id as enabled %% @end %%-------------------------------------------------------------------- --spec enable_account(api_binary()) -> 'ok' | {'error', any()}. +-spec enable_account(kz_term:api_binary()) -> 'ok' | {'error', any()}. enable_account('undefined') -> ok; enable_account(AccountId) -> ViewOptions = [{'startkey', [AccountId]} @@ -639,9 +639,9 @@ enable_account(AccountId) -> %%-------------------------------------------------------------------- -spec response_auth(kz_json:object()) -> kz_json:object(). --spec response_auth(kz_json:object(), api_binary()) -> +-spec response_auth(kz_json:object(), kz_term:api_binary()) -> kz_json:object(). --spec response_auth(kz_json:object(), api_binary(), api_binary()) -> +-spec response_auth(kz_json:object(), kz_term:api_binary(), kz_term:api_binary()) -> kz_json:object(). response_auth(JObj) -> AccountId = kz_json:get_first_defined([<<"account_id">>, <<"pvt_account_id">>], JObj), @@ -655,7 +655,7 @@ response_auth(JObj, AccountId) -> response_auth(JObj, AccountId, UserId) -> populate_resp(JObj, AccountId, UserId). --spec populate_resp(kz_json:object(), api_binary(), api_binary()) -> kz_json:object(). +-spec populate_resp(kz_json:object(), kz_term:api_binary(), kz_term:api_binary()) -> kz_json:object(). populate_resp(JObj, 'undefined', _UserId) -> JObj; populate_resp(JObj, AccountId, UserId) -> Language = get_language(AccountId, UserId), @@ -673,12 +673,12 @@ populate_resp(JObj, AccountId, UserId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec load_apps(ne_binary(), ne_binary()) -> kz_json:objects(). +-spec load_apps(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:objects(). load_apps(AccountId, UserId) -> Language = get_language(AccountId, UserId), load_apps(AccountId, UserId, Language). --spec load_apps(ne_binary(), ne_binary(), ne_binary()) -> kz_json:objects(). +-spec load_apps(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:objects(). load_apps(AccountId, UserId, Language) -> AppJObjs = cb_apps_util:authorized_apps(AccountId, UserId), [format_app(Language, AppJObj) @@ -690,7 +690,7 @@ load_apps(AccountId, UserId, Language) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec format_app(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec format_app(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). format_app(Lang, AppJObj) -> I18N = kzd_app:i18n(AppJObj), DefaultLabel = kz_json:get_value([?DEFAULT_LANGUAGE, <<"label">>], I18N), @@ -708,7 +708,7 @@ format_app(Lang, AppJObj) -> %% Update all descendants of the account id pvt_enabled flag with State %% @end %%-------------------------------------------------------------------- --spec change_pvt_enabled(boolean(), api_ne_binary()) -> ok | {error, any()}. +-spec change_pvt_enabled(boolean(), kz_term:api_ne_binary()) -> ok | {error, any()}. change_pvt_enabled(_, 'undefined') -> 'ok'; change_pvt_enabled(State, AccountId) -> AccountDb = kz_util:format_account_id(AccountId, 'encoded'), @@ -738,8 +738,8 @@ change_pvt_enabled(State, AccountId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_language(ne_binary()) -> ne_binary(). --spec get_language(ne_binary(), api_binary()) -> ne_binary(). +-spec get_language(kz_term:ne_binary()) -> kz_term:ne_binary(). +-spec get_language(kz_term:ne_binary(), kz_term:api_binary()) -> kz_term:ne_binary(). get_language(AccountId) -> case get_account_lang(AccountId) of {'ok', Lang} -> Lang; @@ -761,7 +761,7 @@ get_language(AccountId, UserId) -> end end. --spec get_user_lang(ne_binary(), ne_binary()) -> 'error' | {'ok', ne_binary()}. +-spec get_user_lang(kz_term:ne_binary(), kz_term:ne_binary()) -> 'error' | {'ok', kz_term:ne_binary()}. get_user_lang(AccountId, UserId) -> case kzd_user:fetch(AccountId, UserId) of {'ok', UserJObj} -> @@ -774,7 +774,7 @@ get_user_lang(AccountId, UserId) -> 'error' end. --spec get_account_lang(ne_binary()) -> 'error' | {'ok', ne_binary()}. +-spec get_account_lang(kz_term:ne_binary()) -> 'error' | {'ok', kz_term:ne_binary()}. get_account_lang(AccountId) -> case kz_account:fetch(AccountId) of {'ok', AccountJObj} -> @@ -787,14 +787,14 @@ get_account_lang(AccountId) -> 'error' end. --spec get_user_timezone(api_ne_binary(), api_ne_binary()) -> ne_binary(). +-spec get_user_timezone(kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> kz_term:ne_binary(). get_user_timezone(AccountId, UserId) -> case kzd_user:fetch(AccountId, UserId) of {'ok', UserJObj} -> kzd_user:timezone(UserJObj); {'error', _E} -> kz_account:timezone(AccountId) end. --spec apply_response_map(cb_context:context(), kz_proplist()) -> cb_context:context(). +-spec apply_response_map(cb_context:context(), kz_term:proplist()) -> cb_context:context(). apply_response_map(Context, Map) -> JObj = cb_context:doc(Context), RespData = lists:foldl(fun(MapItem, J) -> @@ -815,7 +815,7 @@ apply_response_map_item({Key, Fun}, J, JObj) when is_function(Fun, 2) -> apply_response_map_item({Key, ExistingKey}, J, JObj) -> kz_json:set_value(Key, kz_json:get_value(ExistingKey, JObj), J). --spec get_path(cowboy_req:req() | ne_binary(), ne_binary()) -> ne_binary(). +-spec get_path(cowboy_req:req() | kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). get_path(<<_/binary>> = RawPath, Relative) -> kz_util:resolve_uri(RawPath, Relative); get_path(Req, Relative) -> @@ -880,8 +880,8 @@ create_auth_token(Context, AuthModule, JObj) -> cb_context:add_system_error('invalid_credentials', Context) end. --spec get_token_restrictions(atom(), ne_binary(), ne_binary()) -> - api_object(). +-spec get_token_restrictions(atom(), kz_term:ne_binary(), kz_term:ne_binary()) -> + kz_term:api_object(). get_token_restrictions(AuthModule, AccountId, OwnerId) -> case kz_util:is_system_admin(AccountId) of 'true' -> 'undefined'; @@ -895,7 +895,7 @@ get_token_restrictions(AuthModule, AccountId, OwnerId) -> get_priv_level_restrictions(Restrictions, PrivLevel) end. --spec get_priv_level(ne_binary(), ne_binary()) -> api_binary(). +-spec get_priv_level(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_binary(). %% for api_auth tokens we force "admin" priv_level get_priv_level(_AccountId, 'undefined') -> cb_token_restrictions:default_priv_level(); @@ -906,14 +906,14 @@ get_priv_level(AccountId, OwnerId) -> {'error', _} -> cb_token_restrictions:default_priv_level() end. --spec get_system_token_restrictions(atom()) -> api_object(). +-spec get_system_token_restrictions(atom()) -> kz_term:api_object(). get_system_token_restrictions(AuthModule) -> case cb_token_restrictions:method_restrictions(AuthModule) of 'undefined' -> cb_token_restrictions:default_method_restrictions(); MethodRestrictions -> MethodRestrictions end. --spec get_account_token_restrictions(ne_binary(), atom()) -> api_object(). +-spec get_account_token_restrictions(kz_term:ne_binary(), atom()) -> kz_term:api_object(). get_account_token_restrictions(AccountId, AuthModule) -> AccountDB = kz_util:format_account_db(AccountId), case kz_datamgr:open_cache_doc(AccountDB, ?CB_ACCOUNT_TOKEN_RESTRICTIONS) of @@ -926,7 +926,7 @@ get_account_token_restrictions(AccountId, AuthModule) -> ) end. --spec get_priv_level_restrictions(api_object(), ne_binary()) -> api_object(). +-spec get_priv_level_restrictions(kz_term:api_object(), kz_term:ne_binary()) -> kz_term:api_object(). get_priv_level_restrictions('undefined', _PrivLevel) -> 'undefined'; get_priv_level_restrictions(Restrictions, PrivLevel) -> @@ -943,7 +943,7 @@ get_priv_level_restrictions(Restrictions, PrivLevel) -> %% @end %%-------------------------------------------------------------------- -spec descendants_count() -> 'ok'. --spec descendants_count(kz_proplist() | ne_binary()) -> 'ok'. +-spec descendants_count(kz_term:proplist() | kz_term:ne_binary()) -> 'ok'. descendants_count() -> Limit = kapps_config:get_integer(?SYSCONFIG_COUCH, <<"default_chunk_size">>, 1000), ViewOptions = [{'limit', Limit} @@ -968,7 +968,7 @@ descendants_count(Opts) -> handle_descendant_counts(ViewOptions, Counts) end. --spec handle_descendant_counts(kz_proplist(), kz_proplist()) -> 'ok'. +-spec handle_descendant_counts(kz_term:proplist(), kz_term:proplist()) -> 'ok'. handle_descendant_counts(ViewOptions, Counts) -> _ = [maybe_update_descendants_count(AccountId, Count) || {AccountId, Count} <- Counts @@ -981,7 +981,7 @@ handle_descendant_counts(ViewOptions, Counts) -> descendants_count(props:set_value('skip', Skip+Limit, ViewOptions)) end. --spec handle_no_descendants(kz_proplist()) -> 'ok'. +-spec handle_no_descendants(kz_term:proplist()) -> 'ok'. handle_no_descendants(ViewOptions) -> case props:get_value('key', ViewOptions) of 'undefined' -> 'ok'; @@ -1093,7 +1093,7 @@ servers_changed(Servers1, Servers2) -> ,Servers1 ). --spec server_changed(kz_json:object(), api_object()) -> boolean(). +-spec server_changed(kz_json:object(), kz_term:api_object()) -> boolean(). server_changed(_Server, 'undefined') -> lager:debug("server ~s existence has changed", [kz_json:get_value(<<"server_name">>, _Server)]), 'true'; @@ -1126,7 +1126,7 @@ refresh_fs_xml(Context) -> DbDoc = cb_context:fetch(Context, 'db_doc'), refresh_fs_xml(Realm, DbDoc). --spec refresh_fs_xml(ne_binary(), kz_json:object()) -> 'ok'. +-spec refresh_fs_xml(kz_term:ne_binary(), kz_json:object()) -> 'ok'. refresh_fs_xml(Realm, Doc) -> case kz_device:sip_username(Doc, kz_json:get_value(<<"username">>, Doc)) of 'undefined' -> 'ok'; @@ -1140,7 +1140,7 @@ refresh_fs_xml(Realm, Doc) -> end. %% @public --spec get_devices_by_owner(ne_binary(), api_binary()) -> ne_binaries(). +-spec get_devices_by_owner(kz_term:ne_binary(), kz_term:api_binary()) -> kz_term:ne_binaries(). get_devices_by_owner(_AccountDb, 'undefined') -> []; get_devices_by_owner(AccountDb, OwnerId) -> ViewOptions = [{'key', [OwnerId, <<"device">>]}, @@ -1153,7 +1153,7 @@ get_devices_by_owner(AccountDb, OwnerId) -> [] end. --spec get_account_devices(api_binary()) -> ne_binaries(). +-spec get_account_devices(kz_term:api_binary()) -> kz_term:ne_binaries(). get_account_devices('undefined') -> []; get_account_devices(Account) -> AccountDb = kz_util:format_account_db(Account), @@ -1170,8 +1170,8 @@ get_account_devices(Account) -> %% %% @end %%-------------------------------------------------------------------- --spec load_descendants_count(kz_proplist()) -> - {'ok', kz_proplist()} | +-spec load_descendants_count(kz_term:proplist()) -> + {'ok', kz_term:proplist()} | {'error', any()}. load_descendants_count(ViewOptions) -> case kz_datamgr:get_results(?KZ_ACCOUNTS_DB, <<"accounts/listing_by_descendants_count">>, ViewOptions) of @@ -1191,10 +1191,10 @@ load_descendants_count(ViewOptions) -> %% %% @end %%-------------------------------------------------------------------- --spec maybe_update_descendants_count(ne_binary(), integer()) -> 'ok'. --spec maybe_update_descendants_count(ne_binary(), integer(), integer()) -> 'ok'. --spec maybe_update_descendants_count(ne_binary(), kz_json:object(), integer(), integer()) -> 'ok'. --spec maybe_update_descendants_count(ne_binary(), kz_json:object(), integer(), integer(), integer()) -> 'ok'. +-spec maybe_update_descendants_count(kz_term:ne_binary(), integer()) -> 'ok'. +-spec maybe_update_descendants_count(kz_term:ne_binary(), integer(), integer()) -> 'ok'. +-spec maybe_update_descendants_count(kz_term:ne_binary(), kz_json:object(), integer(), integer()) -> 'ok'. +-spec maybe_update_descendants_count(kz_term:ne_binary(), kz_json:object(), integer(), integer(), integer()) -> 'ok'. maybe_update_descendants_count(AccountId, NewCount) -> maybe_update_descendants_count(AccountId, NewCount, 3). @@ -1227,7 +1227,7 @@ maybe_update_descendants_count(AccountId, JObj, NewCount, _, Try) -> %% %% @end %%-------------------------------------------------------------------- --spec update_descendants_count(ne_binary(), kz_json:object(), integer()) -> 'ok' | 'error'. +-spec update_descendants_count(kz_term:ne_binary(), kz_json:object(), integer()) -> 'ok' | 'error'. update_descendants_count(AccountId, JObj, NewCount) -> AccountDb = kz_util:format_account_id(AccountId, 'encoded'), Doc = kz_json:set_value(<<"descendants_count">>, NewCount, JObj), diff --git a/applications/crossbar/src/crossbar_view.erl b/applications/crossbar/src/crossbar_view.erl index a970ae2aaf0..905396aa6f5 100644 --- a/applications/crossbar/src/crossbar_view.erl +++ b/applications/crossbar/src/crossbar_view.erl @@ -48,7 +48,7 @@ -type direction() :: 'ascending' | 'descending'. --type time_range() :: {gregorian_seconds(), gregorian_seconds()}. +-type time_range() :: {kz_time:gregorian_seconds(), kz_time:gregorian_seconds()}. -type api_range_key() :: 'undefined' | ['undefined'] | kazoo_data:range_key(). -type range_keys() :: {api_range_key(), api_range_key()}. @@ -57,7 +57,7 @@ fun((cb_context:context(), kazoo_data:view_options()) -> api_range_key()). -type keymap() :: api_range_key() | keymap_fun(). --type range_keymap_fun() :: fun((gregorian_seconds()) -> api_range_key()). +-type range_keymap_fun() :: fun((kz_time:gregorian_seconds()) -> api_range_key()). -type range_keymap() :: 'nil' | api_range_key() | range_keymap_fun(). -type user_mapper_fun() :: 'undefined' | @@ -70,7 +70,7 @@ fun((kz_json:object(), kz_json:objects()) -> kz_json:objects()). -type options() :: kazoo_data:view_options() | - [{'databases', ne_binaries()} | + [{'databases', kz_term:ne_binaries()} | {'mapper', user_mapper_fun()} | {'max_range', pos_integer()} | @@ -88,16 +88,16 @@ {'created_to', pos_integer()} | {'range_end_keymap', range_keymap()} | {'range_keymap', range_keymap()} | - {'range_key_name', ne_binary()} | + {'range_key_name', kz_term:ne_binary()} | {'range_start_keymap', range_keymap()} ]. -type load_params() :: #{chunk_size => pos_integer() ,context => cb_context:context() - ,databases => ne_binaries() + ,databases => kz_term:ne_binaries() ,direction => direction() ,end_key => kazoo_data:range_key() - ,end_time => gregorian_seconds() + ,end_time => kz_time:gregorian_seconds() ,has_qs_filter => boolean() ,is_chunked => boolean() ,last_key => last_key() @@ -106,9 +106,9 @@ ,queried_jobjs => kz_json:objects() ,should_paginate => boolean() ,start_key => kazoo_data:range_key() - ,start_time => gregorian_seconds() + ,start_time => kz_time:gregorian_seconds() ,total_queried => non_neg_integer() - ,view => ne_binary() + ,view => kz_term:ne_binary() ,view_options => kazoo_data:view_options() }. @@ -128,7 +128,7 @@ %% Equivalent of load/3, setting Options to an empty list. %% @end %%-------------------------------------------------------------------- --spec load(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec load(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load(Context, View) -> load(Context, View, []). @@ -139,7 +139,7 @@ load(Context, View) -> %% run against the accounts database. %% @end %%-------------------------------------------------------------------- --spec load(cb_context:context(), ne_binary(), options()) -> cb_context:context(). +-spec load(cb_context:context(), kz_term:ne_binary(), options()) -> cb_context:context(). load(Context, View, Options) -> load_view(build_load_params(Context, View, Options), Context). @@ -149,7 +149,7 @@ load(Context, View, Options) -> %% Equivalent of load/3, setting Options to an empty list. %% @end %%-------------------------------------------------------------------- --spec load_range(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec load_range(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_range(Context, View) -> load_range(Context, View, []). @@ -160,7 +160,7 @@ load_range(Context, View) -> %% results of a view run against the accounts database. %% @end %%-------------------------------------------------------------------- --spec load_range(cb_context:context(), ne_binary(), options()) -> cb_context:context(). +-spec load_range(cb_context:context(), kz_term:ne_binary(), options()) -> cb_context:context(). load_range(Context, View, Options) -> load_view(build_load_range_params(Context, View, Options), Context). @@ -170,7 +170,7 @@ load_range(Context, View, Options) -> %% Equivalent of load_modb/3, setting Options to an empty list. %% @end %%-------------------------------------------------------------------- --spec load_modb(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec load_modb(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_modb(Context, View) -> load_modb(Context, View, []). @@ -181,7 +181,7 @@ load_modb(Context, View) -> %% run against the account's MODBs. %% @end %%-------------------------------------------------------------------- --spec load_modb(cb_context:context(), ne_binary(), options()) -> cb_context:context(). +-spec load_modb(cb_context:context(), kz_term:ne_binary(), options()) -> cb_context:context(). load_modb(Context, View, Options) -> load_view(build_load_modb_params(Context, View, Options), Context). @@ -191,7 +191,7 @@ load_modb(Context, View, Options) -> %% Generates corssbar_view options map for querying view. %% @end %%-------------------------------------------------------------------- --spec build_load_params(cb_context:context(), ne_binary(), options()) -> load_params() | cb_context:context(). +-spec build_load_params(cb_context:context(), kz_term:ne_binary(), options()) -> load_params() | cb_context:context(). build_load_params(Context, View, Options) -> try build_general_load_params(Context, View, Options) of #{direction := Direction}=LoadMap -> @@ -215,7 +215,7 @@ build_load_params(Context, View, Options) -> cb_context:add_system_error('datastore_fault', Context) end. --spec build_load_range_params(cb_context:context(), ne_binary(), options()) -> +-spec build_load_range_params(cb_context:context(), kz_term:ne_binary(), options()) -> load_params() | cb_context:context(). build_load_range_params(Context, View, Options) -> try build_general_load_params(Context, View, Options) of @@ -254,7 +254,7 @@ build_load_range_params(Context, View, Options) -> %% Generates corssbar_view options map for querying MODBs view. %% @end %%-------------------------------------------------------------------- --spec build_load_modb_params(cb_context:context(), ne_binary(), options()) -> +-spec build_load_modb_params(cb_context:context(), kz_term:ne_binary(), options()) -> load_params() | cb_context:context(). build_load_modb_params(Context, View, Options) -> case build_load_range_params(Context, View, Options) of @@ -370,7 +370,7 @@ ranged_start_end_keys(Context, Options) -> %% The keys will be swapped if direction is descending. %% @end %%-------------------------------------------------------------------- --spec ranged_start_end_keys(cb_context:cb_context(), options(), direction(), gregorian_seconds(), gregorian_seconds()) -> range_keys(). +-spec ranged_start_end_keys(cb_context:cb_context(), options(), direction(), kz_time:gregorian_seconds(), kz_time:gregorian_seconds()) -> range_keys(). ranged_start_end_keys(Context, Options, Direction, StartTime, EndTime) -> {StartKeyMap, EndKeyMap} = get_range_key_maps(Options), case {cb_context:req_value(Context, <<"start_key">>) @@ -459,7 +459,7 @@ time_range(Context) -> time_range(Context, []). time_range(Context, Options) -> time_range(Context, Options, props:get_ne_binary_value('range_key_name', Options, <<"created">>)). --spec time_range(cb_context:context(), options(), ne_binary()) -> time_range() | cb_context:context(). +-spec time_range(cb_context:context(), options(), kz_term:ne_binary()) -> time_range() | cb_context:context(). time_range(Context, Options, Key) -> MaxRange = get_max_range(Options), TSTime = kz_time:now_s(), @@ -474,7 +474,7 @@ time_range(Context, Options, Key) -> %% tuple `{start_time, end_time}` or `context` with validation error. %% @end %%-------------------------------------------------------------------- --spec time_range(cb_context:context(), pos_integer(), ne_binary(), pos_integer(), pos_integer()) -> +-spec time_range(cb_context:context(), pos_integer(), kz_term:ne_binary(), pos_integer(), pos_integer()) -> time_range() | cb_context:context(). time_range(Context, MaxRange, Key, RangeFrom, RangeTo) -> Path = <>, @@ -717,7 +717,7 @@ get_results(#{databases := [Db|RestDbs]=Dbs %% we're done or shall we continue. %% @end %%-------------------------------------------------------------------- --spec handle_query_result(load_params(), ne_binaries(), kz_json:objects(), api_pos_integer()) -> +-spec handle_query_result(load_params(), kz_term:ne_binaries(), kz_json:objects(), kz_term:api_pos_integer()) -> load_params(). handle_query_result(#{last_key := LastKey ,mapper := Mapper @@ -791,8 +791,8 @@ check_page_size_and_length(#{total_queried := TotalQueried %% amount to satisfy page_size %% @end %%-------------------------------------------------------------------- --spec limit_with_last_key(boolean(), api_pos_integer(), pos_integer(), non_neg_integer()) -> - api_pos_integer(). +-spec limit_with_last_key(boolean(), kz_term:api_pos_integer(), pos_integer(), non_neg_integer()) -> + kz_term:api_pos_integer(). %% non-chunked unlimited request => no limit limit_with_last_key('false', 'undefined', _, _) -> 'undefined'; @@ -893,7 +893,7 @@ add_paging(StartKey, PageSize, NextStartKey, JObj) -> %% Generates general corssbar_view options map for querying view. %% @end %%-------------------------------------------------------------------- --spec build_general_load_params(cb_context:context(), ne_binary(), options()) -> load_params() | cb_context:context(). +-spec build_general_load_params(cb_context:context(), kz_term:ne_binary(), options()) -> load_params() | cb_context:context(). build_general_load_params(Context, View, Options) -> Direction = direction(Context, Options), try maps:from_list( @@ -928,8 +928,8 @@ is_chunked(Context, Options) -> %% direction. %% @end %%-------------------------------------------------------------------- --spec get_range_modbs(cb_context:context(), options(), direction(), gregorian_seconds(), gregorian_seconds()) -> - ne_binaries(). +-spec get_range_modbs(cb_context:context(), options(), direction(), kz_time:gregorian_seconds(), kz_time:gregorian_seconds()) -> + kz_term:ne_binaries(). get_range_modbs(Context, Options, Direction, StartTime, EndTime) -> case props:get_value('databases', Options) of 'undefined' when Direction =:= 'ascending' -> @@ -942,7 +942,7 @@ get_range_modbs(Context, Options, Direction, StartTime, EndTime) -> lists:reverse(lists:usort(Dbs)) end. --spec get_chunk_size(cb_context:context(), options()) -> api_pos_integer(). +-spec get_chunk_size(cb_context:context(), options()) -> kz_term:api_pos_integer(). get_chunk_size(Context, Options) -> SystemSize = kapps_config:get_pos_integer(?CONFIG_CAT, <<"load_view_chunk_size">>, 50), OptionsSize = props:get_integer_value('chunk_size', Options, SystemSize), @@ -978,7 +978,7 @@ maybe_set_start_end_keys(LoadMap, StartKey, EndKey) -> LoadMap#{start_key => Sta %% Note: DO NOT ADD ONE (1) TO PAGE_SIZE/LIMIT! Load function will add it. %% @end %%-------------------------------------------------------------------- --spec get_page_size(cb_context:context(), options()) -> api_pos_integer(). +-spec get_page_size(cb_context:context(), options()) -> kz_term:api_pos_integer(). get_page_size(Context, Options) -> case cb_context:should_paginate(Context) of 'true' -> @@ -1015,7 +1015,7 @@ get_page_size_from_request(Context) -> %% Get time key value from options or request. %% @end %%-------------------------------------------------------------------- --spec get_time_key(cb_context:context(), ne_binary(), options(), pos_integer()) -> pos_integer(). +-spec get_time_key(cb_context:context(), kz_term:ne_binary(), options(), pos_integer()) -> pos_integer(). get_time_key(Context, Key, Options, Default) -> case props:get_integer_value(Key, Options) of 'undefined' -> diff --git a/applications/crossbar/src/modules/cb_accounts.erl b/applications/crossbar/src/modules/cb_accounts.erl index 92a4c24b122..62a08133529 100644 --- a/applications/crossbar/src/modules/cb_accounts.erl +++ b/applications/crossbar/src/modules/cb_accounts.erl @@ -93,14 +93,14 @@ init() -> %%-------------------------------------------------------------------- -spec allowed_methods() -> http_methods(). -spec allowed_methods(path_token()) -> http_methods(). --spec allowed_methods(path_token(), ne_binary()) -> http_methods(). +-spec allowed_methods(path_token(), kz_term:ne_binary()) -> http_methods(). allowed_methods() -> [?HTTP_PUT]. allowed_methods(AccountId) -> allowed_methods_on_account(AccountId, kapps_util:get_master_account_id()). --spec allowed_methods_on_account(ne_binary(), {'ok', ne_binary()} | {'error', any()}) -> +-spec allowed_methods_on_account(kz_term:ne_binary(), {'ok', kz_term:ne_binary()} | {'error', any()}) -> http_methods(). allowed_methods_on_account(AccountId, {'ok', AccountId}) -> lager:debug("accessing master account, disallowing DELETE"), @@ -133,7 +133,7 @@ allowed_methods(_AccountId, ?PARENTS) -> [?HTTP_GET]. %%-------------------------------------------------------------------- -spec resource_exists() -> 'true'. -spec resource_exists(path_token()) -> 'true'. --spec resource_exists(path_token(), ne_binary()) -> boolean(). +-spec resource_exists(path_token(), kz_term:ne_binary()) -> boolean(). resource_exists() -> 'true'. resource_exists(_) -> 'true'. resource_exists(_, Path) -> @@ -159,7 +159,7 @@ resource_exists(_, Path) -> %%-------------------------------------------------------------------- -spec validate_resource(cb_context:context()) -> cb_context:context(). -spec validate_resource(cb_context:context(), path_token()) -> cb_context:context(). --spec validate_resource(cb_context:context(), path_token(), ne_binary()) -> cb_context:context(). +-spec validate_resource(cb_context:context(), path_token(), kz_term:ne_binary()) -> cb_context:context(). validate_resource(Context) -> Context. validate_resource(Context, AccountId) -> @@ -180,7 +180,7 @@ validate_resource(Context, AccountId, _Path) -> cb_context:context(). -spec validate(cb_context:context(), path_token()) -> cb_context:context(). --spec validate(cb_context:context(), path_token(), ne_binary()) -> +-spec validate(cb_context:context(), path_token(), kz_term:ne_binary()) -> cb_context:context(). validate(Context) -> @@ -193,7 +193,7 @@ validate_accounts(Context, ?HTTP_PUT) -> validate(Context, AccountId) -> validate_account(Context, AccountId, cb_context:req_verb(Context)). --spec validate_account(cb_context:context(), ne_binary(), http_method()) -> cb_context:context(). +-spec validate_account(cb_context:context(), kz_term:ne_binary(), http_method()) -> cb_context:context(). validate_account(Context, AccountId, ?HTTP_GET) -> load_account(AccountId, prepare_context(AccountId, Context)); validate_account(Context, _AccountId, ?HTTP_PUT) -> @@ -208,7 +208,7 @@ validate_account(Context, AccountId, ?HTTP_DELETE) -> validate(Context, AccountId, PathToken) -> validate_account_path(Context, AccountId, PathToken, cb_context:req_verb(Context)). --spec validate_account_path(cb_context:context(), ne_binary(), ne_binary(), http_method()) -> +-spec validate_account_path(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary(), http_method()) -> cb_context:context(). validate_account_path(Context, AccountId, ?CHILDREN, ?HTTP_GET) -> load_children(AccountId, prepare_context('undefined', Context)); @@ -320,7 +320,7 @@ patch(Context, AccountId) -> %% @end %%-------------------------------------------------------------------- -spec put(cb_context:context()) -> cb_context:context(). --spec put(cb_context:context(), api_binary()) -> cb_context:context(). +-spec put(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). -spec put(cb_context:context(), path_token(), path_token()) -> cb_context:context(). put(Context) -> @@ -403,7 +403,7 @@ delete(Context, AccountId, ?RESELLER) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec maybe_update_descendants_count(ne_binaries()) -> 'ok'. +-spec maybe_update_descendants_count(kz_term:ne_binaries()) -> 'ok'. maybe_update_descendants_count([]) -> 'ok'; maybe_update_descendants_count(Tree) -> _ = kz_util:spawn(fun crossbar_util:descendants_count/1, [lists:last(Tree)]), @@ -414,7 +414,7 @@ maybe_update_descendants_count(Tree) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec create_apps_store_doc(ne_binary()) -> 'ok'. +-spec create_apps_store_doc(kz_term:ne_binary()) -> 'ok'. create_apps_store_doc(AccountId) -> _ = kz_util:spawn(fun cb_apps_util:create_apps_store_doc/1, [AccountId]), 'ok'. @@ -424,7 +424,7 @@ create_apps_store_doc(AccountId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec validate_move(ne_binary(), cb_context:context(), ne_binary(), ne_binary()) -> boolean(). +-spec validate_move(kz_term:ne_binary(), cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). validate_move(<<"superduper_admin">>, Context, _, _) -> lager:debug("using superduper_admin flag to allow move account"), AuthId = kz_json:get_value(<<"account_id">>, cb_context:auth_doc(Context)), @@ -453,7 +453,7 @@ validate_move(_Type, _, _, _) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec move_account(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec move_account(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). move_account(Context, AccountId) -> Data = cb_context:req_data(Context), ToAccount = kz_json:get_binary_value(<<"to">>, Data), @@ -470,8 +470,8 @@ move_account(Context, AccountId) -> %% %% @end %%-------------------------------------------------------------------- --spec prepare_context(api_ne_binary(), cb_context:context()) -> cb_context:context(). --spec prepare_context(cb_context:context(), ne_binary(), ne_binary()) -> cb_context:context(). +-spec prepare_context(kz_term:api_ne_binary(), cb_context:context()) -> cb_context:context(). +-spec prepare_context(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). prepare_context('undefined', Context) -> cb_context:set_account_db(Context, ?KZ_ACCOUNTS_DB); prepare_context(Account, Context) -> @@ -490,7 +490,7 @@ prepare_context(Context, AccountId, AccountDb) -> %% %% @end %%-------------------------------------------------------------------- --spec validate_request(api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_request(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_request(AccountId, Context) -> ValidateFuns = [fun ensure_account_has_realm/2 ,fun ensure_account_has_timezone/2 @@ -507,7 +507,7 @@ validate_request(AccountId, Context) -> ,ValidateFuns ). --spec ensure_account_has_realm(api_binary(), cb_context:context()) -> cb_context:context(). +-spec ensure_account_has_realm(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). ensure_account_has_realm(_AccountId, Context) -> JObj = cb_context:req_data(Context), case kz_account:realm(JObj) of @@ -520,14 +520,14 @@ ensure_account_has_realm(_AccountId, Context) -> Context end. --spec ensure_account_has_timezone(api_binary(), cb_context:context()) -> cb_context:context(). +-spec ensure_account_has_timezone(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). ensure_account_has_timezone(_AccountId, Context) -> JObj = cb_context:req_data(Context), Timezone = kz_json:get_value(<<"timezone">>, JObj, get_timezone_from_parent(Context)), lager:debug("selected timezone: ~s", [Timezone]), cb_context:set_req_data(Context, kz_account:set_timezone(JObj, Timezone)). --spec get_timezone_from_parent(cb_context:context()) -> ne_binary(). +-spec get_timezone_from_parent(cb_context:context()) -> kz_term:ne_binary(). get_timezone_from_parent(Context) -> case create_new_tree(Context) of 'error' -> kz_account:default_timezone(); @@ -535,11 +535,11 @@ get_timezone_from_parent(Context) -> Tree -> kz_account:timezone(lists:last(Tree)) end. --spec random_realm() -> ne_binary(). +-spec random_realm() -> kz_term:ne_binary(). random_realm() -> <<(kz_binary:rand_hex(?RANDOM_REALM_STRENGTH))/binary, ".", (?ACCOUNT_REALM_SUFFIX)/binary>>. --spec remove_spaces(api_binary(), cb_context:context()) -> cb_context:context(). +-spec remove_spaces(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). remove_spaces(_AccountId, Context) -> ReqData = lists:foldl(fun remove_spaces_fold/2, cb_context:req_data(Context), ?REMOVE_SPACES), cb_context:set_req_data(Context, ReqData). @@ -553,7 +553,7 @@ remove_spaces_fold(Key, Acc) -> kz_json:set_value(Key, NoSpaces, Acc) end. --spec cleanup_leaky_keys(api_binary(), cb_context:context()) -> cb_context:context(). +-spec cleanup_leaky_keys(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). cleanup_leaky_keys(_AccountId, Context) -> RemoveKeys = [<<"wnm_allow_additions">> ,<<"superduper_admin">> @@ -562,7 +562,7 @@ cleanup_leaky_keys(_AccountId, Context) -> ReqData = kz_json:delete_keys(RemoveKeys, cb_context:req_data(Context)), cb_context:set_req_data(Context, ReqData). --spec validate_realm_is_unique(api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_realm_is_unique(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_realm_is_unique(AccountId, Context) -> Realm = kz_account:realm(cb_context:req_data(Context)), case is_unique_realm(AccountId, Realm) of @@ -577,7 +577,7 @@ validate_realm_is_unique(AccountId, Context) -> cb_context:add_validation_error([<<"realm">>], <<"unique">>, Msg, Context) end. --spec validate_account_name_is_unique(api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_account_name_is_unique(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_account_name_is_unique(AccountId, Context) -> Name = kz_account:name(cb_context:req_data(Context)), case maybe_is_unique_account_name(AccountId, Name) of @@ -592,7 +592,7 @@ validate_account_name_is_unique(AccountId, Context) -> cb_context:add_validation_error([<<"name">>], <<"unique">>, Msg, Context) end. --spec validate_account_schema(api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_account_schema(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_account_schema(AccountId, Context) -> lager:debug("validating payload"), OnSuccess = fun(C) -> @@ -601,7 +601,7 @@ validate_account_schema(AccountId, Context) -> end, cb_context:validate_request_data(<<"accounts">>, Context, OnSuccess). --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> set_private_properties(Context); on_successful_validation(AccountId, Context) -> @@ -612,7 +612,7 @@ on_successful_validation(AccountId, Context) -> cb_context:context(). -spec maybe_import_enabled(cb_context:context(), crossbar_status()) -> cb_context:context(). --spec maybe_import_enabled(cb_context:context(), kz_json:object(), api_binary()) -> +-spec maybe_import_enabled(cb_context:context(), kz_json:object(), kz_term:api_binary()) -> cb_context:context(). maybe_import_enabled(Context) -> case cb_context:auth_account_id(Context) =:= cb_context:account_id(Context) of @@ -643,13 +643,13 @@ maybe_import_enabled(Context, Doc, IsEnabled) -> end, cb_context:set_doc(Context, NewDoc). --spec disallow_direct_clients(api_binary(), cb_context:context()) -> cb_context:context(). +-spec disallow_direct_clients(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). disallow_direct_clients(AccountId, Context) -> ShouldAllow = ?ALLOW_DIRECT_CLIENTS, lager:debug("will allow direct clients: ~s", [ShouldAllow]), maybe_disallow_direct_clients(AccountId, Context, ShouldAllow). --spec maybe_disallow_direct_clients(api_binary(), cb_context:context(), boolean()) -> +-spec maybe_disallow_direct_clients(kz_term:api_binary(), cb_context:context(), boolean()) -> cb_context:context(). maybe_disallow_direct_clients(_AccountId, Context, 'true') -> Context; @@ -676,7 +676,7 @@ maybe_disallow_direct_clients(_AccountId, Context, 'false') -> %% Load an account document from the database %% @end %%-------------------------------------------------------------------- --spec validate_delete_request(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_delete_request(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). validate_delete_request(AccountId, Context) -> case kapps_util:account_has_descendants(AccountId) of 'true' -> cb_context:add_system_error('account_has_descendants', Context); @@ -693,7 +693,7 @@ validate_delete_request(AccountId, Context) -> end. %% @private --spec validate_patch_request(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_patch_request(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). validate_patch_request(AccountId, Context) -> crossbar_doc:patch_and_validate(AccountId, Context, fun validate_request/2). @@ -703,7 +703,7 @@ validate_patch_request(AccountId, Context) -> %% Load an account document from the database %% @end %%-------------------------------------------------------------------- --spec load_account(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_account(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_account(AccountId, Context) -> leak_pvt_fields(AccountId, crossbar_doc:load(AccountId, Context, ?TYPE_CHECK_OPTION(?PVT_TYPE))). @@ -713,8 +713,8 @@ load_account(AccountId, Context) -> %% %% @end %%-------------------------------------------------------------------- --spec leak_pvt_fields(api_binary(), cb_context:context()) -> cb_context:context(). --spec leak_pvt_fields(api_binary(), cb_context:context(), crossbar_status()) -> cb_context:context(). +-spec leak_pvt_fields(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). +-spec leak_pvt_fields(kz_term:api_binary(), cb_context:context(), crossbar_status()) -> cb_context:context(). leak_pvt_fields(AccountId, Context) -> leak_pvt_fields(AccountId, Context, cb_context:resp_status(Context)). @@ -789,7 +789,7 @@ leak_pvt_enabled(Context) -> ) end. --spec leak_reseller_id(cb_context:context(), api_binary()) -> cb_context:context(). +-spec leak_reseller_id(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). leak_reseller_id(Context, PathAccountId) -> cb_context:set_resp_data(Context ,kz_json:set_value(<<"reseller_id">> @@ -808,7 +808,7 @@ leak_is_reseller(Context) -> ) ). --spec leak_billing_mode(cb_context:context(), api_binary()) -> cb_context:context(). +-spec leak_billing_mode(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). leak_billing_mode(Context, PathAccountId) -> {'ok', MasterAccountId} = kapps_util:get_master_account_id(), AuthAccountId = cb_context:auth_account_id(Context), @@ -828,7 +828,7 @@ leak_billing_mode(Context, PathAccountId) -> ) end. --spec find_reseller_id(cb_context:context(), api_binary()) -> api_binary(). +-spec find_reseller_id(cb_context:context(), kz_term:api_binary()) -> kz_term:api_binary(). find_reseller_id(Context, 'undefined') -> %% only when put/1 cb_context:reseller_id(Context); @@ -841,7 +841,7 @@ find_reseller_id(Context, PathAccountId) -> end. -spec leak_notification_preference(cb_context:context()) -> cb_context:context(). --spec leak_notification_preference(cb_context:context(), api_binary()) -> cb_context:context(). +-spec leak_notification_preference(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). leak_notification_preference(Context) -> leak_notification_preference(Context, kz_account:notification_preference(cb_context:doc(Context))). @@ -853,7 +853,7 @@ leak_notification_preference(Context, Pref) -> -spec leak_trial_time_left(cb_context:context()) -> cb_context:context(). --spec leak_trial_time_left(cb_context:context(), kz_json:object(), api_integer()) -> +-spec leak_trial_time_left(cb_context:context(), kz_json:object(), kz_term:api_integer()) -> cb_context:context(). leak_trial_time_left(Context) -> JObj = cb_context:doc(Context), @@ -877,17 +877,17 @@ leak_trial_time_left(Context, JObj, _Expiration) -> %% Load a summary of the children of this account %% @end %%-------------------------------------------------------------------- --spec load_children(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_children(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_children(AccountId, Context) -> load_children(AccountId, Context, cb_context:api_version(Context)). --spec load_children(ne_binary(), cb_context:context(), ne_binary()) -> cb_context:context(). +-spec load_children(kz_term:ne_binary(), cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_children(AccountId, Context, ?VERSION_1) -> load_children_v1(AccountId, Context); load_children(AccountId, Context, _Version) -> load_paginated_children(AccountId, Context). --spec load_children_v1(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_children_v1(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_children_v1(AccountId, Context) -> crossbar_doc:load_view(?AGG_VIEW_CHILDREN ,[{'startkey', [AccountId]} @@ -897,7 +897,7 @@ load_children_v1(AccountId, Context) -> ,fun normalize_view_results/2 ). --spec load_paginated_children(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_paginated_children(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_paginated_children(AccountId, Context) -> StartKey = start_key(Context), fix_envelope( @@ -915,7 +915,7 @@ load_paginated_children(AccountId, Context) -> %% Load a summary of the descendants of this account %% @end %%-------------------------------------------------------------------- --spec load_descendants(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_descendants(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_descendants(AccountId, Context) -> load_descendants(AccountId, Context, cb_context:api_version(Context)). @@ -924,7 +924,7 @@ load_descendants(AccountId, Context, ?VERSION_1) -> load_descendants(AccountId, Context, _Version) -> load_paginated_descendants(AccountId, Context). --spec load_descendants_v1(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_descendants_v1(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_descendants_v1(AccountId, Context) -> crossbar_doc:load_view(?AGG_VIEW_DESCENDANTS ,[{'startkey', [AccountId]} @@ -934,7 +934,7 @@ load_descendants_v1(AccountId, Context) -> ,fun normalize_view_results/2 ). --spec load_paginated_descendants(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_paginated_descendants(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_paginated_descendants(AccountId, Context) -> StartKey = start_key(Context), lager:debug("account ~s startkey ~s", [AccountId, StartKey]), @@ -954,7 +954,7 @@ load_paginated_descendants(AccountId, Context) -> %% Load a summary of the siblngs of this account %% @end %%-------------------------------------------------------------------- --spec load_siblings(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_siblings(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_siblings(AccountId, Context) -> case kz_util:is_system_admin(cb_context:auth_account_id(Context)) orelse @@ -966,13 +966,13 @@ load_siblings(AccountId, Context) -> 'false' -> cb_context:add_system_error('forbidden', Context) end. --spec load_siblings(ne_binary(), cb_context:context(), ne_binary()) -> cb_context:context(). +-spec load_siblings(kz_term:ne_binary(), cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_siblings(AccountId, Context, ?VERSION_1) -> load_siblings_v1(AccountId, Context); load_siblings(AccountId, Context, _Version) -> load_paginated_siblings(AccountId, Context). --spec load_siblings_v1(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_siblings_v1(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_siblings_v1(AccountId, Context) -> Context1 = crossbar_doc:load_view(?AGG_VIEW_PARENT ,[{'startkey', AccountId} @@ -987,7 +987,7 @@ load_siblings_v1(AccountId, Context) -> cb_context:add_system_error('bad_identifier', kz_json:from_list([{<<"cause">>, AccountId}]), Context) end. --spec load_paginated_siblings(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_paginated_siblings(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_paginated_siblings(AccountId, Context) -> Context1 = fix_envelope( @@ -1004,7 +1004,7 @@ load_paginated_siblings(AccountId, Context) -> cb_context:add_system_error('bad_identifier', kz_json:from_list([{<<"cause">>, AccountId}]), Context) end. --spec load_siblings_results(ne_binary(), cb_context:context(), kz_json:objects()) -> cb_context:context(). +-spec load_siblings_results(kz_term:ne_binary(), cb_context:context(), kz_json:objects()) -> cb_context:context(). load_siblings_results(_AccountId, Context, [JObj|_]) -> Parent = kz_json:get_value([<<"value">>, <<"id">>], JObj), load_children(Parent, Context); @@ -1034,7 +1034,7 @@ fix_envelope_fold(Key, JObj) -> V -> kz_json:set_value(Key, V, JObj) end. --spec fix_start_key(api_binary() | list()) -> api_binary(). +-spec fix_start_key(kz_term:api_binary() | list()) -> kz_term:api_binary(). fix_start_key('undefined') -> 'undefined'; fix_start_key(<<_/binary>> = StartKey) -> StartKey; fix_start_key([StartKey]) -> StartKey; @@ -1050,7 +1050,7 @@ load_account_tree(Context) -> {'ok', JObjs} -> format_account_tree_results(Context, JObjs) end. --spec get_authorized_account_tree(cb_context:context()) -> ne_binaries(). +-spec get_authorized_account_tree(cb_context:context()) -> kz_term:ne_binaries(). get_authorized_account_tree(Context) -> AuthAccountId = cb_context:auth_account_id(Context), lists:dropwhile(fun(E) -> E =/= AuthAccountId end @@ -1073,7 +1073,7 @@ format_account_tree_results(Context, JObjs) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec load_parents(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_parents(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_parents(AccountId, Context) -> Context1 = crossbar_doc:load_view(?AGG_VIEW_SUMMARY ,[] @@ -1084,7 +1084,7 @@ load_parents(AccountId, Context) -> _Status -> Context1 end. --spec load_parent_tree(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_parent_tree(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_parent_tree(AccountId, Context) -> RespData = cb_context:resp_data(Context), Tree = extract_tree(AccountId, RespData), @@ -1105,7 +1105,7 @@ load_parent_tree(AccountId, Context) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec extract_tree(ne_binary(), kz_json:objects()) -> ne_binaries(). +-spec extract_tree(kz_term:ne_binary(), kz_json:objects()) -> kz_term:ne_binaries(). extract_tree(AccountId, JObjs) -> JObj = kz_json:find_value(<<"id">>, AccountId, JObjs), [_, Tree] = kz_json:get_value(<<"key">>, JObj), @@ -1116,8 +1116,8 @@ extract_tree(AccountId, JObjs) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec find_accounts_from_tree(ne_binaries(), kz_json:objects(), cb_context:context()) -> kz_json:objects(). --spec find_accounts_from_tree(ne_binaries(), kz_json:objects(), ne_binary(), kz_json:objects()) -> kz_json:objects(). +-spec find_accounts_from_tree(kz_term:ne_binaries(), kz_json:objects(), cb_context:context()) -> kz_json:objects(). +-spec find_accounts_from_tree(kz_term:ne_binaries(), kz_json:objects(), kz_term:ne_binary(), kz_json:objects()) -> kz_json:objects(). find_accounts_from_tree(Tree, JObjs, Context) -> AuthAccountId = cb_context:auth_account_id(Context), find_accounts_from_tree(lists:reverse(Tree), JObjs, AuthAccountId, []). @@ -1222,7 +1222,7 @@ add_pvt_tree(Context) -> Tree -> cb_context:set_doc(Context, kz_account:set_tree(cb_context:doc(Context), Tree)) end. --spec create_new_tree(cb_context:context() | api_binary()) -> ne_binaries() | 'error'. +-spec create_new_tree(cb_context:context() | kz_term:api_binary()) -> kz_term:ne_binaries() | 'error'. create_new_tree('undefined') -> case kapps_util:get_master_account_id() of {'ok', MasterAccountId} -> [MasterAccountId]; @@ -1259,7 +1259,7 @@ create_new_tree(Context, _Verb, _Nouns) -> %% for this account %% @end %%-------------------------------------------------------------------- --spec load_account_db(cb_context:context(), ne_binary() | ne_binaries()) -> +-spec load_account_db(cb_context:context(), kz_term:ne_binary() | kz_term:ne_binaries()) -> cb_context:context(). load_account_db(Context, [AccountId|_]) -> load_account_db(Context, AccountId); @@ -1347,7 +1347,7 @@ maybe_set_notification_preference(Context) -> end end. --spec set_notification_preference(cb_context:context(), ne_binary()) -> 'ok'. +-spec set_notification_preference(cb_context:context(), kz_term:ne_binary()) -> 'ok'. set_notification_preference(Context, Preference) -> AccountDb = cb_context:account_db(Context), AccountDefinition = kz_account:set_notification_preference(cb_context:doc(Context), Preference), @@ -1359,12 +1359,12 @@ set_notification_preference(Context, Preference) -> lager:info("notification_preference set to '~s'", [Preference]) end. --spec create_account_mod(ne_binary()) -> any(). +-spec create_account_mod(kz_term:ne_binary()) -> any(). create_account_mod(AccountId) -> Db = kz_util:format_account_mod_id(AccountId), kazoo_modb:create(Db). --spec create_first_transaction(ne_binary()) -> any(). +-spec create_first_transaction(kz_term:ne_binary()) -> any(). create_first_transaction(AccountId) -> AccountMODb = kazoo_modb:get_modb(AccountId), wht_util:rollup(AccountMODb, 0). @@ -1441,7 +1441,7 @@ replicate_account_definition(JObj) -> %% unique or belongs to the request being made %% @end %%-------------------------------------------------------------------- --spec is_unique_realm(api_binary(), ne_binary()) -> boolean(). +-spec is_unique_realm(kz_term:api_binary(), kz_term:ne_binary()) -> boolean(). is_unique_realm(AccountId, Realm) -> ViewOptions = [{'key', kz_term:to_lower_binary(Realm)}], case kz_datamgr:get_results(?KZ_ACCOUNTS_DB, ?AGG_VIEW_REALM, ViewOptions) of @@ -1457,14 +1457,14 @@ is_unique_realm(AccountId, Realm) -> %% This function will determine if the account name is unique %% @end %%-------------------------------------------------------------------- --spec maybe_is_unique_account_name(api_binary(), ne_binary()) -> boolean(). +-spec maybe_is_unique_account_name(kz_term:api_binary(), kz_term:ne_binary()) -> boolean(). maybe_is_unique_account_name(AccountId, Name) -> case kapps_config:get_is_true(?ACCOUNTS_CONFIG_CAT, <<"ensure_unique_name">>, 'true') of 'true' -> is_unique_account_name(AccountId, Name); 'false' -> 'true' end. --spec is_unique_account_name(api_ne_binary(), ne_binary()) -> boolean(). +-spec is_unique_account_name(kz_term:api_ne_binary(), kz_term:ne_binary()) -> boolean(). is_unique_account_name(AccountId, Name) -> AccountName = kz_util:normalize_account_name(Name), ViewOptions = [{'key', AccountName}], @@ -1510,7 +1510,7 @@ notify_new_account(Context, _AuthDoc) -> %% be phased out shortly %% @end %%-------------------------------------------------------------------- --spec support_depreciated_billing_id(api_binary(), api_binary(), cb_context:context()) -> +-spec support_depreciated_billing_id(kz_term:api_binary(), kz_term:api_binary(), cb_context:context()) -> cb_context:context(). support_depreciated_billing_id('undefined', _, Context) -> Context; support_depreciated_billing_id(BillingId, AccountId, Context) -> @@ -1586,7 +1586,7 @@ delete_remove_db(Context) -> end. -spec delete_mod_dbs(cb_context:context()) -> 'true'. --spec delete_mod_dbs(ne_binary(), kz_year(), kz_month()) -> 'true'. +-spec delete_mod_dbs(kz_term:ne_binary(), kz_time:year(), kz_time:month()) -> 'true'. delete_mod_dbs(Context) -> AccountId = cb_context:account_id(Context), {Year, Month, _} = erlang:date(), diff --git a/applications/crossbar/src/modules/cb_alerts.erl b/applications/crossbar/src/modules/cb_alerts.erl index 4d8e0743c2a..5785e7aaa86 100644 --- a/applications/crossbar/src/modules/cb_alerts.erl +++ b/applications/crossbar/src/modules/cb_alerts.erl @@ -174,7 +174,7 @@ create(Context) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec read(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec read(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). read(Id, Context) -> Context1 = cb_context:set_account_db(Context, ?KZ_ALERTS_DB), crossbar_doc:load(Id, Context1, ?TYPE_CHECK_OPTION(<<"alert">>)). @@ -307,7 +307,7 @@ view_keys(Context) -> %% %% @end %%-------------------------------------------------------------------- --spec add_descendants(ne_binary(), boolean(), list()) -> list(). +-spec add_descendants(kz_term:ne_binary(), boolean(), list()) -> list(). add_descendants(Descendant, 'false', Keys) -> [[<<"descendants">>, [Descendant, <<"all">>]] ,[<<"descendants">>, [Descendant, <<"users">>]] diff --git a/applications/crossbar/src/modules/cb_allotments.erl b/applications/crossbar/src/modules/cb_allotments.erl index 545e4b343eb..04ba925836c 100644 --- a/applications/crossbar/src/modules/cb_allotments.erl +++ b/applications/crossbar/src/modules/cb_allotments.erl @@ -133,9 +133,9 @@ load_consumed(Context, 'success') -> end; load_consumed(Context, _) -> Context. --type mode() :: {ne_binary(), gregorian_seconds(), gregorian_seconds()}. +-type mode() :: {kz_term:ne_binary(), kz_time:gregorian_seconds(), kz_time:gregorian_seconds()}. --spec foldl_consumed(ne_binary(), kz_json:object(), CMA) -> CMA when CMA :: {cb_context:context(), mode(), kz_json:objects()}. +-spec foldl_consumed(kz_term:ne_binary(), kz_json:object(), CMA) -> CMA when CMA :: {cb_context:context(), mode(), kz_json:objects()}. foldl_consumed(Classification, ValueJObj, {Context, {CycleMode, From0, To0}=Mode, Acc}) -> {Cycle, From, To} = case CycleMode =:= <<"cycle">> andalso kz_json:get_ne_binary_value(<<"cycle">>, ValueJObj) @@ -157,7 +157,7 @@ foldl_consumed(Classification, ValueJObj, {Context, {CycleMode, From0, To0}=Mode end. --spec normalize_result(api_ne_binary(), gregorian_seconds(), gregorian_seconds(), kz_json:object(), kz_json:objects()) +-spec normalize_result(kz_term:api_ne_binary(), kz_time:gregorian_seconds(), kz_time:gregorian_seconds(), kz_json:object(), kz_json:objects()) -> kz_json:object(). normalize_result(_Cycle, _From, _To, Acc, []) -> Acc; normalize_result(Cycle, From, To, Acc, [Head|Tail]) -> @@ -193,7 +193,7 @@ get_consumed_mode(Context) -> {From, To} -> {<<"manual">>, From, To} end. --spec maybe_req_seconds(cb_context:context(), api_binary()) -> api_seconds(). +-spec maybe_req_seconds(cb_context:context(), kz_term:api_binary()) -> kz_time:api_seconds(). maybe_req_seconds(Context, Key) -> Val = cb_context:req_value(Context, Key), case kz_term:safe_cast(Val, 'undefined', fun kz_term:to_integer/1) of @@ -275,7 +275,7 @@ update_allotments(Context) -> Context1 = crossbar_doc:save(cb_context:set_doc(Context, NewDoc)), cb_context:set_resp_data(Context1, Allotments). --spec cycle_start(api_ne_binary(), kz_datetime() | gregorian_seconds()) -> gregorian_seconds(). +-spec cycle_start(kz_term:api_ne_binary(), kz_time:datetime() | kz_time:gregorian_seconds()) -> kz_time:gregorian_seconds(). cycle_start(Cycle, Seconds) when is_integer(Seconds) -> cycle_start(Cycle, calendar:gregorian_seconds_to_datetime(Seconds)); cycle_start(<<"monthly">>, {{Year, Month, _}, _}) -> @@ -292,7 +292,7 @@ cycle_start(<<"minutely">>, {{Year, Month, Day}, {Hour, Min, _}}) -> cycle_start(_, {{Year, Month, Day}, {Hour, _, _}}) -> calendar:datetime_to_gregorian_seconds({{Year, Month, Day}, {Hour, 0, 0}}). --spec cycle_end(api_ne_binary(), kz_datetime() | gregorian_seconds()) -> gregorian_seconds(). +-spec cycle_end(kz_term:api_ne_binary(), kz_time:datetime() | kz_time:gregorian_seconds()) -> kz_time:gregorian_seconds(). cycle_end(Cycle, Seconds) when is_integer(Seconds) -> cycle_end(Cycle, calendar:gregorian_seconds_to_datetime(Seconds)); cycle_end(<<"monthly">>, {{Year, Month, _}, _}) -> diff --git a/applications/crossbar/src/modules/cb_api_auth.erl b/applications/crossbar/src/modules/cb_api_auth.erl index c715cabe7fe..7b8545a92ed 100644 --- a/applications/crossbar/src/modules/cb_api_auth.erl +++ b/applications/crossbar/src/modules/cb_api_auth.erl @@ -137,8 +137,8 @@ on_successful_validation(Context) -> 'false' -> validate_by_api_key(Context, ApiKey) end. --spec validate_by_api_key(cb_context:context(), ne_binary()) -> cb_context:context(). --spec validate_by_api_key(cb_context:context(), ne_binary(), kz_json:object() | kz_json:objects()) -> +-spec validate_by_api_key(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). +-spec validate_by_api_key(cb_context:context(), kz_term:ne_binary(), kz_json:object() | kz_json:objects()) -> cb_context:context(). validate_by_api_key(Context, ApiKey) -> Context1 = crossbar_doc:load_view(?AGG_VIEW_API diff --git a/applications/crossbar/src/modules/cb_apps_link.erl b/applications/crossbar/src/modules/cb_apps_link.erl index 840e01133da..96076fa6dd6 100644 --- a/applications/crossbar/src/modules/cb_apps_link.erl +++ b/applications/crossbar/src/modules/cb_apps_link.erl @@ -130,7 +130,7 @@ auth_info(Context) -> ,{<<"is_master">>, AccountId =:= MasterAccountId} ]). --spec get_request_account(cb_context:context()) -> ne_binary(). +-spec get_request_account(cb_context:context()) -> kz_term:ne_binary(). get_request_account(Context) -> RequestNouns = cb_context:req_nouns(Context), case props:get_value(<<"accounts">>, RequestNouns) of diff --git a/applications/crossbar/src/modules/cb_apps_store.erl b/applications/crossbar/src/modules/cb_apps_store.erl index e12eb8b8204..28987049967 100644 --- a/applications/crossbar/src/modules/cb_apps_store.erl +++ b/applications/crossbar/src/modules/cb_apps_store.erl @@ -298,7 +298,7 @@ return_only_blacklist(Context) -> _ -> Context end. --spec validate_app(cb_context:context(), ne_binary(), http_method()) -> cb_context:context(). +-spec validate_app(cb_context:context(), kz_term:ne_binary(), http_method()) -> cb_context:context(). validate_app(Context, Id, ?HTTP_GET) -> Context1 = load_app(Context, Id), case cb_context:resp_status(Context1) of @@ -342,7 +342,7 @@ validate_app(Context, Id, ?HTTP_POST) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec validate_modification(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec validate_modification(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). validate_modification(Context, Id) -> Context1 = can_modify(Context, Id), case cb_context:resp_status(Context1) of @@ -355,7 +355,7 @@ validate_modification(Context, Id) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec can_modify(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec can_modify(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). can_modify(Context, Id) -> AccountId = cb_context:account_id(Context), case cb_apps_util:allowed_app(AccountId, Id) of @@ -421,7 +421,7 @@ normalize_apps_result([App|Apps], Acc) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec load_app(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec load_app(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_app(Context, AppId) -> AccountId = cb_context:account_id(Context), case cb_apps_util:allowed_app(AccountId, AppId) of @@ -436,7 +436,7 @@ load_app(Context, AppId) -> end. %% @private --spec load_app_from_master_account(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec load_app_from_master_account(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_app_from_master_account(Context, AppId) -> {'ok', MasterAccountDb} = kapps_util:get_master_account_db(), {'ok', MasterAccountId} = kapps_util:get_master_account_id(), @@ -459,7 +459,7 @@ load_app_from_master_account(Context, AppId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec bad_app_error(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec bad_app_error(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). bad_app_error(Context, AppId) -> cb_context:add_system_error('bad_identifier' ,kz_json:from_list([{<<"details">>, AppId}]) @@ -472,7 +472,7 @@ bad_app_error(Context, AppId) -> %% install a new app on the account %% @end %%-------------------------------------------------------------------- --spec install(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec install(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). install(Context, Id) -> Doc = cb_context:doc(Context), Apps = kzd_apps_store:apps(Doc), @@ -498,7 +498,7 @@ install(Context, Id) -> %% valid %% @end %%-------------------------------------------------------------------- --spec uninstall(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec uninstall(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). uninstall(Context, Id) -> Doc = cb_context:doc(Context), Apps = kzd_apps_store:apps(Doc), @@ -516,7 +516,7 @@ uninstall(Context, Id) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec update(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec update(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). update(Context, Id) -> Doc = cb_context:doc(Context), Apps = kzd_apps_store:apps(Doc), @@ -552,9 +552,9 @@ get_icon(Context) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec maybe_get_screenshot(cb_context:context(), ne_binary()) -> +-spec maybe_get_screenshot(cb_context:context(), kz_term:ne_binary()) -> 'error' | - {'ok', ne_binary(), kz_json:object()}. + {'ok', kz_term:ne_binary(), kz_json:object()}. maybe_get_screenshot(Context, Number) -> JObj = cb_context:doc(Context), Screenshots = kz_json:get_value(<<"screenshots">>, JObj), @@ -574,7 +574,7 @@ maybe_get_screenshot(Context, Number) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_screenshot(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec get_screenshot(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). get_screenshot(Context, Number) -> case maybe_get_screenshot(Context, Number) of 'error' -> @@ -615,9 +615,9 @@ load_apps_store(Context) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_attachment(cb_context:context(), ne_binary()) -> +-spec get_attachment(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). --spec get_attachment(cb_context:context(), ne_binary(), kz_json:object(), kz_json:object()) -> +-spec get_attachment(cb_context:context(), kz_term:ne_binary(), kz_json:object(), kz_json:object()) -> cb_context:context(). get_attachment(Context, Id) -> JObj = cb_context:doc(Context), @@ -641,7 +641,7 @@ get_attachment(Context, Id, JObj, Attachment) -> add_attachment(Context, Id, Attachment, AttachBin) end. --spec add_attachment(cb_context:context(), ne_binary(), kz_json:object(), binary()) -> +-spec add_attachment(cb_context:context(), kz_term:ne_binary(), kz_json:object(), binary()) -> cb_context:context(). add_attachment(Context, Id, Attachment, AttachBin) -> RespHeaders = diff --git a/applications/crossbar/src/modules/cb_auth.erl b/applications/crossbar/src/modules/cb_auth.erl index 9ae2c783f12..ab88585796a 100644 --- a/applications/crossbar/src/modules/cb_auth.erl +++ b/applications/crossbar/src/modules/cb_auth.erl @@ -214,7 +214,7 @@ authenticate_nouns(_, _, _) -> 'false'. -spec validate_resource(cb_context:context()) -> cb_context:context(). -spec validate_resource(cb_context:context(), path_token()) -> cb_context:context(). --spec validate_resource(cb_context:context(), path_token(), ne_binary()) -> cb_context:context(). +-spec validate_resource(cb_context:context(), path_token(), kz_term:ne_binary()) -> cb_context:context(). validate_resource(Context) -> cb_context:set_account_db(Context, ?KZ_AUTH_DB). validate_resource(Context, _Path) -> cb_context:set_account_db(Context, ?KZ_AUTH_DB). validate_resource(Context, _Path, _Id) -> cb_context:set_account_db(Context, ?KZ_AUTH_DB). @@ -241,7 +241,7 @@ validate(Context, Path, Id) -> validate_path(Context, Path, Id, cb_context:req_verb(Context)). %% validating /auth --spec validate_action(cb_context:context(), api_binary(), http_method()) -> cb_context:context(). +-spec validate_action(cb_context:context(), kz_term:api_binary(), http_method()) -> cb_context:context(). validate_action(Context, <<"reset_signature_secret">>, ?HTTP_PUT) -> case cb_context:req_nouns(Context) of [{<<"auth">>, _}] -> reset_system_identity_secret(Context); @@ -351,7 +351,7 @@ validate_path(Context, ?KEYS_PATH, Id, ?HTTP_PUT) -> validate_path(Context, ?KEYS_PATH, Id, ?HTTP_GET) -> get_public_key(Context, Id). --spec validate_token_info(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec validate_token_info(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). validate_token_info(Context, Token) -> Options = [{'force_profile_update', 'true'}], case crossbar_auth:validate_auth_token(Token, Options) of @@ -464,7 +464,7 @@ maybe_authorize(Context) -> normalize_view(JObj, Acc) -> [kz_json:get_value(<<"value">>, JObj)|Acc]. --spec account_id(cb_contxt:context()) -> ne_binary(). +-spec account_id(cb_contxt:context()) -> kz_term:ne_binary(). account_id(Context) -> {ok, Master} = kapps_util:get_master_account_id(), Source = [cb_context:req_param(Context, <<"account_id">>) @@ -519,14 +519,14 @@ keys_summary(Context) -> ], cb_context:setters(Context, Setters). --spec reset_private_key(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec reset_private_key(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). reset_private_key(Context, KeyId) -> case kz_auth_keys:reset_private_key(KeyId) of {'ok', _} -> cb_context:set_resp_status(Context, 'success'); {'error', Error} -> crossbar_doc:handle_datamgr_errors(Error, KeyId, Context) end. --spec get_public_key(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec get_public_key(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). get_public_key(Context, KeyId) -> lager:debug("trying to get public key ~s", [KeyId]), C1 = crossbar_doc:load(KeyId, Context, ?TYPE_CHECK_OPTION(<<"system_key">>)), @@ -535,7 +535,7 @@ get_public_key(Context, KeyId) -> _ -> C1 end. --spec load_public_key(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec load_public_key(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_public_key(Context, KeyId) -> case kz_datamgr:fetch_attachment(?KZ_AUTH_DB, KeyId, <<"private_key.pem">>) of {'ok', PemContents} -> @@ -558,7 +558,7 @@ get_public_from_private_key(PemContents) -> PublicKey = kz_auth_keys:get_public_key_from_private_key(PrivateKey), kz_auth_keys:to_pem(PublicKey). --spec set_public_key_response(cb_context:context(), ne_binary(), ne_binary()) -> cb_context:context(). +-spec set_public_key_response(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). set_public_key_response(Context, PublicKeyPem, <<"application/json">>) -> RespDoc = kz_json:from_list([{<<"public_key_pem">>, PublicKeyPem}]), Setters = [{fun cb_context:set_resp_status/2, 'success'} @@ -580,7 +580,7 @@ set_public_key_response(Context, PublicKeyPem, <<"application/x-pem-file">>=CT) %% @doc %% Find Mime type we should return from Accept header or payload if provided by module %% (temporary, better to make generic function to use across crossbar module) --spec find_accept_type(cb_context:context()) -> ne_binary(). +-spec find_accept_type(cb_context:context()) -> kz_term:ne_binary(). find_accept_type(Context) -> Acceptable = accept_values(Context), find_accept_type(Context, Acceptable). @@ -603,7 +603,7 @@ accept_values(Context) -> Tunneled = cb_context:req_value(Context, <<"accept">>), media_values(AcceptValue, Tunneled). --spec media_values(api_binary(), api_binary()) -> media_values(). +-spec media_values(kz_term:api_binary(), kz_term:api_binary()) -> media_values(). media_values('undefined', 'undefined') -> lager:debug("no accept headers, assuming JSON"), [?MEDIA_VALUE(<<"application">>, <<"json">>)]; diff --git a/applications/crossbar/src/modules/cb_basic_auth.erl b/applications/crossbar/src/modules/cb_basic_auth.erl index 8ad1aeabd67..21a42f68220 100644 --- a/applications/crossbar/src/modules/cb_basic_auth.erl +++ b/applications/crossbar/src/modules/cb_basic_auth.erl @@ -64,7 +64,7 @@ authenticate(Context, 'basic') -> end; authenticate(_Context, _TokenType) -> 'false'. --spec check_basic_token(cb_context:context(), api_binary()) -> +-spec check_basic_token(cb_context:context(), kz_term:api_binary()) -> 'false' | {'true' | 'stop', cb_context:context()}. check_basic_token(_Context, <<>>) -> 'false'; @@ -75,7 +75,7 @@ check_basic_token(Context, AuthToken) -> {'error', 'not_found'} -> maybe_check_credentials(Context, AuthToken) end. --spec maybe_check_credentials(cb_context:context(), api_binary()) -> +-spec maybe_check_credentials(cb_context:context(), kz_term:api_binary()) -> 'false' | {'true' | 'stop', cb_context:context()}. maybe_check_credentials(Context, AuthToken) -> @@ -86,7 +86,7 @@ maybe_check_credentials(Context, AuthToken) -> 'false' end. --spec check_credentials(cb_context:context(), ne_binary(), api_binary()) -> +-spec check_credentials(cb_context:context(), kz_term:ne_binary(), kz_term:api_binary()) -> 'false' | {'true' | 'stop', cb_context:context()}. check_credentials(Context, AccountId, Credentials) -> @@ -94,7 +94,7 @@ check_credentials(Context, AccountId, Credentials) -> BasicType = kapps_account_config:get(AccountId, ?AUTH_CONFIG_CAT, ?BASIC_AUTH_KEY, ?BASIC_AUTH_TYPE), check_credentials(Context, AccountId, Credentials, BasicType). --spec check_credentials(cb_context:context(), ne_binary(), ne_binary() | {ne_binary(), ne_binary()}, ne_binary()) -> +-spec check_credentials(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary() | {kz_term:ne_binary(), kz_term:ne_binary()}, kz_term:ne_binary()) -> 'false' | {'true' | 'stop', cb_context:context()}. check_credentials(Context, AccountId, {Username, Password}, _BasicType) -> @@ -116,7 +116,7 @@ check_credentials(Context, AccountId, Credentials, BasicType) -> _ -> 'false' end. --spec get_credential_doc(ne_binary(), ne_binary(), ne_binary()) -> api_object(). +-spec get_credential_doc(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_object(). get_credential_doc(AccountId, View, Key) -> AccountDb = kz_util:format_account_id(AccountId, 'encoded'), Options = [{'key', Key}, 'include_docs'], diff --git a/applications/crossbar/src/modules/cb_blacklists.erl b/applications/crossbar/src/modules/cb_blacklists.erl index 4b9a55ca9be..d4e277aaf00 100644 --- a/applications/crossbar/src/modules/cb_blacklists.erl +++ b/applications/crossbar/src/modules/cb_blacklists.erl @@ -136,7 +136,7 @@ create(Context) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec read(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec read(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). read(Id, Context) -> crossbar_doc:load(Id, Context, ?TYPE_CHECK_OPTION(<<"blacklist">>)). @@ -147,7 +147,7 @@ read(Id, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec update(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec update(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). update(Id, Context) -> OnSuccess = fun(C) -> on_successful_validation(Id, C) end, cb_context:validate_request_data(<<"blacklists">>, Context, OnSuccess). @@ -159,7 +159,7 @@ update(Id, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec validate_patch(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_patch(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). validate_patch(Id, Context) -> crossbar_doc:patch_and_validate(Id, Context, fun update/2). @@ -180,7 +180,7 @@ summary(Context) -> %% %% @end %%-------------------------------------------------------------------- --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> Doc = cb_context:doc(Context), cb_context:set_doc(Context, kz_doc:set_type(Doc, <<"blacklist">>)); @@ -213,7 +213,7 @@ format_numbers(Context) -> ,kz_json:set_value(<<"numbers">>, Numbers, Doc) ). --spec format_number_map(ne_binary(), kz_json:object()) -> - {ne_binary(), kz_json:object()}. +-spec format_number_map(kz_term:ne_binary(), kz_json:object()) -> + {kz_term:ne_binary(), kz_json:object()}. format_number_map(Number, Data) -> {knm_converters:normalize(Number), Data}. diff --git a/applications/crossbar/src/modules/cb_braintree.erl b/applications/crossbar/src/modules/cb_braintree.erl index fef1d9b4814..291748e8e44 100644 --- a/applications/crossbar/src/modules/cb_braintree.erl +++ b/applications/crossbar/src/modules/cb_braintree.erl @@ -240,7 +240,7 @@ error_max_credit(Context, MaxCredit, FutureAmount) -> ,Context ). --spec current_account_dollars(ne_binary()) -> dollars(). +-spec current_account_dollars(kz_term:ne_binary()) -> dollars(). current_account_dollars(AccountId) -> case wht_util:current_account_dollars(AccountId) of {'ok', Dollars} -> Dollars; @@ -433,7 +433,7 @@ create_credits(Context) -> crossbar_util:response('error', <<"transaction error">>, 500, Reason, Context) end. --spec reset_low_balance_notification(ne_binary()) -> 'ok'. +-spec reset_low_balance_notification(kz_term:ne_binary()) -> 'ok'. reset_low_balance_notification(AccountId) -> case kz_account:fetch(AccountId) of {'error', _} -> 'ok'; @@ -543,7 +543,7 @@ charge_billing_id(Amount, Context) -> crossbar_util:response('error', kz_term:to_binary(Error), 500, Reason, Context) end. --spec send_transaction_notify(ne_binary(), #bt_transaction{}) -> 'ok'. +-spec send_transaction_notify(kz_term:ne_binary(), #bt_transaction{}) -> 'ok'. send_transaction_notify(AccountId, Transaction) -> Props = [{<<"Account-ID">>, AccountId} | braintree_transaction:record_to_notification_props(Transaction) @@ -551,7 +551,7 @@ send_transaction_notify(AccountId, Transaction) -> ], kapps_notify_publisher:cast(Props, fun kapi_notifications:publish_transaction/1). --spec add_credit_to_account(kz_json:object(), integer(), ne_binary(), ne_binary(), api_binary()) -> +-spec add_credit_to_account(kz_json:object(), integer(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary()) -> {'ok', kz_transaction:transaction()} | {'error', any()}. add_credit_to_account(BraintreeData, Units, LedgerId, AccountId, OrderId) -> diff --git a/applications/crossbar/src/modules/cb_bulk.erl b/applications/crossbar/src/modules/cb_bulk.erl index 4129f34a84a..e2f292f30bc 100644 --- a/applications/crossbar/src/modules/cb_bulk.erl +++ b/applications/crossbar/src/modules/cb_bulk.erl @@ -159,7 +159,7 @@ revalidate_doc(JObj, Context) -> Id -> revalidate_doc(Id, JObj, Context) end. --spec revalidate_doc(ne_binary(), kz_json:object(), cb_context:context()) -> +-spec revalidate_doc(kz_term:ne_binary(), kz_json:object(), cb_context:context()) -> cb_context:context(). revalidate_doc(Id, JObj, Context) -> case get_validate_binding(JObj) of @@ -217,7 +217,7 @@ maybe_save_doc(JObj, Context) -> Id -> maybe_save_doc(Id, Doc, DbDoc, Context) end. --spec maybe_save_doc(ne_binary(), kz_json:object(), kz_json:object(), cb_context:context()) -> +-spec maybe_save_doc(kz_term:ne_binary(), kz_json:object(), kz_json:object(), cb_context:context()) -> cb_context:context(). maybe_save_doc(Id, JObj, DbDoc, Context) -> case get_post_binding(JObj) of @@ -269,7 +269,7 @@ maybe_delete_doc(JObj, Context) -> Id -> maybe_delete_doc(Id, Doc, DbDoc, Context) end. --spec maybe_delete_doc(ne_binary(), kz_json:object(), kz_json:object(), cb_context:context()) -> +-spec maybe_delete_doc(kz_term:ne_binary(), kz_json:object(), kz_json:object(), cb_context:context()) -> cb_context:context(). maybe_delete_doc(Id, JObj, DbDoc, Context) -> lager:debug("try to delete ~p", [Id]), @@ -299,13 +299,13 @@ maybe_delete_doc(Id, JObj, DbDoc, Context) -> run_binding(Binding, Payload, Id, Context) end. --spec run_binding(ne_binary(), list(), ne_binary(), cb_context:context()) -> cb_context:context(). +-spec run_binding(kz_term:ne_binary(), list(), kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). run_binding(Binding, Payload, Id, Context) -> lager:debug("bulk update running: ~p", [Binding]), InterimContext = crossbar_bindings:fold(Binding, Payload), import_results(Id, cb_context:import_errors(InterimContext), Context). --spec import_results(ne_binary(), cb_context:context(), cb_context:context()) -> +-spec import_results(kz_term:ne_binary(), cb_context:context(), cb_context:context()) -> cb_context:context(). import_results(Id, C, Context) -> case cb_context:resp_status(C) of @@ -313,7 +313,7 @@ import_results(Id, C, Context) -> _Error -> import_results_error(Id, C, Context) end. --spec import_results_success(ne_binary(), cb_context:context(), cb_context:context()) -> +-spec import_results_success(kz_term:ne_binary(), cb_context:context(), cb_context:context()) -> cb_context:context(). import_results_success(Id, C, Context) -> Doc = cb_context:doc(C), @@ -332,7 +332,7 @@ import_results_success(Id, C, Context) -> } ]). --spec import_results_error(ne_binary(), cb_context:context(), cb_context:context()) -> +-spec import_results_error(kz_term:ne_binary(), cb_context:context(), cb_context:context()) -> cb_context:context(). import_results_error(Id, C, Context) -> Status = cb_context:resp_status(C), @@ -348,7 +348,7 @@ import_results_error(Id, C, Context) -> ]), cb_context:set_resp_data(Context, kz_json:set_value(Id, Resp, JObj)). --spec select_doc(ne_binary(), kz_json:objects()) -> api_object(). +-spec select_doc(kz_term:ne_binary(), kz_json:objects()) -> kz_term:api_object(). select_doc(_Id, []) -> 'undefined'; select_doc(Id, [JObj|JObjs]) -> case kz_doc:id(JObj) of @@ -356,7 +356,7 @@ select_doc(Id, [JObj|JObjs]) -> _ -> select_doc(Id, JObjs) end. --spec get_doc_updates(cb_context:context()) -> api_object(). +-spec get_doc_updates(cb_context:context()) -> kz_term:api_object(). get_doc_updates(Context) -> JObj = cb_context:req_data(Context), case kz_json:get_value(<<"updates">>, JObj) of @@ -372,7 +372,7 @@ update_docs(Updates, Context) -> ], cb_context:set_doc(Context, JObjs). --spec get_post_binding(kz_json:object() | ne_binary()) -> api_binary(). +-spec get_post_binding(kz_json:object() | kz_term:ne_binary()) -> kz_term:api_binary(). get_post_binding(<<"device">>) -> <<"v1_resource.execute.post.devices">>; get_post_binding(<<"user">>) -> <<"v1_resource.execute.post.users">>; get_post_binding(<<"conference">>) -> <<"v1_resource.execute.post.conferences">>; @@ -380,7 +380,7 @@ get_post_binding(<<"vmbox">>) -> <<"v1_resource.execute.post.vmboxes">>; get_post_binding(<<_/binary>>) -> 'undefined'; get_post_binding(JObj) -> get_post_binding(kz_doc:type(JObj)). --spec get_delete_binding(kz_json:object() | ne_binary()) -> api_binary(). +-spec get_delete_binding(kz_json:object() | kz_term:ne_binary()) -> kz_term:api_binary(). get_delete_binding(<<"device">>) -> <<"v1_resource.execute.delete.devices">>; get_delete_binding(<<"user">>) -> <<"v1_resource.execute.delete.users">>; get_delete_binding(<<"conference">>) -> <<"v1_resource.execute.delete.conferences">>; @@ -388,7 +388,7 @@ get_delete_binding(<<"vmbox">>) -> <<"v1_resource.execute.delete.vmboxes">> get_delete_binding(<<_/binary>>) -> 'undefined'; get_delete_binding(JObj) -> get_delete_binding(kz_doc:type(JObj)). --spec get_validate_binding(kz_json:object() | ne_binary()) -> api_binary(). +-spec get_validate_binding(kz_json:object() | kz_term:ne_binary()) -> kz_term:api_binary(). get_validate_binding(<<"device">>) -> <<"v1_resource.validate.devices">>; get_validate_binding(<<"user">>) -> <<"v1_resource.validate.users">>; get_validate_binding(<<"conference">>) -> <<"v1_resource.validate.conferences">>; diff --git a/applications/crossbar/src/modules/cb_call_inspector.erl b/applications/crossbar/src/modules/cb_call_inspector.erl index c452dcccb14..7b164ae0676 100644 --- a/applications/crossbar/src/modules/cb_call_inspector.erl +++ b/applications/crossbar/src/modules/cb_call_inspector.erl @@ -108,7 +108,7 @@ validate(Context) -> load_chunk_view(Context, ViewName, Options) end. --spec load_chunk_view(cb_context:context(), ne_binary(), kz_proplist()) -> cb_context:context(). +-spec load_chunk_view(cb_context:context(), kz_term:ne_binary(), kz_term:proplist()) -> cb_context:context(). load_chunk_view(Context, ViewName, Options0) -> AuthAccountId = cb_context:auth_account_id(Context), IsReseller = kz_services:is_reseller(AuthAccountId), @@ -131,7 +131,7 @@ validate(Context, CallId) -> %%% Internal functions %%%=================================================================== --spec inspect_call_id(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec inspect_call_id(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). inspect_call_id(CallId, Context) -> Req = [{<<"Call-ID">>, CallId} | kz_api:default_headers(?APP_NAME, ?APP_VERSION) @@ -171,7 +171,7 @@ sanitize(JObjs) -> %% Generate specific view options for the path. %% @end %%-------------------------------------------------------------------- --spec get_view_options(req_nouns()) -> {api_ne_binary(), crossbar_view:options()}. +-spec get_view_options(req_nouns()) -> {kz_term:api_ne_binary(), crossbar_view:options()}. get_view_options([{<<"call_inspector">>, []}, {?KZ_ACCOUNTS_DB, _}|_]) -> {?CB_LIST, []}; get_view_options([{<<"call_inspector">>, []}, {<<"users">>, [OwnerId]}|_]) -> @@ -189,7 +189,7 @@ get_view_options(_) -> %% Loads CDR docs from database and normalized the them. %% @end %%-------------------------------------------------------------------- --spec load_chunked_cdrs(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec load_chunked_cdrs(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_chunked_cdrs(Context, RespType) -> Ids = get_cdr_ids(cb_context:resp_data(Context)), cb_cdrs:load_chunked_cdr_ids(Context, RespType, Ids). @@ -200,7 +200,7 @@ load_chunked_cdrs(Context, RespType) -> %% %% @end %%-------------------------------------------------------------------- --spec get_cdr_ids(kz_json:objects()) -> ne_binaries(). +-spec get_cdr_ids(kz_json:objects()) -> kz_term:ne_binaries(). get_cdr_ids(JObjs) -> Ids = [kz_doc:id(JObj) || JObj <- JObjs], %% Remove leading year, month and dash @@ -222,7 +222,7 @@ get_cdr_ids(JObjs) -> %% which cdr_id is on call_inspector data store %% @end %%-------------------------------------------------------------------- --spec filter_callids(ne_binaries()) -> ne_binaries(). +-spec filter_callids(kz_term:ne_binaries()) -> kz_term:ne_binaries(). filter_callids([]) -> []; filter_callids(CallIds) -> Req = [{<<"Call-IDs">>, CallIds} diff --git a/applications/crossbar/src/modules/cb_callflows.erl b/applications/crossbar/src/modules/cb_callflows.erl index a6f5df6ada4..6e881285c7f 100644 --- a/applications/crossbar/src/modules/cb_callflows.erl +++ b/applications/crossbar/src/modules/cb_callflows.erl @@ -162,7 +162,7 @@ load_callflow_summary(Context) -> %% Load a callflow document from the database %% @end %%-------------------------------------------------------------------- --spec load_callflow(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_callflow(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_callflow(CallflowId, Context) -> Context1 = crossbar_doc:load(CallflowId, Context, ?TYPE_CHECK_OPTION(kzd_callflow:type())), case cb_context:resp_status(Context1) of @@ -176,11 +176,11 @@ load_callflow(CallflowId, Context) -> _Status -> Context1 end. --spec request_numbers(cb_context:context()) -> ne_binaries() | kz_json:json_term(). +-spec request_numbers(cb_context:context()) -> kz_term:ne_binaries() | kz_json:json_term(). request_numbers(Context) -> kz_json:get_ne_value(<<"numbers">>, cb_context:req_data(Context), []). --spec request_patterns(cb_context:context()) -> ne_binaries() | kz_json:json_term(). +-spec request_patterns(cb_context:context()) -> kz_term:ne_binaries() | kz_json:json_term(). request_patterns(Context) -> kz_json:get_ne_value(<<"patterns">>, cb_context:req_data(Context), []). @@ -190,7 +190,7 @@ request_patterns(Context) -> %% %% @end %%-------------------------------------------------------------------- --spec validate_request(api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_request(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_request(CallflowId, Context) -> case request_numbers(Context) of [] -> validate_patterns(CallflowId, Context); @@ -205,7 +205,7 @@ validate_request(CallflowId, Context) -> cb_context:add_validation_error(<<"numbers">>, <<"type">>, Msg, Context) end. --spec normalize_numbers(cb_context:context(), ne_binaries()) -> cb_context:context(). +-spec normalize_numbers(cb_context:context(), kz_term:ne_binaries()) -> cb_context:context(). normalize_numbers(Context, Nums) -> Normalized = knm_converters:normalize(Nums, cb_context:account_id(Context)), NewReqData = kz_json:set_value(<<"numbers">>, Normalized, cb_context:req_data(Context)), @@ -217,11 +217,11 @@ normalize_numbers(Context, Nums) -> %% %% @end %%-------------------------------------------------------------------- --spec validate_patch(api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_patch(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_patch(CallflowId, Context) -> crossbar_doc:patch_and_validate(CallflowId, Context, fun validate_request/2). --spec validate_patterns(api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_patterns(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_patterns(CallflowId, Context) -> case request_patterns(Context) of [] -> @@ -240,18 +240,18 @@ validate_patterns(CallflowId, Context) -> cb_context:add_validation_error(<<"patterns">>, <<"type">>, Msg, Context) end. --spec validate_uniqueness(api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_uniqueness(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_uniqueness(CallflowId, Context) -> Setters = [{fun validate_unique_numbers/2, CallflowId} ,{fun validate_unique_patterns/2, CallflowId} ], cb_context:setters(Context, Setters). --spec validate_unique_numbers(cb_context:context(), api_binary()) -> cb_context:context(). +-spec validate_unique_numbers(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). validate_unique_numbers(Context, CallflowId) -> validate_unique_numbers(Context, CallflowId, request_numbers(Context)). --spec validate_unique_numbers(cb_context:context(), api_binary(), ne_binaries()) -> cb_context:context(). +-spec validate_unique_numbers(cb_context:context(), kz_term:api_binary(), kz_term:ne_binaries()) -> cb_context:context(). validate_unique_numbers(Context, _CallflowId, []) -> Context; validate_unique_numbers(Context, CallflowId, Numbers) -> Options = [{'keys', Numbers}], @@ -263,7 +263,7 @@ validate_unique_numbers(Context, CallflowId, Numbers) -> validate_number_conflicts(Context, CallflowId, JObjs) end. --spec validate_number_conflicts(cb_context:context(), api_binary(), kz_json:objects()) -> cb_context:context(). +-spec validate_number_conflicts(cb_context:context(), kz_term:api_binary(), kz_json:objects()) -> cb_context:context(). validate_number_conflicts(Context, 'undefined', JObjs) -> add_number_conflicts(Context, JObjs); validate_number_conflicts(Context, CallflowId, JObjs) -> @@ -285,11 +285,11 @@ add_number_conflict(Context, JObj) -> ]), cb_context:add_validation_error(<<"numbers">>, <<"unique">>, Msg, Context). --spec validate_unique_patterns(cb_context:context(), api_binary()) -> cb_context:context(). +-spec validate_unique_patterns(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). validate_unique_patterns(Context, CallflowId) -> validate_unique_patterns(Context, CallflowId, request_patterns(Context)). --spec validate_unique_patterns(cb_context:context(), api_binary(), ne_binaries()) -> cb_context:context(). +-spec validate_unique_patterns(cb_context:context(), kz_term:api_binary(), kz_term:ne_binaries()) -> cb_context:context(). validate_unique_patterns(Context, _CallflowId, []) -> Context; validate_unique_patterns(Context, CallflowId, Patterns) -> Options = [{'keys', Patterns}], @@ -301,7 +301,7 @@ validate_unique_patterns(Context, CallflowId, Patterns) -> validate_pattern_conflicts(Context, CallflowId, JObjs) end. --spec validate_pattern_conflicts(cb_context:context(), api_binary(), kz_json:objects()) -> cb_context:context(). +-spec validate_pattern_conflicts(cb_context:context(), kz_term:api_binary(), kz_json:objects()) -> cb_context:context(). validate_pattern_conflicts(Context, 'undefined', JObjs) -> add_pattern_conflicts(Context, JObjs); validate_pattern_conflicts(Context, CallflowId, JObjs) -> @@ -323,7 +323,7 @@ add_pattern_conflict(Context, JObj) -> ]), cb_context:add_validation_error(<<"patterns">>, <<"unique">>, Msg, Context). --spec validate_callflow_schema(api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_callflow_schema(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_callflow_schema(CallflowId, Context) -> OnSuccess = fun(C) -> C1 = validate_uniqueness(CallflowId, on_successful_validation(CallflowId, C)), @@ -334,7 +334,7 @@ validate_callflow_schema(CallflowId, Context) -> end, cb_context:validate_request_data(<<"callflows">>, Context, OnSuccess). --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> cb_context:set_doc(Context ,kz_doc:set_type(cb_context:doc(Context), kzd_callflow:type()) @@ -419,7 +419,7 @@ track_assignment('delete', Context) -> Updates = cb_modules_util:apply_assignment_updates(Unassigned, Context), cb_modules_util:log_assignment_updates(Updates). --spec filter_callflow_list(api_binary(), kz_json:objects()) -> kz_json:objects(). +-spec filter_callflow_list(kz_term:api_binary(), kz_json:objects()) -> kz_json:objects(). filter_callflow_list('undefined', JObjs) -> JObjs; filter_callflow_list(CallflowId, JObjs) -> [JObj @@ -434,12 +434,12 @@ filter_callflow_list(CallflowId, JObjs) -> %% @end %%-------------------------------------------------------------------- --spec ids_in_flow(kz_json:object()) -> ne_binaries(). +-spec ids_in_flow(kz_json:object()) -> kz_term:ne_binaries(). ids_in_flow(FlowJObj) -> ids_in_data(kz_json:get_values(<<"data">>, FlowJObj)). --spec ids_in_data({kz_json:json_terms(), kz_json:keys()}) -> ne_binaries(). --spec ids_in_data({kz_json:json_terms(), kz_json:keys()}, ne_binaries()) -> ne_binaries(). +-spec ids_in_data({kz_json:json_terms(), kz_json:keys()}) -> kz_term:ne_binaries(). +-spec ids_in_data({kz_json:json_terms(), kz_json:keys()}, kz_term:ne_binaries()) -> kz_term:ne_binaries(). ids_in_data(Values) -> ids_in_data(Values, []). @@ -454,8 +454,8 @@ ids_in_data({[V|Vs], [K|Ks]}, IDs) -> 'true' -> ids_in_data({Vs, Ks}, [V | IDs]) end. --spec get_metadata(api_object(), ne_binary()) -> kz_json:object(). --spec get_metadata(kz_json:object(), ne_binary(), kz_json:object()) -> +-spec get_metadata(kz_term:api_object(), kz_term:ne_binary()) -> kz_json:object(). +-spec get_metadata(kz_json:object(), kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). get_metadata('undefined', _Db) -> kz_json:new(); get_metadata(Flow, Db) -> get_metadata(Flow, Db, kz_json:new()). @@ -488,7 +488,7 @@ get_metadata(Flow, Db, Metadata) -> %% exists in metadata. %% @end %%-------------------------------------------------------------------- --spec create_metadata(ne_binary(), ne_binary(), kz_json:object()) -> +-spec create_metadata(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). create_metadata(_, <<"_">>, Metadata) -> Metadata; create_metadata(_, Id, Metadata) when byte_size(Id) < 2 -> Metadata; @@ -501,7 +501,7 @@ create_metadata(Db, Id, Metadata) -> {'error', _E} -> Metadata end. --spec fetch_id_from_db(ne_binary(), ne_binary()) -> +-spec fetch_id_from_db(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | kz_datamgr:data_error(). -ifdef(TEST). diff --git a/applications/crossbar/src/modules/cb_cdrs.erl b/applications/crossbar/src/modules/cb_cdrs.erl index 14800858c35..aab73a58978 100644 --- a/applications/crossbar/src/modules/cb_cdrs.erl +++ b/applications/crossbar/src/modules/cb_cdrs.erl @@ -87,7 +87,7 @@ ,{<<"reseller_call_type">>, fun col_reseller_call_type/2} ]). --type csv_column_fun() :: fun((kz_json:object(), gregorian_seconds()) -> ne_binary()). +-type csv_column_fun() :: fun((kz_json:object(), kz_time:gregorian_seconds()) -> kz_term:ne_binary()). %%%=================================================================== %%% API @@ -225,7 +225,7 @@ validate_chunk_view(Context) -> load_chunk_view(Context, ViewName, Options) end. --spec load_chunk_view(cb_context:context(), ne_binary(), kz_proplist()) -> cb_context:context(). +-spec load_chunk_view(cb_context:context(), kz_term:ne_binary(), kz_term:proplist()) -> cb_context:context(). load_chunk_view(Context, ViewName, Options0) -> AuthAccountId = cb_context:auth_account_id(Context), IsReseller = kz_services:is_reseller(AuthAccountId), @@ -281,7 +281,7 @@ normalize_summary_results(JObj, Acc) -> [JObj|Acc]. %% Generate specific view options for the path. %% @end %%-------------------------------------------------------------------- --spec get_view_options(req_nouns()) -> {api_ne_binary(), crossbar_view:options()}. +-spec get_view_options(req_nouns()) -> {kz_term:api_ne_binary(), crossbar_view:options()}. get_view_options([{<<"cdrs">>, []}, {?KZ_ACCOUNTS_DB, _}|_]) -> {?CB_LIST, []}; get_view_options([{<<"cdrs">>, []}, {<<"users">>, [OwnerId]}|_]) -> @@ -325,7 +325,7 @@ maybe_add_stale_to_options('false') ->[]. %% Loads CDR docs from database and normalized the them. %% @end %%-------------------------------------------------------------------- --spec load_chunked_cdrs(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec load_chunked_cdrs(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_chunked_cdrs(Context, RespType) -> Fun = fun(JObj, Acc) -> split_to_modbs(cb_context:account_id(Context), kz_doc:id(JObj), Acc) end, MapIds = lists:foldl(Fun, #{}, cb_context:resp_data(Context)), @@ -333,20 +333,20 @@ load_chunked_cdrs(Context, RespType) -> maps:fold(fun(Db, Ids, C) -> load_chunked_cdr_ids(C, RespType, Db, Ids) end, C1, MapIds). %% if request is not chunked, map Ids to MODBs --spec split_to_modbs(ne_binary(), ne_binary(), map()) -> map(). +-spec split_to_modbs(kz_term:ne_binary(), kz_term:ne_binary(), map()) -> map(). split_to_modbs(AccountId, ?MATCH_MODB_PREFIX(Year, Month, _)=Id, Map) -> Db = kazoo_modb:get_modb(AccountId, Year, Month), maps:update_with(Db, fun(List) -> List ++ [Id] end, [Id], Map). %% @public --spec load_chunked_cdr_ids(cb_context:context(), ne_binary(), ne_binaries()) -> cb_context:context(). +-spec load_chunked_cdr_ids(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binaries()) -> cb_context:context(). load_chunked_cdr_ids(Context, RespType, Ids) -> Fun = fun(Id, Acc) -> split_to_modbs(cb_context:account_id(Context), Id, Acc) end, MapIds = lists:foldl(Fun, #{}, Ids), C1 = cb_context:set_resp_data(Context, []), maps:fold(fun(Db, DbIds, C) -> load_chunked_cdr_ids(C, RespType, Db, DbIds) end, C1, MapIds). --spec load_chunked_cdr_ids(cb_context:context(), ne_binary(), ne_binary(), ne_binaries()) -> cb_context:context(). +-spec load_chunked_cdr_ids(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binaries()) -> cb_context:context(). load_chunked_cdr_ids(Context, RespType, Db, Ids) -> case cb_context:resp_status(Context) =:= 'success' andalso kz_datamgr:open_docs(Db, Ids, [{'doc_type', <<"cdr">>}]) @@ -399,7 +399,7 @@ normalize_cdr_to_csv(JObj, Context) -> end. --spec csv_rows(cb_context:context()) -> [{ne_binary(), csv_column_fun()}]. +-spec csv_rows(cb_context:context()) -> [{kz_term:ne_binary(), csv_column_fun()}]. csv_rows(Context) -> AuthAccountId = cb_context:auth_account_id(Context), case kz_services:is_reseller(AuthAccountId) of @@ -452,7 +452,7 @@ col_call_priority(JObj, _Timestamp) -> kz_json:get_value([?KEY_CCV, <<"call_prio col_reseller_cost(JObj, _Timestamp) -> kz_term:to_binary(reseller_cost(JObj)). col_reseller_call_type(JObj, _Timestamp) -> kz_json:get_value([?KEY_CCV, <<"reseller_billing">>], JObj, <<>>). --spec pretty_print_datetime(kz_datetime() | integer()) -> ne_binary(). +-spec pretty_print_datetime(kz_time:datetime() | integer()) -> kz_term:ne_binary(). pretty_print_datetime(Timestamp) when is_integer(Timestamp) -> pretty_print_datetime(calendar:gregorian_seconds_to_datetime(Timestamp)); pretty_print_datetime({{Y,Mo,D},{H,Mi,S}}) -> @@ -460,7 +460,7 @@ pretty_print_datetime({{Y,Mo,D},{H,Mi,S}}) -> ,[Y, Mo, D, H, Mi, S] )). --spec format_recordings(kz_json:object()) -> binaries(). +-spec format_recordings(kz_json:object()) -> kz_term:binaries(). format_recordings(JObj) -> case kz_json:get_value([?KEY_CCV, <<"media_recordings">>], JObj, []) of Recordings when is_list(Recordings) -> Recordings; @@ -507,7 +507,7 @@ reseller_cost(JObj) -> %% Load a CDR document from the database %% @end %%-------------------------------------------------------------------- --spec load_cdr(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_cdr(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_cdr(?MATCH_MODB_PREFIX(Year,Month,_) = CDRId, Context) -> AccountId = cb_context:account_id(Context), AccountDb = kazoo_modb:get_modb(AccountId, kz_term:to_integer(Year), kz_term:to_integer(Month)), @@ -523,7 +523,7 @@ load_cdr(CDRId, Context) -> %% Load Legs for a cdr interaction from the database %% @end %%-------------------------------------------------------------------- --spec load_legs(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_legs(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_legs(<> = DocId, Context) -> AccountId = cb_context:account_id(Context), AccountDb = kazoo_modb:get_modb(AccountId, kz_term:to_integer(Year), kz_term:to_integer(Month)), diff --git a/applications/crossbar/src/modules/cb_channels.erl b/applications/crossbar/src/modules/cb_channels.erl index 432ff5fc254..8774d5f260f 100644 --- a/applications/crossbar/src/modules/cb_channels.erl +++ b/applications/crossbar/src/modules/cb_channels.erl @@ -151,7 +151,7 @@ put(Context, UUID) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec read(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec read(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). read(Context, CallId) -> case channels_query(CallId) of {'ok', []} -> @@ -177,7 +177,7 @@ read(Context, CallId) -> crossbar_util:response_datastore_timeout(Context) end. --spec channels_query(ne_binary()) -> kz_amqp_worker:request_return(). +-spec channels_query(kz_term:ne_binary()) -> kz_amqp_worker:request_return(). channels_query(CallId) -> Req = [{<<"Call-ID">>, CallId} ,{<<"Fields">>, <<"all">>} @@ -190,7 +190,7 @@ channels_query(CallId) -> ,{'ecallmgr', fun kapi_call:query_channels_resp_v/1} ). --spec find_channel(ne_binary(), ne_binary(), kz_json:objects()) -> api_object(). +-spec find_channel(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:objects()) -> kz_term:api_object(). find_channel(_AccountId, _CallId, []) -> 'undefined'; find_channel(AccountId, CallId, [StatusJObj|JObjs]) -> Channel = kz_json:get_value([<<"Channels">>, CallId], StatusJObj), @@ -206,7 +206,7 @@ find_channel(AccountId, CallId, [StatusJObj|JObjs]) -> %% valid %% @end %%-------------------------------------------------------------------- --spec update(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec update(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). update(Context, CallId) -> Context1 = read(Context, CallId), @@ -215,8 +215,8 @@ update(Context, CallId) -> 'false' -> maybe_execute_command(Context1, CallId) end. --spec maybe_execute_command(cb_context:context(), ne_binary()) -> cb_context:context(). --spec maybe_execute_command(cb_context:context(), ne_binary(), api_binary()) -> cb_context:context(). +-spec maybe_execute_command(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). +-spec maybe_execute_command(cb_context:context(), kz_term:ne_binary(), kz_term:api_binary()) -> cb_context:context(). maybe_execute_command(Context, CallId) -> maybe_execute_command(Context, CallId, cb_context:req_value(Context, <<"action">>)). @@ -234,8 +234,8 @@ maybe_execute_command(Context, _CallId, _Command) -> lager:debug("unknown command: ~s", [_Command]), crossbar_util:response_invalid_data(cb_context:doc(Context), Context). --spec validate_action(cb_context:context(), ne_binary()) -> cb_context:context(). --spec validate_action(cb_context:context(), ne_binary(), api_binary()) -> cb_context:context(). +-spec validate_action(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). +-spec validate_action(cb_context:context(), kz_term:ne_binary(), kz_term:api_binary()) -> cb_context:context(). validate_action(Context, CallId) -> Ctx = read(Context, CallId), case cb_context:has_errors(Ctx) of @@ -277,11 +277,11 @@ summary(Context) -> crossbar_util:response_faulty_request(Context) end. --spec device_summary(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec device_summary(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). device_summary(Context, DeviceId) -> get_channels(Context, [cb_context:doc(crossbar_doc:load(DeviceId, Context, ?TYPE_CHECK_OPTION_ANY))], fun kapi_call:publish_query_user_channels_req/1). --spec user_summary(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec user_summary(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). user_summary(Context, UserId) -> {Endpoints, Context1} = user_endpoints(Context, UserId), case cb_context:has_errors(Context1) of @@ -300,7 +300,7 @@ maybe_get_user_channels(Context, Endpoints) -> ) end. --spec user_endpoints(cb_context:context(), ne_binary()) -> +-spec user_endpoints(cb_context:context(), kz_term:ne_binary()) -> endpoints_return(). user_endpoints(Context, UserId) -> Options = [{'key', [UserId, <<"device">>]} @@ -309,7 +309,7 @@ user_endpoints(Context, UserId) -> Context1 = crossbar_doc:load_view(<<"attributes/owned">>, Options, Context), {cb_context:doc(Context1), Context1}. --spec group_summary(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec group_summary(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). group_summary(Context, GroupId) -> {GroupEndpoints, Context1} = group_endpoints(Context, GroupId), case cb_context:has_errors(Context1) of @@ -321,14 +321,14 @@ group_summary(Context, GroupId) -> ) end. --spec group_endpoints(cb_context:context(), ne_binary()) -> endpoints_return(). +-spec group_endpoints(cb_context:context(), kz_term:ne_binary()) -> endpoints_return(). group_endpoints(Context, _GroupId) -> kz_json:foldl(fun group_endpoints_fold/3 ,{[], Context} ,kz_json:get_value(<<"endpoints">>, cb_context:doc(Context), kz_json:new()) ). --spec group_endpoints_fold(ne_binary(), kz_json:object(), endpoints_return()) -> +-spec group_endpoints_fold(kz_term:ne_binary(), kz_json:object(), endpoints_return()) -> endpoints_return(). group_endpoints_fold(EndpointId, EndpointData, {Acc, Context}) -> case kz_json:get_value(<<"type">>, EndpointData) of @@ -436,8 +436,8 @@ normalize_channel(JObj) -> kz_json:normalize(JObj) ). --spec maybe_transfer(cb_context:context(), ne_binary()) -> cb_context:context(). --spec maybe_transfer(cb_context:context(), ne_binary(), ne_binary()) -> cb_context:context(). +-spec maybe_transfer(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). +-spec maybe_transfer(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). maybe_transfer(Context, Transferor) -> Channel = cb_context:resp_data(Context), case kz_json:get_value(<<"other_leg_call_id">>, Channel) of @@ -465,7 +465,7 @@ maybe_transfer(Context, Transferor, Transferee) -> transfer(Context, Transferor, Transferee, Target) end. --spec transfer(cb_context:context(), ne_binary(), ne_binary(), ne_binary()) -> cb_context:context(). +-spec transfer(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). transfer(Context, Transferor, _Transferee, Target) -> TransferType = cb_context:req_value(Context, <<"transfer-type">>, <<"blind">>), API = [{<<"Call-ID">>, Transferor} @@ -483,7 +483,7 @@ transfer(Context, Transferor, _Transferee, Target) -> kz_amqp_worker:cast(API, fun kapi_metaflow:publish_action/1), crossbar_util:response_202(<<"transfer initiated">>, Context). --spec maybe_hangup(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec maybe_hangup(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). maybe_hangup(Context, CallId) -> API = [{<<"Call-ID">>, CallId} ,{<<"Action">>, <<"hangup">>} @@ -494,7 +494,7 @@ maybe_hangup(Context, CallId) -> kz_amqp_worker:cast(API, fun kapi_metaflow:publish_action/1), crossbar_util:response_202(<<"hangup initiated">>, Context). --spec maybe_break(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec maybe_break(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). maybe_break(Context, CallId) -> API = [{<<"Call-ID">>, CallId} ,{<<"Action">>, <<"break">>} @@ -505,7 +505,7 @@ maybe_break(Context, CallId) -> kz_amqp_worker:cast(API, fun kapi_metaflow:publish_action/1), crossbar_util:response_202(<<"break initiated">>, Context). --spec maybe_callflow(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec maybe_callflow(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). maybe_callflow(Context, CallId) -> CallflowId = cb_context:req_value(Context, <<"id">>), API = [{<<"Call-ID">>, CallId} @@ -523,13 +523,13 @@ maybe_callflow(Context, CallId) -> kz_amqp_worker:cast(API, fun kapi_metaflow:publish_action/1), crossbar_util:response_202(<<"callflow initiated">>, Context). --spec maybe_intercept(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec maybe_intercept(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). maybe_intercept(Context, CallId) -> TargetType = cb_context:req_value(Context, <<"target_type">>), TargetId = cb_context:req_value(Context, <<"target_id">>), maybe_intercept(Context, CallId, TargetType, TargetId). --spec maybe_intercept(cb_context:context(), ne_binary(), api_binary(), api_binary()) -> cb_context:context(). +-spec maybe_intercept(cb_context:context(), kz_term:ne_binary(), kz_term:api_binary(), kz_term:api_binary()) -> cb_context:context(). maybe_intercept(Context, _CallId, 'undefined', _TargetId) -> cb_context:add_validation_error(<<"target_type">> ,<<"required">> @@ -557,7 +557,7 @@ maybe_intercept(Context, CallId, TargetType, TargetId) -> kz_amqp_worker:cast(API, fun kapi_metaflow:publish_action/1), crossbar_util:response_202(<<"intercept initiated">>, Context). --spec get_account_id(cb_context:context()) -> ne_binary(). +-spec get_account_id(cb_context:context()) -> kz_term:ne_binary(). get_account_id(Context) -> case cb_context:account_id(Context) of 'undefined' -> diff --git a/applications/crossbar/src/modules/cb_clicktocall.erl b/applications/crossbar/src/modules/cb_clicktocall.erl index cc57ee501e2..feee4fbd808 100644 --- a/applications/crossbar/src/modules/cb_clicktocall.erl +++ b/applications/crossbar/src/modules/cb_clicktocall.erl @@ -217,11 +217,11 @@ load_c2c_summary(Context) -> ,fun normalize_view_results/2 ). --spec load_c2c(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_c2c(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_c2c(C2CId, Context) -> crossbar_doc:load(C2CId, Context, ?TYPE_CHECK_OPTION(?PVT_TYPE)). --spec load_c2c_history(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_c2c_history(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_c2c_history(C2CId, Context) -> Options = ['include_docs' ,{'startkey', [C2CId]} @@ -237,16 +237,16 @@ load_c2c_history(C2CId, Context) -> create_c2c(Context) -> cb_context:validate_request_data(<<"clicktocall">>, Context, fun clear_history_set_type/1). --spec update_c2c(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec update_c2c(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). update_c2c(C2CId, Context) -> OnSuccess = fun(C) -> crossbar_doc:load_merge(C2CId, C, ?TYPE_CHECK_OPTION(?PVT_TYPE)) end, cb_context:validate_request_data(<<"clicktocall">>, Context, OnSuccess). --spec validate_patch_c2c(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_patch_c2c(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). validate_patch_c2c(C2CId, Context) -> crossbar_doc:patch_and_validate(C2CId, Context, fun update_c2c/2). --spec establish_c2c(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec establish_c2c(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). establish_c2c(C2CId, Context) -> Context1 = crossbar_doc:load(C2CId, Context, ?TYPE_CHECK_OPTION(?PVT_TYPE)), case cb_context:resp_status(Context1) of @@ -254,7 +254,7 @@ establish_c2c(C2CId, Context) -> _Status -> Context1 end. --spec maybe_migrate_history(ne_binary()) -> 'ok'. +-spec maybe_migrate_history(kz_term:ne_binary()) -> 'ok'. maybe_migrate_history(Account) -> AccountId = kz_util:format_account_id(Account), AccountDb = kz_util:format_account_db(Account), @@ -265,12 +265,12 @@ maybe_migrate_history(Account) -> {'error', _} -> 'ok' end. --spec migrate_histories(ne_binary(), ne_binary(), kz_json:objects()) -> 'ok'. +-spec migrate_histories(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:objects()) -> 'ok'. migrate_histories(AccountId, AccountDb, C2Cs) -> _ = [migrate_history(AccountId, AccountDb, kz_json:get_value(<<"doc">>, C2C)) || C2C <- C2Cs], 'ok'. --spec migrate_history(ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec migrate_history(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. migrate_history(AccountId, AccountDb, C2C) -> case kz_json:get_value(<<"pvt_history">>, C2C, []) of [] -> 'ok'; @@ -284,7 +284,7 @@ migrate_history(AccountId, AccountDb, C2C) -> ]) end. --spec save_history_item(ne_binary(), kz_json:object(), ne_binary()) -> any(). +-spec save_history_item(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> any(). save_history_item(AccountId, HistoryItem, C2CId) -> Timestamp = kz_json:get_integer_value(<<"timestamp">>, HistoryItem, kz_time:now_s()), AccountModb = kz_util:format_account_mod_id(AccountId, Timestamp), @@ -311,9 +311,9 @@ clear_history_set_type(Context) -> %% %% @end %%------------------------------------------------------------------- --spec originate_call(ne_binary(), cb_context:context()) -> cb_context:context(). --spec originate_call(ne_binary(), cb_context:context(), api_binary()) -> cb_context:context(). --spec originate_call(ne_binary(), cb_context:context(), api_binary(), boolean()) -> cb_context:context(). +-spec originate_call(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). +-spec originate_call(kz_term:ne_binary(), cb_context:context(), kz_term:api_binary()) -> cb_context:context(). +-spec originate_call(kz_term:ne_binary(), cb_context:context(), kz_term:api_binary(), boolean()) -> cb_context:context(). originate_call(C2CId, Context) -> originate_call(C2CId, Context, get_c2c_contact(cb_context:req_value(Context, <<"contact">>))). @@ -340,7 +340,7 @@ originate_call(C2CId, Context, Contact, 'true') -> lager:debug("attempting call in ~p", [JObj]), crossbar_util:response_202(<<"processing request">>, JObj, cb_context:set_resp_data(Context, Request)). --spec do_originate_call(ne_binary(), cb_context:context(), api_binary(), kz_proplist()) -> 'ok'. +-spec do_originate_call(kz_term:ne_binary(), cb_context:context(), kz_term:api_binary(), kz_term:proplist()) -> 'ok'. do_originate_call(C2CId, Context, Contact, Request) -> ReqId = cb_context:req_id(Context), kz_util:put_callid(ReqId), @@ -359,7 +359,7 @@ do_originate_call(C2CId, Context, Contact, Request) -> _ = kazoo_modb:save_doc(AccountId, HistoryItem), 'ok'. --spec match_regexps(binaries(), ne_binary()) -> boolean(). +-spec match_regexps(kz_term:binaries(), kz_term:ne_binary()) -> boolean(). match_regexps([Pattern | Rest], Number) -> case re:run(Number, Pattern) of {'match', _} -> 'true'; @@ -367,9 +367,9 @@ match_regexps([Pattern | Rest], Number) -> end; match_regexps([], _Number) -> 'false'. --spec exec_originate(api_terms()) -> - {'success', ne_binary()} | - {'error', ne_binary()}. +-spec exec_originate(kz_term:api_terms()) -> + {'success', kz_term:ne_binary()} | + {'error', kz_term:ne_binary()}. exec_originate(Request) -> handle_originate_resp( kz_amqp_worker:call_collect(Request @@ -384,8 +384,8 @@ exec_originate(Request) -> {'error', _} | {'timeout', _} ) -> - {'success', ne_binary()} | - {'error', ne_binary()}. + {'success', kz_term:ne_binary()} | + {'error', kz_term:ne_binary()}. handle_originate_resp({'ok', [Resp|_]}) -> AppResponse = kz_json:get_first_defined([<<"Application-Response">> ,<<"Hangup-Cause">> @@ -419,12 +419,12 @@ handle_originate_resp({'timeout', _T}) -> lager:debug("timed out while originating: ~p", [_T]), {'error', <<"timed out">>}. --record(contact, {route :: ne_binary() - ,number :: ne_binary() - ,name :: ne_binary() +-record(contact, {route :: kz_term:ne_binary() + ,number :: kz_term:ne_binary() + ,name :: kz_term:ne_binary() }). --spec build_originate_req(ne_binary(), cb_context:context()) -> kz_proplist(). +-spec build_originate_req(kz_term:ne_binary(), cb_context:context()) -> kz_term:proplist(). build_originate_req(Contact, Context) -> AccountId = cb_context:account_id(Context), JObj = cb_context:doc(Context), @@ -502,7 +502,7 @@ build_originate_req(Contact, Context) -> | kz_api:default_headers(<<"resource">>, <<"originate_req">>, ?APP_NAME, ?APP_VERSION) ]). --spec get_caller_callee(ne_binary(), #contact{}, #contact{}) -> {#contact{}, #contact{}}. +-spec get_caller_callee(kz_term:ne_binary(), #contact{}, #contact{}) -> {#contact{}, #contact{}}. get_caller_callee(<<"extension">>, Contact, Extension) -> {Contact, Extension}; get_caller_callee(<<"contact">>, Contact, Extension) -> {Extension, Contact}. @@ -516,12 +516,12 @@ is_resp(JObj) -> kapi_resource:originate_resp_v(JObj) orelse kz_api:error_resp_v(JObj). --spec get_c2c_contact(api_binary()) -> api_binary(). +-spec get_c2c_contact(kz_term:api_binary()) -> kz_term:api_binary(). get_c2c_contact('undefined') -> 'undefined'; get_c2c_contact(Contact) -> knm_converters:normalize(kz_http_util:urlencode(Contact)). --spec create_c2c_history_item({'success' | 'error', ne_binary()}, ne_binary(), ne_binary()) -> kz_proplist(). +-spec create_c2c_history_item({'success' | 'error', kz_term:ne_binary()}, kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:proplist(). create_c2c_history_item({'success', CallId}, C2CId, Contact) -> [{<<"timestamp">>, kz_time:now_s()} ,{<<"contact">>, Contact} diff --git a/applications/crossbar/src/modules/cb_comments.erl b/applications/crossbar/src/modules/cb_comments.erl index aaf379f7a9b..cde03b8d192 100644 --- a/applications/crossbar/src/modules/cb_comments.erl +++ b/applications/crossbar/src/modules/cb_comments.erl @@ -240,7 +240,7 @@ summary(Context) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec read(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec read(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). read(Context, Id) -> Context1 = check_comment_number(Context, Id), case cb_context:resp_status(Context1) of @@ -269,7 +269,7 @@ create(Context) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec update(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec update(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). update(Context, Id) -> Doc = cb_context:doc(Context), Comments = kz_json:get_value(?COMMENTS, Doc, []), @@ -292,7 +292,7 @@ update(Context, Id) -> %% @end %%-------------------------------------------------------------------- -spec remove(cb_context:context()) -> cb_context:context(). --spec remove(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec remove(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). remove(Context) -> Doc = kz_json:set_value(?COMMENTS, [], cb_context:doc(Context)), crossbar_doc:save(cb_context:set_doc(Context, Doc)). @@ -328,7 +328,7 @@ finish_req(_Context, _Type, _Verb) -> 'ok'. %% @doc %% @end %%-------------------------------------------------------------------- --spec check_comment_number(cb_context:context(), ne_binary()) -> +-spec check_comment_number(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). check_comment_number(Context, Id) -> Context1 = load_doc(Context), @@ -352,7 +352,7 @@ check_comment_number(Context, Id) -> %%-------------------------------------------------------------------- -spec load_doc(cb_context:context()) -> cb_context:context(). --spec load_doc(cb_context:context(), ne_binary(), ne_binaries()) -> +-spec load_doc(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binaries()) -> cb_context:context(). load_doc(Context) -> {Type, Id} = cb_context:fetch(Context, 'resource'), @@ -385,7 +385,7 @@ only_return_comments(Context) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec only_return_comment(cb_context:context(), ne_binary()) -> +-spec only_return_comment(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). only_return_comment(Context, Id) -> Doc = cb_context:doc(Context), @@ -400,7 +400,7 @@ only_return_comment(Context, Id) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec id_to_number(ne_binary()) -> pos_integer(). +-spec id_to_number(kz_term:ne_binary()) -> pos_integer(). id_to_number(Id) -> kz_term:to_integer(Id) + 1. %%-------------------------------------------------------------------- @@ -408,7 +408,7 @@ id_to_number(Id) -> kz_term:to_integer(Id) + 1. %% @doc %% @end %%-------------------------------------------------------------------- --spec send_port_comment_notification(cb_context:context(), ne_binary()) -> 'ok'. +-spec send_port_comment_notification(cb_context:context(), kz_term:ne_binary()) -> 'ok'. send_port_comment_notification(Context, PortReqId) -> Props = [{<<"user_id">>, cb_context:auth_user_id(Context)} ,{<<"account_id">>, cb_context:auth_account_id(Context)} diff --git a/applications/crossbar/src/modules/cb_conferences.erl b/applications/crossbar/src/modules/cb_conferences.erl index 012724148e0..5391b9f3e71 100644 --- a/applications/crossbar/src/modules/cb_conferences.erl +++ b/applications/crossbar/src/modules/cb_conferences.erl @@ -117,7 +117,7 @@ validate_conferences(?HTTP_GET, Context) -> validate_conferences(?HTTP_PUT, Context) -> create_conference(Context). --spec validate_conference(http_method(), cb_context:context(), ne_binary()) -> cb_context:context(). +-spec validate_conference(http_method(), cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). validate_conference(?HTTP_GET, Context0, ConferenceId) -> Context1 = maybe_load_conference(ConferenceId, Context0), case cb_context:resp_status(Context1) of @@ -133,7 +133,7 @@ validate_conference(?HTTP_PATCH, Context, ConferenceId) -> validate_conference(?HTTP_DELETE, Context, ConferenceId) -> load_conference(ConferenceId, Context). --spec validate_participants(http_method(), cb_context:context(), ne_binary()) -> cb_context:context(). +-spec validate_participants(http_method(), cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). validate_participants(?HTTP_GET, Context0, ConferenceId) -> Context1 = maybe_load_conference(ConferenceId, Context0), case cb_context:resp_status(Context1) of @@ -143,7 +143,7 @@ validate_participants(?HTTP_GET, Context0, ConferenceId) -> validate_participants(?HTTP_PUT, Context, ConferenceId) -> maybe_load_conference(ConferenceId, Context). --spec validate_participant(http_method(), cb_context:context(), ne_binary(), ne_binary()) -> cb_context:context(). +-spec validate_participant(http_method(), cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). validate_participant(?HTTP_GET, Context0, ConferenceId, ParticipantId) -> Context1 = maybe_load_conference(ConferenceId, Context0), case cb_context:resp_status(Context1) of @@ -213,7 +213,7 @@ build_conference(ConferenceId, Context) -> Merged = kz_json:merge(Conference, cb_context:req_data(Context)), crossbar_doc:handle_datamgr_success(Merged, Context). --spec load_conference(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_conference(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_conference(ConferenceId, Context) -> crossbar_doc:load(ConferenceId, Context, ?TYPE_CHECK_OPTION(kzd_conference:type())). @@ -222,16 +222,16 @@ create_conference(Context) -> OnSuccess = fun(C) -> validate_numbers('undefined', C) end, cb_context:validate_request_data(<<"conferences">>, Context, OnSuccess). --spec update_conference(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec update_conference(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). update_conference(ConferenceId, Context) -> OnSuccess = fun(C) -> validate_numbers(ConferenceId, C) end, cb_context:validate_request_data(<<"conferences">>, Context, OnSuccess). --spec patch_conference(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec patch_conference(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). patch_conference(ConferenceId, Context) -> crossbar_doc:patch_and_validate(ConferenceId, Context, fun update_conference/2). --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> cb_context:update_doc(Context, {fun kz_doc:set_type/2, <<"conference">>}); on_successful_validation(ConferenceId, Context) -> @@ -289,7 +289,7 @@ add_realtime_fold(Conference, RunningConferences) -> %% Create a new conference document with the data provided, if it is valid %% @end %%-------------------------------------------------------------------- --spec validate_numbers(api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_numbers(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_numbers(Id, Context) -> Doc = cb_context:doc(Context), Conf = kz_json:get_value(<<"conference_numbers">>, Doc, []), @@ -318,7 +318,7 @@ invalid_numbers(Context, JObjs) -> %%%=================================================================== %%% Conterence Actions %%%=================================================================== --spec handle_conference_action(cb_context:context(), ne_binary(), ne_binary()) -> cb_context:context(). +-spec handle_conference_action(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). handle_conference_action(Context, ConferenceId, <<"lock">>) -> kapps_conference_command:lock(conference(ConferenceId)), crossbar_util:response_202(<<"ok">>, Context); @@ -333,9 +333,9 @@ handle_conference_action(Context, ConferenceId, Action) -> lager:error("unhandled conference id ~p action: ~p", [ConferenceId, Action]), cb_context:add_system_error('faulty_request', Context). --spec play(cb_context:context(), path_token(), api_object()) -> +-spec play(cb_context:context(), path_token(), kz_term:api_object()) -> cb_context:context(). --spec play(cb_context:context(), path_token(), pos_integer(), api_object()) -> +-spec play(cb_context:context(), path_token(), pos_integer(), kz_term:api_object()) -> cb_context:context(). play(Context, _ConferenceId, 'undefined') -> data_required(Context, <<"play">>); @@ -347,7 +347,7 @@ play(Context, _ConferenceId, _ParticipantId, 'undefined') -> play(Context, ConferenceId, ParticipantId, Data) -> play_media(Context, ConferenceId, ParticipantId, kz_json:get_ne_binary_value(<<"media_id">>, Data)). --spec data_required(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec data_required(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). data_required(Context, Action) -> cb_context:add_validation_error(<<"data">> ,<<"required">> @@ -355,9 +355,9 @@ data_required(Context, Action) -> ,Context ). --spec play_media(cb_context:context(), path_token(), api_ne_binary()) -> +-spec play_media(cb_context:context(), path_token(), kz_term:api_ne_binary()) -> cb_context:context(). --spec play_media(cb_context:context(), path_token(), pos_integer(), api_ne_binary()) -> +-spec play_media(cb_context:context(), path_token(), pos_integer(), kz_term:api_ne_binary()) -> cb_context:context(). play_media(Context, _ConferenceId, 'undefined') -> media_id_required(Context); @@ -383,7 +383,7 @@ play_media(Context, ConferenceId, ParticipantId, MediaId) -> crossbar_util:response_202(<<"ok">>, Context) end. --spec media_id_invalid(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec media_id_invalid(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). media_id_invalid(Context, MediaId) -> crossbar_util:response_bad_identifier(MediaId, Context). @@ -395,7 +395,7 @@ media_id_required(Context) -> ,Context ). --spec dial(cb_context:context(), path_token(), api_object()) -> cb_context:context(). +-spec dial(cb_context:context(), path_token(), kz_term:api_object()) -> cb_context:context(). dial(Context, _ConferenceId, 'undefined') -> data_required(Context, <<"dial">>); dial(Context, ConferenceId, Data) -> @@ -410,7 +410,7 @@ dial(Context, ConferenceId, Data) -> end end. --spec build_valid_endpoints(cb_context:context(), ne_binary(), kz_json:object()) -> +-spec build_valid_endpoints(cb_context:context(), kz_term:ne_binary(), kz_json:object()) -> {cb_context:context(), kz_json:objects()}. build_valid_endpoints(Context, ConferenceId, Data) -> case kz_json_schema:validate(<<"conferences.dial">>, Data) of @@ -463,7 +463,7 @@ exec_dial_endpoints(Context, ConferenceId, Data, ToDial) -> ]) end. --spec zone(api_ne_binary()) -> ne_binary(). +-spec zone(kz_term:api_ne_binary()) -> kz_term:ne_binary(). zone('undefined') -> kz_config:zone('binary'); zone(TargetCallId) -> @@ -490,7 +490,7 @@ zone(TargetCallId) -> kz_config:zone('binary') end. --spec build_endpoints_to_dial(cb_context:context(), path_token(), ne_binaries()) -> +-spec build_endpoints_to_dial(cb_context:context(), path_token(), kz_term:ne_binaries()) -> {cb_context:context(), kz_json:objects()}. build_endpoints_to_dial(Context, ConferenceId, Endpoints) -> {ToDial, _Call, Context1, _Element} = @@ -510,7 +510,7 @@ error_no_endpoints(Context) -> ,Context ). --spec create_call(cb_context:context(), ne_binary()) -> kapps_call:call(). +-spec create_call(cb_context:context(), kz_term:ne_binary()) -> kapps_call:call(). create_call(Context, ConferenceId) -> Routines = [{F, V} @@ -525,7 +525,7 @@ create_call(Context, ConferenceId) -> kapps_call:exec(Routines, kapps_call:new()). -type build_acc() :: {kz_json:objects(), kapps_call:call(), cb_context:context(), pos_integer()}. --spec build_endpoint(ne_binary(), build_acc()) -> build_acc(). +-spec build_endpoint(kz_term:ne_binary(), build_acc()) -> build_acc(). build_endpoint(<<"sip:", _/binary>>=URI, {Endpoints, Call, Context, Element}) -> lager:info("building SIP endpoint ~s", [URI]), Endpoint = kz_json:from_list([{<<"Invite-Format">>, <<"route">>} @@ -562,7 +562,7 @@ add_not_endpoint_error(Context, Element) -> ,Context ). --spec build_number_endpoint(ne_binary(), build_acc()) -> build_acc(). +-spec build_number_endpoint(kz_term:ne_binary(), build_acc()) -> build_acc(). build_number_endpoint(Number, {Endpoints, Call, Context, Element}) -> AccountRealm = kapps_call:account_realm(Call), Endpoint = [{<<"Invite-Format">>, <<"loopback">>} @@ -596,7 +596,7 @@ build_endpoint_from_doc(Endpoint, Acc) -> build_endpoint_from_doc(Endpoint, Acc, kz_doc:type(Endpoint)) end. --spec build_endpoint_from_doc(kz_json:object(), build_acc(), ne_binary()) -> build_acc(). +-spec build_endpoint_from_doc(kz_json:object(), build_acc(), kz_term:ne_binary()) -> build_acc(). build_endpoint_from_doc(Device, {Endpoints, Call, Context, Element}, <<"device">>) -> Properties = kz_json:from_list([{<<"source">>, kz_term:to_binary(?MODULE)}]), case kz_endpoint:build(Device, Properties, Call) of @@ -627,7 +627,7 @@ build_endpoint_from_doc(Endpoint, {Endpoints, Call, Context, Element}, _Type) -> lager:info("ignoring endpoint type ~s for ~s", [_Type, kz_doc:id(Endpoint)]), {Endpoints, Call, add_not_found_error(Context, kz_doc:id(Endpoint), Element), Element+1}. --spec add_no_devices_error(cb_context:context(), ne_binary(), pos_integer()) -> cb_context:context(). +-spec add_no_devices_error(cb_context:context(), kz_term:ne_binary(), pos_integer()) -> cb_context:context(). add_no_devices_error(Context, UserId, Element) -> cb_context:add_validation_error([<<"data">>, <<"endpoints">>, Element] ,<<"minItems">> @@ -638,7 +638,7 @@ add_no_devices_error(Context, UserId, Element) -> ). --spec add_not_found_error(cb_context:context(), ne_binary(), pos_integer()) -> cb_context:context(). +-spec add_not_found_error(cb_context:context(), kz_term:ne_binary(), pos_integer()) -> cb_context:context(). add_not_found_error(Context, Id, Index) -> cb_context:add_validation_error([<<"data">>, <<"participants">>, Index] ,<<"not_found">> @@ -649,7 +649,7 @@ add_not_found_error(Context, Id, Index) -> %%%=================================================================== %%% Participant Actions %%%=================================================================== --spec handle_participants_action(cb_context:context(), ne_binary(), ne_binary()) -> cb_context:context(). +-spec handle_participants_action(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). handle_participants_action(Context, ConferenceId, Action=?MUTE) -> handle_participants_action(Context, ConferenceId, Action, fun(P) -> kz_json:is_false(<<"Is-Moderator">>, P) @@ -689,7 +689,7 @@ handle_participants_action(Context, _ConferenceId, _Action) -> %% action applicable to conference participants selected by selector function -type filter_fun() :: fun((kz_json:object()) -> boolean()). --spec handle_participants_action(cb_context:context(), ne_binary(), ne_binary(), filter_fun()) -> +-spec handle_participants_action(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary(), filter_fun()) -> cb_context:context(). handle_participants_action(Context, ConferenceId, Action, Selector) -> ConfData = request_conference_details(ConferenceId), @@ -757,7 +757,7 @@ participant_not_found(ParticipantId, Context) -> ,Context ). --spec perform_participant_action(kapps_conference:conference(), ne_binary(), api_integer()) -> 'ok'. +-spec perform_participant_action(kapps_conference:conference(), kz_term:ne_binary(), kz_term:api_integer()) -> 'ok'. perform_participant_action(Conference, ?MUTE, ParticipantId) -> kapps_conference_command:mute_participant(ParticipantId, Conference); perform_participant_action(Conference, ?UNMUTE, ParticipantId) -> @@ -770,7 +770,7 @@ perform_participant_action(Conference, ?KICK, ParticipantId) -> kapps_conference_command:kick(ParticipantId, Conference). %% add real-time call-info to participants --spec enrich_participant(ne_binary(), ne_binary(), cb_context:context()) -> cb_context:context(). +-spec enrich_participant(kz_term:ne_binary(), kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). enrich_participant(ParticipantId, ConferenceId, Context) -> Participants = extract_participants( request_conference_details(ConferenceId) @@ -781,7 +781,7 @@ enrich_participant(ParticipantId, ConferenceId, Context) -> ] ++ [kz_json:new()], cb_context:set_resp_data(Context, Normalized). --spec enrich_participants(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec enrich_participants(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). enrich_participants(ConferenceId, Context) -> Participants = extract_participants( request_conference_details(ConferenceId) @@ -789,13 +789,13 @@ enrich_participants(ConferenceId, Context) -> Normalized = [kz_json:normalize_jobj(JObj) || JObj <- Participants], cb_context:set_resp_data(Context, Normalized). --spec enrich_conference(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec enrich_conference(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). enrich_conference(ConferenceId, Context) -> RealtimeData = conference_realtime_data(ConferenceId), Response = kz_json:set_value(<<"_read_only">>, RealtimeData, cb_context:resp_data(Context)), cb_context:set_resp_data(Context, Response). --spec conference_realtime_data(ne_binary()) -> kz_json:object(). +-spec conference_realtime_data(kz_term:ne_binary()) -> kz_json:object(). conference_realtime_data(ConferenceId) -> ConferenceDetails = request_conference_details(ConferenceId), Participants = extract_participants(ConferenceDetails), @@ -808,7 +808,7 @@ conference_realtime_data(ConferenceId) -> ,{<<"participants">>, [kz_json:normalize_jobj(Participant) || Participant <- Participants]} ]). --spec request_conference_details(ne_binary()) -> kz_json:object(). +-spec request_conference_details(kz_term:ne_binary()) -> kz_json:object(). request_conference_details(ConferenceId) -> Req = [{<<"Conference-ID">>, ConferenceId} | kz_api:default_headers(?APP_NAME, ?APP_VERSION) @@ -836,7 +836,7 @@ find_conference_details(JObjs) -> %%%=================================================================== %%% Utility functions %%%=================================================================== --spec conference(ne_binary()) -> kapps_conference:conference(). +-spec conference(kz_term:ne_binary()) -> kapps_conference:conference(). conference(ConferenceId) -> kapps_conference:set_id(ConferenceId, kapps_conference:new()). diff --git a/applications/crossbar/src/modules/cb_configs.erl b/applications/crossbar/src/modules/cb_configs.erl index 43fc96b4536..50657284ab9 100644 --- a/applications/crossbar/src/modules/cb_configs.erl +++ b/applications/crossbar/src/modules/cb_configs.erl @@ -72,7 +72,7 @@ validate(Context, ?HTTP_POST, ConfigId) -> Parent = kapps_config_util:get_reseller_config(cb_context:account_id(Context), ConfigId), validate_with_parent(Context, ConfigId, Parent). --spec validate_with_parent(cb_context:context(), ne_binary(), kz_json:object()) -> cb_context:context(). +-spec validate_with_parent(cb_context:context(), kz_term:ne_binary(), kz_json:object()) -> cb_context:context(). validate_with_parent(Context, ConfigId, Parent) -> RequestData = strip_id(cb_context:req_data(Context)), FullConfig = kz_json:merge(Parent, RequestData), @@ -102,12 +102,12 @@ delete(Context, _ConfigId) -> _ -> crossbar_doc:delete(Context, ?HARD_DELETE) end. --spec set_config_to_context(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec set_config_to_context(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). set_config_to_context(ConfigId, Context) -> Config = kapps_config_util:get_config(cb_context:account_id(Context), ConfigId), crossbar_doc:handle_datamgr_success(set_id(ConfigId, Config), Context). --spec set_id(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec set_id(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). set_id(ConfigId, JObj) -> kz_json:set_value(<<"id">>, kapps_config_util:account_doc_id(ConfigId), JObj). -spec strip_id(kz_json:object()) -> kz_json:object(). diff --git a/applications/crossbar/src/modules/cb_connectivity.erl b/applications/crossbar/src/modules/cb_connectivity.erl index ed8751106e1..d16c2514881 100644 --- a/applications/crossbar/src/modules/cb_connectivity.erl +++ b/applications/crossbar/src/modules/cb_connectivity.erl @@ -181,12 +181,12 @@ track_assignment('delete', Context) -> %% %% @end %%-------------------------------------------------------------------- --spec get_numbers(kz_json:object()) -> ne_binaries(). +-spec get_numbers(kz_json:object()) -> kz_term:ne_binaries(). get_numbers(JObj) -> Servers = kz_json:get_value(<<"servers">>, JObj, []), lists:foldl(fun get_numbers_fold/2, [], Servers). --spec get_numbers_fold(kz_json:object(), ne_binaries()) -> ne_binaries(). +-spec get_numbers_fold(kz_json:object(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). get_numbers_fold(Server, Acc) -> kz_json:get_keys(kz_json:get_value(<<"DIDs">>, Server, kz_json:new())) ++ Acc. @@ -213,7 +213,7 @@ create(Context) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec read(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec read(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). read(Id, Context) -> crossbar_doc:load(Id, Context, ?TYPE_CHECK_OPTION(<<"sys_info">>)). @@ -224,7 +224,7 @@ read(Id, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec update(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec update(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). update(Id, Context) -> OnSuccess = fun(C) -> C1 = on_successful_validation(Id, C), @@ -242,7 +242,7 @@ update(Id, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec validate_patch(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_patch(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). validate_patch(Id, Context) -> crossbar_doc:patch_and_validate(Id, Context, fun update/2). @@ -252,7 +252,7 @@ validate_patch(Id, Context) -> %% %% @end %%-------------------------------------------------------------------- --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> cb_context:set_doc(Context, kz_doc:set_type(cb_context:doc(Context), <<"sys_info">>)); on_successful_validation(Id, Context) -> diff --git a/applications/crossbar/src/modules/cb_dialplans.erl b/applications/crossbar/src/modules/cb_dialplans.erl index 380fd686f82..59a22598e50 100644 --- a/applications/crossbar/src/modules/cb_dialplans.erl +++ b/applications/crossbar/src/modules/cb_dialplans.erl @@ -68,11 +68,11 @@ validate(Context) -> ,{fun cb_context:set_resp_status/2, 'success'} ]). --spec maybe_add_name(kz_proplist()) -> kz_json:object(). +-spec maybe_add_name(kz_term:proplist()) -> kz_json:object(). maybe_add_name(KVs) -> maybe_add_name(KVs, kz_json:new()). --spec maybe_add_name(kz_proplist(), kz_json:object()) -> kz_json:object(). +-spec maybe_add_name(kz_term:proplist(), kz_json:object()) -> kz_json:object(). maybe_add_name([], Acc) -> Acc; maybe_add_name([{K, V} | KVs], Acc0) when is_list(V) -> diff --git a/applications/crossbar/src/modules/cb_directories.erl b/applications/crossbar/src/modules/cb_directories.erl index e6b01222886..13a72657c7c 100644 --- a/applications/crossbar/src/modules/cb_directories.erl +++ b/applications/crossbar/src/modules/cb_directories.erl @@ -188,7 +188,7 @@ validate_directories(Context, ?HTTP_PUT) -> %% Create a new instance with the data provided, if it is valid %% @end %%-------------------------------------------------------------------- --spec validate_directory(cb_context:context(), ne_binary(), path_token()) -> cb_context:context(). +-spec validate_directory(cb_context:context(), kz_term:ne_binary(), path_token()) -> cb_context:context(). validate_directory(Context, Id, ?HTTP_GET) -> read(Id, Context); validate_directory(Context, Id, ?HTTP_POST) -> @@ -220,7 +220,7 @@ get_pdf(Context) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec pdf_props(cb_context:context()) -> kz_proplist(). +-spec pdf_props(cb_context:context()) -> kz_term:proplist(). pdf_props(Context) -> RespData = cb_context:resp_data(Context), AccountId = cb_context:account_id(Context), @@ -242,8 +242,8 @@ pdf_props(Context) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec pdf_users(ne_binary(), ne_binary(), kz_json:objects()) -> any(). --spec pdf_users(ne_binary(), ne_binary(), kz_json:objects(), any()) -> any(). +-spec pdf_users(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:objects()) -> any(). +-spec pdf_users(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:objects(), any()) -> any(). pdf_users(AccountId, SortBy, Users) -> AccountDb = kz_util:format_account_id(AccountId, 'encoded'), pdf_users(AccountDb, SortBy, Users, []). @@ -264,7 +264,7 @@ pdf_users(AccountDb, SortBy, [JObj|Users], Acc) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec pdf_user(ne_binary(), ne_binary()) -> kz_proplist(). +-spec pdf_user(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:proplist(). pdf_user(AccountDb, UserId) -> case kz_datamgr:open_cache_doc(AccountDb, UserId) of {'error', _R} -> @@ -279,7 +279,7 @@ pdf_user(AccountDb, UserId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec pdf_callflow(ne_binary(), ne_binary()) -> kz_proplist(). +-spec pdf_callflow(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:proplist(). pdf_callflow(AccountDb, CallflowId) -> case kz_datamgr:open_cache_doc(AccountDb, CallflowId) of {'error', _R} -> @@ -306,7 +306,7 @@ create(Context) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec read(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec read(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). read(Id, Context) -> Context1 = crossbar_doc:load(Id, Context, ?TYPE_CHECK_OPTION(<<"directory">>)), case cb_context:resp_status(Context1) of @@ -315,7 +315,7 @@ read(Id, Context) -> _Status -> Context1 end. --spec load_directory_users(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_directory_users(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_directory_users(Id, Context) -> Context1 = crossbar_doc:load_view(?CB_USERS_LIST ,[{'key', Id}] @@ -337,7 +337,7 @@ load_directory_users(Id, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec update(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec update(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). update(DocId, Context) -> OnSuccess = fun(C) -> on_successful_validation(DocId, C) end, cb_context:validate_request_data(<<"directories">>, Context, OnSuccess). @@ -349,7 +349,7 @@ update(DocId, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec validate_patch(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_patch(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). validate_patch(DocId, Context) -> crossbar_doc:patch_and_validate(DocId, Context, fun update/2). @@ -359,7 +359,7 @@ validate_patch(DocId, Context) -> %% %% @end %%-------------------------------------------------------------------- --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> cb_context:set_doc(Context ,kz_doc:set_type(cb_context:doc(Context), <<"directory">>) diff --git a/applications/crossbar/src/modules/cb_faxboxes.erl b/applications/crossbar/src/modules/cb_faxboxes.erl index 90c0699cb3e..31411e58404 100644 --- a/applications/crossbar/src/modules/cb_faxboxes.erl +++ b/applications/crossbar/src/modules/cb_faxboxes.erl @@ -52,10 +52,10 @@ ,<<"update_url">> ]). --type fax_field_name() :: ne_binary(). --type fax_file_name() :: ne_binary(). +-type fax_field_name() :: kz_term:ne_binary(). +-type fax_file_name() :: kz_term:ne_binary(). -type fax_file_content() :: binary() | iolist(). --type fax_content_type() :: ne_binary(). +-type fax_content_type() :: kz_term:ne_binary(). -type fax_file() :: {fax_field_name(), fax_file_name(), fax_file_content(), fax_content_type()}. -type fax_files() :: [fax_file()]. @@ -260,7 +260,7 @@ create_faxbox(Context) -> OnSuccess = fun(C) -> on_faxbox_successful_validation('undefined', C) end, cb_context:validate_request_data(<<"faxbox">>, Context, OnSuccess). --spec delete_faxbox(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec delete_faxbox(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). delete_faxbox(Id, Context) -> read(Id, Context). @@ -270,7 +270,7 @@ delete_faxbox(Id, Context) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec read(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec read(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). read(Id, Context) -> Ctx1 = crossbar_doc:load(Id, Context, ?TYPE_CHECK_OPTION(kzd_fax_box:type())), case cb_context:doc(Ctx1) of @@ -283,7 +283,7 @@ leak_private_fields(JObj) -> J = kz_json:set_value(<<"id">>, kz_doc:id(JObj), JObj), lists:foldl(fun leak_private_field/2, J, ?LEAKED_FIELDS). --spec leak_private_field(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec leak_private_field(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). leak_private_field(<<"pvt_", K1/binary>> = K, Acc) -> case kz_json:get_value(K, Acc) of 'undefined' -> Acc; @@ -291,7 +291,7 @@ leak_private_field(<<"pvt_", K1/binary>> = K, Acc) -> end; leak_private_field(_K, Acc) -> Acc. --spec leak_private_field_value(ne_binary(), ne_binary(), kz_json:json_term(), kz_json:object()) -> +-spec leak_private_field_value(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:json_term(), kz_json:object()) -> kz_json:object(). leak_private_field_value(?CLOUD_CLAIM_URL_FIELD, K1, V, Acc) -> case kz_json:get_value(?CLOUD_STATE_FIELD, Acc) of @@ -309,7 +309,7 @@ remove_private_fields(Context) -> ), cb_context:set_req_data(Context, JObj1). --spec remove_private_fields_fold(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec remove_private_fields_fold(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). remove_private_fields_fold(<<"pvt_", K1/binary>>, Acc) -> case kz_json:get_value(K1, Acc) of 'undefined' -> Acc; @@ -323,7 +323,7 @@ remove_private_fields_fold(<<"pvt_", K1/binary>>, Acc) -> %% valid %% @end %%-------------------------------------------------------------------- --spec update_faxbox(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec update_faxbox(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). update_faxbox(Id, Context) -> OnSuccess = fun(C) -> on_faxbox_successful_validation(Id, C) end, cb_context:validate_request_data(<<"faxbox">>, Context, OnSuccess). @@ -334,7 +334,7 @@ update_faxbox(Id, Context) -> %% %% @end %%-------------------------------------------------------------------- --spec on_faxbox_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_faxbox_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_faxbox_successful_validation('undefined', Context) -> cb_context:set_doc(Context ,kz_json:set_values([{<<"pvt_type">>, kzd_fax_box:type()} @@ -350,7 +350,7 @@ on_faxbox_successful_validation('undefined', Context) -> on_faxbox_successful_validation(DocId, Context) -> crossbar_doc:load_merge(DocId, Context, ?TYPE_CHECK_OPTION(kzd_fax_box:type())). --spec generate_email_address(cb_context:context()) -> ne_binary(). +-spec generate_email_address(cb_context:context()) -> kz_term:ne_binary(). generate_email_address(Context) -> ResellerId = cb_context:reseller_id(Context), Domain = kapps_account_config:get_global(ResellerId, <<"fax">>, <<"default_smtp_domain">>, ?DEFAULT_FAX_SMTP_DOMAIN), @@ -377,7 +377,7 @@ faxbox_listing(Context) -> normalize_view_results(JObj, Acc) -> [leak_private_fields(kz_json:get_value(<<"doc">>, JObj)) | Acc]. --spec is_faxbox_email_global_unique(ne_binary(), ne_binary()) -> boolean(). +-spec is_faxbox_email_global_unique(kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_faxbox_email_global_unique(Email, FaxBoxId) -> ViewOptions = [{'key', kz_term:to_lower_binary(Email)}], case kz_datamgr:get_results(?KZ_FAXES_DB, <<"faxbox/email_address">>, ViewOptions) of @@ -388,7 +388,7 @@ is_faxbox_email_global_unique(Email, FaxBoxId) -> end. -spec maybe_reregister_cloud_printer(cb_context:context()) -> cb_context:context(). --spec maybe_reregister_cloud_printer(api_binary(), cb_context:context()) -> cb_context:context(). +-spec maybe_reregister_cloud_printer(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). maybe_reregister_cloud_printer(Context) -> CurrentState = kz_json:get_value(<<"pvt_cloud_state">>, cb_context:doc(Context)), Ctx = maybe_reregister_cloud_printer(CurrentState, Context), @@ -427,7 +427,7 @@ maybe_register_cloud_printer(Context, JObj) -> _PrinterId -> Context end. --spec register_cloud_printer(cb_context:context(), ne_binary()) -> kz_proplist(). +-spec register_cloud_printer(cb_context:context(), kz_term:ne_binary()) -> kz_term:proplist(). register_cloud_printer(Context, FaxboxId) -> ResellerId = cb_context:reseller_id(Context), Boundary = <<"------", (kz_binary:rand_hex(16))/binary>>, @@ -455,7 +455,7 @@ register_cloud_printer(Context, FaxboxId) -> [] end. --spec get_cloud_registered_properties(kz_json:object()) -> kz_proplist(). +-spec get_cloud_registered_properties(kz_json:object()) -> kz_term:proplist(). get_cloud_registered_properties(JObj) -> [PrinterDoc] = kz_json:get_value(<<"printers">>, JObj), [{<<"pvt_cloud_printer_id">>, kz_doc:id(PrinterDoc)} @@ -469,7 +469,7 @@ get_cloud_registered_properties(JObj) -> ,{<<"pvt_cloud_oauth_scope">>, kz_json:get_value(<<"oauth_scope">>, JObj)} ]. --spec register_body(ne_binary(), ne_binary(), ne_binary()) -> iolist(). +-spec register_body(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> iolist(). register_body(ResellerId, FaxboxId, Boundary) -> {'ok', DefaultFields} = file:consult( [filename:join( @@ -501,14 +501,14 @@ register_body(ResellerId, FaxboxId, Boundary) -> ,Files ). --spec format_multipart_formdata(ne_binary(), kz_proplist(), fax_files()) -> iolist(). +-spec format_multipart_formdata(kz_term:ne_binary(), kz_term:proplist(), fax_files()) -> iolist(). format_multipart_formdata(Boundary, Fields, Files) -> EndingParts = [<<"--", Boundary/binary, "--">>, <<"">>], FileParts = build_file_parts(Boundary, Files, EndingParts), FieldParts = build_field_parts(Boundary, Fields, FileParts), lists:foldr(fun join_formdata_fold/2, [], FieldParts). --spec build_field_parts(ne_binary(), kz_proplist(), iolist()) -> iolist(). +-spec build_field_parts(kz_term:ne_binary(), kz_term:proplist(), iolist()) -> iolist(). build_field_parts(Boundary, Fields, Acc0) -> lists:foldr(fun({FieldName, FieldContent}, Acc) -> [<<"--", Boundary/binary>> @@ -522,7 +522,7 @@ build_field_parts(Boundary, Fields, Acc0) -> ,Fields ). --spec build_file_parts(ne_binary(), fax_files(), iolist()) -> iolist(). +-spec build_file_parts(kz_term:ne_binary(), fax_files(), iolist()) -> iolist(). build_file_parts(Boundary, Files, Acc0) -> lists:foldr(fun({FieldName, FileName, FileContent, FileContentType}, Acc) -> [<<"--", Boundary/binary>> @@ -537,17 +537,17 @@ build_file_parts(Boundary, Files, Acc0) -> ,Files ). --spec join_formdata_fold(ne_binary(), iolist()) -> iolist(). +-spec join_formdata_fold(kz_term:ne_binary(), iolist()) -> iolist(). join_formdata_fold(Bin, Acc) -> string:join([binary_to_list(Bin), Acc], "\r\n"). --spec maybe_oauth_req(kz_json:object(), api_binary(), cb_context:context()) -> cb_context:context(). +-spec maybe_oauth_req(kz_json:object(), kz_term:api_binary(), cb_context:context()) -> cb_context:context(). maybe_oauth_req(_Doc, 'undefined', Context) -> maybe_reregister_cloud_printer(Context); maybe_oauth_req(Doc, _, Context) -> oauth_req(Doc, kz_json:get_value(<<"pvt_cloud_refresh_token">>, Doc), Context). --spec oauth_req(kz_json:object(), api_binary(), cb_context:context()) -> cb_context:context(). +-spec oauth_req(kz_json:object(), kz_term:api_binary(), cb_context:context()) -> cb_context:context(). oauth_req(Doc, 'undefined', Context) -> cb_context:set_resp_data(Context, kz_doc:public_fields(leak_private_fields(Doc))); oauth_req(Doc, OAuthRefresh, Context) -> @@ -572,7 +572,7 @@ faxbox_doc_save(Context) -> _ -> Ctx3 end. --spec faxbox_doc_delete(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec faxbox_doc_delete(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). faxbox_doc_delete(Context, Id) -> Ctx2 = crossbar_doc:delete(Context), _ = crossbar_doc:delete( diff --git a/applications/crossbar/src/modules/cb_faxes.erl b/applications/crossbar/src/modules/cb_faxes.erl index 9157f23478e..a297959de72 100644 --- a/applications/crossbar/src/modules/cb_faxes.erl +++ b/applications/crossbar/src/modules/cb_faxes.erl @@ -156,7 +156,7 @@ resource_exists(?OUTGOING, _Id) -> 'true'. resource_exists(?INBOX, _Id, ?ATTACHMENT) -> 'true'; resource_exists(?OUTBOX, _Id, ?ATTACHMENT) -> 'true'. --spec acceptable_content_types() -> kz_proplist(). +-spec acceptable_content_types() -> kz_term:proplist(). acceptable_content_types() -> ?ACCEPTED_MIME_TYPES. @@ -169,7 +169,7 @@ content_types_accepted(Context, ?OUTGOING) -> maybe_add_types_accepted(Context, cb_context:req_verb(Context)); content_types_accepted(Context, _) -> Context. --spec maybe_add_types_accepted(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec maybe_add_types_accepted(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). maybe_add_types_accepted(Context, ?HTTP_PUT) -> cb_context:add_content_types_accepted(Context, ?ACCEPTED_TYPES); maybe_add_types_accepted(Context, _) -> Context. @@ -200,7 +200,7 @@ content_types_provided(Context, ?OUTBOX, FaxId, ?ATTACHMENT) -> content_types_provided(Context, _, _, _) -> Context. --spec content_types_provided_for_fax(cb_context:context(), ne_binary(), ne_binary(), http_method()) -> +-spec content_types_provided_for_fax(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary(), http_method()) -> cb_context:context(). content_types_provided_for_fax(Context, FaxId, Folder, ?HTTP_GET) -> Context1 = load_fax_meta(FaxId, Folder, Context), @@ -297,7 +297,7 @@ validate_modb_fax_attachment(Context, Id, Folder, ?HTTP_GET) -> validate_modb_fax_attachment(Context, Id, Folder, ?HTTP_DELETE) -> load_modb_fax_doc(Id, Folder, Context). --spec validate_outbox_fax_action(api_binary(), ne_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_outbox_fax_action(kz_term:api_binary(), kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). validate_outbox_fax_action('undefined', _Id, Context) -> cb_context:add_system_error(<<"action required">>, Context); validate_outbox_fax_action(Action, Id, Context) -> @@ -306,7 +306,7 @@ validate_outbox_fax_action(Action, Id, Context) -> 'false' -> cb_context:add_system_error(<<"invalid action">>, Context) end. --spec validate_inbox_fax_action(api_binary(), ne_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_inbox_fax_action(kz_term:api_binary(), kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). validate_inbox_fax_action('undefined', _Id, Context) -> cb_context:add_system_error(<<"action required">>, Context); validate_inbox_fax_action(Action, Id, Context) -> @@ -392,7 +392,7 @@ maybe_add_faxbox_data(FaxBoxDoc, Context) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec read(ne_binary(), ne_binary(), cb_context:context()) -> cb_context:context(). +-spec read(kz_term:ne_binary(), kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). read(?MATCH_MODB_PREFIX(YYYY,MM,_) = Id, Type, Context) -> Year = kz_term:to_integer(YYYY), Month = kz_term:to_integer(MM), @@ -400,11 +400,11 @@ read(?MATCH_MODB_PREFIX(YYYY,MM,_) = Id, Type, Context) -> read(Id, Type, Context) -> crossbar_doc:load({Type, Id}, Context, ?TYPE_CHECK_OPTION(Type)). --spec load_modb_fax_doc(ne_binary(), ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_modb_fax_doc(kz_term:ne_binary(), kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_modb_fax_doc(Id, Folder, Context) -> validate_fax_doc_folder(Folder, read(Id, ?FAX_TYPE, Context)). --spec validate_fax_doc_folder(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_fax_doc_folder(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). validate_fax_doc_folder(Folder, Context) -> case cb_context:resp_status(Context) of 'success' -> @@ -414,22 +414,22 @@ validate_fax_doc_folder(Folder, Context) -> Context end. --spec validate_fax_doc_folder(ne_binary(), api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_fax_doc_folder(kz_term:ne_binary(), kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_fax_doc_folder(Folder, Folder, Context) -> Context; validate_fax_doc_folder(Folder, _DocFolder, Context) -> cb_context:add_system_error(<<"document is not in folder ", Folder/binary>>, Context). --spec load_smtp_log_doc(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_smtp_log_doc(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_smtp_log_doc(Id, Context) -> read(Id, ?SMTP_TYPE, Context). --spec load_outgoing_fax_doc(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_outgoing_fax_doc(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_outgoing_fax_doc(Id, Context) -> Ctx = read(Id, ?FAX_TYPE, Context), crossbar_util:apply_response_map(Ctx, ?OUTGOING_FAX_DOC_MAP). --spec get_delivered_date(kz_json:object()) -> api_integer(). +-spec get_delivered_date(kz_json:object()) -> kz_term:api_integer(). get_delivered_date(JObj) -> case kz_json:get_value(<<"pvt_delivered_date">>, JObj) of 'undefined' -> @@ -440,7 +440,7 @@ get_delivered_date(JObj) -> Date -> Date end. --spec get_execution_status(ne_binary(), kz_json:object()) -> api_binary(). +-spec get_execution_status(kz_term:ne_binary(), kz_json:object()) -> kz_term:api_binary(). get_execution_status(Id, JObj) -> case kz_json:get_value(<<"pvt_job_status">>, JObj) of <<"processing">> = S -> @@ -451,7 +451,7 @@ get_execution_status(Id, JObj) -> Status -> Status end. --spec get_fax_running_status(ne_binary(), ne_binary()) -> ne_binary(). +-spec get_fax_running_status(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). get_fax_running_status(Id, Q) -> Api = [{<<"Job-ID">>, Id} | kz_api:default_headers(?APP_NAME, ?APP_VERSION)], case kapps_util:amqp_pool_request(Api @@ -469,7 +469,7 @@ get_fax_running_status(Id, Q) -> %% Load a fax document from the database %% @end %%-------------------------------------------------------------------- --spec load_fax_meta(ne_binary(), ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_fax_meta(kz_term:ne_binary(), kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_fax_meta(FaxId, Folder, Context) -> validate_fax_doc_folder(Folder, crossbar_doc:load({<<"fax">>, FaxId}, Context, ?TYPE_CHECK_OPTION(<<"fax">>))). @@ -479,7 +479,7 @@ load_fax_meta(FaxId, Folder, Context) -> %% %% @end %%-------------------------------------------------------------------- --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> case cb_context:req_files(Context) =:= [] andalso kzd_fax:document_url(cb_context:doc(Context)) =:= 'undefined' @@ -533,11 +533,11 @@ on_success(Context) -> ) ). --spec maybe_add_timezone(cb_context:context()) -> kz_proplist(). +-spec maybe_add_timezone(cb_context:context()) -> kz_term:proplist(). maybe_add_timezone(Context) -> maybe_add_timezone(Context, kz_json:get_value(<<"timezone">>, cb_context:doc(Context))). --spec maybe_add_timezone(cb_context:context(), api_binary()) -> kz_proplist(). +-spec maybe_add_timezone(cb_context:context(), kz_term:api_binary()) -> kz_term:proplist(). maybe_add_timezone(Context, 'undefined') -> AuthDoc = cb_context:auth_doc(Context), OwnerId = kz_json:get_value(<<"owner_id">>, AuthDoc), @@ -546,7 +546,7 @@ maybe_add_timezone(Context, 'undefined') -> maybe_add_timezone(_Context, Timezone) -> [{<<"fax_timezone">>, Timezone}]. --spec initial_job_status(req_files()) -> ne_binary(). +-spec initial_job_status(req_files()) -> kz_term:ne_binary(). initial_job_status([]) -> <<"pending">>; initial_job_status(_) -> <<"attaching_files">>. @@ -563,7 +563,7 @@ inbox_summary(Context) -> fax_modb_summary(Context, ?INBOX). -spec outbox_summary(cb_context:context()) -> cb_context:context(). outbox_summary(Context) -> fax_modb_summary(Context, ?OUTBOX). --spec fax_modb_summary(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec fax_modb_summary(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). fax_modb_summary(Context, Folder) -> {ViewName, Opts} = get_view_and_filter(Context, get_filter_doc(Context), Folder), Options = [{'mapper', fun normalize_modb_view_results/2} @@ -572,8 +572,8 @@ fax_modb_summary(Context, Folder) -> ], crossbar_view:load_modb(Context, ViewName, Options). --spec get_view_and_filter(cb_context:context(), {api_ne_binary(), api_ne_binary()}, api_ne_binary()) -> - {ne_binary(), crossbar_view:options()}. +-spec get_view_and_filter(cb_context:context(), {kz_term:api_ne_binary(), kz_term:api_ne_binary()}, kz_term:api_ne_binary()) -> + {kz_term:ne_binary(), crossbar_view:options()}. get_view_and_filter(_, {?NE_BINARY=Id, <<"faxbox">>}, ?NE_BINARY=Folder) -> {?CB_LIST_BY_FAXBOX ,[{'range_keymap', [Id, Folder]}] @@ -599,14 +599,14 @@ get_view_and_filter(Context, {_, _}, 'undefined') -> ] }. --spec get_filter_doc(cb_context:context()) -> {api_ne_binary(), api_ne_binary()}. +-spec get_filter_doc(cb_context:context()) -> {kz_term:api_ne_binary(), kz_term:api_ne_binary()}. get_filter_doc(Context) -> case cb_context:fetch(Context, <<"faxbox">>) of 'undefined' -> maybe_user_filter_doc(Context); JObj -> {kz_doc:id(JObj), kz_doc:type(JObj)} end. --spec maybe_user_filter_doc(cb_context:context()) -> {api_ne_binary(), api_ne_binary()}. +-spec maybe_user_filter_doc(cb_context:context()) -> {kz_term:api_ne_binary(), kz_term:api_ne_binary()}. maybe_user_filter_doc(Context) -> case cb_context:user_id(Context) of 'undefined' -> {'undefined', 'undefined'}; @@ -645,7 +645,7 @@ do_load_fax_binary(FaxId, Folder, Context) -> _Status -> Context1 end. --spec set_fax_binary(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec set_fax_binary(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). set_fax_binary(Context, AttachmentId) -> Disposition = cb_context:req_param(Context, <<"disposition">>, <<"attachment">>), cb_context:setters(crossbar_doc:load_attachment(cb_context:doc(Context), AttachmentId, ?TYPE_CHECK_OPTION(<<"fax">>), Context) @@ -724,7 +724,7 @@ set_pending(Context, DocId) -> ], crossbar_doc:save(cb_context:set_doc(Ctx1, kz_json:set_values(KVs, cb_context:doc(Ctx1)))). --spec do_put_action(cb_context:context(), ne_binary(), ne_binary(), ne_binary()) -> cb_context:context(). +-spec do_put_action(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). do_put_action(Context, ?OUTBOX, ?OUTBOX_ACTION_RESUBMIT, Id) -> ReqData = kz_doc:public_fields(cb_context:req_data(Context)), Fun = fun(_Source, Target) -> set_resubmit_data(kz_json:merge_jobjs(ReqData, Target)) end, diff --git a/applications/crossbar/src/modules/cb_freeswitch.erl b/applications/crossbar/src/modules/cb_freeswitch.erl index eaea5fe0ce8..d3eb2a0662d 100644 --- a/applications/crossbar/src/modules/cb_freeswitch.erl +++ b/applications/crossbar/src/modules/cb_freeswitch.erl @@ -150,7 +150,7 @@ maybe_load_last_data(Context) -> cb_context:add_system_error(Error, Context) end. --spec load_last_data(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec load_last_data(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_last_data(Context, File) -> {'ok', AttachBin} = file:read_file(File), BaseName = kz_term:to_binary(filename:basename(File)), @@ -165,7 +165,7 @@ load_last_data(Context, File) -> } ]). --spec extension_to_content_type(ne_binary()) -> ne_binary(). +-spec extension_to_content_type(kz_term:ne_binary()) -> kz_term:ne_binary(). extension_to_content_type(<<".gzip">>) -> ?MIME_TYPE_GZIP; extension_to_content_type(<<".zip">>) -> ?MIME_TYPE_ZIP2; extension_to_content_type(<<".rar">>) -> ?MIME_TYPE_RAR; diff --git a/applications/crossbar/src/modules/cb_global_provisioner_templates.erl b/applications/crossbar/src/modules/cb_global_provisioner_templates.erl index a137e6e6565..80bbafadd02 100644 --- a/applications/crossbar/src/modules/cb_global_provisioner_templates.erl +++ b/applications/crossbar/src/modules/cb_global_provisioner_templates.erl @@ -75,7 +75,7 @@ init_db() -> %% Add content types provided by this module %% @end %%-------------------------------------------------------------------- --spec acceptable_content_types() -> kz_proplist(). +-spec acceptable_content_types() -> kz_term:proplist(). acceptable_content_types() -> ?MIME_TYPES. -spec content_types_provided(cb_context:context(), path_token(), path_token()) -> @@ -97,7 +97,7 @@ content_types_provided_for_provisioner(Context, _, _, _) -> Context. %% @private --spec get_content_type(kz_json:object()) -> ne_binary(). +-spec get_content_type(kz_json:object()) -> kz_term:ne_binary(). get_content_type(JObj) -> kz_doc:attachment_content_type(JObj, ?IMAGE_REQ, <<"application/octet-stream">>). @@ -182,8 +182,8 @@ validate_verb(Context, ?HTTP_POST, DocId) -> validate_verb(Context, ?HTTP_DELETE, DocId) -> load_provisioner_template(DocId, cb_context:set_account_db(Context, ?KZ_PROVISIONER_DB)). --spec validate(cb_context:context(), path_token(), ne_binary()) -> cb_context:context(). --spec validate_verb(cb_context:context(), http_method(), path_token(), ne_binary()) -> +-spec validate(cb_context:context(), path_token(), kz_term:ne_binary()) -> cb_context:context(). +-spec validate_verb(cb_context:context(), http_method(), path_token(), kz_term:ne_binary()) -> cb_context:context(). validate(Context, DocId, Noun) -> validate_verb(Context, cb_context:req_verb(Context), DocId, Noun). @@ -326,7 +326,7 @@ create_provisioner_template(Context) -> %% Load a provision template document from the database %% @end %%-------------------------------------------------------------------- --spec load_provisioner_template(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_provisioner_template(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_provisioner_template(DocId, Context) -> %% see note at top of file Context1 = crossbar_doc:load(DocId, Context, ?TYPE_CHECK_OPTION(<<"provisioner_template">>)), @@ -350,7 +350,7 @@ load_provisioner_template(DocId, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec update_provisioner_template(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec update_provisioner_template(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). update_provisioner_template(DocId, Context) -> OnSuccess = fun(C) -> on_successful_validation(DocId, C) end, cb_context:validate_request_data(<<"provisioner_templates">>, Context, OnSuccess). @@ -361,7 +361,7 @@ update_provisioner_template(DocId, Context) -> %% %% @end %%-------------------------------------------------------------------- --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> C = cb_context:set_doc(Context, kz_json:set_values([{<<"pvt_type">>, <<"provisioner_template">>} ,{<<"pvt_provider">>, <<"provisioner.net">>} diff --git a/applications/crossbar/src/modules/cb_groups.erl b/applications/crossbar/src/modules/cb_groups.erl index c8da5a9453c..7e889ae5613 100644 --- a/applications/crossbar/src/modules/cb_groups.erl +++ b/applications/crossbar/src/modules/cb_groups.erl @@ -163,7 +163,7 @@ create(Context) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec read(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec read(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). read(Id, Context) -> crossbar_doc:load(Id, Context, ?TYPE_CHECK_OPTION(<<"group">>)). @@ -174,7 +174,7 @@ read(Id, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec update(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec update(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). update(Id, Context) -> OnSuccess = fun(C) -> on_successful_validation(Id, C) end, cb_context:validate_request_data(<<"groups">>, Context, OnSuccess). @@ -186,7 +186,7 @@ update(Id, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec validate_patch(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_patch(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). validate_patch(Id, Context) -> crossbar_doc:patch_and_validate(Id, Context, fun update/2). @@ -210,7 +210,7 @@ summary(Context) -> %% %% @end %%-------------------------------------------------------------------- --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> cb_context:set_doc(Context, kz_doc:set_type(cb_context:doc(Context), <<"group">>)); on_successful_validation(Id, Context) -> diff --git a/applications/crossbar/src/modules/cb_hotdesks.erl b/applications/crossbar/src/modules/cb_hotdesks.erl index 409c7e353c3..5ccca147ec8 100644 --- a/applications/crossbar/src/modules/cb_hotdesks.erl +++ b/applications/crossbar/src/modules/cb_hotdesks.erl @@ -82,7 +82,7 @@ validate(Context) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec validate_hotdesks(cb_context:context(), http_method(), kz_proplist()) -> cb_context:context(). +-spec validate_hotdesks(cb_context:context(), http_method(), kz_term:proplist()) -> cb_context:context(). validate_hotdesks(Context, ?HTTP_GET, [{<<"hotdesks">>, _}, {<<"users">>, [UserId]}|_]) -> fetch_device_hotdesks(UserId, Context); validate_hotdesks(Context, ?HTTP_GET, [{<<"hotdesks">>, _}, {<<"devices">>, [DeviceId]}|_]) -> @@ -110,7 +110,7 @@ normalize_view_results(JObj, Acc) -> fetch_all_hotdesks(Context) -> crossbar_doc:load_view(?CB_LIST, [], Context, fun normalize_view_results/2). --spec fetch_user_hotdesks(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec fetch_user_hotdesks(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). fetch_user_hotdesks(DeviceId, Context) -> Context1 = crossbar_doc:load(DeviceId, Context, ?TYPE_CHECK_OPTION(kz_device:type())), case cb_context:resp_status(Context1) of @@ -121,13 +121,13 @@ fetch_user_hotdesks(DeviceId, Context) -> _Else -> Context1 end. --spec fetch_users(ne_binaries(), cb_context:context()) -> cb_context:context(). +-spec fetch_users(kz_term:ne_binaries(), cb_context:context()) -> cb_context:context(). fetch_users(UserIds, Context) -> ViewOptions = [{'keys', UserIds}], View = <<"users/list_by_id">>, crossbar_doc:load_view(View, ViewOptions, Context, fun normalize_view_results/2). --spec fetch_device_hotdesks(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec fetch_device_hotdesks(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). fetch_device_hotdesks(UserId, Context) -> ViewOptions = [{'key', UserId}], crossbar_doc:load_view(?CB_LIST, ViewOptions, Context, fun normalize_view_results/2). diff --git a/applications/crossbar/src/modules/cb_ip_auth.erl b/applications/crossbar/src/modules/cb_ip_auth.erl index bc85f72071d..f39b99fbd23 100644 --- a/applications/crossbar/src/modules/cb_ip_auth.erl +++ b/applications/crossbar/src/modules/cb_ip_auth.erl @@ -82,7 +82,7 @@ authenticate_nouns(_Context, [{<<"ip_auth">>, _}]) -> authenticate_nouns(Context, _Nouns) -> authenticate_ip(Context, cb_context:client_ip(Context)). --spec authenticate_ip(cb_context:context(), ne_binary()) -> +-spec authenticate_ip(cb_context:context(), kz_term:ne_binary()) -> 'false' | {'true', cb_context:context()}. authenticate_ip(Context, IpKey) -> diff --git a/applications/crossbar/src/modules/cb_ips.erl b/applications/crossbar/src/modules/cb_ips.erl index bb73a899ce9..ed6f9993b8f 100644 --- a/applications/crossbar/src/modules/cb_ips.erl +++ b/applications/crossbar/src/modules/cb_ips.erl @@ -109,8 +109,8 @@ validate(Context, PathToken) -> _ = cb_context:put_reqid(Context), validate_ips(Context, PathToken, cb_context:req_verb(Context)). --spec validate_ips(cb_context:context(), ne_binary()) -> cb_context:context(). --spec validate_ips(cb_context:context(), path_token(), ne_binary()) -> cb_context:context(). +-spec validate_ips(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). +-spec validate_ips(cb_context:context(), path_token(), kz_term:ne_binary()) -> cb_context:context(). validate_ips(Context, ?HTTP_GET) -> load_available(Context); validate_ips(Context, ?HTTP_PUT) -> @@ -274,7 +274,7 @@ load_hosts(Context) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec load_ip(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec load_ip(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_ip(Context, Id) -> case kz_ip:fetch(Id) of {'ok', IP} -> @@ -315,21 +315,21 @@ maybe_assign_ips(Context) -> cb_context:validate_request_data(<<"ips">>, Context, OnSuccess). -spec validate_ips_not_in_use(cb_context:context()) -> cb_context:context(). --spec validate_ips_not_in_use(cb_context:context(), ne_binaries()) -> cb_context:context(). +-spec validate_ips_not_in_use(cb_context:context(), kz_term:ne_binaries()) -> cb_context:context(). validate_ips_not_in_use(Context) -> validate_ips_not_in_use(Context, cb_context:req_value(Context, <<"ips">>)). validate_ips_not_in_use(Context, IPs) -> lists:foldl(fun validate_ip_not_in_use/2, Context, IPs). --spec validate_ip_not_in_use(ne_binary() | cb_context:context(), ne_binary() | cb_context:context()) -> +-spec validate_ip_not_in_use(kz_term:ne_binary() | cb_context:context(), kz_term:ne_binary() | cb_context:context()) -> cb_context:context(). validate_ip_not_in_use(<<_/binary>> = IP, Context) -> validate_ip_not_in_use(Context, IP); validate_ip_not_in_use(Context, <<_/binary>> = IP) -> validate_ip_not_in_use(Context, IP, cb_context:resp_status(Context)). --spec validate_ip_not_in_use(cb_context:context(), ne_binary(), crossbar_status()) -> +-spec validate_ip_not_in_use(cb_context:context(), kz_term:ne_binary(), crossbar_status()) -> cb_context:context(). validate_ip_not_in_use(Context, IP, 'error') -> case kz_ip:is_available(IP) of @@ -352,7 +352,7 @@ validate_ip_not_in_use(Context, IP, _Status) -> ) end. --spec error_ip_assigned(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec error_ip_assigned(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). error_ip_assigned(Context, IP) -> Msg = kz_json:from_list([{<<"cause">>, IP} ,{<<"message">>, <<"ip already assigned">>} @@ -379,7 +379,7 @@ assign_ips(Context) -> _ -> Context1 end. --spec reconcile_services([api_ne_binary()]) -> 'ok'. +-spec reconcile_services([kz_term:api_ne_binary()]) -> 'ok'. reconcile_services(AccountIds) -> _ = [kz_services:reconcile(AccountId, <<"ips">>) || AccountId <- AccountIds, @@ -387,8 +387,8 @@ reconcile_services(AccountIds) -> ], 'ok'. --type assign_acc() :: {cb_context:context(), kz_json:objects(), [ne_binary() | 'undefined']}. --spec maybe_assign_ip(ne_binary(), assign_acc()) -> assign_acc(). +-type assign_acc() :: {cb_context:context(), kz_json:objects(), [kz_term:ne_binary() | 'undefined']}. +-spec maybe_assign_ip(kz_term:ne_binary(), assign_acc()) -> assign_acc(). maybe_assign_ip(IP, {Context, RespData, AccountIds}) -> AccountId = cb_context:account_id(Context), case kz_ip:fetch(IP) of @@ -397,7 +397,7 @@ maybe_assign_ip(IP, {Context, RespData, AccountIds}) -> {crossbar_doc:handle_datamgr_errors(Reason, IP, Context), RespData} end. --spec maybe_assign_ip(cb_context:context(), ne_binary(), kz_json:object(), kz_json:objects(), [ne_binary() | 'undefined']) -> assign_acc(). +-spec maybe_assign_ip(cb_context:context(), kz_term:ne_binary(), kz_json:object(), kz_json:objects(), [kz_term:ne_binary() | 'undefined']) -> assign_acc(). maybe_assign_ip(Context, AccountId, IPJObj, RespData, AccountIds) -> case kz_ip:assign(AccountId, IPJObj) of {'ok', AssignedIP} -> @@ -420,7 +420,7 @@ maybe_assign_ip(Context, AccountId, IPJObj, RespData, AccountIds) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec assign_ip(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec assign_ip(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). assign_ip(Context, IP) -> AccountId = cb_context:account_id(Context), case kz_ip:assign(AccountId, IP) of @@ -441,13 +441,13 @@ assign_ip(Context, IP) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec release_or_delete_ip(cb_context:context(), ne_binary(), req_nouns()) -> cb_context:context(). +-spec release_or_delete_ip(cb_context:context(), kz_term:ne_binary(), req_nouns()) -> cb_context:context(). release_or_delete_ip(Context, IP, [{<<"ips">>, [IP]}]) -> delete_ip(Context, IP); release_or_delete_ip(Context, IP, [{<<"ips">>, [IP]}, {<<"accounts">>, [_]}]) -> release_ip(Context, IP). --spec release_ip(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec release_ip(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). release_ip(Context, Id) -> case kz_ip:release(Id) of {'ok', IP} -> @@ -459,7 +459,7 @@ release_ip(Context, Id) -> crossbar_doc:handle_datamgr_errors(Reason, Id, Context) end. --spec delete_ip(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec delete_ip(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). delete_ip(Context, IP) -> case kz_ip:delete(IP) of {'ok', Deleted} -> crossbar_doc:handle_json_success(Deleted, Context); diff --git a/applications/crossbar/src/modules/cb_jobs_listener.erl b/applications/crossbar/src/modules/cb_jobs_listener.erl index a7a004fcbc5..7da423611f7 100644 --- a/applications/crossbar/src/modules/cb_jobs_listener.erl +++ b/applications/crossbar/src/modules/cb_jobs_listener.erl @@ -60,7 +60,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link({'local', ?SERVER} ,?MODULE @@ -80,7 +80,7 @@ publish_new_job(Context) -> ReqId = cb_context:req_id(Context), publish(AccountId, JobId, ReqId). --spec publish(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec publish(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. publish(AccountId, JobId, ReqId) -> Work = kz_json:from_list([{<<"Account-ID">>, AccountId} ,{<<"Job-ID">>, JobId} @@ -92,7 +92,7 @@ publish(AccountId, JobId, ReqId) -> ,fun(API) -> kapi_delegate:publish_delegate(?APP_ROUTING, API) end ). --spec handle_job(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_job(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_job(JObj, _Props) -> 'true' = kapi_delegate:delegate_v(JObj), kz_util:put_callid(kz_json:get_first_defined([<<"Msg-ID">>, [<<"Delegate-Message">>, <<"Job-ID">>]], JObj)), @@ -101,14 +101,14 @@ handle_job(JObj, _Props) -> ,kz_json:get_value(<<"Job-ID">>, Job) ). --spec process_job(ne_binary(), ne_binary()) -> 'ok'. +-spec process_job(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. process_job(<<_/binary>> = AccountId, <<_/binary>> = JobId) -> JobModb = job_modb(AccountId, JobId), {'ok', Job} = kz_datamgr:open_cache_doc(JobModb, JobId), lager:debug("processing job ~s for account ~s", [JobId, AccountId]), maybe_start_job(Job, kz_json:get_value(<<"pvt_status">>, Job)). --spec maybe_start_job(kz_json:object(), ne_binary()) -> 'ok'. +-spec maybe_start_job(kz_json:object(), kz_term:ne_binary()) -> 'ok'. maybe_start_job(_Job, <<"complete">>) -> lager:debug("job is complete, nothing to do"); maybe_start_job(Job, <<"pending">>) -> @@ -122,7 +122,7 @@ maybe_start_job(Job, <<"pending">>) -> maybe_start_job(Job, <<"running">>) -> lager:debug("job is running, ~s is in charge", [kz_json:get_value(<<"pvt_node">>, Job)]). --spec start_job(kz_json:object(), ne_binary(), ne_binary(), ne_binary(), ne_binaries()) -> 'ok'. +-spec start_job(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binaries()) -> 'ok'. start_job(Job, _AccountId, _AuthAccountId, _CarrierModule, []) -> update_status(Job, <<"complete">>), lager:debug("successfully finished job"); @@ -130,7 +130,7 @@ start_job(Job, AccountId, AuthAccountId, CarrierModule, [Number|Numbers]) -> Job1 = maybe_create_number(Job, AccountId, AuthAccountId, CarrierModule, Number), start_job(Job1, AccountId, AuthAccountId, CarrierModule, Numbers). --spec select_carrier_module(kz_json:object()) -> ne_binary(). +-spec select_carrier_module(kz_json:object()) -> kz_term:ne_binary(). select_carrier_module(Job) -> ResourceId = kz_json:get_value(<<"resource_id">>, Job), case kz_datamgr:open_cache_doc(?KZ_OFFNET_DB, ResourceId) of @@ -146,7 +146,7 @@ select_carrier_module(Job) -> ?CARRIER_LOCAL end. --spec maybe_create_number(kz_json:object(), ne_binary(), ne_binary(), api_binary(), ne_binary()) -> +-spec maybe_create_number(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary(), kz_term:ne_binary()) -> kz_json:object(). maybe_create_number(Job, AccountId, AuthAccountId, CarrierModule, Number) -> case kz_json:get_first_defined([[?KEY_SUCCESS, Number] @@ -159,7 +159,7 @@ maybe_create_number(Job, AccountId, AuthAccountId, CarrierModule, Number) -> Job end. --spec create_number(kz_json:object(), ne_binary(), ne_binary(), api_binary(), ne_binary()) -> +-spec create_number(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary(), kz_term:ne_binary()) -> kz_json:object(). create_number(Job, AccountId, AuthAccountId, CarrierModule, DID) -> Options = [{'assign_to', AccountId} @@ -196,7 +196,7 @@ create_number(Job, AccountId, AuthAccountId, CarrierModule, DID) -> ) end. --spec update_with_failure(kz_json:object(), ne_binary(), ne_binary(), atom(), kz_json:object()) -> +-spec update_with_failure(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), atom(), kz_json:object()) -> kz_json:object(). update_with_failure(Job, AccountId, Number, Failure, JObj) -> lager:debug("failed to create number ~s for account ~s: ~p ~p", [Number, AccountId, Failure, JObj]), @@ -222,7 +222,7 @@ update_with_failure(Job, AccountId, Number, Failure, JObj) -> build_number_properties(JObj) -> kz_json:from_list([{<<"resource_id">>, kz_json:get_value(<<"resource_id">>, JObj)}]). --spec update_status(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec update_status(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). update_status(Job, Status) -> {'ok', Job1} = kz_datamgr:save_doc(kz_doc:account_db(Job) ,kz_json:set_values([{<<"pvt_status">>, Status} @@ -239,12 +239,12 @@ start_recovery() -> {Year, Month, _} = erlang:date(), maybe_recover_jobs(Year, Month, kapps_util:get_all_accounts('raw')). --spec maybe_recover_jobs(kz_year(), kz_month(), ne_binaries()) -> 'ok'. +-spec maybe_recover_jobs(kz_time:year(), kz_time:month(), kz_term:ne_binaries()) -> 'ok'. maybe_recover_jobs(Year, Month, Accounts) -> _ = [catch maybe_recover_account_jobs(Year, Month, AccountId) || AccountId <- Accounts], lager:debug("finished recovering account jobs"). --spec maybe_recover_account_jobs(kz_year(), kz_month(), ne_binary()) -> 'ok'. +-spec maybe_recover_account_jobs(kz_time:year(), kz_time:month(), kz_term:ne_binary()) -> 'ok'. maybe_recover_account_jobs(Year, Month, AccountId) -> Modb = kazoo_modb:get_modb(AccountId, Year, Month), case kz_datamgr:get_results(Modb, <<"resources/status_listing">>, [{'keys', [<<"pending">> @@ -327,7 +327,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -341,7 +341,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _QueueNAme}}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'is_consuming', _IsConsuming}}, State) -> @@ -359,7 +359,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'timeout', Ref, ?RECOVERY_MESSAGE} ,#state{recovery_ref=Ref}=State ) -> @@ -378,7 +378,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. @@ -412,7 +412,7 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec job_modb(ne_binary(), ne_binary()) -> ne_binary(). +-spec job_modb(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). job_modb(AccountId, ?MATCH_MODB_PREFIX(Year,Month,_)) -> kz_util:format_account_mod_id(AccountId, kz_term:to_integer(Year), kz_term:to_integer(Month)); job_modb(AccountId, ?MATCH_MODB_PREFIX_M1(Year,Month,_)) -> diff --git a/applications/crossbar/src/modules/cb_ledgers.erl b/applications/crossbar/src/modules/cb_ledgers.erl index 7955d408502..23e1560ac74 100644 --- a/applications/crossbar/src/modules/cb_ledgers.erl +++ b/applications/crossbar/src/modules/cb_ledgers.erl @@ -214,7 +214,7 @@ validate_ledger_doc(Context, Ledger, Id, ?HTTP_GET) -> %% %% @end %%-------------------------------------------------------------------- --spec credit_or_debit(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec credit_or_debit(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). credit_or_debit(Context, Action) -> ReqData = cb_context:req_data(Context), @@ -245,8 +245,8 @@ credit_or_debit(Context, Action) -> %% %% @end %%-------------------------------------------------------------------- --spec process_action(ne_binary(), ne_binary(), ne_binary() - ,ne_binary(), kz_proplist(), kz_proplist()) -> +-spec process_action(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary() + ,kz_term:ne_binary(), kz_term:proplist(), kz_term:proplist()) -> {'ok', kz_json:object()} | {'error', any()}. process_action(?CREDIT, SrcService, SrcId, AccountId, Usage, Props) -> @@ -267,7 +267,7 @@ maybe_impact_reseller(Context, Ledger) -> andalso ResellerId =/= cb_context:account_id(Context), maybe_impact_reseller(Context, Ledger, ImpactReseller, ResellerId). --spec maybe_impact_reseller(cb_context:context(), kz_json:object(), boolean(), api_binary()) -> cb_context:context(). +-spec maybe_impact_reseller(cb_context:context(), kz_json:object(), boolean(), kz_term:api_binary()) -> cb_context:context(). maybe_impact_reseller(Context, Ledger, 'false', _ResellerId) -> crossbar_util:response(kz_doc:public_fields(Ledger), Context); maybe_impact_reseller(Context, Ledger, 'true', 'undefined') -> @@ -308,7 +308,7 @@ summary_to_dollars(LedgersJObj) -> || {Path, Value} <- kz_json:to_proplist(kz_json:flatten(LedgersJObj)) ])). --spec maybe_convert_units(ne_binary(), kz_transaction:units() | T) -> kz_transaction:dollars() | T when T::any(). +-spec maybe_convert_units(kz_term:ne_binary(), kz_transaction:units() | T) -> kz_transaction:dollars() | T when T::any(). maybe_convert_units(<<"amount">>, 'undefined') -> 0; maybe_convert_units(<<"amount">>, Units) -> wht_util:units_to_dollars(Units); maybe_convert_units(_, Value) -> Value. @@ -328,7 +328,7 @@ normalize_view_results(Context, JObj, Acc) -> normalize_view_result(Context, JObj) -> normalize_view_result(Context, kz_doc:type(JObj), JObj). --spec normalize_view_result(cb_context:context(), ne_binary(), kz_json:object()) -> kz_json:object(). +-spec normalize_view_result(cb_context:context(), kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). normalize_view_result(_Context, <<"ledger">>, JObj) -> Value = wht_util:units_to_dollars(kazoo_ledger:amount(JObj)), Ledger = kazoo_ledger:set_amount(JObj, Value), @@ -364,7 +364,7 @@ normalize_view_result(Context, _DocType, JObj) -> ,{<<"id">>, maybe_set_doc_modb_prefix(kz_doc:id(JObj), kz_doc:created(JObj))} ]). --spec maybe_set_doc_modb_prefix(ne_binary(), api_integer()) -> ne_binary(). +-spec maybe_set_doc_modb_prefix(kz_term:ne_binary(), kz_term:api_integer()) -> kz_term:ne_binary(). maybe_set_doc_modb_prefix(?MATCH_MODB_PREFIX(_,_,_)=Id, _) -> Id; maybe_set_doc_modb_prefix(Id, Created) -> {Year, Month, _} = kz_term:to_date(Created), @@ -376,7 +376,7 @@ maybe_set_doc_modb_prefix(Id, Created) -> %% %% @end %%-------------------------------------------------------------------- --spec read_ledger_doc(cb_context:context(), ne_binary(), ne_binary()) -> cb_context:context(). +-spec read_ledger_doc(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). read_ledger_doc(Context, Ledger, ?MATCH_MODB_PREFIX(YYYY, MM, SimpleId) = Id) -> Year = kz_term:to_integer(YYYY), Month = kz_term:to_integer(MM), @@ -399,7 +399,7 @@ read_ledger_doc(Context, Ledger, Id) -> Ctx1 -> Ctx1 end. --spec validate_returned_ledger_doc(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_returned_ledger_doc(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). validate_returned_ledger_doc(Ledger, Context) -> JObj = cb_context:doc(Context), TransactionTypes = [?DEBIT, ?CREDIT], diff --git a/applications/crossbar/src/modules/cb_local_provisioner_templates.erl b/applications/crossbar/src/modules/cb_local_provisioner_templates.erl index 76b0f30cd31..ea792ae3c2e 100644 --- a/applications/crossbar/src/modules/cb_local_provisioner_templates.erl +++ b/applications/crossbar/src/modules/cb_local_provisioner_templates.erl @@ -317,7 +317,7 @@ create_provisioner_template(Context) -> %% Load a provision template document from the database %% @end %%-------------------------------------------------------------------- --spec load_provisioner_template(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_provisioner_template(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_provisioner_template(DocId, Context) -> %% see note at top of file Context1 = crossbar_doc:load(DocId, Context, ?TYPE_CHECK_OPTION(<<"provisioner_template">>)), @@ -340,7 +340,7 @@ load_provisioner_template(DocId, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec update_provisioner_template(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec update_provisioner_template(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). update_provisioner_template(DocId, Context) -> OnSuccess = fun(C) -> on_successful_validation(DocId, C) end, cb_context:validate_request_data(<<"provisioner_templates">>, Context, OnSuccess). @@ -351,7 +351,7 @@ update_provisioner_template(DocId, Context) -> %% %% @end %%-------------------------------------------------------------------- --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> provisioner_util:get_provision_defaults( cb_context:set_doc(Context, kz_json:set_values([{<<"pvt_type">>, <<"provisioner_template">>} diff --git a/applications/crossbar/src/modules/cb_local_resources.erl b/applications/crossbar/src/modules/cb_local_resources.erl index c8c1035298e..c20c4bb5e62 100644 --- a/applications/crossbar/src/modules/cb_local_resources.erl +++ b/applications/crossbar/src/modules/cb_local_resources.erl @@ -39,11 +39,11 @@ init() -> %% %% @end %%-------------------------------------------------------------------- --spec validate_request(api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_request(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_request(ResourceId, Context) -> check_for_registering_gateways(ResourceId, Context). --spec check_for_registering_gateways(api_binary(), cb_context:context()) -> cb_context:context(). +-spec check_for_registering_gateways(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_for_registering_gateways(ResourceId, Context) -> case lists:any(fun is_registering_gateway/1 ,cb_context:req_value(Context, <<"gateways">>, []) @@ -60,7 +60,7 @@ is_registering_gateway(Gateway) -> kz_json:is_true(<<"register">>, Gateway) andalso kz_json:is_true(<<"enabled">>, Gateway). --spec check_if_peer(api_binary(), cb_context:context()) -> cb_context:context(). +-spec check_if_peer(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_if_peer(ResourceId, Context) -> case {kz_term:is_true(cb_context:req_value(Context, <<"peer">>)) ,kapps_config:get_is_true(?MOD_CONFIG_CAT, <<"allow_peers">>, 'false') @@ -82,7 +82,7 @@ check_if_peer(ResourceId, Context) -> check_resource_schema(ResourceId, Context) end. --spec check_if_gateways_have_ip(api_binary(), cb_context:context()) -> cb_context:context(). +-spec check_if_gateways_have_ip(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_if_gateways_have_ip(ResourceId, Context) -> Gateways = cb_context:req_value(Context, <<"gateways">>, []), IPs = extract_gateway_ips(Gateways, 0, []), @@ -90,7 +90,7 @@ check_if_gateways_have_ip(ResourceId, Context) -> ACLs = get_all_acl_ips(), validate_gateway_ips(IPs, SIPAuth, ACLs, ResourceId, Context, cb_context:resp_status(Context)). --spec validate_gateway_ips(gateway_ips(), sip_auth_ips(), acl_ips(), api_binary(), cb_context:context(), crossbar_status()) -> cb_context:context(). +-spec validate_gateway_ips(gateway_ips(), sip_auth_ips(), acl_ips(), kz_term:api_binary(), cb_context:context(), crossbar_status()) -> cb_context:context(). validate_gateway_ips([], _, _, ResourceId, Context, 'error') -> check_resource_schema(ResourceId, Context); validate_gateway_ips([], _, _, ResourceId, Context, 'success') -> @@ -149,12 +149,12 @@ validate_gateway_ips([{Idx, InboundIP, ServerIP}|IPs], SIPAuth, ACLs, ResourceId validate_gateway_ips([{Idx, 'undefined', ServerIP}|IPs], SIPAuth, ACLs, ResourceId, Context, cb_context:resp_status(Context)) end. --spec check_resource_schema(api_binary(), cb_context:context()) -> cb_context:context(). +-spec check_resource_schema(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_resource_schema(ResourceId, Context) -> %% This has been validated in cb_resources already! on_successful_validation(ResourceId, Context). --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> cb_context:set_doc(Context, kz_doc:set_type(cb_context:doc(Context), <<"resource">>)); on_successful_validation(Id, Context) -> @@ -185,8 +185,8 @@ maybe_aggregate_resource(Context, 'success') -> end; maybe_aggregate_resource(_Context, _Status) -> 'false'. --spec maybe_remove_aggregate(ne_binary(), cb_context:context()) -> boolean(). --spec maybe_remove_aggregate(ne_binary(), cb_context:context(), crossbar_status()) -> boolean(). +-spec maybe_remove_aggregate(kz_term:ne_binary(), cb_context:context()) -> boolean(). +-spec maybe_remove_aggregate(kz_term:ne_binary(), cb_context:context(), crossbar_status()) -> boolean(). maybe_remove_aggregate(ResourceId, Context) -> maybe_remove_aggregate(ResourceId, Context, cb_context:resp_status(Context)). @@ -208,7 +208,7 @@ maybe_remove_aggregate(_ResourceId, _Context, _Status) -> 'false'. %% %% @end %%-------------------------------------------------------------------- --type sip_auth_ip() :: {ne_binary(), ne_binary()}. +-type sip_auth_ip() :: {kz_term:ne_binary(), kz_term:ne_binary()}. -type sip_auth_ips() :: [sip_auth_ip()]. -spec get_all_sip_auth_ips() -> sip_auth_ips(). @@ -223,7 +223,7 @@ get_all_sip_auth_ips() -> get_sip_auth_ip(JObj, IPs) -> [{kz_json:get_value(<<"key">>, JObj), kz_doc:id(JObj)} | IPs]. --type acl_ips() :: ne_binaries(). +-type acl_ips() :: kz_term:ne_binaries(). -spec get_all_acl_ips() -> acl_ips(). get_all_acl_ips() -> Req = [{<<"Category">>, <<"ecallmgr">>} @@ -257,7 +257,7 @@ extract_ips_fold(_K, JObj, IPs) -> [{CIDR, AuthorizingId} | IPs] end. --type gateway_ip() :: {non_neg_integer(), api_binary(), api_binary()}. +-type gateway_ip() :: {non_neg_integer(), kz_term:api_binary(), kz_term:api_binary()}. -type gateway_ips() :: [gateway_ip()]. -spec extract_gateway_ips(kz_json:objects(), non_neg_integer(), gateway_ips()) -> gateway_ips(). extract_gateway_ips([], _, IPs) -> IPs; @@ -268,7 +268,7 @@ extract_gateway_ips([Gateway|Gateways], Idx, IPs) -> }, extract_gateway_ips(Gateways, Idx + 1, [IP|IPs]). --spec validate_ip(api_binary(), sip_auth_ips(), acl_ips(), api_binary()) -> boolean(). +-spec validate_ip(kz_term:api_binary(), sip_auth_ips(), acl_ips(), kz_term:api_binary()) -> boolean(). validate_ip(IP, SIPAuth, ACLs, ResourceId) -> lists:all(fun({CIDR, AuthId}) -> AuthId =:= ResourceId diff --git a/applications/crossbar/src/modules/cb_media.erl b/applications/crossbar/src/modules/cb_media.erl index 3906552e3f1..3a38f095090 100644 --- a/applications/crossbar/src/modules/cb_media.erl +++ b/applications/crossbar/src/modules/cb_media.erl @@ -126,7 +126,7 @@ resource_exists(_, ?BIN_DATA) -> 'true'. authorize(Context) -> authorize_media(Context, cb_context:req_nouns(Context), cb_context:account_id(Context)). --spec authorize_media(cb_context:context(), req_nouns(), api_binary()) -> boolean(). +-spec authorize_media(cb_context:context(), req_nouns(), kz_term:api_binary()) -> boolean(). authorize_media(_Context, [{<<"media">>, [?PROMPTS]}], 'undefined') -> lager:debug("allowing system prompts request"), 'true'; @@ -165,7 +165,7 @@ authorize_media(_Context, _Nouns, _AccountId) -> %% %% @end %%-------------------------------------------------------------------- --spec acceptable_content_types() -> kz_proplist(). +-spec acceptable_content_types() -> kz_term:proplist(). acceptable_content_types() -> ?MEDIA_MIME_TYPES. @@ -260,7 +260,7 @@ validate_media_docs(Context, ?HTTP_GET) -> validate_media_docs(Context, ?HTTP_PUT) -> validate_request('undefined', Context). --spec validate_media_doc(cb_context:context(), ne_binary(), http_method()) -> cb_context:context(). +-spec validate_media_doc(cb_context:context(), kz_term:ne_binary(), http_method()) -> cb_context:context(). validate_media_doc(Context, MediaId, ?HTTP_GET) -> load_media_meta(Context, MediaId); validate_media_doc(Context, MediaId, ?HTTP_POST) -> @@ -268,7 +268,7 @@ validate_media_doc(Context, MediaId, ?HTTP_POST) -> validate_media_doc(Context, MediaId, ?HTTP_DELETE) -> load_media_meta(Context, MediaId). --spec validate_media_binary(cb_context:context(), ne_binary(), http_method(), kz_proplist()) -> cb_context:context(). +-spec validate_media_binary(cb_context:context(), kz_term:ne_binary(), http_method(), kz_term:proplist()) -> cb_context:context(). validate_media_binary(Context, MediaId, ?HTTP_GET, _Files) -> lager:debug("fetch media contents for '~s'", [MediaId]), load_media_binary(Context, MediaId); @@ -299,7 +299,7 @@ validate_media_binary(Context, _MediaId, ?HTTP_POST, _Files) -> ,Context ). --spec maybe_normalize_upload(cb_context:context(), ne_binary(), kz_json:object()) -> cb_context:context(). +-spec maybe_normalize_upload(cb_context:context(), kz_term:ne_binary(), kz_json:object()) -> cb_context:context(). maybe_normalize_upload(Context, MediaId, FileJObj) -> case kapps_config:get_is_true(?MOD_CONFIG_CAT, <<"normalize_media">>, 'false') of 'true' -> @@ -310,9 +310,9 @@ maybe_normalize_upload(Context, MediaId, FileJObj) -> validate_upload(Context, MediaId, FileJObj) end. --spec normalize_upload(cb_context:context(), ne_binary(), kz_json:object()) -> +-spec normalize_upload(cb_context:context(), kz_term:ne_binary(), kz_json:object()) -> cb_context:context(). --spec normalize_upload(cb_context:context(), ne_binary(), kz_json:object(), api_binary()) -> +-spec normalize_upload(cb_context:context(), kz_term:ne_binary(), kz_json:object(), kz_term:api_binary()) -> cb_context:context(). normalize_upload(Context, MediaId, FileJObj) -> normalize_upload(Context, MediaId, FileJObj @@ -334,7 +334,7 @@ normalize_upload(Context, MediaId, FileJObj, UploadContentType) -> ,UpdatedFileJObj ). --spec validate_upload(cb_context:context(), ne_binary(), kz_json:object()) -> cb_context:context(). +-spec validate_upload(cb_context:context(), kz_term:ne_binary(), kz_json:object()) -> cb_context:context(). validate_upload(Context, MediaId, FileJObj) -> CT = kz_json:get_value([<<"headers">>, <<"content_type">>], FileJObj, <<"application/octet-stream">>), Size = kz_json:get_integer_value([<<"headers">>, <<"content_length">>] @@ -361,7 +361,7 @@ get(Context, _MediaId, ?BIN_DATA) -> put(Context) -> put_media(Context, cb_context:account_id(Context)). --spec put_media(cb_context:context(), api_binary()) -> cb_context:context(). +-spec put_media(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). put_media(Context, 'undefined') -> put_media(cb_context:set_account_db(Context, ?KZ_MEDIA_DB), <<"ignore">>); put_media(Context, _AccountId) -> @@ -391,7 +391,7 @@ put_media(Context, _AccountId) -> post(Context, MediaId) -> post_media_doc(Context, MediaId, cb_context:account_id(Context)). --spec post_media_doc(cb_context:context(), ne_binary(), api_binary()) -> cb_context:context(). +-spec post_media_doc(cb_context:context(), kz_term:ne_binary(), kz_term:api_binary()) -> cb_context:context(). post_media_doc(Context, MediaId, 'undefined') -> post_media_doc(cb_context:set_account_db(Context, ?KZ_MEDIA_DB), MediaId, <<"ignore">>); post_media_doc(Context, MediaId, _AccountId) -> @@ -423,13 +423,13 @@ remove_tts_keys(C) -> JObj = cb_context:doc(C), cb_context:set_doc(C, kz_json:delete_keys([<<"pvt_previous_tts">>, <<"pvt_previous_voice">>], JObj)). --spec post_media_binary(cb_context:context(), ne_binary(), api_binary()) -> cb_context:context(). +-spec post_media_binary(cb_context:context(), kz_term:ne_binary(), kz_term:api_binary()) -> cb_context:context(). post_media_binary(Context, MediaId, 'undefined') -> post_media_binary(cb_context:set_account_db(Context, ?KZ_MEDIA_DB), MediaId, <<"ignore">>); post_media_binary(Context, MediaId, _AccountId) -> update_media_binary(Context, MediaId). --spec maybe_save_tts(cb_context:context(), ne_binary(), ne_binary(), crossbar_status()) -> +-spec maybe_save_tts(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary(), crossbar_status()) -> cb_context:context(). maybe_save_tts(Context, Text, Voice, 'success') -> JObj = kz_json:set_value(<<"media_source">>, <<"tts">>, cb_context:doc(Context)), @@ -443,7 +443,7 @@ maybe_save_tts(Context, Text, Voice, 'success') -> maybe_save_tts(Context, _Text, _Voice, _Status) -> Context. --spec maybe_update_tts(cb_context:context(), ne_binary(), ne_binary(), crossbar_status()) -> +-spec maybe_update_tts(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary(), crossbar_status()) -> cb_context:context(). maybe_update_tts(Context, Text, VoiceLang, 'success') -> JObj = cb_context:doc(Context), @@ -481,7 +481,7 @@ maybe_update_tts(Context, Text, VoiceLang, 'success') -> end; maybe_update_tts(Context, _Text, _Voice, _Status) -> Context. --spec maybe_merge_tts(cb_context:context(), ne_binary(), ne_binary(), ne_binary(), crossbar_status()) -> +-spec maybe_merge_tts(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), crossbar_status()) -> cb_context:context(). maybe_merge_tts(Context, MediaId, Text, Voice, 'success') -> JObj = cb_context:doc(Context), @@ -541,7 +541,7 @@ delete(Context, MediaId, ?BIN_DATA) -> %% @end %%-------------------------------------------------------------------- -spec load_media_summary(cb_context:context()) -> cb_context:context(). --spec load_media_summary(cb_context:context(), api_binary()) -> cb_context:context(). +-spec load_media_summary(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). load_media_summary(Context) -> load_media_summary(Context, cb_context:account_id(Context)). @@ -591,7 +591,7 @@ fix_start_keys_fold(Key, JObj) -> end. -spec load_available_languages(cb_context:context()) -> cb_context:context(). --spec load_available_languages(cb_context:context(), api_binary()) -> cb_context:context(). +-spec load_available_languages(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). load_available_languages(Context) -> load_available_languages(Context, cb_context:account_id(Context)). @@ -623,9 +623,9 @@ normalize_count_results(JObj, [Acc]) -> [kz_json:set_value(Lang, kz_json:get_integer_value(<<"value">>, JObj), Acc)] end. --spec load_media_docs_by_language(cb_context:context(), ne_binary()) -> +-spec load_media_docs_by_language(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). --spec load_media_docs_by_language(cb_context:context(), ne_binary() | 'null', api_binary()) -> +-spec load_media_docs_by_language(cb_context:context(), kz_term:ne_binary() | 'null', kz_term:api_binary()) -> cb_context:context(). load_media_docs_by_language(Context, <<"missing">>) -> lager:debug("loading media files missing a language"), @@ -659,8 +659,8 @@ load_media_docs_by_language(Context, Language, _AccountId) -> ) ). --spec language_start_key(cb_context:context(), ne_binary()) -> ne_binaries(). --spec language_start_key(cb_context:context(), ne_binary(), ne_binaries()) -> ne_binaries(). +-spec language_start_key(cb_context:context(), kz_term:ne_binary()) -> kz_term:ne_binaries(). +-spec language_start_key(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). language_start_key(Context, Language) -> case crossbar_doc:start_key(Context) of 'undefined' -> [Language]; @@ -672,7 +672,7 @@ language_start_key(_Context, Language, [Language, Id]) -> language_start_key(_Context, Language, _Key) -> [Language]. --spec normalize_language_results(kz_json:object(), ne_binaries()) -> ne_binaries(). +-spec normalize_language_results(kz_json:object(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). normalize_language_results(JObj, Acc) -> [kz_doc:id(JObj) | Acc]. @@ -684,7 +684,7 @@ normalize_language_results(JObj, Acc) -> %%-------------------------------------------------------------------- -spec load_available_prompts(cb_context:context()) -> cb_context:context(). --spec load_available_prompts(cb_context:context(), api_binary()) -> +-spec load_available_prompts(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). load_available_prompts(Context) -> load_available_prompts(Context, cb_context:account_id(Context)). @@ -710,8 +710,8 @@ load_available_prompts(Context, _AccountId) -> ) ). --spec load_media_docs_by_prompt(cb_context:context(), ne_binary()) -> cb_context:context(). --spec load_media_docs_by_prompt(cb_context:context(), ne_binary(), api_binary()) -> cb_context:context(). +-spec load_media_docs_by_prompt(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). +-spec load_media_docs_by_prompt(cb_context:context(), kz_term:ne_binary(), kz_term:api_binary()) -> cb_context:context(). load_media_docs_by_prompt(Context, PromptId) -> lager:debug("loading media files in prompt ~p", [PromptId]), load_media_docs_by_prompt(Context, PromptId, cb_context:account_id(Context)). @@ -743,9 +743,9 @@ load_media_docs_by_prompt(Context, PromptId, _AccountId) -> -spec prompt_start_key(cb_context:context()) -> - ne_binaries(). --spec prompt_start_key(cb_context:context(), api_binary()) -> - ne_binaries(). + kz_term:ne_binaries(). +-spec prompt_start_key(cb_context:context(), kz_term:api_binary()) -> + kz_term:ne_binaries(). prompt_start_key(Context) -> prompt_start_key(Context, 'undefined'). @@ -756,7 +756,7 @@ prompt_start_key(Context, PromptId) -> Key -> [Key] end. --spec normalize_prompt_results(kz_json:object(), ne_binaries()) -> ne_binaries(). +-spec normalize_prompt_results(kz_json:object(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). normalize_prompt_results(JObj, Acc) -> HasAttachments = case kz_doc:attachments(kz_json:get_value(<<"doc">>, JObj)) of @@ -799,9 +799,9 @@ fix_prompt_start_keys_fold(Key, JObj) -> %% Load a media document from the database %% @end %%-------------------------------------------------------------------- --spec load_media_meta(cb_context:context(), ne_binary()) -> +-spec load_media_meta(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). --spec load_media_meta(cb_context:context(), ne_binary(), api_binary()) -> +-spec load_media_meta(cb_context:context(), kz_term:ne_binary(), kz_term:api_binary()) -> cb_context:context(). load_media_meta(Context, MediaId) -> load_media_meta(Context, MediaId, cb_context:account_id(Context)). @@ -817,12 +817,12 @@ load_media_meta(Context, MediaId, _AccountId) -> %% %% @end %%-------------------------------------------------------------------- --spec validate_request(api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_request(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_request(MediaId, Context) -> OnSuccess = fun(C) -> on_successful_validation(MediaId, C) end, cb_context:validate_request_data(<<"media">>, Context, OnSuccess). --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> Props = [{<<"pvt_type">>, kzd_media:type()} ,{<<"media_source">>, <<"upload">>} @@ -833,7 +833,7 @@ on_successful_validation(MediaId, Context) -> Context1 = crossbar_doc:load_merge(MediaId, Context, ?TYPE_CHECK_OPTION(kzd_media:type())), maybe_validate_prompt(MediaId, Context1, cb_context:resp_status(Context1)). --spec maybe_validate_prompt(ne_binary(), cb_context:context(), crossbar_status()) -> +-spec maybe_validate_prompt(kz_term:ne_binary(), cb_context:context(), crossbar_status()) -> cb_context:context(). maybe_validate_prompt(MediaId, Context, 'success') -> case kzd_media:prompt_id(cb_context:doc(Context)) of @@ -844,7 +844,7 @@ maybe_validate_prompt(MediaId, Context, 'success') -> maybe_validate_prompt(_MediaId, Context, _Status) -> Context. --spec validate_prompt(ne_binary(), cb_context:context(), ne_binary()) -> +-spec validate_prompt(kz_term:ne_binary(), cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). validate_prompt(MediaId, Context, PromptId) -> Language = kz_term:to_lower_binary(kzd_media:language(cb_context:doc(Context))), @@ -864,7 +864,7 @@ validate_prompt(MediaId, Context, PromptId) -> ) end. --spec maybe_add_prompt_fields(cb_context:context()) -> kz_proplist(). +-spec maybe_add_prompt_fields(cb_context:context()) -> kz_term:proplist(). maybe_add_prompt_fields(Context) -> JObj = cb_context:doc(Context), case kzd_media:prompt_id(JObj) of @@ -960,7 +960,7 @@ update_media_binary(Context, MediaId, [{Filename, FileObj}|Files]) -> %% Delete the binary attachment of a media doc %% @end %%-------------------------------------------------------------------- --spec delete_media_binary(path_token(), cb_context:context(), api_binary()) -> cb_context:context(). +-spec delete_media_binary(path_token(), cb_context:context(), kz_term:api_binary()) -> cb_context:context(). delete_media_binary(MediaId, Context, 'undefined') -> delete_media_binary(MediaId, cb_context:set_account_db(Context, ?KZ_MEDIA_DB), <<"ignore">>); delete_media_binary(MediaId, Context, _AccountId) -> @@ -976,7 +976,7 @@ delete_media_binary(MediaId, Context, _AccountId) -> end. -spec is_tts(kz_json:object()) -> boolean(). --spec is_tts(kz_json:object(), api_binary()) -> boolean(). +-spec is_tts(kz_json:object(), kz_term:api_binary()) -> boolean(). is_tts(JObj) -> is_tts(JObj, kz_json:get_ne_value([<<"tts">>, <<"text">>], JObj)). diff --git a/applications/crossbar/src/modules/cb_menus.erl b/applications/crossbar/src/modules/cb_menus.erl index 703fdebc1c5..f2d34ae9285 100644 --- a/applications/crossbar/src/modules/cb_menus.erl +++ b/applications/crossbar/src/modules/cb_menus.erl @@ -148,7 +148,7 @@ create_menu(Context) -> %% Load a menu document from the database %% @end %%-------------------------------------------------------------------- --spec load_menu(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_menu(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_menu(DocId, Context) -> crossbar_doc:load(DocId, Context, ?TYPE_CHECK_OPTION(<<"menu">>)). @@ -159,7 +159,7 @@ load_menu(DocId, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec update_menu(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec update_menu(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). update_menu(DocId, Context) -> OnSuccess = fun(C) -> on_successful_validation(DocId, C) end, cb_context:validate_request_data(<<"menus">>, Context, OnSuccess). @@ -171,7 +171,7 @@ update_menu(DocId, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec validate_patch(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_patch(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). validate_patch(DocId, Context) -> crossbar_doc:patch_and_validate(DocId, Context, fun update_menu/2). @@ -181,7 +181,7 @@ validate_patch(DocId, Context) -> %% %% @end %%-------------------------------------------------------------------- --spec on_successful_validation(api_binary(), cb_context:context()) -> +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> cb_context:set_doc(Context, kz_json:set_values([{<<"pvt_type">>, <<"menu">>} diff --git a/applications/crossbar/src/modules/cb_metaflows.erl b/applications/crossbar/src/modules/cb_metaflows.erl index 3d80ddb0f03..cd2e0b42b47 100644 --- a/applications/crossbar/src/modules/cb_metaflows.erl +++ b/applications/crossbar/src/modules/cb_metaflows.erl @@ -89,8 +89,8 @@ validate_metaflows(Context, ?HTTP_POST) -> validate_metaflows(Context, ?HTTP_DELETE) -> validate_delete_metaflows(Context, thing_doc(Context)). --spec thing_doc(cb_context:context()) -> api_object(). --spec thing_doc(cb_context:context(), ne_binary()) -> api_object(). +-spec thing_doc(cb_context:context()) -> kz_term:api_object(). +-spec thing_doc(cb_context:context(), kz_term:ne_binary()) -> kz_term:api_object(). thing_doc(Context) -> case cb_context:req_nouns(Context) of [{<<"metaflows">>, []}, {_Thing, [ThingId]} | _] -> @@ -108,7 +108,7 @@ thing_doc(Context, ThingId) -> 'undefined' end. --spec validate_get_metaflows(cb_context:context(), api_object()) -> cb_context:context(). +-spec validate_get_metaflows(cb_context:context(), kz_term:api_object()) -> cb_context:context(). validate_get_metaflows(Context, 'undefined') -> {'ok', AccountDoc} = kz_account:fetch(cb_context:account_id(Context)), validate_get_metaflows(Context, AccountDoc); @@ -116,7 +116,7 @@ validate_get_metaflows(Context, Doc) -> Metaflows = kz_json:get_value(<<"metaflows">>, Doc, kz_json:new()), crossbar_util:response(Metaflows, Context). --spec validate_delete_metaflows(cb_context:context(), api_object()) -> cb_context:context(). +-spec validate_delete_metaflows(cb_context:context(), kz_term:api_object()) -> cb_context:context(). validate_delete_metaflows(Context, 'undefined') -> {'ok', AccountDoc} = kz_account:fetch(cb_context:account_id(Context)), validate_delete_metaflows(Context, AccountDoc); @@ -128,7 +128,7 @@ validate_delete_metaflows(Context, Doc) -> -spec validate_set_metaflows(cb_context:context()) -> cb_context:context(). --spec validate_set_metaflows(cb_context:context(), kz_json:object(), api_object()) -> +-spec validate_set_metaflows(cb_context:context(), kz_json:object(), kz_term:api_object()) -> cb_context:context(). validate_set_metaflows(Context) -> lager:debug("metaflow data is valid, setting on thing"), @@ -154,8 +154,8 @@ post(Context) -> lager:debug("saving ~p", [Doc]), after_post(crossbar_doc:save(Context), kz_doc:type(Doc)). --spec after_post(cb_context:context(), ne_binary()) -> cb_context:context(). --spec after_post(cb_context:context(), ne_binary(), crossbar_status()) -> cb_context:context(). +-spec after_post(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). +-spec after_post(cb_context:context(), kz_term:ne_binary(), crossbar_status()) -> cb_context:context(). after_post(Context, DocType) -> after_post(Context, DocType, cb_context:resp_status(Context)). diff --git a/applications/crossbar/src/modules/cb_migrations.erl b/applications/crossbar/src/modules/cb_migrations.erl index b49f5dad9f4..98667b40c32 100644 --- a/applications/crossbar/src/modules/cb_migrations.erl +++ b/applications/crossbar/src/modules/cb_migrations.erl @@ -248,7 +248,7 @@ mark_migration_complete(MigId, AccountId, Context) -> {'ok', _} = kz_datamgr:save_doc(AccountDb, kz_json:set_value(<<"migrations_performed">>, NewMigs, Doc)), lager:debug("migrating ~s in ~s complete", [MigId, AccountId]). --spec get_user_name(ne_binary(), ne_binary()) -> api_ne_binary(). +-spec get_user_name(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_ne_binary(). get_user_name(AccountId, UserId) -> case kzd_user:fetch(AccountId, UserId) of {'ok', UserDoc} -> kzd_user:name(UserDoc); diff --git a/applications/crossbar/src/modules/cb_modules_util.erl b/applications/crossbar/src/modules/cb_modules_util.erl index ec341569158..63ab76ce325 100644 --- a/applications/crossbar/src/modules/cb_modules_util.erl +++ b/applications/crossbar/src/modules/cb_modules_util.erl @@ -40,7 +40,7 @@ -define(QCALL_NUMBER_FILTER, [<<" ">>, <<",">>, <<".">>, <<"-">>, <<"(">>, <<")">>]). --type binding() :: {ne_binary(), atom()}. +-type binding() :: {kz_term:ne_binary(), atom()}. -type bindings() :: [binding(),...]. -spec bind(atom(), bindings()) -> 'ok'. bind(Module, Bindings) -> @@ -49,18 +49,18 @@ bind(Module, Bindings) -> ], 'ok'. --spec pass_hashes(ne_binary(), ne_binary()) -> {ne_binary(), ne_binary()}. +-spec pass_hashes(kz_term:ne_binary(), kz_term:ne_binary()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. pass_hashes(Username, Password) -> Creds = list_to_binary([Username, ":", Password]), SHA1 = kz_term:to_hex_binary(crypto:hash('sha', Creds)), MD5 = kz_term:to_hex_binary(crypto:hash('md5', Creds)), {MD5, SHA1}. --spec update_mwi(ne_binary(), ne_binary()) -> pid(). +-spec update_mwi(kz_term:ne_binary(), kz_term:ne_binary()) -> pid(). update_mwi(BoxId, AccountId) -> kz_util:spawn(fun() -> send_mwi_update(BoxId, AccountId) end). --spec send_mwi_update(ne_binary(), ne_binary()) -> 'ok'. +-spec send_mwi_update(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. send_mwi_update(BoxId, AccountId) -> timer:sleep(?MILLISECONDS_IN_SECOND), @@ -74,7 +74,7 @@ send_mwi_update(BoxId, AccountId) -> _ = kz_util:spawn(fun send_mwi_update/4, [New, Saved, BoxNumber, AccountId]), lager:debug("sent MWI updates for vmbox ~s in account ~s (~b/~b)", [BoxNumber, AccountId, New, Saved]). --spec send_mwi_update(non_neg_integer(), non_neg_integer(), ne_binary(), ne_binary()) -> 'ok'. +-spec send_mwi_update(non_neg_integer(), non_neg_integer(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. send_mwi_update(New, Saved, BoxNumber, AccountId) -> Realm = kz_account:fetch_realm(AccountId), To = <>, @@ -87,7 +87,7 @@ send_mwi_update(New, Saved, BoxNumber, AccountId) -> lager:debug("updating MWI for vmbox ~s@~s (~b/~b)", [BoxNumber, Realm, New, Saved]), kz_amqp_worker:cast(Command, fun kapi_presence:publish_mwi_update/1). --spec get_devices_owned_by(ne_binary(), ne_binary()) -> kz_json:objects(). +-spec get_devices_owned_by(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:objects(). get_devices_owned_by(OwnerID, DB) -> case kz_datamgr:get_results(DB ,<<"attributes/owned">> @@ -151,7 +151,7 @@ request_specific_extraction_funs_from_nouns(Context, ?USERS_QCALL_NOUNS(UserId, request_specific_extraction_funs_from_nouns(_Context, _ReqNouns) -> []. --spec filter_number_regex(ne_binary(), ne_binary()) -> ne_binary(). +-spec filter_number_regex(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). filter_number_regex(Number, Regex) -> case re:run(Number, Regex, [{'capture', 'all_but_first', 'binary'}]) of {'match', [Match|_]} -> @@ -163,7 +163,7 @@ filter_number_regex(Number, Regex) -> Number end. --spec build_number_uri(cb_context:context(), ne_binary()) -> ne_binary(). +-spec build_number_uri(cb_context:context(), kz_term:ne_binary()) -> kz_term:ne_binary(). build_number_uri(Context, Number) -> QueryStr = cb_context:query_string(Context), FilterVal = kz_json:get_value(<<"number_filter">>, QueryStr, <<"true">>), @@ -208,7 +208,7 @@ get_endpoints(Call, _Context, ?USERS_QCALL_NOUNS(_UserId, Number)) -> get_endpoints(_Call, _Context, _ReqNouns) -> []. --spec aleg_cid(ne_binary(), kapps_call:call()) -> kapps_call:call(). +-spec aleg_cid(kz_term:ne_binary(), kapps_call:call()) -> kapps_call:call(). aleg_cid(Number, Call) -> Routines = [{fun kapps_call:set_custom_channel_var/3, <<"Retain-CID">>, <<"true">>} ,{fun kapps_call:set_caller_id_name/2, <<"QuickCall">>} @@ -216,13 +216,13 @@ aleg_cid(Number, Call) -> ], kapps_call:exec(Routines, Call). --spec cavs_from_context(cb_context:context()) -> kz_proplist(). +-spec cavs_from_context(cb_context:context()) -> kz_term:proplist(). cavs_from_context(Context) -> ReqData = cb_context:req_data(Context), QueryString = cb_context:query_string(Context), cavs_from_request(ReqData, QueryString). --spec cavs_from_request(api_object(), api_object()) -> kz_proplist(). +-spec cavs_from_request(kz_term:api_object(), kz_term:api_object()) -> kz_term:proplist(). cavs_from_request('undefined', 'undefined') -> []; cavs_from_request('undefined', QueryString) -> kapps_call_util:filter_ccvs(QueryString); @@ -382,21 +382,21 @@ get_timeout(Context) -> get_ignore_early_media(Context) -> kz_term:is_true(cb_context:req_value(Context, <<"ignore-early-media">>, 'true')). --spec get_media(cb_context:context()) -> ne_binary(). +-spec get_media(cb_context:context()) -> kz_term:ne_binary(). get_media(Context) -> case cb_context:req_value(Context, <<"media">>) of <<"bypass">> -> <<"bypass">>; _Else -> <<"process">> end. --spec get_cid_name(cb_context:context(), api_binary()) -> api_binary(). +-spec get_cid_name(cb_context:context(), kz_term:api_binary()) -> kz_term:api_binary(). get_cid_name(Context, Default) -> case cb_context:req_value(Context, <<"cid-name">>, Default) of 'undefined' -> 'undefined'; CIDName -> kz_util:uri_decode(CIDName) end. --spec get_cid_number(cb_context:context(), api_binary()) -> api_binary(). +-spec get_cid_number(cb_context:context(), kz_term:api_binary()) -> kz_term:api_binary(). get_cid_number(Context, Default) -> case cb_context:req_value(Context, <<"cid-number">>, Default) of 'undefined' -> 'undefined'; @@ -410,7 +410,7 @@ get_cid_number(Context, Default) -> %% it has an extension (for the associated content type) %% @end %%-------------------------------------------------------------------- --spec attachment_name(binary(), text()) -> ne_binary(). +-spec attachment_name(binary(), kz_term:text()) -> kz_term:ne_binary(). attachment_name(Filename, CT) -> Generators = [fun(A) -> case kz_term:is_empty(A) of @@ -428,8 +428,8 @@ attachment_name(Filename, CT) -> ], lists:foldl(fun(F, A) -> F(A) end, Filename, Generators). --spec parse_media_type(ne_binary()) -> media_values() | - {'error', 'badarg'}. +-spec parse_media_type(kz_term:ne_binary()) -> media_values() | + {'error', 'badarg'}. parse_media_type(MediaType) -> try cow_http_hd:parse_accept(MediaType) catch @@ -438,8 +438,8 @@ parse_media_type(MediaType) -> {'error', 'badarg'} end. --spec bucket_name(cb_context:context()) -> ne_binary(). --spec bucket_name(api_ne_binary(), api_ne_binary()) -> ne_binary(). +-spec bucket_name(cb_context:context()) -> kz_term:ne_binary(). +-spec bucket_name(kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> kz_term:ne_binary(). bucket_name(Context) -> bucket_name(cb_context:client_ip(Context), cb_context:account_id(Context)). @@ -481,7 +481,7 @@ token_cost(Context, Default, Suffix) when is_integer(Default), Default >= 0 -> ,kz_json:path() ,req_nouns() ,http_method() - ,api_ne_binary() + ,kz_term:api_ne_binary() ) -> integer() | Default. find_token_cost(N, _Default, _Suffix, _Nouns, _ReqVerb, _AccountId) when is_integer(N) -> @@ -530,7 +530,7 @@ remove_plaintext_password(Context) -> cb_context:set_doc(Context, Doc). %% @public --spec validate_number_ownership(ne_binaries(), cb_context:context()) -> +-spec validate_number_ownership(kz_term:ne_binaries(), cb_context:context()) -> cb_context:context(). validate_number_ownership(Numbers, Context) -> Options = [{'auth_by', cb_context:auth_account_id(Context)}], @@ -544,8 +544,8 @@ validate_number_ownership(Numbers, Context) -> cb_context:add_system_error(403, 'forbidden', Message, Context) end. --spec validate_number_ownership_fold(knm_numbers:num(), knm_numbers:ko(), ne_binaries()) -> - ne_binaries(). +-spec validate_number_ownership_fold(knm_numbers:num(), knm_numbers:ko(), kz_term:ne_binaries()) -> + kz_term:ne_binaries(). validate_number_ownership_fold(_, Reason, Unauthorized) when is_atom(Reason) -> %% Ignoring atom reasons, i.e. 'not_found' or 'not_reconcilable' Unauthorized; @@ -555,13 +555,13 @@ validate_number_ownership_fold(Number, ReasonJObj, Unauthorized) -> _ -> Unauthorized end. --type assignment_to_apply() :: {ne_binary(), api_binary()}. +-type assignment_to_apply() :: {kz_term:ne_binary(), kz_term:api_binary()}. -type assignments_to_apply() :: [assignment_to_apply()]. --type port_req_assignment() :: {ne_binary(), api_binary(), kz_json:object()}. +-type port_req_assignment() :: {kz_term:ne_binary(), kz_term:api_binary(), kz_json:object()}. -type port_req_assignments() :: [port_req_assignment()]. --type assignment_update() :: {ne_binary(), knm_number:knm_number_return()} | - {ne_binary(), {'ok', kz_json:object()}} | - {ne_binary(), {'error', any()}}. +-type assignment_update() :: {kz_term:ne_binary(), knm_number:knm_number_return()} | + {kz_term:ne_binary(), {'ok', kz_json:object()}} | + {kz_term:ne_binary(), {'error', any()}}. -type assignment_updates() :: [assignment_update()]. -spec apply_assignment_updates(assignments_to_apply(), cb_context:context()) -> @@ -600,7 +600,7 @@ assign_to_port_number(PRUpdates) -> || {Num, Assign, JObj} <- PRUpdates ]. --spec maybe_assign_to_app(assignments_to_apply(), ne_binary()) -> +-spec maybe_assign_to_app(assignments_to_apply(), kz_term:ne_binary()) -> assignment_updates(). maybe_assign_to_app(NumUpdates, AccountId) -> Options = [{'auth_by', AccountId}], @@ -610,7 +610,7 @@ maybe_assign_to_app(NumUpdates, AccountId) -> format_assignment_results(Results) ++ Acc end, [], Groups). --type assign_to_groups() :: #{api_binary() => ne_binaries()}. +-type assign_to_groups() :: #{kz_term:api_binary() => kz_term:ne_binaries()}. -spec group_by_assign_to(assignments_to_apply()) -> assign_to_groups(). group_by_assign_to(NumUpdates) -> @@ -655,7 +655,7 @@ log_assignment_update({DID, {'ok', _Number}}) -> log_assignment_update({DID, {'error', E}}) -> lager:debug("failed to update ~s: ~p", [DID, E]). --spec normalize_media_upload(cb_context:context(), ne_binary(), ne_binary(), kz_json:object(), kz_media_util:normalization_options()) -> +-spec normalize_media_upload(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), kz_media_util:normalization_options()) -> {cb_context:context(), kz_json:object()}. normalize_media_upload(Context, FromExt, ToExt, FileJObj, NormalizeOptions) -> NormalizedResult = kz_media_util:normalize_media(FromExt @@ -665,7 +665,7 @@ normalize_media_upload(Context, FromExt, ToExt, FileJObj, NormalizeOptions) -> ), handle_normalized_upload(Context, FileJObj, ToExt, NormalizedResult). --spec handle_normalized_upload(cb_context:context(), kz_json:object(), ne_binary(), kz_media_util:normalized_media()) -> +-spec handle_normalized_upload(cb_context:context(), kz_json:object(), kz_term:ne_binary(), kz_media_util:normalized_media()) -> {cb_context:context(), kz_json:object()}. handle_normalized_upload(Context, FileJObj, ToExt, {'ok', Contents}) -> lager:debug("successfully normalized to ~s", [ToExt]), @@ -698,14 +698,14 @@ handle_normalized_upload(Context, FileJObj, ToExt, {'error', _R}) -> %% but we want "action" on the envelope to be respected for these PUTs against %% /channels or /conferences, so we reverse the order here (just in case people are %% only putting "action" in "data" --spec get_request_action(cb_context:context()) -> api_ne_binary(). +-spec get_request_action(cb_context:context()) -> kz_term:api_ne_binary(). get_request_action(Context) -> kz_json:find(<<"action">>, [cb_context:req_json(Context) ,cb_context:req_data(Context) ] ). --spec normalize_alphanum_name(api_binary() | cb_context:context()) -> cb_context:context() | api_binary(). +-spec normalize_alphanum_name(kz_term:api_binary() | cb_context:context()) -> cb_context:context() | kz_term:api_binary(). normalize_alphanum_name('undefined') -> 'undefined'; normalize_alphanum_name(Name) when is_binary(Name) -> diff --git a/applications/crossbar/src/modules/cb_multi_factor.erl b/applications/crossbar/src/modules/cb_multi_factor.erl index 5387e4e7f73..3b1b1826d58 100644 --- a/applications/crossbar/src/modules/cb_multi_factor.erl +++ b/applications/crossbar/src/modules/cb_multi_factor.erl @@ -233,7 +233,7 @@ create(Context) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec read(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec read(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). read(Id, Context) -> crossbar_doc:load(Id, Context, ?TYPE_CHECK_OPTION(<<"provider">>)). @@ -244,7 +244,7 @@ read(Id, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec update(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec update(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). update(Id, Context) -> OnSuccess = fun(C) -> on_successful_validation(Id, C) end, cb_context:validate_request_data(<<"multi_factor_provider">>, Context, OnSuccess). @@ -255,7 +255,7 @@ update(Id, Context) -> %% Load a login attempt log from MODB %% @end %%-------------------------------------------------------------------- --spec read_attempt_log(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec read_attempt_log(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). read_attempt_log(?MATCH_MODB_PREFIX(YYYY, MM, _) = AttemptId, Context) -> Year = kz_term:to_integer(YYYY), Month = kz_term:to_integer(MM), @@ -268,7 +268,7 @@ read_attempt_log(?MATCH_MODB_PREFIX(YYYY, MM, _) = AttemptId, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec validate_patch(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_patch(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). validate_patch(Id, Context) -> crossbar_doc:patch_and_validate(Id, Context, fun update/2). @@ -319,7 +319,7 @@ merge_summary(Configured, Available) -> %% %% @end %%-------------------------------------------------------------------- --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> Doc = kz_json:set_value(<<"pvt_provider_type">>, <<"multi_factor">>, cb_context:doc(Context)), cb_context:set_doc(Context, kz_doc:set_type(Doc, <<"provider">>)); diff --git a/applications/crossbar/src/modules/cb_notifications.erl b/applications/crossbar/src/modules/cb_notifications.erl index 83ee3875f2f..8acc770b6dd 100644 --- a/applications/crossbar/src/modules/cb_notifications.erl +++ b/applications/crossbar/src/modules/cb_notifications.erl @@ -151,7 +151,7 @@ resource_exists(?CUSTOMER_UPDATE, ?MESSAGE) -> 'true'. %% @end %%-------------------------------------------------------------------- --spec acceptable_content_types() -> kz_proplist(). +-spec acceptable_content_types() -> kz_term:proplist(). acceptable_content_types() -> ?NOTIFICATION_MIME_TYPES. @@ -196,12 +196,12 @@ set_content_types(Context, Attachments) -> ,{'to_binary', ContentTypes} ]). --spec content_types_from_attachments(kz_json:object()) -> kz_proplist(). +-spec content_types_from_attachments(kz_json:object()) -> kz_term:proplist(). content_types_from_attachments(Attachments) -> kz_json:foldl(fun content_type_from_attachment/3, [], Attachments). --spec content_type_from_attachment(kz_json:path(), kz_json:object(), kz_proplist()) -> - kz_proplist(). +-spec content_type_from_attachment(kz_json:path(), kz_json:object(), kz_term:proplist()) -> + kz_term:proplist(). content_type_from_attachment(_Name, Attachment, Acc) -> case kz_json:get_value(<<"content_type">>, Attachment) of 'undefined' -> Acc; @@ -269,7 +269,7 @@ validate_notifications(Context, ?HTTP_PUT) -> validate_notifications(Context, ?HTTP_DELETE) -> validate_action(Context, ?HTTP_DELETE, cb_context:req_value(Context, <<"action">>), cb_context:account_id(Context)). --spec validate_action(cb_context:context(), http_method(), api_binary(), api_binary()) -> cb_context:context(). +-spec validate_action(cb_context:context(), http_method(), kz_term:api_binary(), kz_term:api_binary()) -> cb_context:context(). validate_action(Context, ?HTTP_PUT, 'undefined', _AccountId) -> create(Context); validate_action(Context, _Method, Action, 'undefined') -> @@ -292,7 +292,7 @@ validate_notification(Context, Id, ?HTTP_POST) -> validate_notification(Context, Id, ?HTTP_DELETE) -> validate_delete(Context, Id, cb_context:account_id(Context)). --spec validate_delete(cb_context:context(), path_token(), api_binary()) -> cb_context:context(). +-spec validate_delete(cb_context:context(), path_token(), kz_term:api_binary()) -> cb_context:context(). validate_delete(Context, Id, 'undefined') -> disallow_delete(Context, kz_notification:resp_id(Id)); validate_delete(Context, Id, _AccountId) -> @@ -319,7 +319,7 @@ may_be_validate_recipient_id(Context) -> Context end. --spec validate_recipient_id(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_recipient_id(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). validate_recipient_id(RecipientId, Context) -> SenderId = sender_account_id(Context), ViewOpts = [{'startkey', [SenderId]} @@ -337,11 +337,11 @@ validate_recipient_id(RecipientId, Context) -> Context end. --spec sender_account_id(cb_context:context()) -> ne_binary(). +-spec sender_account_id(cb_context:context()) -> kz_term:ne_binary(). sender_account_id(Context) -> sender_account_id(Context, cb_context:account_id(Context)). --spec sender_account_id(cb_context:context(), api_ne_binary()) -> ne_binary(). +-spec sender_account_id(cb_context:context(), kz_term:api_ne_binary()) -> kz_term:ne_binary(). sender_account_id(Context, 'undefined') -> cb_context:auth_account_id(Context); sender_account_id(_Context, AccountId) -> @@ -447,7 +447,7 @@ post(Context, Id, ?PREVIEW) -> crossbar_util:response('error', <<"Failed to process notification preview">>, Context) end. --spec build_customer_update_payload(cb_context:context()) -> kz_proplist(). +-spec build_customer_update_payload(cb_context:context()) -> kz_term:proplist(). build_customer_update_payload(Context) -> SenderId = sender_account_id(Context), props:filter_empty( @@ -465,7 +465,7 @@ build_customer_update_payload(Context) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]). --spec build_preview_payload(cb_context:context(), kz_json:object()) -> kz_proplist(). +-spec build_preview_payload(cb_context:context(), kz_json:object()) -> kz_term:proplist(). build_preview_payload(Context, Notification) -> props:filter_empty( [{<<"Template-ID">>, kz_json:get_value(<<"id">>, Notification)} @@ -497,7 +497,7 @@ handle_preview_response(Context, Resp) -> crossbar_util:response_202(<<"Notification processing">>, Context) end. --spec headers(ne_binary()) -> ne_binaries(). +-spec headers(kz_term:ne_binary()) -> kz_term:ne_binaries(). headers(<<"voicemail_to_email">>) -> kapi_notifications:headers(<<"voicemail_new">>); headers(<<"port_request_admin">>) -> @@ -511,7 +511,7 @@ headers(<<"transaction_failed">>) -> headers(Id) -> kapi_notifications:headers(Id). --spec maybe_add_extra_data(ne_binary(), kz_proplist()) -> kz_proplist(). +-spec maybe_add_extra_data(kz_term:ne_binary(), kz_term:proplist()) -> kz_term:proplist(). maybe_add_extra_data(<<"fax_inbound_error_to_email">>, API) -> props:set_value(<<"Fax-Result-Code">>, <<"500">>, API); maybe_add_extra_data(<<"fax_inbound_error_to_email_filtered">>, API) -> @@ -524,7 +524,7 @@ maybe_add_extra_data(<<"transaction_failed">>, API) -> props:set_value(<<"Success">>, 'false', API); maybe_add_extra_data(_Id, API) -> API. --spec publish_fun(ne_binary()) -> fun((api_terms()) -> 'ok'). +-spec publish_fun(kz_term:ne_binary()) -> fun((kz_term:api_terms()) -> 'ok'). publish_fun(<<"account_zone_change">>) -> fun kapi_notifications:publish_account_zone_change/1; publish_fun(<<"cnam_request">>) -> @@ -597,8 +597,8 @@ publish_fun(_Id) -> lager:debug("no kapi_notifications:publish_~s/1 defined", [_Id]), fun(_Any) -> 'ok' end. --spec preview_fold(ne_binary(), {kz_proplist(), kz_json:object()}) -> - {kz_proplist(), kz_json:object()}. +-spec preview_fold(kz_term:ne_binary(), {kz_term:proplist(), kz_json:object()}) -> + {kz_term:proplist(), kz_json:object()}. preview_fold(Header, {Props, ReqData}) -> case kz_json:get_first_defined([Header, kz_json:normalize_key(Header)], ReqData) of 'undefined' -> @@ -627,7 +627,7 @@ maybe_delete(Context, Id, [?MEDIA_VALUE(<<"application">>, <<"x-json">>, _, _, _ maybe_delete(Context, Id, [?MEDIA_VALUE(Type, SubType, _, _, _)]) -> maybe_delete_template(Context, Id, <>). --spec delete_doc(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec delete_doc(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). delete_doc(Context, Id) -> Context1 = crossbar_doc:delete(Context, ?HARD_DELETE), case cb_context:resp_status(Context1) of @@ -637,9 +637,9 @@ delete_doc(Context, Id) -> _Status -> Context1 end. --spec maybe_delete_template(cb_context:context(), ne_binary(), ne_binary()) -> +-spec maybe_delete_template(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). --spec maybe_delete_template(cb_context:context(), ne_binary(), ne_binary(), kz_json:object()) -> +-spec maybe_delete_template(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> cb_context:context(). maybe_delete_template(Context, Id, ContentType) -> maybe_delete_template(Context, Id, ContentType, cb_context:doc(Context)). @@ -679,8 +679,8 @@ accept_values(Context) -> Tunneled = cb_context:req_value(Context, <<"accept">>), media_values(AcceptValue, Tunneled). --spec media_values(api_binary()) -> media_values(). --spec media_values(api_binary(), api_binary()) -> media_values(). +-spec media_values(kz_term:api_binary()) -> media_values(). +-spec media_values(kz_term:api_binary(), kz_term:api_binary()) -> media_values(). media_values(Media) -> media_values(Media, 'undefined'). @@ -700,12 +700,12 @@ media_values(AcceptValue, Tunneled) -> lists:reverse(lists:keysort(2, TunneledValues)) end. --spec acceptable_content_types(cb_context:context()) -> kz_proplist(). +-spec acceptable_content_types(cb_context:context()) -> kz_term:proplist(). acceptable_content_types(Context) -> props:get_value('to_binary', cb_context:content_types_provided(Context), []). --spec maybe_read(cb_context:context(), ne_binary()) -> cb_context:context(). --spec maybe_read(cb_context:context(), ne_binary(), kz_proplist(), media_values()) -> cb_context:context(). +-spec maybe_read(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). +-spec maybe_read(cb_context:context(), kz_term:ne_binary(), kz_term:proplist(), media_values()) -> cb_context:context(). maybe_read(Context, Id) -> Acceptable = acceptable_content_types(Context), maybe_read(Context, Id, Acceptable, accept_values(Context)). @@ -730,14 +730,14 @@ maybe_read(Context, Id, _Acceptable, []) -> lager:debug("no accept headers, using json"), read(Context, Id). --spec is_acceptable_accept(kz_proplist(), ne_binary(), ne_binary()) -> boolean(). +-spec is_acceptable_accept(kz_term:proplist(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_acceptable_accept(Acceptable, Type, SubType) -> lists:member({Type,SubType}, Acceptable). -type load_from() :: 'system' | 'account' | 'system_migrate'. --spec read(cb_context:context(), ne_binary()) -> cb_context:context(). --spec read(cb_context:context(), ne_binary(), load_from()) -> cb_context:context(). +-spec read(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). +-spec read(cb_context:context(), kz_term:ne_binary(), load_from()) -> cb_context:context(). read(Context, Id) -> read(Context, Id, 'system'). @@ -758,7 +758,7 @@ read(Context, Id, LoadFrom) -> _Status -> Context1 end. --spec read_system(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec read_system(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). read_system(Context, Id) -> Context1 = crossbar_doc:load(Id ,cb_context:set_account_db(Context, ?KZ_CONFIG_DB) @@ -774,7 +774,7 @@ read_system(Context, Id) -> {_Code, _status} -> Context1 end. --spec read_account(cb_context:context(), ne_binary(), load_from()) -> cb_context:context(). +-spec read_account(cb_context:context(), kz_term:ne_binary(), load_from()) -> cb_context:context(). read_account(Context, Id, LoadFrom) -> Context1 = crossbar_doc:load(Id, Context, ?TYPE_CHECK_OPTION(kz_notification:pvt_type())), case {cb_context:resp_error_code(Context1) @@ -793,7 +793,7 @@ read_account(Context, Id, LoadFrom) -> Context1 end. --spec maybe_read_from_parent(cb_context:context(), ne_binary(), load_from(), api_binary()) -> cb_context:context(). +-spec maybe_read_from_parent(cb_context:context(), kz_term:ne_binary(), load_from(), kz_term:api_binary()) -> cb_context:context(). maybe_read_from_parent(Context, Id, LoadFrom, 'undefined') -> lager:debug("~s not found in account and reseller is undefined, reading from master", [Id]), read_system_for_account(Context, Id, LoadFrom); @@ -829,7 +829,7 @@ read_system_for_account(Context, Id, LoadFrom) -> Context1 end. --spec get_parent_account_id(ne_binary()) -> api_binary(). +-spec get_parent_account_id(kz_term:ne_binary()) -> kz_term:api_binary(). get_parent_account_id(AccountId) -> case kz_account:fetch(AccountId) of {'ok', JObj} -> kz_account:parent_account_id(JObj); @@ -866,7 +866,7 @@ migrate_template_to_account(Context, Id) -> _Status -> Context1 end. --spec maybe_hard_delete(cb_context:context(), ne_binary()) -> 'ok'. +-spec maybe_hard_delete(cb_context:context(), kz_term:ne_binary()) -> 'ok'. maybe_hard_delete(Context, Id) -> case kz_datamgr:del_doc(cb_context:account_db(Context), Id) of {'ok', _} -> @@ -879,7 +879,7 @@ maybe_hard_delete(Context, Id) -> lager:debug("error deleting ~s from ~s: ~p", [Id, cb_context:account_db(Context), _E]) end. --spec maybe_merge_ancestor_attachments(cb_context:context(), ne_binary()) -> +-spec maybe_merge_ancestor_attachments(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). maybe_merge_ancestor_attachments(Context, Id) -> Doc = cb_context:doc(Context), @@ -889,8 +889,8 @@ maybe_merge_ancestor_attachments(Context, Id) -> _ -> cb_context:store(Context, 'attachments_db', AttachmentsDb) end. --spec merge_ancestor_attachments(cb_context:context(), ne_binary()) -> cb_context:context(). --spec merge_ancestor_attachments(cb_context:context(), ne_binary(), ne_binary(), ne_binary()) -> +-spec merge_ancestor_attachments(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). +-spec merge_ancestor_attachments(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). merge_ancestor_attachments(Context, Id) -> AccountId = cb_context:account_id(Context), @@ -921,7 +921,7 @@ merge_ancestor_attachments(Context, Id, AccountId, ResellerId) -> try_parent_attachments(Context, Id, AccountId, ParentAccountId, ResellerId) end. --spec try_parent_attachments(cb_context:context(), ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> +-spec try_parent_attachments(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). try_parent_attachments(Context, Id, AccountId, ParentAccountId, ResellerId) -> ParentNotificationContext = crossbar_doc:load(Id @@ -940,7 +940,7 @@ try_parent_attachments(Context, Id, AccountId, ParentAccountId, ResellerId) -> ,{fun cb_context:store/3, 'attachments_db', AttachmentsDb}]) end. --spec masquerade(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec masquerade(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). masquerade(Context, AccountId) -> AccountDb = kz_util:format_account_id(AccountId, 'encoded'), cb_context:setters(Context @@ -957,7 +957,7 @@ maybe_set_teletype_as_default(Context) -> maybe_set_teletype_as_default(Context, AccountDb, AccountJObj) end. --spec maybe_set_teletype_as_default(cb_context:context(), ne_binary(), kz_json:object()) -> 'ok'. +-spec maybe_set_teletype_as_default(cb_context:context(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. maybe_set_teletype_as_default(Context, AccountDb, AccountJObj) -> case kz_account:notification_preference(AccountJObj) of 'undefined' -> set_teletype_as_default(Context, AccountDb, AccountJObj); @@ -965,7 +965,7 @@ maybe_set_teletype_as_default(Context, AccountDb, AccountJObj) -> _Pref -> set_teletype_as_default(Context, AccountDb, AccountJObj) end. --spec set_teletype_as_default(cb_context:context(), ne_binary(), kz_json:object()) -> 'ok'. +-spec set_teletype_as_default(cb_context:context(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. set_teletype_as_default(Context, AccountDb, AccountJObj) -> JObj = kz_account:set_notification_preference(AccountJObj, <<"teletype">>), case kz_datamgr:save_doc(AccountDb, crossbar_doc:update_pvt_parameters(JObj, Context)) of @@ -976,7 +976,7 @@ set_teletype_as_default(Context, AccountDb, AccountJObj) -> lager:debug("failed to note preference: ~p", [_E]) end. --spec migrate_template_attachments(cb_context:context(), ne_binary(), api_object()) -> cb_context:context(). +-spec migrate_template_attachments(cb_context:context(), kz_term:ne_binary(), kz_term:api_object()) -> cb_context:context(). migrate_template_attachments(Context, _Id, 'undefined') -> lager:debug("no attachments to migrate for ~s", [_Id]), Context; @@ -987,7 +987,7 @@ migrate_template_attachments(Context, Id, Attachments) -> migrate_template_attachment(MasterAccountDb, Id, AName, AMeta, C) end, Context, Attachments). --spec migrate_template_attachment(ne_binary(), ne_binary(), ne_binary(), kz_json:object(), cb_context:context()) -> +-spec migrate_template_attachment(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), cb_context:context()) -> cb_context:context(). migrate_template_attachment(MasterAccountDb, Id, AName, AMeta, Context) -> case kz_datamgr:fetch_attachment(MasterAccountDb, Id, AName) of @@ -1012,7 +1012,7 @@ read_success(Context) -> ,fun leak_doc_id/1 ]). --spec maybe_read_template(cb_context:context(), ne_binary(), ne_binary()) -> cb_context:context(). +-spec maybe_read_template(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). maybe_read_template(Context, _Id, <<"application/json">>) -> Context; maybe_read_template(Context, _Id, <<"application/x-json">>) -> Context; maybe_read_template(Context, Id, Accept) -> @@ -1021,7 +1021,7 @@ maybe_read_template(Context, Id, Accept) -> _Status -> Context end. --spec read_template(cb_context:context(), ne_binary(), ne_binary()) -> cb_context:context(). +-spec read_template(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). read_template(Context, Id, Accept) -> Doc = cb_context:fetch(Context, 'db_doc'), AttachmentName = attachment_name_by_media_type(Accept), @@ -1045,14 +1045,14 @@ read_template(Context, Id, Accept) -> ) end. --spec attachment_filename(ne_binary(), ne_binary()) -> iolist(). +-spec attachment_filename(kz_term:ne_binary(), kz_term:ne_binary()) -> iolist(). attachment_filename(Id, Accept) -> [<<"attachment; filename=">> ,kz_notification:resp_id(Id) ,$., kz_mime:to_extension(Accept) ]. --spec read_account_attachment(cb_context:context(), ne_binary(), ne_binary(), ne_binary()) -> cb_context:context(). +-spec read_account_attachment(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). read_account_attachment(Context, AttachmentsDb, DocId, Name) -> Context1 = crossbar_doc:load_attachment(DocId ,Name @@ -1081,7 +1081,7 @@ read_account_attachment(Context, AttachmentsDb, DocId, Name) -> %% valid %% @end %%-------------------------------------------------------------------- --spec maybe_update(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec maybe_update(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). maybe_update(Context, Id) -> case cb_context:req_files(Context) of [] -> @@ -1092,13 +1092,13 @@ maybe_update(Context, Id) -> read(Context, Id, 'system_migrate') end. --spec update_notification(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec update_notification(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). update_notification(Context, Id) -> Context1 = maybe_inherit_defaults(Context, cb_context:doc(read(Context, Id))), OnSuccess = fun(C) -> on_successful_validation(Id, C) end, cb_context:validate_request_data(<<"notifications">>, Context1, OnSuccess). --spec maybe_inherit_defaults(cb_context:context(), api_object()) -> +-spec maybe_inherit_defaults(cb_context:context(), kz_term:api_object()) -> cb_context:context(). maybe_inherit_defaults(Context, Doc) -> case ?INHERIT_DEFAULT_VALUES of @@ -1106,7 +1106,7 @@ maybe_inherit_defaults(Context, Doc) -> 'false' -> Context end. --spec inherit_defaults(cb_context:context(), api_object()) -> cb_context:context(). +-spec inherit_defaults(cb_context:context(), kz_term:api_object()) -> cb_context:context(). inherit_defaults(Context, 'undefined') -> Context; inherit_defaults(Context, InheritedDefaultsDoc) -> PublicDefaults = kz_doc:public_fields(InheritedDefaultsDoc), @@ -1137,15 +1137,15 @@ update_template(Context, Id, FileJObj) -> crossbar_util:response('error', <<"Failed to compile notification template">>, Context) end. --spec attachment_name_by_content_type(ne_binary()) -> ne_binary(). +-spec attachment_name_by_content_type(kz_term:ne_binary()) -> kz_term:ne_binary(). attachment_name_by_content_type(CT) -> kz_binary:clean(<<"template.", CT/binary>>). --spec attachment_name_by_media_type(ne_binary()) -> ne_binary(). +-spec attachment_name_by_media_type(kz_term:ne_binary()) -> kz_term:ne_binary(). attachment_name_by_media_type(CT) -> <<"template.", CT/binary>>. --spec template_module_name(ne_binary(), cb_context:context(), ne_binary()) -> atom(). +-spec template_module_name(kz_term:ne_binary(), cb_context:context(), kz_term:ne_binary()) -> atom(). template_module_name(Id, Context, CT) -> AccountId = cb_context:account_db(Context), [_C, Type] = binary:split(CT, <<"/">>), @@ -1308,13 +1308,13 @@ normalize_available_port(Value, Acc, Context) -> %% @end %%-------------------------------------------------------------------- --spec system_config_notification_doc(ne_binary()) -> +-spec system_config_notification_doc(kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. system_config_notification_doc(DocId) -> kz_datamgr:open_cache_doc(?KZ_CONFIG_DB, DocId). --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> ReqTemplate = clean_req_doc(cb_context:doc(Context)), @@ -1350,7 +1350,7 @@ on_successful_validation(Id, Context) -> Context1 end. --spec handle_missing_account_notification(cb_context:context(), ne_binary(), kz_proplist()) -> +-spec handle_missing_account_notification(cb_context:context(), kz_term:ne_binary(), kz_term:proplist()) -> cb_context:context(). handle_missing_account_notification(Context, Id, [{<<"notifications">>, [_Id, ?PREVIEW]}|_]) -> lager:debug("preview request, ignoring if notification ~s is missing", [Id]), @@ -1360,7 +1360,7 @@ handle_missing_account_notification(Context, Id, _ReqNouns) -> _Context = read_system_for_account(Context, Id, 'system_migrate'), on_successful_validation(Id, Context). --spec handle_missing_system_config_notification(cb_context:context(), ne_binary(), kz_json:object()) -> +-spec handle_missing_system_config_notification(cb_context:context(), kz_term:ne_binary(), kz_json:object()) -> cb_context:context(). handle_missing_system_config_notification(Context, DocId, ReqTemplate) -> case cb_context:account_id(Context) of @@ -1374,7 +1374,7 @@ handle_missing_system_config_notification(Context, DocId, ReqTemplate) -> crossbar_util:response_bad_identifier(kz_notification:resp_id(DocId), Context) end. --spec create_new_notification(cb_context:context(), ne_binary(), kz_json:object()) -> +-spec create_new_notification(cb_context:context(), kz_term:ne_binary(), kz_json:object()) -> cb_context:context(). create_new_notification(Context, DocId, ReqTemplate) -> lager:debug("this will create a new template in the system config"), @@ -1420,7 +1420,7 @@ leak_attachments_fold(_Attachment, Props, Acc) -> ,Acc ). --spec load_smtp_log_doc(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_smtp_log_doc(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_smtp_log_doc(?MATCH_MODB_PREFIX(YYYY,MM,_) = Id, Context) -> Year = kz_term:to_integer(YYYY), Month = kz_term:to_integer(MM), @@ -1441,7 +1441,7 @@ maybe_update_db(Context) -> %% Remove Template Customization from an account %% @end %%-------------------------------------------------------------------- --spec remove_account_customizations(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec remove_account_customizations(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). remove_account_customizations(Context, AccountId) -> ToRemove = list_templates_from_db(kz_util:format_account_db(AccountId)), Result = remove_customization(AccountId, ToRemove), @@ -1450,7 +1450,7 @@ remove_account_customizations(Context, AccountId) -> ], cb_context:setters(Context, Setters). --spec remove_customization(ne_binary(), ne_binaries()) -> kz_json:object(). +-spec remove_customization(kz_term:ne_binary(), kz_term:ne_binaries()) -> kz_json:object(). remove_customization(_, []) -> kz_json:from_list([{<<"message">>, <<"no template customization(s) found">>}]); remove_customization(AccountId, Ids) -> @@ -1475,7 +1475,7 @@ remove_customization(AccountId, Ids) -> %% system_config to account's db. %% @end %%-------------------------------------------------------------------- --spec force_system_templates(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec force_system_templates(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). force_system_templates(Context, AccountId) -> ToRemove = list_templates_from_db(kz_util:format_account_db(AccountId)), _ = remove_customization(AccountId, ToRemove), @@ -1486,7 +1486,7 @@ force_system_templates(Context, AccountId) -> ], cb_context:setters(Context, Setters). --spec force_system_default(ne_binary(), ne_binaries()) -> kz_json:object(). +-spec force_system_default(kz_term:ne_binary(), kz_term:ne_binaries()) -> kz_json:object(). force_system_default(_, []) -> kz_json:from_list([{<<"message">>, <<"no system template found">>}]); force_system_default(AccountId, Ids) -> @@ -1494,14 +1494,14 @@ force_system_default(AccountId, Ids) -> AccountDb = kz_util:format_account_db(AccountId), kz_json:from_list([copy_from_system_to_account(AccountDb, Id) || Id <- Ids]). --spec copy_from_system_to_account(ne_binary(), ne_binary()) -> {ne_binary(), ne_binary()}. +-spec copy_from_system_to_account(kz_term:ne_binary(), kz_term:ne_binary()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. copy_from_system_to_account(AccountDb, Id) -> case kz_datamgr:copy_doc(?KZ_CONFIG_DB, Id, AccountDb, Id, []) of {'ok', _} -> {kz_notification:resp_id(Id), <<"replaced">>}; {'error', Reason} -> {kz_notification:resp_id(Id), kz_term:to_binary(Reason)} end. --spec list_templates_from_db(ne_binary()) -> ne_binaries(). +-spec list_templates_from_db(kz_term:ne_binary()) -> kz_term:ne_binaries(). list_templates_from_db(Db) -> ViewOpts = [{'startkey', <<"notification.">>} ,{'endkey', <<"notification.zzz">>} diff --git a/applications/crossbar/src/modules/cb_onboard.erl b/applications/crossbar/src/modules/cb_onboard.erl index f0b9524b5ea..23a153f90a4 100644 --- a/applications/crossbar/src/modules/cb_onboard.erl +++ b/applications/crossbar/src/modules/cb_onboard.erl @@ -121,7 +121,7 @@ put(Context) -> %% Any errors will also be collected. %% @end %%-------------------------------------------------------------------- --spec create_extensions(kz_json:object(), cb_context:context(), {kz_proplist(), kz_json:object()}) -> {kz_proplist(), kz_json:object()}. +-spec create_extensions(kz_json:object(), cb_context:context(), {kz_term:proplist(), kz_json:object()}) -> {kz_term:proplist(), kz_json:object()}. create_extensions(JObj, Context, Results) -> Extensions = kz_json:get_value(<<"extensions">>, JObj, []), create_extensions(Extensions, 1, Context, Results). @@ -151,8 +151,8 @@ create_extensions([Exten|Extens], Iteration, Context, {PassAcc, FailAcc}) -> %% json object. %% @end %%-------------------------------------------------------------------- --spec create_account(kz_json:object(), cb_context:context(), {kz_proplist(), kz_json:object()}) -> - {kz_proplist(), kz_json:object()}. +-spec create_account(kz_json:object(), cb_context:context(), {kz_term:proplist(), kz_json:object()}) -> + {kz_term:proplist(), kz_json:object()}. create_account(JObj, Context, {Pass, Fail}) -> Account = kz_json:get_value(<<"account">>, JObj, kz_json:new()), Generators = [fun(J) -> kz_doc:set_id(J, kz_datamgr:get_uuid()) end @@ -176,8 +176,8 @@ create_account(JObj, Context, {Pass, Fail}) -> %% json object. %% @end %%-------------------------------------------------------------------- --spec create_phone_numbers(kz_json:object(), cb_context:context(), {kz_proplist(), kz_json:object()}) -> - {kz_proplist(), kz_json:object()}. +-spec create_phone_numbers(kz_json:object(), cb_context:context(), {kz_term:proplist(), kz_json:object()}) -> + {kz_term:proplist(), kz_json:object()}. create_phone_numbers(JObj, Context, Results) -> PhoneNumbers = kz_json:get_value(<<"phone_numbers">>, JObj), lists:foldr(fun(Number, R) -> @@ -207,7 +207,7 @@ create_phone_number(Number, Properties, Context, {Pass, Fail}) -> %% json object. %% @end %%-------------------------------------------------------------------- --spec create_braintree_cards(kz_json:object(), cb_context:context(), {kz_proplist(), kz_json:object()}) -> {kz_proplist(), kz_json:object()}. +-spec create_braintree_cards(kz_json:object(), cb_context:context(), {kz_term:proplist(), kz_json:object()}) -> {kz_term:proplist(), kz_json:object()}. create_braintree_cards(JObj, Context, {Pass, Fail}) -> Account = get_context_jobj(<<"accounts">>, Pass), case kz_doc:id(Account) of @@ -245,8 +245,8 @@ create_braintree_cards(JObj, Context, {Pass, Fail}) -> %% json object. %% @end %%-------------------------------------------------------------------- --spec create_user(kz_json:object(), pos_integer(), cb_context:context(), {kz_proplist(), kz_json:object()}) - -> {kz_proplist(), kz_json:object()}. +-spec create_user(kz_json:object(), pos_integer(), cb_context:context(), {kz_term:proplist(), kz_json:object()}) + -> {kz_term:proplist(), kz_json:object()}. create_user(JObj, Iteration, Context, {Pass, Fail}) -> User = kz_json:get_value(<<"user">>, JObj, kz_json:new()), Generators = [fun(J) -> kz_doc:set_id(J, kz_datamgr:get_uuid()) end @@ -297,8 +297,8 @@ create_user(JObj, Iteration, Context, {Pass, Fail}) -> %% json object. %% @end %%-------------------------------------------------------------------- --spec create_device(kz_json:object(), pos_integer(), cb_context:context(), {kz_proplist(), kz_json:object()}) - -> {kz_proplist(), kz_json:object()}. +-spec create_device(kz_json:object(), pos_integer(), cb_context:context(), {kz_term:proplist(), kz_json:object()}) + -> {kz_term:proplist(), kz_json:object()}. create_device(JObj, Iteration, Context, {Pass, Fail}) -> Device = kz_json:get_value(<<"device">>, JObj, kz_json:new()), Generators = [fun(J) -> kz_doc:set_id(J, kz_datamgr:get_uuid()) end @@ -356,8 +356,8 @@ create_device(JObj, Iteration, Context, {Pass, Fail}) -> %% json object. %% @end %%-------------------------------------------------------------------- --spec create_vmbox(kz_json:object(), pos_integer(), cb_context:context(), {kz_proplist(), kz_json:object()}) - -> {kz_proplist(), kz_json:object()}. +-spec create_vmbox(kz_json:object(), pos_integer(), cb_context:context(), {kz_term:proplist(), kz_json:object()}) + -> {kz_term:proplist(), kz_json:object()}. create_vmbox(JObj, Iteration, Context, {Pass, Fail}) -> VMBox = kz_json:get_value(<<"vmbox">>, JObj, kz_json:new()), Generators = [fun(J) -> kz_doc:set_id(J, kz_datamgr:get_uuid()) end @@ -406,8 +406,8 @@ create_vmbox(JObj, Iteration, Context, {Pass, Fail}) -> %% to the error json object. %% @end %%-------------------------------------------------------------------- --spec create_exten_callflow(kz_json:object(), pos_integer(), cb_context:context(), {kz_proplist(), kz_json:object()}) - -> {kz_proplist(), kz_json:object()}. +-spec create_exten_callflow(kz_json:object(), pos_integer(), cb_context:context(), {kz_term:proplist(), kz_json:object()}) + -> {kz_term:proplist(), kz_json:object()}. create_exten_callflow(JObj, Iteration, Context, {Pass, Fail}) -> Callflow = kz_json:get_value(<<"callflow">>, JObj, kz_json:new()), Generators = [fun(J) -> @@ -449,8 +449,8 @@ create_exten_callflow(JObj, Iteration, Context, {Pass, Fail}) -> %% the objects. Starts with the account :) %% @end %%-------------------------------------------------------------------- --spec populate_new_account(kz_proplist(), cb_context:context()) -> cb_context:context(). --spec populate_new_account(kz_proplist(), ne_binary(), kz_json:object()) -> kz_json:object(). +-spec populate_new_account(kz_term:proplist(), cb_context:context()) -> cb_context:context(). +-spec populate_new_account(kz_term:proplist(), kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). populate_new_account(Props, _) -> Context = props:get_value(?KZ_ACCOUNTS_DB, Props), @@ -553,7 +553,7 @@ prepare_props(Props) -> %% context records for a specific key. %% @end %%-------------------------------------------------------------------- --spec get_context_jobj(ne_binary(), kz_proplist()) -> kz_json:object(). +-spec get_context_jobj(kz_term:ne_binary(), kz_term:proplist()) -> kz_json:object(). get_context_jobj(Key, Pass) -> case props:get_value(Key, Pass) of Context when is_tuple(Context) -> cb_context:doc(Context); @@ -611,8 +611,8 @@ notfy_new_account(JObj) -> ], kapps_notify_publisher:cast(Notify, fun kapi_notifications:publish_new_account/1). --spec generate_username(api_binary(), api_binary(), api_binary()) -> - ne_binary(). +-spec generate_username(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary()) -> + kz_term:ne_binary(). generate_username('undefined', 'undefined', _) -> kz_binary:rand_hex(3); generate_username('undefined', _, 'undefined') -> diff --git a/applications/crossbar/src/modules/cb_pivot.erl b/applications/crossbar/src/modules/cb_pivot.erl index 925868b4183..beb60bd2bab 100644 --- a/applications/crossbar/src/modules/cb_pivot.erl +++ b/applications/crossbar/src/modules/cb_pivot.erl @@ -112,7 +112,7 @@ debug_summary(Context) -> %% both documents. %% @end %%-------------------------------------------------------------------- --spec limit_by_page_size(cb_context:context()) -> api_pos_integer(). +-spec limit_by_page_size(cb_context:context()) -> kz_term:api_pos_integer(). limit_by_page_size(Context) -> case cb_context:pagination_page_size(Context) of Size when is_integer(Size), Size > 0 -> @@ -126,7 +126,7 @@ limit_by_page_size(Context) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec debug_read(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec debug_read(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). debug_read(Context, ?MATCH_MODB_PREFIX(Year, Month, CallId)) -> AccountModb = kazoo_modb:get_modb(cb_context:account_id(Context), Year, Month), Context1 = @@ -260,7 +260,7 @@ leak_pvt_node(JObj, Acc) -> set_debug_id(JObj, Acc) -> kz_json:set_value(<<"debug_id">>, debug_id(JObj), Acc). --spec debug_id(kz_json:object()) -> ne_binary(). +-spec debug_id(kz_json:object()) -> kz_term:ne_binary(). debug_id(JObj) -> Created = kz_json:get_first_defined([<<"created">>, <<"pvt_created">>], JObj), CallId = kz_json:get_value(<<"call_id">>, JObj), diff --git a/applications/crossbar/src/modules/cb_port_requests.erl b/applications/crossbar/src/modules/cb_port_requests.erl index f68b2ad8c0c..9e2e528b95c 100644 --- a/applications/crossbar/src/modules/cb_port_requests.erl +++ b/applications/crossbar/src/modules/cb_port_requests.erl @@ -174,7 +174,7 @@ resource_exists(_PortRequestId, ?PORT_ATTACHMENT, _AttachmentId) -> 'true'. %% Of the form {atom, [{Type, SubType}]} :: {to_json, [{<<"application">>, <<"json">>}]} %% @end %%-------------------------------------------------------------------- --spec acceptable_content_types() -> kz_proplist(). +-spec acceptable_content_types() -> kz_term:proplist(). acceptable_content_types() -> ?ATTACHMENT_MIME_TYPES. -spec content_types_provided(cb_context:context(), path_token(), path_token()) -> @@ -192,7 +192,7 @@ content_types_provided(Context, _Id, ?PORT_ATTACHMENT, _AttachmentId) -> _Verb -> Context end. --spec content_types_provided_get(cb_context:context(), ne_binary(), ne_binary()) -> cb_context:context(). +-spec content_types_provided_get(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). content_types_provided_get(Context, Id, AttachmentId) -> Context1 = cb_context:set_account_db(Context, ?KZ_PORT_REQUESTS_DB), cb_context:add_attachment_content_type(Context1, Id, AttachmentId). @@ -350,7 +350,7 @@ patch(Context, Id, NewState=?PORT_REJECTED) -> patch(Context, Id, NewState=?PORT_CANCELED) -> save_then_maybe_notify(Context, Id, NewState). --spec save_then_maybe_notify(cb_context:context(), ne_binary(), ne_binary()) -> cb_context:context(). +-spec save_then_maybe_notify(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). save_then_maybe_notify(Context, PortId, NewState) -> Context1 = save(Context), case success =:= cb_context:resp_status(Context1) of @@ -374,7 +374,7 @@ maybe_set_scheduled_date_from_schedule_on(Doc) -> kz_json:set_value(<<"scheduled_date">>, Scheduled, Doc) end. --spec date_as_configured_timezone(ne_binary(), ne_binary()) -> gregorian_seconds(). +-spec date_as_configured_timezone(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_time:gregorian_seconds(). date_as_configured_timezone(<> ,FromTimezone @@ -435,7 +435,7 @@ delete(Context, Id, ?PORT_ATTACHMENT, AttachmentName) -> %%% Internal functions %%%=================================================================== --spec load_port_request(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec load_port_request(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_port_request(Context, Id) -> Context1 = cb_context:set_account_db(Context, ?KZ_PORT_REQUESTS_DB), crossbar_doc:load(Id, Context1, ?TYPE_CHECK_OPTION(?TYPE_PORT_REQUEST)). @@ -445,7 +445,7 @@ load_port_request(Context, Id) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec validate_load_summary(cb_context:context(), ne_binary()) -> +-spec validate_load_summary(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). validate_load_summary(Context, ?PORT_COMPLETED = Type) -> load_summary_by_type(Context, Type); @@ -462,9 +462,9 @@ validate_load_summary(Context, <<_/binary>> = Type) -> %%-------------------------------------------------------------------- -spec validate_port_request(cb_context:context(), http_method()) -> cb_context:context(). --spec validate_port_request(cb_context:context(), ne_binary(), http_method()) -> +-spec validate_port_request(cb_context:context(), kz_term:ne_binary(), http_method()) -> cb_context:context(). --spec validate_port_request(cb_context:context(), ne_binary(), ne_binary(), http_method()) -> +-spec validate_port_request(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary(), http_method()) -> cb_context:context(). validate_port_request(Context, ?HTTP_GET) -> summary(Context); @@ -491,7 +491,7 @@ validate_port_request(Context, Id, ToState=?PORT_REJECTED, ?HTTP_PATCH) -> validate_port_request(Context, Id, ToState=?PORT_CANCELED, ?HTTP_PATCH) -> patch_then_validate_then_maybe_transition(Context, Id, ToState). --spec patch_then_validate_then_maybe_transition(cb_context:context(), ne_binary(), ne_binary()) -> +-spec patch_then_validate_then_maybe_transition(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). patch_then_validate_then_maybe_transition(Context, PortId, ToState) -> ValidateFun = fun (_PortId, C) -> @@ -507,7 +507,7 @@ patch_then_validate_then_maybe_transition(Context, PortId, ToState) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec validate_attachments(cb_context:context(), ne_binary(), http_method()) -> +-spec validate_attachments(cb_context:context(), kz_term:ne_binary(), http_method()) -> cb_context:context(). validate_attachments(Context, Id, ?HTTP_GET) -> summary_attachments(Context, Id); @@ -519,7 +519,7 @@ validate_attachments(Context, Id, ?HTTP_PUT) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec validate_attachment(cb_context:context(), ne_binary(), ne_binary(), http_method()) -> +-spec validate_attachment(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary(), http_method()) -> cb_context:context(). validate_attachment(Context, Id, AttachmentId, ?HTTP_GET) -> load_attachment(Id, AttachmentId, Context); @@ -534,7 +534,7 @@ validate_attachment(Context, Id, AttachmentId, ?HTTP_DELETE) -> %% @end %%-------------------------------------------------------------------- -spec is_deletable(cb_context:context()) -> cb_context:context(). --spec is_deletable(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec is_deletable(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). is_deletable(Context) -> is_deletable(Context, knm_port_request:current_state(cb_context:doc(Context))). is_deletable(Context, ?PORT_UNCONFIRMED) -> Context; @@ -562,7 +562,7 @@ create(Context) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec read(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec read(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). read(Context, Id) -> Context1 = load_port_request(Context, Id), case cb_context:resp_status(Context1) of @@ -575,7 +575,7 @@ read(Context, Id) -> _ -> Context1 end. --spec authority(ne_binary()) -> api_binary(). +-spec authority(kz_term:ne_binary()) -> kz_term:api_binary(). authority(AccountId) -> case kz_whitelabel:fetch(AccountId) of {'error', _R} -> 'undefined'; @@ -590,7 +590,7 @@ authority(AccountId) -> %% valid %% @end %%-------------------------------------------------------------------- --spec update(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec update(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). update(Context, Id) -> OnSuccess = fun(C) -> on_successful_validation(C, Id) end, cb_context:validate_request_data(?SCHEMA, Context, OnSuccess). @@ -613,7 +613,7 @@ summary(Context) -> %%% Load Summary By Range %%%=================================================================== --spec load_summary_by_type(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec load_summary_by_type(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_summary_by_type(Context, <<"all">>) -> lager:debug("loading summary for all port requests"), Funs = fun(?PORT_SUBMITTED=Type, C) -> load_summary_fold(C, Type, 'false'); @@ -633,7 +633,7 @@ load_summary_by_type(Context, Type) -> load_summary(Context, view_key_options(Context, Type, 'true')) ). --spec load_summary_fold(cb_context:context(), ne_binary(), boolean()) -> cb_context:context(). +-spec load_summary_fold(cb_context:context(), kz_term:ne_binary(), boolean()) -> cb_context:context(). load_summary_fold(Context, Type, IsRanged) -> Summary = cb_context:resp_data(Context), case cb_context:resp_data(load_summary(Context, view_key_options(Context, Type, IsRanged))) of @@ -657,7 +657,7 @@ load_summary(Context, {IsRanged, Opts}) -> 'false' -> crossbar_view:load(Context1, View, Options) end. --spec view_key_options(cb_context:context(), ne_binary(), boolean()) -> {boolean(), crossbar_view:options()}. +-spec view_key_options(cb_context:context(), kz_term:ne_binary(), boolean()) -> {boolean(), crossbar_view:options()}. view_key_options(Context, Type, 'true') -> {'true' ,[{'range_start_keymap', [cb_context:account_id(Context), Type]} @@ -699,7 +699,7 @@ normalize_summary_results(Context) -> ], cb_context:set_resp_data(Context, JObj). --spec get_account_names(ne_binaries()) -> kz_proplist(). +-spec get_account_names(kz_term:ne_binaries()) -> kz_term:proplist(). get_account_names(Keys) -> case kz_datamgr:get_results(?KZ_ACCOUNTS_DB, ?ACCOUNTS_BY_SIMPLE_ID, Keys) of {'ok', JObjs} -> @@ -711,7 +711,7 @@ get_account_names(Keys) -> {'error', _} -> [] end. --spec get_summarize_view_name(cb_context:context()) -> ne_binary(). +-spec get_summarize_view_name(cb_context:context()) -> kz_term:ne_binary(). get_summarize_view_name(Context) -> case props:get_value(<<"accounts">>, cb_context:req_nouns(Context)) of [_AccountId, ?DESCENDANTS] -> ?DESCENDANT_LISTING_BY_STATE; @@ -722,7 +722,7 @@ get_summarize_view_name(Context) -> %%% Load Summary By Number %%%=================================================================== --spec load_summary_by_number(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec load_summary_by_number(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_summary_by_number(Context, Number) -> Options = [{'keys', build_keys(Context, Number)} ,{'mapper', fun normalize_view_results/2} @@ -731,7 +731,7 @@ load_summary_by_number(Context, Number) -> ], crossbar_view:load(Context, ?ALL_PORT_REQ_NUMBERS, Options). --spec build_keys(cb_context:context(), ne_binary()) -> [ne_binaries()]. +-spec build_keys(cb_context:context(), kz_term:ne_binary()) -> [kz_term:ne_binaries()]. build_keys(Context, Number) -> E164 = knm_converters:normalize(Number), case props:get_value(<<"accounts">>, cb_context:req_nouns(Context)) of @@ -846,7 +846,7 @@ leak_pvt_fields(Res, JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec summary_attachments(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec summary_attachments(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). summary_attachments(Context, Id) -> Context1 = load_port_request(Context, Id), As = kz_doc:attachments(cb_context:doc(Context1), kz_json:new()), @@ -858,8 +858,8 @@ summary_attachments(Context, Id) -> %% %% @end %%-------------------------------------------------------------------- --spec on_successful_validation(cb_context:context(), api_binary()) -> cb_context:context(). --spec on_successful_validation(cb_context:context(), api_binary(), boolean()) -> cb_context:context(). +-spec on_successful_validation(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). +-spec on_successful_validation(cb_context:context(), kz_term:api_binary(), boolean()) -> cb_context:context(). on_successful_validation(Context, 'undefined') -> on_successful_validation(Context, 'undefined', 'true'); on_successful_validation(Context, Id) -> @@ -900,7 +900,7 @@ on_successful_validation(Context, _Id, 'false') -> %% @end %%-------------------------------------------------------------------- -spec can_update_port_request(cb_context:context()) -> boolean(). --spec can_update_port_request(cb_context:context(), ne_binary()) -> boolean(). +-spec can_update_port_request(cb_context:context(), kz_term:ne_binary()) -> boolean(). can_update_port_request(Context) -> lager:debug("port request: ~p", [cb_context:doc(Context)]), can_update_port_request(Context, knm_port_request:current_state(cb_context:doc(Context))). @@ -917,7 +917,7 @@ can_update_port_request(Context, _) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec successful_validation(cb_context:context(), api_binary()) -> cb_context:context(). +-spec successful_validation(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). successful_validation(Context, 'undefined') -> PortReq = knm_port_request:new(cb_context:doc(Context) ,cb_context:auth_account_id(Context) @@ -933,9 +933,9 @@ successful_validation(Context, _Id) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec check_number_portability(api_binary(), ne_binary(), cb_context:context()) -> +-spec check_number_portability(kz_term:api_binary(), kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). --spec check_number_portability(api_binary(), ne_binary(), cb_context:context(), ne_binary(), kz_json:object()) -> +-spec check_number_portability(kz_term:api_binary(), kz_term:ne_binary(), cb_context:context(), kz_term:ne_binary(), kz_json:object()) -> cb_context:context(). check_number_portability(PortId, Number, Context) -> E164 = knm_converters:normalize(Number), @@ -977,7 +977,7 @@ check_number_portability(PortId, Number, Context, E164, PortReq) -> number_validation_error(Context, Number, Message) end. --spec number_validation_error(cb_context:context(), ne_binary(), ne_binary()) -> +-spec number_validation_error(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). number_validation_error(Context, Number, Message) -> Msg = kz_json:from_list([{<<"message">>, Message} @@ -990,7 +990,7 @@ number_validation_error(Context, Number, Message) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec check_number_existence(ne_binary(), ne_binary(), cb_context:context()) -> +-spec check_number_existence(kz_term:ne_binary(), kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). check_number_existence(E164, Number, Context) -> case knm_number:lookup_account(E164) of @@ -1016,7 +1016,7 @@ check_number_existence(E164, Number, Context) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec load_attachment(ne_binary(), ne_binary(), cb_context:context()) -> +-spec load_attachment(kz_term:ne_binary(), kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_attachment(Id, AttachmentId, Context) -> Context1 = read(Context, Id), @@ -1030,7 +1030,7 @@ load_attachment(Id, AttachmentId, Context) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec load_attachment(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_attachment(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_attachment(AttachmentId, Context) -> Context1 = crossbar_doc:load_attachment(cb_context:doc(Context) ,AttachmentId @@ -1044,7 +1044,7 @@ load_attachment(AttachmentId, Context) -> cb_context:add_resp_headers(Context1, Headers). %% @private --spec maybe_move_state(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec maybe_move_state(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). maybe_move_state(Context, PortState) -> Metadata = knm_port_request:transition_metadata(cb_context:auth_account_id(Context) ,cb_context:auth_user_id(Context) @@ -1092,7 +1092,7 @@ generate_loa(Context, _RespStatus) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec find_template(ne_binary(), api_ne_binary()) -> ne_binary(). +-spec find_template(kz_term:ne_binary(), kz_term:api_ne_binary()) -> kz_term:ne_binary(). find_template(ResellerId, 'undefined') -> {'ok', Template} = kz_pdf:find_template(ResellerId, <<"loa">>), Template; @@ -1111,7 +1111,7 @@ find_template(ResellerId, CarrierName) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec maybe_send_port_comment_notification(cb_context:context(), ne_binary()) -> 'ok'. +-spec maybe_send_port_comment_notification(cb_context:context(), kz_term:ne_binary()) -> 'ok'. maybe_send_port_comment_notification(Context, Id) -> DbDoc = cb_context:fetch(Context, 'db_doc'), ReqData = cb_context:req_data(Context), @@ -1133,7 +1133,7 @@ maybe_send_port_comment_notification(Context, Id) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec has_new_comment(api_objects(), api_objects()) -> boolean(). +-spec has_new_comment(kz_term:api_objects(), kz_term:api_objects()) -> boolean(). has_new_comment('undefined', [_|_]) -> 'true'; has_new_comment([], [_|_]) -> 'true'; has_new_comment(_, 'undefined') -> 'false'; @@ -1200,7 +1200,7 @@ revert_patch(Context) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec send_port_comment_notification(cb_context:context(), ne_binary(), kz_json:object()) -> 'ok'. +-spec send_port_comment_notification(cb_context:context(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. send_port_comment_notification(Context, Id, NewComment) -> Props = [{<<"user_id">>, cb_context:auth_user_id(Context)} ,{<<"account_id">>, cb_context:auth_account_id(Context)} @@ -1222,7 +1222,7 @@ send_port_comment_notification(Context, Id, NewComment) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec send_port_unconfirmed_notification(cb_context:context(), ne_binary()) -> 'ok'. +-spec send_port_unconfirmed_notification(cb_context:context(), kz_term:ne_binary()) -> 'ok'. send_port_unconfirmed_notification(Context, Id) -> Req = [{<<"Account-ID">>, cb_context:account_id(Context)} ,{<<"Authorized-By">>, cb_context:auth_account_id(Context)} @@ -1236,7 +1236,7 @@ send_port_unconfirmed_notification(Context, Id) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec send_port_request_notification(cb_context:context(), ne_binary()) -> 'ok'. +-spec send_port_request_notification(cb_context:context(), kz_term:ne_binary()) -> 'ok'. send_port_request_notification(Context, Id) -> Req = [{<<"Account-ID">>, cb_context:account_id(Context)} ,{<<"Authorized-By">>, cb_context:auth_account_id(Context)} @@ -1251,7 +1251,7 @@ send_port_request_notification(Context, Id) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec send_port_pending_notification(cb_context:context(), ne_binary()) -> 'ok'. +-spec send_port_pending_notification(cb_context:context(), kz_term:ne_binary()) -> 'ok'. send_port_pending_notification(Context, Id) -> Req = [{<<"Account-ID">>, cb_context:account_id(Context)} ,{<<"Authorized-By">>, cb_context:auth_account_id(Context)} @@ -1265,7 +1265,7 @@ send_port_pending_notification(Context, Id) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec send_port_rejected_notification(cb_context:context(), ne_binary()) -> 'ok'. +-spec send_port_rejected_notification(cb_context:context(), kz_term:ne_binary()) -> 'ok'. send_port_rejected_notification(Context, Id) -> Req = [{<<"Account-ID">>, cb_context:account_id(Context)} ,{<<"Authorized-By">>, cb_context:auth_account_id(Context)} @@ -1279,7 +1279,7 @@ send_port_rejected_notification(Context, Id) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec send_port_cancel_notification(cb_context:context(), ne_binary()) -> 'ok'. +-spec send_port_cancel_notification(cb_context:context(), kz_term:ne_binary()) -> 'ok'. send_port_cancel_notification(Context, Id) -> Req = [{<<"Account-ID">>, cb_context:account_id(Context)} ,{<<"Authorized-By">>, cb_context:auth_account_id(Context)} @@ -1293,7 +1293,7 @@ send_port_cancel_notification(Context, Id) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec send_ported_notification(cb_context:context(), ne_binary()) -> 'ok'. +-spec send_ported_notification(cb_context:context(), kz_term:ne_binary()) -> 'ok'. send_ported_notification(Context, Id) -> Req = [{<<"Account-ID">>, cb_context:account_id(Context)} ,{<<"Authorized-By">>, cb_context:auth_account_id(Context)} @@ -1307,7 +1307,7 @@ send_ported_notification(Context, Id) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec send_port_scheduled_notification(cb_context:context(), ne_binary()) -> 'ok'. +-spec send_port_scheduled_notification(cb_context:context(), kz_term:ne_binary()) -> 'ok'. send_port_scheduled_notification(Context, Id) -> Req = [{<<"Account-ID">>, cb_context:account_id(Context)} ,{<<"Authorized-By">>, cb_context:auth_account_id(Context)} @@ -1316,7 +1316,7 @@ send_port_scheduled_notification(Context, Id) -> ], kapps_notify_publisher:cast(Req, fun kapi_notifications:publish_port_scheduled/1). --spec common_patch_notification_props(cb_context:context(), api_ne_binary()) -> kz_proplist(). +-spec common_patch_notification_props(cb_context:context(), kz_term:api_ne_binary()) -> kz_term:proplist(). common_patch_notification_props(Context, ?NE_BINARY=Reason) -> Props = [{<<"user_id">>, cb_context:auth_user_id(Context)} ,{<<"account_id">>, cb_context:auth_account_id(Context)} @@ -1360,7 +1360,7 @@ generate_loa_from_port(Context, PortRequest) -> cb_context:set_resp_status(cb_context:set_resp_data(Context, PDF), 'success') end. --spec create_QR_code(api_binary(), api_binary()) -> kz_proplist() | 'undefined'. +-spec create_QR_code(kz_term:api_binary(), kz_term:api_binary()) -> kz_term:proplist() | 'undefined'. create_QR_code('undefined', _) -> 'undefined'; create_QR_code(_, 'undefined') -> 'undefined'; create_QR_code(AccountId, PortRequestId) -> diff --git a/applications/crossbar/src/modules/cb_presence.erl b/applications/crossbar/src/modules/cb_presence.erl index 88eef29f55e..f07854c8480 100644 --- a/applications/crossbar/src/modules/cb_presence.erl +++ b/applications/crossbar/src/modules/cb_presence.erl @@ -129,7 +129,7 @@ content_types_provided(Context, ?MATCH_REPORT_PREFIX(Report)) -> content_types_provided_for_report(Context, Report); content_types_provided(Context, _) -> Context. --spec content_types_provided_for_report(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec content_types_provided_for_report(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). content_types_provided_for_report(Context, Report) -> File = <<"/tmp/", Report/binary, ".json">>, case filelib:is_file(File) of @@ -169,7 +169,7 @@ validate_thing(Context, ?HTTP_POST) -> search_summary(Context) -> search_result(Context, search_req(Context, <<"summary">>)). --spec search_detail(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec search_detail(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). search_detail(Context, Extension) -> search_result(Context, search_req(Context, <<"detail">>, Extension)). @@ -182,11 +182,11 @@ search_result(Context, {'ok', JObj}) -> search_result(Context, {'error', Error}) -> cb_context:add_system_error(Error, Context). --spec search_req(cb_context:context(), ne_binary()) -> search_result(). +-spec search_req(cb_context:context(), kz_term:ne_binary()) -> search_result(). search_req(Context, SearchType) -> search_req(Context, SearchType, 'undefined'). --spec search_req(cb_context:context(), ne_binary(), api_binary()) -> search_result(). +-spec search_req(cb_context:context(), kz_term:ne_binary(), kz_term:api_binary()) -> search_result(). search_req(Context, SearchType, Username) -> Req = [{<<"Realm">>, cb_context:account_realm(Context)} ,{<<"Username">>, Username} @@ -218,17 +218,17 @@ collect_results([Response | _], {Count, Max}) -> V -> {'false', {V, Max}} end. --spec search_resp_value(ne_binary()) -> 0..1. +-spec search_resp_value(kz_term:ne_binary()) -> 0..1. search_resp_value(<<"search_resp">>) -> 1; search_resp_value(_) -> 0. -type acc_function() :: fun((kz_json:object(), kz_json:object()) -> kz_json:object()). --spec accumulator_fun(ne_binary()) -> acc_function(). +-spec accumulator_fun(kz_term:ne_binary()) -> acc_function(). accumulator_fun(<<"summary">>) -> fun kz_json:sum/2; accumulator_fun(<<"detail">>) -> fun kz_json:merge/2. --spec process_responses(kz_json:objects(), ne_binary(), atom()) -> {'ok', kz_json:object()}. +-spec process_responses(kz_json:objects(), kz_term:ne_binary(), atom()) -> {'ok', kz_json:object()}. process_responses(JObjs, SearchType, Timeout) -> Fun = accumulator_fun(SearchType), Subscriptions = extract_subscriptions(JObjs, Fun), @@ -256,12 +256,12 @@ validate_presence_thing(Context, [{<<"presence">>, _} validate_presence_thing(Context, _ReqNouns) -> crossbar_util:response_faulty_request(Context). --spec load_device(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec load_device(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_device(Context, ThingId) -> %% validating device crossbar_doc:load(ThingId, Context, ?TYPE_CHECK_OPTION(kz_device:type())). --spec load_presence_for_user(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec load_presence_for_user(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_presence_for_user(Context, UserId) -> %% load the user_doc if it has a presence_id set, otherwise load all the user's devices Context1 = crossbar_doc:load(UserId, Context, ?TYPE_CHECK_OPTION(kzd_user:type())), @@ -337,13 +337,13 @@ post(Context) -> Things = cb_context:doc(Context), post_things(Context, Things, kz_json:get_value(<<"action">>, ReqData)). --spec post(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec post(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). post(Context, Extension) -> _ = collect_report(Context, Extension), publish_presence_reset(Context, Extension), crossbar_util:response_202(<<"reset command sent for extension ", Extension/binary>>, Context). --spec post_things(cb_context:context(), kz_json:object() | kz_json:objects(), ne_binary()) -> +-spec post_things(cb_context:context(), kz_json:object() | kz_json:objects(), kz_term:ne_binary()) -> cb_context:context(). post_things(Context, Things, <<"reset">>) -> _ = collect_report(Context, Things), @@ -352,7 +352,7 @@ post_things(Context, Things, <<"set">>) -> State = kz_json:get_value(<<"state">>, cb_context:req_data(Context)), send_command(Context, fun(C, Id) -> publish_presence_update(C, Id, State) end, Things). --type presence_command_fun() :: fun((cb_context:context(), api_binary()) -> any()). +-type presence_command_fun() :: fun((cb_context:context(), kz_term:api_binary()) -> any()). -spec send_command(cb_context:context(), presence_command_fun(), kz_json:object() | kz_json:objects()) -> cb_context:context(). send_command(Context, _CommandFun, []) -> @@ -364,7 +364,7 @@ send_command(Context, CommandFun, [_|_]=Things) -> send_command(Context, CommandFun, Thing) -> send_command(Context, CommandFun, [Thing]). --spec publish_presence_reset(cb_context:context(), api_binary()) -> 'ok'. +-spec publish_presence_reset(cb_context:context(), kz_term:api_binary()) -> 'ok'. publish_presence_reset(_Context, 'undefined') -> 'ok'; publish_presence_reset(Context, PresenceId) -> Realm = cb_context:account_realm(Context), @@ -376,7 +376,7 @@ publish_presence_reset(Context, PresenceId) -> ], kz_amqp_worker:cast(API, fun kapi_presence:publish_reset/1). --spec publish_presence_update(cb_context:context(), api_binary(), ne_binary()) -> 'ok'. +-spec publish_presence_update(cb_context:context(), kz_term:api_binary(), kz_term:ne_binary()) -> 'ok'. publish_presence_update(_Context, 'undefined', _PresenceState) -> 'ok'; publish_presence_update(Context, PresenceId, PresenceState) -> Realm = cb_context:account_realm(Context), @@ -387,7 +387,7 @@ publish_presence_update(Context, PresenceId, PresenceState) -> PresenceString = <>, kapps_call_command:presence(PresenceState, PresenceString, kz_term:to_hex_binary(crypto:hash(md5, PresenceString))). --spec find_presence_id(kz_json:object()) -> api_binary(). +-spec find_presence_id(kz_json:object()) -> kz_term:api_binary(). find_presence_id(JObj) -> case kz_device:is_device(JObj) of 'true' -> kz_device:presence_id(JObj); @@ -404,7 +404,7 @@ load_report(Context, Report) -> cb_context:add_system_error('bad_identifier', kz_json:from_list([{<<"cause">>, Report}]), Context) end. --spec set_report(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec set_report(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). set_report(Context, File) -> Name = kz_term:to_binary(filename:basename(File)), Headers = [{<<"Content-Disposition">>, <<"attachment; filename=", Name/binary>>}], @@ -416,14 +416,14 @@ set_report(Context, File) -> ] ). --spec collect_report(cb_context:context(), ne_binary() | kz_json:object() | kz_json:objects()) -> any(). +-spec collect_report(cb_context:context(), kz_term:ne_binary() | kz_json:object() | kz_json:objects()) -> any(). collect_report(_Context, []) -> lager:debug("nothing to collect"); collect_report(Context, Param) -> lager:debug("collecting report for ~s", [Param]), kz_util:spawn(fun send_report/2, [search_detail(Context, Param), Param]). --spec send_report(cb_context:context(), ne_binary() | kz_json:object() | kz_json:objects()) -> 'ok'. +-spec send_report(cb_context:context(), kz_term:ne_binary() | kz_json:object() | kz_json:objects()) -> 'ok'. send_report(Context, Extension) when is_binary(Extension) -> Msg = <<"presence reset received for extension ", Extension/binary>>, @@ -453,7 +453,7 @@ format_and_send_report(Context, Msg) -> ], kz_notify:detailed_alert(Subject, Msg, Props, Headers). --spec save_report(cb_context:context()) -> {ne_binary(), ne_binary()}. +-spec save_report(cb_context:context()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. save_report(Context) -> JObj = kz_json:encode(cb_context:resp_data(Context)), Report = kz_binary:rand_hex(16), diff --git a/applications/crossbar/src/modules/cb_profile.erl b/applications/crossbar/src/modules/cb_profile.erl index 35b089f3009..d7d48bc46a1 100644 --- a/applications/crossbar/src/modules/cb_profile.erl +++ b/applications/crossbar/src/modules/cb_profile.erl @@ -41,7 +41,7 @@ init() -> -spec req_init({cb_context:context(), cowboy_req:req()}) -> {cb_context:context(), cowboy_req:req()}. --spec req_init(api_binary(), {cb_context:context(), cowboy_req:req()}) -> +-spec req_init(kz_term:api_binary(), {cb_context:context(), cowboy_req:req()}) -> {cb_context:context(), cowboy_req:req()}. req_init({Context, _} = InitArgs) -> req_init(cb_context:profile_id(Context), InitArgs). @@ -63,7 +63,7 @@ req_init(ProfileId, InitArgs) -> end, InitArgs. --spec req_finish(cb_context:context() | api_binary()) -> any(). +-spec req_finish(cb_context:context() | kz_term:api_binary()) -> any(). req_finish('undefined') -> 'ok'; req_finish(ProfileId) when is_binary(ProfileId) -> File = list_to_binary([?TRACE_PATH, ProfileId, ".trace"]), diff --git a/applications/crossbar/src/modules/cb_quickcall.erl b/applications/crossbar/src/modules/cb_quickcall.erl index 59dc91e60b1..9847c4a22ab 100644 --- a/applications/crossbar/src/modules/cb_quickcall.erl +++ b/applications/crossbar/src/modules/cb_quickcall.erl @@ -62,7 +62,7 @@ maybe_originate(Context, ?HTTP_GET) -> maybe_originate(Context, ?HTTP_POST) -> Context. --spec load_endpoint(cb_context:context(), path_token(), ne_binary()) -> cb_context:context(). +-spec load_endpoint(cb_context:context(), path_token(), kz_term:ne_binary()) -> cb_context:context(). load_endpoint(Context, EndpointId, EndpointType) -> crossbar_doc:load(EndpointId, Context, ?TYPE_CHECK_OPTION(EndpointType)). diff --git a/applications/crossbar/src/modules/cb_rate_limits.erl b/applications/crossbar/src/modules/cb_rate_limits.erl index 8af77ff1aa4..14c24ec64de 100644 --- a/applications/crossbar/src/modules/cb_rate_limits.erl +++ b/applications/crossbar/src/modules/cb_rate_limits.erl @@ -66,8 +66,8 @@ authorize(Context) -> orelse kz_services:is_reseller(AuthAccountId) end. --type thing_type() :: ne_binary(). --type thing_id() :: ne_binary(). +-type thing_type() :: kz_term:ne_binary(). +-type thing_id() :: kz_term:ne_binary(). -type thing_description() :: {thing_type(), thing_id()}. -spec thing_type_id(cb_context:context()) -> thing_description() | 'undefined'. thing_type_id(Context) -> @@ -136,7 +136,7 @@ validate_post_rate_limits(Context) -> crossbar_util:response_faulty_request(Context) end. --spec get_rate_limits_id_for_thing(cb_context:context(), ne_binary()) -> api_binaries(). +-spec get_rate_limits_id_for_thing(cb_context:context(), kz_term:ne_binary()) -> kz_term:api_binaries(). get_rate_limits_id_for_thing(Context, ThingId) -> ViewOpt = [{'key', ThingId}], case kz_datamgr:get_results(cb_context:account_db(Context), ?LISTING_BY_OWNER, ViewOpt) of @@ -147,11 +147,11 @@ get_rate_limits_id_for_thing(Context, ThingId) -> 'undefined' end. --spec get_id(kz_json:object()) -> api_binary(). +-spec get_id(kz_json:object()) -> kz_term:api_binary(). get_id(JObj) -> kz_doc:id(JObj). --spec validate_get_rate_limits(cb_context:context(), api_binary()) -> cb_context:context(). +-spec validate_get_rate_limits(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). validate_get_rate_limits(Context, 'undefined') -> crossbar_util:response_faulty_request(Context); validate_get_rate_limits(Context, ThingId) -> @@ -166,7 +166,7 @@ validate_get_rate_limits(Context, ThingId) -> crossbar_util:response('fatal', <<"data collection error">>, 503, Context) end. --spec validate_delete_rate_limits(cb_context:context(), api_binary()) -> cb_context:context(). +-spec validate_delete_rate_limits(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). validate_delete_rate_limits(Context, 'undefined') -> crossbar_util:response_faulty_request(Context); validate_delete_rate_limits(Context, ThingId) -> @@ -183,7 +183,7 @@ validate_delete_rate_limits(Context, ThingId) -> -spec validate_set_rate_limits(cb_context:context()) -> cb_context:context(). --spec validate_set_rate_limits(cb_context:context(), api_binary()) -> +-spec validate_set_rate_limits(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). validate_set_rate_limits(Context) -> lager:debug("rate limits data is valid, setting on thing"), @@ -217,7 +217,7 @@ set_pvt_fields(Context) -> ], cb_context:set_doc(Context, kz_json:set_values(Props, cb_context:doc(Context))). --spec query_name(ne_binary(), kz_json:object()) -> api_binary(). +-spec query_name(kz_term:ne_binary(), kz_json:object()) -> kz_term:api_binary(). query_name(<<"account">>, JObj) -> kz_account:realm(JObj); query_name(<<"device">>, JObj) -> diff --git a/applications/crossbar/src/modules/cb_rates.erl b/applications/crossbar/src/modules/cb_rates.erl index 84131f5fc3e..264bb620faf 100644 --- a/applications/crossbar/src/modules/cb_rates.erl +++ b/applications/crossbar/src/modules/cb_rates.erl @@ -170,7 +170,7 @@ validate_rate(Context, Id, ?HTTP_PATCH) -> validate_rate(Context, Id, ?HTTP_DELETE) -> read(Id, cb_context:set_account_db(Context, ratedeck_db(Context))). --spec ratedeck_db(cb_context:context()) -> ne_binary(). +-spec ratedeck_db(cb_context:context()) -> kz_term:ne_binary(). ratedeck_db(Context) -> RatedeckId = cb_context:req_value(Context, <<"ratedeck_id">>, ?KZ_RATES_DB), kzd_ratedeck:format_ratedeck_db(RatedeckId). @@ -196,7 +196,7 @@ put(Context) -> delete(Context, _RateId) -> crossbar_doc:delete(Context). --spec validate_number(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_number(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). validate_number(Phonenumber, Context) -> case knm_converters:is_reconcilable(Phonenumber) of 'true' -> @@ -229,7 +229,7 @@ create(Context) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec read(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec read(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). read(Id, Context) -> crossbar_doc:load(Id, Context, ?TYPE_CHECK_OPTION(<<"rate">>)). @@ -240,7 +240,7 @@ read(Id, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec update(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec update(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). update(Id, Context) -> OnSuccess = fun(C) -> on_successful_validation(Id, C) end, cb_context:validate_request_data(<<"rates">>, Context, OnSuccess). @@ -252,7 +252,7 @@ update(Id, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec validate_patch(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_patch(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). validate_patch(Id, Context) -> crossbar_doc:patch_and_validate(Id, Context, fun update/2). @@ -262,7 +262,7 @@ validate_patch(Id, Context) -> %% %% @end %%-------------------------------------------------------------------- --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> Doc = lists:foldl(fun doc_updates/2 ,cb_context:doc(Context) @@ -274,7 +274,7 @@ on_successful_validation('undefined', Context) -> on_successful_validation(Id, Context) -> crossbar_doc:load_merge(Id, Context, ?TYPE_CHECK_OPTION(<<"rate">>)). --spec doc_updates({fun(), ne_binary()} | fun(), kz_json:object()) -> +-spec doc_updates({fun(), kz_term:ne_binary()} | fun(), kz_json:object()) -> kz_json:object(). doc_updates({Fun, Value}, Doc) when is_function(Fun, 2) -> Fun(Doc, Value); @@ -282,7 +282,7 @@ doc_updates(Fun, Doc) when is_function(Fun, 1) -> Fun(Doc). -spec ensure_routes_set(kz_json:object()) -> kz_json:object(). --spec ensure_routes_set(kz_json:object(), api_binaries()) -> kz_json:object(). +-spec ensure_routes_set(kz_json:object(), kz_term:api_binaries()) -> kz_json:object(). ensure_routes_set(Doc) -> ensure_routes_set(Doc, kz_json:get_value(<<"routes">>, Doc)). @@ -293,7 +293,7 @@ ensure_routes_set(Doc, []) -> ensure_routes_set(Doc, _) -> Doc. --spec add_default_route(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec add_default_route(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). add_default_route(Doc, Prefix) -> kz_json:set_value(<<"routes">>, [<<"^\\+?", Prefix/binary, ".+$">>], Doc). @@ -377,7 +377,7 @@ process_upload_file(Context, [{_Name, File}|_]) -> process_upload_file(Context, _ReqFiles) -> error_no_file(Context). --spec convert_file(ne_binary(), ne_binary(), cb_context:context()) -> +-spec convert_file(kz_term:ne_binary(), kz_term:ne_binary(), cb_context:context()) -> {'ok', {non_neg_integer(), kz_json:objects()}}. convert_file(<<"text/csv">>, FileContents, Context) -> csv_to_rates(FileContents, Context); @@ -390,7 +390,7 @@ convert_file(ContentType, _, _) -> lager:debug("unknown content type: ~s", [ContentType]), throw({'unknown_content_type', ContentType}). --spec csv_to_rates(ne_binary(), cb_context:context()) -> +-spec csv_to_rates(kz_term:ne_binary(), cb_context:context()) -> {'ok', {integer(), kz_json:objects()}}. csv_to_rates(CSV, Context) -> BulkInsert = kz_datamgr:max_bulk_insert(), @@ -461,7 +461,7 @@ process_row(Row, {Count, JObjs}=Acc) -> {Count + 1, [kz_json:set_values(Setters, kz_json:new()) | JObjs]} end. --spec get_row_prefix(rate_row()) -> api_binary(). +-spec get_row_prefix(rate_row()) -> kz_term:api_binary(). get_row_prefix([Prefix | _]=_R) -> try kz_term:to_integer(Prefix) catch @@ -473,27 +473,27 @@ get_row_prefix(_R) -> lager:info("prefix not found on row: ~p", [_R]), 'undefined'. --spec get_row_iso(rate_row()) -> ne_binary(). +-spec get_row_iso(rate_row()) -> kz_term:ne_binary(). get_row_iso([_, ISO | _]) -> strip_quotes(kz_term:to_binary(ISO)); get_row_iso(_R) -> lager:info("iso not found on row: ~p", [_R]), <<"XX">>. --spec get_row_description(rate_row()) -> api_binary(). +-spec get_row_description(rate_row()) -> kz_term:api_binary(). get_row_description([_, _, Description | _]) -> strip_quotes(kz_term:to_binary(Description)); get_row_description(_R) -> lager:info("description not found on row: ~p", [_R]), 'undefined'. --spec get_row_internal_surcharge(rate_row()) -> api_float(). +-spec get_row_internal_surcharge(rate_row()) -> kz_term:api_float(). get_row_internal_surcharge([_, _, _, InternalSurcharge, _, _ | _]) -> kz_term:to_float(InternalSurcharge); get_row_internal_surcharge(_R) -> lager:info("internal surcharge not found on row: ~p", [_R]), 'undefined'. --spec get_row_surcharge(rate_row()) -> api_float(). +-spec get_row_surcharge(rate_row()) -> kz_term:api_float(). get_row_surcharge([_, _, _, Surcharge, _, _]) -> kz_term:to_float(Surcharge); get_row_surcharge([_, _, _, _, Surcharge, _ | _]) -> @@ -502,7 +502,7 @@ get_row_surcharge([_|_]=_R) -> lager:info("surcharge not found on row: ~p", [_R]), 'undefined'. --spec get_row_internal_rate(rate_row()) -> api_float(). +-spec get_row_internal_rate(rate_row()) -> kz_term:api_float(). get_row_internal_rate([_, _, _, Rate]) -> kz_term:to_float(Rate); get_row_internal_rate([_, _, _, InternalRate, _]) -> @@ -515,7 +515,7 @@ get_row_internal_rate([_|_]=_R) -> lager:info("internal rate not found on row: ~p", [_R]), 'undefined'. --spec get_row_rate(rate_row()) -> api_float(). +-spec get_row_rate(rate_row()) -> kz_term:api_float(). get_row_rate([_, _, _, Rate]) -> kz_term:to_float(Rate); get_row_rate([_, _, _, _, Rate]) -> kz_term:to_float(Rate); get_row_rate([_, _, _, _, _, Rate]) -> kz_term:to_float(Rate); @@ -550,7 +550,7 @@ get_row_direction([_, _, _, _, _, _, _, _, _, _, Direction | _]) -> get_row_direction([_|_]) -> 'undefined'. --spec strip_quotes(ne_binary()) -> ne_binary(). +-spec strip_quotes(kz_term:ne_binary()) -> kz_term:ne_binary(). strip_quotes(Bin) -> binary:replace(Bin, [<<"\"">>, <<"\'">>], <<>>, ['global']). @@ -564,7 +564,7 @@ save_processed_rates(Context, Count) -> lager:debug("saved up to ~b docs (took ~b ms)", [Count, kz_time:elapsed_ms(Now)]) end). --spec rate_for_number(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec rate_for_number(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). rate_for_number(Phonenumber, Context) -> Request = props:filter_undefined( [{<<"To-DID">>, Phonenumber} @@ -589,7 +589,7 @@ rate_for_number(Phonenumber, Context) -> cb_context:add_system_error(<<"No rate found for this number">>, Context) end. --spec maybe_handle_rate(ne_binary(), cb_context:context(), kz_json:object()) -> +-spec maybe_handle_rate(kz_term:ne_binary(), cb_context:context(), kz_json:object()) -> cb_context:context(). maybe_handle_rate(Phonenumber, Context, Rate) -> case kz_json:get_value(<<"Base-Cost">>, Rate) of diff --git a/applications/crossbar/src/modules/cb_recordings.erl b/applications/crossbar/src/modules/cb_recordings.erl index 842e978e243..98143d680de 100644 --- a/applications/crossbar/src/modules/cb_recordings.erl +++ b/applications/crossbar/src/modules/cb_recordings.erl @@ -148,26 +148,26 @@ recording_summary(Context) -> ], crossbar_view:load_modb(Context, ViewName, Options). --spec build_end_key(gregorian_seconds(), api_ne_binary()) -> kazoo_data:range_key(). +-spec build_end_key(kz_time:gregorian_seconds(), kz_term:api_ne_binary()) -> kazoo_data:range_key(). build_end_key(Timestamp, 'undefined') -> [Timestamp, kz_json:new()]; build_end_key(Timestamp, UserId) -> [UserId, Timestamp, kz_json:new()]. --spec get_view_name(api_ne_binary()) -> ne_binary(). +-spec get_view_name(kz_term:api_ne_binary()) -> kz_term:ne_binary(). get_view_name('undefined') -> ?CB_LIST; get_view_name(_) -> ?CB_LIST_BY_OWNERID. --spec load_recording_doc(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec load_recording_doc(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_recording_doc(Context, ?MATCH_MODB_PREFIX(Year, Month, _) = RecordingId) -> Ctx = cb_context:set_account_modb(Context, kz_term:to_integer(Year), kz_term:to_integer(Month)), crossbar_doc:load({<<"call_recording">>, RecordingId}, Ctx, ?TYPE_CHECK_OPTION(<<"call_recording">>)); load_recording_doc(Context, Id) -> crossbar_util:response_bad_identifier(Id, Context). --spec load_recording_binary(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec load_recording_binary(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_recording_binary(Context, ?MATCH_MODB_PREFIX(Year, Month, _) = DocId) -> do_load_recording_binary(cb_context:set_account_modb(Context, kz_term:to_integer(Year), kz_term:to_integer(Month)), DocId). --spec do_load_recording_binary(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec do_load_recording_binary(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). do_load_recording_binary(Context, DocId) -> Context1 = crossbar_doc:load({<<"call_recording">>, DocId}, Context, ?TYPE_CHECK_OPTION(<<"call_recording">>)), case cb_context:resp_status(Context1) of @@ -176,7 +176,7 @@ do_load_recording_binary(Context, DocId) -> _Status -> Context1 end. --spec do_load_recording_binary_attachment(cb_context:context(), ne_binary()) -> +-spec do_load_recording_binary_attachment(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). do_load_recording_binary_attachment(Context, DocId) -> case kz_doc:attachment_names(cb_context:doc(Context)) of @@ -201,12 +201,12 @@ do_load_recording_binary_attachment(Context, DocId) -> %% @end %%-------------------------------------------------------------------- --spec set_resp_headers(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec set_resp_headers(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). set_resp_headers(Context, AName) -> Headers = #{<<"content-disposition">> => get_disposition(AName, Context)}, cb_context:add_resp_headers(Context, Headers). --spec get_disposition(ne_binary(), cb_context:context()) -> ne_binary(). +-spec get_disposition(kz_term:ne_binary(), cb_context:context()) -> kz_term:ne_binary(). get_disposition(MediaName, Context) -> case kz_json:is_true(<<"inline">>, cb_context:query_string(Context), 'false') of 'false' -> <<"attachment; filename=", MediaName/binary>>; @@ -214,7 +214,7 @@ get_disposition(MediaName, Context) -> end. -spec action_lookup(cb_context:context()) -> atom(). --spec action_lookup(kz_proplist(), media_values()) -> atom(). +-spec action_lookup(kz_term:proplist(), media_values()) -> atom(). action_lookup(Context) -> Acceptable = acceptable_content_types(Context), action_lookup(Acceptable, accept_values(Context)). @@ -245,7 +245,7 @@ accept_values(Context) -> Tunneled = cb_context:req_value(Context, <<"accept">>), media_values(AcceptValue, Tunneled). --spec media_values(api_binary(), api_binary()) -> media_values(). +-spec media_values(kz_term:api_binary(), kz_term:api_binary()) -> media_values(). media_values('undefined', 'undefined') -> lager:debug("no accept headers, assuming JSON"), [?MEDIA_VALUE(<<"application">>, <<"json">>)]; @@ -262,10 +262,10 @@ media_values(AcceptValue, Tunneled) -> lists:reverse(lists:keysort(2, TunneledValues)) end. --spec acceptable_content_types(cb_context:context()) -> kz_proplist(). +-spec acceptable_content_types(cb_context:context()) -> kz_term:proplist(). acceptable_content_types(Context) -> props:get_value('to_binary', cb_context:content_types_provided(Context), []). --spec is_acceptable_accept(kz_proplist(), ne_binary(), ne_binary()) -> boolean(). +-spec is_acceptable_accept(kz_term:proplist(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_acceptable_accept(Acceptable, Type, SubType) -> lists:member({Type,SubType}, Acceptable). diff --git a/applications/crossbar/src/modules/cb_registrations.erl b/applications/crossbar/src/modules/cb_registrations.erl index 49f5cfb3a69..1ac0eb5278d 100644 --- a/applications/crossbar/src/modules/cb_registrations.erl +++ b/applications/crossbar/src/modules/cb_registrations.erl @@ -132,7 +132,7 @@ validate_count(Context) -> ,Context ). --spec validate_sip_username(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec validate_sip_username(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). validate_sip_username(Context, Username) -> case sip_username_exists(Context, Username) of 'true' -> @@ -141,7 +141,7 @@ validate_sip_username(Context, Username) -> crossbar_util:response_bad_identifier(Username, Context) end. --spec sip_username_exists(cb_context:context(), ne_binary()) -> boolean(). +-spec sip_username_exists(cb_context:context(), kz_term:ne_binary()) -> boolean(). sip_username_exists(Context, Username) -> ViewOptions = [{'key', kz_term:to_lower_binary(Username)}], case kz_datamgr:get_results(cb_context:account_db(Context) @@ -201,7 +201,7 @@ merge_response(JObj, Regs) -> end end, Regs, kz_json:get_value(<<"Fields">>, JObj, [])). --spec maybe_default_port(integer(), nklib:scheme(), api_binary()) -> integer(). +-spec maybe_default_port(integer(), nklib:scheme(), kz_term:api_binary()) -> integer(). maybe_default_port(0, 'sips', _) -> 5061; maybe_default_port(0, 'sip', <<"TLS">>) -> 5061; maybe_default_port(0, 'sip', <<"tls">>) -> 5061; @@ -240,7 +240,7 @@ count_registrations(Context) -> {'timeout', _} -> lager:debug("timed out query for counting regs"), 0 end. --spec get_realm(cb_context:context()) -> ne_binary(). +-spec get_realm(cb_context:context()) -> kz_term:ne_binary(). get_realm(Context) -> case cb_context:account_id(Context) of 'undefined' -> <<"all">>; diff --git a/applications/crossbar/src/modules/cb_resource_selectors.erl b/applications/crossbar/src/modules/cb_resource_selectors.erl index 2925c11da4b..8617b406d10 100644 --- a/applications/crossbar/src/modules/cb_resource_selectors.erl +++ b/applications/crossbar/src/modules/cb_resource_selectors.erl @@ -242,7 +242,7 @@ delete(Context, _UUID) -> load_rules(Context) -> crossbar_doc:load(?RULES_PVT_TYPE, Context, ?TYPE_CHECK_OPTION(?RULES_PVT_TYPE)). --spec summary(cb_context:context(), api_binaries(), api_binary(), boolean()) -> cb_context:context(). +-spec summary(cb_context:context(), kz_term:api_binaries(), kz_term:api_binary(), boolean()) -> cb_context:context(). summary(Context, Prefix, ViewName, Reduce) -> case kz_term:is_true(Reduce) of 'true' -> @@ -261,25 +261,25 @@ summary(Context, Prefix, ViewName, Reduce) -> RespEnvelope = fix_envelope_start_keys(cb_context:resp_envelope(Context1), Prefix), cb_context:set_resp_envelope(Context1, RespEnvelope). --spec build_start_key(cb_context:context(), api_binaries()) -> api_binaries(). +-spec build_start_key(cb_context:context(), kz_term:api_binaries()) -> kz_term:api_binaries(). build_start_key(Context, PrefixKeys) -> case cb_context:req_value(Context, <<"start_key">>) of 'undefined' -> PrefixKeys; StartKey -> build_key(PrefixKeys, StartKey) end. --spec build_end_key(cb_context:context(), api_binaries()) -> api_binaries(). +-spec build_end_key(cb_context:context(), kz_term:api_binaries()) -> kz_term:api_binaries(). build_end_key(Context, PrefixKeys) -> case cb_context:req_value(Context, <<"end_key">>) of 'undefined' -> build_key(PrefixKeys, <<16#fff0/utf8>>); EndKey -> build_key(PrefixKeys, EndKey) end. --spec build_key(api_binaries(), api_binary()) -> api_binaries(). +-spec build_key(kz_term:api_binaries(), kz_term:api_binary()) -> kz_term:api_binaries(). build_key(PrefixKeys, Suffix) -> lists:reverse([Suffix | lists:reverse(PrefixKeys)]). --spec fix_envelope_start_keys(kz_json:object(), api_binaries()) -> kz_json:object(). +-spec fix_envelope_start_keys(kz_json:object(), kz_term:api_binaries()) -> kz_json:object(). fix_envelope_start_keys(JObj, Prefix) -> lists:foldl(fun(K,J) -> case {kz_json:get_value(K, J), Prefix} of diff --git a/applications/crossbar/src/modules/cb_resource_templates.erl b/applications/crossbar/src/modules/cb_resource_templates.erl index b0a9c9aceb4..b833783fed4 100644 --- a/applications/crossbar/src/modules/cb_resource_templates.erl +++ b/applications/crossbar/src/modules/cb_resource_templates.erl @@ -194,7 +194,7 @@ forbidden(Context) -> %% %% @end %%-------------------------------------------------------------------- --spec validate_request(api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_request(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_request(ResourceId, Context) -> Context1 = check_template_name(Context), case cb_context:has_errors(Context1) of @@ -208,7 +208,7 @@ validate_request(ResourceId, Context) -> %% %% @end %%-------------------------------------------------------------------- --spec validate_patch(api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_patch(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_patch(ResourceId, Context) -> crossbar_doc:patch_and_validate(ResourceId, Context, fun validate_request/2). @@ -227,7 +227,7 @@ check_template_name(Context) -> _Name -> cb_context:set_resp_status(Context, 'success') end. --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> JObj = kz_doc:set_type(cb_context:req_data(Context), <<"resource_template">>), cb_context:set_resp_status(cb_context:set_doc(Context, JObj), 'success'); diff --git a/applications/crossbar/src/modules/cb_resources.erl b/applications/crossbar/src/modules/cb_resources.erl index 3b1f7f44fee..79167c797f6 100644 --- a/applications/crossbar/src/modules/cb_resources.erl +++ b/applications/crossbar/src/modules/cb_resources.erl @@ -75,7 +75,7 @@ maybe_start_jobs_listener() -> Pid -> Pid end. --spec jobs_listener_pid() -> api_pid(). +-spec jobs_listener_pid() -> kz_term:api_pid(). jobs_listener_pid() -> whereis('cb_jobs_listener'). @@ -357,13 +357,13 @@ delete(Context, ResourceId) -> %%% Internal functions %%%=================================================================== --spec maybe_aggregate_resource(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec maybe_aggregate_resource(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). maybe_aggregate_resource(Context, ?KZ_OFFNET_DB) -> Context; maybe_aggregate_resource(Context, _AccountDb) -> _ = cb_local_resources:maybe_aggregate_resource(Context), Context. --spec maybe_remove_aggregate(cb_context:context(), ne_binary(), ne_binary()) -> cb_context:context(). +-spec maybe_remove_aggregate(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). maybe_remove_aggregate(Context, _ResourceId, ?KZ_OFFNET_DB) -> Context; maybe_remove_aggregate(Context, ResourceId, _AccountDb) -> _ = cb_local_resources:maybe_remove_aggregate(ResourceId, Context), @@ -375,11 +375,11 @@ maybe_remove_aggregate(Context, ResourceId, _AccountDb) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec read(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec read(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). read(Id, Context) -> crossbar_doc:load(Id, Context, ?TYPE_CHECK_OPTION(<<"resource">>)). --spec read_job(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec read_job(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). read_job(Context, ?MATCH_MODB_PREFIX(Year,Month,_) = JobId) -> Modb = cb_context:account_modb(Context, kz_term:to_integer(Year), kz_term:to_integer(Month)), leak_job_fields(crossbar_doc:load(JobId, cb_context:set_account_db(Context, Modb), ?TYPE_CHECK_OPTION(<<"resource_job">>))); @@ -462,12 +462,12 @@ create_local(Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec update(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec update(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). update(Id, Context) -> OnSuccess = fun(C) -> on_successful_validation(Id, C) end, cb_context:validate_request_data(<<"resources">>, Context, OnSuccess). --spec update_local(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec update_local(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). update_local(Context, Id) -> OnSuccess = fun(C) -> on_successful_local_validation(Id, C) end, cb_context:validate_request_data(<<"resources">>, Context, OnSuccess). @@ -478,14 +478,14 @@ update_local(Context, Id) -> %% %% @end %%-------------------------------------------------------------------- --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> cb_context:set_doc(Context, kz_doc:set_type(cb_context:doc(Context), <<"resource">>)); on_successful_validation(Id, Context) -> crossbar_doc:load_merge(Id, Context, ?TYPE_CHECK_OPTION(<<"resource">>)). --spec on_successful_local_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_local_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_local_validation(Id, Context) -> cb_local_resources:validate_request(Id, Context). @@ -499,7 +499,7 @@ on_successful_job_validation('undefined', Context) -> ], cb_context:set_doc(Context, kz_json:set_values(Props, cb_context:doc(Context))). --spec maybe_reload_acls(ne_binary()) -> 'ok'. +-spec maybe_reload_acls(kz_term:ne_binary()) -> 'ok'. maybe_reload_acls(?KZ_OFFNET_DB) -> reload_acls(), reload_gateways(); @@ -538,7 +538,7 @@ collection_process(Context, Successes) -> end. -spec is_global_resource_request(cb_context:context()) -> boolean(). --spec is_global_resource_request(req_nouns(), api_binary()) -> boolean(). +-spec is_global_resource_request(req_nouns(), kz_term:api_binary()) -> boolean(). is_global_resource_request(Context) -> is_global_resource_request(cb_context:req_nouns(Context), cb_context:account_id(Context)). diff --git a/applications/crossbar/src/modules/cb_schemas.erl b/applications/crossbar/src/modules/cb_schemas.erl index 23588270e28..32720026574 100644 --- a/applications/crossbar/src/modules/cb_schemas.erl +++ b/applications/crossbar/src/modules/cb_schemas.erl @@ -122,7 +122,7 @@ on_success(Context) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec read(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec read(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). read(Id, Context) -> crossbar_doc:load(Id, Context, ?TYPE_CHECK_OPTION_ANY). @@ -140,7 +140,7 @@ summary(Context) -> ,lists:sort(cb_context:resp_data(Context1)) ). --type normalizer_fun() :: fun((kz_json:object(), ne_binaries()) -> ne_binaries()). +-type normalizer_fun() :: fun((kz_json:object(), kz_term:ne_binaries()) -> kz_term:ne_binaries()). -spec normalize_fun(cb_context:context()) -> normalizer_fun(). normalize_fun(Context) -> case kz_term:to_boolean(cb_context:req_value(Context, <<"internals">>, 'false')) of @@ -154,14 +154,14 @@ normalize_fun(Context) -> %% Normalizes the results of a view %% @end %%-------------------------------------------------------------------- --spec normalize_all_results(kz_json:object(), kz_json:objects()) -> ne_binaries(). +-spec normalize_all_results(kz_json:object(), kz_json:objects()) -> kz_term:ne_binaries(). normalize_all_results(JObj, Acc) -> case kz_doc:id(JObj) of <<"_design/", _/binary>> -> Acc; ID -> [ID | Acc] end. --spec normalize_doc_results(kz_json:object(), kz_json:objects()) -> ne_binaries(). +-spec normalize_doc_results(kz_json:object(), kz_json:objects()) -> kz_term:ne_binaries(). normalize_doc_results(JObj, Acc) -> case kz_doc:id(JObj) of <<"_design/", _/binary>> -> Acc; diff --git a/applications/crossbar/src/modules/cb_search.erl b/applications/crossbar/src/modules/cb_search.erl index 58809e23a07..90e7f66c04c 100644 --- a/applications/crossbar/src/modules/cb_search.erl +++ b/applications/crossbar/src/modules/cb_search.erl @@ -114,10 +114,10 @@ validate(Context, ?MULTI) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec validate_search(cb_context:context(), api_binary()) -> cb_context:context(). --spec validate_search(cb_context:context(), ne_binary(), api_binary()) -> +-spec validate_search(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). +-spec validate_search(cb_context:context(), kz_term:ne_binary(), kz_term:api_binary()) -> cb_context:context(). --spec validate_search(cb_context:context(), ne_binary(), ne_binary(), api_binary()) -> +-spec validate_search(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary()) -> cb_context:context(). validate_search(Context, 'undefined') -> Message = kz_json:from_list([{<<"message">>, <<"search needs a document type to search on">>} @@ -159,7 +159,7 @@ validate_search(Context, Type, Query, Value) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec validate_multi(cb_context:context(), api_binary()) -> cb_context:context(). +-spec validate_multi(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). validate_multi(Context, 'undefined') -> Message = kz_json:from_list([{<<"message">>, <<"Search needs a document type to search on">>} ,{<<"target">>, ?SEARCHABLE} @@ -170,7 +170,7 @@ validate_multi(Context, <<"account">>=Type) -> validate_multi(Context, Type) -> validate_multi(Context, Type, kz_json:to_proplist(cb_context:query_string(Context))). --spec validate_multi(cb_context:context(), ne_binary(), kz_proplist()) -> cb_context:context(). +-spec validate_multi(cb_context:context(), kz_term:ne_binary(), kz_term:proplist()) -> cb_context:context(). validate_multi(Context, Type, Query) -> Context1 = validate_query(Context, Query), case cb_context:resp_status(Context1) of @@ -183,8 +183,8 @@ validate_multi(Context, Type, Query) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec validate_query(cb_context:context(), kz_proplist() | ne_binary()) -> cb_context:context(). --spec validate_query(cb_context:context(), kz_proplist(), kz_proplist() | ne_binary()) -> cb_context:context(). +-spec validate_query(cb_context:context(), kz_term:proplist() | kz_term:ne_binary()) -> cb_context:context(). +-spec validate_query(cb_context:context(), kz_term:proplist(), kz_term:proplist() | kz_term:ne_binary()) -> cb_context:context(). validate_query(Context, Query) -> QueryOptions = available_query_options(cb_context:account_db(Context)), validate_query(Context, QueryOptions, Query). @@ -222,7 +222,7 @@ validate_query(Context, Available, Query) when is_binary(Query) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec available_query_options(api_ne_binary()) -> ne_binaries(). +-spec available_query_options(kz_term:api_ne_binary()) -> kz_term:ne_binaries(). available_query_options(AccountDb) -> case kz_datamgr:open_cache_doc(AccountDb, <<"_design/search">>) of {'ok', JObj} -> @@ -238,8 +238,8 @@ available_query_options(AccountDb) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec format_query_options(ne_binaries()) -> ne_binaries(). --spec format_query_option(ne_binary()) -> ne_binary(). +-spec format_query_options(kz_term:ne_binaries()) -> kz_term:ne_binaries(). +-spec format_query_option(kz_term:ne_binary()) -> kz_term:ne_binary(). format_query_options(Views) -> [format_query_option(View) || View <- Views]. @@ -253,7 +253,7 @@ format_query_option(Name) -> Name. %% resource. %% @end %%-------------------------------------------------------------------- --spec search(cb_context:context(), ne_binary(), ne_binary(), binary(), kz_proplist()) -> cb_context:context(). +-spec search(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary(), binary(), kz_term:proplist()) -> cb_context:context(). search(Context, Type, Query, Val, Opts) -> ViewName = <>, Value = maybe_normalize_value(Type, Val), @@ -272,8 +272,8 @@ search(Context, Type, Query, Val, Opts) -> %% resource. %% @end %%-------------------------------------------------------------------- --spec multi_search(cb_context:context(), ne_binary(), kz_proplist()) -> cb_context:context(). --spec multi_search(cb_context:context(), ne_binary(), kz_proplist(), kz_json:object()) -> cb_context:context(). +-spec multi_search(cb_context:context(), kz_term:ne_binary(), kz_term:proplist()) -> cb_context:context(). +-spec multi_search(cb_context:context(), kz_term:ne_binary(), kz_term:proplist(), kz_json:object()) -> cb_context:context(). multi_search(Context, Type, Props) -> Context1 = cb_context:set_should_paginate(Context, 'false'), multi_search(Context1, Type, Props , kz_json:new()). @@ -298,7 +298,7 @@ multi_search(Context, Type, [_|Props], Acc) -> %% Normalize search term for using in accounts search view %% @end %%-------------------------------------------------------------------- --spec maybe_normalize_value(ne_binary(), ne_binary()) -> ne_binary(). +-spec maybe_normalize_value(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). maybe_normalize_value(<<"account">>, Value) -> cb_modules_util:normalize_alphanum_name(Value); maybe_normalize_value(_, Value) -> @@ -310,7 +310,7 @@ maybe_normalize_value(_, Value) -> %% resource. %% @end %%-------------------------------------------------------------------- --spec get_start_key(cb_context:context(), ne_binary(), ne_binary()) -> ne_binaries(). +-spec get_start_key(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binaries(). get_start_key(Context, <<"account">>=Type, Value) -> [cb_context:auth_account_id(Context), Type, cb_context:req_value(Context, <<"start_key">>, Value)]; get_start_key(Context, Type, Value) -> @@ -322,7 +322,7 @@ get_start_key(Context, Type, Value) -> %% resource. %% @end %%-------------------------------------------------------------------- --spec get_end_key(cb_context:context(), ne_binary(), binary()) -> ne_binaries(). +-spec get_end_key(cb_context:context(), kz_term:ne_binary(), binary()) -> kz_term:ne_binaries(). get_end_key(Context, <<"account">>=Type, Value) -> [cb_context:auth_account_id(Context), Type, next_binary_key(Value)]; get_end_key(_, Type, Value) -> @@ -334,7 +334,7 @@ get_end_key(_, Type, Value) -> %% replaces last character in binary with next character %% @end %%-------------------------------------------------------------------- --spec next_binary_key(binary()) -> ne_binary(). +-spec next_binary_key(binary()) -> kz_term:ne_binary(). next_binary_key(<<>>) -> <<"\ufff0">>; next_binary_key(Bin) -> diff --git a/applications/crossbar/src/modules/cb_security.erl b/applications/crossbar/src/modules/cb_security.erl index 993ada02ea8..c109364618e 100644 --- a/applications/crossbar/src/modules/cb_security.erl +++ b/applications/crossbar/src/modules/cb_security.erl @@ -282,7 +282,7 @@ maybe_add_multi_factor_metadata(AuthConfig) -> end, kz_json:foldl(Fun, AuthConfig, kz_json:get_value(<<"auth_modules">>, AuthConfig, kz_json:new())). --spec add_multi_factor_metadata(ne_binary(), kz_json:object(), kz_json:object()) -> kz_json:object(). +-spec add_multi_factor_metadata(kz_term:ne_binary(), kz_json:object(), kz_json:object()) -> kz_json:object(). add_multi_factor_metadata(AuthModule, JObj, AuthConfig) -> AccountId = kz_json:get_value([<<"multi_factor">>, <<"account_id">>], JObj), ConfigId = kz_json:get_value([<<"multi_factor">>, <<"configuration_id">>], JObj), @@ -298,7 +298,7 @@ add_multi_factor_metadata(AuthModule, JObj, AuthConfig) -> kz_json:set_value(Path, Metadata, AuthConfig) end. --spec get_metadata(ne_binary(), ne_binary()) -> api_object(). +-spec get_metadata(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_object(). get_metadata(AccountId, ConfigId) -> case kz_datamgr:open_cache_doc(kz_util:format_account_db(AccountId), ConfigId) of {'ok', JObj} -> @@ -324,7 +324,7 @@ set_as_system(AuthConfig, Path) -> %% valid %% @end %%-------------------------------------------------------------------- --spec update(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec update(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). update(Id, Context) -> OnSuccess = fun(C) -> on_successful_validation(Id, C) end, SchemaName = kapps_config_util:account_schema_name(?AUTH_CONFIG_CAT), @@ -337,7 +337,7 @@ update(Id, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec validate_patch(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_patch(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). validate_patch(Id, Context) -> C1 = cb_context:store(Context, <<"orig_req_data">>, cb_context:req_data(Context)), crossbar_doc:patch_and_validate(Id, C1, fun update/2). @@ -379,7 +379,7 @@ check_multi_factor_setting(AuthModule, JObj, Context) -> has_configuration_id(JObj) -> kz_json:get_ne_binary_value([<<"multi_factor">>, <<"configuration_id">>], JObj) =/= 'undefined'. --spec has_account_id_or_db(kz_json:object()) -> boolean() | ne_binary(). +-spec has_account_id_or_db(kz_json:object()) -> boolean() | kz_term:ne_binary(). has_account_id_or_db(JObj) -> case kz_json:get_ne_binary_value([<<"multi_factor">>, <<"account_id">>], JObj) of 'undefined' -> <<"setting multi-factor configuration_id needs setting account_id">>; @@ -397,7 +397,7 @@ has_account_id_or_db(JObj) -> %% * if a include_subaccounts, allow a child account set its parent's config %% @end %%-------------------------------------------------------------------- --spec check_account_hierarchy(ne_binary(), kz_json:object(), cb_context:context()) -> cb_context:context(). +-spec check_account_hierarchy(kz_term:ne_binary(), kz_json:object(), cb_context:context()) -> cb_context:context(). check_account_hierarchy(AuthModule, JObj, Context) -> AuthAccountId = cb_context:auth_account_id(Context), AccountId = kz_json:get_ne_binary_value([<<"multi_factor">>, <<"account_id">>], JObj), @@ -413,7 +413,7 @@ check_account_hierarchy(AuthModule, JObj, Context) -> failed_multi_factor_validation(AuthModule, ErrMsg, Context) end. --spec failed_multi_factor_validation(ne_binary(), ne_binary(), cb_context:context()) -> cb_context:context(). +-spec failed_multi_factor_validation(kz_term:ne_binary(), kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). failed_multi_factor_validation(AuthModule, ErrMsg, Context) -> KeyPath = <<"auth_modules.", AuthModule/binary, ".account_id">>, JObj = cb_context:validation_errors(Context), @@ -432,6 +432,6 @@ failed_multi_factor_validation(AuthModule, ErrMsg, Context) -> %% Load a login attempt log from MODB %% @end %%-------------------------------------------------------------------- --spec read_attempt_log(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec read_attempt_log(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). read_attempt_log(?MATCH_MODB_PREFIX(Year, Month, _)=AttemptId, Context) -> crossbar_doc:load(AttemptId, cb_context:set_account_modb(Context, Year, Month), ?TYPE_CHECK_OPTION(?AUTH_ATTEMPT_TYPE)). diff --git a/applications/crossbar/src/modules/cb_service_plans.erl b/applications/crossbar/src/modules/cb_service_plans.erl index a4c5b936281..dadc4ea0bbf 100644 --- a/applications/crossbar/src/modules/cb_service_plans.erl +++ b/applications/crossbar/src/modules/cb_service_plans.erl @@ -297,7 +297,7 @@ delete_plans(Context, Services) -> %% @end %%-------------------------------------------------------------------- -type services_pipe() :: fun((kz_services:services()) -> kz_services:services()). --spec pipe_services(ne_binary(), [services_pipe()]) -> kz_services:services(). +-spec pipe_services(kz_term:ne_binary(), [services_pipe()]) -> kz_services:services(). pipe_services(AccountId, Routines) -> Services = kz_services:fetch(AccountId), lists:foldl(fun (F, S) -> F(S) end, Services, Routines). @@ -310,8 +310,8 @@ pipe_services(AccountId, Routines) -> %% @end %%-------------------------------------------------------------------- -spec content_types_provided(cb_context:context()) -> cb_context:context(). --spec content_types_provided(cb_context:context(), ne_binary()) -> cb_context:context(). --spec content_types_provided(cb_context:context(), ne_binary(), ne_binary()) -> cb_context:context(). +-spec content_types_provided(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). +-spec content_types_provided(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). content_types_provided(Context) -> cb_context:add_content_types_provided(Context ,[{'to_json', ?JSON_CONTENT_TYPES} @@ -347,7 +347,7 @@ normalize_view_results(JObj, Acc) -> %% Check if you have the permission to update or delete service plans %% @end %%-------------------------------------------------------------------- --spec is_allowed(cb_context:context()) -> {'ok', ne_binary()} | 'false'. +-spec is_allowed(cb_context:context()) -> {'ok', kz_term:ne_binary()} | 'false'. is_allowed(Context) -> ResellerId = kz_services:find_reseller_id(cb_context:account_id(Context)), AuthAccountId = cb_context:auth_account_id(Context), @@ -387,8 +387,8 @@ maybe_allow_change(Context, PlanId) -> %% %% @end %%-------------------------------------------------------------------- --spec check_plan_ids(cb_context:context(), ne_binary()) -> cb_context:context(). --spec check_plan_ids(cb_context:context(), ne_binary(), ne_binaries()) -> cb_context:context(). +-spec check_plan_ids(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). +-spec check_plan_ids(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binaries()) -> cb_context:context(). check_plan_ids(Context, ResellerId) -> ReqData = cb_context:req_data(Context), AddPlanIds = kz_json:get_value(<<"add">>, ReqData, []), @@ -415,7 +415,7 @@ check_plan_ids(Context, ResellerId, PlanIds) -> %% %% @end %%-------------------------------------------------------------------- --spec check_plan_id(cb_context:context(), path_token(), ne_binary()) -> +-spec check_plan_id(cb_context:context(), path_token(), kz_term:ne_binary()) -> cb_context:context(). check_plan_id(Context, PlanId, ResellerId) -> ResellerDb = kz_util:format_account_id(ResellerId, 'encoded'), @@ -429,7 +429,7 @@ maybe_forbid_delete(Context) -> maybe_forbid_delete(DeletePlansIds, Context) end. --spec maybe_forbid_delete(ne_binaries(), cb_context:context()) -> cb_context:context(). +-spec maybe_forbid_delete(kz_term:ne_binaries(), cb_context:context()) -> cb_context:context(). maybe_forbid_delete(DeletePlansIds, Context) -> case kz_services:fetch_services_doc(cb_context:account_id(Context)) of {'error', 'not_found'} -> Context; diff --git a/applications/crossbar/src/modules/cb_shared_auth.erl b/applications/crossbar/src/modules/cb_shared_auth.erl index 5ab4633faad..b59964d6071 100644 --- a/applications/crossbar/src/modules/cb_shared_auth.erl +++ b/applications/crossbar/src/modules/cb_shared_auth.erl @@ -126,7 +126,7 @@ authenticate(_, _) -> 'false'. %% @end %%-------------------------------------------------------------------- -spec validate(cb_context:context()) -> cb_context:context(). --spec validate_request(cb_context:context(), http_method(), api_object()) -> cb_context:context(). +-spec validate_request(cb_context:context(), http_method(), kz_term:api_object()) -> cb_context:context(). validate(Context) -> validate_request(Context, cb_context:req_verb(Context), cb_context:auth_doc(Context)). @@ -232,7 +232,7 @@ create_local_token(Context) -> %% the shared token and get the account/user for the token %% @end %%-------------------------------------------------------------------- --spec authenticate_shared_token(api_binary(), nonempty_string()) -> +-spec authenticate_shared_token(kz_term:api_binary(), nonempty_string()) -> {'ok', string() | binary()} | {'error', atom()} | {'forbidden', atom()}. @@ -277,7 +277,7 @@ import_missing_data(Account, User) -> %% an account and user, ensure the account exists (creating if not) %% @end %%-------------------------------------------------------------------- --spec import_missing_account(api_ne_binary(), kz_json:object()) -> boolean(). +-spec import_missing_account(kz_term:api_ne_binary(), kz_json:object()) -> boolean(). import_missing_account('undefined', _Account) -> lager:debug("shared auth reply did not define an account id"), 'false'; @@ -337,7 +337,7 @@ import_missing_account(AccountId, Account) -> %% an account and user, ensure the user exists locally (creating if not) %% @end %%-------------------------------------------------------------------- --spec import_missing_user(ne_binary(), api_ne_binary(), kz_json:object()) -> boolean(). +-spec import_missing_user(kz_term:ne_binary(), kz_term:api_ne_binary(), kz_json:object()) -> boolean(). import_missing_user(_, 'undefined', _) -> lager:debug("shared auth reply did not define an user id"), 'false'; diff --git a/applications/crossbar/src/modules/cb_skels.erl b/applications/crossbar/src/modules/cb_skels.erl index 3a8194439fd..5738b4775d9 100644 --- a/applications/crossbar/src/modules/cb_skels.erl +++ b/applications/crossbar/src/modules/cb_skels.erl @@ -309,7 +309,7 @@ create(Context) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec read(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec read(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). read(Id, Context) -> crossbar_doc:load(Id, Context, ?TYPE_CHECK_OPTION(<<"skel">>)). @@ -320,7 +320,7 @@ read(Id, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec update(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec update(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). update(Id, Context) -> OnSuccess = fun(C) -> on_successful_validation(Id, C) end, cb_context:validate_request_data(<<"skels">>, Context, OnSuccess). @@ -332,7 +332,7 @@ update(Id, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec validate_patch(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_patch(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). validate_patch(Id, Context) -> crossbar_doc:patch_and_validate(Id, Context, fun update/2). @@ -353,7 +353,7 @@ summary(Context) -> %% %% @end %%-------------------------------------------------------------------- --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> cb_context:set_doc(Context, kz_doc:set_type(cb_context:doc(Context), <<"skel">>)); on_successful_validation(Id, Context) -> diff --git a/applications/crossbar/src/modules/cb_sms.erl b/applications/crossbar/src/modules/cb_sms.erl index e1e1690d958..7f862975e07 100644 --- a/applications/crossbar/src/modules/cb_sms.erl +++ b/applications/crossbar/src/modules/cb_sms.erl @@ -143,7 +143,7 @@ create(Context) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec read(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec read(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). read(?MATCH_MODB_PREFIX(Year,Month,_) = Id, Context) -> Context1 = cb_context:set_account_modb(Context, kz_term:to_integer(Year), kz_term:to_integer(Month)), crossbar_doc:load(Id, Context1, ?TYPE_CHECK_OPTION(<<"sms">>)); @@ -223,7 +223,7 @@ on_successful_validation(Context) -> -define(CALLER_ID_INTERNAL, [<<"caller_id">>, <<"internal">>, <<"number">>]). -define(CALLER_ID_EXTERNAL, [<<"caller_id">>, <<"external">>, <<"number">>]). --spec get_default_caller_id(cb_context:context(), api_binary()) -> api_binary(). +-spec get_default_caller_id(cb_context:context(), kz_term:api_binary()) -> kz_term:api_binary(). get_default_caller_id(Context, 'undefined') -> {'ok', JObj} = kz_account:fetch(cb_context:account_id(Context)), kz_json:get_first_defined([?CALLER_ID_INTERNAL, ?CALLER_ID_EXTERNAL] @@ -255,7 +255,7 @@ summary(Context) -> ], crossbar_view:load_modb(Context, ViewName, Options). --spec build_view_name_rane_keys(api_binary(), api_binary()) -> {ne_binary(), crossbar_view:options()}. +-spec build_view_name_rane_keys(kz_term:api_binary(), kz_term:api_binary()) -> {kz_term:ne_binary(), crossbar_view:options()}. build_view_name_rane_keys('undefined', 'undefined') -> {?CB_LIST_ALL ,[{'range_start_keymap', []} @@ -293,7 +293,7 @@ is_digit(N) when is_integer(N), N =< $9 -> true; is_digit(_) -> false. --spec build_number(ne_binary()) -> {api_binary(), kz_proplist()}. +-spec build_number(kz_term:ne_binary()) -> {kz_term:api_binary(), kz_term:proplist()}. build_number(Number) -> N = binary:split(Number, <<",">>, ['global']), case N of @@ -301,8 +301,8 @@ build_number(Number) -> _ -> lists:foldl(fun parse_number/2, {'undefined', []}, N) end. --spec parse_number(ne_binary(), {api_binary(), kz_proplist()}) -> - {api_binary(), kz_proplist()}. +-spec parse_number(kz_term:ne_binary(), {kz_term:api_binary(), kz_term:proplist()}) -> + {kz_term:api_binary(), kz_term:proplist()}. parse_number(<<"TON=", N/binary>>, {Num, Options}) -> {Num, [{<<"TON">>, kz_term:to_integer(N) } | Options]}; parse_number(<<"NPI=", N/binary>>, {Num, Options}) -> diff --git a/applications/crossbar/src/modules/cb_storage.erl b/applications/crossbar/src/modules/cb_storage.erl index 459505cd19f..d7a92d08727 100644 --- a/applications/crossbar/src/modules/cb_storage.erl +++ b/applications/crossbar/src/modules/cb_storage.erl @@ -35,11 +35,11 @@ -type scope() :: 'system' | 'system_plans' - | {'system_plan', ne_binary()} - | {'user', ne_binary(), ne_binary()} - | {'account', ne_binary()} - | {'reseller_plans', ne_binary()} - | {'reseller_plan', ne_binary(), ne_binary()} + | {'system_plan', kz_term:ne_binary()} + | {'user', kz_term:ne_binary(), kz_term:ne_binary()} + | {'account', kz_term:ne_binary()} + | {'reseller_plans', kz_term:ne_binary()} + | {'reseller_plan', kz_term:ne_binary(), kz_term:ne_binary()} | 'invalid'. %%%=================================================================== @@ -191,7 +191,7 @@ validate_storage_plans(Context, ?HTTP_GET) -> validate_storage_plans(Context, ?HTTP_PUT) -> create(Context). --spec validate_storage_plan(cb_context:context(), ne_binary(), http_method()) -> cb_context:context(). +-spec validate_storage_plan(cb_context:context(), kz_term:ne_binary(), http_method()) -> cb_context:context(). validate_storage_plan(Context, PlanId, ?HTTP_GET) -> read(Context, PlanId); validate_storage_plan(Context, PlanId, ?HTTP_POST) -> @@ -332,11 +332,11 @@ summary(Context, {'reseller_plans', AccountId}) -> %% %% @end %%-------------------------------------------------------------------- --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation(Id, Context) -> on_successful_validation(Id, cb_context:req_verb(Context), Context). --spec on_successful_validation(api_binary(), http_method(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), http_method(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', ?HTTP_PUT, Context) -> IsSystemPlan = scope(Context) =:= 'system_plans', JObj = cb_context:doc(Context), @@ -403,7 +403,7 @@ set_scope(Context, [{<<"storage">>, []} set_scope(Context, _Nouns) -> cb_context:store(Context, 'scope', 'invalid'). --spec doc_id(cb_context:context() | scope()) -> api_binary(). +-spec doc_id(cb_context:context() | scope()) -> kz_term:api_binary(). doc_id('system') -> <<"system">>; doc_id('system_plans') -> 'undefined'; doc_id({'system_plan', PlanId}) -> PlanId; diff --git a/applications/crossbar/src/modules/cb_sup.erl b/applications/crossbar/src/modules/cb_sup.erl index e1a0f27a8b5..e72f2607cac 100644 --- a/applications/crossbar/src/modules/cb_sup.erl +++ b/applications/crossbar/src/modules/cb_sup.erl @@ -48,7 +48,7 @@ %%%=================================================================== %%% API %%%=================================================================== --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> proc_lib:start_link(?SERVER, 'init_io', [self()]). @@ -185,7 +185,7 @@ allowed_methods(_Module, _Function, _Args) -> -spec resource_exists() -> 'false'. -spec resource_exists(path_token()) -> boolean(). -spec resource_exists(path_token(), path_token()) -> boolean(). --spec resource_exists(path_token(), path_token(), ne_binaries()) -> boolean(). +-spec resource_exists(path_token(), path_token(), kz_term:ne_binaries()) -> boolean(). resource_exists() -> 'false'. resource_exists(ModuleBin) -> diff --git a/applications/crossbar/src/modules/cb_system_configs.erl b/applications/crossbar/src/modules/cb_system_configs.erl index 5c52326b390..3a1f9ec6392 100644 --- a/applications/crossbar/src/modules/cb_system_configs.erl +++ b/applications/crossbar/src/modules/cb_system_configs.erl @@ -170,7 +170,7 @@ validate_document_request(Context, Id, FullConfig) -> %% Node API %%-------------------------------------------------------------------- --spec validate_document_node(cb_context:context(), path_token(), http_method(), api_ne_binary()) -> cb_context:context(). +-spec validate_document_node(cb_context:context(), path_token(), http_method(), kz_term:api_ne_binary()) -> cb_context:context(). validate_document_node(Context, Id, ?HTTP_GET, Node) -> Config = case kz_term:is_true(cb_context:req_value(Context, <<"with_defaults">>, false)) of @@ -251,7 +251,7 @@ patch(Context, Id, Node) -> cb_context:context(). -spec delete(cb_context:context(), path_token(), path_token()) -> cb_context:context(). --spec delete(cb_context:context(), path_token(), path_token(), api_object() | kz_json:objects()) -> +-spec delete(cb_context:context(), path_token(), path_token(), kz_term:api_object() | kz_json:objects()) -> cb_context:context(). delete(Context, _Id) -> crossbar_doc:delete(Context, ?HARD_DELETE). @@ -275,7 +275,7 @@ delete(Context, Id, Node, Doc) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec read_for_delete(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec read_for_delete(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). read_for_delete(Id, Context) -> Context1 = crossbar_doc:load(Id, Context, ?TYPE_CHECK_OPTION(<<"config">>)), case cb_context:resp_status(Context) of @@ -303,7 +303,7 @@ summary(Context) -> %% Normalizes the results of a view %% @end %%-------------------------------------------------------------------- --spec normalize_view_results(kz_json:object(), ne_binaries()) -> ne_binaries(). +-spec normalize_view_results(kz_json:object(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). normalize_view_results(JObj, Acc) -> [kz_json:get_value(<<"key">>, JObj) | Acc]. @@ -314,18 +314,18 @@ set_db_to_system(Context) -> ,{fun cb_context:set_account_id/2, cb_context:auth_account_id(Context)} ]). --spec maybe_set_private_fields(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec maybe_set_private_fields(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). maybe_set_private_fields(ConfigId, JObj) -> case kapps_config:get_category(ConfigId) of {ok, Doc} -> kz_json:merge(JObj, kz_doc:private_fields(Doc)); _ -> kz_doc:set_id(JObj, ConfigId) end. --spec set_id(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec set_id(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). set_id(Id, JObj) -> kz_json:set_value(<<"id">>, Id, JObj). --spec set_id(ne_binary(), ne_binary(), kz_json:object()) -> kz_json:object(). +-spec set_id(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). set_id(Id, Node, JObj) -> kz_json:set_value(<<"id">>, <>, JObj). diff --git a/applications/crossbar/src/modules/cb_tasks.erl b/applications/crossbar/src/modules/cb_tasks.erl index 8a1ae8c7b81..19d5647e75f 100644 --- a/applications/crossbar/src/modules/cb_tasks.erl +++ b/applications/crossbar/src/modules/cb_tasks.erl @@ -196,7 +196,7 @@ to_csv({Req, Context}) -> ), {Req, cb_context:set_resp_headers(Context, Headers)}. --spec download_filename(cb_context:context(), ne_binary()) -> ne_binary(). +-spec download_filename(cb_context:context(), kz_term:ne_binary()) -> kz_term:ne_binary(). download_filename(Context, ?KZ_TASKS_ANAME_OUT) -> TaskJObj = cb_context:doc(Context), @@ -343,7 +343,7 @@ put(Context) -> crossbar_util:response_400(<<"bad request">>, Reason, Context) end. --spec task_account_id(cb_context:context()) -> api_ne_binary(). +-spec task_account_id(cb_context:context()) -> kz_term:api_ne_binary(). task_account_id(Context) -> case cb_context:account_id(Context) of 'undefined' -> cb_context:auth_account_id(Context); @@ -439,9 +439,9 @@ set_db(Context) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec read(ne_binary(), cb_context:context()) -> cb_context:context(). --spec read(ne_binary(), cb_context:context(), api_binary()) -> cb_context:context(). --spec read(ne_binary(), cb_context:context(), api_binary(), api_binary()) -> cb_context:context(). +-spec read(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). +-spec read(kz_term:ne_binary(), cb_context:context(), kz_term:api_binary()) -> cb_context:context(). +-spec read(kz_term:ne_binary(), cb_context:context(), kz_term:api_binary(), kz_term:api_binary()) -> cb_context:context(). read(TaskId, Context) -> AccountId = cb_context:account_id(Context), read(TaskId, set_db(Context), AccountId). @@ -453,13 +453,13 @@ read(TaskId, Context, AccountId) -> AcceptValue = accept_value(Context), read(TaskId, Context, AccountId, AcceptValue). --spec accept_value(cb_context:context()) -> api_ne_binary(). +-spec accept_value(cb_context:context()) -> kz_term:api_ne_binary(). accept_value(Context) -> accept_value(cb_context:req_header(Context, <<"accept">>) ,cb_context:req_value(Context, <<"accept">>) ). --spec accept_value(api_ne_binary(), api_ne_binary()) -> ne_binary(). +-spec accept_value(kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> kz_term:ne_binary(). accept_value('undefined', 'undefined') -> ?DEFAULT_CONTENT_TYPE; accept_value(Header, 'undefined') -> Header; accept_value(_Header, <<"csv">>) -> <<"text/csv">>; @@ -471,7 +471,7 @@ read(TaskId, Context, AccountId, Accept) -> -type parsed_accept_values() :: {'error', 'badarg'} | media_values(). --spec read_doc_or_attachment(ne_binary(), cb_context:context(), ne_binary(), parsed_accept_values()) -> +-spec read_doc_or_attachment(kz_term:ne_binary(), cb_context:context(), kz_term:ne_binary(), parsed_accept_values()) -> cb_context:context(). read_doc_or_attachment(TaskId, Context, AccountId, {'error', 'badarg'}) -> lager:info("failed to parse the accept header"), @@ -495,7 +495,7 @@ read_doc_or_attachment(TaskId, Context, AccountId, []) -> lager:info("failed to find valid accept value"), read_doc(TaskId, Context, AccountId). --spec read_doc(ne_binary(), cb_context:context(), ne_binary()) -> +-spec read_doc(kz_term:ne_binary(), cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). read_doc(TaskId, Context, AccountId) -> Ctx = crossbar_doc:load_view(?KZ_TASKS_BY_ACCOUNT @@ -532,17 +532,17 @@ read_attachment(TaskId, Context, AccountId) -> ReadContext end. --spec requested_attachment_name(cb_context:context()) -> ne_binary(). +-spec requested_attachment_name(cb_context:context()) -> kz_term:ne_binary(). requested_attachment_name(Context) -> cb_context:req_value(Context, <<"csv_name">>, ?KZ_TASKS_ANAME_OUT). --spec csv_path_to_file(ne_binary()) -> ne_binary(). +-spec csv_path_to_file(kz_term:ne_binary()) -> kz_term:ne_binary(). csv_path_to_file(?PATH_INPUT) -> ?KZ_TASKS_ANAME_IN; csv_path_to_file(?PATH_OUTPUT) -> ?KZ_TASKS_ANAME_OUT. --spec read_attachment_file(ne_binary(), cb_context:context(), ne_binary()) -> cb_context:context(). +-spec read_attachment_file(kz_term:ne_binary(), cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). read_attachment_file(TaskId, Context, AttachmentName) -> Type = ?TYPE_CHECK_OPTION(kzd_task:type()), crossbar_doc:load_attachment(TaskId, AttachmentName, Type, Context). @@ -572,7 +572,7 @@ normalize_view_results(JObj, Acc) -> [kz_json:get_value(<<"value">>, JObj) | Acc]. %% @private --spec req_content_type(cb_context:context()) -> ne_binary(). +-spec req_content_type(cb_context:context()) -> kz_term:ne_binary(). req_content_type(Context) -> cb_context:req_header(Context, <<"content-type">>). @@ -591,7 +591,7 @@ attached_data(Context, 'false') -> kz_json:get_value(?RD_RECORDS, cb_context:req_data(Context)). %% @private --spec save_attached_data(cb_context:context(), ne_binary(), kz_tasks:input(), boolean()) -> +-spec save_attached_data(cb_context:context(), kz_term:ne_binary(), kz_tasks:input(), boolean()) -> cb_context:context(). save_attached_data(Context, TaskId, CSV, 'true') -> CT = req_content_type(Context), diff --git a/applications/crossbar/src/modules/cb_templates.erl b/applications/crossbar/src/modules/cb_templates.erl index 29fdb524916..a447e4afcd5 100644 --- a/applications/crossbar/src/modules/cb_templates.erl +++ b/applications/crossbar/src/modules/cb_templates.erl @@ -104,7 +104,7 @@ validate_request(Context, _, _, TemplateName) -> put(Context, TemplateName) -> create_template_db(TemplateName, Context). --spec delete(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec delete(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). delete(Context, TemplateName) -> DbName = format_template_name(TemplateName, 'encoded'), case kz_datamgr:db_delete(DbName) of @@ -147,7 +147,7 @@ summary(Context) -> %% for this account %% @end %%-------------------------------------------------------------------- --spec load_template_db(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_template_db(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_template_db([TemplateName], Context) -> load_template_db(TemplateName, Context); load_template_db(TemplateName, Context) -> @@ -170,7 +170,7 @@ load_template_db(TemplateName, Context) -> %% Format the template/db name into a raw, unencoded or encoded form. %% @end %%-------------------------------------------------------------------- --spec format_template_name(ne_binary(), 'encoded' | 'raw') -> ne_binary(). +-spec format_template_name(kz_term:ne_binary(), 'encoded' | 'raw') -> kz_term:ne_binary(). format_template_name(<<"template%2F", _/binary>> = TemplateName, 'encoded') -> TemplateName; format_template_name(<<"template/", TemplateName/binary>>, 'encoded') -> @@ -191,7 +191,7 @@ format_template_name(TemplateName, 'raw') -> %% used as an 'account' %% @end %%-------------------------------------------------------------------- --spec create_template_db(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec create_template_db(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). create_template_db(TemplateName, Context) -> TemplateDb = format_template_name(TemplateName, 'encoded'), case kz_datamgr:db_create(TemplateDb) of @@ -212,7 +212,7 @@ create_template_db(TemplateName, Context) -> %% documents into the account %% @end %%-------------------------------------------------------------------- --spec import_template(api_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec import_template(kz_term:api_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. import_template('undefined', _, _) -> 'ok'; import_template(TemplateName, AccountId, AccountDb) -> %%TODO: use couch replication... @@ -229,7 +229,7 @@ import_template(TemplateName, AccountId, AccountDb) -> _ -> 'ok' end. --spec is_design_doc_id(ne_binary()) -> boolean(). +-spec is_design_doc_id(kz_term:ne_binary()) -> boolean(). is_design_doc_id(<<"_design/", _/binary>>) -> 'false'; is_design_doc_id(_) -> 'true'. @@ -240,7 +240,7 @@ is_design_doc_id(_) -> 'true'. %% account database, correcting the pvt fields. %% @end %%-------------------------------------------------------------------- --spec import_template_docs(ne_binaries(), ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec import_template_docs(kz_term:ne_binaries(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. import_template_docs([], _, _, _) -> 'ok'; import_template_docs([Id|Ids], TemplateDb, AccountId, AccountDb) -> case kz_datamgr:open_doc(TemplateDb, Id) of @@ -257,7 +257,7 @@ import_template_docs([Id|Ids], TemplateDb, AccountId, AccountDb) -> import_template_docs(Ids, TemplateDb, AccountId, AccountDb) end. --spec import_template_attachments(ne_binaries(), kz_json:object(), ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec import_template_attachments(kz_term:ne_binaries(), kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. import_template_attachments([], _, _, _, _) -> 'ok'; import_template_attachments([Attachment|Attachments], JObj, TemplateDb, AccountDb, Id) -> {'ok', Bin} = kz_datamgr:fetch_attachment(TemplateDb, Id, Attachment), diff --git a/applications/crossbar/src/modules/cb_temporal_rules.erl b/applications/crossbar/src/modules/cb_temporal_rules.erl index 50ca12db57d..5853ae96150 100644 --- a/applications/crossbar/src/modules/cb_temporal_rules.erl +++ b/applications/crossbar/src/modules/cb_temporal_rules.erl @@ -135,7 +135,7 @@ create(Context) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec read(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec read(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). read(Id, Context) -> crossbar_doc:load(Id, Context, ?TYPE_CHECK_OPTION(<<"temporal_rule">>)). @@ -146,7 +146,7 @@ read(Id, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec update(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec update(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). update(Id, Context) -> OnSuccess = fun(C) -> on_successful_validation(Id, C) end, cb_context:validate_request_data(<<"temporal_rules">>, Context, OnSuccess). @@ -158,7 +158,7 @@ update(Id, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec validate_patch(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_patch(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). validate_patch(Id, Context) -> crossbar_doc:patch_and_validate(Id, Context, fun update/2). @@ -179,7 +179,7 @@ summary(Context) -> %% %% @end %%-------------------------------------------------------------------- --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> cb_context:set_doc(Context, kz_doc:set_type(cb_context:doc(Context), <<"temporal_rule">>)); on_successful_validation(Id, Context) -> diff --git a/applications/crossbar/src/modules/cb_temporal_rules_sets.erl b/applications/crossbar/src/modules/cb_temporal_rules_sets.erl index c112eadc170..88dedbc74e1 100644 --- a/applications/crossbar/src/modules/cb_temporal_rules_sets.erl +++ b/applications/crossbar/src/modules/cb_temporal_rules_sets.erl @@ -137,7 +137,7 @@ create(Context) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec read(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec read(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). read(Id, Context) -> crossbar_doc:load(Id, Context, ?TYPE_CHECK_OPTION(<<"temporal_rule_set">>)). @@ -148,7 +148,7 @@ read(Id, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec update(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec update(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). update(Id, Context) -> OnSuccess = fun(C) -> on_successful_validation(Id, C) end, cb_context:validate_request_data(<<"temporal_rules_sets">>, Context, OnSuccess). @@ -160,7 +160,7 @@ update(Id, Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec validate_patch(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_patch(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). validate_patch(Id, Context) -> crossbar_doc:patch_and_validate(Id, Context, fun update/2). @@ -181,7 +181,7 @@ summary(Context) -> %% %% @end %%-------------------------------------------------------------------- --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> Doc = cb_context:doc(Context), cb_context:set_doc(Context, kz_doc:set_type(Doc, <<"temporal_rule_set">>)); diff --git a/applications/crossbar/src/modules/cb_token_auth.erl b/applications/crossbar/src/modules/cb_token_auth.erl index 7adb1e9cefe..476551a4288 100644 --- a/applications/crossbar/src/modules/cb_token_auth.erl +++ b/applications/crossbar/src/modules/cb_token_auth.erl @@ -50,7 +50,7 @@ validate(Context) -> _ = cb_context:put_reqid(Context), validate(Context, cb_context:req_verb(Context)). --spec validate(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec validate(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). validate(Context, ?HTTP_GET) -> JObj = crossbar_util:response_auth( kz_doc:public_fields(cb_context:auth_doc(Context)) @@ -108,7 +108,7 @@ authorize(Context) -> -spec authenticate(cb_context:context()) -> boolean() | {'true' | 'stop', cb_context:context()}. --spec authenticate(cb_context:context(), api_ne_binary(), atom()) -> +-spec authenticate(cb_context:context(), kz_term:api_ne_binary(), atom()) -> boolean() | {'true' | 'stop', cb_context:context()}. authenticate(Context) -> @@ -138,7 +138,7 @@ authenticate(_Context, _AccountId, _TokenType) -> 'false'. -spec early_authenticate(cb_context:context()) -> boolean() | {'true', cb_context:context()}. --spec early_authenticate(cb_context:context(), atom() | api_binary()) -> +-spec early_authenticate(cb_context:context(), atom() | kz_term:api_binary()) -> boolean() | {'true', cb_context:context()}. early_authenticate(Context) -> @@ -149,14 +149,14 @@ early_authenticate(Context, 'x-auth-token') -> early_authenticate_token(Context, cb_context:auth_token(Context)); early_authenticate(_Context, _TokenType) -> 'false'. --spec early_authenticate_token(cb_context:context(), api_binary()) -> +-spec early_authenticate_token(cb_context:context(), kz_term:api_binary()) -> boolean() | {'true', cb_context:context()}. early_authenticate_token(Context, AuthToken) when is_binary(AuthToken) -> validate_auth_token(Context, AuthToken); early_authenticate_token(_Context, 'undefined') -> 'true'. --spec check_auth_token(cb_context:context(), api_binary(), boolean()) -> +-spec check_auth_token(cb_context:context(), kz_term:api_binary(), boolean()) -> boolean() | {'true', cb_context:context()}. check_auth_token(_Context, <<>>, MagicPathed) -> @@ -168,7 +168,7 @@ check_auth_token(_Context, 'undefined', MagicPathed) -> check_auth_token(Context, AuthToken, _MagicPathed) -> validate_auth_token(Context, AuthToken). --spec validate_auth_token(cb_context:context(), ne_binary()) -> +-spec validate_auth_token(cb_context:context(), kz_term:ne_binary()) -> boolean() | {'true', cb_context:context()}. validate_auth_token(Context, ?NE_BINARY = AuthToken) -> @@ -217,7 +217,7 @@ check_as(Context, JObj) -> AccountId -> check_as_payload(Context, JObj, AccountId) end. --spec check_as_payload(cb_context:context(), kz_json:object(), ne_binary()) -> +-spec check_as_payload(cb_context:context(), kz_json:object(), kz_term:ne_binary()) -> boolean() | {'true', cb_context:context()}. check_as_payload(Context, JObj, AccountId) -> @@ -230,7 +230,7 @@ check_as_payload(Context, JObj, AccountId) -> {AsAccountId, AsOwnerId} -> check_descendants(Context, JObj, AccountId, AsAccountId, AsOwnerId) end. --spec check_descendants(cb_context:context(), kz_json:object(), ne_binary(), ne_binary(), ne_binary()) -> +-spec check_descendants(cb_context:context(), kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean() | {'true', cb_context:context()}. check_descendants(Context, JObj, AccountId, AsAccountId, AsOwnerId) -> diff --git a/applications/crossbar/src/modules/cb_token_restrictions.erl b/applications/crossbar/src/modules/cb_token_restrictions.erl index 21ea134b91a..0d89d302ed2 100644 --- a/applications/crossbar/src/modules/cb_token_restrictions.erl +++ b/applications/crossbar/src/modules/cb_token_restrictions.erl @@ -39,18 +39,18 @@ -define(PVT_TYPE, <<"token_restrictions">>). -define(MOD_CONFIG_CAT, <<(?CONFIG_CAT)/binary, ".token_restrictions">>). --spec default_priv_level() -> ne_binary(). +-spec default_priv_level() -> kz_term:ne_binary(). default_priv_level() -> kapps_config:get_binary(?MOD_CONFIG_CAT ,<<"default_priv_level">> ,<<"admin">> ). --spec default_method_restrictions() -> api_object(). +-spec default_method_restrictions() -> kz_term:api_object(). default_method_restrictions() -> kapps_config:get_json(?MOD_CONFIG_CAT, ?CATCH_ALL). --spec method_restrictions(atom()) -> api_object(). +-spec method_restrictions(atom()) -> kz_term:api_object(). method_restrictions(AuthModule) -> kapps_config:get_json(?MOD_CONFIG_CAT, AuthModule). @@ -154,7 +154,7 @@ maybe_deny_access(Context) -> get_auth_restrictions(AuthDoc) -> kz_json:get_json_value(<<"restrictions">>, AuthDoc). -else. --spec get_auth_restrictions(api_object()) -> api_object(). +-spec get_auth_restrictions(kz_term:api_object()) -> kz_term:api_object(). get_auth_restrictions('undefined') -> lager:debug("no auth doc to check"), 'undefined'; @@ -185,15 +185,15 @@ maybe_deny_access(Context, Restrictions) -> _Else -> 'false' end. --spec match_endpoint(cb_context:context(), api_object()) -> - api_object(). +-spec match_endpoint(cb_context:context(), kz_term:api_object()) -> + kz_term:api_object(). match_endpoint(Context, Restrictions) -> [{ReqEndpoint, _}|_] = cb_context:req_nouns(Context), match_request_endpoint(Restrictions, ReqEndpoint). --spec match_request_endpoint(api_object(), ne_binary()) -> - api_objects(). +-spec match_request_endpoint(kz_term:api_object(), kz_term:ne_binary()) -> + kz_term:api_objects(). match_request_endpoint(Restrictions, ?CATCH_ALL = ReqEndpoint) -> kz_json:get_list_value(ReqEndpoint, Restrictions); match_request_endpoint(Restrictions, ReqEndpoint) -> @@ -202,15 +202,15 @@ match_request_endpoint(Restrictions, ReqEndpoint) -> EndpointRestrictions -> EndpointRestrictions end. --spec match_account(cb_context:context(), api_objects()) -> api_object(). +-spec match_account(cb_context:context(), kz_term:api_objects()) -> kz_term:api_object(). match_account(_Context, 'undefined') -> 'undefined'; match_account(_Context, []) -> 'undefined'; match_account(Context, EndpointRestrictions) -> AllowedAccounts = allowed_accounts(Context), find_endpoint_restrictions_by_account(AllowedAccounts, EndpointRestrictions). --spec find_endpoint_restrictions_by_account(ne_binaries(), kz_json:objects()) -> - api_object(). +-spec find_endpoint_restrictions_by_account(kz_term:ne_binaries(), kz_json:objects()) -> + kz_term:api_object(). find_endpoint_restrictions_by_account(_Accounts, []) -> 'undefined'; find_endpoint_restrictions_by_account(AllowedAccounts @@ -225,7 +225,7 @@ find_endpoint_restrictions_by_account(AllowedAccounts find_endpoint_restrictions_by_account(AllowedAccounts, Restrictions) end. --spec maybe_match_accounts(ne_binaries(), api_binaries()) -> boolean(). +-spec maybe_match_accounts(kz_term:ne_binaries(), kz_term:api_binaries()) -> boolean(). maybe_match_accounts(_AllowedAccounts, 'undefined') -> 'true'; maybe_match_accounts(_AllowedAccounts, [?CATCH_ALL]) -> 'true'; maybe_match_accounts(AllowedAccounts, RestrictionAccounts) -> @@ -235,7 +235,7 @@ maybe_match_accounts(AllowedAccounts, RestrictionAccounts) -> sets:intersection(SetsAllowedAccounts, SetsRsAccounts) ) > 0. --spec allowed_accounts(cb_context:context()) -> ne_binaries(). +-spec allowed_accounts(cb_context:context()) -> kz_term:ne_binaries(). allowed_accounts(Context) -> AuthAccountId = cb_context:auth_account_id(Context), @@ -249,7 +249,7 @@ allowed_accounts(Context) -> allowed_accounts(?AUTH_ACCOUNT_ID, ?ACCOUNT_ID = AccountId) -> [?CATCH_ALL, AccountId, <<"{DESCENDANT_ACCOUNT_ID}">>]. -else. --spec allowed_accounts(api_binary(), api_binary()) -> ne_binaries(). +-spec allowed_accounts(kz_term:api_binary(), kz_term:api_binary()) -> kz_term:ne_binaries(). allowed_accounts('undefined', _AccountId) -> [?CATCH_ALL]; allowed_accounts(_AuthAccountId, 'undefined') -> [?CATCH_ALL]; allowed_accounts(AuthAccountId, AccountId) -> @@ -259,7 +259,7 @@ allowed_accounts(AuthAccountId, AccountId) -> end. -endif. --spec match_arguments(cb_context:context(), api_object()) -> +-spec match_arguments(cb_context:context(), kz_term:api_object()) -> http_methods(). match_arguments(_Context, 'undefined') -> []; match_arguments(Context, RulesJObj) -> @@ -267,7 +267,7 @@ match_arguments(Context, RulesJObj) -> RuleKeys = kz_json:get_keys(RulesJObj), match_argument_patterns(ReqParams, RulesJObj, RuleKeys). --spec match_argument_patterns(req_nouns(), kz_json:object(), ne_binaries()) -> +-spec match_argument_patterns(req_nouns(), kz_json:object(), kz_term:ne_binaries()) -> http_methods(). match_argument_patterns(_ReqParams, _RulesJObj, []) -> []; match_argument_patterns(ReqParams, RulesJObj, RuleKeys) -> @@ -277,7 +277,7 @@ match_argument_patterns(ReqParams, RulesJObj, RuleKeys) -> kz_json:get_list_value(MatchedRuleKey, RulesJObj, []) end. --spec match_rules(ne_binaries(), ne_binaries()) -> api_binary(). +-spec match_rules(kz_term:ne_binaries(), kz_term:ne_binaries()) -> kz_term:api_binary(). match_rules(_ReqParams, []) -> 'undefined'; match_rules(ReqParams, [RuleKey|RuleKeys]) -> case does_rule_match(RuleKey, ReqParams) of @@ -285,7 +285,7 @@ match_rules(ReqParams, [RuleKey|RuleKeys]) -> 'true' -> RuleKey end. --spec does_rule_match(ne_binary(), ne_binaries()) -> boolean(). +-spec does_rule_match(kz_term:ne_binary(), kz_term:ne_binaries()) -> boolean(). does_rule_match(RuleKey, ReqParams) -> kazoo_bindings:matches(binary:split(RuleKey, <<"/">>, ['global', 'trim']) ,ReqParams diff --git a/applications/crossbar/src/modules/cb_transactions.erl b/applications/crossbar/src/modules/cb_transactions.erl index 9df4912e099..7e267c77dcb 100644 --- a/applications/crossbar/src/modules/cb_transactions.erl +++ b/applications/crossbar/src/modules/cb_transactions.erl @@ -347,7 +347,7 @@ validate_transaction(Context, _PathToken, _Verb) -> %% @end %%-------------------------------------------------------------------- -spec validate_credit(cb_context:context()) -> cb_context:context(). --spec validate_credit(cb_context:context(), api_float()) -> cb_context:context(). +-spec validate_credit(cb_context:context(), kz_term:api_float()) -> cb_context:context(). validate_credit(Context) -> Amount = kz_json:get_float_value(<<"amount">>, cb_context:req_data(Context)), {'ok', MasterAccountId} = kapps_util:get_master_account_id(), @@ -374,7 +374,7 @@ validate_credit(Context, _) -> cb_context:set_resp_status(Context, 'success'). -spec validate_debit(cb_context:context()) -> cb_context:context(). --spec validate_debit(cb_context:context(), api_float()) -> cb_context:context(). +-spec validate_debit(cb_context:context(), kz_term:api_float()) -> cb_context:context(). validate_debit(Context) -> Amount = kz_json:get_float_value(<<"amount">>, cb_context:req_data(Context)), @@ -423,7 +423,7 @@ validate_debit(Context, Amount) -> %% %% @end %%-------------------------------------------------------------------- --spec fetch_transactions(cb_context:context(), gregorian_seconds(), gregorian_seconds(), api_binary()) -> +-spec fetch_transactions(cb_context:context(), kz_time:gregorian_seconds(), kz_time:gregorian_seconds(), kz_term:api_binary()) -> cb_context:context(). fetch_transactions(Context, From, To, 'undefined') -> @@ -466,7 +466,7 @@ fetch_transactions(Context, From, To, Reason) -> %% %% @end %%-------------------------------------------------------------------- --spec fetch_monthly_recurring(cb_context:context(), gregorian_seconds(), gregorian_seconds(), api_binary()) -> +-spec fetch_monthly_recurring(cb_context:context(), kz_time:gregorian_seconds(), kz_time:gregorian_seconds(), kz_term:api_binary()) -> cb_context:context(). fetch_monthly_recurring(Context, From, To, Reason) -> case kz_bookkeeper_braintree:transactions(cb_context:account_id(Context), From, To) of @@ -550,7 +550,7 @@ correct_date_braintree_subscription(BSubscription) -> ], lists:foldl(fun correct_date_braintree_subscription_fold/2, BSubscription, Keys). --spec correct_date_braintree_subscription_fold(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec correct_date_braintree_subscription_fold(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). correct_date_braintree_subscription_fold(Key, BSub) -> case kz_json:get_value(Key, BSub, 'null') of 'null' -> BSub; diff --git a/applications/crossbar/src/modules/cb_ubiquiti_auth.erl b/applications/crossbar/src/modules/cb_ubiquiti_auth.erl index c80163ff352..e8759f78cb7 100644 --- a/applications/crossbar/src/modules/cb_ubiquiti_auth.erl +++ b/applications/crossbar/src/modules/cb_ubiquiti_auth.erl @@ -165,7 +165,7 @@ login_req(Context) -> ,kz_json:delete_key(<<"username">>, Data) ). --spec auth_response(kz_proplist(), binary()) -> kz_json:object(). +-spec auth_response(kz_term:proplist(), binary()) -> kz_json:object(). auth_response(_RespHeaders, RespBody) -> RespJObj = kz_json:decode(RespBody), UUID = kz_json:get_value(<<"uuid">>, RespJObj), @@ -176,7 +176,7 @@ auth_response(_RespHeaders, RespBody) -> ) ). --spec maybe_add_account_information(api_binary(), kz_json:object()) -> kz_json:object(). +-spec maybe_add_account_information(kz_term:api_binary(), kz_json:object()) -> kz_json:object(). maybe_add_account_information('undefined', AuthResponse) -> AuthResponse; maybe_add_account_information(UUID, AuthResponse) -> diff --git a/applications/crossbar/src/modules/cb_ubiquiti_util.erl b/applications/crossbar/src/modules/cb_ubiquiti_util.erl index b7ada475754..35dd9607d44 100644 --- a/applications/crossbar/src/modules/cb_ubiquiti_util.erl +++ b/applications/crossbar/src/modules/cb_ubiquiti_util.erl @@ -27,8 +27,8 @@ -define(SECRET, kapps_config:get_ne_binary(?U_CONFIG_CAT, <<"api_secret">>)). -define(SALT_LENGTH, kapps_config:get_integer(?U_CONFIG_CAT, <<"salt_length">>, 20)). --spec create_api_token(ne_binary()) -> ne_binary(). --spec create_api_token(ne_binary(), ne_binary()) -> ne_binary(). +-spec create_api_token(kz_term:ne_binary()) -> kz_term:ne_binary(). +-spec create_api_token(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). create_api_token(ProviderId) -> create_api_token(ProviderId, ?SECRET). @@ -39,7 +39,7 @@ create_api_token(ProviderId, <<_/binary>> = Secret) -> create_api_token(_ProviderId, 'undefined') -> throw({'error', 'no_api_secret'}). --spec make_api_token(ne_binary(), integer(), ne_binary(), ne_binary()) -> ne_binary(). +-spec make_api_token(kz_term:ne_binary(), integer(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). make_api_token(ProviderId, Timestamp, Salt, Secret) -> TimestampHex = encode_timestamp(Timestamp), kz_binary:join( @@ -51,15 +51,15 @@ make_api_token(ProviderId, Timestamp, Salt, Secret) -> ,<<":">> ). --spec encode_timestamp(integer()) -> ne_binary(). +-spec encode_timestamp(integer()) -> kz_term:ne_binary(). encode_timestamp(Timestamp) when is_integer(Timestamp) -> kz_term:to_lower_binary(integer_to_list(Timestamp, 16)). --spec decode_timestamp(ne_binary()) -> integer(). +-spec decode_timestamp(kz_term:ne_binary()) -> integer(). decode_timestamp(<<_/binary>> = TimestampHex) -> list_to_integer(binary_to_list(TimestampHex), 16). --spec auth_hash(ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> ne_binary(). +-spec auth_hash(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). auth_hash(ProviderId, TimestampHex, Salt, Secret) -> Auth = kz_term:to_lower_binary( kz_binary:hexencode( @@ -76,7 +76,7 @@ auth_hash(ProviderId, TimestampHex, Salt, Secret) -> kz_binary:hexencode(Hash). --spec split_api_token(ne_binary()) -> {ne_binary(), integer(), ne_binary()}. +-spec split_api_token(kz_term:ne_binary()) -> {kz_term:ne_binary(), integer(), kz_term:ne_binary()}. split_api_token(Token) -> [?VERSION, Salt, TimestampHex, Auth] = binary:split(kz_term:to_lower_binary(Token), <<":">>, ['global']), {Salt, decode_timestamp(TimestampHex), Auth}. diff --git a/applications/crossbar/src/modules/cb_user_auth.erl b/applications/crossbar/src/modules/cb_user_auth.erl index 46f772ee414..037f87618bc 100644 --- a/applications/crossbar/src/modules/cb_user_auth.erl +++ b/applications/crossbar/src/modules/cb_user_auth.erl @@ -155,7 +155,7 @@ validate(Context) -> _Status -> Context1 end. --spec validate_action(cb_context:context(), api_ne_binary()) -> cb_context:context(). +-spec validate_action(cb_context:context(), kz_term:api_ne_binary()) -> cb_context:context(). validate_action(Context, 'undefined') -> cb_context:validate_request_data(<<"user_auth">>, Context, fun maybe_authenticate_user/1); validate_action(Context, ?SWITCH_USER) -> @@ -230,7 +230,7 @@ post(Context, ?RECOVERY) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec maybe_get_auth_token(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec maybe_get_auth_token(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). maybe_get_auth_token(Context, AuthToken) -> case AuthToken =:= cb_context:auth_token(Context) of 'true' -> @@ -245,7 +245,7 @@ maybe_get_auth_token(Context, AuthToken) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec create_auth_resp(cb_context:context(), ne_binary(), ne_binary()) -> +-spec create_auth_resp(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). create_auth_resp(Context, AccountId, AccountId) -> lager:debug("account ~s is same as auth account", [AccountId]), @@ -269,7 +269,7 @@ create_auth_resp(Context, _AccountId, _AuthAccountId) -> %% @end %%-------------------------------------------------------------------- -spec maybe_authenticate_user(cb_context:context()) -> cb_context:context(). --spec maybe_authenticate_user(cb_context:context(), ne_binary(), ne_binary(), ne_binary()) -> +-spec maybe_authenticate_user(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). maybe_authenticate_user(Context) -> JObj = cb_context:doc(Context), @@ -322,7 +322,7 @@ maybe_authenticate_user(Context, _Creds, _Method, Account) -> crossbar_auth:log_failed_auth(?MODULE, <<"credentials">>, Reason, Context, Account), cb_context:add_system_error('invalid_credentials', Context). --spec maybe_auth_account(cb_context:context(), ne_binary(), ne_binary(), ne_binary()) -> +-spec maybe_auth_account(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). maybe_auth_account(Context, Credentials, Method, Account) -> Context1 = maybe_authenticate_user(Context, Credentials, Method, Account), @@ -332,7 +332,7 @@ maybe_auth_account(Context, Credentials, Method, Account) -> _Status -> Context1 end. --spec maybe_auth_accounts(cb_context:context(), ne_binary(), ne_binary(), ne_binaries()) -> +-spec maybe_auth_accounts(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binaries()) -> cb_context:context(). maybe_auth_accounts(Context, _, _, []) -> lager:debug("no account(s) specified"), @@ -346,7 +346,7 @@ maybe_auth_accounts(Context, Credentials, Method, [Account|Accounts]) -> maybe_auth_accounts(Context, Credentials, Method, Accounts) end. --spec maybe_account_is_expired(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec maybe_account_is_expired(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). maybe_account_is_expired(Context, Account) -> case kz_util:is_account_expired(Account) of 'false' -> maybe_account_is_enabled(Context, Account); @@ -363,7 +363,7 @@ maybe_account_is_expired(Context, Account) -> cb_context:add_validation_error(<<"account">>, <<"expired">>, Cause, Context) end. --spec maybe_account_is_enabled(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec maybe_account_is_enabled(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). maybe_account_is_enabled(Context, Account) -> case kz_util:is_account_enabled(Account) of 'true' -> Context; @@ -378,7 +378,7 @@ maybe_account_is_enabled(Context, Account) -> cb_context:add_validation_error(<<"account">>, <<"disabled">>, Cause, Context) end. --spec load_sha1_results(cb_context:context(), kz_json:objects() | kz_json:object(), ne_binary())-> +-spec load_sha1_results(cb_context:context(), kz_json:objects() | kz_json:object(), kz_term:ne_binary())-> cb_context:context(). load_sha1_results(Context, [JObj|_], _Account)-> lager:debug("found more that one user with SHA1 creds, using ~s", [kz_doc:id(JObj)]), @@ -392,7 +392,7 @@ load_sha1_results(Context, JObj, _Account)-> lager:debug("found SHA1 credentials belong to user ~s", [kz_doc:id(JObj)]), cb_context:set_doc(cb_context:store(Context, 'auth_type', <<"credentials">>), kz_json:get_value(<<"value">>, JObj)). --spec load_md5_results(cb_context:context(), kz_json:objects() | kz_json:object(), ne_binary()) -> +-spec load_md5_results(cb_context:context(), kz_json:objects() | kz_json:object(), kz_term:ne_binary()) -> cb_context:context(). load_md5_results(Context, [JObj|_], _Account) -> lager:debug("found more that one user with MD5 creds, using ~s", [kz_doc:id(JObj)]), @@ -421,7 +421,7 @@ maybe_load_user_doc_via_creds(Context) -> end. %% @private --spec maybe_load_user_doc_by_username(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec maybe_load_user_doc_by_username(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). maybe_load_user_doc_by_username(Account, Context) -> JObj = cb_context:doc(Context), AccountDb = kz_util:format_account_db(Account), @@ -529,7 +529,7 @@ maybe_load_user_doc_via_reset_id(Context) -> end. %% @private --spec reset_id(ne_binary()) -> ne_binary(). +-spec reset_id(kz_term:ne_binary()) -> kz_term:ne_binary(). reset_id(?MATCH_MODB_SUFFIX_ENCODED(A, B, Rest, YYYY, MM)) -> <> = YYYY, <> = MM, @@ -553,7 +553,7 @@ reset_id(< ne_binary(). +-spec reset_link(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). reset_link(UIURL, ResetId) -> case binary:match(UIURL, <<$?>>) of 'nomatch' -> <>, ResetId} @@ -576,8 +576,8 @@ create_resetid_doc(ResetId, UserId) -> %% %% @end %%-------------------------------------------------------------------- --spec find_account(api_binary(), api_binary(), api_binary(), cb_context:context()) -> - {'ok', ne_binary() | ne_binaries()} | +-spec find_account(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), cb_context:context()) -> + {'ok', kz_term:ne_binary() | kz_term:ne_binaries()} | {'error', cb_context:context()}. find_account('undefined', 'undefined', 'undefined', Context) -> {'error', Context}; @@ -615,7 +615,7 @@ find_account(PhoneNumber, AccountRealm, AccountName, Context) -> find_account('undefined', AccountRealm, AccountName, ErrorContext) end. --spec error_no_account_phone_number(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec error_no_account_phone_number(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). error_no_account_phone_number(Context, PhoneNumber) -> Msg = kz_json:from_list( @@ -624,7 +624,7 @@ error_no_account_phone_number(Context, PhoneNumber) -> ]), cb_context:add_validation_error(<<"phone_number">>, <<"not_found">>, Msg, Context). --spec error_no_account_realm(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec error_no_account_realm(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). error_no_account_realm(Context, AccountRealm) -> Msg = kz_json:from_list( @@ -633,7 +633,7 @@ error_no_account_realm(Context, AccountRealm) -> ]), cb_context:add_validation_error(<<"account_realm">>, <<"not_found">>, Msg, Context). --spec error_no_account_name(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec error_no_account_name(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). error_no_account_name(Context, AccountName) -> Msg = kz_json:from_list( diff --git a/applications/crossbar/src/modules/cb_vmboxes.erl b/applications/crossbar/src/modules/cb_vmboxes.erl index f77ca419c62..c3a4de51be2 100644 --- a/applications/crossbar/src/modules/cb_vmboxes.erl +++ b/applications/crossbar/src/modules/cb_vmboxes.erl @@ -123,7 +123,7 @@ resource_exists(_, ?MESSAGES_RESOURCE, _, ?BIN_DATA) -> 'true'. %% %% @end %%-------------------------------------------------------------------- --spec acceptable_content_types() -> kz_proplist(). +-spec acceptable_content_types() -> kz_term:proplist(). acceptable_content_types() -> ?ALL_MIME_TYPES. -spec content_types_accepted(cb_context:context(), path_token(), path_token()) -> cb_context:context(). @@ -139,7 +139,7 @@ content_types_accepted(Context, _VMBox, ?MESSAGES_RESOURCE, _) -> Context. content_types_accepted(Context, _VMBox, ?MESSAGES_RESOURCE, _MsgId, ?BIN_DATA) -> maybe_add_types_accepted(Context, ?BIN_DATA, cb_context:req_verb(Context)). --spec maybe_add_types_accepted(cb_context:context(), ne_binary(), http_method()) -> cb_context:context(). +-spec maybe_add_types_accepted(cb_context:context(), kz_term:ne_binary(), http_method()) -> cb_context:context(). maybe_add_types_accepted(Context, _, ?HTTP_PUT) -> CTA = [{'from_binary', ?UPLOAD_MIME_TYPES}], cb_context:set_content_types_accepted(Context, CTA); @@ -171,7 +171,7 @@ content_types_provided(Context, _VMBox, ?MESSAGES_RESOURCE, _) -> Context. content_types_provided(Context, _VMBox, ?MESSAGES_RESOURCE, _MsgID, ?BIN_DATA) -> maybe_add_types_provided(Context, ?BIN_DATA, cb_context:req_verb(Context)). --spec maybe_add_types_provided(cb_context:context(), ne_binary(), http_method()) -> cb_context:context(). +-spec maybe_add_types_provided(cb_context:context(), kz_term:ne_binary(), http_method()) -> cb_context:context(). maybe_add_types_provided(Context, _, ?HTTP_PUT) -> Context; maybe_add_types_provided(Context, ?BIN_DATA, ?HTTP_POST) -> CTP = [{'send_file', ?BULK_DOWNLOAD_MIME_TYPE}], @@ -287,7 +287,7 @@ validate_message(Context, BoxId, MessageId, ?HTTP_DELETE) -> validate(Context, DocId, ?MESSAGES_RESOURCE, MediaId, ?BIN_DATA) -> load_or_upload(DocId, MediaId, Context, cb_context:req_verb(Context)). --spec load_or_upload(ne_binary(), ne_binary(), cb_context:context(), http_method()) -> cb_context:context(). +-spec load_or_upload(kz_term:ne_binary(), kz_term:ne_binary(), cb_context:context(), http_method()) -> cb_context:context(). load_or_upload(DocId, MediaId, Context, ?HTTP_PUT) -> C1 = load_message(MediaId, DocId, Context), case cb_context:resp_status(C1) of @@ -441,7 +441,7 @@ add_pvt_auth_funs(Context) -> %% and inform client to do migrate their vmbox %% @end %%-------------------------------------------------------------------- --spec check_mailbox_for_messages_array(cb_context:context(), api_objects()) -> cb_context:context(). +-spec check_mailbox_for_messages_array(cb_context:context(), kz_term:api_objects()) -> cb_context:context(). check_mailbox_for_messages_array(Context, 'undefined') -> Context; check_mailbox_for_messages_array(Context, []) -> Context; check_mailbox_for_messages_array(Context, VMBoxMsgs) -> @@ -489,7 +489,7 @@ save_attachment(Context, Filename, FileJObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_folder_filter(cb_context:context(), ne_binary()) -> kvm_message:vm_folder(). +-spec get_folder_filter(cb_context:context(), kz_term:ne_binary()) -> kvm_message:vm_folder(). get_folder_filter(Context, Default) -> ReqData = cb_context:req_data(Context), QS = cb_context:query_string(Context), @@ -510,10 +510,10 @@ get_folder_filter(Context, Default) -> %% Note: Filter can be <<"all">> which return all messages. %% @end %%-------------------------------------------------------------------- --type filter_options() :: kvm_message:vm_folder() | ne_binaries(). +-type filter_options() :: kvm_message:vm_folder() | kz_term:ne_binaries(). --spec filter_messages(kz_json:objects(), filter_options(), cb_context:context()) -> ne_binaries(). --spec filter_messages(kz_json:objects(), filter_options(), cb_context:context(), ne_binaries()) -> ne_binaries(). +-spec filter_messages(kz_json:objects(), filter_options(), cb_context:context()) -> kz_term:ne_binaries(). +-spec filter_messages(kz_json:objects(), filter_options(), cb_context:context(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). filter_messages(Messages, {?VM_FOLDER_DELETED, _}, Context) -> %% move to delete folder and soft-delete filter_messages(Messages, ?VM_FOLDER_DELETED, Context, []); @@ -550,7 +550,7 @@ filter_messages([Mess|Messages], Filters, Context, Selected) -> 'false' -> filter_messages(Messages, Filters, Context, Selected) end. --spec validate_media_binary(cb_context:context(), kz_proplist(), boolean()) -> cb_context:context(). +-spec validate_media_binary(cb_context:context(), kz_term:proplist(), boolean()) -> cb_context:context(). validate_media_binary(Context, [], 'false') -> Context; validate_media_binary(Context, [], 'true') -> cb_context:add_validation_error(<<"file">> @@ -582,7 +582,7 @@ maybe_normalize_upload(Context, FileJObj) -> normalize_upload(Context, FileJObj) -> normalize_upload(Context, FileJObj, kz_json:get_ne_binary_value([<<"headers">>, <<"content_type">>], FileJObj)). --spec normalize_upload(cb_context:context(), kz_json:object(), api_binary()) -> cb_context:context(). +-spec normalize_upload(cb_context:context(), kz_json:object(), kz_term:api_binary()) -> cb_context:context(). normalize_upload(Context, FileJObj, UploadContentType) -> FromExt = kz_mime:to_extension(UploadContentType), ToExt = normalization_format(Context), @@ -595,7 +595,7 @@ normalize_upload(Context, FileJObj, UploadContentType) -> cb_modules_util:normalize_media_upload(Context, FromExt, ToExt, FileJObj, [{'to_args', <<"-r 16000">>}]), UpdatedContext. --spec normalization_format(cb_context:context()) -> ne_binary(). +-spec normalization_format(cb_context:context()) -> kz_term:ne_binary(). normalization_format(Context) -> BoxId = kzd_box_message:source_id(cb_context:doc(Context)), AccountDb = kz_util:format_account_db(cb_context:account_id(Context)), @@ -610,7 +610,7 @@ normalization_format(Context) -> %% %% @end %%-------------------------------------------------------------------- --spec validate_request(api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_request(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_request(VMBoxId, Context) -> validate_unique_vmbox(VMBoxId, Context). @@ -620,8 +620,8 @@ validate_request(VMBoxId, Context) -> %% %% @end %%-------------------------------------------------------------------- --spec validate_unique_vmbox(api_binary(), cb_context:context()) -> cb_context:context(). --spec validate_unique_vmbox(api_binary(), cb_context:context(), api_binary()) -> cb_context:context(). +-spec validate_unique_vmbox(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_unique_vmbox(kz_term:api_binary(), cb_context:context(), kz_term:api_binary()) -> cb_context:context(). validate_unique_vmbox(VMBoxId, Context) -> validate_unique_vmbox(VMBoxId, Context, cb_context:account_db(Context)). @@ -642,7 +642,7 @@ validate_unique_vmbox(VMBoxId, Context, _AccountDb) -> %% %% @end %%-------------------------------------------------------------------- --spec check_vmbox_schema(api_binary(), cb_context:context()) -> cb_context:context(). +-spec check_vmbox_schema(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_vmbox_schema(VMBoxId, Context) -> Context1 = maybe_migrate_notification_emails(Context), OnSuccess = fun(C) -> on_successful_validation(VMBoxId, C) end, @@ -676,7 +676,7 @@ maybe_migrate_notification_emails(Context) -> %% %% @end %%-------------------------------------------------------------------- --spec on_successful_validation(api_binary(), cb_context:context()) -> +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> Props = [{<<"pvt_type">>, kzd_voicemail_box:type()}], @@ -690,7 +690,7 @@ on_successful_validation(VMBoxId, Context) -> %% Support PATCH - merge vmbox document with request data %% @end %%-------------------------------------------------------------------- --spec validate_patch(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec validate_patch(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). validate_patch(Context, DocId)-> crossbar_doc:patch_and_validate(DocId, Context, fun validate_request/2). @@ -737,7 +737,7 @@ merge_summary_fold(BoxSummary, CountMap) -> %% Load a vmbox document from the database %% @end %%-------------------------------------------------------------------- --type source_id() :: api_binary() | api_binaries(). +-type source_id() :: kz_term:api_binary() | kz_term:api_binaries(). -spec maybe_load_vmboxes(source_id(), cb_context:context()) -> cb_context:context(). -spec maybe_load_vmboxes_fold(source_id(), cb_context:context()) -> cb_context:context(). @@ -763,7 +763,7 @@ maybe_load_vmboxes_fold([Id|Ids], Context) -> C1 end. --spec load_vmbox(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_vmbox(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_vmbox(DocId, Context) -> C1 = crossbar_doc:load(DocId, Context, ?TYPE_CHECK_OPTION(kzd_voicemail_box:type())), cb_context:set_resp_data(C1, kz_json:delete_key(?VM_KEY_MESSAGES, cb_context:resp_data(C1))). @@ -779,7 +779,7 @@ empty_source_id(Context) -> %% Get messages summary for a given mailbox %% @end %%-------------------------------------------------------------------- --spec load_message_summary(api_binary(), cb_context:context()) -> cb_context:context(). +-spec load_message_summary(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). load_message_summary(BoxId, Context) -> {MaxRange, RetentionSeconds} = get_max_range(Context), RetentionTimestamp = kz_time:now_s() - RetentionSeconds, @@ -799,7 +799,7 @@ prefix_qs_filter_keys(Context) -> ), cb_context:set_query_string(Context, NewQs). --spec prefix_filter_key(ne_binary(), any()) -> {ne_binary(), any()}. +-spec prefix_filter_key(kz_term:ne_binary(), any()) -> {kz_term:ne_binary(), any()}. prefix_filter_key(<<"filter_not_", Key/binary>>, Val) -> {<<"filter_not_metadata.", Key/binary>>, Val}; prefix_filter_key(<<"filter_", Key/binary>>, Val) -> @@ -813,7 +813,7 @@ prefix_filter_key(<<"has_value">>, Key) -> prefix_filter_key(Key, Value) -> {Key, Value}. --spec message_summary_normalizer(api_binary(), kz_json:object(), kz_json:objects(), gregorian_seconds()) -> +-spec message_summary_normalizer(kz_term:api_binary(), kz_json:object(), kz_json:objects(), kz_time:gregorian_seconds()) -> kz_json:objects(). message_summary_normalizer('undefined', JObj, Acc, RetentionTimestamp) -> [kz_json:from_list( @@ -839,7 +839,7 @@ message_summary_normalizer(_BoxId, JObj, Acc, RetentionTimestamp) -> %% If `created_from` is set, use default Crossbar max range. %% @end %%-------------------------------------------------------------------- --spec get_max_range(cb_context:context()) -> {api_seconds(), gregorian_seconds()}. +-spec get_max_range(cb_context:context()) -> {kz_time:api_seconds(), kz_time:gregorian_seconds()}. get_max_range(Context) -> RetentionSeconds = kvm_util:retention_seconds(cb_context:account_id(Context)), case cb_context:req_value(Context, <<"created_from">>) of @@ -853,11 +853,11 @@ get_max_range(Context) -> %% Get message by its media ID and its context %% @end %%-------------------------------------------------------------------- --spec load_message(api_binary(), ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_message(kz_term:api_binary(), kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_message(MessageId, BoxId, Context) -> load_message(MessageId, BoxId, Context, 'false'). --spec load_message(ne_binary(), ne_binary(), cb_context:context(), boolean()) -> cb_context:context(). +-spec load_message(kz_term:ne_binary(), kz_term:ne_binary(), cb_context:context(), boolean()) -> cb_context:context(). load_message(MessageId, BoxId, Context, ReturnMetadata) -> case kvm_message:fetch(cb_context:account_id(Context), MessageId, BoxId) of {'ok', Msg} when ReturnMetadata -> @@ -868,7 +868,7 @@ load_message(MessageId, BoxId, Context, ReturnMetadata) -> crossbar_doc:handle_datamgr_errors(Error, MessageId, Context) end. --spec validate_new_message(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_new_message(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). validate_new_message(BoxId, Context) -> C1 = load_vmbox(BoxId, Context), case cb_context:resp_status(C1) of @@ -925,7 +925,7 @@ create_new_message_document(Context, BoxJObj) -> %% VMId is the id for the voicemail document, containing the binary data %% @end %%-------------------------------------------------------------------- --spec load_message_binary(ne_binary(), ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_message_binary(kz_term:ne_binary(), kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_message_binary(BoxId, MediaId, Context) -> case kvm_message:fetch(cb_context:account_id(Context), MediaId, BoxId) of {'ok', JObj} -> @@ -949,7 +949,7 @@ load_message_binary(BoxId, MediaId, Context) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec load_attachment_from_message(kz_json:object(), cb_context:context(), ne_binary()) -> +-spec load_attachment_from_message(kz_json:object(), cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_attachment_from_message(Doc, Context, Timezone) -> MediaId = kz_doc:id(Doc), @@ -978,7 +978,7 @@ load_attachment_from_message(Doc, Context, Timezone) -> cb_context:setters(Context, Setters) end. --spec load_messages_binaries(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_messages_binaries(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_messages_binaries(BoxId, Context) -> WorkDir = kz_term:to_list(<<"/tmp/", (cb_context:req_id(Context))/binary, "/">>), Ids = kz_json:get_value(?VM_KEY_MESSAGES, cb_context:req_data(Context), []), @@ -996,7 +996,7 @@ load_messages_binaries(BoxId, Context) -> maybe_create_zip_file(WorkDir, Context) end. --spec save_attachments_to_file(ne_binaries(), ne_binary(), cb_context:context(), ne_binary(), string()) -> +-spec save_attachments_to_file(kz_term:ne_binaries(), kz_term:ne_binary(), cb_context:context(), kz_term:ne_binary(), string()) -> cb_context:context(). save_attachments_to_file([], _, Context, _, _) -> Context; save_attachments_to_file([Id|Ids], BoxId, Context, Timezone, WorkDir) -> @@ -1012,7 +1012,7 @@ save_attachments_to_file([Id|Ids], BoxId, Context, Timezone, WorkDir) -> cb_context:add_system_error('unspecified_fault', Context) end. --spec save_attachment_to_file(ne_binary(), ne_binary(), cb_context:context(), ne_binary(), string()) -> +-spec save_attachment_to_file(kz_term:ne_binary(), kz_term:ne_binary(), cb_context:context(), kz_term:ne_binary(), string()) -> 'ok' | {atom(), any()}. save_attachment_to_file(MsgId, BoxId, Context, Timezone, WorkDir) -> case kvm_message:fetch(cb_context:account_id(Context), MsgId, BoxId) of @@ -1087,7 +1087,7 @@ del_all_files(Dir) -> %% CallerID_YYYY-MM-DD_HH-MM-SS.ext %% @end %%-------------------------------------------------------------------- --spec generate_media_name(api_binary(), ne_binary(), ne_binary(), ne_binary()) -> ne_binary(). +-spec generate_media_name(kz_term:api_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). generate_media_name('undefined', GregorianSeconds, Ext, Timezone) -> generate_media_name(<<"unknown">>, GregorianSeconds, Ext, Timezone); generate_media_name(CallerId, GregorianSeconds, Ext, Timezone) -> @@ -1105,8 +1105,8 @@ generate_media_name(CallerId, GregorianSeconds, Ext, Timezone) -> %% %% @end %%-------------------------------------------------------------------- --spec check_uniqueness(api_binary(), cb_context:context()) -> boolean(). --spec check_uniqueness(api_binary(), cb_context:context(), pos_integer()) -> boolean(). +-spec check_uniqueness(kz_term:api_binary(), cb_context:context()) -> boolean(). +-spec check_uniqueness(kz_term:api_binary(), cb_context:context(), pos_integer()) -> boolean(). check_uniqueness(VMBoxId, Context) -> try kz_json:get_integer_value(<<"mailbox">>, cb_context:req_data(Context)) of Mailbox -> @@ -1141,8 +1141,8 @@ check_uniqueness(VMBoxId, Context, Mailbox) -> %% %% @end %%-------------------------------------------------------------------- --spec update_mwi(cb_context:context(), ne_binary() | ne_binaries()) -> cb_context:context(). --spec update_mwi(cb_context:context(), ne_binary() | ne_binaries(), atom()) -> cb_context:context(). +-spec update_mwi(cb_context:context(), kz_term:ne_binary() | kz_term:ne_binaries()) -> cb_context:context(). +-spec update_mwi(cb_context:context(), kz_term:ne_binary() | kz_term:ne_binaries(), atom()) -> cb_context:context(). update_mwi(Context, BoxId) when is_binary(BoxId) -> update_mwi(Context, [BoxId]); update_mwi(Context, []) -> Context; @@ -1179,7 +1179,7 @@ maybe_migrate_vm_box(Box) -> %% %% @end %%-------------------------------------------------------------------- --spec migrate(ne_binary()) -> 'ok'. +-spec migrate(kz_term:ne_binary()) -> 'ok'. migrate(Account) -> AccountDb = kz_util:format_account_id(Account, 'encoded'), case kz_datamgr:get_results(AccountDb, ?CB_LIST, ['include_docs']) of @@ -1195,7 +1195,7 @@ migrate(Account) -> %% %% @end %%-------------------------------------------------------------------- --spec maybe_migrate_boxes(ne_binary(), kz_json:objects()) -> 'ok'. +-spec maybe_migrate_boxes(kz_term:ne_binary(), kz_json:objects()) -> 'ok'. maybe_migrate_boxes(AccountDb, Boxes) -> ToUpdate = lists:foldl(fun(View, Acc) -> @@ -1217,7 +1217,7 @@ maybe_migrate_boxes(AccountDb, Boxes) -> %% %% @end %%-------------------------------------------------------------------- --spec maybe_update_boxes(ne_binary(), kz_json:objects()) -> 'ok'. +-spec maybe_update_boxes(kz_term:ne_binary(), kz_json:objects()) -> 'ok'. maybe_update_boxes(_AccountDb, []) -> 'ok'; maybe_update_boxes(AccountDb, Boxes) -> case kz_datamgr:save_docs(AccountDb, Boxes) of diff --git a/applications/crossbar/src/modules/cb_webhooks.erl b/applications/crossbar/src/modules/cb_webhooks.erl index e77e6bf95ea..b882710aa8c 100644 --- a/applications/crossbar/src/modules/cb_webhooks.erl +++ b/applications/crossbar/src/modules/cb_webhooks.erl @@ -74,7 +74,7 @@ init_master_account_db() -> lager:warning("master account not set yet, unable to load view and revise schema: ~p", [_E]) end. --spec maybe_revise_schema(ne_binary()) -> 'ok'. +-spec maybe_revise_schema(kz_term:ne_binary()) -> 'ok'. maybe_revise_schema(MasterAccountDb) -> case kz_json_schema:load(<<"webhooks">>) of {'ok', SchemaJObj} -> maybe_revise_schema(MasterAccountDb, SchemaJObj); @@ -82,7 +82,7 @@ maybe_revise_schema(MasterAccountDb) -> lager:warning("failed to find webhooks schema: ~p", [_E]) end. --spec maybe_revise_schema(ne_binary(), kz_json:object()) -> 'ok'. +-spec maybe_revise_schema(kz_term:ne_binary(), kz_json:object()) -> 'ok'. maybe_revise_schema(MasterDb, SchemaJObj) -> case kz_datamgr:get_results(MasterDb, ?AVAILABLE_HOOKS) of {'ok', []} -> @@ -101,7 +101,7 @@ maybe_revise_schema(MasterDb, SchemaJObj) -> ]) end. --spec revise_schema(kz_json:object(), ne_binaries()) -> 'ok'. +-spec revise_schema(kz_json:object(), kz_term:ne_binaries()) -> 'ok'. revise_schema(SchemaJObj, HNs) -> HookNames = [<<"all">> | HNs], Updated = kz_json:set_value([<<"properties">>, <<"hook">>, <<"enum">>], HookNames, SchemaJObj), @@ -215,7 +215,7 @@ validate_webhook(Context, WebhookId, ?HTTP_DELETE) -> validate(Context, WebhookId=?NE_BINARY, ?PATH_TOKEN_ATTEMPTS) -> summary_attempts(Context, WebhookId). --spec validate_patch(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec validate_patch(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). validate_patch(Context, WebhookId) -> case cb_context:resp_status(Context) of 'success' -> @@ -247,13 +247,13 @@ patch(Context, WebhookId) -> delete(Context, _) -> crossbar_doc:delete(cb_context:set_account_db(Context, ?KZ_WEBHOOKS_DB)). --spec delete_account(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec delete_account(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). delete_account(Context, AccountId) -> lager:debug("account ~s deleted, removing any webhooks", [AccountId]), kz_util:spawn(fun delete_account_webhooks/1, [AccountId]), Context. --spec delete_account_webhooks(ne_binary()) -> 'ok'. +-spec delete_account_webhooks(kz_term:ne_binary()) -> 'ok'. delete_account_webhooks(AccountId) -> case fetch_account_hooks(AccountId) of {'ok', []} -> 'ok'; @@ -264,7 +264,7 @@ delete_account_webhooks(AccountId) -> lager:debug("deleted ~p hooks from account ~s", [length(ViewJObjs), AccountId]) end. --spec fetch_account_hooks(ne_binary()) -> kazoo_data:get_results_return(). +-spec fetch_account_hooks(kz_term:ne_binary()) -> kazoo_data:get_results_return(). fetch_account_hooks(AccountId) -> ViewOptions = [{'key', AccountId}, {'reduce', 'false'}], kz_datamgr:get_results(?KZ_WEBHOOKS_DB, <<"webhooks/accounts_listing">>, ViewOptions). @@ -289,7 +289,7 @@ create(Context) -> cb_context:validate_request_data(<<"webhooks">>, Context, OnSuccess). -spec validate_collection_patch(cb_context:context()) -> cb_context:context(). --spec validate_collection_patch(cb_context:context(), api_boolean()) -> +-spec validate_collection_patch(cb_context:context(), kz_term:api_boolean()) -> cb_context:context(). validate_collection_patch(Context) -> validate_collection_patch(Context, cb_context:req_value(Context, ?REENABLE)). @@ -316,7 +316,7 @@ reenable_validation_error(Context) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec read(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec read(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). read(Id, Context) -> Context1 = crossbar_doc:load(Id, Context, ?TYPE_CHECK_OPTION(kzd_webhook:type())), case cb_context:resp_status(Context1) of @@ -337,7 +337,7 @@ maybe_leak_pvt_fields(Context) -> %% valid %% @end %%-------------------------------------------------------------------- --spec update(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec update(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). update(Id, Context) -> OnSuccess = fun(C) -> on_successful_validation(Id, C) end, cb_context:validate_request_data(<<"webhooks">>, Context, OnSuccess). @@ -373,7 +373,7 @@ summary_available(Context) -> normalize_available(Context, JObj, Acc) -> maybe_filter_non_admin_hooks(Context, kz_doc:id(JObj), kz_json:get_value(<<"doc">>, JObj), Acc). --spec maybe_filter_non_admin_hooks(cb_context:context(), ne_binary(), kz_json:object(), kz_json:objects()) -> kz_json:objects(). +-spec maybe_filter_non_admin_hooks(cb_context:context(), kz_term:ne_binary(), kz_json:object(), kz_json:objects()) -> kz_json:objects(). maybe_filter_non_admin_hooks(_, <<"webhooks_skel">>, _, Acc) -> Acc; maybe_filter_non_admin_hooks(Context, <<"webhooks_notifications">>, JObj, Acc) -> [kz_doc:set_id(maybe_filter_non_admin_notifications(Context, JObj), <<"notifications">>) | Acc]; @@ -395,7 +395,7 @@ filter_non_admin_notifications({_, _}, 'true') -> filter_non_admin_notifications({Name, _}, 'false') -> not lists:member(Name, ?NOTIFY_SUPER_ADMIN_ONLY). --spec summary_attempts(cb_context:context(), api_ne_binary()) -> cb_context:context(). +-spec summary_attempts(cb_context:context(), kz_term:api_ne_binary()) -> cb_context:context(). summary_attempts(Context, HookId) -> ViewName = get_view_name(HookId), Options = [{'mapper', fun normalize_attempt_results/2} @@ -404,7 +404,7 @@ summary_attempts(Context, HookId) -> ], crossbar_view:load_modb(Context, ViewName, Options). --spec get_view_name(api_ne_binary()) -> ne_binary(). +-spec get_view_name(kz_term:api_ne_binary()) -> kz_term:ne_binary(). get_view_name('undefined') -> ?ATTEMPTS_BY_ACCOUNT; get_view_name(_) -> ?ATTEMPTS_BY_HOOK. @@ -422,7 +422,7 @@ normalize_attempt_results(JObj, Acc) -> %% %% @end %%-------------------------------------------------------------------- --spec on_successful_validation(api_binary(), cb_context:context()) -> +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> Props = [{<<"pvt_type">>, kzd_webhook:type()} @@ -443,13 +443,13 @@ check_modifiers(Context) -> check_modifiers(Context, JObj, kz_json:get_value(<<"modifiers">>, HookDefinition)) end. --spec check_modifiers(cb_context:context(), kz_json:object(), api_object()) -> cb_context:context(). +-spec check_modifiers(cb_context:context(), kz_json:object(), kz_term:api_object()) -> cb_context:context(). check_modifiers(Context, _, 'undefined') -> Context; check_modifiers(Context, JObj, Modifiers) -> kz_json:foldl(fun(K, V, Acc) -> check_modifiers(JObj, K, V, Acc) end, Context, Modifiers). --spec check_modifiers(kz_json:object(), ne_binary(), kz_json:object(), cb_context:context()) -> cb_context:context(). +-spec check_modifiers(kz_json:object(), kz_term:ne_binary(), kz_json:object(), cb_context:context()) -> cb_context:context(). check_modifiers(Hook, ModifierKey, ModifierValue, Context) -> case kz_json:get_value([<<"custom_data">>, ModifierKey], Hook) of 'undefined' -> @@ -460,7 +460,7 @@ check_modifiers(Hook, ModifierKey, ModifierValue, Context) -> check_modifier_values(CustomValue, ModifierKey, ModifierValue, Type, Context) end. --spec check_modifier_values(ne_binary(), ne_binary(), kz_json:object(), ne_binary(), cb_context:context()) -> cb_context:context(). +-spec check_modifier_values(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). check_modifier_values(CustomValue, ModifierKey, ModifierValue, <<"array">>, Context) -> Items = kz_json:get_value(<<"items">>, ModifierValue, []), case lists:member(CustomValue, Items) of @@ -490,14 +490,14 @@ check_modifier_values(CustomValue, ModifierKey, ModifierValue, <<"object">>, Con Context end. --spec get_hook_definition(ne_binary()) -> api_object(). +-spec get_hook_definition(kz_term:ne_binary()) -> kz_term:api_object(). get_hook_definition(HookEvent) -> case kapps_util:get_master_account_db() of {'ok', MasterDb} -> get_hook_definition(HookEvent, MasterDb); {'error', _} -> 'undefined' end. --spec get_hook_definition(ne_binary(), ne_binary()) -> api_object(). +-spec get_hook_definition(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_object(). get_hook_definition(HookEvent, MasterDb) -> case kz_datamgr:open_doc(MasterDb, <<"webhooks_", HookEvent/binary>>) of {'ok', JObj} -> JObj; @@ -523,7 +523,7 @@ maybe_update_hook(Context) -> -spec reenable_hooks(cb_context:context()) -> cb_context:context(). --spec reenable_hooks(cb_context:context(), ne_binaries()) -> +-spec reenable_hooks(cb_context:context(), kz_term:ne_binaries()) -> cb_context:context(). reenable_hooks(Context) -> reenable_hooks(Context, props:get_value(<<"accounts">>, cb_context:req_nouns(Context))). @@ -533,7 +533,7 @@ reenable_hooks(Context, [AccountId]) -> reenable_hooks(Context, [AccountId, ?DESCENDANTS]) -> handle_resp(Context, send_reenable_req(Context, AccountId, ?DESCENDANTS)). --spec send_reenable_req(cb_context:context(), ne_binary(), ne_binary()) -> +-spec send_reenable_req(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_amqp_worker:request_return(). send_reenable_req(Context, AccountId, Action) -> Req = [{<<"Type">>, kzd_webhook:type()} diff --git a/applications/crossbar/src/modules/cb_websockets.erl b/applications/crossbar/src/modules/cb_websockets.erl index cf616a99392..c9924f28bc5 100644 --- a/applications/crossbar/src/modules/cb_websockets.erl +++ b/applications/crossbar/src/modules/cb_websockets.erl @@ -211,7 +211,7 @@ summary(Context) -> %% Load an instance from the database %% @end %%-------------------------------------------------------------------- --spec read(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec read(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). read(Id, Context) -> websockets_req(Context, [{<<"Socket-ID">>, Id}]). @@ -220,7 +220,7 @@ read(Id, Context) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec websockets_req(cb_context:context(), kz_proplist()) -> cb_context:context(). +-spec websockets_req(cb_context:context(), kz_term:proplist()) -> cb_context:context(). websockets_req(Context, Props) -> Req = [{<<"Msg-ID">>, cb_context:req_id(Context)} | kz_api:default_headers(?APP_NAME, ?APP_VERSION) diff --git a/applications/crossbar/src/modules/cb_whitelabel.erl b/applications/crossbar/src/modules/cb_whitelabel.erl index 8c3c4c2bdfe..a3849430ca8 100644 --- a/applications/crossbar/src/modules/cb_whitelabel.erl +++ b/applications/crossbar/src/modules/cb_whitelabel.erl @@ -177,7 +177,7 @@ authenticate(_Nouns, _Verb) -> %% @end %%-------------------------------------------------------------------- --spec acceptable_content_types() -> kz_proplist(). +-spec acceptable_content_types() -> kz_term:proplist(). acceptable_content_types() -> ?WHITELABEL_WELCOME_MIME_TYPES ++ ?WHITELABEL_ICON_MIME_TYPES. @@ -197,7 +197,7 @@ content_types_provided_for_attachments(Context, ?WELCOME_REQ, ?HTTP_GET) -> content_types_provided_for_attachments(Context, _Type, _Verb) -> Context. --spec content_types_provided_for_attachments(cb_context:context(), ne_binary()) -> +-spec content_types_provided_for_attachments(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). content_types_provided_for_attachments(Context, AttachType) -> Context1 = load_whitelabel_meta(Context, ?WHITELABEL_ID), @@ -381,7 +381,7 @@ validate_upload(Context, FileJObj) -> _Status -> Context1 end. --spec content_type(kz_json:object()) -> ne_binary(). +-spec content_type(kz_json:object()) -> kz_term:ne_binary(). content_type(FileJObj) -> kz_json:get_value([<<"headers">>, <<"content_type">>] ,FileJObj @@ -412,9 +412,9 @@ validate_domains(Context, ?HTTP_POST) -> -spec load_domains(cb_context:context()) -> cb_context:context(). --spec load_domains(cb_context:context(), api_binary()) -> +-spec load_domains(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). --spec load_domains(cb_context:context(), ne_binary(), kz_json:object()) -> +-spec load_domains(cb_context:context(), kz_term:ne_binary(), kz_json:object()) -> cb_context:context(). load_domains(Context) -> load_domains(Context, find_domain(Context)). @@ -441,14 +441,14 @@ missing_domain_error(Context) -> ,Context ). --spec find_domain(cb_context:context()) -> api_binary(). +-spec find_domain(cb_context:context()) -> kz_term:api_binary(). find_domain(Context) -> case cb_context:req_value(Context, <<"domain">>) of 'undefined' -> find_existing_domain(Context); Domain -> Domain end. --spec find_existing_domain(cb_context:context()) -> api_binary(). +-spec find_existing_domain(cb_context:context()) -> kz_term:api_binary(). find_existing_domain(Context) -> Context1 = load_whitelabel_meta(Context, ?WHITELABEL_ID), case cb_context:resp_status(Context1) of @@ -524,12 +524,12 @@ test_account_domains(Context, DomainsJObj) -> ), crossbar_util:response(TestResults, Context). --spec test_domains(ne_binary(), kz_json:object(), kz_network_utils:options()) -> - {ne_binary(), kz_json:object()}. +-spec test_domains(kz_term:ne_binary(), kz_json:object(), kz_network_utils:options()) -> + {kz_term:ne_binary(), kz_json:object()}. test_domains(DomainType, DomainConfig, Options) -> {DomainType, test_domain_config(DomainType, DomainConfig, Options)}. --spec test_domain_config(ne_binary(), kz_json:object(), kz_network_utils:options()) -> +-spec test_domain_config(kz_term:ne_binary(), kz_json:object(), kz_network_utils:options()) -> kz_json:object(). test_domain_config(DomainType, DomainConfig, Options) -> kz_json:map(fun(Host, HostConfig) -> @@ -538,7 +538,7 @@ test_domain_config(DomainType, DomainConfig, Options) -> ,DomainConfig ). --spec test_host(ne_binary(), kz_json:object(), ne_binary(), kz_network_utils:options()) -> +-spec test_host(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary(), kz_network_utils:options()) -> kz_json:object(). test_host(Host, HostConfig, DomainType, Options) -> kz_json:from_list([{<<"expected">>, kzd_domains:mappings(HostConfig)} @@ -546,8 +546,8 @@ test_host(Host, HostConfig, DomainType, Options) -> ,{<<"name">>, kzd_domains:name(HostConfig)} ]). --spec lookup(ne_binary(), ne_binary(), kz_network_utils:options()) -> - ne_binaries(). +-spec lookup(kz_term:ne_binary(), kz_term:ne_binary(), kz_network_utils:options()) -> + kz_term:ne_binaries(). lookup(Host, DomainType, Options) -> Type = kz_term:to_atom(kz_term:to_lower_binary(DomainType)), {'ok', Lookup} = kz_network_utils:lookup_dns(Host, Type, Options), @@ -555,11 +555,11 @@ lookup(Host, DomainType, Options) -> format_lookup_results(Type, Lookup). -spec format_lookup_results(atom(), [inet_res:dns_data()]) -> - ne_binaries(). + kz_term:ne_binaries(). format_lookup_results(Type, Lookup) -> [format_lookup_result(Type, Result) || Result <- Lookup]. --spec format_lookup_result(atom(), inet_res:dns_data()) -> ne_binary(). +-spec format_lookup_result(atom(), inet_res:dns_data()) -> kz_term:ne_binary(). format_lookup_result('naptr', {_, _, _, _, _, _}=NAPTR) -> kz_network_utils:naptrtuple_to_binary(NAPTR); format_lookup_result('srv', {_, _, _, _}=Srv) -> @@ -631,7 +631,7 @@ delete(Context) -> %% Load the binary attachment of a whitelabel doc (based on a domain) %% @end %%-------------------------------------------------------------------- --spec find_whitelabel(cb_context:context(), ne_binary()) -> +-spec find_whitelabel(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). find_whitelabel(Context, Domain) -> ViewOptions = [{'key', kz_term:to_lower_binary(Domain)}], @@ -664,11 +664,11 @@ find_whitelabel(Context, Domain) -> %% Load a whitelabel document from the database %% @end %%-------------------------------------------------------------------- --spec load_whitelabel_meta(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec load_whitelabel_meta(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_whitelabel_meta(Context, WhitelabelId) -> crossbar_doc:load(WhitelabelId, Context, ?TYPE_CHECK_OPTION(<<"whitelabel">>)). --spec find_whitelabel_meta(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec find_whitelabel_meta(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). find_whitelabel_meta(Context, Domain) -> Context1 = find_whitelabel(Context, Domain), case cb_context:resp_status(Context1) of @@ -682,7 +682,7 @@ find_whitelabel_meta(Context, Domain) -> %% Load a whitelabel binary attachment from the database %% @end %%-------------------------------------------------------------------- --spec load_whitelabel_binary(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec load_whitelabel_binary(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_whitelabel_binary(Context, AttachType) -> case whitelabel_binary_meta(Context, AttachType) of 'undefined' -> crossbar_util:response_bad_identifier(AttachType, Context); @@ -690,7 +690,7 @@ load_whitelabel_binary(Context, AttachType) -> update_response_with_attachment(Context, AttachmentId, JObj) end. --spec find_whitelabel_binary(cb_context:context(), ne_binary(), ne_binary()) -> cb_context:context(). +-spec find_whitelabel_binary(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). find_whitelabel_binary(Context, Domain, AttachType) -> Context1 = find_whitelabel_meta(Context, Domain), case kz_doc:id(cb_context:doc(Context)) =:= ?WHITELABEL_ID @@ -700,8 +700,8 @@ find_whitelabel_binary(Context, Domain, AttachType) -> 'false' -> Context1 end. --spec find_whitelabel_binary_meta(cb_context:context(), ne_binary(), ne_binary()) -> - 'undefined' | {ne_binary(), kz_json:object()}. +-spec find_whitelabel_binary_meta(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> + 'undefined' | {kz_term:ne_binary(), kz_json:object()}. find_whitelabel_binary_meta(Context, Domain, AttachType) -> Context1 = find_whitelabel_meta(Context, Domain), case kz_doc:id(cb_context:doc(Context)) =:= ?WHITELABEL_ID @@ -711,8 +711,8 @@ find_whitelabel_binary_meta(Context, Domain, AttachType) -> 'false' -> 'undefined' end. --spec whitelabel_binary_meta(cb_context:context(), ne_binary()) -> - 'undefined' | {ne_binary(), kz_json:object()}. +-spec whitelabel_binary_meta(cb_context:context(), kz_term:ne_binary()) -> + 'undefined' | {kz_term:ne_binary(), kz_json:object()}. whitelabel_binary_meta(Context, AttachType) -> case kz_doc:id(cb_context:doc(Context)) =:= ?WHITELABEL_ID orelse cb_context:resp_status(Context) =:= 'success' @@ -727,12 +727,12 @@ whitelabel_binary_meta(Context, AttachType) -> 'false' -> 'undefined' end. --spec whitelabel_attachment_id(kz_json:object(), ne_binary()) -> - 'undefined' | {ne_binary(), kz_json:object()}. +-spec whitelabel_attachment_id(kz_json:object(), kz_term:ne_binary()) -> + 'undefined' | {kz_term:ne_binary(), kz_json:object()}. whitelabel_attachment_id(JObj, AttachType) -> filter_attachment_type(kz_json:get_keys(JObj), AttachType). --spec filter_attachment_type(ne_binaries(), ne_binary()) -> api_binary(). +-spec filter_attachment_type(kz_term:ne_binaries(), kz_term:ne_binary()) -> kz_term:api_binary(). filter_attachment_type([], _) -> 'undefined'; filter_attachment_type([AttachmentId], <<"logo">>) -> %% if there is only one attachment and it is not an icon @@ -748,7 +748,7 @@ filter_attachment_type([AttachmentId|AttachmentIds], AttachType) -> _Else -> filter_attachment_type(AttachmentIds, AttachType) end. --spec update_response_with_attachment(cb_context:context(), ne_binary(), kz_json:object()) -> +-spec update_response_with_attachment(cb_context:context(), kz_term:ne_binary(), kz_json:object()) -> cb_context:context(). update_response_with_attachment(Context, AttachmentId, JObj) -> LoadedContext = crossbar_doc:load_attachment(cb_context:doc(Context), AttachmentId, ?TYPE_CHECK_OPTION(<<"whitelabel">>), Context), @@ -766,11 +766,11 @@ update_response_with_attachment(Context, AttachmentId, JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec validate_request(cb_context:context(), api_binary()) -> cb_context:context(). +-spec validate_request(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). validate_request(Context, WhitelabelId) -> validate_unique_domain(Context, WhitelabelId). --spec validate_unique_domain(cb_context:context(), api_binary()) -> cb_context:context(). +-spec validate_unique_domain(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). validate_unique_domain(Context, WhitelabelId) -> Domain = kz_json:get_ne_value(<<"domain">>, cb_context:req_data(Context)), case is_domain_unique(cb_context:account_id(Context), Domain) of @@ -788,12 +788,12 @@ validate_unique_domain(Context, WhitelabelId) -> check_whitelabel_schema(Context1, WhitelabelId) end. --spec check_whitelabel_schema(cb_context:context(), api_binary()) -> cb_context:context(). +-spec check_whitelabel_schema(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). check_whitelabel_schema(Context, WhitelabelId) -> OnSuccess = fun(C) -> on_successful_validation(C, WhitelabelId) end, cb_context:validate_request_data(<<"whitelabel">>, Context, OnSuccess). --spec on_successful_validation(cb_context:context(), api_binary()) -> cb_context:context(). +-spec on_successful_validation(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). on_successful_validation(Context, 'undefined') -> Doc = kz_json:set_values([{<<"pvt_type">>, <<"whitelabel">>} ,{<<"_id">>, ?WHITELABEL_ID} @@ -815,7 +815,7 @@ on_successful_validation(Context, WhitelabelId) -> %% Update the binary attachment of a whitelabel doc %% @end %%-------------------------------------------------------------------- --spec update_whitelabel_binary(ne_binary(), path_token(), cb_context:context()) -> +-spec update_whitelabel_binary(kz_term:ne_binary(), path_token(), cb_context:context()) -> cb_context:context(). update_whitelabel_binary(AttachType, WhitelabelId, Context) -> JObj = cb_context:doc(Context), @@ -845,8 +845,8 @@ update_whitelabel_binary(AttachType, WhitelabelId, Context) -> %% it has an extension (for the associated content type) %% @end %%-------------------------------------------------------------------- --spec attachment_name(ne_binary(), ne_binary()) -> ne_binary(). --spec attachment_name(ne_binary(), ne_binary(), ne_binary()) -> ne_binary(). +-spec attachment_name(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). +-spec attachment_name(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). attachment_name(Filename, CT) -> Generators = [fun(A) -> case kz_term:is_empty(A) of @@ -873,7 +873,7 @@ attachment_name(AttachType, Filename, CT) -> %% %% @end %%-------------------------------------------------------------------- --spec is_domain_unique(ne_binary(), ne_binary()) -> boolean(). +-spec is_domain_unique(kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_domain_unique(AccountId, Domain) -> ViewOptions = [{'key', kz_term:to_lower_binary(Domain)}], case kz_datamgr:get_results(?KZ_ACCOUNTS_DB, ?AGG_VIEW_WHITELABEL_DOMAIN, ViewOptions) of diff --git a/applications/crossbar/src/modules/notification_util.erl b/applications/crossbar/src/modules/notification_util.erl index 65414dee2bf..22ae878ebc0 100644 --- a/applications/crossbar/src/modules/notification_util.erl +++ b/applications/crossbar/src/modules/notification_util.erl @@ -29,7 +29,7 @@ maybe_notify_account_change(Old, Context) -> kz_json:foreach(Notify, Changed). --spec notify_account_change(api_binary(), {ne_binary(), kz_json:object()}, cb_context:context()) -> 'ok'. +-spec notify_account_change(kz_term:api_binary(), {kz_term:ne_binary(), kz_json:object()}, cb_context:context()) -> 'ok'. notify_account_change(AccountId, {<<"zones">>, Zones}, _Context) -> lager:info("publishing zone change notification for ~p, zones: ~p", [AccountId, Zones]), Props = [{<<"Account-ID">>, AccountId} diff --git a/applications/crossbar/src/modules/provisioner_contact_list.erl b/applications/crossbar/src/modules/provisioner_contact_list.erl index 45df3475d11..e87e12244ed 100644 --- a/applications/crossbar/src/modules/provisioner_contact_list.erl +++ b/applications/crossbar/src/modules/provisioner_contact_list.erl @@ -14,15 +14,15 @@ -include("crossbar.hrl"). --record(contact, {id :: api_ne_binary() - ,callflow :: api_ne_binary() - ,name :: api_ne_binary() - ,first_module :: api_ne_binary() - ,external_numbers = [] :: ne_binaries() - ,internal_numbers = [] :: ne_binaries() +-record(contact, {id :: kz_term:api_ne_binary() + ,callflow :: kz_term:api_ne_binary() + ,name :: kz_term:api_ne_binary() + ,first_module :: kz_term:api_ne_binary() + ,external_numbers = [] :: kz_term:ne_binaries() + ,internal_numbers = [] :: kz_term:ne_binaries() }). --spec build(ne_binary()) -> kz_json:objects(). +-spec build(kz_term:ne_binary()) -> kz_json:objects(). build(AccountDb) -> [contact_to_json(Contact) || Contact <- build_contacts(AccountDb) diff --git a/applications/crossbar/src/modules/provisioner_util.erl b/applications/crossbar/src/modules/provisioner_util.erl index e6dcb410a78..80d5b656ff4 100644 --- a/applications/crossbar/src/modules/provisioner_util.erl +++ b/applications/crossbar/src/modules/provisioner_util.erl @@ -35,12 +35,12 @@ -define(JSON_HEADERS, [{"content-type", "application/json"} | ?BASE_HEADERS]). -define(FORM_HEADERS, [{"content-type", "application/x-www-form-urlencoded"} | ?BASE_HEADERS]). --spec get_mac_address(cb_context:context()) -> api_binary(). +-spec get_mac_address(cb_context:context()) -> kz_term:api_binary(). get_mac_address(Context) -> MACAddress = kz_json:get_ne_binary_value(<<"mac_address">>, cb_context:doc(Context)), cleanse_mac_address(MACAddress). --spec get_old_mac_address(cb_context:context()) -> api_binary(). +-spec get_old_mac_address(cb_context:context()) -> kz_term:api_binary(). get_old_mac_address(Context) -> MACAddress = case cb_context:fetch(Context, 'db_doc') of @@ -50,7 +50,7 @@ get_old_mac_address(Context) -> end, cleanse_mac_address(MACAddress). --spec cleanse_mac_address(api_ne_binary()) -> api_ne_binary(). +-spec cleanse_mac_address(kz_term:api_ne_binary()) -> kz_term:api_ne_binary(). cleanse_mac_address('undefined') -> 'undefined'; cleanse_mac_address(MACAddress) -> ReOptions = ['global' @@ -95,7 +95,7 @@ maybe_provision(Context, 'success') -> end; maybe_provision(_Context, _Status) -> 'false'. --spec maybe_provision_v5(cb_context:context(), ne_binary()) -> 'ok'. +-spec maybe_provision_v5(cb_context:context(), kz_term:ne_binary()) -> 'ok'. maybe_provision_v5(Context, ?HTTP_PUT) -> AuthToken = cb_context:auth_token(Context), NewDevice = cb_context:doc(Context), @@ -215,7 +215,7 @@ maybe_send_contact_list(_Context, _Status) -> 'ok'. do_full_provisioner_provider(Context) -> do_full_provision_contact_list(cb_context:account_id(Context)). --spec do_full_provision_contact_list(ne_binary() | cb_context:context()) -> boolean(). +-spec do_full_provision_contact_list(kz_term:ne_binary() | cb_context:context()) -> boolean(). do_full_provision_contact_list(AccountId) when is_binary(AccountId) -> case kz_account:fetch(AccountId) of {'ok', JObj} -> @@ -305,7 +305,7 @@ get_provision_defaults(Context) -> %% %% @end %%-------------------------------------------------------------------- --spec is_mac_address_in_use(cb_context:context(), ne_binary()) -> boolean(). +-spec is_mac_address_in_use(cb_context:context(), kz_term:ne_binary()) -> boolean(). is_mac_address_in_use(Context, MacAddress) -> case cb_context:is_context(Context) andalso get_provisioning_type() @@ -323,7 +323,7 @@ is_mac_address_in_use(Context, MacAddress) -> %% post data to a provisiong server %% @end %%-------------------------------------------------------------------- --spec do_simple_provision(ne_binary(), cb_context:context()) -> boolean(). +-spec do_simple_provision(kz_term:ne_binary(), cb_context:context()) -> boolean(). do_simple_provision(MACAddress, Context) -> JObj = cb_context:doc(Context), case kapps_config:get_string(?MOD_CONFIG_CAT, <<"provisioning_url">>) of @@ -352,21 +352,21 @@ do_simple_provision(MACAddress, Context) -> %% post data to a provisiong server %% @end %%-------------------------------------------------------------------- --spec delete_account(ne_binary() | cb_context:context()) -> boolean(). +-spec delete_account(kz_term:ne_binary() | cb_context:context()) -> boolean(). delete_account(<<_/binary>> = AccountId) -> maybe_send_to_full_provisioner(AccountId); delete_account(Context) -> delete_account(cb_context:account_id(Context)). --spec delete_full_provision(ne_binary(), cb_context:context()) -> boolean(). +-spec delete_full_provision(kz_term:ne_binary(), cb_context:context()) -> boolean(). delete_full_provision(MACAddress, Context) -> {'ok', Context1} = get_merged_device(MACAddress, Context), AccountId = kz_json:get_binary_value(<<"account_id">>, cb_context:doc(Context1)), PartialURL = <>, maybe_send_to_full_provisioner(PartialURL). --spec do_full_provision(ne_binary(), cb_context:context()) -> boolean(). +-spec do_full_provision(kz_term:ne_binary(), cb_context:context()) -> boolean(). do_full_provision(MACAddress, Context) -> {'ok', Context1} = get_merged_device(MACAddress, Context), OldMACAddress = get_old_mac_address(Context), @@ -381,8 +381,8 @@ do_full_provision(MACAddress, Context) -> PartialURL = <>, maybe_send_to_full_provisioner(PartialURL, JObj). --spec maybe_send_to_full_provisioner(ne_binary()) -> boolean(). --spec maybe_send_to_full_provisioner(ne_binary(), kz_json:object()) -> boolean(). +-spec maybe_send_to_full_provisioner(kz_term:ne_binary()) -> boolean(). +-spec maybe_send_to_full_provisioner(kz_term:ne_binary(), kz_json:object()) -> boolean(). maybe_send_to_full_provisioner(PartialURL) -> case kapps_config:get_binary(?MOD_CONFIG_CAT, <<"provisioning_url">>) of 'undefined' -> 'false'; @@ -445,13 +445,13 @@ do_awesome_provision(Context) -> %% %% @end %%-------------------------------------------------------------------- --spec get_merged_device(ne_binary(), cb_context:context()) -> +-spec get_merged_device(kz_term:ne_binary(), cb_context:context()) -> {'ok', cb_context:context()}. get_merged_device(MACAddress, Context) -> {'ok', Data} = merge_device(MACAddress, Context), {'ok', cb_context:set_doc(Context, Data)}. --spec merge_device(ne_binary(), cb_context:context()) -> +-spec merge_device(kz_term:ne_binary(), cb_context:context()) -> {'ok', kz_json:object()}. merge_device(MACAddress, Context) -> JObj = cb_context:doc(Context), @@ -469,7 +469,7 @@ merge_device(MACAddress, Context) -> MergedDevice = lists:foldl(fun(F, J) -> F(J) end, JObj, Routines), {'ok', kz_doc:public_fields(MergedDevice)}. --spec get_owner(api_binary(), ne_binary()) -> kz_json:object(). +-spec get_owner(kz_term:api_binary(), kz_term:ne_binary()) -> kz_json:object(). get_owner('undefined', _) -> kz_json:new(); get_owner(OwnerId, AccountId) -> AccountDb = kz_util:format_account_id(AccountId, 'encoded'), @@ -709,7 +709,7 @@ set_device_overrides(Context) -> %% Send awesome provisioning request %% @end %%-------------------------------------------------------------------- --spec send_provisioning_request(kz_json:object(), ne_binary()) -> 'ok'. +-spec send_provisioning_request(kz_json:object(), kz_term:ne_binary()) -> 'ok'. send_provisioning_request(Template, MACAddress) -> ProvisionRequest = kz_json:encode(Template), UrlTmpl = kapps_config:get_string(?MOD_CONFIG_CAT, <<"provisioning_url">>), @@ -729,7 +729,7 @@ send_provisioning_request(Template, MACAddress) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_provisioning_type() -> api_ne_binary(). +-spec get_provisioning_type() -> kz_term:api_ne_binary(). get_provisioning_type() -> case kapps_config:get_ne_binary(?MOD_CONFIG_CAT, <<"provisioning_type">>) of 'undefined' -> @@ -800,7 +800,7 @@ maybe_sync_sip_data(Context, 'user', 'force') -> end. %% @private --spec send_check_sync(api_binary(), api_binary(), api_binary()) -> 'ok'. +-spec send_check_sync(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary()) -> 'ok'. send_check_sync('undefined', _Realm, _MsgId) -> lager:warning("did not send check sync: username is undefined"); send_check_sync(_Username, 'undefined', _MsgId) -> @@ -813,8 +813,8 @@ send_check_sync(Username, Realm, MsgId) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]). --spec publish_check_sync(kz_proplist()) -> 'ok'. --spec publish_check_sync(api_binary(), kz_proplist()) -> 'ok'. +-spec publish_check_sync(kz_term:proplist()) -> 'ok'. +-spec publish_check_sync(kz_term:api_binary(), kz_term:proplist()) -> 'ok'. publish_check_sync('undefined', Req) -> publish_check_sync(Req); publish_check_sync(MsgId, Req) -> diff --git a/applications/crossbar/src/modules/provisioner_v5.erl b/applications/crossbar/src/modules/provisioner_v5.erl index 84a4058a117..e5798eadc41 100644 --- a/applications/crossbar/src/modules/provisioner_v5.erl +++ b/applications/crossbar/src/modules/provisioner_v5.erl @@ -26,7 +26,7 @@ %% %% @end %%-------------------------------------------------------------------- --spec update_device(kz_json:object(), ne_binary()) -> 'ok'. +-spec update_device(kz_json:object(), kz_term:ne_binary()) -> 'ok'. update_device(JObj, AuthToken) -> AccountId = kz_doc:account_id(JObj), Request = device_settings(set_owner(JObj)), @@ -38,7 +38,7 @@ update_device(JObj, AuthToken) -> ,kz_device:mac_address(JObj) ). --spec delete_device(kz_json:object(), ne_binary()) -> 'ok'. +-spec delete_device(kz_json:object(), kz_term:ne_binary()) -> 'ok'. delete_device(JObj, AuthToken) -> send_req('devices_delete' ,'undefined' @@ -89,7 +89,7 @@ get_family(JObj) -> Family -> Family end. --spec get_model(kz_json:object()) -> ne_binary(). +-spec get_model(kz_json:object()) -> kz_term:ne_binary(). get_model(JObj) -> Family = kz_json:get_binary_value([<<"provision">>, <<"endpoint_model">>], JObj, <<>>), case kz_term:to_lower_binary(Family) of @@ -116,7 +116,7 @@ get_model(JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec update_account(ne_binary(), kz_json:object(), ne_binary()) -> 'ok'. +-spec update_account(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> 'ok'. update_account(AccountId, JObj, AuthToken) -> send_req('accounts_update' ,account_settings(JObj) @@ -125,7 +125,7 @@ update_account(AccountId, JObj, AuthToken) -> ,'undefined' ). --spec delete_account(ne_binary(), ne_binary()) -> 'ok'. +-spec delete_account(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. delete_account(AccountId, AuthToken) -> send_req('accounts_delete' ,'undefined' @@ -133,7 +133,7 @@ delete_account(AccountId, AuthToken) -> ,AccountId ,'undefined' ). --spec update_account(ne_binary(), ne_binary()) -> 'ok'. +-spec update_account(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. update_account(Account, AuthToken) -> AccountId = kz_util:format_account_id(Account, 'raw'), case kz_account:fetch(AccountId) of @@ -154,14 +154,14 @@ account_settings(JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec update_user(ne_binary(), kz_json:object(), ne_binary()) -> 'ok'. +-spec update_user(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> 'ok'. update_user(AccountId, JObj, AuthToken) -> case kz_doc:type(JObj) of <<"user">> -> save_user(AccountId, JObj, AuthToken); _ -> 'ok' %% Gets rid of VMbox end. --spec save_user(ne_binary(), kz_json:object(), ne_binary()) -> 'ok'. +-spec save_user(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> 'ok'. save_user(AccountId, JObj, AuthToken) -> _ = update_account(AccountId, AuthToken), AccountDb = kz_util:format_account_id(AccountId, 'encoded'), @@ -172,7 +172,7 @@ save_user(AccountId, JObj, AuthToken) -> maybe_save_device(Device, Settings, AccountId, AuthToken) end, Devices). --spec maybe_save_device(kz_json:object(), kz_json:object(), ne_binary(), ne_binary()) -> +-spec maybe_save_device(kz_json:object(), kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | {'EXIT', _}. maybe_save_device(Device, Settings, AccountId, AuthToken) -> Request = kz_json:from_list( @@ -184,7 +184,7 @@ maybe_save_device(Device, Settings, AccountId, AuthToken) -> ]), catch save_device(AccountId, Device, Request, AuthToken). --spec save_device(ne_binary(), kz_json:object(), kz_json:object(), ne_binary()) -> 'ok'. +-spec save_device(kz_term:ne_binary(), kz_json:object(), kz_json:object(), kz_term:ne_binary()) -> 'ok'. save_device(AccountId, Device, Request, AuthToken) -> case kz_device:mac_address(Device) of 'undefined' -> 'ok'; @@ -199,7 +199,7 @@ save_device(AccountId, Device, Request, AuthToken) -> %% Return the account id a MAC address belongs to, `false' otherwise. %% @end %%-------------------------------------------------------------------- --spec check_MAC(ne_binary(), ne_binary()) -> ne_binary() | 'false'. +-spec check_MAC(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary() | 'false'. check_MAC(MacAddress, AuthToken) -> Headers = req_headers(AuthToken), UrlString = req_uri('devices', MacAddress), @@ -228,7 +228,7 @@ set_owner(JObj) -> {'error', _R} -> JObj end. --spec get_owner(api_binary(), ne_binary()) -> +-spec get_owner(kz_term:api_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. get_owner('undefined', _) -> {'error', 'undefined'}; @@ -258,7 +258,7 @@ settings(JObj) -> settings_line_keys(JObj) -> settings_line_keys(get_brand(JObj), get_family(JObj)). --spec settings_line_keys(ne_binary(), ne_binary()) -> kz_json:object(). +-spec settings_line_keys(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). settings_line_keys(<<"yealink">>, _) -> Props = props:filter_empty( [{<<"account">>, <<"1">>} @@ -327,7 +327,7 @@ settings_feature_keys(JObj) -> settings_combo_keys(JObj) -> settings_keys(?COMBO_KEYS, <<"combo_keys">>, JObj). --spec settings_keys(kz_json:object(), ne_binary(), kz_json:object()) -> kz_json:object(). +-spec settings_keys(kz_json:object(), kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). settings_keys(Assoc, KeyKind, JObj) -> FeatureKeys = kz_json:get_value([<<"provision">>, KeyKind], JObj, kz_json:new()), Brand = get_brand(JObj), @@ -372,7 +372,7 @@ get_label(Doc) -> <> end. --spec get_feature_key(ne_binary(), ne_binary(), binary(), binary(), ne_binary(), kz_json:object()) -> api_object(). +-spec get_feature_key(kz_term:ne_binary(), kz_term:ne_binary(), binary(), binary(), kz_term:ne_binary(), kz_json:object()) -> kz_term:api_object(). get_feature_key(<<"presence">>=Type, Value, Brand, Family, AccountId, Assoc) -> {'ok', UserJObj} = get_user(AccountId, Value), case kz_device:presence_id(UserJObj) of @@ -420,11 +420,11 @@ get_feature_key(<<"line">>=Type, _Value, Brand, Family, _AccountId, Assoc) -> ,{<<"account">>, get_line_key(Brand, Family)} ]). --spec get_line_key(ne_binary(), ne_binary()) -> api_binary(). +-spec get_line_key(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_binary(). get_line_key(<<"yealink">>, _) -> <<"1">>; get_line_key(_, _) -> 'undefined'. --spec get_feature_key_type(kz_json:object(), ne_binary(), binary(), binary()) -> api_object(). +-spec get_feature_key_type(kz_json:object(), kz_term:ne_binary(), binary(), binary()) -> kz_term:api_object(). get_feature_key_type(Assoc, Type, Brand, Family) -> kz_json:get_first_defined([[Brand, Family, Type] ,[Brand, <<"_">>, Type] @@ -432,13 +432,13 @@ get_feature_key_type(Assoc, Type, Brand, Family) -> ,Assoc ). --spec get_user(ne_binary(), ne_binary()) -> {'ok', kz_json:object()} | - {'error', any()}. +-spec get_user(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | + {'error', any()}. get_user(AccountId, UserId) -> AccountDb = kz_util:format_account_id(AccountId, 'encoded'), kz_datamgr:open_cache_doc(AccountDb, UserId). --spec maybe_add_feature_key(ne_binary(), api_object(), kz_json:object()) -> kz_json:object(). +-spec maybe_add_feature_key(kz_term:ne_binary(), kz_term:api_object(), kz_json:object()) -> kz_json:object(). maybe_add_feature_key(_Key, 'undefined', JObj) -> JObj; maybe_add_feature_key(Key, FeatureKey, JObj) -> kz_json:set_value(Key @@ -473,7 +473,7 @@ settings_audio(JObj) -> ], settings_audio(Codecs, Keys, kz_json:new()). --spec settings_audio(ne_binaries(), ne_binaries(), kz_json:object()) -> kz_json:object(). +-spec settings_audio(kz_term:ne_binaries(), kz_term:ne_binaries(), kz_json:object()) -> kz_json:object(). settings_audio([], _, JObj) -> JObj; settings_audio(_, [], JObj) -> JObj; settings_audio([Codec|Codecs], [Key|Keys], JObj) -> @@ -485,7 +485,7 @@ settings_audio([Codec|Codecs], [Key|Keys], JObj) -> %% Send provisioning request %% @end %%-------------------------------------------------------------------- --spec send_req(atom(), api_object(), ne_binary(), ne_binary(), api_binary()) -> 'ok'. +-spec send_req(atom(), kz_term:api_object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary()) -> 'ok'. send_req('devices_post', JObj, AuthToken, AccountId, MACAddress) -> Data = kz_json:encode(device_payload(JObj)), Headers = req_headers(AuthToken), @@ -513,13 +513,13 @@ send_req('accounts_update', JObj, AuthToken, AccountId, _) -> Resp = kz_http:post(UrlString, Headers, Data), handle_resp(Resp, AccountId, AuthToken). --spec req_uri('accounts' | 'devices', ne_binary()) -> iolist(). +-spec req_uri('accounts' | 'devices', kz_term:ne_binary()) -> iolist(). req_uri('accounts', AccountId) -> provisioning_uri([<<"accounts">>, AccountId]); req_uri('devices', MacAddress) -> provisioning_uri([<<"devices">>, <<"search">>, MacAddress]). --spec req_uri('devices', ne_binary(), ne_binary()) -> iolist(). +-spec req_uri('devices', kz_term:ne_binary(), kz_term:ne_binary()) -> iolist(). req_uri('devices', AccountId, MACAddress) -> EncodedAddress = binary:replace(MACAddress, <<":">>, <<>>, ['global']), provisioning_uri([<<"devices">>, AccountId, EncodedAddress]). @@ -530,7 +530,7 @@ provisioning_uri(ExplodedPath) -> Uri = kz_util:uri(Url, ExplodedPath), binary:bin_to_list(Uri). --spec account_payload(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec account_payload(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). account_payload(JObj, AccountId) -> ResellerId = kz_services:find_reseller_id(AccountId), kz_json:from_list( @@ -549,7 +549,7 @@ device_payload(JObj) -> ,{<<"data">>, JObj} ]). --spec handle_resp(kz_http:ret(), ne_binary(), ne_binary()) -> 'ok'. +-spec handle_resp(kz_http:ret(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. handle_resp({'ok', 200, _, Resp}, _, _) -> lager:debug("provisioning success ~s", [Resp]); handle_resp({'ok', Code, _, Resp}, AccountId, AuthToken) -> @@ -591,7 +591,7 @@ create_alert(JObj, AccountId, AuthToken) -> {ok, _} = kapps_alert:save(AlertJObj), ok. --spec req_headers(ne_binary()) -> kz_proplist(). +-spec req_headers(kz_term:ne_binary()) -> kz_term:proplist(). req_headers(Token) -> props:filter_undefined( [{"Content-Type", "application/json"} diff --git a/applications/crossbar/src/modules_v1/cb_devices_v1.erl b/applications/crossbar/src/modules_v1/cb_devices_v1.erl index e6f626a09ed..4bb55f6455d 100644 --- a/applications/crossbar/src/modules_v1/cb_devices_v1.erl +++ b/applications/crossbar/src/modules_v1/cb_devices_v1.erl @@ -251,7 +251,7 @@ load_device_summary(Context, [{<<"devices">>, []} load_device_summary(Context, _ReqNouns) -> crossbar_doc:load_view(?CB_LIST, [], Context, fun normalize_view_results/2). --spec load_users_device_summary(cb_context:context(), ne_binary()) -> +-spec load_users_device_summary(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_users_device_summary(Context, UserId) -> crossbar_doc:load_view(?OWNER_LIST @@ -266,7 +266,7 @@ load_users_device_summary(Context, UserId) -> %% %% @end %%-------------------------------------------------------------------- --spec validate_request(api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_request(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_request('undefined', Context) -> check_mac_address('undefined', Context); validate_request(DeviceId, Context) -> @@ -278,7 +278,7 @@ validate_request(DeviceId, Context) -> %% Validate payloads for actions on a device %% @end %%-------------------------------------------------------------------- --spec validate_action(cb_context:context(), ne_binary(), api_binary()) -> +-spec validate_action(cb_context:context(), kz_term:ne_binary(), kz_term:api_binary()) -> cb_context:context(). validate_action(Context, DeviceId, <<"notify">>) -> Context1 = cb_context:validate_request_data(<<"devices_notify">>, Context), @@ -298,7 +298,7 @@ changed_mac_address(Context) -> NewAddress =:= OldAddress orelse unique_mac_address(NewAddress, Context). --spec check_mac_address(api_binary(), cb_context:context()) -> cb_context:context(). +-spec check_mac_address(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_mac_address(DeviceId, Context) -> MacAddress = cb_context:req_value(Context, ?KEY_MAC_ADDRESS), case unique_mac_address(MacAddress, Context) of @@ -308,7 +308,7 @@ check_mac_address(DeviceId, Context) -> error_used_mac_address(Context) end. --spec unique_mac_address(api_binary(), cb_context:context()) -> boolean(). +-spec unique_mac_address(kz_term:api_binary(), cb_context:context()) -> boolean(). unique_mac_address('undefined', _Context) -> 'true'; unique_mac_address(MacAddress, Context) -> DbName = cb_context:account_db(Context), @@ -328,14 +328,14 @@ error_used_mac_address(Context) -> ,Context ). --spec get_mac_addresses(ne_binary()) -> ne_binaries(). +-spec get_mac_addresses(kz_term:ne_binary()) -> kz_term:ne_binaries(). get_mac_addresses(DbName) -> case kz_datamgr:get_all_results(DbName, ?CB_LIST_MAC) of {'ok', AdJObj} -> kz_datamgr:get_result_keys(AdJObj); _ -> [] end. --spec prepare_outbound_flags(api_binary(), cb_context:context()) -> +-spec prepare_outbound_flags(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). prepare_outbound_flags(DeviceId, Context) -> JObj = @@ -352,7 +352,7 @@ prepare_outbound_flags(DeviceId, Context) -> end, prepare_device_realm(DeviceId, cb_context:set_req_data(Context, JObj)). --spec prepare_device_realm(api_binary(), cb_context:context()) -> cb_context:context(). +-spec prepare_device_realm(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). prepare_device_realm(DeviceId, Context) -> AccountRealm = kz_account:fetch_realm(cb_context:account_id(Context)), Realm = cb_context:req_value(Context, [<<"sip">>, <<"realm">>], AccountRealm), @@ -364,7 +364,7 @@ prepare_device_realm(DeviceId, Context) -> validate_device_creds(Realm, DeviceId, cb_context:store(Context, 'aggregate_device', 'true')) end. --spec validate_device_creds(ne_binary(), api_binary(), cb_context:context()) -> +-spec validate_device_creds(kz_term:ne_binary(), kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_device_creds(Realm, DeviceId, Context) -> case cb_context:req_value(Context, [<<"sip">>, <<"method">>], <<"password">>) of @@ -385,7 +385,7 @@ validate_device_creds(Realm, DeviceId, Context) -> check_emergency_caller_id(DeviceId, C) end. --spec validate_device_password(ne_binary(), api_binary(), cb_context:context()) -> +-spec validate_device_password(kz_term:ne_binary(), kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_device_password(Realm, DeviceId, Context) -> Username = cb_context:req_value(Context, [<<"sip">>, <<"username">>]), @@ -403,7 +403,7 @@ validate_device_password(Realm, DeviceId, Context) -> check_emergency_caller_id(DeviceId, C) end. --spec validate_device_ip(ne_binary(), api_binary(), cb_context:context()) -> +-spec validate_device_ip(kz_term:ne_binary(), kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_device_ip(IP, DeviceId, Context) -> case kz_network_utils:is_ipv4(IP) of @@ -420,7 +420,7 @@ validate_device_ip(IP, DeviceId, Context) -> check_emergency_caller_id(DeviceId, C) end. --spec validate_device_ip_unique(ne_binary(), api_binary(), cb_context:context()) -> +-spec validate_device_ip_unique(kz_term:ne_binary(), kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_device_ip_unique(IP, DeviceId, Context) -> case cb_devices_utils:is_ip_unique(IP, DeviceId) of @@ -439,13 +439,13 @@ validate_device_ip_unique(IP, DeviceId, Context) -> check_emergency_caller_id(DeviceId, C) end. --spec check_emergency_caller_id(api_binary(), cb_context:context()) -> +-spec check_emergency_caller_id(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_emergency_caller_id(DeviceId, Context) -> Context1 = crossbar_util:format_emergency_caller_id_number(Context), check_device_schema(DeviceId, Context1). --spec check_device_schema(api_binary(), cb_context:context()) -> +-spec check_device_schema(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_device_schema(DeviceId, Context) -> OnSuccess = fun(C) -> on_successful_validation(DeviceId, C) end, @@ -454,7 +454,7 @@ check_device_schema(DeviceId, Context) -> ,OnSuccess ). --spec on_successful_validation(api_binary(), cb_context:context()) -> +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> Props = [{<<"pvt_type">>, <<"device">>}], @@ -468,7 +468,7 @@ on_successful_validation(DeviceId, Context) -> %% Load a device document from the database %% @end %%-------------------------------------------------------------------- --spec load_device(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_device(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_device(DeviceId, Context) -> crossbar_doc:load(DeviceId, Context, ?TYPE_CHECK_OPTION(kz_device:type())). @@ -506,7 +506,7 @@ normalize_view_results(JObj, Acc) -> %% accurate enough for the status icons. %% @end %%-------------------------------------------------------------------- --spec lookup_regs(ne_binary()) -> kz_json:objects(). +-spec lookup_regs(kz_term:ne_binary()) -> kz_json:objects(). lookup_regs(AccountRealm) -> Req = [{<<"Realm">>, AccountRealm} ,{<<"Fields">>, [<<"Authorizing-ID">>]} @@ -528,7 +528,7 @@ lookup_regs(AccountRealm) -> ] end. --spec extract_device_registrations(kz_json:objects()) -> ne_binaries(). +-spec extract_device_registrations(kz_json:objects()) -> kz_term:ne_binaries(). extract_device_registrations(JObjs) -> sets:to_list(extract_device_registrations(JObjs, sets:new())). @@ -550,7 +550,7 @@ extract_device_registrations([JObj|JObjs], Set) -> %% Check if the device sip creds are unique %% @end %%-------------------------------------------------------------------- --spec is_sip_creds_unique(api_binary(), ne_binary(), ne_binary(), api_binary()) -> +-spec is_sip_creds_unique(kz_term:api_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary()) -> boolean(). %% no account id and no doc id (ie initial create with no account) @@ -559,7 +559,7 @@ is_sip_creds_unique(AccountDb, Realm, Username, DeviceId) -> is_creds_locally_unique(AccountDb, Username, DeviceId) andalso is_creds_global_unique(Realm, Username, DeviceId). --spec is_creds_locally_unique(ne_binary(), ne_binary(), ne_binary()) -> boolean(). +-spec is_creds_locally_unique(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_creds_locally_unique(AccountDb, Username, DeviceId) -> ViewOptions = [{'key', kz_term:to_lower_binary(Username)}], case kz_datamgr:get_results(AccountDb, <<"devices/sip_credentials">>, ViewOptions) of @@ -569,7 +569,7 @@ is_creds_locally_unique(AccountDb, Username, DeviceId) -> _ -> 'false' end. --spec is_creds_global_unique(ne_binary(), ne_binary(), ne_binary()) -> boolean(). +-spec is_creds_global_unique(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_creds_global_unique(Realm, Username, DeviceId) -> ViewOptions = [{'key', [kz_term:to_lower_binary(Realm) ,kz_term:to_lower_binary(Username) @@ -588,8 +588,8 @@ is_creds_global_unique(Realm, Username, DeviceId) -> %% %% @end %%-------------------------------------------------------------------- --spec maybe_aggregate_device(api_binary(), cb_context:context()) -> boolean(). --spec maybe_aggregate_device(api_binary(), cb_context:context(), crossbar_status()) -> boolean(). +-spec maybe_aggregate_device(kz_term:api_binary(), cb_context:context()) -> boolean(). +-spec maybe_aggregate_device(kz_term:api_binary(), cb_context:context(), crossbar_status()) -> boolean(). maybe_aggregate_device(DeviceId, Context) -> maybe_aggregate_device(DeviceId, Context, cb_context:resp_status(Context)). maybe_aggregate_device(DeviceId, Context, 'success') -> @@ -612,8 +612,8 @@ maybe_aggregate_device(_, _, _) -> 'false'. %% %% @end %%-------------------------------------------------------------------- --spec maybe_remove_aggregate(api_binary(), cb_context:context()) -> boolean(). --spec maybe_remove_aggregate(api_binary(), cb_context:context(), crossbar_status()) -> boolean(). +-spec maybe_remove_aggregate(kz_term:api_binary(), cb_context:context()) -> boolean(). +-spec maybe_remove_aggregate(kz_term:api_binary(), cb_context:context(), crossbar_status()) -> boolean(). maybe_remove_aggregate(DeviceId, Context) -> maybe_remove_aggregate(DeviceId, Context, cb_context:resp_status(Context)). @@ -634,7 +634,7 @@ maybe_remove_aggregate(_, _, _) -> 'false'. %% Perform actions on a device %% @end %%-------------------------------------------------------------------- --spec put_action(cb_context:context(), ne_binary(), api_binary()) -> +-spec put_action(cb_context:context(), kz_term:ne_binary(), kz_term:api_binary()) -> cb_context:context(). put_action(Context, DeviceId, <<"notify">>) -> lager:debug("publishing NOTIFY for ~s", [DeviceId]), diff --git a/applications/crossbar/src/modules_v1/cb_lists_v1.erl b/applications/crossbar/src/modules_v1/cb_lists_v1.erl index f90ed291e9c..26e2dd4dd05 100644 --- a/applications/crossbar/src/modules_v1/cb_lists_v1.erl +++ b/applications/crossbar/src/modules_v1/cb_lists_v1.erl @@ -117,7 +117,7 @@ validate_list_entry(Context, ListId, EntryId, ?HTTP_POST) -> validate_list_entry(Context, _ListId, EntryId, ?HTTP_DELETE) -> crossbar_doc:load(EntryId, Context, ?TYPE_CHECK_OPTION(<<"list_entry">>)). --spec check_list_schema(api_binary(), cb_context:context()) -> cb_context:context(). +-spec check_list_schema(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_list_schema(ListId, Context) -> case cb_context:req_value(Context, <<"entries">>) of 'undefined' -> @@ -131,7 +131,7 @@ check_list_schema(ListId, Context) -> crossbar_util:response('error', <<"API changed: entries not acceptable">>, 406, Context) end. --spec filter_list_req_data({ne_binary(), any()}) -> boolean(). +-spec filter_list_req_data({kz_term:ne_binary(), any()}) -> boolean(). filter_list_req_data({Key, _Val}) when Key =:= <<"name">>; Key =:= <<"org">>; @@ -139,7 +139,7 @@ filter_list_req_data({Key, _Val}) -> 'true'; filter_list_req_data(_) -> 'false'. --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> Props = [{<<"pvt_type">>, <<"list">>}], cb_context:set_doc(Context @@ -148,13 +148,13 @@ on_successful_validation('undefined', Context) -> on_successful_validation(ListId, Context) -> crossbar_doc:load_merge(ListId, Context, ?TYPE_CHECK_OPTION(<<"list">>)). --spec check_list_entry_schema(path_token(), api_binary(), cb_context:context()) -> cb_context:context(). +-spec check_list_entry_schema(path_token(), kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_list_entry_schema(ListId, EntryId, Context) -> OnSuccess = fun(C) -> entry_schema_success(C, ListId, EntryId) end, ReqData = kz_json:set_value(<<"list_id">>, ListId, cb_context:req_data(Context)), cb_context:validate_request_data(<<"list_entries">>, cb_context:set_req_data(Context, ReqData), OnSuccess). --spec entry_schema_success(cb_context:context(), ne_binary(), ne_binary()) -> cb_context:context(). +-spec entry_schema_success(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). entry_schema_success(Context, ListId, EntryId) -> Pattern = kz_json:get_value(<<"pattern">>, cb_context:doc(Context)), case is_binary(Pattern) @@ -251,7 +251,7 @@ load_entries_and_normalize(AllEntries) -> [kz_json:set_value(<<"entries">>, entries_from_list(ListEntries), Val)|Acc] end. --spec filter_entries_by_list_id(ne_binary()) -> fun((kz_json:object()) -> boolean()). +-spec filter_entries_by_list_id(kz_term:ne_binary()) -> fun((kz_json:object()) -> boolean()). filter_entries_by_list_id(Id) -> fun(Entry) -> kz_json:get_value(<<"list_id">>, Entry) =:= Id @@ -263,7 +263,7 @@ entries_from_list(Entries) -> || X <- Entries ]). --spec load_list(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec load_list(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_list(Context, ListId) -> Entries = cb_context:doc(crossbar_doc:load_view(<<"lists/entries">> ,[{'key', ListId}] diff --git a/applications/crossbar/src/modules_v1/cb_phone_numbers_v1.erl b/applications/crossbar/src/modules_v1/cb_phone_numbers_v1.erl index 5e6c79f555a..2a5eb2a7ab7 100644 --- a/applications/crossbar/src/modules_v1/cb_phone_numbers_v1.erl +++ b/applications/crossbar/src/modules_v1/cb_phone_numbers_v1.erl @@ -340,7 +340,7 @@ normalize_view_results(JObj, Acc) -> %% resource. %% @end %%-------------------------------------------------------------------- --spec identify(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec identify(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). identify(Context, Number) -> case knm_number:lookup_account(Number) of {'error', 'not_reconcilable'} -> @@ -364,7 +364,7 @@ identify(Context, Number) -> %% @private %% @doc Load an instance from the database %%-------------------------------------------------------------------- --spec read(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec read(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). read(Context, Number) -> Options = [{'auth_by', cb_context:auth_account_id(Context)} ], @@ -486,8 +486,8 @@ set_response(CollectionJObjOrUnkown, _, Context) -> end. -spec collection_process(cb_context:context()) -> kz_json:object(). --spec collection_process(cb_context:context(), ne_binary() | ne_binaries()) -> kz_json:object(). --spec collection_process(cb_context:context(), ne_binary() | ne_binaries(), ne_binary()) -> kz_json:object(). +-spec collection_process(cb_context:context(), kz_term:ne_binary() | kz_term:ne_binaries()) -> kz_json:object(). +-spec collection_process(cb_context:context(), kz_term:ne_binary() | kz_term:ne_binaries(), kz_term:ne_binary()) -> kz_json:object(). collection_process(Context) -> Numbers = kz_json:get_value(<<"numbers">>, cb_context:req_data(Context), []), collection_process(Context, Numbers). @@ -516,7 +516,7 @@ collection_process(Context, Numbers, Action) -> ,Numbers ). --spec collection_process_action_fold(ne_binary(), kz_json:object(), cb_context:context(), ne_binary()) -> +-spec collection_process_action_fold(kz_term:ne_binary(), kz_json:object(), cb_context:context(), kz_term:ne_binary()) -> kz_json:object(). collection_process_action_fold(Number, Acc, Context, Action) -> case collection_action(Context, cb_context:req_verb(Context), Number, Action) of @@ -527,7 +527,7 @@ collection_process_action_fold(Number, Acc, Context, Action) -> kz_json:set_value([<<"error">>, Number], JObj, Acc) end. --spec collection_process_fold(ne_binary(), kz_json:object(), cb_context:context()) -> +-spec collection_process_fold(kz_term:ne_binary(), kz_json:object(), cb_context:context()) -> kz_json:object(). collection_process_fold(Number, Acc, Context) -> case collection_action(Context, cb_context:req_verb(Context), Number) of @@ -539,8 +539,8 @@ collection_process_fold(Number, Acc, Context) -> kz_json:set_value([<<"error">>, Number], JObj, Acc) end. --spec collection_action(cb_context:context(), http_method(), ne_binary()) -> knm_number_return(). --spec collection_action(cb_context:context(), http_method(), ne_binary(), ne_binary()) -> +-spec collection_action(cb_context:context(), http_method(), kz_term:ne_binary()) -> knm_number_return(). +-spec collection_action(cb_context:context(), http_method(), kz_term:ne_binary(), kz_term:ne_binary()) -> knm_number_return() | {'ok', kz_json:object()}. diff --git a/applications/crossbar/src/modules_v1/cb_users_v1.erl b/applications/crossbar/src/modules_v1/cb_users_v1.erl index 38a1796d32f..2e0ebab7f90 100644 --- a/applications/crossbar/src/modules_v1/cb_users_v1.erl +++ b/applications/crossbar/src/modules_v1/cb_users_v1.erl @@ -142,8 +142,8 @@ validate_resource(Context) -> Context. validate_resource(Context, UserId) -> validate_user_id(UserId, Context). validate_resource(Context, UserId, _) -> validate_user_id(UserId, Context). --spec validate_user_id(api_binary(), cb_context:context()) -> cb_context:context(). --spec validate_user_id(api_binary(), cb_context:context(), kz_json:object()) -> cb_context:context(). +-spec validate_user_id(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_user_id(kz_term:api_binary(), cb_context:context(), kz_json:object()) -> cb_context:context(). validate_user_id(UserId, Context) -> case kz_datamgr:open_cache_doc(cb_context:account_db(Context), UserId) of {'ok', Doc} -> validate_user_id(UserId, Context, Doc); @@ -255,7 +255,7 @@ validate_users(Context, ?HTTP_GET) -> validate_users(Context, ?HTTP_PUT) -> validate_request('undefined', Context). --spec validate_user(cb_context:context(), ne_binary(), http_method()) -> cb_context:context(). +-spec validate_user(cb_context:context(), kz_term:ne_binary(), http_method()) -> cb_context:context(). validate_user(Context, UserId, ?HTTP_GET) -> load_user(UserId, Context); validate_user(Context, UserId, ?HTTP_POST) -> @@ -272,7 +272,7 @@ post(Context, _) -> _ = provisioner_util:maybe_sync_sip_data(Context1, 'user'), crossbar_doc:save(cb_modules_util:remove_plaintext_password(Context1)). --spec post(cb_context:context(), ne_binary(), path_token()) -> cb_context:context(). +-spec post(cb_context:context(), kz_term:ne_binary(), path_token()) -> cb_context:context(). post(Context, UserId, ?PHOTO) -> [{_FileName, FileObj}] = cb_context:req_files(Context), Headers = kz_json:get_value(<<"headers">>, FileObj), @@ -404,18 +404,18 @@ vcard_fields_acc([X | Rest], Acc) -> vcard_fields_acc([], Acc) -> Acc. --spec vcard_normalize_val(binary() | {char(), binaries()}) -> binary(). +-spec vcard_normalize_val(binary() | {char(), kz_term:binaries()}) -> binary(). vcard_normalize_val({Divider, Vals}) when is_list(Vals) -> iolist_join(Divider, [vcard_escape_chars(X) || X <- Vals, X =/= 'undefined', X =/= [], X =/= <<>>]); vcard_normalize_val(Val) when is_binary(Val) -> vcard_escape_chars(Val). --spec vcard_normalize_type(list() | {ne_binary(), ne_binary()} | ne_binary()) -> ne_binary(). +-spec vcard_normalize_type(list() | {kz_term:ne_binary(), kz_term:ne_binary()} | kz_term:ne_binary()) -> kz_term:ne_binary(). vcard_normalize_type(T) when is_list(T) -> iolist_join(<<";">>, [vcard_normalize_type(X) || X <- T]); vcard_normalize_type({T, V}) -> iolist_join(<<"=">>, [T, V]); vcard_normalize_type(T) -> T. -%%-spec card_field(ne_binary(), kz_json:object()) -> {vcard_type_spec(), vcard_val()}. +%%-spec card_field(kz_term:ne_binary(), kz_json:object()) -> {vcard_type_spec(), vcard_val()}. card_field(Key, _) when Key =:= <<"BEGIN">> -> {Key, <<"VCARD">>}; @@ -480,18 +480,18 @@ card_field(Key = <<"NICKNAME">>, JObj) -> card_field(Key, JObj) -> {Key, kz_json:get_value(Key, JObj)}. --spec iolist_join(char() | binary(), binaries()) -> binary(). +-spec iolist_join(char() | binary(), kz_term:binaries()) -> binary(). iolist_join(Divider, List) -> case lists:foldl(fun iolist_join_acc/2, {Divider, []}, List) of {_, [_ | Reversed]} -> iolist_to_binary(lists:reverse(Reversed)); {_, []} -> <<>> end. --spec iolist_join_acc(binary(), {char() | binary(), binaries()}) -> {char() | binary(), binaries()}. +-spec iolist_join_acc(binary(), {char() | binary(), kz_term:binaries()}) -> {char() | binary(), kz_term:binaries()}. iolist_join_acc(E, {Divider, Acc}) -> {Divider, [Divider, E | Acc]}. --spec vcard_field_divide_by_length(binary(), binaries()) -> binaries(). +-spec vcard_field_divide_by_length(binary(), kz_term:binaries()) -> kz_term:binaries(). vcard_field_divide_by_length(<>, Acc) -> vcard_field_divide_by_length(Rest, [Row | Acc]); vcard_field_divide_by_length(Row, Acc) -> @@ -533,7 +533,7 @@ load_user_summary(Context) -> %% Load a user document from the database %% @end %%-------------------------------------------------------------------- --spec load_user(api_binary(), cb_context:context()) -> cb_context:context(). +-spec load_user(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). load_user(UserId, Context) -> crossbar_doc:load(UserId, Context, ?TYPE_CHECK_OPTION(kzd_user:type())). %%-------------------------------------------------------------------- @@ -542,15 +542,15 @@ load_user(UserId, Context) -> crossbar_doc:load(UserId, Context, ?TYPE_CHECK_OPT %% %% @end %%-------------------------------------------------------------------- --spec validate_request(api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_request(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_request(UserId, Context) -> prepare_username(UserId, Context). --spec validate_patch(api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_patch(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_patch(UserId, Context) -> crossbar_doc:patch_and_validate(UserId, Context, fun validate_request/2). --spec prepare_username(api_binary(), cb_context:context()) -> cb_context:context(). +-spec prepare_username(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). prepare_username(UserId, Context) -> JObj = cb_context:req_data(Context), case kz_json:get_ne_value(<<"username">>, JObj) of @@ -560,7 +560,7 @@ prepare_username(UserId, Context) -> check_user_name(UserId, cb_context:set_req_data(Context, JObj1)) end. --spec check_user_name(api_binary(), cb_context:context()) -> cb_context:context(). +-spec check_user_name(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_user_name(UserId, Context) -> JObj = cb_context:req_data(Context), UserName = kz_json:get_ne_value(<<"username">>, JObj), @@ -579,12 +579,12 @@ check_user_name(UserId, Context) -> check_emergency_caller_id(UserId, Context1) end. --spec check_emergency_caller_id(api_binary(), cb_context:context()) -> cb_context:context(). +-spec check_emergency_caller_id(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_emergency_caller_id(UserId, Context) -> Context1 = crossbar_util:format_emergency_caller_id_number(Context), check_user_schema(UserId, Context1). --spec is_username_unique(api_binary(), api_binary(), ne_binary()) -> boolean(). +-spec is_username_unique(kz_term:api_binary(), kz_term:api_binary(), kz_term:ne_binary()) -> boolean(). is_username_unique(AccountDb, UserId, UserName) -> ViewOptions = [{'key', UserName}], case kz_datamgr:get_results(AccountDb, ?LIST_BY_USERNAME, ViewOptions) of @@ -595,12 +595,12 @@ is_username_unique(AccountDb, UserId, UserName) -> 'false' end. --spec check_user_schema(api_binary(), cb_context:context()) -> cb_context:context(). +-spec check_user_schema(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_user_schema(UserId, Context) -> OnSuccess = fun(C) -> on_successful_validation(UserId, C) end, cb_context:validate_request_data(<<"users">>, Context, OnSuccess). --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> Props = [{<<"pvt_type">>, <<"user">>}], maybe_import_credintials('undefined' @@ -611,7 +611,7 @@ on_successful_validation('undefined', Context) -> on_successful_validation(UserId, Context) -> maybe_import_credintials(UserId, crossbar_doc:load_merge(UserId, Context, ?TYPE_CHECK_OPTION(kzd_user:type()))). --spec maybe_import_credintials(api_binary(), cb_context:context()) -> cb_context:context(). +-spec maybe_import_credintials(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). maybe_import_credintials(UserId, Context) -> JObj = cb_context:doc(Context), case kz_json:get_ne_value(<<"credentials">>, JObj) of @@ -626,7 +626,7 @@ maybe_import_credintials(UserId, Context) -> maybe_validate_username(UserId, C) end. --spec maybe_validate_username(api_binary(), cb_context:context()) -> cb_context:context(). +-spec maybe_validate_username(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). maybe_validate_username(UserId, Context) -> NewUsername = kz_json:get_ne_value(<<"username">>, cb_context:doc(Context)), CurrentUsername = case cb_context:fetch(Context, 'db_doc') of @@ -653,7 +653,7 @@ maybe_validate_username(UserId, Context) -> manditory_rehash_creds(UserId, NewUsername, C) end. --spec maybe_rehash_creds(api_binary(), api_binary(), cb_context:context()) -> cb_context:context(). +-spec maybe_rehash_creds(kz_term:api_binary(), kz_term:api_binary(), cb_context:context()) -> cb_context:context(). maybe_rehash_creds(UserId, Username, Context) -> case kz_json:get_ne_value(<<"password">>, cb_context:doc(Context)) of %% No user name or hash, no creds for you! @@ -666,7 +666,7 @@ maybe_rehash_creds(UserId, Username, Context) -> Password -> rehash_creds(UserId, Username, Password, Context) end. --spec manditory_rehash_creds(api_binary(), api_binary(), cb_context:context()) -> +-spec manditory_rehash_creds(kz_term:api_binary(), kz_term:api_binary(), cb_context:context()) -> cb_context:context(). manditory_rehash_creds(UserId, Username, Context) -> case kz_json:get_ne_value(<<"password">>, cb_context:doc(Context)) of @@ -678,7 +678,7 @@ manditory_rehash_creds(UserId, Username, Context) -> Password -> rehash_creds(UserId, Username, Password, Context) end. --spec rehash_creds(api_binary(), api_binary(), ne_binary(), cb_context:context()) -> +-spec rehash_creds(kz_term:api_binary(), kz_term:api_binary(), kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). rehash_creds(_UserId, 'undefined', _Password, Context) -> Msg = kz_json:from_list( @@ -702,7 +702,7 @@ rehash_creds(_UserId, Username, Password, Context) -> %% unique or belongs to the request being made %% @end %%-------------------------------------------------------------------- --spec username_doc_id(api_binary(), cb_context:context()) -> api_binary(). +-spec username_doc_id(kz_term:api_binary(), cb_context:context()) -> kz_term:api_binary(). username_doc_id(Username, Context) -> username_doc_id(Username, Context, cb_context:account_db(Context)). username_doc_id(_, _, 'undefined') -> diff --git a/applications/crossbar/src/modules_v2/cb_devices_v2.erl b/applications/crossbar/src/modules_v2/cb_devices_v2.erl index 155ce9a6512..ec30b028098 100644 --- a/applications/crossbar/src/modules_v2/cb_devices_v2.erl +++ b/applications/crossbar/src/modules_v2/cb_devices_v2.erl @@ -177,7 +177,7 @@ validate_resource(Context) -> Context. validate_resource(Context, ?STATUS_PATH_TOKEN) -> Context; validate_resource(Context, DeviceId) -> validate_device_id(Context, DeviceId). --spec validate_device_id(cb_context:context(), api_binary()) -> cb_context:context(). +-spec validate_device_id(cb_context:context(), kz_term:api_binary()) -> cb_context:context(). validate_device_id(Context, DeviceId) -> case kz_datamgr:open_cache_doc(cb_context:account_db(Context), DeviceId) of {'ok', _} -> cb_context:set_device_id(Context, DeviceId); @@ -345,7 +345,7 @@ load_device_summary(Context, [{<<"devices">>, []} load_device_summary(Context, _ReqNouns) -> crossbar_doc:load_view(?CB_LIST, [], Context, fun normalize_view_results/2). --spec load_users_device_summary(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec load_users_device_summary(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). load_users_device_summary(Context, UserId) -> View = ?OWNER_LIST, ViewOptions = [{'key', UserId}], @@ -357,7 +357,7 @@ load_users_device_summary(Context, UserId) -> %% %% @end %%-------------------------------------------------------------------- --spec validate_request(api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_request(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_request('undefined', Context) -> maybe_check_mdn('undefined', Context); validate_request(DeviceId, Context) -> @@ -373,7 +373,7 @@ validate_request(DeviceId, Context) -> %% Validate payloads for actions on a device %% @end %%-------------------------------------------------------------------- --spec validate_action(cb_context:context(), ne_binary(), api_binary()) -> +-spec validate_action(cb_context:context(), kz_term:ne_binary(), kz_term:api_binary()) -> cb_context:context(). validate_action(Context, DeviceId, <<"notify">>) -> Context1 = cb_context:validate_request_data(<<"devices_notify">>, Context), @@ -386,7 +386,7 @@ validate_action(Context, _, 'undefined') -> validate_action(Context, _, _) -> crossbar_util:response_400(<<"invalid action">>, kz_json:new(), Context). --spec maybe_check_mdn(api_binary(), cb_context:context()) -> cb_context:context(). +-spec maybe_check_mdn(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). maybe_check_mdn(DeviceId, Context) -> case get_device_type(Context) of <<"mobile">> -> check_mdn_undefined(DeviceId, Context); @@ -396,7 +396,7 @@ maybe_check_mdn(DeviceId, Context) -> prepare_outbound_flags(DeviceId, Context) end. --spec check_mdn_undefined(api_binary(), cb_context:context()) -> cb_context:context(). +-spec check_mdn_undefined(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_mdn_undefined(DeviceId, Context) -> case get_mdn(Context) =:= 'undefined' of 'true' -> error_mdn_undefined(Context); @@ -410,7 +410,7 @@ error_mdn_undefined(Context) -> ), cb_context:add_validation_error(?KEY_MOBILE_MDN, <<"required">>, Msg, Context). --spec check_mdn_changed(api_binary(), cb_context:context()) -> cb_context:context(). +-spec check_mdn_changed(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_mdn_changed('undefined', Context) -> check_mdn_taken('undefined', Context); check_mdn_changed(DeviceId, Context) -> @@ -435,7 +435,7 @@ error_mdn_changed(Context) -> ]), cb_context:add_validation_error(?KEY_MOBILE_MDN, <<"invalid">>, Msg, Context). --spec check_mdn_taken(api_binary(), cb_context:context()) -> cb_context:context(). +-spec check_mdn_taken(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_mdn_taken(DeviceId, Context) -> MDN = get_mdn(Context), case knm_number:get(MDN, knm_number_options:mdn_options()) of @@ -450,7 +450,7 @@ check_mdn_taken(DeviceId, Context) -> error_mdn_taken(MDN, Context) end. --spec error_mdn_taken(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec error_mdn_taken(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). error_mdn_taken(MDN, Context) -> Msg = kz_json:from_list( [{<<"message">>, <<"Mobile Device Number already exists in the system">>} @@ -458,7 +458,7 @@ error_mdn_taken(MDN, Context) -> ]), cb_context:add_validation_error(?KEY_MOBILE_MDN, <<"unique">>, Msg, Context). --spec check_mdn_registered(api_binary(), cb_context:context()) -> cb_context:context(). +-spec check_mdn_registered(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_mdn_registered(DeviceId, Context) -> %%TODO: issue API request to TOP (if configured with URL) and validate %% that the number is present in that system, if not stop the request @@ -469,7 +469,7 @@ check_mdn_registered(DeviceId, Context) -> 'false' -> prepare_outbound_flags(DeviceId, Context1) end. --spec get_mac_address(cb_context:context()) -> api_binary(). +-spec get_mac_address(cb_context:context()) -> kz_term:api_binary(). get_mac_address(Context) -> provisioner_util:cleanse_mac_address( cb_context:req_value(Context, ?KEY_MAC_ADDRESS)). @@ -481,7 +481,7 @@ changed_mac_address(Context) -> NewAddress =:= provisioner_util:cleanse_mac_address(OldAddress) orelse unique_mac_address(NewAddress, Context). --spec check_mac_address(api_binary(), cb_context:context()) -> cb_context:context(). +-spec check_mac_address(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_mac_address(DeviceId, Context) -> MacAddress = get_mac_address(Context), case unique_mac_address(MacAddress, Context) of @@ -490,7 +490,7 @@ check_mac_address(DeviceId, Context) -> prepare_outbound_flags(DeviceId, Context) end. --spec unique_mac_address(api_binary(), cb_context:context()) -> boolean(). +-spec unique_mac_address(kz_term:api_binary(), cb_context:context()) -> boolean(). unique_mac_address('undefined', _Context) -> 'true'; unique_mac_address(MacAddress, Context) -> DbName = cb_context:account_db(Context), @@ -506,7 +506,7 @@ error_used_mac_address(Context) -> ]), cb_context:add_validation_error(?KEY_MAC_ADDRESS, <<"unique">>, Msg, Context). --spec get_mac_addresses(ne_binary()) -> ne_binaries(). +-spec get_mac_addresses(kz_term:ne_binary()) -> kz_term:ne_binaries(). get_mac_addresses(DbName) -> MACs = case kz_datamgr:get_all_results(DbName, ?CB_LIST_MAC) of {'ok', AdJObj} -> kz_datamgr:get_result_keys(AdJObj); @@ -514,7 +514,7 @@ get_mac_addresses(DbName) -> end, [provisioner_util:cleanse_mac_address(MAC) || MAC <- MACs]. --spec prepare_outbound_flags(api_binary(), cb_context:context()) -> cb_context:context(). +-spec prepare_outbound_flags(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). prepare_outbound_flags(DeviceId, Context) -> JObj = case cb_context:req_value(Context, <<"outbound_flags">>) of 'undefined' -> cb_context:req_data(Context); @@ -527,7 +527,7 @@ prepare_outbound_flags(DeviceId, Context) -> end, prepare_device_realm(DeviceId, cb_context:set_req_data(Context, JObj)). --spec prepare_device_realm(api_binary(), cb_context:context()) -> cb_context:context(). +-spec prepare_device_realm(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). prepare_device_realm(DeviceId, Context) -> AccountRealm = kz_account:fetch_realm(cb_context:account_id(Context)), Realm = cb_context:req_value(Context, [<<"sip">>, <<"realm">>], AccountRealm), @@ -539,7 +539,7 @@ prepare_device_realm(DeviceId, Context) -> validate_device_creds(Realm, DeviceId, cb_context:store(Context, 'aggregate_device', 'true')) end. --spec validate_device_creds(api_binary(), api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_device_creds(kz_term:api_binary(), kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_device_creds(Realm, DeviceId, Context) -> case cb_context:req_value(Context, [<<"sip">>, <<"method">>], <<"password">>) of <<"password">> -> @@ -561,7 +561,7 @@ validate_device_creds(Realm, DeviceId, Context) -> check_emergency_caller_id(DeviceId, C) end. --spec validate_device_password(ne_binary(), api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_device_password(kz_term:ne_binary(), kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_device_password(Realm, DeviceId, Context) -> Username = cb_context:req_value(Context, [<<"sip">>, <<"username">>]), case is_sip_creds_unique(cb_context:account_db(Context), Realm, Username, DeviceId) of @@ -579,7 +579,7 @@ validate_device_password(Realm, DeviceId, Context) -> check_emergency_caller_id(DeviceId, C) end. --spec validate_device_ip(ne_binary(), api_binary(), cb_context:context()) -> +-spec validate_device_ip(kz_term:ne_binary(), kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_device_ip(IP, DeviceId, Context) -> case kz_network_utils:is_ipv4(IP) of @@ -598,7 +598,7 @@ validate_device_ip(IP, DeviceId, Context) -> check_emergency_caller_id(DeviceId, C) end. --spec validate_device_ip_unique(ne_binary(), api_binary(), cb_context:context()) -> +-spec validate_device_ip_unique(kz_term:ne_binary(), kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_device_ip_unique(IP, DeviceId, Context) -> case cb_devices_utils:is_ip_unique(IP, DeviceId) of @@ -617,12 +617,12 @@ validate_device_ip_unique(IP, DeviceId, Context) -> check_emergency_caller_id(DeviceId, C) end. --spec check_emergency_caller_id(api_binary(), cb_context:context()) -> cb_context:context(). +-spec check_emergency_caller_id(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_emergency_caller_id(DeviceId, Context) -> Context1 = crossbar_util:format_emergency_caller_id_number(Context), check_device_type_change(DeviceId, Context1). --spec check_device_type_change(api_binary(), cb_context:context()) -> cb_context:context(). +-spec check_device_type_change(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_device_type_change('undefined', Context) -> check_device_schema('undefined', Context); check_device_type_change(DeviceId, Context) -> @@ -636,7 +636,7 @@ check_device_type_change(DeviceId, Context) -> _Else -> error_device_type_change(NewDeviceType, Context) end. --spec error_device_type_change(api_binary(), cb_context:context()) -> cb_context:context(). +-spec error_device_type_change(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). error_device_type_change(DeviceType, Context) -> Msg = kz_json:from_list( @@ -645,12 +645,12 @@ error_device_type_change(DeviceType, Context) -> ]), cb_context:add_validation_error(<<"device_type">>, <<"invalid">>, Msg, Context). --spec check_device_schema(api_binary(), cb_context:context()) -> cb_context:context(). +-spec check_device_schema(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_device_schema(DeviceId, Context) -> OnSuccess = fun(C) -> on_successful_validation(DeviceId, C) end, cb_context:validate_request_data(<<"devices">>, Context, OnSuccess). --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> Props = [{<<"pvt_type">>, <<"device">>}], cb_context:set_doc(Context, kz_json:set_values(Props, cb_context:doc(Context))); @@ -663,7 +663,7 @@ on_successful_validation(DeviceId, Context) -> %% Load a device document from the database %% @end %%-------------------------------------------------------------------- --spec load_device(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec load_device(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_device(DeviceId, Context) -> crossbar_doc:load(DeviceId, Context, ?TYPE_CHECK_OPTION(kz_device:type())). @@ -700,7 +700,7 @@ normalize_view_results(JObj, Acc) -> %% accurate enough for the status icons. %% @end %%-------------------------------------------------------------------- --spec lookup_regs(ne_binary()) -> kz_json:objects(). +-spec lookup_regs(kz_term:ne_binary()) -> kz_json:objects(). lookup_regs(AccountRealm) -> Req = [{<<"Realm">>, AccountRealm} ,{<<"Fields">>, [<<"Authorizing-ID">>]} @@ -722,7 +722,7 @@ lookup_regs(AccountRealm) -> ] end. --spec extract_device_registrations(kz_json:objects()) -> ne_binaries(). +-spec extract_device_registrations(kz_json:objects()) -> kz_term:ne_binaries(). extract_device_registrations(JObjs) -> sets:to_list(extract_device_registrations(JObjs, sets:new())). @@ -744,7 +744,7 @@ extract_device_registrations([JObj|JObjs], Set) -> %% Check if the device sip creds are unique %% @end %%-------------------------------------------------------------------- --spec is_sip_creds_unique(api_binary(), ne_binary(), ne_binary(), api_binary()) -> +-spec is_sip_creds_unique(kz_term:api_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary()) -> boolean(). %% no account id and no doc id (ie initial create with no account) is_sip_creds_unique('undefined', _, _, 'undefined') -> 'true'; @@ -779,8 +779,8 @@ is_creds_global_unique(Realm, Username, DeviceId) -> %% %% @end %%-------------------------------------------------------------------- --spec maybe_aggregate_device(api_binary(), cb_context:context()) -> boolean(). --spec maybe_aggregate_device(api_binary(), cb_context:context(), crossbar_status()) -> boolean(). +-spec maybe_aggregate_device(kz_term:api_binary(), cb_context:context()) -> boolean(). +-spec maybe_aggregate_device(kz_term:api_binary(), cb_context:context(), crossbar_status()) -> boolean(). maybe_aggregate_device(DeviceId, Context) -> maybe_aggregate_device(DeviceId, Context, cb_context:resp_status(Context)). maybe_aggregate_device(DeviceId, Context, 'success') -> @@ -802,8 +802,8 @@ maybe_aggregate_device(_, _, _) -> 'false'. %% %% @end %%-------------------------------------------------------------------- --spec maybe_remove_aggregate(api_binary(), cb_context:context()) -> boolean(). --spec maybe_remove_aggregate(api_binary(), cb_context:context(), crossbar_status()) -> boolean(). +-spec maybe_remove_aggregate(kz_term:api_binary(), cb_context:context()) -> boolean(). +-spec maybe_remove_aggregate(kz_term:api_binary(), cb_context:context(), crossbar_status()) -> boolean(). maybe_remove_aggregate(DeviceId, Context) -> maybe_remove_aggregate(DeviceId, Context, cb_context:resp_status(Context)). @@ -824,7 +824,7 @@ maybe_remove_aggregate(_, _, _) -> 'false'. %% Perform actions on a device %% @end %%-------------------------------------------------------------------- --spec put_action(cb_context:context(), ne_binary(), api_binary()) -> +-spec put_action(cb_context:context(), kz_term:ne_binary(), kz_term:api_binary()) -> cb_context:context(). put_action(Context, DeviceId, <<"notify">>) -> lager:debug("publishing NOTIFY for ~s", [DeviceId]), @@ -848,7 +848,7 @@ put_action(Context, DeviceId, <<"notify">>) -> %% gets the one from request data. %% @end %%-------------------------------------------------------------------- --spec get_device_type(cb_context:context()) -> api_binary(). +-spec get_device_type(cb_context:context()) -> kz_term:api_binary(). get_device_type(Context) -> case kz_device:device_type(cb_context:fetch(Context, 'db_doc')) of 'undefined' -> @@ -908,7 +908,7 @@ remove_mobile_mdn(Context) -> MDN -> remove_if_mobile(MDN, Context) end. --spec remove_if_mobile(ne_binary(), cb_context:context()) -> cb_context:context(). +-spec remove_if_mobile(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). remove_if_mobile(MDN, Context) -> Normalized = knm_converters:normalize(MDN), case knm_number:get(Normalized, knm_number_options:mdn_options()) of @@ -935,7 +935,7 @@ remove_if_mobile(MDN, Context) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_mdn(cb_context:context()) -> api_binary(). +-spec get_mdn(cb_context:context()) -> kz_term:api_binary(). get_mdn(Context) -> ReqMDN = cb_context:req_value(Context, ?KEY_MOBILE_MDN), case kz_term:is_empty(ReqMDN) diff --git a/applications/crossbar/src/modules_v2/cb_lists_v2.erl b/applications/crossbar/src/modules_v2/cb_lists_v2.erl index 26e7e95e3d4..87a0007f0a1 100644 --- a/applications/crossbar/src/modules_v2/cb_lists_v2.erl +++ b/applications/crossbar/src/modules_v2/cb_lists_v2.erl @@ -32,7 +32,7 @@ %%%=================================================================== %%% API %%%=================================================================== --spec maybe_migrate(ne_binary()) -> 'ok'. +-spec maybe_migrate(kz_term:ne_binary()) -> 'ok'. maybe_migrate(Account) -> AccountDb = kz_util:format_account_id(Account, 'encoded'), case kz_datamgr:get_results(AccountDb, ?CB_LIST, ['include_docs']) of @@ -41,7 +41,7 @@ maybe_migrate(Account) -> {'error', _} -> 'ok' end. --spec migrate(ne_binary(), kz_json:objects()) -> 'ok'. +-spec migrate(kz_term:ne_binary(), kz_json:objects()) -> 'ok'. migrate(AccountDb, [List | Lists]) -> DocId = kz_json:get_value(<<"id">>, List), Entries = kz_json:to_proplist(kz_json:get_value([<<"doc">>, <<"entries">>], List, kz_json:new())), @@ -196,7 +196,7 @@ validate_req(?HTTP_GET, Context, [_ListId, ?ENTRIES, EntryId, ?VCARD]) -> RespData = kzd_user:to_vcard(JObj4), cb_context:set_resp_data(Context1, [RespData, "\n"]). --spec validate_doc(api_binary(), ne_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_doc(kz_term:api_binary(), kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). validate_doc(Id, Type, Context) -> OnSuccess = fun(C) -> on_successfull_validation(Id, Type, C) end, cb_context:validate_request_data(type_schema_name(Type), Context, OnSuccess). @@ -234,11 +234,11 @@ save(Context, _, ?ENTRIES, EntryId, ?PHOTO) -> %% May be move code from cb_users_v2 to crossbar_doc? cb_users_v2:post(Context, EntryId, ?PHOTO). --spec type_schema_name(ne_binary()) -> ne_binary(). +-spec type_schema_name(kz_term:ne_binary()) -> kz_term:ne_binary(). type_schema_name(?TYPE_LIST) -> <<"lists">>; type_schema_name(?TYPE_LIST_ENTRY) -> <<"list_entries">>. --spec on_successfull_validation(api_binary(), ne_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successfull_validation(kz_term:api_binary(), kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). on_successfull_validation('undefined', Type, Context) -> Doc = kz_json:set_values([{<<"pvt_type">>, Type}], cb_context:doc(Context)), cb_context:set_doc(Context, Doc); @@ -251,7 +251,7 @@ set_org(JObj, Context) -> Context1 = crossbar_doc:load(ListId, Context, ?TYPE_CHECK_OPTION(?TYPE_LIST_ENTRY)), set_org(JObj, Context1, cb_context:resp_status(Context1), ListId). --spec set_org(kz_json:object(), cb_context:context(), crossbar_status(), ne_binary()) -> kz_json:object(). +-spec set_org(kz_json:object(), cb_context:context(), crossbar_status(), kz_term:ne_binary()) -> kz_json:object(). set_org(JObj, Context, 'success', _) -> case kz_json:get_value(<<"org">>, cb_context:doc(Context)) of 'undefined' -> JObj; diff --git a/applications/crossbar/src/modules_v2/cb_phone_numbers_v2.erl b/applications/crossbar/src/modules_v2/cb_phone_numbers_v2.erl index 1d2c53428ce..f1f307b1afe 100644 --- a/applications/crossbar/src/modules_v2/cb_phone_numbers_v2.erl +++ b/applications/crossbar/src/modules_v2/cb_phone_numbers_v2.erl @@ -251,7 +251,7 @@ maybe_allow_updates(Context, _Nouns, _Verb) -> Context. validate(Context) -> validate_phone_numbers(Context, cb_context:req_verb(Context), cb_context:account_id(Context)). --spec validate_phone_numbers(cb_context:context(), http_method(), api_binary()) -> +-spec validate_phone_numbers(cb_context:context(), http_method(), kz_term:api_binary()) -> cb_context:context(). validate_phone_numbers(Context, ?HTTP_GET, 'undefined') -> maybe_find_numbers(Context); @@ -338,13 +338,13 @@ unclassified_number(Context, Number) -> ,{fun cb_context:set_resp_status/2, 'success'} ]). --spec base_classified_number(cb_context:context(), ne_binary()) -> kz_proplist(). +-spec base_classified_number(cb_context:context(), kz_term:ne_binary()) -> kz_term:proplist(). base_classified_number(_Context, Number) -> [{<<"number">>, Number} ,{<<"e164">>, knm_converters:normalize(Number)} ]. --spec classified_number(cb_context:context(), path_token(), api_binary()) -> cb_context:context(). +-spec classified_number(cb_context:context(), path_token(), kz_term:api_binary()) -> cb_context:context(). classified_number(Context, Number, Classifier) -> ClassifierJObj = kz_json:get_value(Classifier, knm_converters:available_classifiers()), BaseData = base_classified_number(Context, Number), @@ -481,7 +481,7 @@ delete(Context, Number) -> %% Lists number on GET /v2/accounts/{{ACCOUNT_ID}}/phone_numbers/{{DID}} %% @end %%-------------------------------------------------------------------- --spec summary(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec summary(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). summary(Context, Number) -> case knm_number:get(Number, [{auth_by, cb_context:auth_account_id(Context)}]) of {'ok', KNMNumber} -> @@ -490,7 +490,7 @@ summary(Context, Number) -> maybe_find_port_number(Context, Number, should_include_ports(Context)) end. --spec maybe_find_port_number(cb_context:context(), ne_binary(), boolean()) -> +-spec maybe_find_port_number(cb_context:context(), kz_term:ne_binary(), boolean()) -> cb_context:context(). maybe_find_port_number(Context, _Number, 'false') -> reply_number_not_found(Context); @@ -517,7 +517,7 @@ port_number_summary(PhoneNumber, Context, 'true') -> port_number_summary(_PhoneNumber, Context, 'false') -> reply_number_not_found(Context). --spec normalize_port_number(kz_json:object(), ne_binary(), ne_binary()) -> +-spec normalize_port_number(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> knm_phone_number_return(). normalize_port_number(JObj, Num, AuthBy) -> knm_phone_number:setters(knm_phone_number:from_number_with_options(Num, [{auth_by, AuthBy}]) @@ -642,8 +642,8 @@ maybe_find_numbers(Context) -> find_numbers(Context, AccountId, ResellerId) end. --spec pick_account_and_reseller_id(cb_context:context()) -> {ok, ne_binary(), api_ne_binary()} | - {error, ne_binary()}. +-spec pick_account_and_reseller_id(cb_context:context()) -> {ok, kz_term:ne_binary(), kz_term:api_ne_binary()} | + {error, kz_term:ne_binary()}. pick_account_and_reseller_id(Context) -> case kz_json:get_value(<<"reseller_id">>, cb_context:query_string(Context)) of 'undefined' -> @@ -658,7 +658,7 @@ pick_account_and_reseller_id(Context) -> maybe_reseller_id_lookup(ReqResellerId) end. --spec find_numbers(cb_context:context(), ne_binary(), ne_binary()) -> cb_context:context(). +-spec find_numbers(cb_context:context(), kz_term:ne_binary(), kz_term:ne_binary()) -> cb_context:context(). find_numbers(Context, AccountId, ResellerId) -> QS = cb_context:query_string(Context), Country = kz_json:get_ne_value(?COUNTRY, QS, ?KNM_DEFAULT_COUNTRY), @@ -692,8 +692,8 @@ find_numbers(Context, AccountId, ResellerId) -> Context1 = cb_context:set_req_data(Context, kz_json:from_list(Options)), cb_context:validate_request_data(?SCHEMA_FIND_NUMBERS, Context1, OnSuccess). --spec maybe_reseller_id_lookup(ne_binary()) -> {ok, ne_binary(), ne_binary()} | - {error, ne_binary()}. +-spec maybe_reseller_id_lookup(kz_term:ne_binary()) -> {ok, kz_term:ne_binary(), kz_term:ne_binary()} | + {error, kz_term:ne_binary()}. maybe_reseller_id_lookup(ReqResellerId) -> try ?UNAUTHORIZED_NUMBERS_LOOKUP(ReqResellerId) @@ -768,8 +768,8 @@ validate_collection_request(Context, _E) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_prefix(ne_binary()) -> {'ok', kz_json:object()} | - {'error', any()}. +-spec get_prefix(kz_term:ne_binary()) -> {'ok', kz_json:object()} | + {'error', any()}. get_prefix(City) -> case kapps_config:get_string(?PHONE_NUMBERS_CONFIG_CAT, ?KEY_PHONEBOOK_FREE_URL) of 'undefined' -> @@ -816,7 +816,7 @@ maybe_update_locality(Context) -> update_locality(Context, ToUpdate). %% @private --spec update_locality(cb_context:context(), ne_binaries()) -> +-spec update_locality(cb_context:context(), kz_term:ne_binaries()) -> cb_context:context(). update_locality(Context, []) -> Context; update_locality(Context, Numbers) -> @@ -834,7 +834,7 @@ update_context_locality(Context, Localities) -> JObj = kz_json:foldl(fun update_context_locality_fold/3, cb_context:resp_data(Context), Localities), cb_context:set_resp_data(Context, JObj). --spec update_context_locality_fold(ne_binary(), kz_json:object(), kz_json:object()) -> kz_json:object(). +-spec update_context_locality_fold(kz_term:ne_binary(), kz_json:object(), kz_json:object()) -> kz_json:object(). update_context_locality_fold(Key, Value, JObj) -> case kz_json:get_value(<<"status">>, Value) of <<"success">> -> @@ -861,7 +861,7 @@ update_phone_numbers_locality(Context, Localities) -> end. %% @private --spec update_phone_numbers_locality_fold(ne_binary(), kz_json:object(), kz_json:object(), cb_context:context()) -> +-spec update_phone_numbers_locality_fold(kz_term:ne_binary(), kz_json:object(), kz_json:object(), cb_context:context()) -> kz_json:object(). update_phone_numbers_locality_fold(Key, Value, JObj, Context) -> case kz_json:get_value(<<"status">>, Value) of @@ -881,7 +881,7 @@ update_phone_numbers_locality_fold(Key, Value, JObj, Context) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec identify(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec identify(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). identify(Context, Num) -> case knm_number:lookup_account(Num) of {'ok', AccountId, ExtraOptions} -> @@ -1015,7 +1015,7 @@ reply_number_not_found(Context) -> %% %% @end %%-------------------------------------------------------------------- --spec collection_process(cb_context:context(), ne_binary() | http_method()) -> knm_numbers:ret(). +-spec collection_process(cb_context:context(), kz_term:ne_binary() | http_method()) -> knm_numbers:ret(). collection_process(Context, Action) -> ReqData = cb_context:req_data(Context), Numbers = kz_json:get_value(<<"numbers">>, ReqData), @@ -1023,7 +1023,7 @@ collection_process(Context, Action) -> numbers_action(Context1, Action, Numbers). %% @private --spec numbers_action(cb_context:context(), ne_binary() | http_method(), ne_binaries()) -> knm_numbers:ret(). +-spec numbers_action(cb_context:context(), kz_term:ne_binary() | http_method(), kz_term:ne_binaries()) -> knm_numbers:ret(). numbers_action(Context, ?ACTIVATE, Numbers) -> Options = [{'auth_by', cb_context:auth_account_id(Context)} ,{'dry_run', not cb_context:accepting_charges(Context)} @@ -1071,7 +1071,7 @@ pick_release_or_delete(Context, Options) -> Pick. %% @private --spec maybe_ask_for_state(api_ne_binary()) -> [{state, ne_binary()}]. +-spec maybe_ask_for_state(kz_term:api_ne_binary()) -> [{state, kz_term:ne_binary()}]. maybe_ask_for_state(undefined) -> []; maybe_ask_for_state(StateAskedFor) -> [{state, StateAskedFor}]. diff --git a/applications/crossbar/src/modules_v2/cb_users_v2.erl b/applications/crossbar/src/modules_v2/cb_users_v2.erl index 1c42e58482e..d53606bdea4 100644 --- a/applications/crossbar/src/modules_v2/cb_users_v2.erl +++ b/applications/crossbar/src/modules_v2/cb_users_v2.erl @@ -194,8 +194,8 @@ validate_resource(Context, UserId) -> validate_user_id(UserId, Context). validate_resource(Context, UserId, _) -> validate_user_id(UserId, Context). validate_resource(Context, UserId, _, _) -> validate_user_id(UserId, Context). --spec validate_user_id(api_binary(), cb_context:context()) -> cb_context:context(). --spec validate_user_id(api_binary(), cb_context:context(), kz_json:object()) -> cb_context:context(). +-spec validate_user_id(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_user_id(kz_term:api_binary(), cb_context:context(), kz_json:object()) -> cb_context:context(). validate_user_id(UserId, Context) -> case kz_datamgr:open_cache_doc(cb_context:account_db(Context), UserId) of {'ok', Doc} -> validate_user_id(UserId, Context, Doc); @@ -282,7 +282,7 @@ post(Context, _) -> _ -> Context2 end. --spec post(cb_context:context(), ne_binary(), path_token()) -> cb_context:context(). +-spec post(cb_context:context(), kz_term:ne_binary(), path_token()) -> cb_context:context(). post(Context, UserId, ?PHOTO) -> [{_FileName, FileObj}] = cb_context:req_files(Context), Headers = kz_json:get_value(<<"headers">>, FileObj), @@ -306,7 +306,7 @@ put(Context) -> crossbar_services:maybe_dry_run(Context, Callback). -spec delete(cb_context:context(), path_token()) -> cb_context:context(). --spec delete(cb_context:context(), ne_binary(), path_token()) -> cb_context:context(). +-spec delete(cb_context:context(), kz_term:ne_binary(), path_token()) -> cb_context:context(). delete(Context, _Id) -> crossbar_doc:delete(Context). @@ -322,9 +322,9 @@ patch(Context, Id) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec load_attachment(ne_binary(), cb_context:context()) -> +-spec load_attachment(kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). --spec load_attachment(ne_binary(), ne_binary(), cb_context:context()) -> +-spec load_attachment(kz_term:ne_binary(), kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). load_attachment(AttachmentId, Context) -> Headers = @@ -461,7 +461,7 @@ fix_envelope(Context) -> %% Load a user document from the database %% @end %%-------------------------------------------------------------------- --spec load_user(api_binary(), cb_context:context()) -> cb_context:context(). +-spec load_user(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). load_user(UserId, Context) -> crossbar_doc:load(UserId, Context, ?TYPE_CHECK_OPTION(kzd_user:type())). %%-------------------------------------------------------------------- @@ -470,15 +470,15 @@ load_user(UserId, Context) -> crossbar_doc:load(UserId, Context, ?TYPE_CHECK_OPT %% %% @end %%-------------------------------------------------------------------- --spec validate_request(api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_request(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_request(UserId, Context) -> prepare_username(UserId, Context). --spec validate_patch(api_binary(), cb_context:context()) -> cb_context:context(). +-spec validate_patch(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). validate_patch(UserId, Context) -> crossbar_doc:patch_and_validate(UserId, Context, fun validate_request/2). --spec prepare_username(api_binary(), cb_context:context()) -> cb_context:context(). +-spec prepare_username(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). prepare_username(UserId, Context) -> JObj = cb_context:req_data(Context), case kz_json:get_ne_value(<<"username">>, JObj) of @@ -488,7 +488,7 @@ prepare_username(UserId, Context) -> check_user_name(UserId, cb_context:set_req_data(Context, JObj1)) end. --spec check_user_name(api_binary(), cb_context:context()) -> cb_context:context(). +-spec check_user_name(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_user_name(UserId, Context) -> JObj = cb_context:req_data(Context), UserName = kz_json:get_ne_value(<<"username">>, JObj), @@ -503,7 +503,7 @@ check_user_name(UserId, Context) -> check_emergency_caller_id(UserId, Context1) end. --spec non_unique_username_error(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec non_unique_username_error(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). non_unique_username_error(Context, Username) -> Msg = kz_json:from_list( [{<<"message">>, <<"User name is not unique for this account">>} @@ -511,12 +511,12 @@ non_unique_username_error(Context, Username) -> ]), cb_context:add_validation_error([<<"username">>], <<"unique">>, Msg, Context). --spec check_emergency_caller_id(api_binary(), cb_context:context()) -> cb_context:context(). +-spec check_emergency_caller_id(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_emergency_caller_id(UserId, Context) -> Context1 = crossbar_util:format_emergency_caller_id_number(Context), check_user_schema(UserId, Context1). --spec is_username_unique(api_binary(), api_binary(), ne_binary()) -> boolean(). +-spec is_username_unique(kz_term:api_binary(), kz_term:api_binary(), kz_term:ne_binary()) -> boolean(). is_username_unique(AccountDb, UserId, UserName) -> ViewOptions = [{'key', UserName}], case kz_datamgr:get_results(AccountDb, ?LIST_BY_USERNAME, ViewOptions) of @@ -527,12 +527,12 @@ is_username_unique(AccountDb, UserId, UserName) -> 'false' end. --spec check_user_schema(api_binary(), cb_context:context()) -> cb_context:context(). +-spec check_user_schema(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). check_user_schema(UserId, Context) -> OnSuccess = fun(C) -> on_successful_validation(UserId, C) end, cb_context:validate_request_data(<<"users">>, Context, OnSuccess). --spec on_successful_validation(api_binary(), cb_context:context()) -> cb_context:context(). +-spec on_successful_validation(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). on_successful_validation('undefined', Context) -> Props = [{<<"pvt_type">>, kzd_user:type()}], maybe_import_credintials('undefined' @@ -543,7 +543,7 @@ on_successful_validation('undefined', Context) -> on_successful_validation(UserId, Context) -> maybe_import_credintials(UserId, crossbar_doc:load_merge(UserId, Context, ?TYPE_CHECK_OPTION(kzd_user:type()))). --spec maybe_import_credintials(api_binary(), cb_context:context()) -> cb_context:context(). +-spec maybe_import_credintials(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). maybe_import_credintials(UserId, Context) -> JObj = cb_context:doc(Context), case kz_json:get_ne_value(<<"credentials">>, JObj) of @@ -558,7 +558,7 @@ maybe_import_credintials(UserId, Context) -> maybe_validate_username(UserId, C) end. --spec maybe_validate_username(api_binary(), cb_context:context()) -> cb_context:context(). +-spec maybe_validate_username(kz_term:api_binary(), cb_context:context()) -> cb_context:context(). maybe_validate_username(UserId, Context) -> JObj = cb_context:doc(Context), NewUsername = kz_json:get_ne_value(<<"username">>, JObj), @@ -583,7 +583,7 @@ maybe_validate_username(UserId, Context) -> manditory_rehash_creds(UserId, NewUsername, Context1) end. --spec maybe_rehash_creds(api_binary(), api_binary(), cb_context:context()) -> cb_context:context(). +-spec maybe_rehash_creds(kz_term:api_binary(), kz_term:api_binary(), cb_context:context()) -> cb_context:context(). maybe_rehash_creds(UserId, Username, Context) -> case kz_json:get_ne_value(<<"password">>, cb_context:doc(Context)) of %% No user name or hash, no creds for you! @@ -596,7 +596,7 @@ maybe_rehash_creds(UserId, Username, Context) -> Password -> rehash_creds(UserId, Username, Password, Context) end. --spec manditory_rehash_creds(api_binary(), api_binary(), cb_context:context()) -> +-spec manditory_rehash_creds(kz_term:api_binary(), kz_term:api_binary(), cb_context:context()) -> cb_context:context(). manditory_rehash_creds(UserId, Username, Context) -> case kz_json:get_ne_value(<<"password">>, cb_context:doc(Context)) of @@ -612,7 +612,7 @@ required_password_error(Context) -> ]), cb_context:add_validation_error(<<"password">>, <<"required">>, Msg, Context). --spec rehash_creds(api_binary(), api_binary(), ne_binary(), cb_context:context()) -> +-spec rehash_creds(kz_term:api_binary(), kz_term:api_binary(), kz_term:ne_binary(), cb_context:context()) -> cb_context:context(). rehash_creds(_UserId, 'undefined', _Password, Context) -> Msg = kz_json:from_list( @@ -638,7 +638,7 @@ rehash_creds(_UserId, Username, Password, Context) -> %% unique or belongs to the request being made %% @end %%-------------------------------------------------------------------- --spec username_doc_id(api_binary(), cb_context:context()) -> api_binary(). +-spec username_doc_id(kz_term:api_binary(), cb_context:context()) -> kz_term:api_binary(). username_doc_id(Username, Context) -> username_doc_id(Username, Context, cb_context:account_db(Context)). username_doc_id(_, _, 'undefined') -> 'undefined'; diff --git a/applications/doodle/src/doodle.hrl b/applications/doodle/src/doodle.hrl index c18ed938bf3..7632f21f2c7 100644 --- a/applications/doodle/src/doodle.hrl +++ b/applications/doodle/src/doodle.hrl @@ -19,7 +19,7 @@ ,exchange :: binary() ,type :: binary() ,queue :: binary() - ,options :: kz_proplist() + ,options :: kz_term:proplist() }). -type amqp_listener_connection() :: #amqp_listener_connection{}. diff --git a/applications/doodle/src/doodle_api.erl b/applications/doodle/src/doodle_api.erl index a47e58d844a..54c6cfb9d76 100644 --- a/applications/doodle/src/doodle_api.erl +++ b/applications/doodle/src/doodle_api.erl @@ -12,7 +12,7 @@ -include("doodle.hrl"). --spec handle_api_sms(ne_binary(), ne_binary()) -> 'ok'. +-spec handle_api_sms(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. handle_api_sms(Db, Id) -> {'ok', Doc} = kz_datamgr:open_doc(Db, Id), Status = kz_json:get_value(<<"pvt_status">>, Doc), @@ -20,12 +20,12 @@ handle_api_sms(Db, Id) -> FetchId = kz_binary:rand_hex(16), maybe_handle_sms_document(Status, Origin, FetchId, Id, Doc). --spec maybe_handle_sms_document(ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec maybe_handle_sms_document(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. maybe_handle_sms_document(<<"queued">>, <<"api">>, FetchId, Id, JObj) -> process_sms_api_document(FetchId, Id, JObj); maybe_handle_sms_document(_Status, _Origin, _FetchId, _Id, _JObj) -> 'ok'. --spec process_sms_api_document(ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec process_sms_api_document(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. process_sms_api_document(FetchId, <<_:7/binary, CallId/binary>> = _Id, APIJObj) -> ReqResp = kz_amqp_worker:call(route_req(FetchId, CallId, APIJObj) ,fun kapi_route:publish_req/1 @@ -39,7 +39,7 @@ process_sms_api_document(FetchId, <<_:7/binary, CallId/binary>> = _Id, APIJObj) send_route_win(FetchId, CallId, RespJObj) end. --spec send_route_win(ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec send_route_win(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. send_route_win(FetchId, CallId, JObj) -> ServerQ = kz_json:get_value(<<"Server-ID">>, JObj), CCVs = kz_json:get_value(<<"Custom-Channel-Vars">>, JObj, kz_json:new()), @@ -52,7 +52,7 @@ send_route_win(FetchId, CallId, JObj) -> lager:debug("sms api handler sending route_win to ~s", [ServerQ]), kz_amqp_worker:cast(Win, fun(Payload) -> kapi_route:publish_win(ServerQ, Payload) end). --spec route_req(ne_binary(), ne_binary(), kz_json:object()) -> kz_proplist(). +-spec route_req(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> kz_term:proplist(). route_req(FetchId, CallId, JObj) -> [{<<"Msg-ID">>, FetchId} ,{<<"Call-ID">>, CallId} @@ -69,7 +69,7 @@ route_req(FetchId, CallId, JObj) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]. --spec route_req_ccvs(ne_binary(), kz_json:object()) -> kz_proplist(). +-spec route_req_ccvs(kz_term:ne_binary(), kz_json:object()) -> kz_term:proplist(). route_req_ccvs(FetchId, JObj) -> props:filter_undefined( [{<<"Fetch-ID">>, FetchId} diff --git a/applications/doodle/src/doodle_app.erl b/applications/doodle/src/doodle_app.erl index 6de7ca98ac0..d40c7588671 100644 --- a/applications/doodle/src/doodle_app.erl +++ b/applications/doodle/src/doodle_app.erl @@ -20,7 +20,7 @@ %% Implement the application start behaviour %% @end %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = declare_exchanges(), case kapps_config:get_json(?CONFIG_CAT, <<"reschedule">>) =:= undefined diff --git a/applications/doodle/src/doodle_delivery_handler.erl b/applications/doodle/src/doodle_delivery_handler.erl index db7bd2ee763..58e6285f665 100644 --- a/applications/doodle/src/doodle_delivery_handler.erl +++ b/applications/doodle/src/doodle_delivery_handler.erl @@ -12,7 +12,7 @@ -include("doodle.hrl"). --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Props) -> 'true' = kapi_sms:delivery_v(JObj), _ = kz_util:put_callid(JObj), @@ -30,7 +30,7 @@ maybe_update_doc(JObj) -> end, update_doc(JObj, Value). --spec update_doc(kz_json:object(), ne_binary()) -> any(). +-spec update_doc(kz_json:object(), kz_term:ne_binary()) -> any(). update_doc(JObj, Value) -> CallId = kz_json:get_value(<<"Call-ID">>, JObj), CCVs = kz_json:get_value(<<"Custom-Channel-Vars">>, JObj), diff --git a/applications/doodle/src/doodle_doc_handler.erl b/applications/doodle/src/doodle_doc_handler.erl index a1c4915acb8..9d8b7b09f4f 100644 --- a/applications/doodle/src/doodle_doc_handler.erl +++ b/applications/doodle/src/doodle_doc_handler.erl @@ -13,7 +13,7 @@ -include("doodle.hrl"). -include_lib("kazoo_amqp/include/kapi_conf.hrl"). --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Props) -> 'true' = kapi_conf:doc_update_v(JObj), Id = kz_json:get_value(<<"ID">>, JObj), @@ -22,7 +22,7 @@ handle_req(JObj, _Props) -> Action = kz_json:get_value(<<"Event-Name">>, JObj), handle_doc(Action, Type, Db, Id). --spec handle_doc(api_binary(), api_binary(), api_binary(), api_binary()) -> 'ok'. +-spec handle_doc(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary()) -> 'ok'. handle_doc(?DOC_CREATED, <<"sms">>, Db, Id) -> doodle_api:handle_api_sms(Db, Id); handle_doc(_, <<"device">>, ?MATCH_ACCOUNT_RAW(AccountId), Id) -> diff --git a/applications/doodle/src/doodle_event_handler_sup.erl b/applications/doodle/src/doodle_event_handler_sup.erl index 830cd6415e5..3bf0f93c056 100644 --- a/applications/doodle/src/doodle_event_handler_sup.erl +++ b/applications/doodle/src/doodle_event_handler_sup.erl @@ -32,15 +32,15 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec new(any(), atom(), list()) -> sup_startchild_ret(). +-spec new(any(), atom(), list()) -> kz_types:sup_startchild_ret(). new(Name, M, A) -> supervisor:start_child(?SERVER, ?WORKER_NAME_ARGS_TYPE(Name, M, A, 'temporary')). --spec workers() -> pids(). +-spec workers() -> kz_term:pids(). workers() -> [Pid || {_, Pid, 'worker', [_]} <- supervisor:which_children(?SERVER)]. @@ -57,7 +57,7 @@ workers() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 0, diff --git a/applications/doodle/src/doodle_exe.erl b/applications/doodle/src/doodle_exe.erl index 14ec02dc1cc..6c4bc56e7c2 100644 --- a/applications/doodle/src/doodle_exe.erl +++ b/applications/doodle/src/doodle_exe.erl @@ -54,8 +54,8 @@ ,flow = kz_json:new() :: kz_json:object() ,cf_module_pid :: {pid(), reference()} | 'undefined' ,cf_module_old_pid :: {pid(), reference()} | 'undefined' - ,status = <<"sane">> :: ne_binary() - ,queue :: api_binary() + ,status = <<"sane">> :: kz_term:ne_binary() + ,queue :: kz_term:api_binary() ,self = self() }). -type state() :: #state{}. @@ -67,7 +67,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(kapps_call:call()) -> startlink_ret(). +-spec start_link(kapps_call:call()) -> kz_types:startlink_ret(). start_link(Call) -> CallId = kapps_call:call_id(Call), Bindings = [{'sms', [{'message_id', CallId} @@ -101,7 +101,7 @@ update_call(Call) -> gen_server:cast(Srv, {'update_call', Call}). -spec continue(kapps_call:call() | pid()) -> 'ok'. --spec continue(ne_binary(), kapps_call:call() | pid()) -> 'ok'. +-spec continue(kz_term:ne_binary(), kapps_call:call() | pid()) -> 'ok'. continue(Srv) -> continue(<<"_">>, Srv). continue(Key, Srv) when is_pid(Srv) -> @@ -149,15 +149,15 @@ control_usurped(Call) -> Srv = kapps_call:kvs_fetch('consumer_pid', Call), control_usurped(Srv). --spec callid_update(ne_binary(), kapps_call:call() | pid()) -> 'ok'. +-spec callid_update(kz_term:ne_binary(), kapps_call:call() | pid()) -> 'ok'. callid_update(CallId, Srv) when is_pid(Srv) -> gen_listener:cast(Srv, {'callid_update', CallId}); callid_update(CallId, Call) -> Srv = kapps_call:kvs_fetch('consumer_pid', Call), callid_update(CallId, Srv). --spec callid(kapps_call:call() | pid()) -> ne_binary(). --spec callid(api_binary(), kapps_call:call()) -> ne_binary(). +-spec callid(kapps_call:call() | pid()) -> kz_term:ne_binary(). +-spec callid(kz_term:api_binary(), kapps_call:call()) -> kz_term:ne_binary(). callid(Srv) when is_pid(Srv) -> CallId = gen_server:call(Srv, 'callid', ?MILLISECONDS_IN_SECOND), @@ -170,15 +170,15 @@ callid(Call) -> callid(_, Call) -> callid(Call). --spec queue_name(kapps_call:call() | pid()) -> ne_binary(). +-spec queue_name(kapps_call:call() | pid()) -> kz_term:ne_binary(). queue_name(Srv) when is_pid(Srv) -> gen_listener:queue_name(Srv); queue_name(Call) -> Srv = kapps_call:kvs_fetch('consumer_pid', Call), queue_name(Srv). --spec control_queue(kapps_call:call() | pid()) -> ne_binary(). --spec control_queue(api_binary(), kapps_call:call() | pid()) -> ne_binary(). +-spec control_queue(kapps_call:call() | pid()) -> kz_term:ne_binary(). +-spec control_queue(kz_term:api_binary(), kapps_call:call() | pid()) -> kz_term:ne_binary(). control_queue(Srv) when is_pid(Srv) -> gen_listener:call(Srv, 'control_queue_name'); control_queue(Call) -> control_queue(kapps_call:kvs_fetch('consumer_pid', Call)). @@ -219,7 +219,7 @@ wildcard_is_empty(Call) -> Srv = kapps_call:kvs_fetch('consumer_pid', Call), wildcard_is_empty(Srv). --spec relay_amqp(kz_json:object(), kz_proplist()) -> any(). +-spec relay_amqp(kz_json:object(), kz_term:proplist()) -> any(). relay_amqp(JObj, Props) -> Pids = case props:get_value('cf_module_pid', Props) of P when is_pid(P) -> [P | props:get_value('cf_event_pids', Props, [])]; @@ -227,7 +227,7 @@ relay_amqp(JObj, Props) -> end, [kapps_call_command:relay_event(Pid, JObj) || Pid <- Pids, is_pid(Pid)]. --spec send_amqp(pid() | kapps_call:call(), api_terms(), kz_amqp_worker:publish_fun()) -> 'ok'. +-spec send_amqp(pid() | kapps_call:call(), kz_term:api_terms(), kz_amqp_worker:publish_fun()) -> 'ok'. send_amqp(Srv, API, PubFun) when is_pid(Srv), is_function(PubFun, 1) -> gen_listener:cast(Srv, {'send_amqp', API, PubFun}); send_amqp(Call, API, PubFun) when is_function(PubFun, 1) -> @@ -270,7 +270,7 @@ init([Call]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call('get_call', _From, #state{call=Call}=State) -> {'reply', {'ok', Call}, State}; handle_call('callid', _From, #state{call=Call}=State) -> @@ -322,7 +322,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'set_call', Call}, State) -> {'noreply', State#state{call=Call}}; handle_cast({'update_call', NewCall}, #state{call=OldCall, queue=Q}=State) -> @@ -422,7 +422,7 @@ event_listener_name(Call, Module) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'DOWN', Ref, 'process', Pid, 'normal'}, #state{cf_module_pid={Pid, Ref} ,call=Call }=State) -> @@ -616,21 +616,21 @@ launch_cf_module(#state{call=Call ,call=kapps_call:kvs_store('cf_last_action', Action, Call) }. --spec cf_link('undefined' | pid_ref()) -> 'true'. +-spec cf_link('undefined' | kz_term:pid_ref()) -> 'true'. cf_link('undefined') -> 'true'; cf_link(PidRef) -> link(get_pid(PidRef)). --spec cf_module_prefix(kapps_call:call()) -> ne_binary(). +-spec cf_module_prefix(kapps_call:call()) -> kz_term:ne_binary(). cf_module_prefix(Call) -> cf_module_prefix(Call, kapps_call:resource_type(Call)). --spec cf_module_prefix(kapps_call:call(), ne_binary()) -> ne_binary(). +-spec cf_module_prefix(kapps_call:call(), kz_term:ne_binary()) -> kz_term:ne_binary(). cf_module_prefix(_Call, <<"sms">>) -> <<"cf_sms_">>; cf_module_prefix(_Call, _) -> <<"cf_">>. --spec maybe_start_cf_module(ne_binary(), kz_proplist(), kapps_call:call()) -> - {pid_ref() | 'undefined', atom()}. +-spec maybe_start_cf_module(kz_term:ne_binary(), kz_term:proplist(), kapps_call:call()) -> + {kz_term:pid_ref() | 'undefined', atom()}. maybe_start_cf_module(ModuleBin, Data, Call) -> CFModule = kz_term:to_atom(ModuleBin, 'true'), try CFModule:module_info('exports') of @@ -657,7 +657,7 @@ cf_module_skip(CFModule, _Call) -> %% @end %%-------------------------------------------------------------------- -spec spawn_cf_module(CFModule, list(), kapps_call:call()) -> - {pid_ref(), CFModule}. + {kz_term:pid_ref(), CFModule}. spawn_cf_module(CFModule, Data, Call) -> AMQPConsumer = kz_amqp_channel:consumer_pid(), {kz_util:spawn_monitor(fun cf_module_task/4, [CFModule, Data, Call, AMQPConsumer]) @@ -688,11 +688,11 @@ cf_module_task(CFModule, Data, Call, AMQPConsumer) -> %% a hangup command without relying on the (now terminated) doodle_exe. %% @end %%-------------------------------------------------------------------- --spec send_amqp_message(api_terms(), kz_amqp_worker:publish_fun(), ne_binary()) -> 'ok'. +-spec send_amqp_message(kz_term:api_terms(), kz_amqp_worker:publish_fun(), kz_term:ne_binary()) -> 'ok'. send_amqp_message(API, PubFun, Q) -> PubFun(add_server_id(API, Q)). --spec send_command(kz_proplist(), api_binary(), api_binary()) -> 'ok'. +-spec send_command(kz_term:proplist(), kz_term:api_binary(), kz_term:api_binary()) -> 'ok'. send_command(_, 'undefined', _) -> 'ok'; send_command(_, _, 'undefined') -> 'ok'; send_command(Command, ControlQ, CallId) -> @@ -701,7 +701,7 @@ send_command(Command, ControlQ, CallId) -> ], kapps_util:amqp_pool_send(Props, fun(P) -> kapi_dialplan:publish_command(ControlQ, P) end). --spec add_server_id(api_terms(), ne_binary()) -> api_terms(). +-spec add_server_id(kz_term:api_terms(), kz_term:ne_binary()) -> kz_term:api_terms(). add_server_id(API, Q) when is_list(API) -> [{<<"Server-ID">>, Q} | props:delete(<<"Server-ID">>, API)]; add_server_id(API, Q) -> diff --git a/applications/doodle/src/doodle_exe_sup.erl b/applications/doodle/src/doodle_exe_sup.erl index 57ecec525d0..84c7ffff9f0 100644 --- a/applications/doodle/src/doodle_exe_sup.erl +++ b/applications/doodle/src/doodle_exe_sup.erl @@ -32,15 +32,15 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec new(kapps_call:call()) -> sup_startchild_ret(). +-spec new(kapps_call:call()) -> kz_types:sup_startchild_ret(). new(Call) -> supervisor:start_child(?SERVER, [Call]). --spec workers() -> pids(). +-spec workers() -> kz_term:pids(). workers() -> [Pid || {_, Pid, 'worker', [_]} <- supervisor:which_children(?SERVER)]. @@ -57,7 +57,7 @@ workers() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 0, diff --git a/applications/doodle/src/doodle_inbound_handler.erl b/applications/doodle/src/doodle_inbound_handler.erl index 6d0e9808b7f..066910c3397 100644 --- a/applications/doodle/src/doodle_inbound_handler.erl +++ b/applications/doodle/src/doodle_inbound_handler.erl @@ -12,7 +12,7 @@ -include("doodle.hrl"). --spec handle_req(kz_json:object(), kz_proplist(), gen_listener:basic_deliver()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist(), gen_listener:basic_deliver()) -> 'ok'. handle_req(JObj, Props, Deliver) -> Srv = props:get_value('server', Props), case kapi_sms:inbound_v(JObj) of @@ -55,7 +55,7 @@ maybe_relay_request(JObj) -> process_sms_req(FetchId, CallId, JObjReq) end. --spec process_sms_req(ne_binary(), ne_binary(), kz_json:object()) -> 'ack' | 'nack'. +-spec process_sms_req(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ack' | 'nack'. process_sms_req(FetchId, CallId, JObj) -> Req = kz_json:set_values([{<<"Msg-ID">>, FetchId} ,{<<"Call-ID">>, CallId} @@ -77,7 +77,7 @@ process_sms_req(FetchId, CallId, JObj) -> send_route_win(FetchId, CallId, RespJObj) end. --spec send_route_win(ne_binary(), ne_binary(), kz_json:object()) -> 'ack'. +-spec send_route_win(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ack'. send_route_win(FetchId, CallId, JObj) -> ServerQ = kz_json:get_value(<<"Server-ID">>, JObj), CCVs = kz_json:get_value(<<"Custom-Channel-Vars">>, JObj, kz_json:new()), @@ -97,7 +97,7 @@ send_route_win(FetchId, CallId, JObj) -> %% determine the e164 format of the inbound number %% @end %%-------------------------------------------------------------------- --spec set_account_id(ne_binary(), knm_number_options:extra_options(), kz_json:object()) -> +-spec set_account_id(kz_term:ne_binary(), knm_number_options:extra_options(), kz_json:object()) -> kz_json:object(). set_account_id(_Inception, NumberProps, JObj) -> AccountId = knm_number_options:account_id(NumberProps), @@ -111,7 +111,7 @@ set_account_id(_Inception, NumberProps, JObj) -> ,JObj ). --spec set_inception(ne_binary(), knm_number_options:extra_options(), kz_json:object()) -> +-spec set_inception(kz_term:ne_binary(), knm_number_options:extra_options(), kz_json:object()) -> kz_json:object(). set_inception(<<"off-net">>, _, JObj) -> Request = kz_json:get_value(<<"From">>, JObj), @@ -119,7 +119,7 @@ set_inception(<<"off-net">>, _, JObj) -> set_inception(_Inception, _, JObj) -> kz_json:delete_keys([<<"Inception">>, ?CCV(<<"Inception">>)], JObj). --spec set_mdn(ne_binary(), knm_number_options:extra_options(), kz_json:object()) -> +-spec set_mdn(kz_term:ne_binary(), knm_number_options:extra_options(), kz_json:object()) -> kz_json:object(). set_mdn(<<"on-net">>, NumberProps, JObj) -> Number = knm_number_options:number(NumberProps), @@ -141,7 +141,7 @@ set_mdn(<<"on-net">>, NumberProps, JObj) -> end; set_mdn(_Inception, _NumberProps, JObj) -> JObj. --spec set_static(ne_binary(), knm_number_options:extra_options(), kz_json:object()) -> +-spec set_static(kz_term:ne_binary(), knm_number_options:extra_options(), kz_json:object()) -> kz_json:object(). set_static(_Inception, _, JObj) -> kz_json:set_values([{<<"Resource-Type">>, <<"sms">>} @@ -151,12 +151,12 @@ set_static(_Inception, _, JObj) -> ,JObj ). --spec delete_headers(ne_binary(), knm_number_options:extra_options(), kz_json:object()) -> +-spec delete_headers(kz_term:ne_binary(), knm_number_options:extra_options(), kz_json:object()) -> kz_json:object(). delete_headers(_, _, JObj) -> kz_api:remove_defaults(JObj). --spec set_realm(ne_binary(), knm_number_options:extra_options(), kz_json:object()) -> +-spec set_realm(kz_term:ne_binary(), knm_number_options:extra_options(), kz_json:object()) -> kz_json:object(). set_realm(_, _, JObj) -> Realm = kz_json:get_value(?CCV(<<"Account-Realm">>), JObj), @@ -170,6 +170,6 @@ set_realm(_, _, JObj) -> end, [], Keys), kz_json:set_values(KVs, JObj). --spec set_realm_value(K, ne_binary(), ne_binary()) -> {K, ne_binary()}. +-spec set_realm_value(K, kz_term:ne_binary(), kz_term:ne_binary()) -> {K, kz_term:ne_binary()}. set_realm_value(K, Value, Realm) -> {K, <>}. diff --git a/applications/doodle/src/doodle_inbound_listener.erl b/applications/doodle/src/doodle_inbound_listener.erl index 83912777d65..2436ef2e38d 100644 --- a/applications/doodle/src/doodle_inbound_listener.erl +++ b/applications/doodle/src/doodle_inbound_listener.erl @@ -56,7 +56,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(amqp_listener_connection()) -> startlink_ret(). +-spec start_link(amqp_listener_connection()) -> kz_types:startlink_ret(). start_link(#amqp_listener_connection{broker=Broker ,exchange=Exchange ,type=Type @@ -112,7 +112,7 @@ init([#amqp_listener_connection{}=Connection]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -126,7 +126,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _QueueNAme}}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'is_consuming', _IsConsuming}}, State) -> @@ -145,7 +145,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'send_outbound', Payload}, State) -> kapi_sms:publish_outbound(Payload), {'noreply', State}; @@ -161,7 +161,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/doodle/src/doodle_inbound_listener_sup.erl b/applications/doodle/src/doodle_inbound_listener_sup.erl index b44772e352a..ca4f53962ed 100644 --- a/applications/doodle/src/doodle_inbound_listener_sup.erl +++ b/applications/doodle/src/doodle_inbound_listener_sup.erl @@ -36,7 +36,7 @@ %% =================================================================== %% API functions %% =================================================================== --spec start_inbound_listener(amqp_listener_connection()) -> startlink_ret(). +-spec start_inbound_listener(amqp_listener_connection()) -> kz_types:startlink_ret(). start_inbound_listener(Connection) -> supervisor:start_child(?SERVER, [Connection]). @@ -48,7 +48,7 @@ start_listeners() -> %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> R = supervisor:start_link({'local', ?SERVER}, ?MODULE, []), case R of @@ -70,7 +70,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 5, @@ -107,7 +107,7 @@ connections_fold(K, V, Acc) -> }, [C | Acc]. --spec connection_options(api_object()) -> kz_proplist(). +-spec connection_options(kz_term:api_object()) -> kz_term:proplist(). connection_options('undefined') -> connection_options(?DEFAULT_EXCHANGE_OPTIONS_JOBJ); connection_options(JObj) -> diff --git a/applications/doodle/src/doodle_listener.erl b/applications/doodle/src/doodle_listener.erl index a104d0b7795..0b0acf7ae61 100644 --- a/applications/doodle/src/doodle_listener.erl +++ b/applications/doodle/src/doodle_listener.erl @@ -44,7 +44,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'bindings', ?BINDINGS} ,{'responders', ?RESPONDERS} @@ -87,7 +87,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -101,7 +101,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _QueueNAme}}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'is_consuming', _IsConsuming}}, State) -> @@ -119,7 +119,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -131,7 +131,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/doodle/src/doodle_maintenance.erl b/applications/doodle/src/doodle_maintenance.erl index 646c4f57e62..9b3c07edfdf 100644 --- a/applications/doodle/src/doodle_maintenance.erl +++ b/applications/doodle/src/doodle_maintenance.erl @@ -22,15 +22,15 @@ flush() -> kz_cache:flush_local(?CACHE_NAME). --spec start_check_sms_by_device_id(ne_binary(), ne_binary()) -> pid(). +-spec start_check_sms_by_device_id(kz_term:ne_binary(), kz_term:ne_binary()) -> pid(). start_check_sms_by_device_id(AccountId, DeviceId) -> kz_util:spawn(fun check_sms_by_device_id/2, [AccountId, DeviceId]). --spec start_check_sms_by_owner_id(ne_binary(), ne_binary()) -> pid(). +-spec start_check_sms_by_owner_id(kz_term:ne_binary(), kz_term:ne_binary()) -> pid(). start_check_sms_by_owner_id(AccountId, OwnerId) -> kz_util:spawn(fun check_sms_by_owner_id/2, [AccountId, OwnerId]). --spec check_sms_by_device_id(ne_binary(), ne_binary()) -> 'ok'. +-spec check_sms_by_device_id(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. check_sms_by_device_id(_AccountId, 'undefined') -> 'ok'; check_sms_by_device_id(AccountId, DeviceId) -> ViewOptions = [{'endkey', [DeviceId, kz_time:now_s()]}], @@ -41,7 +41,7 @@ check_sms_by_device_id(AccountId, DeviceId) -> lager:debug("unable to get sms by device for ~s/~s: ~p", [AccountId, DeviceId, _R]) end. --spec check_sms_by_owner_id(ne_binary(), api_binary()) -> 'ok'. +-spec check_sms_by_owner_id(kz_term:ne_binary(), kz_term:api_binary()) -> 'ok'. check_sms_by_owner_id(_AccountId, 'undefined') -> 'ok'; check_sms_by_owner_id(AccountId, OwnerId) -> ViewOptions = [{'endkey', [OwnerId, kz_time:now_s()]}], @@ -52,7 +52,7 @@ check_sms_by_owner_id(AccountId, OwnerId) -> lager:debug("unable to get sms by owner_id for owner_id ~s in account ~s: ~p", [AccountId, OwnerId, _R]) end. --spec start_check_sms_by_account(ne_binary(), kz_json:object()) -> pid(). +-spec start_check_sms_by_account(kz_term:ne_binary(), kz_json:object()) -> pid(). start_check_sms_by_account(AccountId, JObj) -> case kz_doc:is_soft_deleted(JObj) orelse kz_term:is_false(kz_json:get_value(<<"pvt_enabled">>, JObj, 'true')) @@ -61,12 +61,12 @@ start_check_sms_by_account(AccountId, JObj) -> 'false' -> kz_util:spawn(fun check_pending_sms_for_delivery/1, [AccountId]) end. --spec check_pending_sms_for_outbound_delivery(ne_binary()) -> pid(). +-spec check_pending_sms_for_outbound_delivery(kz_term:ne_binary()) -> pid(). check_pending_sms_for_outbound_delivery(AccountId) -> kz_util:spawn(fun check_pending_sms_for_offnet_delivery/1, [AccountId]), kz_util:spawn(fun check_queued_sms/1, [AccountId]). --spec check_pending_sms_for_delivery(ne_binary()) -> 'ok'. +-spec check_pending_sms_for_delivery(kz_term:ne_binary()) -> 'ok'. check_pending_sms_for_delivery(AccountId) -> ViewOptions = [{'limit', 100} ,{'endkey', kz_time:now_s()} @@ -78,7 +78,7 @@ check_pending_sms_for_delivery(AccountId) -> lager:debug("unable to get sms list for delivery in account ~s : ~p", [AccountId, _R]) end. --spec check_queued_sms(ne_binary()) -> 'ok'. +-spec check_queued_sms(kz_term:ne_binary()) -> 'ok'. check_queued_sms(AccountId) -> ViewOptions = [{'limit', 100}], case kazoo_modb:get_results(AccountId, <<"sms/queued">>, ViewOptions) of @@ -88,7 +88,7 @@ check_queued_sms(AccountId) -> lager:debug("unable to get queued sms list in account ~s : ~p", [AccountId, _R]) end. --spec replay_queue_sms(ne_binary(), kz_json:objects()) -> 'ok'. +-spec replay_queue_sms(kz_term:ne_binary(), kz_json:objects()) -> 'ok'. replay_queue_sms(AccountId, JObjs) -> lager:debug("starting queued sms for account ~s", [AccountId]), _ = [spawn_handler(AccountId, JObj) @@ -96,7 +96,7 @@ replay_queue_sms(AccountId, JObjs) -> ], 'ok'. --spec spawn_handler(ne_binary(), kz_json:object()) -> 'ok'. +-spec spawn_handler(kz_term:ne_binary(), kz_json:object()) -> 'ok'. spawn_handler(AccountId, JObj) -> DocId = kz_doc:id(JObj), ?MATCH_MODB_PREFIX(Year,Month,_) = DocId, @@ -104,7 +104,7 @@ spawn_handler(AccountId, JObj) -> _ = kz_util:spawn(fun doodle_api:handle_api_sms/2, [AccountDb, DocId]), timer:sleep(200). --spec check_pending_sms_for_offnet_delivery(ne_binary()) -> 'ok'. +-spec check_pending_sms_for_offnet_delivery(kz_term:ne_binary()) -> 'ok'. check_pending_sms_for_offnet_delivery(AccountId) -> ViewOptions = [{'limit', 100} ,{'endkey', kz_time:now_s()} @@ -116,7 +116,7 @@ check_pending_sms_for_offnet_delivery(AccountId) -> lager:debug("unable to get sms list for offnet delivery in account ~s : ~p", [AccountId, _R]) end. --spec replay_sms(ne_binary(), kz_json:objects()) -> 'ok'. +-spec replay_sms(kz_term:ne_binary(), kz_json:objects()) -> 'ok'. replay_sms(AccountId, JObjs) -> lager:debug("starting sms offnet delivery for account ~s", [AccountId]), F = fun (JObj) -> @@ -130,9 +130,9 @@ replay_sms(AccountId, JObjs) -> -define(DEFAULT_FROM, kapps_config:get_ne_binary(?CONFIG_CAT, <<"default_test_from_number">>, <<"15552220001">>)). --spec send_outbound_sms(ne_binary(), ne_binary()) -> 'ok'. --spec send_outbound_sms(ne_binary(), ne_binary(), pos_integer()) -> 'ok'. --spec send_outbound_sms(ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec send_outbound_sms(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. +-spec send_outbound_sms(kz_term:ne_binary(), kz_term:ne_binary(), pos_integer()) -> 'ok'. +-spec send_outbound_sms(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. send_outbound_sms(To, Msg) -> send_outbound_sms(To, ?DEFAULT_FROM, ?DEFAULT_ROUTEID, Msg). @@ -150,7 +150,7 @@ send_outbound_sms(To, From, RouteId, Msg) -> ], kz_amqp_worker:cast(Payload, fun kapi_sms:publish_outbound/1). --spec send_outbound_sms(ne_binary(), ne_binary(), ne_binary(), ne_binary(), pos_integer()) -> 'ok'. +-spec send_outbound_sms(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), pos_integer()) -> 'ok'. send_outbound_sms(To, From, RouteId, Msg, Times) -> F = fun (X) -> MSG = <<"MSG - ", (kz_term:to_binary(X))/binary, " => ", Msg/binary>>, diff --git a/applications/doodle/src/doodle_notify_handler.erl b/applications/doodle/src/doodle_notify_handler.erl index cb20965bc72..5fadaee4376 100644 --- a/applications/doodle/src/doodle_notify_handler.erl +++ b/applications/doodle/src/doodle_notify_handler.erl @@ -12,7 +12,7 @@ -include("doodle.hrl"). --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Props) -> 'true' = kapi_registration:success_v(JObj), _ = kz_util:put_callid(JObj), @@ -23,7 +23,7 @@ handle_req(JObj, _Props) -> {'error', 'not_found'} -> handle_no_account_req(Realm, Username) end. --spec handle_account_req(ne_binary(), ne_binary()) -> 'ok'. +-spec handle_account_req(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. handle_account_req(AccountDb, Username) -> AccountId = kz_util:format_account_id(AccountDb), case cf_util:endpoint_id_by_sip_username(AccountDb, Username) of @@ -42,7 +42,7 @@ handle_account_req(AccountDb, Username) -> ,[Username, AccountDb, _E]) end. --spec handle_no_account_req(ne_binary(), ne_binary()) -> 'ok'. +-spec handle_no_account_req(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. handle_no_account_req(Realm, Username) -> case doodle_util:endpoint_from_sipdb(Realm, Username) of {'ok', Endpoint} -> diff --git a/applications/doodle/src/doodle_route_req.erl b/applications/doodle/src/doodle_route_req.erl index 1b0f2a1ae84..8ee12f908b1 100644 --- a/applications/doodle/src/doodle_route_req.erl +++ b/applications/doodle/src/doodle_route_req.erl @@ -16,7 +16,7 @@ -define(ROUTE_WIN_TIMEOUT_KEY, <<"route_win_timeout">>). -define(ROUTE_WIN_TIMEOUT, kapps_config:get_integer(?CONFIG_CAT, ?ROUTE_WIN_TIMEOUT_KEY, ?DEFAULT_ROUTE_WIN_TIMEOUT)). --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, Props) -> 'true' = kapi_route:req_v(JObj), Call = kapps_call:from_route_req(JObj), @@ -68,7 +68,7 @@ allow_no_match_type(Call) -> _ -> 'true' end. --spec maybe_reply_to_req(kz_json:object(), kz_proplist(), kapps_call:call(), kz_json:object(), boolean()) -> +-spec maybe_reply_to_req(kz_json:object(), kz_term:proplist(), kapps_call:call(), kz_json:object(), boolean()) -> 'ok'. maybe_reply_to_req(JObj, Props, Call, Flow, NoMatch) -> lager:info("callflow ~s in ~s satisfies request" @@ -84,14 +84,14 @@ maybe_reply_to_req(JObj, Props, Call, Flow, NoMatch) -> send_route_response(Flow, JObj, UpdatedCall) end. --spec bucket_info(kapps_call:call(), kz_json:object()) -> {ne_binary(), pos_integer()}. +-spec bucket_info(kapps_call:call(), kz_json:object()) -> {kz_term:ne_binary(), pos_integer()}. bucket_info(Call, Flow) -> case kz_json:get_value(<<"pvt_bucket_name">>, Flow) of 'undefined' -> {bucket_name_from_call(Call, Flow), bucket_cost(Flow)}; Name -> {Name, bucket_cost(Flow)} end. --spec bucket_name_from_call(kapps_call:call(), kz_json:object()) -> ne_binary(). +-spec bucket_name_from_call(kapps_call:call(), kz_json:object()) -> kz_term:ne_binary(). bucket_name_from_call(Call, Flow) -> <<(kapps_call:account_id(Call))/binary, ":", (kz_doc:id(Flow))/binary>>. @@ -128,7 +128,7 @@ send_route_response(_Flow, JObj, Call) -> lager:info("doodle didn't received a route win, exiting : ~p", [_E]) end. --spec update_call(kz_json:object(), boolean(), ne_binary(), kapps_call:call(), kz_json:object()) -> kapps_call:call(). +-spec update_call(kz_json:object(), boolean(), kz_term:ne_binary(), kapps_call:call(), kz_json:object()) -> kapps_call:call(). update_call(Flow, NoMatch, ControllerQ, Call, JObj) -> Updaters = [{fun kapps_call:kvs_store_proplist/2 ,[{'cf_flow_id', kz_doc:id(Flow)} @@ -155,7 +155,7 @@ cache_resource_types(Flow, Call, JObj) -> ,cache_resource_types(kapps_call:resource_type(Call), Flow, Call, JObj) ). --spec cache_resource_types(ne_binary(), kz_json:object(), kapps_call:call(), kz_json:object()) -> ne_binaries(). +-spec cache_resource_types(kz_term:ne_binary(), kz_json:object(), kapps_call:call(), kz_json:object()) -> kz_term:ne_binaries(). cache_resource_types(<<"sms">>, _Flow, _Call, _JObj) -> [<<"Message-ID">>, <<"Body">>]; cache_resource_types(_Other, _Flow, _Call, _JObj) -> []. diff --git a/applications/doodle/src/doodle_route_win.erl b/applications/doodle/src/doodle_route_win.erl index 5dc5e23c91d..c0c48a5ca4c 100644 --- a/applications/doodle/src/doodle_route_win.erl +++ b/applications/doodle/src/doodle_route_win.erl @@ -137,7 +137,7 @@ get_caller_groups(Groups, JObj, Call) -> get_group_associations(Id, Groups, Set) end, sets:new(), Ids). --spec maybe_device_groups_intersect(ne_binary(), sets:set(), kz_json:objects(), kapps_call:call()) -> boolean(). +-spec maybe_device_groups_intersect(kz_term:ne_binary(), sets:set(), kz_json:objects(), kapps_call:call()) -> boolean(). maybe_device_groups_intersect(CalleeId, CallerGroups, Groups, Call) -> CalleeGroups = get_group_associations(CalleeId, Groups), case sets:size(sets:intersection(CallerGroups, CalleeGroups)) =:= 0 of @@ -152,11 +152,11 @@ maybe_device_groups_intersect(CalleeId, CallerGroups, Groups, Call) -> sets:size(sets:intersection(CallerGroups, UsersGroups)) =:= 0 end. --spec get_group_associations(ne_binary(), kz_json:objects()) -> sets:set(). +-spec get_group_associations(kz_term:ne_binary(), kz_json:objects()) -> sets:set(). get_group_associations(Id, Groups) -> get_group_associations(Id, Groups, sets:new()). --spec get_group_associations(ne_binary(), kz_json:objects(), sets:set()) -> sets:set(). +-spec get_group_associations(kz_term:ne_binary(), kz_json:objects(), sets:set()) -> sets:set(). get_group_associations(Id, Groups, Set) -> lists:foldl(fun(Group, S) -> case kz_json:get_value([<<"value">>, Id], Group) of @@ -167,7 +167,7 @@ get_group_associations(Id, Groups, Set) -> end end, Set, Groups). --spec get_callee_extension_info(kapps_call:call()) -> {ne_binary(), ne_binary()} | 'undefined'. +-spec get_callee_extension_info(kapps_call:call()) -> {kz_term:ne_binary(), kz_term:ne_binary()} | 'undefined'. get_callee_extension_info(Call) -> Flow = kapps_call:kvs_fetch('cf_flow', Call), FirstModule = kz_json:get_value(<<"module">>, Flow), @@ -235,7 +235,7 @@ update_ccvs(Call) -> ]), kapps_call:set_custom_channel_vars(Props, Call). --spec get_incoming_security(kapps_call:call()) -> kz_proplist(). +-spec get_incoming_security(kapps_call:call()) -> kz_term:proplist(). get_incoming_security(Call) -> case kz_endpoint:get(Call) of {'error', _R} -> []; diff --git a/applications/doodle/src/doodle_shared_listener.erl b/applications/doodle/src/doodle_shared_listener.erl index fa4d995a106..c1d0dc56602 100644 --- a/applications/doodle/src/doodle_shared_listener.erl +++ b/applications/doodle/src/doodle_shared_listener.erl @@ -50,7 +50,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link({'local', ?SERVER} ,?MODULE @@ -96,7 +96,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -110,7 +110,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _QueueNAme}}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'is_consuming', _IsConsuming}}, State) -> @@ -128,7 +128,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -140,7 +140,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/doodle/src/doodle_sup.erl b/applications/doodle/src/doodle_sup.erl index 4a8bbfeeaba..6fecc89ec38 100644 --- a/applications/doodle/src/doodle_sup.erl +++ b/applications/doodle/src/doodle_sup.erl @@ -40,7 +40,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -57,7 +57,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/doodle/src/doodle_util.erl b/applications/doodle/src/doodle_util.erl index f4c86b16080..9af4bd21c9f 100644 --- a/applications/doodle/src/doodle_util.erl +++ b/applications/doodle/src/doodle_util.erl @@ -42,15 +42,15 @@ %% API functions %% ==================================================================== --spec set_sms_body(ne_binary(), kapps_call:call()) -> kapps_call:call(). +-spec set_sms_body(kz_term:ne_binary(), kapps_call:call()) -> kapps_call:call(). set_sms_body(Body, Call) -> kapps_call:kvs_store(<<"Body">>, Body, Call). --spec get_sms_body(kapps_call:call()) -> ne_binary(). +-spec get_sms_body(kapps_call:call()) -> kz_term:ne_binary(). get_sms_body(Call) -> kapps_call:kvs_fetch(<<"Body">>, Call). --spec set_flow_status(ne_binary() | {binary(), binary()}, kapps_call:call()) -> kapps_call:call(). +-spec set_flow_status(kz_term:ne_binary() | {binary(), binary()}, kapps_call:call()) -> kapps_call:call(). set_flow_status({Status, Message}, Call) -> Props = [{<<"flow_status">>, Status} ,{<<"flow_message">>, Message} @@ -59,14 +59,14 @@ set_flow_status({Status, Message}, Call) -> set_flow_status(Status, Call) -> kapps_call:kvs_store(<<"flow_status">>, Status, Call). --spec set_flow_status(ne_binary(), ne_binary(), kapps_call:call()) -> kapps_call:call(). +-spec set_flow_status(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> kapps_call:call(). set_flow_status(Status, Message, Call) -> Props = [{<<"flow_status">>, Status} ,{<<"flow_message">>, Message} ], kapps_call:kvs_store_proplist(Props, Call). --spec set_flow_error(api_binary() | {binary(), binary()}, kapps_call:call()) -> kapps_call:call(). +-spec set_flow_error(kz_term:api_binary() | {binary(), binary()}, kapps_call:call()) -> kapps_call:call(). set_flow_error({Status, Error}, Call) -> Props = [{<<"flow_status">>, Status} ,{<<"flow_error">>, Error} @@ -75,7 +75,7 @@ set_flow_error({Status, Error}, Call) -> set_flow_error(Error, Call) -> set_flow_error(<<"pending">>, Error, Call). --spec set_flow_error(ne_binary(), api_binary(), kapps_call:call()) -> kapps_call:call(). +-spec set_flow_error(kz_term:ne_binary(), kz_term:api_binary(), kapps_call:call()) -> kapps_call:call(). set_flow_error(Status, Error, Call) -> Props = [{<<"flow_status">>, Status} ,{<<"flow_error">>, Error} @@ -87,14 +87,14 @@ clear_flow_error(Call) -> Props = [<<"flow_status">>, <<"flow_error">>], kapps_call:kvs_erase(Props, Call). --spec get_sms_revision(kapps_call:call()) -> api_binary(). +-spec get_sms_revision(kapps_call:call()) -> kz_term:api_binary(). get_sms_revision(Call) -> case kapps_call:kvs_fetch(<<"_rev">>, Call) of 'undefined' -> kapps_call:custom_channel_var(<<"Doc-Revision">>, Call); Rev -> Rev end. --spec set_sms_revision(api_binary(), kapps_call:call()) -> kapps_call:call(). +-spec set_sms_revision(kz_term:api_binary(), kapps_call:call()) -> kapps_call:call(). set_sms_revision(Rev, Call) -> kapps_call:kvs_store(<<"_rev">>, Rev, Call). @@ -108,7 +108,7 @@ save_sms(JObj, Call) -> Id = kapps_call:kvs_fetch('sms_docid', kapps_call:custom_channel_var(<<"Doc-ID">>, Call), Call), save_sms(JObj, Id, Call). --spec save_sms(kz_json:object(), api_binary(), kapps_call:call()) -> kapps_call:call(). +-spec save_sms(kz_json:object(), kz_term:api_binary(), kapps_call:call()) -> kapps_call:call(). save_sms(JObj, 'undefined', Call) -> {Year, Month, _} = erlang:date(), SmsDocId = kz_term:to_binary( @@ -127,7 +127,7 @@ save_sms(JObj, DocId, Call) -> {'ok', Doc} = kazoo_modb:open_doc(AccountId, DocId, Year, Month), save_sms(JObj, DocId, Doc, Call). --spec save_sms(kz_json:object(), api_binary(), kz_json:object(), kapps_call:call()) -> +-spec save_sms(kz_json:object(), kz_term:api_binary(), kz_json:object(), kapps_call:call()) -> kapps_call:call(). save_sms(JObj, ?MATCH_MODB_PREFIX(Year,Month,_) = DocId, Doc, Call) -> AccountId = kapps_call:account_id(Call), @@ -203,8 +203,8 @@ remove_keys(Call) -> remove_keys(Call, Keys) -> lists:foldl(fun kapps_call:kvs_erase/2, Call, Keys). --spec endpoint_id_from_sipdb(ne_binary(), ne_binary()) -> - {'ok', ne_binary()} | +-spec endpoint_id_from_sipdb(kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | {'error', any()}. endpoint_id_from_sipdb(Realm, Username) -> case kz_cache:peek_local(?CACHE_NAME, ?SIP_ENDPOINT_ID_KEY(Realm, Username)) of @@ -213,8 +213,8 @@ endpoint_id_from_sipdb(Realm, Username) -> get_endpoint_id_from_sipdb(Realm, Username) end. --spec get_endpoint_id_from_sipdb(ne_binary(), ne_binary()) -> - {'ok', ne_binary(), ne_binary()} | +-spec get_endpoint_id_from_sipdb(kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary(), kz_term:ne_binary()} | {'error', any()}. get_endpoint_id_from_sipdb(Realm, Username) -> ViewOptions = [{'key', [kz_term:to_lower_binary(Realm) @@ -233,7 +233,7 @@ get_endpoint_id_from_sipdb(Realm, Username) -> E end. --spec endpoint_from_sipdb(ne_binary(), ne_binary()) -> +-spec endpoint_from_sipdb(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. endpoint_from_sipdb(Realm, Username) -> @@ -243,7 +243,7 @@ endpoint_from_sipdb(Realm, Username) -> get_endpoint_from_sipdb(Realm, Username) end. --spec get_endpoint_from_sipdb(ne_binary(), ne_binary()) -> +-spec get_endpoint_from_sipdb(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. get_endpoint_from_sipdb(Realm, Username) -> @@ -265,7 +265,7 @@ get_endpoint_from_sipdb(Realm, Username) -> E end. --spec replay_sms(ne_binary(), ne_binary()) -> any(). +-spec replay_sms(kz_term:ne_binary(), kz_term:ne_binary()) -> any(). replay_sms(AccountId, DocId) -> lager:debug("trying to replay sms ~s for account ~s",[DocId, AccountId]), {'ok', Doc} = kazoo_modb:open_doc(AccountId, DocId), @@ -274,7 +274,7 @@ replay_sms(AccountId, DocId) -> Rev = kz_doc:revision(Doc), replay_sms_flow(AccountId, DocId, Rev, Flow, Schedule). --spec replay_sms_flow(ne_binary(), ne_binary(), ne_binary(), api_object(), api_object()) -> any(). +-spec replay_sms_flow(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_object(), kz_term:api_object()) -> any(). replay_sms_flow(_AccountId, _DocId, _Rev, 'undefined', _) -> 'ok'; replay_sms_flow(AccountId, <<_:7/binary, CallId/binary>> = DocId, Rev, JObj, Schedule) -> lager:debug("replaying sms ~s for account ~s",[DocId, AccountId]), @@ -289,14 +289,14 @@ replay_sms_flow(AccountId, <<_:7/binary, CallId/binary>> = DocId, Rev, JObj, Sch lager:info("doodle received sms resume for ~s of account ~s, taking control", [DocId, AccountId]), doodle_route_win:execute_text_flow(JObj, Call). --spec sms_status(api_object()) -> ne_binary(). +-spec sms_status(kz_term:api_object()) -> kz_term:ne_binary(). sms_status('undefined') -> <<"pending">>; sms_status(JObj) -> DeliveryCode = kz_json:get_value(<<"Delivery-Result-Code">>, JObj), Status = kz_json:get_value(<<"Status">>, JObj), sms_status(DeliveryCode, Status). --spec sms_status(api_binary(), api_binary()) -> ne_binary(). +-spec sms_status(kz_term:api_binary(), kz_term:api_binary()) -> kz_term:ne_binary(). sms_status(<<"sip:", Code/binary>>, Status) -> sms_status(Code, Status); sms_status(<<"200">>, _) -> <<"delivered">>; sms_status(<<"202">>, _) -> <<"accepted">>; @@ -310,7 +310,7 @@ sms_status(_, _) -> <<"pending">>. %% certain actions, like cf_sms_offnet and cf_sms_resources %% @end %%-------------------------------------------------------------------- --spec handle_bridge_failure({'fail' | 'error', kz_json:object() | atom()} | api_binary(), kapps_call:call()) -> +-spec handle_bridge_failure({'fail' | 'error', kz_json:object() | atom()} | kz_term:api_binary(), kapps_call:call()) -> 'ok' | 'not_found'. handle_bridge_failure({'fail', Reason}, Call) -> {Cause, Code} = kapps_util:get_call_termination_reason(Reason), @@ -327,7 +327,7 @@ handle_bridge_failure(<<_/binary>> = Failure, Call) -> end; handle_bridge_failure(_, _Call) -> 'not_found'. --spec handle_bridge_failure(api_binary(), api_binary(), kapps_call:call()) -> +-spec handle_bridge_failure(kz_term:api_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok' | 'not_found'. handle_bridge_failure(Cause, Code, Call) -> lager:info("attempting to find failure branch for ~s:~s", [Code, Cause]), @@ -337,11 +337,11 @@ handle_bridge_failure(Cause, Code, Call) -> 'false' -> 'not_found' end. --spec get_caller_id(kz_json:object(), kapps_call:call()) -> {api_binary(), api_binary()}. +-spec get_caller_id(kz_json:object(), kapps_call:call()) -> {kz_term:api_binary(), kz_term:api_binary()}. get_caller_id(Data, Call) -> get_caller_id(Data, <<"external">>, Call). --spec get_caller_id(kz_json:object(), binary(), kapps_call:call()) -> {api_binary(), api_binary()}. +-spec get_caller_id(kz_json:object(), binary(), kapps_call:call()) -> {kz_term:api_binary(), kz_term:api_binary()}. get_caller_id(Data, Default, Call) -> Type = kz_json:get_value(<<"caller_id_type">>, Data, Default), kz_attributes:caller_id(Type, Call). @@ -366,7 +366,7 @@ set_caller_id(CIDNumber, CIDName, Call) -> ], kapps_call:exec(Routines, Call). --spec get_callee_id(binary(), kapps_call:call()) -> {api_binary(), api_binary()}. +-spec get_callee_id(binary(), kapps_call:call()) -> {kz_term:api_binary(), kz_term:api_binary()}. get_callee_id(EndpointId, Call) -> kz_attributes:callee_id(EndpointId, Call). @@ -379,7 +379,7 @@ set_callee_id(EndpointId, Call) -> ]), kapps_call:set_custom_channel_vars(Props, Call). --spec get_inbound_field(ne_binary()) -> ne_binaries(). +-spec get_inbound_field(kz_term:ne_binary()) -> kz_term:ne_binaries(). get_inbound_field(Inception) -> case Inception of <<"on-net">> -> [<<"Caller-ID-Number">>, <<"From">>]; @@ -387,15 +387,15 @@ get_inbound_field(Inception) -> _ -> get_inbound_field(?DEFAULT_INCEPTION) end. --spec get_inbound_destination(kz_json:object()) -> {ne_binary(), ne_binary()}. +-spec get_inbound_destination(kz_json:object()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. get_inbound_destination(JObj) -> Inception = kz_json:get_value(<<"Route-Type">>, JObj, ?DEFAULT_INCEPTION), Keys = get_inbound_field(Inception), Number = kz_json:get_first_defined(Keys, JObj), {knm_converters:normalize(Number), Inception}. --spec lookup_mdn(ne_binary()) -> - {'ok', ne_binary(), api_binary()} | +-spec lookup_mdn(kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary(), kz_term:api_binary()} | {'error', any()}. lookup_mdn(Number) -> Num = knm_converters:normalize(Number), @@ -406,8 +406,8 @@ lookup_mdn(Number) -> {'error', 'not_found'} -> fetch_mdn(Num) end. --spec fetch_mdn(ne_binary()) -> - {'ok', ne_binary(), api_binary()} | +-spec fetch_mdn(kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary(), kz_term:api_binary()} | {'error', any()}. fetch_mdn(Num) -> case knm_number:lookup_account(Num) of @@ -418,8 +418,8 @@ fetch_mdn(Num) -> E end. --spec fetch_mdn_result(ne_binary(), ne_binary()) -> - {'ok', ne_binary(), api_binary()} | +-spec fetch_mdn_result(kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary(), kz_term:api_binary()} | {'error', 'not_found'}. fetch_mdn_result(AccountId, Num) -> AccountDb = kz_util:format_account_db(AccountId), @@ -435,14 +435,14 @@ fetch_mdn_result(AccountId, Num) -> E end. --spec cache_mdn_result(ne_binary(), ne_binary(), api_binary()) -> - {'ok', ne_binary(), api_binary()}. +-spec cache_mdn_result(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary()) -> + {'ok', kz_term:ne_binary(), kz_term:api_binary()}. cache_mdn_result(AccountDb, Id, OwnerId) -> CacheProps = [{'origin', [{'db', AccountDb, Id}]}], kz_cache:store_local(?CACHE_NAME, cache_key_mdn(Id), {Id, OwnerId}, CacheProps), {'ok', Id, OwnerId}. --spec cache_key_mdn(ne_binary()) -> {'sms_mdn', ne_binary()}. +-spec cache_key_mdn(kz_term:ne_binary()) -> {'sms_mdn', kz_term:ne_binary()}. cache_key_mdn(Number) -> {'sms_mdn', Number}. @@ -457,13 +457,13 @@ mdn_from_e164(Number) -> Number. maybe_reschedule_sms(Call) -> maybe_reschedule_sms(<<>>, <<>>, Call). --spec maybe_reschedule_sms(api_binary(), kapps_call:call()) -> 'ok'. +-spec maybe_reschedule_sms(kz_term:api_binary(), kapps_call:call()) -> 'ok'. maybe_reschedule_sms(<<"sip:", Code/binary>>, Call) -> maybe_reschedule_sms(Code, <<>>, Call); maybe_reschedule_sms(Code, Call) -> maybe_reschedule_sms(Code, <<>>, Call). --spec maybe_reschedule_sms(api_binary(), api_binary(), kapps_call:call()) -> 'ok'. +-spec maybe_reschedule_sms(kz_term:api_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. maybe_reschedule_sms(Code, 'undefined', Call) -> maybe_reschedule_sms(Code, set_flow_error(<<"unknown error">>, Call)); maybe_reschedule_sms(<<"sip:", Code/binary>>, Message, Call) -> @@ -471,7 +471,7 @@ maybe_reschedule_sms(<<"sip:", Code/binary>>, Message, Call) -> maybe_reschedule_sms(Code, Message, Call) -> maybe_reschedule_sms(Code, Message, kapps_call:account_id(Call), set_flow_error(Message, Call)). --spec maybe_reschedule_sms(api_binary(), api_binary(), ne_binary(), kapps_call:call()) -> 'ok'. +-spec maybe_reschedule_sms(kz_term:api_binary(), kz_term:api_binary(), kz_term:ne_binary(), kapps_call:call()) -> 'ok'. maybe_reschedule_sms(Code, Message, AccountId, Call) -> put('call', Call), Rules = kapps_account_config:get_global(AccountId, ?CONFIG_CAT, <<"reschedule">>, kz_json:new()), @@ -541,7 +541,7 @@ apply_reschedule_step({[Value | Values], [Key | Keys]}, JObj) -> Schedule -> apply_reschedule_step({Values, Keys}, Schedule) end. --spec apply_reschedule_rule(ne_binary(), any(), kz_json:object()) -> 'no_match' | kz_json:object(). +-spec apply_reschedule_rule(kz_term:ne_binary(), any(), kz_json:object()) -> 'no_match' | kz_json:object(). apply_reschedule_rule(<<"error">>, ErrorObj, JObj) -> Codes = kz_json:get_value(<<"code">>, ErrorObj, []), XCodes = kz_json:get_value(<<"xcode">>, ErrorObj, []), @@ -606,16 +606,16 @@ apply_reschedule_rule(<<"report">>, V, JObj) -> JObj; apply_reschedule_rule(_, _, JObj) -> JObj. --spec safe_to_proplist(any()) -> kz_proplist(). +-spec safe_to_proplist(any()) -> kz_term:proplist(). safe_to_proplist(JObj) -> safe_to_proplist(kz_json:is_json_object(JObj), JObj). --spec safe_to_proplist(boolean(), any()) -> kz_proplist(). +-spec safe_to_proplist(boolean(), any()) -> kz_term:proplist(). safe_to_proplist('true', JObj) -> kz_json:to_proplist(JObj); safe_to_proplist(_, _) -> []. --spec time_rule(ne_binary(), integer(), integer()) -> integer(). +-spec time_rule(kz_term:ne_binary(), integer(), integer()) -> integer(). time_rule(<<"week">>, N, Base) -> Base + N * ?SECONDS_IN_WEEK; time_rule(<<"day">>, N, Base) -> Base + N * ?SECONDS_IN_DAY; time_rule(<<"hour">>, N, Base) -> Base + N * ?SECONDS_IN_HOUR; diff --git a/applications/doodle/src/module/cf_sms_device.erl b/applications/doodle/src/module/cf_sms_device.erl index 006d3293d12..8adefe6919d 100644 --- a/applications/doodle/src/module/cf_sms_device.erl +++ b/applications/doodle/src/module/cf_sms_device.erl @@ -42,7 +42,7 @@ handle_result(JObj, Call) -> Call1 = doodle_util:set_flow_status(Status, Call), handle_result_status(Call1, Status). --spec handle_result_status(kapps_call:call(), ne_binary()) -> 'ok'. +-spec handle_result_status(kapps_call:call(), kz_term:ne_binary()) -> 'ok'. handle_result_status(Call, <<"pending">>) -> doodle_util:maybe_reschedule_sms(Call); handle_result_status(Call, _Status) -> @@ -64,9 +64,9 @@ maybe_handle_bridge_failure({_ , R}=Reason, Call) -> %% Attempts to build the endpoints to reach this device %% @end %%-------------------------------------------------------------------- --spec build_endpoint(ne_binary(), kz_json:object(), kapps_call:call()) -> +-spec build_endpoint(kz_term:ne_binary(), kz_json:object(), kapps_call:call()) -> {'error', atom() | kz_json:object()} | - {'fail', ne_binary() | kz_json:object()} | + {'fail', kz_term:ne_binary() | kz_json:object()} | {'ok', kz_json:object()}. build_endpoint(EndpointId, Data, Call) -> Params = kz_json:set_value(<<"source">>, kz_term:to_binary(?MODULE), Data), diff --git a/applications/doodle/src/module/cf_sms_resources.erl b/applications/doodle/src/module/cf_sms_resources.erl index 9901e0234c1..a72a2f5ecc6 100644 --- a/applications/doodle/src/module/cf_sms_resources.erl +++ b/applications/doodle/src/module/cf_sms_resources.erl @@ -59,14 +59,14 @@ handle_result(_Message, <<"sip:200">>, Response, _JObj, Call1) -> handle_result(Message, Code, _Response, _JObj, Call) -> handle_bridge_failure(Message, Code, Call). --spec handle_result_status(kapps_call:call(), ne_binary()) -> 'ok'. +-spec handle_result_status(kapps_call:call(), kz_term:ne_binary()) -> 'ok'. handle_result_status(Call, <<"pending">>) -> doodle_util:maybe_reschedule_sms(Call); handle_result_status(Call, _Status) -> lager:info("completed successful message to the device"), doodle_exe:stop(Call). --spec handle_bridge_failure(api_binary(), api_binary(), kapps_call:call()) -> 'ok'. +-spec handle_bridge_failure(kz_term:api_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. handle_bridge_failure(Cause, Code, Call) -> lager:info("offnet request error, attempting to find failure branch for ~s:~s", [Code, Cause]), case doodle_util:handle_bridge_failure(Cause, Code, Call) of @@ -83,7 +83,7 @@ handle_bridge_failure(Cause, Code, Call) -> %% %% @end %%-------------------------------------------------------------------- --spec build_offnet_request(kz_json:object(), kapps_call:call()) -> kz_proplist(). +-spec build_offnet_request(kz_json:object(), kapps_call:call()) -> kz_term:proplist(). build_offnet_request(Data, Call) -> props:filter_undefined( [{<<"Resource-Type">>, <<"sms">>} @@ -117,21 +117,21 @@ get_bypass_e164(Data) -> kz_json:is_true(<<"do_not_normalize">>, Data) orelse kz_json:is_true(<<"bypass_e164">>, Data). --spec get_from_uri_realm(kz_json:object(), kapps_call:call()) -> api_ne_binary(). +-spec get_from_uri_realm(kz_json:object(), kapps_call:call()) -> kz_term:api_ne_binary(). get_from_uri_realm(Data, Call) -> case kz_json:get_ne_value(<<"from_uri_realm">>, Data) of 'undefined' -> maybe_get_call_from_realm(Call); Realm -> Realm end. --spec maybe_get_call_from_realm(kapps_call:call()) -> api_ne_binary(). +-spec maybe_get_call_from_realm(kapps_call:call()) -> kz_term:api_ne_binary(). maybe_get_call_from_realm(Call) -> case kapps_call:from_realm(Call) of <<"norealm">> -> kz_account:fetch_realm(kapps_call:account_id(Call)); Realm -> Realm end. --spec get_hunt_account_id(kz_json:object(), kapps_call:call()) -> api_ne_binary(). +-spec get_hunt_account_id(kz_json:object(), kapps_call:call()) -> kz_term:api_ne_binary(). get_hunt_account_id(Data, Call) -> case kz_json:is_true(<<"use_local_resources">>, Data, 'true') of 'false' -> 'undefined'; @@ -140,7 +140,7 @@ get_hunt_account_id(Data, Call) -> kz_json:get_value(<<"hunt_account_id">>, Data, AccountId) end. --spec get_to_did(kz_json:object(), kapps_call:call()) -> ne_binary(). +-spec get_to_did(kz_json:object(), kapps_call:call()) -> kz_term:ne_binary(). get_to_did(Data, Call) -> case kz_json:is_true(<<"do_not_normalize">>, Data) of 'false' -> get_to_did(Data, Call, kapps_call:request_user(Call)); @@ -150,7 +150,7 @@ get_to_did(Data, Call) -> RequestUser end. --spec get_to_did(kz_json:object(), kapps_call:call(), ne_binary()) -> ne_binary(). +-spec get_to_did(kz_json:object(), kapps_call:call(), kz_term:ne_binary()) -> kz_term:ne_binary(). get_to_did(_Data, Call, Number) -> case kz_endpoint:get(Call) of {'ok', Endpoint} -> @@ -161,7 +161,7 @@ get_to_did(_Data, Call, Number) -> {'error', _ } -> Number end. --spec get_sip_headers(kz_json:object(), kapps_call:call()) -> api_object(). +-spec get_sip_headers(kz_json:object(), kapps_call:call()) -> kz_term:api_object(). get_sip_headers(Data, Call) -> Routines = [fun(J) -> case kz_json:is_true(<<"emit_account_id">>, Data) of @@ -178,7 +178,7 @@ get_sip_headers(Data, Call) -> 'false' -> JObj end. --spec get_flags(kz_json:object(), kapps_call:call()) -> ne_binaries() | undefined. +-spec get_flags(kz_json:object(), kapps_call:call()) -> kz_term:ne_binaries() | undefined. get_flags(Data, Call) -> Flags = kz_attributes:get_flags(?APP_NAME, Call), Routines = [fun get_flow_flags/3 @@ -187,30 +187,30 @@ get_flags(Data, Call) -> ], lists:foldl(fun(F, A) -> F(Data, Call, A) end, Flags, Routines). --spec get_flow_flags(kz_json:object(), kapps_call:call(), ne_binaries()) -> - ne_binaries(). +-spec get_flow_flags(kz_json:object(), kapps_call:call(), kz_term:ne_binaries()) -> + kz_term:ne_binaries(). get_flow_flags(Data, _Call, Flags) -> case kz_json:get_list_value(<<"outbound_flags">>, Data, []) of [] -> Flags; FlowFlags -> FlowFlags ++ Flags end. --spec get_flow_dynamic_flags(kz_json:object(), kapps_call:call(), ne_binaries()) -> - ne_binaries(). +-spec get_flow_dynamic_flags(kz_json:object(), kapps_call:call(), kz_term:ne_binaries()) -> + kz_term:ne_binaries(). get_flow_dynamic_flags(Data, Call, Flags) -> case kz_json:get_list_value(<<"dynamic_flags">>, Data) of 'undefined' -> Flags; DynamicFlags -> kz_attributes:process_dynamic_flags(DynamicFlags, Flags, Call) end. --spec get_resource_flags(kz_json:object(), kapps_call:call(), ne_binaries()) -> ne_binaries(). +-spec get_resource_flags(kz_json:object(), kapps_call:call(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). get_resource_flags(JObj, Call, Flags) -> get_resource_type_flags(kapps_call:resource_type(Call), JObj, Call, Flags). --spec get_resource_type_flags(ne_binary(), kz_json:object(), kapps_call:call(), ne_binaries()) -> ne_binaries(). +-spec get_resource_type_flags(kz_term:ne_binary(), kz_json:object(), kapps_call:call(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). get_resource_type_flags(<<"sms">>, _JObj, _Call, Flags) -> [<<"sms">> | Flags]; get_resource_type_flags(_Other, _JObj, _Call, Flags) -> Flags. --spec get_inception(kapps_call:call()) -> api_ne_binary(). +-spec get_inception(kapps_call:call()) -> kz_term:api_ne_binary(). get_inception(Call) -> kz_json:get_value(<<"Inception">>, kapps_call:custom_channel_vars(Call)). diff --git a/applications/doodle/src/module/cf_sms_user.erl b/applications/doodle/src/module/cf_sms_user.erl index f0133c2d6de..d0914341441 100644 --- a/applications/doodle/src/module/cf_sms_user.erl +++ b/applications/doodle/src/module/cf_sms_user.erl @@ -53,7 +53,7 @@ handle_result(JObj, Call1) -> Call = doodle_util:set_flow_status(Status, Call1), handle_result_status(Call, Status). --spec handle_result_status(kapps_call:call(), ne_binary()) -> 'ok'. +-spec handle_result_status(kapps_call:call(), kz_term:ne_binary()) -> 'ok'. handle_result_status(Call, <<"pending">>) -> doodle_util:maybe_reschedule_sms(Call); handle_result_status(Call, _Status) -> @@ -78,7 +78,7 @@ maybe_handle_bridge_failure({_ , R}=Reason, Call) -> %% Send to endpoint in determined order %% @end %%-------------------------------------------------------------------- --spec get_endpoints(api_binary(), kz_json:object(), kapps_call:call()) -> +-spec get_endpoints(kz_term:api_binary(), kz_json:object(), kapps_call:call()) -> {kz_json:objects(), non_neg_integer()}. get_endpoints('undefined', _, _) -> {[], 0}; get_endpoints(UserId, Data, Call) -> diff --git a/applications/dth/src/dth.erl b/applications/dth/src/dth.erl index 28a3812f45a..e33f66036eb 100644 --- a/applications/dth/src/dth.erl +++ b/applications/dth/src/dth.erl @@ -17,11 +17,11 @@ %% TODO move these two to a better place --spec add_binding_to_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec add_binding_to_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. add_binding_to_q(Q, _Props) -> amqp_util:bind_q_to_callmgr(Q, ?KEY_DTH_BLACKLIST_REQ), 'ok'. --spec rm_binding_from_q(ne_binary()) -> 'ok'. +-spec rm_binding_from_q(kz_term:ne_binary()) -> 'ok'. rm_binding_from_q(Q) -> amqp_util:unbind_q_from_callmgr(Q, ?KEY_DTH_BLACKLIST_REQ). diff --git a/applications/dth/src/dth_api.erl b/applications/dth/src/dth_api.erl index 1f095d234d3..656cc99ab4c 100644 --- a/applications/dth/src/dth_api.erl +++ b/applications/dth/src/dth_api.erl @@ -20,8 +20,8 @@ %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec blacklist_req(api_terms()) -> {'ok', iolist()} | - {'error', string()}. +-spec blacklist_req(kz_term:api_terms()) -> {'ok', iolist()} | + {'error', string()}. blacklist_req(Prop) when is_list(Prop) -> case blacklist_req_v(Prop) of true -> kz_api:build_message(Prop, ?DTH_BLACKLIST_REQ_HEADERS, ?OPTIONAL_DTH_BLACKLIST_REQ_HEADERS); @@ -30,7 +30,7 @@ blacklist_req(Prop) when is_list(Prop) -> blacklist_req(JObj) -> blacklist_req(kz_json:to_proplist(JObj)). --spec blacklist_req_v(api_terms()) -> boolean(). +-spec blacklist_req_v(kz_term:api_terms()) -> boolean(). blacklist_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?DTH_BLACKLIST_REQ_HEADERS, ?DTH_BLACKLIST_REQ_VALUES, ?DTH_BLACKLIST_REQ_TYPES); blacklist_req_v(JObj) -> @@ -41,8 +41,8 @@ blacklist_req_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec blacklist_resp(api_terms()) -> {'ok', iolist()} | - {'error', string()}. +-spec blacklist_resp(kz_term:api_terms()) -> {'ok', iolist()} | + {'error', string()}. blacklist_resp(Prop) when is_list(Prop) -> case blacklist_resp_v(Prop) of true -> kz_api:build_message(Prop, ?DTH_BLACKLIST_RESP_HEADERS, ?OPTIONAL_DTH_BLACKLIST_RESP_HEADERS); @@ -52,7 +52,7 @@ blacklist_resp(JObj) -> blacklist_resp(kz_json:to_proplist(JObj)). --spec blacklist_resp_v(api_terms()) -> boolean(). +-spec blacklist_resp_v(kz_term:api_terms()) -> boolean(). blacklist_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?DTH_BLACKLIST_RESP_HEADERS, ?DTH_BLACKLIST_RESP_VALUES, ?DTH_BLACKLIST_RESP_TYPES); blacklist_resp_v(JObj) -> diff --git a/applications/dth/src/dth_app.erl b/applications/dth/src/dth_app.erl index 11e6ce54fd8..5236d543a9f 100644 --- a/applications/dth/src/dth_app.erl +++ b/applications/dth/src/dth_app.erl @@ -21,7 +21,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_StartType, _StartArgs) -> _ = declare_exchanges(), dth_sup:start_link(). diff --git a/applications/dth/src/dth_blacklist_req.erl b/applications/dth/src/dth_blacklist_req.erl index 628d3a229e8..d09586ce1a8 100644 --- a/applications/dth/src/dth_blacklist_req.erl +++ b/applications/dth/src/dth_blacklist_req.erl @@ -16,7 +16,7 @@ init() -> ok. --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Props) -> 'true' = dth_api:blacklist_req_v(JObj), diff --git a/applications/dth/src/dth_cdr_handler.erl b/applications/dth/src/dth_cdr_handler.erl index 2a18bd5eb81..3a246218f04 100644 --- a/applications/dth/src/dth_cdr_handler.erl +++ b/applications/dth/src/dth_cdr_handler.erl @@ -59,7 +59,7 @@ init() -> %% WsdlModel = props:get_value(wsdl, Props), %% detergent:call(WsdlModel, "SubmitCallRecord", [CallRecord]). --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, Props) -> 'true' = kapi_call:event_v(JObj), CallID = kz_json:get_value(<<"Call-ID">>, JObj), @@ -143,7 +143,7 @@ get_from_user(JObj) -> From end. --spec get_account_code(kz_json:object()) -> ne_binary(). +-spec get_account_code(kz_json:object()) -> kz_term:ne_binary(). get_account_code(JObj) -> AccountID = kz_binary:truncate_left( kz_json:get_value([<<"Custom-Channel-Vars">>, <<"Account-ID">>], JObj) diff --git a/applications/dth/src/dth_listener.erl b/applications/dth/src/dth_listener.erl index b5e7ee1d78a..92699458965 100644 --- a/applications/dth/src/dth_listener.erl +++ b/applications/dth/src/dth_listener.erl @@ -50,7 +50,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'responders', ?RESPONDERS} ,{'bindings', ?BINDINGS} @@ -111,7 +111,7 @@ maybe_init_model() -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Req, _From, State) -> {'noreply', State}. @@ -125,7 +125,7 @@ handle_call(_Req, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('blacklist_refresh', #state{wsdl_model='undefined'}=State) -> gen_listener:delayed_cast(self(), 'blacklist_refresh', ?BLACKLIST_REFRESH), {'noreply', State#state{wsdl_model=maybe_init_model()}}; @@ -146,7 +146,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. diff --git a/applications/dth/src/dth_sup.erl b/applications/dth/src/dth_sup.erl index 7ed2b7e2921..ff114cffa39 100644 --- a/applications/dth/src/dth_sup.erl +++ b/applications/dth/src/dth_sup.erl @@ -30,7 +30,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -47,7 +47,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/ecallmgr/src/ecallmgr.hrl b/applications/ecallmgr/src/ecallmgr.hrl index 1ff612d9ef8..f404f748d41 100644 --- a/applications/ecallmgr/src/ecallmgr.hrl +++ b/applications/ecallmgr/src/ecallmgr.hrl @@ -33,8 +33,8 @@ -define(DEFAULT_SAMPLE_RATE, ecallmgr_config:get_integer(<<"record_sample_rate">>, 8000)). -define(DEFAULT_STEREO_SAMPLE_RATE, ecallmgr_config:get_integer(<<"record_stereo_sample_rate">>, 16000)). --type fs_app() :: {ne_binary(), binary() | 'noop'} | - {ne_binary(), ne_binary(), atom()}. +-type fs_app() :: {kz_term:ne_binary(), binary() | 'noop'} | + {kz_term:ne_binary(), kz_term:ne_binary(), atom()}. -type fs_apps() :: [fs_app()]. -type fs_api_ret() :: {'ok', binary()} | @@ -53,64 +53,64 @@ {'error', 'badarg' | 'session_attach_failed' | 'badsession' | 'baduuid'} | 'timeout'. --record(sip_subscription, {key :: api_binary() | '_' - ,to :: api_binary() | '$1' | '_' - ,from :: api_binary() | '$2' | '_' +-record(sip_subscription, {key :: kz_term:api_binary() | '_' + ,to :: kz_term:api_binary() | '$1' | '_' + ,from :: kz_term:api_binary() | '$2' | '_' ,node :: atom() | '$1' | '_' ,expires = 300 :: pos_integer() | '$1' | '_' ,timestamp = kz_time:now_s() :: pos_integer() | '$2' | '_' }). --record(channel, {uuid :: api_binary() | '$1' | '$2' | '_' - ,destination :: ne_binary() | '_' - ,direction :: api_binary() | '$1' | '_' - ,account_id :: api_binary() | '$1' | '$2' | '_' - ,account_billing :: api_binary() | '$7' | '_' - ,authorizing_id :: api_binary() | '$1' | '$3' | '_' - ,authorizing_type :: api_binary() | '_' - ,is_authorized :: api_boolean() | '_' - ,owner_id :: api_binary() | '$1' | '_' - ,resource_id :: api_binary() | '$4' | '_' - ,presence_id :: api_binary() | '$2' | '_' - ,fetch_id :: api_binary() | '$5' | '_' - ,bridge_id :: api_binary() | '$5' | '_' - ,reseller_id :: api_binary() | '$1' | '$2' | '_' - ,reseller_billing :: api_binary() | '_' - ,realm :: ne_binary() | '_' | '$2' - ,username :: api_binary() | '_' | '$1' +-record(channel, {uuid :: kz_term:api_binary() | '$1' | '$2' | '_' + ,destination :: kz_term:ne_binary() | '_' + ,direction :: kz_term:api_binary() | '$1' | '_' + ,account_id :: kz_term:api_binary() | '$1' | '$2' | '_' + ,account_billing :: kz_term:api_binary() | '$7' | '_' + ,authorizing_id :: kz_term:api_binary() | '$1' | '$3' | '_' + ,authorizing_type :: kz_term:api_binary() | '_' + ,is_authorized :: kz_term:api_boolean() | '_' + ,owner_id :: kz_term:api_binary() | '$1' | '_' + ,resource_id :: kz_term:api_binary() | '$4' | '_' + ,presence_id :: kz_term:api_binary() | '$2' | '_' + ,fetch_id :: kz_term:api_binary() | '$5' | '_' + ,bridge_id :: kz_term:api_binary() | '$5' | '_' + ,reseller_id :: kz_term:api_binary() | '$1' | '$2' | '_' + ,reseller_billing :: kz_term:api_binary() | '_' + ,realm :: kz_term:ne_binary() | '_' | '$2' + ,username :: kz_term:api_binary() | '_' | '$1' ,import_moh = 'false' :: boolean() | '_' ,answered = 'true' :: boolean() | '_' - ,other_leg :: api_binary() | '$2' | '_' + ,other_leg :: kz_term:api_binary() | '$2' | '_' ,node :: atom() | '$1' | '$2' | '$3' | '_' ,former_node :: atom() | '$2' | '_' - ,timestamp :: gregorian_seconds() | '$3' | '_' - ,profile :: api_binary() | '_' - ,context :: api_binary() | '_' - ,dialplan :: api_binary() | '_' + ,timestamp :: kz_time:gregorian_seconds() | '$3' | '_' + ,profile :: kz_term:api_binary() | '_' + ,context :: kz_term:api_binary() | '_' + ,dialplan :: kz_term:api_binary() | '_' ,precedence = 5 :: pos_integer() | '$2' | '_' ,handling_locally = 'false' :: boolean() | '_' %% is this ecallmgr handling the call control? - ,to_tag :: api_binary() | '_' - ,from_tag :: api_binary() | '_' - ,interaction_id :: api_binary() | '$5' | '_' - ,callee_number :: api_binary() | '$5' | '_' - ,callee_name :: api_binary() | '$5' | '_' + ,to_tag :: kz_term:api_binary() | '_' + ,from_tag :: kz_term:api_binary() | '_' + ,interaction_id :: kz_term:api_binary() | '$5' | '_' + ,callee_number :: kz_term:api_binary() | '$5' | '_' + ,callee_name :: kz_term:api_binary() | '$5' | '_' ,is_loopback :: boolean() | '_' - ,loopback_leg_name :: api_binary() | '_' - ,loopback_other_leg :: api_binary() | '_' - ,callflow_id :: api_binary() | '_' + ,loopback_leg_name :: kz_term:api_binary() | '_' + ,loopback_other_leg :: kz_term:api_binary() | '_' + ,callflow_id :: kz_term:api_binary() | '_' ,is_onhold = 'false' :: boolean() | '_' - ,cavs :: kz_proplist() | '_' | 'undefined' + ,cavs :: kz_term:proplist() | '_' | 'undefined' }). -type channel() :: #channel{}. -type channels() :: [channel()]. -type channel_updates() :: [{pos_integer(), any()}]. --record(conference, {name :: api_binary() | '$1' | '_' - ,uuid :: api_binary() | '$1' | '_' +-record(conference, {name :: kz_term:api_binary() | '$1' | '_' + ,uuid :: kz_term:api_binary() | '$1' | '_' ,node :: atom() | '$1' | '$2' | '_' ,participants = 0 :: non_neg_integer() | '_' - ,profile_name = <<"default">> :: ne_binary() | '_' + ,profile_name = <<"default">> :: kz_term:ne_binary() | '_' ,with_floor :: 'undefined' | non_neg_integer() | '_' % which participant has the floor ,lost_floor :: 'undefined' | non_neg_integer() | '_' % which participant has lost the floor ,running = 'true' :: boolean() | '_' @@ -121,10 +121,10 @@ ,exit_sound = 'true' :: boolean() | '_' ,enter_sound = 'true' :: boolean() | '_' ,start_time = kz_time:now_s() :: non_neg_integer() | '_' - ,switch_hostname :: api_binary() | '_' - ,switch_url :: api_binary() | '_' - ,switch_external_ip :: api_binary() | '_' - ,account_id :: api_binary() | '_' + ,switch_hostname :: kz_term:api_binary() | '_' + ,switch_url :: kz_term:api_binary() | '_' + ,switch_external_ip :: kz_term:api_binary() | '_' + ,account_id :: kz_term:api_binary() | '_' ,handling_locally = 'false' :: boolean() | '_' %% was this ecallmgr handling the call control? ,origin_node :: atom() | '_' ,control_node :: atom() | '_' @@ -133,16 +133,16 @@ -type conference() :: #conference{}. -type conferences() :: [conference()]. --record(participant, {uuid :: api_ne_binary() | '$1' | '_' +-record(participant, {uuid :: kz_term:api_ne_binary() | '$1' | '_' ,node :: atom() | '$2' | '_' - ,conference_uuid :: api_ne_binary() | '$1'| '_' - ,conference_name :: api_ne_binary() | '$1'| '_' - ,join_time = kz_time:now_s() :: gregorian_seconds() | '_' - ,caller_id_name :: api_ne_binary() | '_' - ,caller_id_number :: api_ne_binary() | '_' - ,conference_channel_vars = [] :: kz_proplist() | '_' - ,custom_channel_vars = [] :: kz_proplist() | '_' - ,custom_application_vars = [] :: kz_proplist() | '_' + ,conference_uuid :: kz_term:api_ne_binary() | '$1'| '_' + ,conference_name :: kz_term:api_ne_binary() | '$1'| '_' + ,join_time = kz_time:now_s() :: kz_time:gregorian_seconds() | '_' + ,caller_id_name :: kz_term:api_ne_binary() | '_' + ,caller_id_number :: kz_term:api_ne_binary() | '_' + ,conference_channel_vars = [] :: kz_term:proplist() | '_' + ,custom_channel_vars = [] :: kz_term:proplist() | '_' + ,custom_application_vars = [] :: kz_term:proplist() | '_' }). -type participant() :: #participant{}. -type participants() :: [participant()]. diff --git a/applications/ecallmgr/src/ecallmgr_app.erl b/applications/ecallmgr/src/ecallmgr_app.erl index f5b739fc316..836ee1e0336 100644 --- a/applications/ecallmgr/src/ecallmgr_app.erl +++ b/applications/ecallmgr/src/ecallmgr_app.erl @@ -22,7 +22,7 @@ %% @public %% @doc Implement the application start behaviour --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_StartType, _StartArgs) -> _ = declare_exchanges(), _ = node_bindings(), @@ -88,6 +88,6 @@ freeswitch_nodesup_unbind() -> _ = kazoo_bindings:unbind(<<"freeswitch.node.modules">>, ?MODULE, 'freeswitch_node_modules'), 'ok'. --spec freeswitch_node_modules() -> ne_binaries(). +-spec freeswitch_node_modules() -> kz_term:ne_binaries(). freeswitch_node_modules() -> application:get_env(?APP, 'node_modules', ?NODE_MODULES). diff --git a/applications/ecallmgr/src/ecallmgr_auxiliary_sup.erl b/applications/ecallmgr/src/ecallmgr_auxiliary_sup.erl index 09d80463414..03559c268a2 100644 --- a/applications/ecallmgr/src/ecallmgr_auxiliary_sup.erl +++ b/applications/ecallmgr/src/ecallmgr_auxiliary_sup.erl @@ -48,7 +48,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -68,7 +68,7 @@ cache_proc() -> ?ECALLMGR_UTIL_CACHE. %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, diff --git a/applications/ecallmgr/src/ecallmgr_balance_crawler_statem.erl b/applications/ecallmgr/src/ecallmgr_balance_crawler_statem.erl index 08aef539cde..bc46047e7c4 100644 --- a/applications/ecallmgr/src/ecallmgr_balance_crawler_statem.erl +++ b/applications/ecallmgr/src/ecallmgr_balance_crawler_statem.erl @@ -36,8 +36,8 @@ -type statem_events() :: 'start_cycle' | 'worker_stop'. -type statem_state() :: 'idle' | 'working' | 'worker_timeout'. --type statem_reply() :: {'next_state', statem_state(), api_pid()} | - {'next_state', statem_state(), api_pid(), 'hibernate'}. +-type statem_reply() :: {'next_state', statem_state(), kz_term:api_pid()} | + {'next_state', statem_state(), kz_term:api_pid(), 'hibernate'}. %%==================================================================== %% API @@ -45,7 +45,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> case ?IS_ENABLED of 'true' -> gen_statem:start_link(?SERVER, [], []); @@ -66,7 +66,7 @@ init(_Args) -> callback_mode() -> 'state_functions'. --spec handle_info(any(), atom(), statem_state()) -> handle_fsm_ret(statem_state()). +-spec handle_info(any(), atom(), statem_state()) -> kz_types:handle_fsm_ret(statem_state()). handle_info({'EXIT', WorkerPid, Reason}, StateName, WorkerPid) -> lager:debug("worker: ~p exited with reason ~p", [WorkerPid, Reason]), gen_statem:cast(self(), 'worker_stop'), @@ -83,14 +83,14 @@ terminate(_Reason, _StateName, _State) -> code_change(_OldVsn, StateName, State, _Extra) -> {'ok', StateName, State}. --spec idle(gen_statem:event_type(), statem_events(), api_pid()) -> statem_reply(). +-spec idle(gen_statem:event_type(), statem_events(), kz_term:api_pid()) -> statem_reply(). idle('cast', 'start_cycle', 'undefined') -> WorkerPid = spawn_worker(?CRAWLER_CYCLE_MS), {'next_state', 'working', WorkerPid}; idle('info', Evt, State) -> handle_info(Evt, ?FUNCTION_NAME, State). --spec working(gen_statem:event_type(), statem_events(), api_pid()) -> statem_reply(). +-spec working(gen_statem:event_type(), statem_events(), kz_term:api_pid()) -> statem_reply(). working('cast', 'worker_stop', _OldWorkerPid) -> {'next_state', 'idle', 'undefined', 'hibernate'}; working('cast', 'start_cycle', WorkerPid) -> @@ -99,7 +99,7 @@ working('cast', 'start_cycle', WorkerPid) -> working('info', Evt, State) -> handle_info(Evt, ?FUNCTION_NAME, State). --spec worker_timeout(gen_statem:event_type(), statem_events(), api_pid()) -> statem_reply(). +-spec worker_timeout(gen_statem:event_type(), statem_events(), kz_term:api_pid()) -> statem_reply(). worker_timeout('cast', 'worker_stop', _OldWorkerPid) -> WorkerPid = spawn_worker(?CRAWLER_CYCLE_MS), {'next_state', 'working', WorkerPid}; diff --git a/applications/ecallmgr/src/ecallmgr_balance_crawler_worker.erl b/applications/ecallmgr/src/ecallmgr_balance_crawler_worker.erl index 07efd530781..d89036508fc 100644 --- a/applications/ecallmgr/src/ecallmgr_balance_crawler_worker.erl +++ b/applications/ecallmgr/src/ecallmgr_balance_crawler_worker.erl @@ -28,7 +28,7 @@ start() -> exit('work_done') end. --spec send_req(ne_binaries()) -> ne_binaries(). +-spec send_req(kz_term:ne_binaries()) -> kz_term:ne_binaries(). send_req(Accounts) -> ReqResp = kz_amqp_worker:call(balance_check_req(Accounts) ,fun kapi_authz:publish_balance_check_req/1 @@ -43,14 +43,14 @@ send_req(Accounts) -> balance_check_response(JObj) end. --spec balance_check_req(ne_binaries()) -> kz_proplist(). +-spec balance_check_req(kz_term:ne_binaries()) -> kz_term:proplist(). balance_check_req(Accounts) -> props:filter_undefined( [{<<"Accounts">>, Accounts} | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]). --spec balance_check_response(kz_json:object()) -> ne_binaries(). +-spec balance_check_response(kz_json:object()) -> kz_term:ne_binaries(). balance_check_response(JObj) -> Balances = kz_json:get_json_value(<<"Balances">>, JObj), kz_json:foldl( @@ -64,14 +64,14 @@ balance_check_response(JObj) -> ,Balances ). --spec disconnect_accounts(ne_binaries()) -> 'ok'. +-spec disconnect_accounts(kz_term:ne_binaries()) -> 'ok'. disconnect_accounts([]) -> 'ok'; disconnect_accounts([Account|Accounts]) -> disconnect_account(Account), timer:sleep(?INTERACCOUNT_DELAY_MS), disconnect_accounts(Accounts). --spec disconnect_account(ne_binary()) -> 'ok'. +-spec disconnect_account(kz_term:ne_binary()) -> 'ok'. disconnect_account(AccountId) -> case ecallmgr_fs_channels:per_minute_channels(AccountId) of [] -> @@ -81,13 +81,13 @@ disconnect_account(AccountId) -> disconnect_channels(Channels) end. --spec disconnect_channels(kz_proplist()) -> 'ok'. +-spec disconnect_channels(kz_term:proplist()) -> 'ok'. disconnect_channels([]) -> 'ok'; disconnect_channels([Channel|Channels]) -> try_disconnect_channel(Channel), disconnect_channels(Channels). --spec try_disconnect_channel({atom(), ne_binary()}) -> 'ok'. +-spec try_disconnect_channel({atom(), kz_term:ne_binary()}) -> 'ok'. try_disconnect_channel({Node, UUID}) -> lager:debug("disconnect channel ~p",[UUID]), _ = ecallmgr_util:send_cmd(Node, UUID, "hangup", ""), diff --git a/applications/ecallmgr/src/ecallmgr_call_command.erl b/applications/ecallmgr/src/ecallmgr_call_command.erl index 227713842e6..39b7be6ad7f 100644 --- a/applications/ecallmgr/src/ecallmgr_call_command.erl +++ b/applications/ecallmgr/src/ecallmgr_call_command.erl @@ -23,7 +23,7 @@ -define(RECORD_SOFTWARE, ecallmgr_config:get_ne_binary(<<"recording_software_name">>, <<"2600Hz, Inc.'s Kazoo">>)). --spec exec_cmd(atom(), ne_binary(), kz_json:object(), api_pid()) -> +-spec exec_cmd(atom(), kz_term:ne_binary(), kz_json:object(), kz_term:api_pid()) -> 'ok' | 'error' | ecallmgr_util:send_cmd_ret() | @@ -49,7 +49,7 @@ exec_cmd(_Node, _UUID, JObj, _ControlPid, _DestId) -> lager:debug("command ~s not meant for us but for ~s", [kz_json:get_value(<<"Application-Name">>, JObj), _DestId]), throw(<<"call command provided with a command for a different call id">>). --spec fetch_dialplan(atom(), ne_binary(), kz_json:object(), api_pid()) -> fs_apps(). +-spec fetch_dialplan(atom(), kz_term:ne_binary(), kz_json:object(), kz_term:api_pid()) -> fs_apps(). fetch_dialplan(Node, UUID, JObj, _ControlPid) -> App = kz_json:get_value(<<"Application-Name">>, JObj), case get_fs_app(Node, UUID, JObj, App) of @@ -67,10 +67,10 @@ fetch_dialplan(Node, UUID, JObj, _ControlPid) -> %% the FS ESL via mod_erlang_event %% @end %%-------------------------------------------------------------------- --spec get_fs_app(atom(), ne_binary(), kz_json:object(), ne_binary()) -> +-spec get_fs_app(atom(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> fs_app() | fs_apps() | - {'return', 'error' | ne_binary()} | - {'error', ne_binary()}. + {'return', 'error' | kz_term:ne_binary()} | + {'error', kz_term:ne_binary()}. get_fs_app(Node, UUID, JObj, <<"noop">>) -> case kapi_dialplan:noop_v(JObj) of 'false' -> @@ -623,13 +623,13 @@ get_fs_app(_Node, _UUID, _JObj, _App) -> lager:debug("unknown application ~s", [_App]), {'error', <<"application unknown">>}. --spec media_macro_to_file_string(ne_binaries()) -> ne_binary(). +-spec media_macro_to_file_string(kz_term:ne_binaries()) -> kz_term:ne_binary(). media_macro_to_file_string(Macro) -> Paths = lists:map(fun ecallmgr_util:media_path/1, Macro), list_to_binary(["file_string://", kz_binary:join(Paths, <<"!">>)]). --spec maybe_multi_set(atom(), ne_binary(), kz_proplist()) -> api_binary(). +-spec maybe_multi_set(atom(), kz_term:ne_binary(), kz_term:proplist()) -> kz_term:api_binary(). maybe_multi_set(_Node, _UUID, []) -> 'undefined'; maybe_multi_set(Node, UUID, Vars) -> ecallmgr_util:multi_set_args(Node, UUID, Vars). @@ -640,21 +640,21 @@ maybe_multi_set(Node, UUID, Vars) -> ecallmgr_util:multi_set_args(Node, UUID, Va %% @end %%-------------------------------------------------------------------- --spec lookup_redirect_server(kz_json:object()) -> api_binary(). +-spec lookup_redirect_server(kz_json:object()) -> kz_term:api_binary(). lookup_redirect_server(JObj) -> case kz_json:get_value(<<"Redirect-Server">>, JObj) of 'undefined' -> fixup_redirect_node(kz_json:get_value(<<"Redirect-Node">>, JObj)); Server -> Server end. --spec fixup_redirect_node(api_binary()) -> api_binary(). +-spec fixup_redirect_node(kz_term:api_binary()) -> kz_term:api_binary(). fixup_redirect_node('undefined') -> 'undefined'; fixup_redirect_node(Node) -> SipUrl = ecallmgr_fs_node:sip_url(Node), binary:replace(SipUrl, <<"mod_sofia@">>, <<>>). --spec maybe_add_redirect_header(atom(), ne_binary(), api_binary()) -> 'ok'. +-spec maybe_add_redirect_header(atom(), kz_term:ne_binary(), kz_term:api_binary()) -> 'ok'. maybe_add_redirect_header(_Node, _UUID, 'undefined') -> 'ok'; maybe_add_redirect_header(Node, UUID, RedirectServer) -> lager:debug("Set X-Redirect-Server to ~s", [RedirectServer]), @@ -666,10 +666,10 @@ maybe_add_redirect_header(Node, UUID, RedirectServer) -> %% Eavesdrop command helpers %% @end %%-------------------------------------------------------------------- --spec eavesdrop(atom(), ne_binary(), kz_json:object()) -> - {ne_binary(), ne_binary()} | - {'return', ne_binary()} | - {'error', ne_binary()}. +-spec eavesdrop(atom(), kz_term:ne_binary(), kz_json:object()) -> + {kz_term:ne_binary(), kz_term:ne_binary()} | + {'return', kz_term:ne_binary()} | + {'error', kz_term:ne_binary()}. eavesdrop(Node, UUID, JObj) -> case prepare_app(Node, UUID, JObj) of {'execute', AppNode, AppUUID, AppJObj, AppTarget} -> @@ -684,10 +684,10 @@ eavesdrop(Node, UUID, JObj) -> %% Call pickup command helpers %% @end %%-------------------------------------------------------------------- --spec call_pickup(atom(), ne_binary(), kz_json:object()) -> - {ne_binary(), ne_binary()} | - {'return', ne_binary()} | - {'error', ne_binary()}. +-spec call_pickup(atom(), kz_term:ne_binary(), kz_json:object()) -> + {kz_term:ne_binary(), kz_term:ne_binary()} | + {'return', kz_term:ne_binary()} | + {'error', kz_term:ne_binary()}. call_pickup(Node, UUID, JObj) -> case prepare_app(Node, UUID, JObj) of {'execute', AppNode, AppUUID, AppJObj, AppTarget} -> @@ -696,10 +696,10 @@ call_pickup(Node, UUID, JObj) -> Other end. --spec connect_leg(atom(), ne_binary(), kz_json:object()) -> - {ne_binary(), ne_binary()} | - {'return', ne_binary()} | - {'error', ne_binary()}. +-spec connect_leg(atom(), kz_term:ne_binary(), kz_json:object()) -> + {kz_term:ne_binary(), kz_term:ne_binary()} | + {'return', kz_term:ne_binary()} | + {'error', kz_term:ne_binary()}. connect_leg(Node, UUID, JObj) -> _ = ecallmgr_fs_bridge:maybe_b_leg_events(Node, UUID, JObj), case prepare_app(Node, UUID, JObj) of @@ -709,20 +709,20 @@ connect_leg(Node, UUID, JObj) -> Other end. --spec prepare_app(atom(), ne_binary(), kz_json:object() ) -> - {ne_binary(), ne_binary()} | - {'execute', atom(), ne_binary(), kz_json:object(), ne_binary()} | - {'return', ne_binary()} | - {'error', ne_binary()}. +-spec prepare_app(atom(), kz_term:ne_binary(), kz_json:object() ) -> + {kz_term:ne_binary(), kz_term:ne_binary()} | + {'execute', atom(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()} | + {'return', kz_term:ne_binary()} | + {'error', kz_term:ne_binary()}. prepare_app(Node, UUID, JObj) -> Target = kz_json:get_value(<<"Target-Call-ID">>, JObj), prepare_app(Target, Node, UUID, JObj). --spec prepare_app(ne_binary(), atom(), ne_binary(), kz_json:object() ) -> - {ne_binary(), ne_binary()} | - {'execute', atom(), ne_binary(), kz_json:object(), ne_binary()} | - {'return', ne_binary()} | - {'error', ne_binary()}. +-spec prepare_app(kz_term:ne_binary(), atom(), kz_term:ne_binary(), kz_json:object() ) -> + {kz_term:ne_binary(), kz_term:ne_binary()} | + {'execute', atom(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()} | + {'return', kz_term:ne_binary()} | + {'error', kz_term:ne_binary()}. prepare_app(Target, _Node, Target, _JObj) -> {'error', <<"intercept target is the same as the caller">>}; prepare_app(Target, Node, UUID, JObj) -> @@ -743,11 +743,11 @@ prepare_app(Target, Node, UUID, JObj) -> prepare_app_via_amqp(Node, UUID, JObj, Target) end. --spec prepare_app_via_amqp(atom(), ne_binary(), kz_json:object(), ne_binary()) -> - {ne_binary(), ne_binary()} | - {'return', ne_binary()} | - {'execute', atom(), ne_binary(), kz_json:object(), ne_binary()} | - {'error', ne_binary()}. +-spec prepare_app_via_amqp(atom(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> + {kz_term:ne_binary(), kz_term:ne_binary()} | + {'return', kz_term:ne_binary()} | + {'execute', atom(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()} | + {'error', kz_term:ne_binary()}. prepare_app_via_amqp(Node, UUID, JObj, TargetCallId) -> case kz_amqp_worker:call_collect( [{<<"Call-ID">>, TargetCallId} @@ -788,24 +788,24 @@ prepare_app_status_filter([JObj|JObjs]) -> 'false' -> prepare_app_status_filter(JObjs) end. --spec prepare_app_via_amqp(atom(), ne_binary(), kz_json:object(), ne_binary(), kz_json:object()) -> - {ne_binary(), ne_binary()} | - {'execute', atom(), ne_binary(), kz_json:object(), ne_binary()} | - {'return', ne_binary()}. +-spec prepare_app_via_amqp(atom(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary(), kz_json:object()) -> + {kz_term:ne_binary(), kz_term:ne_binary()} | + {'execute', atom(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()} | + {'return', kz_term:ne_binary()}. prepare_app_via_amqp(Node, UUID, JObj, TargetCallId, Resp) -> TargetNode = kz_json:get_value(<<"Switch-Nodename">>, Resp), lager:debug("call ~s is on ~s", [TargetCallId, TargetNode]), prepare_app_maybe_move_remote(Node, UUID, JObj, TargetCallId, kz_term:to_atom(TargetNode, 'true'), Resp). --spec maybe_answer(atom(), ne_binary(), boolean()) -> 'ok'. +-spec maybe_answer(atom(), kz_term:ne_binary(), boolean()) -> 'ok'. maybe_answer(_Node, _UUID, 'true') -> 'ok'; maybe_answer(Node, UUID, 'false') -> ecallmgr_util:send_cmd(Node, UUID, <<"answer">>, <<>>). --spec prepare_app_maybe_move(atom(), ne_binary(), kz_json:object(), ne_binary(), atom()) -> - {ne_binary(), ne_binary()} | - {'execute', atom(), ne_binary(), kz_json:object(), ne_binary()} | - {'return', ne_binary()}. +-spec prepare_app_maybe_move(atom(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary(), atom()) -> + {kz_term:ne_binary(), kz_term:ne_binary()} | + {'execute', atom(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()} | + {'return', kz_term:ne_binary()}. prepare_app_maybe_move(Node, UUID, JObj, Target, OtherNode) -> case kz_json:is_true(<<"Move-Channel-If-Necessary">>, JObj, 'false') of 'true' -> @@ -822,10 +822,10 @@ prepare_app_maybe_move(Node, UUID, JObj, Target, OtherNode) -> {'return', <<"target is on different media server: ", (kz_term:to_binary(OtherNode))/binary>>} end. --spec prepare_app_maybe_move_remote(atom(), ne_binary(), kz_json:object(), ne_binary(), atom(), kz_json:object()) -> - {ne_binary(), ne_binary()} | - {'execute', atom(), ne_binary(), kz_json:object(), ne_binary()} | - {'return', ne_binary()}. +-spec prepare_app_maybe_move_remote(atom(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary(), atom(), kz_json:object()) -> + {kz_term:ne_binary(), kz_term:ne_binary()} | + {'execute', atom(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()} | + {'return', kz_term:ne_binary()}. prepare_app_maybe_move_remote(Node, UUID, JObj, TargetCallId, TargetNode, ChannelStatusJObj) -> case kz_json:is_true(<<"Move-Channel-If-Necessary">>, JObj, 'false') of 'true' -> @@ -842,7 +842,7 @@ prepare_app_maybe_move_remote(Node, UUID, JObj, TargetCallId, TargetNode, Channe {'return', <<"target is on different media server: ", (kz_term:to_binary(TargetNode))/binary>>} end. --spec prepare_app_usurpers(atom(), ne_binary()) -> 'ok'. +-spec prepare_app_usurpers(atom(), kz_term:ne_binary()) -> 'ok'. prepare_app_usurpers(Node, UUID) -> lager:debug("gotta usurp some fools first"), ControlUsurp = [{<<"Call-ID">>, UUID} @@ -864,8 +864,8 @@ prepare_app_usurpers(Node, UUID) -> ,fun(C) -> kapi_call:publish_usurp_publisher(UUID, C) end ). --spec get_call_pickup_app(atom(), ne_binary(), kz_json:object(), ne_binary(), ne_binary()) -> - {ne_binary(), ne_binary()}. +-spec get_call_pickup_app(atom(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> + {kz_term:ne_binary(), kz_term:ne_binary()}. get_call_pickup_app(Node, UUID, JObj, Target, Command) -> ExportsApi = exports_from_api(JObj, [<<"Continue-On-Fail">> ,<<"Continue-On-Cancel">> @@ -905,14 +905,14 @@ get_call_pickup_app(Node, UUID, JObj, Target, Command) -> {Command, Target}. --spec exports_from_api(kz_json:object(), ne_binaries()) -> kz_proplist(). +-spec exports_from_api(kz_json:object(), kz_term:ne_binaries()) -> kz_term:proplist(). exports_from_api(JObj, Ks) -> props:filter_undefined( [{K, kz_json:get_binary_value(K, JObj)} || K <- Ks] ). --spec get_eavesdrop_app(atom(), ne_binary(), kz_json:object(), ne_binary()) -> - {ne_binary(), ne_binary()}. +-spec get_eavesdrop_app(atom(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> + {kz_term:ne_binary(), kz_term:ne_binary()}. get_eavesdrop_app(Node, UUID, JObj, Target) -> ExportsApi = exports_from_api(JObj, [<<"Park-After-Pickup">> ,<<"Continue-On-Fail">> @@ -940,11 +940,11 @@ get_eavesdrop_app(Node, UUID, JObj, Target) -> _ = ecallmgr_fs_command:export(Node, UUID, Exports), {<<"eavesdrop">>, Target}. --type set_headers() :: kz_proplist() | [{ne_binary(), api_binary(), ne_binary()},...]. +-type set_headers() :: kz_term:proplist() | [{kz_term:ne_binary(), kz_term:api_binary(), kz_term:ne_binary()},...]. -spec build_set_args(set_headers(), kz_json:object()) -> - kz_proplist(). --spec build_set_args(set_headers(), kz_json:object(), kz_proplist()) -> - kz_proplist(). + kz_term:proplist(). +-spec build_set_args(set_headers(), kz_json:object(), kz_term:proplist()) -> + kz_term:proplist(). build_set_args(Headers, JObj) -> build_set_args(Headers, JObj, []). @@ -972,9 +972,9 @@ get_conf_id_and_profile(JObj) -> ProfileName = kz_json:get_ne_value(<<"Profile">>, JObj, <<"default">>), {ConfName, ProfileName}. --spec get_conference_app(atom(), ne_binary(), kz_json:object(), boolean()) -> - {ne_binary(), ne_binary(), atom()} | - {ne_binary(), 'noop' | ne_binary()}. +-spec get_conference_app(atom(), kz_term:ne_binary(), kz_json:object(), boolean()) -> + {kz_term:ne_binary(), kz_term:ne_binary(), atom()} | + {kz_term:ne_binary(), 'noop' | kz_term:ne_binary()}. get_conference_app(ChanNode, UUID, JObj, 'true') -> {ConfName, ConferenceConfig} = get_conf_id_and_profile(JObj), Cmd = list_to_binary([ConfName, "@", ConferenceConfig, get_conference_flags(JObj)]), @@ -1001,9 +1001,9 @@ get_conference_app(ChanNode, UUID, JObj, 'false') -> %% ecallmgr_fs_command:export(ChanNode, UUID, [{<<"Hold-Media">>, <<"silence">>}]), {<<"conference">>, list_to_binary([ConfName, "@", ConferenceConfig, get_conference_flags(JObj)])}. --spec maybe_start_conference_on_our_node(atom(), ne_binary(), kz_json:object()) -> - {ne_binary(), ne_binary(), atom()} | - {ne_binary(), 'noop' | ne_binary()}. +-spec maybe_start_conference_on_our_node(atom(), kz_term:ne_binary(), kz_json:object()) -> + {kz_term:ne_binary(), kz_term:ne_binary(), atom()} | + {kz_term:ne_binary(), 'noop' | kz_term:ne_binary()}. maybe_start_conference_on_our_node(ChanNode, UUID, JObj) -> {ConfName, ConferenceConfig} = get_conf_id_and_profile(JObj), Cmd = list_to_binary([ConfName, "@", ConferenceConfig, get_conference_flags(JObj)]), @@ -1062,7 +1062,7 @@ maybe_add_conference_flag({K, V}, Acc) -> _ -> Acc end. --spec wait_for_conference(ne_binary()) -> {'ok', atom()}. +-spec wait_for_conference(kz_term:ne_binary()) -> {'ok', atom()}. wait_for_conference(ConfName) -> case ecallmgr_fs_conferences:node(ConfName) of {'ok', _N}=OK -> OK; @@ -1077,7 +1077,7 @@ wait_for_conference(ConfName) -> %% Store command helpers %% @end %%-------------------------------------------------------------------- --spec stream_over_http(atom(), ne_binary(), file:filename_all(), 'put' | 'post', 'store'| 'store_vm' | 'fax', kz_json:object()) -> any(). +-spec stream_over_http(atom(), kz_term:ne_binary(), file:filename_all(), 'put' | 'post', 'store'| 'store_vm' | 'fax', kz_json:object()) -> any(). stream_over_http(Node, UUID, File, 'put'=Method, 'store'=Type, JObj) -> Url = kz_term:to_list(kz_json:get_value(<<"Media-Transfer-Destination">>, JObj)), lager:debug("streaming via HTTP(~s) to ~s", [Method, Url]), @@ -1117,25 +1117,25 @@ stream_over_http(Node, UUID, File, Method, Type, JObj) -> 'fax' -> send_store_fax_call_event(UUID, Result) end. --spec maybe_send_detailed_alert(boolean(), atom(), ne_binary(), ne_binary(), 'store' | 'fax', any()) -> any(). +-spec maybe_send_detailed_alert(boolean(), atom(), kz_term:ne_binary(), kz_term:ne_binary(), 'store' | 'fax', any()) -> any(). maybe_send_detailed_alert('true', _, _, _, _, _) -> 'ok'; maybe_send_detailed_alert(_, Node, UUID, File, Type, Reason) -> send_detailed_alert(Node, UUID, File, Type, Reason). --spec send_detailed_alert(atom(), ne_binary(), ne_binary(), 'store' | 'fax', any()) -> any(). +-spec send_detailed_alert(atom(), kz_term:ne_binary(), kz_term:ne_binary(), 'store' | 'fax', any()) -> any(). send_detailed_alert(Node, UUID, File, Type, Reason) -> kz_notify:detailed_alert("Failed to store ~s: media file ~s for call ~s on ~s " ,[Type, File, UUID, Node] ,[{<<"Details">>, Reason}] ). --spec send_fs_store(atom(), ne_binary(), 'put' | 'post') -> fs_api_ret(). +-spec send_fs_store(atom(), kz_term:ne_binary(), 'put' | 'post') -> fs_api_ret(). send_fs_store(Node, Args, 'put') -> freeswitch:api(Node, 'http_put', kz_term:to_list(Args), 120 * ?MILLISECONDS_IN_SECOND); send_fs_store(Node, Args, 'post') -> freeswitch:api(Node, 'http_post', kz_term:to_list(Args), 120 * ?MILLISECONDS_IN_SECOND). --spec send_fs_bg_store(atom(), ne_binary(), ne_binary(), ne_binary(), 'put' | 'post', 'store' | 'store_vm' | 'fax') -> fs_api_ret(). +-spec send_fs_bg_store(atom(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), 'put' | 'post', 'store' | 'store_vm' | 'fax') -> fs_api_ret(). send_fs_bg_store(Node, UUID, File, Args, 'put', 'store') -> case freeswitch:bgapi(Node, UUID, [File], 'http_put', kz_term:to_list(Args), fun chk_store_result/6) of {'error', _} -> send_store_call_event(Node, UUID, <<"failure">>); @@ -1147,7 +1147,7 @@ send_fs_bg_store(Node, UUID, File, Args, 'put', 'store_vm') -> {'ok', JobId} -> lager:debug("bgapi started ~p", [JobId]) end. --spec chk_store_result(atom(), atom(), ne_binary(), list(), ne_binary(), binary()) -> 'ok'. +-spec chk_store_result(atom(), atom(), kz_term:ne_binary(), list(), kz_term:ne_binary(), binary()) -> 'ok'. chk_store_result(Res, Node, UUID, [File], JobId, <<"+OK", _/binary>>=Reply) -> lager:debug("chk_store_result ~p : ~p : ~p", [Res, JobId, Reply]), send_store_call_event(Node, UUID, {<<"success">>, File}); @@ -1155,7 +1155,7 @@ chk_store_result(Res, Node, UUID, [File], JobId, Reply) -> lager:debug("chk_store_result ~p : ~p : ~p", [Res, JobId, Reply]), send_store_call_event(Node, UUID, {<<"failure">>, File}). --spec chk_store_vm_result(atom(), atom(), ne_binary(), list(), ne_binary(), binary()) -> 'ok'. +-spec chk_store_vm_result(atom(), atom(), kz_term:ne_binary(), list(), kz_term:ne_binary(), binary()) -> 'ok'. chk_store_vm_result(Res, Node, UUID, _, JobId, <<"+OK", _/binary>>=Reply) -> lager:debug("chk_store_result ~p : ~p : ~p", [Res, JobId, Reply]), send_store_vm_call_event(Node, UUID, <<"success">>); @@ -1163,7 +1163,7 @@ chk_store_vm_result(Res, Node, UUID, _, JobId, Reply) -> lager:debug("chk_store_result ~p : ~p : ~p", [Res, JobId, Reply]), send_store_vm_call_event(Node, UUID, <<"failure">>). --spec send_store_call_event(atom(), ne_binary(), kz_json:object() | ne_binary() | {ne_binary(), api_binary()}) -> 'ok'. +-spec send_store_call_event(atom(), kz_term:ne_binary(), kz_json:object() | kz_term:ne_binary() | {kz_term:ne_binary(), kz_term:api_binary()}) -> 'ok'. send_store_call_event(Node, UUID, {MediaTransResults, File}) -> ChannelProps = case ecallmgr_fs_channel:channel_data(Node, UUID) of @@ -1178,7 +1178,7 @@ send_store_call_event(Node, UUID, {MediaTransResults, File}) -> send_store_call_event(Node, UUID, MediaTransResults) -> send_store_call_event(Node, UUID, {MediaTransResults, 'undefined'}). --spec maybe_add_ccvs(kz_proplist(), kz_proplist()) -> kz_proplist(). +-spec maybe_add_ccvs(kz_term:proplist(), kz_term:proplist()) -> kz_term:proplist(). maybe_add_ccvs(BaseProps, ChannelProps) -> case ecallmgr_util:custom_channel_vars(ChannelProps) of [] -> BaseProps; @@ -1189,7 +1189,7 @@ maybe_add_ccvs(BaseProps, ChannelProps) -> ) end. --spec maybe_add_cavs(kz_proplist(), kz_proplist()) -> kz_proplist(). +-spec maybe_add_cavs(kz_term:proplist(), kz_term:proplist()) -> kz_term:proplist(). maybe_add_cavs(BaseProps, ChannelProps) -> case ecallmgr_util:custom_application_vars(ChannelProps) of [] -> BaseProps; @@ -1200,7 +1200,7 @@ maybe_add_cavs(BaseProps, ChannelProps) -> ) end. --spec build_base_store_event_props(ne_binary(), kz_proplist(), ne_binary(), api_binary(), ne_binary()) -> kz_proplist(). +-spec build_base_store_event_props(kz_term:ne_binary(), kz_term:proplist(), kz_term:ne_binary(), kz_term:api_binary(), kz_term:ne_binary()) -> kz_term:proplist(). build_base_store_event_props(UUID, ChannelProps, MediaTransResults, File, App) -> Timestamp = kz_term:to_binary(kz_time:now_s()), props:filter_undefined( @@ -1214,7 +1214,7 @@ build_base_store_event_props(UUID, ChannelProps, MediaTransResults, File, App) - | kz_api:default_headers(<<"call_event">>, <<"CHANNEL_EXECUTE_COMPLETE">>, ?APP_NAME, ?APP_VERSION) ]). --spec send_store_vm_call_event(atom(), ne_binary(), kz_json:object() | ne_binary()) -> 'ok'. +-spec send_store_vm_call_event(atom(), kz_term:ne_binary(), kz_json:object() | kz_term:ne_binary()) -> 'ok'. send_store_vm_call_event(Node, UUID, MediaTransResults) -> ChannelProps = case ecallmgr_fs_channel:channel_data(Node, UUID) of @@ -1227,7 +1227,7 @@ send_store_vm_call_event(Node, UUID, MediaTransResults) -> kz_amqp_worker:cast(ApiProps, fun kapi_call:publish_event/1). --spec send_store_fax_call_event(ne_binary(), ne_binary()) -> 'ok'. +-spec send_store_fax_call_event(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. send_store_fax_call_event(UUID, Results) -> Timestamp = kz_term:to_binary(kz_time:now_s()), Prop = [{<<"Msg-ID">>, Timestamp} @@ -1243,8 +1243,8 @@ send_store_fax_call_event(UUID, Results) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec find_fetch_channel_data(atom(), ne_binary(), kz_json:object()) -> - {'ok', kz_proplist()}. +-spec find_fetch_channel_data(atom(), kz_term:ne_binary(), kz_json:object()) -> + {'ok', kz_term:proplist()}. find_fetch_channel_data(Node, UUID, JObj) -> case kz_json:is_true(<<"From-Other-Leg">>, JObj) of 'true' -> @@ -1254,7 +1254,7 @@ find_fetch_channel_data(Node, UUID, JObj) -> ecallmgr_fs_channel:channel_data(Node, UUID) end. --spec send_fetch_call_event(atom(), ne_binary(), kz_json:object()) -> 'ok'. +-spec send_fetch_call_event(atom(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. send_fetch_call_event(Node, UUID, JObj) -> try {'ok', ChannelProps} = find_fetch_channel_data(Node, UUID, JObj), @@ -1267,8 +1267,8 @@ send_fetch_call_event(Node, UUID, JObj) -> kz_amqp_worker:cast(Error, fun(E) -> kapi_dialplan:publish_error(UUID, E) end) end. --spec base_fetch_error_event_props(ne_binary(), kz_json:object(), atom()) -> - kz_proplist(). +-spec base_fetch_error_event_props(kz_term:ne_binary(), kz_json:object(), atom()) -> + kz_term:proplist(). base_fetch_error_event_props(UUID, JObj, Type) -> props:filter_undefined( [{<<"Msg-ID">>, kz_json:get_value(<<"Msg-ID">>, JObj)} @@ -1279,8 +1279,8 @@ base_fetch_error_event_props(UUID, JObj, Type) -> | kz_api:default_headers(<<"error">>, kz_term:to_binary(Type), ?APP_NAME, ?APP_VERSION) ]). --spec base_fetch_call_event_props(ne_binary(), kz_proplist()) -> - kz_proplist(). +-spec base_fetch_call_event_props(kz_term:ne_binary(), kz_term:proplist()) -> + kz_term:proplist(). base_fetch_call_event_props(UUID, ChannelProps) -> props:filter_undefined( [{<<"Msg-ID">>, props:get_value(<<"Event-Date-Timestamp">>, ChannelProps)} @@ -1334,7 +1334,7 @@ execute_exten_post_exec(DP, _Node, _UUID, _JObj) -> |DP ]. --spec create_dialplan_move_ccvs(atom(), ne_binary(), kz_proplist()) -> kz_proplist(). +-spec create_dialplan_move_ccvs(atom(), kz_term:ne_binary(), kz_term:proplist()) -> kz_term:proplist(). create_dialplan_move_ccvs(Node, UUID, DP) -> case ecallmgr_fs_channel:channel_data(Node, UUID) of {'ok', Props} -> @@ -1344,7 +1344,7 @@ create_dialplan_move_ccvs(Node, UUID, DP) -> DP end. --spec create_dialplan_move_ccvs(kz_proplist(), kz_proplist()) -> kz_proplist(). +-spec create_dialplan_move_ccvs(kz_term:proplist(), kz_term:proplist()) -> kz_term:proplist(). create_dialplan_move_ccvs(DP, Props) -> lists:foldr( fun({<<"variable_", ?CHANNEL_VAR_PREFIX, Key/binary>>, Val}, Acc) -> @@ -1373,8 +1373,8 @@ create_dialplan_move_ccvs(DP, Props) -> ,Props ). --spec tts(atom(), ne_binary(), kz_json:object()) -> - {ne_binary(), ne_binary()}. +-spec tts(atom(), kz_term:ne_binary(), kz_json:object()) -> + {kz_term:ne_binary(), kz_term:ne_binary()}. tts(Node, UUID, JObj) -> 'ok' = set_terminators(Node, UUID, kz_json:get_value(<<"Terminators">>, JObj)), @@ -1406,13 +1406,13 @@ tts(Node, UUID, JObj) -> %% Playback command helpers %% @end %%-------------------------------------------------------------------- --spec play(atom(), ne_binary(), kz_json:object()) -> fs_apps(). +-spec play(atom(), kz_term:ne_binary(), kz_json:object()) -> fs_apps(). play(Node, UUID, JObj) -> [play_vars(Node, UUID, JObj) ,play_app(UUID, JObj) ]. --spec play_app(ne_binary(), kz_json:object()) -> fs_app(). +-spec play_app(kz_term:ne_binary(), kz_json:object()) -> fs_app(). play_app(UUID, JObj) -> MediaName = kz_json:get_value(<<"Media-Name">>, JObj), F = ecallmgr_util:media_path(MediaName, 'new', UUID, JObj), @@ -1422,14 +1422,14 @@ play_app(UUID, JObj) -> 'true' -> play_bridged(UUID, JObj, F) end. --spec playback_app(kz_json:object()) -> ne_binary(). +-spec playback_app(kz_json:object()) -> kz_term:ne_binary(). playback_app(JObj) -> case kz_json:is_true(<<"Endless-Playback">>, JObj, 'false') of 'true' -> <<"endless_playback">>; 'false' -> <<"playback">> end. --spec play_bridged(ne_binary(), kz_json:object(), ne_binary()) -> fs_app(). +-spec play_bridged(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> fs_app(). play_bridged(UUID, JObj, F) -> case kz_json:get_value(<<"Leg">>, JObj) of <<"self">> -> {<<"broadcast">>, list_to_binary([UUID, " '", F, <<"' aleg">>])}; @@ -1440,7 +1440,7 @@ play_bridged(UUID, JObj, F) -> 'undefined' -> {<<"broadcast">>, list_to_binary([UUID, " '", F, <<"' both">>])} end. --spec play_vars(atom(), ne_binary(), kz_json:object()) -> fs_app(). +-spec play_vars(atom(), kz_term:ne_binary(), kz_json:object()) -> fs_app(). play_vars(Node, UUID, JObj) -> Routines = [fun(V) -> case kz_json:get_value(<<"Group-ID">>, JObj) of @@ -1464,8 +1464,8 @@ play_vars(Node, UUID, JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_terminators(api_binary() | ne_binaries() | kz_json:object()) -> - {ne_binary(), ne_binary()} | 'undefined'. +-spec get_terminators(kz_term:api_binary() | kz_term:ne_binaries() | kz_json:object()) -> + {kz_term:ne_binary(), kz_term:ne_binary()} | 'undefined'. get_terminators('undefined') -> {<<"playback_terminators">>, <<"none">>}; get_terminators(Ts) when is_binary(Ts) -> get_terminators([Ts]); get_terminators([]) -> {<<"playback_terminators">>, <<"none">>}; @@ -1481,7 +1481,7 @@ get_terminators(Ts) when is_list(Ts) -> end; get_terminators(JObj) -> get_terminators(kz_json:get_ne_value(<<"Terminators">>, JObj)). --spec set_terminators(atom(), ne_binary(), api_binary() | ne_binaries()) -> +-spec set_terminators(atom(), kz_term:ne_binary(), kz_term:api_binary() | kz_term:ne_binaries()) -> ecallmgr_util:send_cmd_ret(). set_terminators(Node, UUID, Ts) -> case get_terminators(Ts) of @@ -1498,7 +1498,7 @@ say_language('undefined') -> <<"en">>; say_language(<<_:2/binary>> = Lang) -> Lang; say_language(<>) -> Lang. --spec maybe_set_park_timeout(atom(), ne_binary(), kz_json:object()) -> 'ok'. +-spec maybe_set_park_timeout(atom(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. maybe_set_park_timeout(Node, UUID, JObj) -> case kz_json:get_integer_value(<<"Timeout">>, JObj) of 'undefined' -> 'ok'; @@ -1512,12 +1512,12 @@ maybe_set_park_timeout(Node, UUID, JObj) -> ecallmgr_fs_command:set(Node, UUID, [{<<"park_timeout">>, ParkTimeout}]) end. --spec record_call(atom(), ne_binary(), kz_json:object()) -> fs_app(). +-spec record_call(atom(), kz_term:ne_binary(), kz_json:object()) -> fs_app(). record_call(Node, UUID, JObj) -> Action = kz_json:get_value(<<"Record-Action">>, JObj), record_call(Node, UUID, Action, JObj). --spec record_call(atom(), ne_binary(), ne_binary(), kz_json:object()) -> fs_app(). +-spec record_call(atom(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> fs_app(). record_call(Node, UUID, <<"start">>, JObj) -> Vars = props:filter_undefined(record_call_vars(JObj)), Args = ecallmgr_util:process_fs_kv(Node, UUID, Vars, 'set'), @@ -1541,7 +1541,7 @@ record_call(_Node, _UUID, <<"stop">>, JObj) -> end, {<<"stop_record_session">>, RecordingName}. --spec record_call_vars(kz_json:object()) -> kz_proplist(). +-spec record_call_vars(kz_json:object()) -> kz_term:proplist(). record_call_vars(JObj) -> Routines = [fun maybe_waste_resources/1 ,fun(Acc) -> maybe_get_terminators(Acc, JObj) end @@ -1570,21 +1570,21 @@ record_call_vars(JObj) -> ,Routines ). --spec maybe_waste_resources(kz_proplist()) -> kz_proplist(). +-spec maybe_waste_resources(kz_term:proplist()) -> kz_term:proplist(). maybe_waste_resources(Acc) -> case ecallmgr_config:is_true(<<"record_waste_resources">>, 'false') of 'false' -> Acc; 'true' -> [{<<"record_waste_resources">>, <<"true">>} | Acc] end. --spec maybe_get_terminators(kz_proplist(), kz_json:object()) -> kz_proplist(). +-spec maybe_get_terminators(kz_term:proplist(), kz_json:object()) -> kz_term:proplist(). maybe_get_terminators(Acc, JObj) -> case get_terminators(JObj) of 'undefined' -> Acc; Terminators -> [Terminators|Acc] end. --spec should_record_stereo(kz_json:object()) -> ne_binary(). +-spec should_record_stereo(kz_json:object()) -> kz_term:ne_binary(). should_record_stereo(JObj) -> case kz_json:is_true(<<"Channels-As-Stereo">>, JObj, 'true') of 'true' -> <<"true">>; @@ -1605,7 +1605,7 @@ get_default_sample_rate(JObj) -> <<"false">> -> ?DEFAULT_SAMPLE_RATE end. --spec tones_app(kz_json:objects()) -> {ne_binary(), iodata()}. +-spec tones_app(kz_json:objects()) -> {kz_term:ne_binary(), iodata()}. tones_app(Tones) -> FSTones = [tone_to_fs_tone(Tone) || Tone <- Tones], Arg = "tone_stream://" ++ string:join(FSTones, ";"), @@ -1639,7 +1639,7 @@ tone_repeat(Tone) -> R -> list_to_binary(["l=", kz_term:to_list(R), ";"]) end. --spec tone_frequencies(kz_json:object()) -> ne_binary(). +-spec tone_frequencies(kz_json:object()) -> kz_term:ne_binary(). tone_frequencies(Tone) -> kz_binary:join( [kz_term:to_binary(V) @@ -1648,21 +1648,21 @@ tone_frequencies(Tone) -> ,<<",">> ). --spec tone_duration_on(kz_json:object()) -> ne_binary(). +-spec tone_duration_on(kz_json:object()) -> kz_term:ne_binary(). tone_duration_on(Tone) -> kz_json:get_binary_value(<<"Duration-ON">>, Tone). --spec tone_duration_off(kz_json:object()) -> ne_binary(). +-spec tone_duration_off(kz_json:object()) -> kz_term:ne_binary(). tone_duration_off(Tone) -> kz_json:get_binary_value(<<"Duration-OFF">>, Tone). --spec transfer(atom(), ne_binary(), kz_json:object()) -> {ne_binary(), ne_binary()}. +-spec transfer(atom(), kz_term:ne_binary(), kz_json:object()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. transfer(Node, UUID, JObj) -> TransferType = kz_json:get_value(<<"Transfer-Type">>, JObj), TransferTo = kz_json:get_value(<<"Transfer-To">>, JObj), transfer(Node, UUID, TransferType, TransferTo, JObj). --spec transfer(atom(), ne_binary(), ne_binary(), ne_binary(), kz_json:object()) -> {ne_binary(), ne_binary()}. +-spec transfer(atom(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. transfer(Node, UUID, <<"attended">>, TransferTo, JObj) -> CCVs = kz_json:to_proplist(kz_json:get_value(<<"Custom-Channel-Vars">>, JObj, kz_json:new())), CCVList = [<<"Account-ID">> @@ -1702,14 +1702,14 @@ transfer(Node, UUID, <<"blind">>, TransferTo, JObj) -> ,{<<"blind_xfer">>, list_to_binary([TransferLeg, " ", TransferTo, <<" XML ">>, transfer_context(JObj)])} ]. --spec transfer_realm(ne_binary()) -> ne_binary(). +-spec transfer_realm(kz_term:ne_binary()) -> kz_term:ne_binary(). transfer_realm(UUID) -> case ecallmgr_fs_channel:fetch(UUID, 'record') of {'ok', #channel{realm=Realm}} -> Realm; _Else -> <<"norealm">> end. --spec transfer_set_callid(ne_binary(), binary()) -> ne_binary(). +-spec transfer_set_callid(kz_term:ne_binary(), binary()) -> kz_term:ne_binary(). transfer_set_callid(UUID, <<"-bleg">>) -> case ecallmgr_fs_channel:fetch(UUID, 'record') of {'ok', #channel{other_leg='undefined'}} -> UUID; @@ -1718,7 +1718,7 @@ transfer_set_callid(UUID, <<"-bleg">>) -> end; transfer_set_callid(UUID, _) -> UUID. --spec transfer_referred(ne_binary(), binary()) -> api_binary(). +-spec transfer_referred(kz_term:ne_binary(), binary()) -> kz_term:api_binary(). transfer_referred(UUID, <<"-bleg">>) -> case ecallmgr_fs_channel:fetch(UUID, 'record') of {'ok', #channel{presence_id='undefined'}} -> 'undefined'; @@ -1743,7 +1743,7 @@ transfer_leg(JObj) -> transfer_context(JObj) -> kz_json:get_value(<<"Transfer-Context">>, JObj, ?DEFAULT_FREESWITCH_CONTEXT). --spec sound_touch(ne_binary(), ne_binary(), kz_json:object()) -> {ne_binary(), ne_binary()}. +-spec sound_touch(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. sound_touch(UUID, <<"start">>, JObj) -> {<<"soundtouch">>, list_to_binary([UUID, " start ", sound_touch_options(JObj)])}; sound_touch(UUID, <<"stop">>, _JObj) -> @@ -1772,9 +1772,9 @@ sound_touch_options(JObj) -> {Args, _} = lists:foldl(fun sound_touch_options_fold/2, {[], JObj}, Options), kz_binary:join(lists:reverse(Args), <<" ">>). --type sound_touch_fun() :: fun((kz_json:json_term(), ne_binaries())-> ne_binaries()). --type sound_touch_option() :: {ne_binary(), sound_touch_fun()}. --type sound_touch_option_acc() :: {ne_binaries(), kz_json:object()}. +-type sound_touch_fun() :: fun((kz_json:json_term(), kz_term:ne_binaries())-> kz_term:ne_binaries()). +-type sound_touch_option() :: {kz_term:ne_binary(), sound_touch_fun()}. +-type sound_touch_option_acc() :: {kz_term:ne_binaries(), kz_json:object()}. -spec sound_touch_options_fold(sound_touch_option(), sound_touch_option_acc()) -> sound_touch_option_acc(). sound_touch_options_fold({K, F}, {List, JObj}=Acc) -> diff --git a/applications/ecallmgr/src/ecallmgr_call_control.erl b/applications/ecallmgr/src/ecallmgr_call_control.erl index c1b9ced1f6b..4817e8bb614 100644 --- a/applications/ecallmgr/src/ecallmgr_call_control.erl +++ b/applications/ecallmgr/src/ecallmgr_call_control.erl @@ -78,23 +78,23 @@ -type insert_at_options() :: 'now' | 'head' | 'tail' | 'flush'. -record(state, {node :: atom() - ,call_id :: ne_binary() + ,call_id :: kz_term:ne_binary() ,command_q = queue:new() :: queue:queue() - ,current_app :: api_binary() - ,current_cmd :: api_object() - ,start_time = os:timestamp() :: kz_now() + ,current_app :: kz_term:api_binary() + ,current_cmd :: kz_term:api_object() + ,start_time = os:timestamp() :: kz_time:now() ,is_call_up = 'true' :: boolean() ,is_node_up = 'true' :: boolean() - ,keep_alive_ref :: api_reference() - ,other_legs = [] :: ne_binaries() - ,last_removed_leg :: api_binary() - ,sanity_check_tref :: api_reference() - ,msg_id :: api_binary() - ,fetch_id :: api_binary() - ,controller_q :: api_ne_binary() - ,control_q :: api_ne_binary() + ,keep_alive_ref :: kz_term:api_reference() + ,other_legs = [] :: kz_term:ne_binaries() + ,last_removed_leg :: kz_term:api_binary() + ,sanity_check_tref :: kz_term:api_reference() + ,msg_id :: kz_term:api_binary() + ,fetch_id :: kz_term:api_binary() + ,controller_q :: kz_term:api_ne_binary() + ,control_q :: kz_term:api_ne_binary() ,initial_ccvs :: kz_json:object() - ,node_down_tref :: api_reference() + ,node_down_tref :: kz_term:api_reference() }). -type state() :: #state{}. @@ -110,8 +110,8 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(atom(), ne_binary(), api_ne_binary(), api_ne_binary(), kz_json:object()) -> - startlink_ret(). +-spec start_link(atom(), kz_term:ne_binary(), kz_term:api_ne_binary(), kz_term:api_ne_binary(), kz_json:object()) -> + kz_types:startlink_ret(). start_link(Node, CallId, FetchId, ControllerQ, CCVs) -> %% We need to become completely decoupled from ecallmgr_call_events %% because the call_events process might have been spun up with A->B @@ -138,11 +138,11 @@ start_link(Node, CallId, FetchId, ControllerQ, CCVs) -> stop(Srv) -> gen_listener:cast(Srv, 'stop'). --spec callid(pid()) -> ne_binary(). +-spec callid(pid()) -> kz_term:ne_binary(). callid(Srv) -> gen_listener:call(Srv, 'callid', ?MILLISECONDS_IN_SECOND). --spec node(pid()) -> ne_binary(). +-spec node(pid()) -> kz_term:ne_binary(). node(Srv) -> gen_listener:call(Srv, 'node', ?MILLISECONDS_IN_SECOND). @@ -152,27 +152,27 @@ hostname(Srv) -> [_, Hostname] = binary:split(kz_term:to_binary(Node), <<"@">>), Hostname. --spec queue_name(api_pid()) -> api_ne_binary(). +-spec queue_name(kz_term:api_pid()) -> kz_term:api_ne_binary(). queue_name('undefined') -> 'undefined'; queue_name(Srv) when is_pid(Srv) -> gen_listener:queue_name(Srv). --spec other_legs(pid()) -> ne_binaries(). +-spec other_legs(pid()) -> kz_term:ne_binaries(). other_legs(Srv) -> gen_listener:call(Srv, 'other_legs', ?MILLISECONDS_IN_SECOND). --spec event_execute_complete(api_pid(), ne_binary(), ne_binary()) -> 'ok'. +-spec event_execute_complete(kz_term:api_pid(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. event_execute_complete('undefined', _CallId, _App) -> 'ok'; event_execute_complete(Srv, CallId, App) -> gen_listener:cast(Srv, {'event_execute_complete', CallId, App, kz_json:new()}). --spec update_node(atom(), ne_binary() | pids()) -> 'ok'. +-spec update_node(atom(), kz_term:ne_binary() | kz_term:pids()) -> 'ok'. update_node(Node, CallId) when is_binary(CallId) -> update_node(Node, gproc:lookup_pids({'p', 'l', {'call_control', CallId}})); update_node(Node, Pids) when is_list(Pids) -> _ = [gen_listener:cast(Srv, {'update_node', Node}) || Srv <- Pids], 'ok'. --spec control_procs(ne_binary()) -> pids(). +-spec control_procs(kz_term:ne_binary()) -> kz_term:pids(). control_procs(CallId) -> gproc:lookup_pids({'p', 'l', {'call_control', CallId}}). @@ -194,7 +194,7 @@ fs_nodedown(Srv, Node) -> %% Initializes the server %% @end %%-------------------------------------------------------------------- --spec init([atom() | ne_binary() | kz_json:object()]) -> {'ok', state()}. +-spec init([atom() | kz_term:ne_binary() | kz_json:object()]) -> {'ok', state()}. init([Node, CallId, FetchId, ControllerQ, CCVs]) -> kz_util:put_callid(CallId), lager:debug("starting call control listener"), @@ -227,7 +227,7 @@ init([Node, CallId, FetchId, ControllerQ, CCVs]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call('node', _From, #state{node=Node}=State) -> {'reply', Node, State}; handle_call('callid', _From, #state{call_id=CallId}=State) -> @@ -247,7 +247,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('init', State) -> TRef = erlang:send_after(?SANITY_CHECK_PERIOD, self(), 'sanity_check'), {'noreply', State#state{sanity_check_tref=TRef}}; @@ -311,7 +311,7 @@ handle_cast(_, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'event', [CallId | Props]}, #state{call_id=CallId}=State) -> handle_event_info(CallId, Props, State); handle_info({'event', [CallId | Props]}, State) -> @@ -385,7 +385,7 @@ handle_call_command(JObj) -> handle_conference_command(JObj) -> gen_listener:cast(self(), {'dialplan', JObj}). --spec handle_call_events(kz_json:object(), ne_binary()) -> 'ok'. +-spec handle_call_events(kz_json:object(), kz_term:ne_binary()) -> 'ok'. handle_call_events(JObj, FetchId) -> kz_util:put_callid(kz_json:get_value(<<"Call-ID">>, JObj)), case kz_json:get_value(<<"Event-Name">>, JObj) of @@ -563,7 +563,7 @@ force_queue_advance(#state{call_id=CallId %% %% @end %%-------------------------------------------------------------------- --spec handle_execute_complete(api_binary(), kz_json:object(), state()) -> state(). +-spec handle_execute_complete(kz_term:api_binary(), kz_json:object(), state()) -> state(). handle_execute_complete('undefined', _, State) -> State; handle_execute_complete(<<"noop">>, JObj, #state{msg_id=CurrMsgId}=State) -> NoopId = kz_json:get_value(<<"Application-Response">>, JObj), @@ -602,7 +602,7 @@ handle_execute_complete(AppName, JObj, #state{current_app=CurrApp}=State) -> 'false' -> State end. --spec flush_group_id(queue:queue(), api_binary(), ne_binary()) -> queue:queue(). +-spec flush_group_id(queue:queue(), kz_term:api_binary(), kz_term:ne_binary()) -> queue:queue(). flush_group_id(CmdQ, 'undefined', _) -> CmdQ; flush_group_id(CmdQ, GroupId, AppName) -> Filter = kz_json:from_list([{<<"Application-Name">>, AppName} @@ -651,7 +651,7 @@ forward_queue(#state{call_id = CallId %% %% @end %%-------------------------------------------------------------------- --spec handle_sofia_replaced(ne_binary(), state()) -> state(). +-spec handle_sofia_replaced(kz_term:ne_binary(), state()) -> state(). handle_sofia_replaced(<<_/binary>> = CallId, #state{call_id=CallId}=State) -> lager:debug("call id hasn't changed, no replacement necessary"), State; @@ -685,7 +685,7 @@ handle_sofia_replaced(<<_/binary>> = ReplacedBy, #state{call_id=CallId %% %% @end %%-------------------------------------------------------------------- --spec handle_channel_create(kz_proplist(), state()) -> state(). +-spec handle_channel_create(kz_term:proplist(), state()) -> state(). handle_channel_create(Props, #state{call_id=CallId}=State) -> LegId = props:get_value(<<"Caller-Unique-ID">>, Props), case ecallmgr_fs_channel:get_other_leg(LegId, Props) of @@ -694,7 +694,7 @@ handle_channel_create(Props, #state{call_id=CallId}=State) -> OtherLeg -> maybe_add_cleg(Props, OtherLeg, LegId, State) end. --spec add_leg(kz_proplist(), ne_binary(), state()) -> state(). +-spec add_leg(kz_term:proplist(), kz_term:ne_binary(), state()) -> state(). add_leg(Props, LegId, #state{other_legs=Legs ,call_id=CallId ,node=Node @@ -719,7 +719,7 @@ add_leg(Props, LegId, #state{other_legs=Legs State#state{other_legs=[LegId|Legs]} end. --spec publish_leg_addition(kz_proplist()) -> 'ok'. +-spec publish_leg_addition(kz_term:proplist()) -> 'ok'. publish_leg_addition(Props) -> Event = ecallmgr_call_events:create_event(<<"LEG_CREATED">> ,'undefined' @@ -727,14 +727,14 @@ publish_leg_addition(Props) -> ), ecallmgr_call_events:publish_event(Event). --spec maybe_add_cleg(kz_proplist(), api_binary(), api_binary(), state()) -> state(). +-spec maybe_add_cleg(kz_term:proplist(), kz_term:api_binary(), kz_term:api_binary(), state()) -> state(). maybe_add_cleg(Props, OtherLeg, LegId, #state{other_legs=Legs}=State) -> case lists:member(OtherLeg, Legs) of 'true' -> add_cleg(Props, OtherLeg, LegId, State); 'false' -> State end. --spec add_cleg(kz_proplist(), api_binary(), api_binary(), state()) -> state(). +-spec add_cleg(kz_term:proplist(), kz_term:api_binary(), kz_term:api_binary(), state()) -> state(). add_cleg(_Props, _OtherLeg, 'undefined', State) -> State; add_cleg(Props, OtherLeg, LegId, #state{other_legs=Legs ,call_id=CallId @@ -753,7 +753,7 @@ add_cleg(Props, OtherLeg, LegId, #state{other_legs=Legs State#state{other_legs=[LegId|Legs]} end. --spec publish_cleg_addition(kz_proplist(), api_binary(), ne_binary()) -> 'ok'. +-spec publish_cleg_addition(kz_term:proplist(), kz_term:api_binary(), kz_term:ne_binary()) -> 'ok'. publish_cleg_addition(Props, OtherLeg, CallId) -> Event = ecallmgr_call_events:create_event(<<"LEG_CREATED">> ,'undefined' @@ -762,7 +762,7 @@ publish_cleg_addition(Props, OtherLeg, CallId) -> Event1 = replace_call_id(Event, OtherLeg, CallId, []), ecallmgr_call_events:publish_event(Event1). --spec replace_call_id(kz_proplist(), api_binary(), ne_binary(), kz_proplist()) -> kz_proplist(). +-spec replace_call_id(kz_term:proplist(), kz_term:api_binary(), kz_term:ne_binary(), kz_term:proplist()) -> kz_term:proplist(). replace_call_id([], _Call1, _Call2, Swap) -> Swap; replace_call_id([{Key, Call1}|T], Call1, Call2, Swap) -> replace_call_id(T, Call1, Call2, [{Key, Call2}|Swap]); @@ -775,7 +775,7 @@ replace_call_id([Prop|T], Call1, Call2, Swap) -> %% %% @end %%-------------------------------------------------------------------- --spec handle_channel_destroy(kz_proplist(), state()) -> state(). +-spec handle_channel_destroy(kz_term:proplist(), state()) -> state(). handle_channel_destroy(Props, #state{call_id=CallId}=State) -> LegId = props:get_value(<<"Caller-Unique-ID">>, Props), case ecallmgr_fs_channel:get_other_leg(LegId, Props) =:= CallId of @@ -783,7 +783,7 @@ handle_channel_destroy(Props, #state{call_id=CallId}=State) -> 'false' -> State end. --spec remove_leg(kz_proplist(), state()) -> state(). +-spec remove_leg(kz_term:proplist(), state()) -> state(). remove_leg(Props, #state{other_legs=Legs ,call_id=CallId }=State) -> @@ -804,7 +804,7 @@ remove_leg(Props, #state{other_legs=Legs } end. --spec publish_leg_removal(kz_proplist()) -> 'ok'. +-spec publish_leg_removal(kz_term:proplist()) -> 'ok'. publish_leg_removal(Props) -> Event = ecallmgr_call_events:create_event(<<"LEG_DESTROYED">> ,'undefined' @@ -1017,11 +1017,11 @@ maybe_filter_queue([AppJObj|T]=Apps, CommandQ) -> end end. --spec is_post_hangup_command(ne_binary()) -> boolean(). +-spec is_post_hangup_command(kz_term:ne_binary()) -> boolean(). is_post_hangup_command(AppName) -> lists:member(AppName, ?POST_HANGUP_COMMANDS). --spec get_module(ne_binary(), ne_binary()) -> atom(). +-spec get_module(kz_term:ne_binary(), kz_term:ne_binary()) -> atom(). get_module(Category, Name) -> ModuleName = <<"ecallmgr_", Category/binary, "_", Name/binary>>, try kz_term:to_atom(ModuleName) @@ -1103,7 +1103,7 @@ execute_control_request(Cmd, #state{node=Node 'ok' end. --spec which_call_leg(ne_binary(), ne_binaries(), ne_binary()) -> ne_binary(). +-spec which_call_leg(kz_term:ne_binary(), kz_term:ne_binaries(), kz_term:ne_binary()) -> kz_term:ne_binary(). which_call_leg(CmdLeg, OtherLegs, CallId) -> case lists:member(CmdLeg, OtherLegs) of 'true' -> @@ -1112,8 +1112,8 @@ which_call_leg(CmdLeg, OtherLegs, CallId) -> 'false' -> CallId end. --spec maybe_send_error_resp(ne_binary(), kz_json:object()) -> 'ok'. --spec maybe_send_error_resp(ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec maybe_send_error_resp(kz_term:ne_binary(), kz_json:object()) -> 'ok'. +-spec maybe_send_error_resp(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. maybe_send_error_resp(CallId, Cmd) -> AppName = kz_json:get_value(<<"Application-Name">>, Cmd), maybe_send_error_resp(AppName, CallId, Cmd). @@ -1121,7 +1121,7 @@ maybe_send_error_resp(CallId, Cmd) -> maybe_send_error_resp(<<"hangup">>, _CallId, _Cmd) -> 'ok'; maybe_send_error_resp(_, CallId, Cmd) -> send_error_resp(CallId, Cmd). --spec send_error_resp(ne_binary(), kz_json:object()) -> 'ok'. +-spec send_error_resp(kz_term:ne_binary(), kz_json:object()) -> 'ok'. send_error_resp(CallId, Cmd) -> send_error_resp(CallId ,Cmd @@ -1130,8 +1130,8 @@ send_error_resp(CallId, Cmd) -> >> ). --spec send_error_resp(ne_binary(), kz_json:object(), ne_binary()) -> 'ok'. --spec send_error_resp(ne_binary(), kz_json:object(), ne_binary(), api_object()) -> 'ok'. +-spec send_error_resp(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> 'ok'. +-spec send_error_resp(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary(), kz_term:api_object()) -> 'ok'. send_error_resp(CallId, Cmd, Msg) -> case ecallmgr_fs_channel:fetch(CallId) of {'ok', Channel} -> send_error_resp(CallId, Cmd, Msg, Channel); @@ -1151,7 +1151,7 @@ send_error_resp(CallId, Cmd, Msg, Channel) -> lager:debug("sending execution error: ~p", [Resp]), kapi_dialplan:publish_error(CallId, Resp). --spec error_ccvs(api_object()) -> api_object(). +-spec error_ccvs(kz_term:api_object()) -> kz_term:api_object(). error_ccvs('undefined') -> 'undefined'; error_ccvs(Channel) -> kz_json:from_list(ecallmgr_fs_channel:channel_ccvs(Channel)). @@ -1162,7 +1162,7 @@ error_ccvs(Channel) -> %% %% @end %%-------------------------------------------------------------------- --spec get_keep_alive_ref(state()) -> api_reference(). +-spec get_keep_alive_ref(state()) -> kz_term:api_reference(). get_keep_alive_ref(#state{is_call_up='true'}) -> 'undefined'; get_keep_alive_ref(#state{keep_alive_ref='undefined' ,is_call_up='false' @@ -1187,7 +1187,7 @@ get_keep_alive_ref(#state{keep_alive_ref=TRef %% %% @end %%-------------------------------------------------------------------- --spec bind_to_events(atom(), ne_binary()) -> 'true'. +-spec bind_to_events(atom(), kz_term:ne_binary()) -> 'true'. bind_to_events(Node, CallId) -> lager:debug("binding to call ~s events on node ~s", [CallId, Node]), 'true' = gproc:reg({'p', 'l', ?FS_CALL_EVENT_REG_MSG(Node, CallId)}), @@ -1200,7 +1200,7 @@ bind_to_events(Node, CallId) -> %% %% @end %%-------------------------------------------------------------------- --spec unbind_from_events(atom(), ne_binary()) -> 'true'. +-spec unbind_from_events(atom(), kz_term:ne_binary()) -> 'true'. unbind_from_events(Node, CallId) -> lager:debug("unbinding from call ~s events on node ~s", [CallId, Node]), _ = (catch gproc:unreg({'p', 'l', ?FS_CALL_EVENT_REG_MSG(Node, CallId)})), @@ -1208,18 +1208,18 @@ unbind_from_events(Node, CallId) -> _ = (catch gproc:unreg({'p', 'l', ?FS_EVENT_REG_MSG(Node, <<"CHANNEL_DESTROY">>)})), 'true'. --spec reg_for_call_related_events(ne_binary()) -> 'ok'. +-spec reg_for_call_related_events(kz_term:ne_binary()) -> 'ok'. reg_for_call_related_events(CallId) -> gproc:reg({'p', 'l', {'call_control', CallId}}), gproc:reg({'p', 'l', ?LOOPBACK_BOWOUT_REG(CallId)}). --spec unreg_for_call_related_events(ne_binary()) -> 'ok'. +-spec unreg_for_call_related_events(kz_term:ne_binary()) -> 'ok'. unreg_for_call_related_events(CallId) -> (catch gproc:unreg({'p', 'l', {'call_control', CallId}})), (catch gproc:unreg({'p', 'l', ?LOOPBACK_BOWOUT_REG(CallId)})), 'ok'. --spec handle_replaced(kz_proplist(), state()) -> +-spec handle_replaced(kz_term:proplist(), state()) -> {'noreply', state()}. handle_replaced(Props, #state{fetch_id=FetchId ,node=Node @@ -1246,7 +1246,7 @@ handle_replaced(Props, #state{fetch_id=FetchId {'noreply', State} end. --spec handle_transferee(kz_proplist(), state()) -> +-spec handle_transferee(kz_term:proplist(), state()) -> {'noreply', state()}. handle_transferee(Props, #state{fetch_id=FetchId ,node=_Node @@ -1261,7 +1261,7 @@ handle_transferee(Props, #state{fetch_id=FetchId {'noreply', State} end. --spec handle_transferor(kz_proplist(), state()) -> +-spec handle_transferor(kz_term:proplist(), state()) -> {'noreply', state()}. handle_transferor(_Props, #state{fetch_id=_FetchId ,node=_Node @@ -1269,7 +1269,7 @@ handle_transferor(_Props, #state{fetch_id=_FetchId }=State) -> {'noreply', State}. --spec handle_intercepted(atom(), ne_binary(), kz_proplist()) -> 'ok'. +-spec handle_intercepted(atom(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. handle_intercepted(Node, CallId, Props) -> _ = case {props:get_value(<<"Core-UUID">>, Props) ,props:get_value(?GET_CUSTOM_HEADER(<<"Core-UUID">>), Props) @@ -1292,7 +1292,7 @@ handle_intercepted(Node, CallId, Props) -> end, 'ok'. --spec handle_event_info(ne_binary(), kzd_freeswitch:data(), state()) -> +-spec handle_event_info(kz_term:ne_binary(), kzd_freeswitch:data(), state()) -> {'noreply', state()} | {'stop', any(), state()}. handle_event_info(CallId, Props, #state{call_id=CallId @@ -1335,7 +1335,7 @@ handle_event_info(CallId, Props, #state{call_id=CallId {'noreply', State} end. --spec handle_other_event_info(api_binary(), kzd_freeswitch:data(), state()) -> {'noreply', state()}. +-spec handle_other_event_info(kz_term:api_binary(), kzd_freeswitch:data(), state()) -> {'noreply', state()}. handle_other_event_info(CallId, Props, State) -> case props:get_first_defined([<<"Event-Subclass">> ,<<"Event-Name">> diff --git a/applications/ecallmgr/src/ecallmgr_call_control_sup.erl b/applications/ecallmgr/src/ecallmgr_call_control_sup.erl index 816cc672016..2ff130fffb2 100644 --- a/applications/ecallmgr/src/ecallmgr_call_control_sup.erl +++ b/applications/ecallmgr/src/ecallmgr_call_control_sup.erl @@ -30,12 +30,12 @@ %%-------------------------------------------------------------------- %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --type start_args() :: [atom() | api_ne_binary() | kz_json:object()]. --spec start_proc(start_args()) -> sup_startchild_ret(). +-type start_args() :: [atom() | kz_term:api_ne_binary() | kz_json:object()]. +-spec start_proc(start_args()) -> kz_types:sup_startchild_ret(). start_proc(Args) -> supervisor:start_child(?SERVER, Args). @@ -52,7 +52,7 @@ start_proc(Args) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 5, diff --git a/applications/ecallmgr/src/ecallmgr_call_event_sup.erl b/applications/ecallmgr/src/ecallmgr_call_event_sup.erl index 1c6e3b7228e..612bb24fceb 100644 --- a/applications/ecallmgr/src/ecallmgr_call_event_sup.erl +++ b/applications/ecallmgr/src/ecallmgr_call_event_sup.erl @@ -27,11 +27,11 @@ %%-------------------------------------------------------------------- %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec start_proc(list()) -> sup_startchild_ret(). +-spec start_proc(list()) -> kz_types:sup_startchild_ret(). start_proc([Node, CallId|_]=Args) -> case gproc:lookup_values(?FS_CALL_EVENTS_PROCESS_REG(Node, CallId)) of [] -> @@ -59,7 +59,7 @@ start_proc([Node, CallId|_]=Args) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 5, diff --git a/applications/ecallmgr/src/ecallmgr_call_events.erl b/applications/ecallmgr/src/ecallmgr_call_events.erl index 35a9faacdc2..849e1718f38 100644 --- a/applications/ecallmgr/src/ecallmgr_call_events.erl +++ b/applications/ecallmgr/src/ecallmgr_call_events.erl @@ -61,14 +61,14 @@ -define(CONSUME_OPTIONS, [{'no_local', 'true'}]). -record(state, {node :: atom() - ,call_id :: api_binary() - ,other_leg :: api_binary() - ,other_leg_events = [] :: ne_binaries() + ,call_id :: kz_term:api_binary() + ,other_leg :: kz_term:api_binary() + ,other_leg_events = [] :: kz_term:ne_binaries() ,is_node_up = 'true' :: boolean() ,failed_node_checks = 0 :: non_neg_integer() - ,node_down_tref :: api_reference() - ,sanity_check_tref :: api_reference() - ,ref = kz_binary:rand_hex(12) :: ne_binary() + ,node_down_tref :: kz_term:api_reference() + ,sanity_check_tref :: kz_term:api_reference() + ,ref = kz_binary:rand_hex(12) :: kz_term:ne_binary() ,passive = 'false' :: boolean() }). -type state() :: #state{}. @@ -80,7 +80,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(atom(), ne_binary()) -> startlink_ret(). +-spec start_link(atom(), kz_term:ne_binary()) -> kz_types:startlink_ret(). start_link(Node, CallId) -> Bindings = [{'call', [{'callid', CallId} ,{'restrict_to', ['publisher_usurp']} @@ -93,21 +93,21 @@ start_link(Node, CallId) -> ,{'consume_options', ?CONSUME_OPTIONS} ], [Node, CallId]). --spec graceful_shutdown(atom(), ne_binary()) -> 'ok'. +-spec graceful_shutdown(atom(), kz_term:ne_binary()) -> 'ok'. graceful_shutdown(Node, UUID) -> _ = [gen_listener:cast(Pid, {'graceful_shutdown', UUID}) || Pid <- gproc:lookup_pids({'p', 'l', ?FS_CALL_EVENT_REG_MSG(Node, UUID)}) ], 'ok'. --spec shutdown(atom(), ne_binary()) -> 'ok'. +-spec shutdown(atom(), kz_term:ne_binary()) -> 'ok'. shutdown(Node, UUID) -> _ = [gen_listener:cast(Pid, 'shutdown') || Pid <- gproc:lookup_pids({'p', 'l', ?FS_CALL_EVENT_REG_MSG(Node, UUID)}) ], 'ok'. --spec listen_for_other_leg(atom(), ne_binary(), api_binaries()) -> 'ok'. +-spec listen_for_other_leg(atom(), kz_term:ne_binary(), kz_term:api_binaries()) -> 'ok'. listen_for_other_leg(_Node, _UUID, 'undefined') -> 'ok'; listen_for_other_leg(_Node, _UUID, []) -> 'ok'; listen_for_other_leg(Node, UUID, [_|_] = Events) -> @@ -116,26 +116,26 @@ listen_for_other_leg(Node, UUID, [_|_] = Events) -> ], lager:debug("sent msg to ~s to bind for b leg events ~p", [UUID, Events]). --spec callid(pid()) -> ne_binary(). +-spec callid(pid()) -> kz_term:ne_binary(). callid(Srv) -> gen_listener:call(Srv, 'callid', ?MILLISECONDS_IN_SECOND). --spec node(pid()) -> ne_binary(). +-spec node(pid()) -> kz_term:ne_binary(). node(Srv) -> gen_listener:call(Srv, 'node', ?MILLISECONDS_IN_SECOND). -spec update_node(pid(), atom()) -> 'ok'. update_node(Srv, Node) -> gen_listener:cast(Srv, {'update_node', Node}). --spec transfer(pid(), atom(), kz_proplist()) -> 'ok'. +-spec transfer(pid(), atom(), kz_term:proplist()) -> 'ok'. transfer(Srv, TransferType, Props) -> gen_listener:cast(Srv, {TransferType, Props}). --spec queue_name(pid()) -> ne_binary(). +-spec queue_name(pid()) -> kz_term:ne_binary(). queue_name(Srv) -> gen_listener:queue_name(Srv). --spec to_json(kz_proplist()) -> kz_json:object(). +-spec to_json(kz_term:proplist()) -> kz_json:object(). to_json(Props) -> kz_json:from_list(create_event(Props)). --spec handle_publisher_usurp(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_publisher_usurp(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_publisher_usurp(JObj, Props) -> CallId = props:get_value('call_id', Props), Ref = props:get_value('reference', Props), @@ -173,7 +173,7 @@ handle_publisher_usurp(JObj, Props) -> %% {'stop', Reason} %% @end %%-------------------------------------------------------------------- --spec init([atom() | ne_binary(),...]) -> {'ok', state()}. +-spec init([atom() | kz_term:ne_binary(),...]) -> {'ok', state()}. init([Node, CallId]) when is_atom(Node) andalso is_binary(CallId) -> case register_event_process(Node, CallId) of @@ -193,7 +193,7 @@ init(Node, CallId) -> ,ref=kz_binary:rand_hex(12) }}. --spec register_event_process(atom(), ne_binary()) -> 'ok' | {'error', any()}. +-spec register_event_process(atom(), kz_term:ne_binary()) -> 'ok' | {'error', any()}. register_event_process(Node, CallId) -> try gproc:reg(?FS_CALL_EVENTS_PROCESS_REG(Node, CallId)) of 'true' -> 'ok' @@ -201,7 +201,7 @@ register_event_process(Node, CallId) -> _E:R -> {'error', R} end. --spec unregister_event_process(atom(), ne_binary()) -> 'ok' | {'error', any()}. +-spec unregister_event_process(atom(), kz_term:ne_binary()) -> 'ok' | {'error', any()}. unregister_event_process(Node, CallId) -> try gproc:unreg(?FS_CALL_EVENTS_PROCESS_REG(Node, CallId)) of 'true' -> 'ok' @@ -223,7 +223,7 @@ unregister_event_process(Node, CallId) -> %% {'stop', Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call('node', _From, #state{node=Node}=State) -> {'reply', Node, State}; handle_call('callid', _From, #state{call_id=CallId}=State) -> @@ -241,7 +241,7 @@ handle_call(_Request, _From, State) -> %% {'stop', Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('init', #state{node=Node}=State) -> erlang:monitor_node(Node, 'true'), TRef = erlang:send_after(?SANITY_CHECK_PERIOD, self(), 'sanity_check'), @@ -314,15 +314,15 @@ handle_cast(_Msg, State) -> lager:debug("unhandled cast: ~p", [_Msg]), {'noreply', State}. --spec register_for_events(atom(), ne_binary()) -> 'true'. +-spec register_for_events(atom(), kz_term:ne_binary()) -> 'true'. register_for_events(Node, CallId) -> update_events(Node, CallId, fun gproc:reg/1). --spec unregister_for_events(atom(), ne_binary()) -> 'true'. +-spec unregister_for_events(atom(), kz_term:ne_binary()) -> 'true'. unregister_for_events(Node, CallId) -> update_events(Node, CallId, fun gproc:unreg/1). --spec update_events(atom(), ne_binary(), function()) -> 'true'. +-spec update_events(atom(), kz_term:ne_binary(), function()) -> 'true'. update_events(Node, CallId, Fun) -> Regs = ['call_events_processes' ,?FS_CALL_EVENT_REG_MSG(Node, CallId) @@ -346,7 +346,7 @@ update_event(Fun, Reg) -> %% {'stop', Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'event', [CallId | _]}, #state{call_id=CallId ,passive='true' }=State) -> @@ -487,7 +487,7 @@ handle_info(_Info, State) -> lager:debug("unhandled message: ~p", [_Info]), {'noreply', State}. --spec handle_bowout(atom(), kz_proplist(), ne_binary()) -> ne_binary(). +-spec handle_bowout(atom(), kz_term:proplist(), kz_term:ne_binary()) -> kz_term:ne_binary(). handle_bowout(Node, Props, ResigningUUID) -> case {props:get_value(?RESIGNING_UUID, Props) ,props:get_value(?ACQUIRED_UUID, Props) @@ -562,7 +562,7 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec maybe_process_channel_destroy(atom(), ne_binary(), kz_proplist()) -> 'ok'. +-spec maybe_process_channel_destroy(atom(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. maybe_process_channel_destroy(Node, CallId, Props) -> kz_util:spawn(fun maybe_manual_bowout/2, [Node, Props]), case ecallmgr_fs_channel:node(CallId) of @@ -576,14 +576,14 @@ maybe_process_channel_destroy(Node, CallId, Props) -> publish_event(Event) end. --spec maybe_manual_bowout(atom(), kz_proplist()) -> 'ok'. +-spec maybe_manual_bowout(atom(), kz_term:proplist()) -> 'ok'. maybe_manual_bowout(Node, Props) -> App = props:get_value(<<"variable_last_app">>, Props), Role = props:get_value(<<"variable_last_bridge_role">>, Props), BridgeTo = props:get_value(<<"variable_last_bridge_to">>, Props), maybe_manual_bowout(Node, App, Role, BridgeTo). --spec maybe_manual_bowout(atom(), ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec maybe_manual_bowout(atom(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. maybe_manual_bowout(Node, <<"att_xfer">>, <<"originator">>, UUID) -> case ecallmgr_fs_channel:fetch(UUID, 'record') of {'ok', #channel{loopback_other_leg=OtherLeg, is_loopback='true'}} -> @@ -594,7 +594,7 @@ maybe_manual_bowout(Node, <<"att_xfer">>, <<"originator">>, UUID) -> end; maybe_manual_bowout(_Node, _App, _Role, _UUID) -> 'ok'. --spec process_channel_event(kz_proplist()) -> 'ok'. +-spec process_channel_event(kz_term:proplist()) -> 'ok'. process_channel_event(Props) -> kz_util:put_callid(get_call_id(Props)), EventName = get_event_name(Props), @@ -607,15 +607,15 @@ process_channel_event(Props) -> publish_event(Event) end. --spec create_event(kz_proplist()) -> kz_proplist(). +-spec create_event(kz_term:proplist()) -> kz_term:proplist(). create_event(Props) -> create_event(get_event_name(Props), Props). --spec create_event(ne_binary(), kz_proplist()) -> kz_proplist(). +-spec create_event(kz_term:ne_binary(), kz_term:proplist()) -> kz_term:proplist(). create_event(EventName, Props) -> create_event(EventName, get_application_name(Props), Props). --spec create_event(ne_binary(), api_binary(), kz_proplist()) -> kz_proplist(). +-spec create_event(kz_term:ne_binary(), kz_term:api_binary(), kz_term:proplist()) -> kz_term:proplist(). create_event(EventName, ApplicationName, Props) -> props:filter_undefined( [{<<"Event-Name">>, EventName} @@ -624,8 +624,8 @@ create_event(EventName, ApplicationName, Props) -> ++ specific_call_channel_vars_props(EventName, Props) ]). --spec specific_call_channel_vars_props(ne_binary(), kz_proplist()) -> - kz_proplist(). +-spec specific_call_channel_vars_props(kz_term:ne_binary(), kz_term:proplist()) -> + kz_term:proplist(). specific_call_channel_vars_props(<<"CHANNEL_DESTROY">>, Props) -> UUID = get_call_id(Props), ChanVars = kz_json:from_list(ecallmgr_util:custom_channel_vars(Props)), @@ -655,7 +655,7 @@ specific_call_channel_vars_props(_EventName, Props) -> ,{<<"Custom-Application-Vars">>, kz_json:from_list(ecallmgr_util:custom_application_vars(Props))} ]. --spec generic_call_event_props(kz_proplist()) -> kz_proplist(). +-spec generic_call_event_props(kz_term:proplist()) -> kz_term:proplist(). generic_call_event_props(Props) -> Timestamp = kz_time:now_us(), FSTimestamp = props:get_integer_value(<<"Event-Date-Timestamp">>, Props, Timestamp), @@ -703,7 +703,7 @@ generic_call_event_props(Props) -> ++ kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]. --spec publish_event(kz_proplist()) -> 'ok'. +-spec publish_event(kz_term:proplist()) -> 'ok'. publish_event(Props) -> %% call_control publishes channel create/destroy on the control %% events queue by calling create_event then this directly. @@ -730,7 +730,7 @@ publish_event(Props) -> end, kz_amqp_worker:cast(Props, fun kapi_call:publish_event/1). --spec is_masquerade(kz_proplist()) -> boolean(). +-spec is_masquerade(kz_term:proplist()) -> boolean(). is_masquerade(Props) -> case props:get_value(<<"Event-Subclass">>, Props) of %% If this is a event created by kazoo, then use @@ -741,7 +741,7 @@ is_masquerade(Props) -> end. %% return a proplist of k/v pairs specific to the event --spec specific_call_event_props(binary(), api_binary(), kz_proplist()) -> kz_proplist(). +-spec specific_call_event_props(binary(), kz_term:api_binary(), kz_term:proplist()) -> kz_term:proplist(). specific_call_event_props(<<"CHANNEL_EXECUTE">>, <<"conference">>, Props) -> conference_specific(Props); specific_call_event_props(<<"CHANNEL_EXECUTE_COMPLETE">>, <<"conference">>, Props) -> @@ -856,7 +856,7 @@ specific_call_event_props(_Evt, Application, Props) -> ,{<<"Application-Response">>, props:get_value(<<"Application-Response">>, Props)} ]. --spec transfer_to(kz_proplist() | api_binary()) -> {api_binary(), api_binary()}. +-spec transfer_to(kz_term:proplist() | kz_term:api_binary()) -> {kz_term:api_binary(), kz_term:api_binary()}. transfer_to(Props) when is_list(Props) -> transfer_to(props:get_value(<<"variable_transfer_to">>, Props)); @@ -864,13 +864,13 @@ transfer_to(<<"att:", TransferTo/binary>>) -> {<<"attended">>, TransferTo}; transfer_to(<<"blind:", TransferTo/binary>>) -> {<<"blind">>, TransferTo}; transfer_to(_) -> {'undefined', 'undefined'}. --spec page_specific(kz_proplist()) -> kz_proplist(). +-spec page_specific(kz_term:proplist()) -> kz_term:proplist(). page_specific(Props) -> [{<<"Application-Name">>, <<"page">>} ,{<<"Application-Response">>, props:get_value(<<"Application-Response">>, Props)} ]. --spec conference_specific(kz_proplist()) -> kz_proplist(). +-spec conference_specific(kz_term:proplist()) -> kz_term:proplist(). conference_specific(Props) -> Default = [{<<"Application-Name">>, <<"conference">>} ,{<<"Application-Response">>, props:get_value(<<"Application-Response">>, Props)} @@ -888,14 +888,14 @@ conference_specific(Props) -> end end. --spec maybe_fax_specific(kz_proplist()) -> api_object(). +-spec maybe_fax_specific(kz_term:proplist()) -> kz_term:api_object(). maybe_fax_specific(Props) -> case fax_specific(Props) of [] -> 'undefined'; FaxProps -> kz_json:from_list(FaxProps) end. --spec fax_specific(kz_proplist()) -> kz_proplist(). +-spec fax_specific(kz_term:proplist()) -> kz_term:proplist(). fax_specific(Props) -> props:filter_undefined( [{<<"Fax-Success">>, get_fax_success(Props)} @@ -927,7 +927,7 @@ fax_specific(Props) -> ,{<<"Fax-Doc-DB">>, props:get_value(<<"variable_fax_doc_database">>, Props)} ]). --spec should_publish(ne_binary(), ne_binary(), boolean()) -> boolean(). +-spec should_publish(kz_term:ne_binary(), kz_term:ne_binary(), boolean()) -> boolean(). should_publish(<<"CHANNEL_EXECUTE_COMPLETE">>, <<"bridge">>, 'false') -> lager:debug("suppressing bridge execute complete in favour the kazoo masquerade of this event"), 'false'; @@ -956,7 +956,7 @@ should_publish(<<"DETECTED_TONE">>, _, _) -> should_publish(EventName, _A, _) -> lists:member(EventName, ?CALL_EVENTS). --spec silence_terminated(api_integer() | kz_proplist()) -> api_boolean(). +-spec silence_terminated(kz_term:api_integer() | kz_term:proplist()) -> kz_term:api_boolean(). silence_terminated('undefined') -> 'undefined'; silence_terminated(Hits) when is_integer(Hits) -> Hits =:= 0; silence_terminated(Prop) when is_list(Prop) -> @@ -965,18 +965,18 @@ silence_terminated(Prop) when is_list(Prop) -> Ex -> kz_term:is_true(Ex) end. --spec is_channel_moving(kz_proplist()) -> boolean(). +-spec is_channel_moving(kz_term:proplist()) -> boolean(). is_channel_moving(Props) -> props:get_is_true(<<"variable_channel_is_moving">>, Props, 'false'). --spec get_channel_moving(kz_proplist()) -> api_boolean(). +-spec get_channel_moving(kz_term:proplist()) -> kz_term:api_boolean(). get_channel_moving(Props) -> case is_channel_moving(Props) of 'false' -> 'undefined'; 'true' -> 'true' end. --spec get_channel_state(kz_proplist()) -> api_binary(). +-spec get_channel_state(kz_term:proplist()) -> kz_term:api_binary(). get_channel_state(Props) -> case props:get_value(<<"Channel-State">>, Props) of 'undefined' -> 'undefined'; @@ -984,15 +984,15 @@ get_channel_state(Props) -> Other -> Other end. --spec get_call_id(kz_proplist()) -> api_binary(). +-spec get_call_id(kz_term:proplist()) -> kz_term:api_binary(). get_call_id(Props) -> kzd_freeswitch:call_id(Props). --spec get_other_leg(kz_proplist()) -> api_binary(). +-spec get_other_leg(kz_term:proplist()) -> kz_term:api_binary(). get_other_leg(Props) -> ecallmgr_fs_channel:get_other_leg(get_call_id(Props), Props). --spec get_event_name(kz_proplist()) -> api_binary(). +-spec get_event_name(kz_term:proplist()) -> kz_term:api_binary(). get_event_name(Props) -> case kzd_freeswitch:application_name(Props) of <<"sofia::transferee">> -> <<"CHANNEL_TRANSFEREE">>; @@ -1005,7 +1005,7 @@ get_event_name(Props) -> _AppName -> get_fs_event_name(Props) end. --spec get_fs_event_name(kz_proplist()) -> api_binary(). +-spec get_fs_event_name(kz_term:proplist()) -> kz_term:api_binary(). get_fs_event_name(Props) -> case kzd_freeswitch:event_name(Props) of <<"DETECTED_TONE">> -> @@ -1016,7 +1016,7 @@ get_fs_event_name(Props) -> Event -> Event end. --spec get_application_name(kz_proplist()) -> api_binary(). +-spec get_application_name(kz_term:proplist()) -> kz_term:api_binary(). get_application_name(Props) -> case kzd_freeswitch:application_name(Props) of <<"sofia::transferee">> -> <<"transfer">>; @@ -1027,32 +1027,32 @@ get_application_name(Props) -> AppName -> AppName end. --spec get_raw_application_name(kz_proplist()) -> api_binary(). +-spec get_raw_application_name(kz_term:proplist()) -> kz_term:api_binary(). get_raw_application_name(Props) -> kzd_freeswitch:raw_application_name(Props). --spec get_fax_success(kz_proplist()) -> api_boolean(). +-spec get_fax_success(kz_term:proplist()) -> kz_term:api_boolean(). get_fax_success(Props) -> case props:get_value(<<"variable_fax_success">>, Props) of 'undefined' -> 'undefined'; Else -> Else =/= <<"0">> end. --spec get_fax_t38_used(kz_proplist()) -> api_boolean(). +-spec get_fax_t38_used(kz_term:proplist()) -> kz_term:api_boolean(). get_fax_t38_used(Props) -> case props:get_value(<<"variable_has_t38">>, Props) of 'undefined' -> 'undefined'; Else -> kz_term:is_true(Else) end. --spec get_fax_ecm_used(kz_proplist()) -> api_boolean(). +-spec get_fax_ecm_used(kz_term:proplist()) -> kz_term:api_boolean(). get_fax_ecm_used(Props) -> case props:get_value(<<"variable_fax_ecm_used">>, Props) of 'undefined' -> 'undefined'; Else -> Else =/= <<"off">> end. --spec get_serialized_history(kz_proplist()) -> binaries(). +-spec get_serialized_history(kz_term:proplist()) -> kz_term:binaries(). get_serialized_history(Props) -> case kzd_freeswitch:transfer_history(Props) of 'undefined' -> []; @@ -1062,7 +1062,7 @@ get_serialized_history(Props) -> History end. --spec get_transfer_history(kz_proplist()) -> api_object(). +-spec get_transfer_history(kz_term:proplist()) -> kz_term:api_object(). get_transfer_history(Props) -> SerializedHistory = get_serialized_history(Props), case [HistJObj @@ -1074,7 +1074,7 @@ get_transfer_history(Props) -> History -> kz_json:from_list(History) end. --spec create_trnsf_history_object(list()) -> {ne_binary(), kz_json:object()} | 'undefined'. +-spec create_trnsf_history_object(list()) -> {kz_term:ne_binary(), kz_json:object()} | 'undefined'. create_trnsf_history_object([Epoch, CallId, <<"att_xfer">>, Props]) -> [Transferee, Transferer] = binary:split(Props, <<"/">>), Trans = [{<<"Call-ID">>, CallId} @@ -1104,27 +1104,27 @@ create_trnsf_history_object(_Params) -> lager:debug("unhandled transfer type : ~p", [_Params]), 'undefined'. --spec get_hangup_cause(kz_proplist()) -> api_binary(). +-spec get_hangup_cause(kz_term:proplist()) -> kz_term:api_binary(). get_hangup_cause(Props) -> kzd_freeswitch:hangup_cause(Props). --spec get_disposition(kz_proplist()) -> api_binary(). +-spec get_disposition(kz_term:proplist()) -> kz_term:api_binary(). get_disposition(Props) -> kzd_freeswitch:disposition(Props). --spec get_hangup_code(kz_proplist()) -> api_binary(). +-spec get_hangup_code(kz_term:proplist()) -> kz_term:api_binary(). get_hangup_code(Props) -> kzd_freeswitch:hangup_code(Props). --spec get_billing_seconds(kz_proplist()) -> api_binary(). +-spec get_billing_seconds(kz_term:proplist()) -> kz_term:api_binary(). get_billing_seconds(Props) -> case props:get_integer_value(<<"variable_billmsec">>, Props) of 'undefined' -> props:get_value(<<"variable_billsec">>, Props); Billmsec -> kz_term:to_binary(kz_term:ceiling(Billmsec / 1000)) end. --spec swap_call_legs(kz_proplist() | kz_json:object()) -> kz_proplist(). --spec swap_call_legs(kz_proplist(), kz_proplist()) -> kz_proplist(). +-spec swap_call_legs(kz_term:proplist() | kz_json:object()) -> kz_term:proplist(). +-spec swap_call_legs(kz_term:proplist(), kz_term:proplist()) -> kz_term:proplist(). swap_call_legs(Props) when is_list(Props) -> swap_call_legs(Props, []); swap_call_legs(JObj) -> swap_call_legs(kz_json:to_proplist(JObj)). @@ -1152,11 +1152,11 @@ usurp_other_publishers(#state{node=Node ], kapi_call:publish_usurp_publisher(CallId, Usurp). --spec get_is_loopback(api_binary()) -> atom(). +-spec get_is_loopback(kz_term:api_binary()) -> atom(). get_is_loopback('undefined') -> 'undefined'; get_is_loopback(_) -> 'true'. --spec callee_call_event_props(kz_proplist()) -> kz_proplist(). +-spec callee_call_event_props(kz_term:proplist()) -> kz_term:proplist(). callee_call_event_props(Props) -> UUID = get_call_id(Props), case kz_cache:peek_local(?ECALLMGR_INTERACTION_CACHE, {'channel', UUID}) of @@ -1171,8 +1171,8 @@ callee_call_event_props(Props) -> ] end. --spec debug_channel_props(kz_proplist()) -> kz_proplist(). --spec debug_channel_props(kz_proplist(), boolean()) -> kz_proplist(). +-spec debug_channel_props(kz_term:proplist()) -> kz_term:proplist(). +-spec debug_channel_props(kz_term:proplist(), boolean()) -> kz_term:proplist(). debug_channel_props(Props) -> debug_channel_props(Props, ?DEBUG_CHANNEL). diff --git a/applications/ecallmgr/src/ecallmgr_call_sup.erl b/applications/ecallmgr/src/ecallmgr_call_sup.erl index f854939a18c..0231095ab8d 100644 --- a/applications/ecallmgr/src/ecallmgr_call_sup.erl +++ b/applications/ecallmgr/src/ecallmgr_call_sup.erl @@ -32,20 +32,20 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec start_event_process(atom(), ne_binary()) -> sup_startchild_ret(). +-spec start_event_process(atom(), kz_term:ne_binary()) -> kz_types:sup_startchild_ret(). start_event_process(Node, UUID) -> ecallmgr_call_event_sup:start_proc([Node, UUID]). --spec start_control_process(atom(), ne_binary(), ne_binary()) -> sup_startchild_ret(). +-spec start_control_process(atom(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_types:sup_startchild_ret(). start_control_process(Node, CallId, FetchId) -> start_control_process(Node, CallId, FetchId, 'undefined', kz_json:new()). --spec start_control_process(atom(), ne_binary(), ne_binary(), api_ne_binary(), kz_json:object()) -> - sup_startchild_ret(). +-spec start_control_process(atom(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_ne_binary(), kz_json:object()) -> + kz_types:sup_startchild_ret(). start_control_process(Node, CallId, FetchId, ControllerQ, CCVs) -> ecallmgr_call_control_sup:start_proc([Node ,CallId @@ -67,7 +67,7 @@ start_control_process(Node, CallId, FetchId, ControllerQ, CCVs) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, diff --git a/applications/ecallmgr/src/ecallmgr_channel_move.erl b/applications/ecallmgr/src/ecallmgr_channel_move.erl index 580d406eac7..9ab22ffa261 100644 --- a/applications/ecallmgr/src/ecallmgr_channel_move.erl +++ b/applications/ecallmgr/src/ecallmgr_channel_move.erl @@ -13,7 +13,7 @@ -include("ecallmgr.hrl"). --spec move(ne_binary(), atom(), atom()) -> boolean(). +-spec move(kz_term:ne_binary(), atom(), atom()) -> boolean(). move(UUID, ONode, NNode) -> OriginalNode = kz_term:to_atom(ONode), NewNode = kz_term:to_atom(NNode), @@ -35,7 +35,7 @@ move(UUID, ONode, NNode) -> end. %% listens for the event from FS with the XML --spec wait_for_teardown(ne_binary(), atom()) -> +-spec wait_for_teardown(kz_term:ne_binary(), atom()) -> {'ok', kzd_freeswitch:data()} | {'error', 'timeout'}. wait_for_teardown(UUID, OriginalNode) -> @@ -50,14 +50,14 @@ wait_for_teardown(UUID, OriginalNode) -> {'error', 'timeout'} end. --spec rebuild_channel(ne_binary(), atom(), kz_proplist()) -> boolean(). +-spec rebuild_channel(kz_term:ne_binary(), atom(), kz_term:proplist()) -> boolean(). rebuild_channel(UUID, NewNode, Evt) -> catch gproc:reg({'p', 'l', ?CHANNEL_MOVE_REG(NewNode, UUID)}), lager:debug("waiting for message with metadata for channel ~s so we can move it to ~s", [UUID, NewNode]), resume(UUID, NewNode, Evt), wait_for_completion(UUID, NewNode). --spec resume(ne_binary(), atom(), kz_proplist()) -> 'ok'. +-spec resume(kz_term:ne_binary(), atom(), kz_term:proplist()) -> 'ok'. resume(UUID, NewNode, Evt) -> Meta = fix_metadata(props:get_value(<<"metadata">>, Evt)), @@ -75,7 +75,7 @@ resume(UUID, NewNode, Evt) -> %% ;tag=abc %% So this is an awesome search/replace list to convert the '' to %3C and %3E as they should be --spec fix_metadata(ne_binary()) -> ne_binary(). +-spec fix_metadata(kz_term:ne_binary()) -> kz_term:ne_binary(). fix_metadata(Meta) -> Replacements = [{<<">, <<"%3Csip:">>} ,{<<">>, <<"%3E>} @@ -88,7 +88,7 @@ fix_metadata(Meta) -> iolist_to_binary(re:replace(MetaAcc, S, R, ['global'])) end, Meta, Replacements). --spec wait_for_completion(ne_binary(), atom()) -> boolean(). +-spec wait_for_completion(kz_term:ne_binary(), atom()) -> boolean(). wait_for_completion(UUID, NewNode) -> lager:debug("waiting for confirmation from ~s of move", [NewNode]), receive @@ -104,7 +104,7 @@ wait_for_completion(UUID, NewNode) -> 'false' end. --spec teardown_sbd(ne_binary(), atom()) -> 'ok'. +-spec teardown_sbd(kz_term:ne_binary(), atom()) -> 'ok'. teardown_sbd(UUID, OriginalNode) -> catch gproc:reg({'p', 'l', ?CHANNEL_MOVE_REG(OriginalNode, UUID)}), diff --git a/applications/ecallmgr/src/ecallmgr_channel_redirect.erl b/applications/ecallmgr/src/ecallmgr_channel_redirect.erl index b7c071fc9f0..f915bb2f506 100644 --- a/applications/ecallmgr/src/ecallmgr_channel_redirect.erl +++ b/applications/ecallmgr/src/ecallmgr_channel_redirect.erl @@ -14,7 +14,7 @@ -include("ecallmgr.hrl"). --spec redirect(ne_binary(), atom() | ne_binary()) -> ecallmgr_util:send_cmd_ret(). +-spec redirect(kz_term:ne_binary(), atom() | kz_term:ne_binary()) -> ecallmgr_util:send_cmd_ret(). redirect(UUID, DestinationNode) -> URL = ecallmgr_fs_node:sip_url(DestinationNode), case ecallmgr_config:get_boolean(<<"redirect_via_proxy">>, 'true') of @@ -22,7 +22,7 @@ redirect(UUID, DestinationNode) -> 'false' -> redirect_via_endpoint(URL, UUID) end. --spec redirect_remote(ne_binary(), kz_json:object()) -> ecallmgr_util:send_cmd_ret(). +-spec redirect_remote(kz_term:ne_binary(), kz_json:object()) -> ecallmgr_util:send_cmd_ret(). redirect_remote(UUID, ChannelStatusJObj) -> URL = kz_json:get_value(<<"Switch-URL">>, ChannelStatusJObj), @@ -31,7 +31,7 @@ redirect_remote(UUID, ChannelStatusJObj) -> 'false' -> redirect_via_endpoint(URL, UUID) end. --spec redirect_via_proxy(ne_binary(), ne_binary()) -> ecallmgr_util:send_cmd_ret(). +-spec redirect_via_proxy(kz_term:ne_binary(), kz_term:ne_binary()) -> ecallmgr_util:send_cmd_ret(). redirect_via_proxy(DestNodeURL, UUID) -> {'ok', #channel{destination=ToUser ,realm=Realm @@ -42,13 +42,13 @@ redirect_via_proxy(DestNodeURL, UUID) -> RedirectURL = binary:replace(DestNodeURL, <<"mod_sofia@">>, <<>>), send_redirect(RedirectURL, Contact, Channel). --spec redirect_via_endpoint(ne_binary(), ne_binary()) -> ecallmgr_util:send_cmd_ret(). +-spec redirect_via_endpoint(kz_term:ne_binary(), kz_term:ne_binary()) -> ecallmgr_util:send_cmd_ret(). redirect_via_endpoint(DestNodeURL, UUID) -> {'ok', #channel{destination=ToUser}=Channel} = ecallmgr_fs_channel:fetch(UUID, 'record'), Contact = binary:replace(DestNodeURL, <<"mod_sofia">>, ToUser), send_redirect('undefined', Contact, Channel). --spec send_redirect(api_binary(), ne_binary(), channel()) -> +-spec send_redirect(kz_term:api_binary(), kz_term:ne_binary(), channel()) -> ecallmgr_util:send_cmd_ret(). send_redirect('undefined', Contact, #channel{node=Node ,uuid=UUID @@ -62,6 +62,6 @@ send_redirect(RedirectUrl, Contact, #channel{node=Node _ = ecallmgr_fs_command:set(Node, UUID, [{<<"sip_rh_X-Redirect-Server">>, RedirectUrl}]), ecallmgr_util:send_cmd(Node, UUID, redirect_app(IsAnswered), Contact). --spec redirect_app(boolean()) -> ne_binary(). +-spec redirect_app(boolean()) -> kz_term:ne_binary(). redirect_app('true') -> <<"deflect">>; redirect_app('false') -> <<"redirect">>. diff --git a/applications/ecallmgr/src/ecallmgr_conference_command.erl b/applications/ecallmgr/src/ecallmgr_conference_command.erl index 32e298a8d6d..1b64b9be3f5 100644 --- a/applications/ecallmgr/src/ecallmgr_conference_command.erl +++ b/applications/ecallmgr/src/ecallmgr_conference_command.erl @@ -18,8 +18,8 @@ ecallmgr_util:send_cmd_ret() | [ecallmgr_util:send_cmd_ret(),...]. --spec exec_cmd(atom(), ne_binary(), kz_json:object()) -> api_response(). --spec exec_cmd(atom(), ne_binary(), kz_json:object(), ne_binary()) -> api_response(). +-spec exec_cmd(atom(), kz_term:ne_binary(), kz_json:object()) -> api_response(). +-spec exec_cmd(atom(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> api_response(). exec_cmd(Node, ConferenceId, JObj) -> exec_cmd(Node, ConferenceId, JObj, kz_json:get_value(<<"Conference-ID">>, JObj)). @@ -36,16 +36,16 @@ exec_cmd(_Node, _ConferenceId, JObj, _DestId) -> ,_DestId ]). --spec api(atom(), ne_binary(), {ne_binary(), iodata()}) -> api_response(). +-spec api(atom(), kz_term:ne_binary(), {kz_term:ne_binary(), iodata()}) -> api_response(). api(Node, ConferenceId, {AppName, AppData}) -> Command = kz_term:to_list(list_to_binary([ConferenceId, " ", AppName, " ", AppData])), lager:debug("api: ~s", [Command]), freeswitch:api(Node, 'conference', Command). --spec get_conf_command(ne_binary(), atom(), ne_binary(), kz_json:object()) -> +-spec get_conf_command(kz_term:ne_binary(), atom(), kz_term:ne_binary(), kz_json:object()) -> fs_app() | fs_apps() | - {'return', 'error' | ne_binary()} | - {'error', ne_binary()}. + {'return', 'error' | kz_term:ne_binary()} | + {'error', kz_term:ne_binary()}. %% The following conference commands can operate on the entire conference @@ -257,7 +257,7 @@ get_conf_command(Cmd, _Focus, _ConferenceId, _JObj) -> lager:debug("unknown conference command ~s", [Cmd]), {'error', list_to_binary([<<"unknown conference command: ">>, Cmd])}. --spec dial(atom(), ne_binary(), kz_json:object(), kz_json:object() | kz_json:objects()) -> +-spec dial(atom(), kz_term:ne_binary(), kz_json:object(), kz_json:object() | kz_json:objects()) -> api_response(). dial(Node, ConferenceId, JObj, [_|_]=Endpoints) -> DialCmd = list_to_binary([ecallmgr_fs_xml:get_channel_vars(JObj) @@ -270,12 +270,12 @@ dial(Node, ConferenceId, JObj, [_|_]=Endpoints) -> dial(Node, ConferenceId, JObj, Endpoint) -> dial(Node, ConferenceId, JObj, [Endpoint]). --spec relationship(ne_binary()) -> ne_binary(). +-spec relationship(kz_term:ne_binary()) -> kz_term:ne_binary(). relationship(<<"mute">>) -> <<"nospeak">>; relationship(<<"deaf">>) -> <<"nohear">>; relationship(_) -> <<"clear">>. --spec caller_id(api_ne_binary(), api_ne_binary()) -> iodata(). +-spec caller_id(kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> iodata(). caller_id('undefined', 'undefined') -> ""; caller_id('undefined', Name) -> [" ", $",$", " ", Name]; caller_id(Number, 'undefined') -> [" ", Number]; diff --git a/applications/ecallmgr/src/ecallmgr_conference_control.erl b/applications/ecallmgr/src/ecallmgr_conference_control.erl index cad9d7f9724..2afa6993adf 100644 --- a/applications/ecallmgr/src/ecallmgr_conference_control.erl +++ b/applications/ecallmgr/src/ecallmgr_conference_control.erl @@ -43,8 +43,8 @@ -define(CONSUME_OPTIONS, [{'exclusive', 'false'}]). -record(state, {node :: atom() - ,conference_id :: ne_binary() - ,instance_id :: ne_binary() + ,conference_id :: kz_term:ne_binary() + ,instance_id :: kz_term:ne_binary() }). -type state() :: #state{}. @@ -55,7 +55,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(atom(), ne_binary(), ne_binary()) -> startlink_ret(). +-spec start_link(atom(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_types:startlink_ret(). start_link(Node, ConferenceId, InstanceId) -> lager:debug("starting conference ~s control instance ~s for node ~s in ~s" ,[ConferenceId, InstanceId, Node, node()] @@ -70,7 +70,7 @@ start_link(Node, ConferenceId, InstanceId) -> ,[Node, ConferenceId, InstanceId] ). --spec handle_conference_command(kz_json:object(), kz_proplist()) -> any(). +-spec handle_conference_command(kz_json:object(), kz_term:proplist()) -> any(). handle_conference_command(JObj, Props) -> Node = props:get_value('node', Props), ConferenceId = props:get_value('conference_id', Props), @@ -86,7 +86,7 @@ handle_conference_command(JObj, Props) -> %% Initializes the server %% @end %%-------------------------------------------------------------------- --spec init([atom() | ne_binary()]) -> {'ok', state()}. +-spec init([atom() | kz_term:ne_binary()]) -> {'ok', state()}. init([Node, ConferenceId, InstanceId]) -> kz_util:put_callid(ConferenceId), lager:info("starting new conference control for ~s", [ConferenceId]), @@ -110,7 +110,7 @@ init([Node, ConferenceId, InstanceId]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {reply, ok, State}. @@ -124,7 +124,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener',{'created_queue',_QueueName}}, State) -> {'noreply', State}; handle_cast({'gen_listener',{'is_consuming',_IsConsuming}}, State) -> @@ -142,7 +142,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'stop', {Node, ConferenceId, InstanceId}}, #state{node=Node ,conference_id=ConferenceId ,instance_id=InstanceId diff --git a/applications/ecallmgr/src/ecallmgr_conference_sup.erl b/applications/ecallmgr/src/ecallmgr_conference_sup.erl index 0ae8452b354..d921802b3ea 100644 --- a/applications/ecallmgr/src/ecallmgr_conference_sup.erl +++ b/applications/ecallmgr/src/ecallmgr_conference_sup.erl @@ -29,15 +29,15 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec start_conference_control(node(), ne_binary(), ne_binary()) -> sup_startchild_ret(). +-spec start_conference_control(node(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_types:sup_startchild_ret(). start_conference_control(Node, ConferenceId, InstanceId) -> supervisor:start_child(?SERVER, [Node, ConferenceId, InstanceId]). --spec stop_conference_control(node(), ne_binary(), ne_binary()) -> any(). +-spec stop_conference_control(node(), kz_term:ne_binary(), kz_term:ne_binary()) -> any(). stop_conference_control(Node, ConferenceId, InstanceId) -> [Pid ! {'stop', {Node, ConferenceId, InstanceId}} || {_, Pid, _, _} @@ -57,7 +57,7 @@ stop_conference_control(Node, ConferenceId, InstanceId) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 5, diff --git a/applications/ecallmgr/src/ecallmgr_config.erl b/applications/ecallmgr/src/ecallmgr_config.erl index c6a989e9902..2a6707df765 100644 --- a/applications/ecallmgr/src/ecallmgr_config.erl +++ b/applications/ecallmgr/src/ecallmgr_config.erl @@ -33,7 +33,7 @@ -include("ecallmgr.hrl"). -include_lib("kazoo_stdlib/include/kz_databases.hrl"). --type node_specific() :: node() | ne_binary(). +-type node_specific() :: node() | kz_term:ne_binary(). -type api_node_specific() :: 'undefined' | node_specific(). -spec flush() -> 'ok'. @@ -46,7 +46,7 @@ flush() -> flush(Key) -> flush(Key, 'undefined'). --spec flush(api_binary(), api_node_specific()) -> 'ok'. +-spec flush(kz_term:api_binary(), api_node_specific()) -> 'ok'. flush(Key, 'undefined') -> flush(Key, <<"undefined">>); flush(Key, Node) when not is_binary(Key), @@ -69,7 +69,7 @@ flush(Key, Node) -> ). -spec flush_default() -> 'ok'. --spec flush_default(api_binary()) -> 'ok'. +-spec flush_default(kz_term:api_binary()) -> 'ok'. flush_default() -> flush('undefined', <<"default">>). flush_default(Key) -> @@ -114,7 +114,7 @@ get_default(Key) -> get_default(Key, Default) -> get(Key, Default, <<"default">>). --spec get_json(kz_json:path()) -> api_object(). +-spec get_json(kz_json:path()) -> kz_term:api_object(). -spec get_json(kz_json:path(), Default) -> kz_json:object() | Default. -spec get_json(kz_json:path(), Default, api_node_specific()) -> kz_json:object() | Default. get_json(Key) -> @@ -124,7 +124,7 @@ get_json(Key, Default) -> get_json(Key, Default, Node) -> as_json_value(get(Key, Default, Node), Default). --spec as_json_value(any(), api_object()) -> api_object(). +-spec as_json_value(any(), kz_term:api_object()) -> kz_term:api_object(). as_json_value('undefined', Default) -> Default; as_json_value(V, Default) -> case kz_json:is_json_object(V) of @@ -142,7 +142,7 @@ get_jsons(Key, Default) -> get_jsons(Key, Default, Node) -> as_jsons_value(get(Key, Default, Node), Default). --spec as_jsons_value(any(), api_objects()) -> api_objects(). +-spec as_jsons_value(any(), kz_term:api_objects()) -> kz_term:api_objects(). as_jsons_value(V, Default) when is_list(V) -> case lists:all(fun kz_json:is_json_object/1, V) of 'false' -> Default; @@ -150,7 +150,7 @@ as_jsons_value(V, Default) when is_list(V) -> end; as_jsons_value(_, Default) -> Default. --spec get_integer(kz_json:path()) -> api_integer(). +-spec get_integer(kz_json:path()) -> kz_term:api_integer(). -spec get_integer(kz_json:path(), Default) -> integer() | Default. -spec get_integer(kz_json:path(), Default, api_node_specific()) -> integer() | Default. get_integer(Key) -> @@ -168,7 +168,7 @@ get_integer(Key, Default, Node) -> N -> kz_term:to_integer(N) end. --spec get_boolean(kz_json:path()) -> api_boolean(). +-spec get_boolean(kz_json:path()) -> kz_term:api_boolean(). -spec get_boolean(kz_json:path(), Default) -> boolean() | Default. -spec get_boolean(kz_json:path(), Default, api_node_specific()) -> boolean() | Default. get_boolean(Key) -> @@ -204,9 +204,9 @@ is_true(Key, Default, Node) -> N -> kz_term:is_true(N) end. --spec get_ne_binary(kz_json:path()) -> api_ne_binary(). --spec get_ne_binary(kz_json:path(), Default) -> ne_binary() | Default. --spec get_ne_binary(kz_json:path(), Default, api_node_specific()) -> ne_binary() | Default. +-spec get_ne_binary(kz_json:path()) -> kz_term:api_ne_binary(). +-spec get_ne_binary(kz_json:path(), Default) -> kz_term:ne_binary() | Default. +-spec get_ne_binary(kz_json:path(), Default, api_node_specific()) -> kz_term:ne_binary() | Default. get_ne_binary(Key) -> get_ne_binary(Key, 'undefined'). @@ -222,9 +222,9 @@ get_ne_binary(Key, Default, Node) -> _ -> Default end. --spec get_ne_binaries(kz_json:path()) -> ne_binaries(). --spec get_ne_binaries(kz_json:path(), Default) -> ne_binaries() | Default. --spec get_ne_binaries(kz_json:path(), Default, api_node_specific()) -> ne_binaries() | Default. +-spec get_ne_binaries(kz_json:path()) -> kz_term:ne_binaries(). +-spec get_ne_binaries(kz_json:path(), Default) -> kz_term:ne_binaries() | Default. +-spec get_ne_binaries(kz_json:path(), Default, api_node_specific()) -> kz_term:ne_binaries() | Default. get_ne_binaries(Key) -> get_ne_binaries(Key, []). @@ -297,7 +297,7 @@ fetch(Key, Default, Node, RequestTimeout) -> Value end. --spec maybe_cache_resp(ne_binary(), ne_binary(), any()) -> 'ok'. +-spec maybe_cache_resp(kz_term:ne_binary(), kz_term:ne_binary(), any()) -> 'ok'. maybe_cache_resp(_, _ , 'null') -> 'ok'; maybe_cache_resp(_, _ , <<"null">>) -> 'ok'; maybe_cache_resp(Key, Node, Value) -> @@ -326,7 +326,7 @@ set_node(Key, Value, Node) when is_atom(Node) -> set_node(Key, Value, Node) -> set(Key, Value, Node, [{'node_specific', 'true'}]). --spec set(kz_json:path(), kz_json:json_term(), node_specific(), kz_proplist()) -> 'ok'. +-spec set(kz_json:path(), kz_json:json_term(), node_specific(), kz_term:proplist()) -> 'ok'. set(Key, Value, Node, Opt) when not is_binary(Key) -> set(kz_term:to_binary(Key), Value, Node, Opt); set(Key, Value, Node, Opt) -> diff --git a/applications/ecallmgr/src/ecallmgr_events.erl b/applications/ecallmgr/src/ecallmgr_events.erl index 6fe73d03ebe..cfceb708fee 100644 --- a/applications/ecallmgr/src/ecallmgr_events.erl +++ b/applications/ecallmgr/src/ecallmgr_events.erl @@ -11,7 +11,7 @@ -include("ecallmgr.hrl"). --spec event(ne_binary(), api_binary(), kzd_freeswitch:data(), atom()) -> any(). +-spec event(kz_term:ne_binary(), kz_term:api_binary(), kzd_freeswitch:data(), atom()) -> any(). event(<<"CHANNEL_CREATE">> = EventName, UUID, EventProps, Node) -> Props = ecallmgr_fs_loopback:filter(Node, UUID, EventProps, 'true'), process_event(EventName, UUID, Props, Node), @@ -63,7 +63,7 @@ event(EventName, UUID, EventProps, Node) -> maybe_send_event(EventName, UUID, EventProps, Node), process_event(EventName, UUID, EventProps, Node). --spec process_event(ne_binary(), api_binary(), kzd_freeswitch:data(), atom()) -> any(). +-spec process_event(kz_term:ne_binary(), kz_term:api_binary(), kzd_freeswitch:data(), atom()) -> any(). process_event(<<"CHANNEL_CREATE">>, UUID, Props, Node) -> _ = ecallmgr_fs_channel:new(Props, Node), lager:debug("channel added to cache"), @@ -90,7 +90,7 @@ process_event(<<"loopback::bowout">>, _UUID, Props, Node) -> gproc:send({'p', 'l', ?LOOPBACK_BOWOUT_REG(ResigningUUID)}, ?LOOPBACK_BOWOUT_MSG(Node, Props)); process_event(_, _, _, _) -> 'ok'. --spec maybe_send_event(ne_binary(), api_binary(), kzd_freeswitch:data(), atom()) -> any(). +-spec maybe_send_event(kz_term:ne_binary(), kz_term:api_binary(), kzd_freeswitch:data(), atom()) -> any(). maybe_send_event(<<"HEARTBEAT">>, _UUID, _Props, _Node) -> 'ok'; maybe_send_event(<<"CHANNEL_BRIDGE">>=EventName, UUID, Props, Node) -> BridgeID = props:get_value(<<"variable_bridge_uuid">>, Props), @@ -144,13 +144,13 @@ send_event(EventName, UUID, Props, Node) -> gproc:send({'p', 'l', ?FS_EVENT_REG_MSG(Node, EventName)}, {'event', [UUID | Props]}), maybe_send_call_event(UUID, EventName, Props, Node). --spec maybe_send_call_event(api_binary(), ne_binary(), kz_proplist(), atom()) -> any(). +-spec maybe_send_call_event(kz_term:api_binary(), kz_term:ne_binary(), kz_term:proplist(), atom()) -> any(). maybe_send_call_event('undefined', _, _, _) -> 'ok'; maybe_send_call_event(CallId, EventName, Props, Node) -> gproc:send({'p', 'l', ?FS_CALL_EVENT_MSG(Node, EventName, CallId)}, {'event', EventName, [CallId | Props]}), gproc:send({'p', 'l', ?FS_CALL_EVENT_REG_MSG(Node, CallId)}, {'event', [CallId | Props]}). --spec maybe_start_event_listener(atom(), ne_binary()) -> 'ok' | sup_startchild_ret(). +-spec maybe_start_event_listener(atom(), kz_term:ne_binary()) -> 'ok' | kz_types:sup_startchild_ret(). maybe_start_event_listener(Node, UUID) -> case kz_cache:fetch_local(?ECALLMGR_UTIL_CACHE, {UUID, 'start_listener'}) of {'ok', 'true'} -> ecallmgr_call_sup:start_event_process(Node, UUID); diff --git a/applications/ecallmgr/src/ecallmgr_fs_authn.erl b/applications/ecallmgr/src/ecallmgr_fs_authn.erl index 23c09587545..48cebdef616 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_authn.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_authn.erl @@ -29,7 +29,7 @@ -include("ecallmgr.hrl"). -record(state, {node :: atom() - ,options = [] :: kz_proplist() + ,options = [] :: kz_term:proplist() }). -type state() :: #state{}. @@ -40,8 +40,8 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(atom()) -> startlink_ret(). --spec start_link(atom(), kz_proplist()) -> startlink_ret(). +-spec start_link(atom()) -> kz_types:startlink_ret(). +-spec start_link(atom(), kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Node) -> start_link(Node, []). start_link(Node, Options) -> gen_server:start_link(?SERVER, [Node, Options], []). @@ -61,7 +61,7 @@ start_link(Node, Options) -> %% {stop, Reason} %% @end %%-------------------------------------------------------------------- --spec init([atom() | kz_proplist()]) -> {'ok', state()}. +-spec init([atom() | kz_term:proplist()]) -> {'ok', state()}. init([Node, Options]) -> process_flag('trap_exit', 'true'), kz_util:put_callid(Node), @@ -85,7 +85,7 @@ init([Node, Options]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -99,7 +99,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('bind_to_directory', #state{node=Node}=State) -> case freeswitch:bind(Node, 'directory') of 'ok' -> {'noreply', State}; @@ -121,7 +121,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'fetch', 'directory', <<"domain">>, <<"name">>, _Value, Id, ['undefined' | Props]} ,#state{node=Node}=State) -> _ = kz_util:spawn(fun handle_directory_lookup/3, [Id, Props, Node]), @@ -174,7 +174,7 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec handle_directory_lookup(ne_binary(), kz_proplist(), atom()) -> fs_handlecall_ret(). +-spec handle_directory_lookup(kz_term:ne_binary(), kz_term:proplist(), atom()) -> fs_handlecall_ret(). handle_directory_lookup(Id, Props, Node) -> kz_util:put_callid(Id), lager:debug("received fetch request (~s) user directory from ~s", [Id, Node]), @@ -184,7 +184,7 @@ handle_directory_lookup(Id, Props, Node) -> _Other -> directory_not_found(Node, Id) end. --spec maybe_sip_auth_response(ne_binary(), kz_proplist(), atom()) -> fs_handlecall_ret(). +-spec maybe_sip_auth_response(kz_term:ne_binary(), kz_term:proplist(), atom()) -> fs_handlecall_ret(). maybe_sip_auth_response(Id, Props, Node) -> case kz_term:is_not_empty(props:get_value(<<"sip_auth_response">>, Props)) of 'false' -> maybe_kamailio_association(Id, Props, Node); @@ -193,7 +193,7 @@ maybe_sip_auth_response(Id, Props, Node) -> lookup_user(Node, Id, <<"password">>, Props) end. --spec maybe_kamailio_association(ne_binary(), kz_proplist(), atom()) -> fs_handlecall_ret(). +-spec maybe_kamailio_association(kz_term:ne_binary(), kz_term:proplist(), atom()) -> fs_handlecall_ret(). maybe_kamailio_association(Id, Props, Node) -> case kz_term:is_not_empty(kzd_freeswitch:authorizing_id(Props)) andalso kz_term:is_not_empty(kzd_freeswitch:authorizing_type(Props)) @@ -202,7 +202,7 @@ maybe_kamailio_association(Id, Props, Node) -> 'false' -> directory_not_found(Node, Id) end. --spec kamailio_association(ne_binary(), kz_proplist(), atom()) -> fs_handlecall_ret(). +-spec kamailio_association(kz_term:ne_binary(), kz_term:proplist(), atom()) -> fs_handlecall_ret(). kamailio_association(Id, Props, Node) -> Password = kz_binary:rand_hex(12), Realm = props:get_value(<<"domain">>, Props), @@ -220,13 +220,13 @@ kamailio_association(Id, Props, Node) -> lager:debug("sending authn XML to ~w: ~s", [Node, Xml]), freeswitch:fetch_reply(Node, Id, 'directory', iolist_to_binary(Xml)). --spec directory_not_found(atom(), ne_binary()) -> fs_handlecall_ret(). +-spec directory_not_found(atom(), kz_term:ne_binary()) -> fs_handlecall_ret(). directory_not_found(Node, Id) -> {'ok', Xml} = ecallmgr_fs_xml:not_found(), lager:debug("sending authn not found XML to ~w", [Node]), freeswitch:fetch_reply(Node, Id, 'directory', iolist_to_binary(Xml)). --spec lookup_user(atom(), ne_binary(), ne_binary(), kz_proplist()) -> fs_handlecall_ret(). +-spec lookup_user(atom(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> fs_handlecall_ret(). lookup_user(Node, Id, Method, Props) -> Domain = props:get_value(<<"domain">>, Props), {'ok', Xml} = @@ -244,7 +244,7 @@ lookup_user(Node, Id, Method, Props) -> lager:debug("sending authn XML to ~w: ~s", [Node, Xml]), freeswitch:fetch_reply(Node, Id, 'directory', iolist_to_binary(Xml)). --spec get_auth_realm(kz_proplist()) -> ne_binary(). +-spec get_auth_realm(kz_term:proplist()) -> kz_term:ne_binary(). get_auth_realm(Props) -> case props:get_first_defined([<<"sip_auth_realm">> ,<<"domain">> @@ -260,7 +260,7 @@ get_auth_realm(Props) -> end end. --spec get_auth_uri_realm(kz_proplist()) -> ne_binary(). +-spec get_auth_uri_realm(kz_term:proplist()) -> kz_term:ne_binary(). get_auth_uri_realm(Props) -> AuthURI = props:get_value(<<"sip_auth_uri">>, Props, <<>>), case binary:split(AuthURI, <<"@">>) of @@ -272,7 +272,7 @@ get_auth_uri_realm(Props) -> ], Props) end. --spec handle_lookup_resp(ne_binary(), ne_binary(), ne_binary() +-spec handle_lookup_resp(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary() ,{'ok', kz_json:object()} | {'error', _}) -> {'ok', _}. handle_lookup_resp(<<"reverse-lookup">>, Realm, Username, {'ok', JObj}) -> @@ -292,7 +292,7 @@ handle_lookup_resp(_, _, _, {'error', _R}) -> lager:debug("authn request lookup failed: ~p", [_R]), ecallmgr_fs_xml:not_found(). --spec maybe_query_registrar(ne_binary(), ne_binary(), atom(), ne_binary(), ne_binary(), kz_proplist()) -> +-spec maybe_query_registrar(kz_term:ne_binary(), kz_term:ne_binary(), atom(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> {'ok', kz_json:object()} | {'error', any()}. maybe_query_registrar(Realm, Username, Node, Id, Method, Props) -> @@ -301,7 +301,7 @@ maybe_query_registrar(Realm, Username, Node, Id, Method, Props) -> {'error', 'not_found'} -> query_registrar(Realm, Username, Node, Id, Method, Props) end. --spec query_registrar(ne_binary(), ne_binary(), atom(), ne_binary(), ne_binary(), kz_proplist()) -> +-spec query_registrar(kz_term:ne_binary(), kz_term:ne_binary(), atom(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> {'ok', kz_json:object()} | {'error', any()}. query_registrar(Realm, Username, Node, Id, Method, Props) -> @@ -337,7 +337,7 @@ query_registrar(Realm, Username, Node, Id, Method, Props) -> %% to wait for conferences, etc. Since Kamailio does not honor %% Defer-Response we can use that flag on registrar errors %% to queue in Kazoo but still advance Kamailio, just need to check here. --spec maybe_defered_error(ne_binary(), ne_binary(), kz_json:object()) -> {'ok', kz_json:object()} | {'error', 'timeout'}. +-spec maybe_defered_error(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> {'ok', kz_json:object()} | {'error', 'timeout'}. maybe_defered_error(Realm, Username, JObj) -> case kapi_authn:resp_v(JObj) of 'false' -> {'error', 'timeout'}; diff --git a/applications/ecallmgr/src/ecallmgr_fs_authz.erl b/applications/ecallmgr/src/ecallmgr_fs_authz.erl index aaf800e3972..db6d2b3b4e9 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_authz.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_authz.erl @@ -31,7 +31,7 @@ -export_type([authz_reply/0]). --spec authorize(kzd_freeswitch:data(), ne_binary(), atom()) -> authz_reply(). +-spec authorize(kzd_freeswitch:data(), kz_term:ne_binary(), atom()) -> authz_reply(). authorize(Props, CallId, Node) -> kz_util:put_callid(CallId), AuthorizeReply = is_mobile_device(Props, Node), @@ -50,7 +50,7 @@ authorized_log('true') -> ""; authorized_log('false') -> " not". -spec kill_channel(kzd_freeswitch:data(), atom()) -> 'ok'. --spec kill_channel(ne_binary(), ne_binary(), ne_binary(), atom()) -> 'ok'. +-spec kill_channel(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), atom()) -> 'ok'. kill_channel(Props, Node) -> Direction = kzd_freeswitch:call_direction(Props), @@ -95,7 +95,7 @@ maybe_authorize_conference_number(Props) -> ), <<"conference">> =:= kzd_freeswitch:hunt_destination_number(Props). --spec maybe_channel_recovering(kzd_freeswitch:data(), ne_binary(), atom()) -> authz_reply(). +-spec maybe_channel_recovering(kzd_freeswitch:data(), kz_term:ne_binary(), atom()) -> authz_reply(). maybe_channel_recovering(Props, CallId, Node) -> case kzd_freeswitch:is_channel_recovering(Props, 'false') of 'false' -> is_authz_enabled(Props, CallId, Node); @@ -104,7 +104,7 @@ maybe_channel_recovering(Props, CallId, Node) -> allow_call(Props, CallId, Node) end. --spec is_authz_enabled(kzd_freeswitch:data(), ne_binary(), atom()) -> authz_reply(). +-spec is_authz_enabled(kzd_freeswitch:data(), kz_term:ne_binary(), atom()) -> authz_reply(). is_authz_enabled(Props, CallId, Node) -> case ecallmgr_config:is_true(<<"authz_enabled">>, 'false') of 'true' -> is_global_resource(Props, CallId, Node); @@ -113,7 +113,7 @@ is_authz_enabled(Props, CallId, Node) -> allow_call(Props, CallId, Node) end. --spec is_global_resource(kzd_freeswitch:data(), ne_binary(), atom()) -> authz_reply(). +-spec is_global_resource(kzd_freeswitch:data(), kz_term:ne_binary(), atom()) -> authz_reply(). is_global_resource(Props, CallId, Node) -> case kzd_freeswitch:is_consuming_global_resource(Props, 'true') orelse ecallmgr_config:is_true(<<"authz_local_resources">>, 'false') @@ -124,7 +124,7 @@ is_global_resource(Props, CallId, Node) -> allow_call(Props, CallId, Node) end. --spec is_consuming_resource(kzd_freeswitch:data(), ne_binary(), atom()) -> authz_reply(). +-spec is_consuming_resource(kzd_freeswitch:data(), kz_term:ne_binary(), atom()) -> authz_reply(). is_consuming_resource(Props, CallId, Node) -> case kzd_freeswitch:call_direction(Props) of <<"outbound">> -> @@ -133,7 +133,7 @@ is_consuming_resource(Props, CallId, Node) -> is_consuming_inbound_resource(Props, CallId, Node) end. --spec is_consuming_outbound_resource(kzd_freeswitch:data(), ne_binary(), atom()) -> authz_reply(). +-spec is_consuming_outbound_resource(kzd_freeswitch:data(), kz_term:ne_binary(), atom()) -> authz_reply(). is_consuming_outbound_resource(Props, CallId, Node) -> case kzd_freeswitch:resource_id(Props) of 'undefined' -> @@ -142,7 +142,7 @@ is_consuming_outbound_resource(Props, CallId, Node) -> _ResourceId -> request_channel_authorization(Props, CallId, Node) end. --spec is_consuming_inbound_resource(kzd_freeswitch:data(), ne_binary(), atom()) -> authz_reply(). +-spec is_consuming_inbound_resource(kzd_freeswitch:data(), kz_term:ne_binary(), atom()) -> authz_reply(). is_consuming_inbound_resource(Props, CallId, Node) -> case kzd_freeswitch:authorizing_id(Props) =:= 'undefined' orelse kzd_freeswitch:authorizing_type(Props) =:= <<"resource">> @@ -153,7 +153,7 @@ is_consuming_inbound_resource(Props, CallId, Node) -> allow_call(Props, CallId, Node) end. --spec request_channel_authorization(kzd_freeswitch:data(), ne_binary(), atom()) -> +-spec request_channel_authorization(kzd_freeswitch:data(), kz_term:ne_binary(), atom()) -> authz_reply(). request_channel_authorization(Props, CallId, Node) -> lager:debug("channel authorization request started"), @@ -169,7 +169,7 @@ request_channel_authorization(Props, CallId, Node) -> authz_default(Props, CallId, Node) end. --spec authz_response(kz_json:object(), kzd_freeswitch:data(), ne_binary(), atom()) -> authz_reply(). +-spec authz_response(kz_json:object(), kzd_freeswitch:data(), kz_term:ne_binary(), atom()) -> authz_reply(). authz_response(JObj, Props, CallId, Node) -> case kz_json:is_true(<<"Is-Authorized">>, JObj) orelse kz_json:is_true(<<"Soft-Limit">>, JObj) @@ -191,7 +191,7 @@ authz_response(JObj, Props, CallId, Node) -> end end. --spec authorize_account(kz_json:object(), kzd_freeswitch:data(), ne_binary(), atom()) -> +-spec authorize_account(kz_json:object(), kzd_freeswitch:data(), kz_term:ne_binary(), atom()) -> authz_reply(). authorize_account(JObj, Props, CallId, Node) -> AccountId = kz_json:get_value(<<"Account-ID">>, JObj), @@ -208,14 +208,14 @@ authorize_account(JObj, Props, CallId, Node) -> authorize_reseller(JObj, P, CallId, Node). --spec maybe_add_outbound_flags(kz_json:object()) -> kz_proplist(). +-spec maybe_add_outbound_flags(kz_json:object()) -> kz_term:proplist(). maybe_add_outbound_flags(JObj) -> case kz_json:get_value(<<"Outbound-Flags">>, JObj) of 'undefined' -> []; Flags -> [{?GET_CCV(<<"Outbound-Flags">>), Flags}] end. --spec authorize_reseller(kz_json:object(), kzd_freeswitch:data(), ne_binary(), atom()) -> +-spec authorize_reseller(kz_json:object(), kzd_freeswitch:data(), kz_term:ne_binary(), atom()) -> authz_reply(). authorize_reseller(JObj, Props, CallId, Node) -> AccountId = props:get_value(?GET_CCV(<<"Account-ID">>), Props), @@ -232,7 +232,7 @@ authorize_reseller(JObj, Props, CallId, Node) -> set_ccv_trunk_usage(JObj, P, CallId, Node) end. --spec set_ccv_trunk_usage(kz_json:object(), kzd_freeswitch:data(), ne_binary(), atom()) -> +-spec set_ccv_trunk_usage(kz_json:object(), kzd_freeswitch:data(), kz_term:ne_binary(), atom()) -> authz_reply(). set_ccv_trunk_usage(JObj, Props, CallId, Node) -> Usage = [{?GET_CCV(Key), TrunkUsage} @@ -244,13 +244,13 @@ set_ccv_trunk_usage(JObj, Props, CallId, Node) -> P = props:set_values(props:filter_undefined(Usage), Props), rate_call(P, CallId, Node). --spec rate_call(kzd_freeswitch:data(), ne_binary(), atom()) -> authz_reply(). +-spec rate_call(kzd_freeswitch:data(), kz_term:ne_binary(), atom()) -> authz_reply(). rate_call(Props, CallId, Node) -> _P = kz_util:spawn(fun rate_channel/2, [Props, Node]), lager:debug("rating call in ~p", [_P]), allow_call(Props, CallId, Node). --spec allow_call(kzd_freeswitch:data(), ne_binary(), atom()) -> authz_reply(). +-spec allow_call(kzd_freeswitch:data(), kz_term:ne_binary(), atom()) -> authz_reply(). allow_call(Props, _CallId, _Node) -> lager:debug("channel authorization succeeded, allowing call"), Vars = props:filter_undefined( @@ -310,7 +310,7 @@ maybe_kill_unrated_channel(Props, Node) -> kill_channel(Props, Node) end. --spec authz_default(kzd_freeswitch:data(), ne_binary(), atom()) -> {'ok', ne_binary()} | boolean(). +-spec authz_default(kzd_freeswitch:data(), kz_term:ne_binary(), atom()) -> {'ok', kz_term:ne_binary()} | boolean(). %% TODO: fix use of authz_default authz_default(Props, CallId, Node) -> case ecallmgr_config:get_ne_binary(<<"authz_default_action">>, <<"deny">>) =:= <<"deny">> @@ -337,7 +337,7 @@ set_rating_ccvs(JObj, Node) -> ,get_rating_ccvs(JObj) ). --spec get_rating_ccvs(kz_json:object()) -> kz_proplist(). +-spec get_rating_ccvs(kz_json:object()) -> kz_term:proplist(). get_rating_ccvs(JObj) -> lists:foldl(fun(Key, Acc) -> rating_ccv(Key, Acc, JObj) @@ -346,8 +346,8 @@ get_rating_ccvs(JObj) -> ,?RATE_VARS ). --spec rating_ccv(ne_binary(), kz_proplist(), kz_json:object()) -> - kz_proplist(). +-spec rating_ccv(kz_term:ne_binary(), kz_term:proplist(), kz_json:object()) -> + kz_term:proplist(). rating_ccv(<<"Rate">>, Acc, JObj) -> maybe_update_callee_id(JObj, Acc); rating_ccv(Key, Acc, JObj) -> @@ -356,7 +356,7 @@ rating_ccv(Key, Acc, JObj) -> Value -> [{Key, Value}|Acc] end. --spec maybe_update_callee_id(kz_json:object(), kz_proplist()) -> kz_proplist(). +-spec maybe_update_callee_id(kz_json:object(), kz_term:proplist()) -> kz_term:proplist(). maybe_update_callee_id(JObj, Acc) -> Rate = kz_json:get_binary_value(<<"Rate">>, JObj, <<"0.00">>), @@ -374,7 +374,7 @@ maybe_update_callee_id(JObj, Acc) -> 'false' -> [{<<"Rate">>, Rate}|Acc] end. --spec authz_req(kzd_freeswitch:data()) -> kz_proplist(). +-spec authz_req(kzd_freeswitch:data()) -> kz_term:proplist(). authz_req(Props) -> AccountId = kzd_freeswitch:account_id(Props), props:filter_undefined( @@ -405,7 +405,7 @@ outbound_flags(Props) -> Flags when is_list(Flags) -> Flags end. --spec rating_req(ne_binary(), kzd_freeswitch:data()) -> kz_proplist(). +-spec rating_req(kz_term:ne_binary(), kzd_freeswitch:data()) -> kz_term:proplist(). rating_req(CallId, Props) -> props:filter_undefined([{<<"To-DID">>, kzd_freeswitch:to_did(Props)} ,{<<"From-DID">>, kzd_freeswitch:caller_id_number(Props)} diff --git a/applications/ecallmgr/src/ecallmgr_fs_bridge.erl b/applications/ecallmgr/src/ecallmgr_fs_bridge.erl index 8e8f60389e2..6aabbb770d7 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_bridge.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_bridge.erl @@ -20,7 +20,7 @@ -define(BYPASS_MEDIA_AFTER_BRIDGE, ecallmgr_config:get_boolean(<<"use_bypass_media_after_bridge">>, 'false')). -define(CHANNEL_ACTIONS_KEY, [<<"Custom-Channel-Vars">>, <<"Channel-Actions">>]). --spec call_command(atom(), ne_binary(), kz_json:object()) -> {'error', binary()} | {binary(), kz_proplist()}. +-spec call_command(atom(), kz_term:ne_binary(), kz_json:object()) -> {'error', binary()} | {binary(), kz_term:proplist()}. call_command(Node, UUID, JObj) -> Endpoints = kz_json:get_list_value(<<"Endpoints">>, JObj, []), case kapi_dialplan:bridge_v(JObj) of @@ -59,9 +59,9 @@ call_command(Node, UUID, JObj) -> {<<"xferext">>, XferExt} end. --spec unbridge(ne_binary(), kz_json:object()) -> - kz_proplist() | - {'error', ne_binary()}. +-spec unbridge(kz_term:ne_binary(), kz_json:object()) -> + kz_term:proplist() | + {'error', kz_term:ne_binary()}. unbridge(UUID, JObj) -> case kapi_dialplan:unbridge_v(JObj) of 'false' -> {'error', <<"unbridge failed to execute as API did not validate">>}; @@ -81,7 +81,7 @@ unbridge(UUID, JObj) -> %% Bridge command helpers %% @end %%-------------------------------------------------------------------- --spec handle_ringback(atom(), ne_binary(), kz_json:object()) -> 'ok'. +-spec handle_ringback(atom(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. handle_ringback(Node, UUID, JObj) -> case kz_json:get_first_defined([<<"Ringback">> ,[<<"Custom-Channel-Vars">>, <<"Ringback">>] @@ -96,18 +96,18 @@ handle_ringback(Node, UUID, JObj) -> ecallmgr_fs_command:set(Node, UUID, [{<<"ringback">>, Stream}]) end. --spec maybe_early_media(atom(), ne_binary(), kz_json:object(), kz_json:objects()) -> ecallmgr_util:send_cmd_ret(). +-spec maybe_early_media(atom(), kz_term:ne_binary(), kz_json:object(), kz_json:objects()) -> ecallmgr_util:send_cmd_ret(). maybe_early_media(Node, UUID, JObj, Endpoints) -> Separator = ecallmgr_util:get_dial_separator(JObj, Endpoints), maybe_early_media_separator(Node, UUID, JObj, Separator). --spec maybe_early_media_separator(atom(), ne_binary(), kz_json:object(), ne_binary()) -> ecallmgr_util:send_cmd_ret(). +-spec maybe_early_media_separator(atom(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> ecallmgr_util:send_cmd_ret(). maybe_early_media_separator(Node, UUID, _JObj, ?SEPARATOR_SIMULTANEOUS) -> lager:debug("bridge is simultaneous to multiple endpoints, starting local ringing"), ecallmgr_util:send_cmd(Node, UUID, <<"ring_ready">>, ""); maybe_early_media_separator(_Node, _UUID, _, _) -> 'ok'. --spec handle_hold_media(kz_proplist(), atom(), ne_binary(), channel(), kz_json:object()) -> kz_proplist(). +-spec handle_hold_media(kz_term:proplist(), atom(), kz_term:ne_binary(), channel(), kz_json:object()) -> kz_term:proplist(). handle_hold_media(DP, _Node, UUID, _Channel, JObj) -> case kz_json:get_value(<<"Hold-Media">>, JObj) of 'undefined' -> @@ -130,21 +130,21 @@ handle_hold_media(DP, _Node, UUID, _Channel, JObj) -> ] end. --spec handle_secure_rtp(kz_proplist(), atom(), ne_binary(), channel(), kz_json:object()) -> kz_proplist(). +-spec handle_secure_rtp(kz_term:proplist(), atom(), kz_term:ne_binary(), channel(), kz_json:object()) -> kz_term:proplist(). handle_secure_rtp(DP, _Node, _UUID, _Channel, JObj) -> case kz_json:is_true(<<"Secure-RTP">>, JObj, 'false') of 'true' -> [{"application", "set zrtp_secure_media=true"}|DP]; 'false' -> DP end. --spec maybe_handle_bypass_media(kz_proplist(), atom(), ne_binary(), channel(), kz_json:object()) -> kz_proplist(). +-spec maybe_handle_bypass_media(kz_term:proplist(), atom(), kz_term:ne_binary(), channel(), kz_json:object()) -> kz_term:proplist(). maybe_handle_bypass_media(DP, Node, UUID, Channel, JObj) -> case ?BYPASS_MEDIA_AFTER_BRIDGE of 'true' -> DP; 'false' -> handle_bypass_media(DP, Node, UUID, Channel, JObj) end. --spec handle_bypass_media(kz_proplist(), atom(), ne_binary(), channel(), kz_json:object()) -> kz_proplist(). +-spec handle_bypass_media(kz_term:proplist(), atom(), kz_term:ne_binary(), channel(), kz_json:object()) -> kz_term:proplist(). handle_bypass_media(DP, _Node, _UUID, #channel{profile=ChannelProfile}, JObj) -> BridgeProfile = kz_term:to_binary(kz_json:get_value(<<"SIP-Interface">>, JObj, ?DEFAULT_FS_PROFILE)), case kz_json:get_value(<<"Media">>, JObj) of @@ -159,7 +159,7 @@ handle_bypass_media(DP, _Node, _UUID, #channel{profile=ChannelProfile}, JObj) -> maybe_bypass_endpoint_media(Endpoints, BridgeProfile, ChannelProfile, DP) end. --spec maybe_bypass_endpoint_media(kz_json:objects(), ne_binary(), ne_binary(), kz_proplist()) -> kz_proplist(). +-spec maybe_bypass_endpoint_media(kz_json:objects(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> kz_term:proplist(). maybe_bypass_endpoint_media(Endpoints, BridgeProfile, ChannelProfile, DP) -> ShouldBypass = lists:all(fun(Endpoint) -> bypass_endpoint_media_enabled(Endpoint @@ -174,13 +174,13 @@ maybe_bypass_endpoint_media(Endpoints, BridgeProfile, ChannelProfile, DP) -> 'false' -> DP end. --spec bypass_endpoint_media_enabled(kz_json:object(), ne_binary(), ne_binary()) -> boolean(). +-spec bypass_endpoint_media_enabled(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). bypass_endpoint_media_enabled(Endpoint, BridgeProfile, ChannelProfile) -> EndpointProfile = kz_json:get_ne_binary_value(<<"SIP-Interface">>, Endpoint, BridgeProfile), kz_json:is_true(<<"Bypass-Media">>, Endpoint) andalso EndpointProfile =:= ChannelProfile. --spec handle_ccvs(kz_proplist(), atom(), ne_binary(), channel(), kz_json:object()) -> kz_proplist(). +-spec handle_ccvs(kz_term:proplist(), atom(), kz_term:ne_binary(), channel(), kz_json:object()) -> kz_term:proplist(). handle_ccvs(DP, Node, UUID, _Channel, JObj) -> case kz_json:get_json_value(<<"Custom-Channel-Vars">>, JObj) of 'undefined' -> DP; @@ -190,7 +190,7 @@ handle_ccvs(DP, Node, UUID, _Channel, JObj) -> [{"application", <<"kz_multiset ", AppArgs/binary>>}] ++ DP end. --spec handle_cavs(kz_proplist(), atom(), ne_binary(), channel(), kz_json:object()) -> kz_proplist(). +-spec handle_cavs(kz_term:proplist(), atom(), kz_term:ne_binary(), channel(), kz_json:object()) -> kz_term:proplist(). handle_cavs(DP, Node, UUID, _Channel, JObj) -> case kz_json:get_json_value(<<"Custom-Application-Vars">>, JObj) of 'undefined' -> DP; @@ -201,29 +201,29 @@ handle_cavs(DP, Node, UUID, _Channel, JObj) -> [{"application", <<"kz_multiset ", AppArgs/binary>>}] ++ DP end. --spec handle_loopback_key(boolean(), ne_binary(), kz_json:object()) -> kz_proplist(). +-spec handle_loopback_key(boolean(), kz_term:ne_binary(), kz_json:object()) -> kz_term:proplist(). handle_loopback_key('false', _Key, _JObj) -> []; handle_loopback_key('true', Key, JObj) -> V = kz_term:to_binary(kz_json:is_false(Key, JObj, 'false')), K = ecallmgr_util:get_fs_key(Key), [{"application", <<"export ", K/binary, "=", V/binary>>}]. --spec handle_loopback_key(ne_binary(), kz_json:object()) -> kz_proplist(). +-spec handle_loopback_key(kz_term:ne_binary(), kz_json:object()) -> kz_term:proplist(). handle_loopback_key(Key, JObj) -> Exists = kz_json:get_value(Key, JObj) =/= 'undefined', handle_loopback_key(Exists, Key, JObj). --spec handle_loopback_keys(ne_binaries(), kz_json:object(), kz_proplist()) -> kz_proplist(). +-spec handle_loopback_keys(kz_term:ne_binaries(), kz_json:object(), kz_term:proplist()) -> kz_term:proplist(). handle_loopback_keys([], _JObj, Acc) -> Acc; handle_loopback_keys([Key | Keys], JObj, Acc) -> handle_loopback_keys(Keys, JObj, Acc ++ handle_loopback_key(Key, JObj)). --spec handle_loopback(kz_proplist(), atom(), ne_binary(), channel(), kz_json:object()) -> kz_proplist(). +-spec handle_loopback(kz_term:proplist(), atom(), kz_term:ne_binary(), channel(), kz_json:object()) -> kz_term:proplist(). handle_loopback(DP, _Node, _UUID, _Channel, JObj) -> Keys = [<<"Simplify-Loopback">>, <<"Loopback-Bowout">>], handle_loopback_keys(Keys, JObj, DP). --spec pre_exec(kz_proplist(), atom(), ne_binary(), channel(), kz_json:object()) -> kz_proplist(). +-spec pre_exec(kz_term:proplist(), atom(), kz_term:ne_binary(), channel(), kz_json:object()) -> kz_term:proplist(). pre_exec(DP, _Node, _UUID, _Channel, _JObj) -> [{"application", "set continue_on_fail=true"} ,{"application", "export sip_redirect_context=context_2"} @@ -241,7 +241,7 @@ pre_exec(DP, _Node, _UUID, _Channel, _JObj) -> |DP ]. --spec create_command(kz_proplist(), atom(), ne_binary(), channel(), kz_json:object()) -> kz_proplist(). +-spec create_command(kz_term:proplist(), atom(), kz_term:ne_binary(), channel(), kz_json:object()) -> kz_term:proplist(). create_command(DP, _Node, _UUID, #channel{profile=ChannelProfile}, JObj) -> BypassAfterBridge = ?BYPASS_MEDIA_AFTER_BRIDGE, BridgeProfile = kz_term:to_binary(kz_json:get_value(<<"SIP-Interface">>, JObj, ?DEFAULT_FS_PROFILE)), @@ -253,7 +253,7 @@ create_command(DP, _Node, _UUID, #channel{profile=ChannelProfile}, JObj) -> ]), [{"application", BridgeCmd}|DP]. --spec maybe_bypass_after_bridge(boolean(), ne_binary(), ne_binary(), kz_json:objects()) -> kz_json:objects(). +-spec maybe_bypass_after_bridge(boolean(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:objects()) -> kz_json:objects(). maybe_bypass_after_bridge('false', _, _, Endpoints) -> [kz_json:delete_key(<<"Bypass-Media">>, Endpoint) || Endpoint <- Endpoints]; maybe_bypass_after_bridge('true', BridgeProfile, ChannelProfile, Endpoints) -> @@ -264,7 +264,7 @@ maybe_bypass_after_bridge('true', BridgeProfile, ChannelProfile, Endpoints) -> end end || Endpoint <- Endpoints]. --spec try_create_bridge_string(kz_json:objects(), kz_json:object()) -> ne_binary(). +-spec try_create_bridge_string(kz_json:objects(), kz_json:object()) -> kz_term:ne_binary(). try_create_bridge_string(Endpoints, JObj) -> DialSeparator = ecallmgr_util:get_dial_separator(JObj, Endpoints), case ecallmgr_util:build_bridge_string(Endpoints, DialSeparator) of @@ -283,7 +283,7 @@ build_channels_vars(Endpoints, JObj) -> end, ecallmgr_fs_xml:get_channel_vars(kz_json:set_values(Props, JObj)). --spec post_exec(kz_proplist(), atom(), ne_binary(), channel(), kz_json:object()) -> kz_proplist(). +-spec post_exec(kz_term:proplist(), atom(), kz_term:ne_binary(), channel(), kz_json:object()) -> kz_term:proplist(). post_exec(DP, _Node, _UUID, _Channel, _JObj) -> Event = ecallmgr_util:create_masquerade_event(<<"bridge">>, <<"CHANNEL_EXECUTE_COMPLETE">>), [{"application", Event} @@ -291,22 +291,22 @@ post_exec(DP, _Node, _UUID, _Channel, _JObj) -> |DP ]. --spec maybe_b_leg_events(atom(), ne_binary(), kz_json:object()) -> 'ok'. +-spec maybe_b_leg_events(atom(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. maybe_b_leg_events(Node, UUID, JObj) -> Events = kz_json:get_value(<<"B-Leg-Events">>, JObj, []), ecallmgr_call_events:listen_for_other_leg(Node, UUID, Events). --spec add_endpoints_channel_actions(atom(), ne_binary(), kz_json:object()) -> kz_json:object(). +-spec add_endpoints_channel_actions(atom(), kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). add_endpoints_channel_actions(Node, UUID, JObj) -> Endpoints = kz_json:get_list_value(<<"Endpoints">>, JObj, []), kz_json:set_value(<<"Endpoints">>, build_endpoints_actions(Node, UUID, Endpoints), JObj). --spec build_endpoints_actions(atom(), ne_binary(), kz_json:objects()) -> kz_json:objects(). +-spec build_endpoints_actions(atom(), kz_term:ne_binary(), kz_json:objects()) -> kz_json:objects(). build_endpoints_actions(Node, UUID, Endpoints) -> Fun = fun(Endpoint) -> build_endpoint_actions(Node, UUID, Endpoint) end, lists:map(Fun, Endpoints). --spec build_endpoint_actions(atom(), ne_binary(), kz_json:object()) -> kz_json:object(). +-spec build_endpoint_actions(atom(), kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). build_endpoint_actions(Node, UUID, Endpoint) -> JObj = kz_json:get_json_value(<<"Endpoint-Actions">>, Endpoint, kz_json:new()), Fun = fun(K, V, Acc)-> build_endpoint_actions(Node, UUID, K, V, Acc) end, @@ -317,27 +317,27 @@ build_endpoint_actions(Node, UUID, Endpoint) -> kz_json:set_value(?CHANNEL_ACTIONS_KEY, Var, Endpoint) end. --type ep_actions() :: ne_binaries(). +-type ep_actions() :: kz_term:ne_binaries(). --spec build_endpoint_actions(atom(), ne_binary(), ne_binary(), kz_json:object(), ep_actions()) -> +-spec build_endpoint_actions(atom(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), ep_actions()) -> ep_actions(). build_endpoint_actions(Node, UUID, K, V, Acc) -> Fun = fun(K1, V1, Acc1)-> build_endpoint_action(Node, UUID, K1, V1, Acc1) end, DP = kz_json:foldr(Fun, [], V), Acc ++ build_endpoint_action_dp(K, DP). --spec build_endpoint_action(atom(), ne_binary(), ne_binary(), kz_json:object(), fs_apps()) -> +-spec build_endpoint_action(atom(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), fs_apps()) -> fs_apps(). build_endpoint_action(Node, UUID, _K, V, Acc) -> lager:debug("building dialplan action for ~s", [_K]), DP = ecallmgr_call_command:fetch_dialplan(Node, UUID, V, self()), Acc ++ DP. --spec build_endpoint_action_dp(ne_binary(), fs_apps()) -> ep_actions(). +-spec build_endpoint_action_dp(kz_term:ne_binary(), fs_apps()) -> ep_actions(). build_endpoint_action_dp(K, DP) -> build_endpoint_action_dp(endpoint_action_cmd(K), DP, 1, []). --spec build_endpoint_action_dp(ne_binary(), fs_apps(), pos_integer(), ep_actions()) -> ep_actions(). +-spec build_endpoint_action_dp(kz_term:ne_binary(), fs_apps(), pos_integer(), ep_actions()) -> ep_actions(). build_endpoint_action_dp(_K, [], _N, Acc) -> lists:reverse(Acc); build_endpoint_action_dp(K, [{App, Args} | DP], N, Acc) -> @@ -347,14 +347,14 @@ build_endpoint_action_dp(K, [{App, Args} | DP], N, Acc) -> Var = list_to_binary([K, "_", Seq, "=", DPApp, " ", DPArgs, ""]), build_endpoint_action_dp(K, DP, N + 1, [Var | Acc]). --spec endpoint_action_cmd(ne_binary()) -> ne_binary(). +-spec endpoint_action_cmd(kz_term:ne_binary()) -> kz_term:ne_binary(). endpoint_action_cmd(Event) -> case lists:keyfind(Event, 1, ?DP_EVENT_VARS) of 'false' -> normalize_event_action_key(Event); {_, Prefix} -> Prefix end. --spec normalize_event_action_key(ne_binary()) -> ne_binary(). +-spec normalize_event_action_key(kz_term:ne_binary()) -> kz_term:ne_binary(). normalize_event_action_key(Key) when is_binary(Key) -> << <<(normalize_event_action_char(B))>> || <> <= Key>>. diff --git a/applications/ecallmgr/src/ecallmgr_fs_channel.erl b/applications/ecallmgr/src/ecallmgr_fs_channel.erl index 135ad4f2284..07844de1839 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_channel.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_channel.erl @@ -56,7 +56,7 @@ -define(SERVER, ?MODULE). -record(state, {node = 'undefined' :: atom() - ,options = [] :: kz_proplist() + ,options = [] :: kz_term:proplist() }). -type state() :: #state{}. @@ -67,21 +67,21 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(atom()) -> startlink_ret(). --spec start_link(atom(), kz_proplist()) -> startlink_ret(). +-spec start_link(atom()) -> kz_types:startlink_ret(). +-spec start_link(atom(), kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Node) -> start_link(Node, []). start_link(Node, Options) -> gen_server:start_link(?SERVER, [Node, Options], []). -type fetch_resp() :: kz_json:object() | - kz_proplist() | + kz_term:proplist() | channel(). -type channel_format() :: 'json' | 'proplist' | 'record'. --spec fetch(ne_binary()) -> +-spec fetch(kz_term:ne_binary()) -> {'ok', fetch_resp()} | {'error', 'not_found'}. --spec fetch(ne_binary(), channel_format()) -> +-spec fetch(kz_term:ne_binary(), channel_format()) -> {'ok', fetch_resp()} | {'error', 'not_found'}. fetch(UUID) -> @@ -92,10 +92,10 @@ fetch(UUID, Format) -> _Else -> {'error', 'not_found'} end. --spec fetch_other_leg(ne_binary()) -> +-spec fetch_other_leg(kz_term:ne_binary()) -> {'ok', fetch_resp()} | {'error', 'not_found'}. --spec fetch_other_leg(ne_binary(), channel_format()) -> +-spec fetch_other_leg(kz_term:ne_binary(), channel_format()) -> {'ok', fetch_resp()} | {'error', 'not_found'}. fetch_other_leg(UUID) -> @@ -111,7 +111,7 @@ format('json', Channel) -> to_json(Channel); format('proplist', Channel) -> to_props(Channel); format('record', Channel) -> Channel. --spec node(ne_binary()) -> +-spec node(kz_term:ne_binary()) -> {'ok', atom()} | {'error', 'not_found'}. node(UUID) -> @@ -124,7 +124,7 @@ node(UUID) -> _ -> {'error', 'not_found'} end. --spec set_node(atom(), ne_binary()) -> 'ok'. +-spec set_node(atom(), kz_term:ne_binary()) -> 'ok'. set_node(Node, UUID) -> Updates = case node(UUID) of @@ -137,7 +137,7 @@ set_node(Node, UUID) -> end, ecallmgr_fs_channels:updates(UUID, Updates). --spec former_node(ne_binary()) -> +-spec former_node(kz_term:ne_binary()) -> {'ok', atom()} | {'error', any()}. former_node(UUID) -> @@ -151,7 +151,7 @@ former_node(UUID) -> _ -> {'error', 'not_found'} end. --spec is_bridged(ne_binary()) -> boolean(). +-spec is_bridged(kz_term:ne_binary()) -> boolean(). is_bridged(UUID) -> MatchSpec = [{#channel{uuid = '$1', other_leg = '$2', _ = '_'} ,[{'=:=', '$1', {'const', UUID}}] @@ -163,27 +163,27 @@ is_bridged(UUID) -> _E -> lager:debug("not bridged: ~p", [_E]), 'false' end. --spec exists(ne_binary()) -> boolean(). +-spec exists(kz_term:ne_binary()) -> boolean(). exists(UUID) -> ets:member(?CHANNELS_TBL, UUID). --spec import_moh(ne_binary()) -> boolean(). +-spec import_moh(kz_term:ne_binary()) -> boolean(). import_moh(UUID) -> try ets:lookup_element(?CHANNELS_TBL, UUID, #channel.import_moh) catch 'error':'badarg' -> 'false' end. --spec set_account_id(ne_binary(), string() | ne_binary()) -> 'ok'. +-spec set_account_id(kz_term:ne_binary(), string() | kz_term:ne_binary()) -> 'ok'. set_account_id(UUID, Value) when is_binary(Value) -> ecallmgr_fs_channels:update(UUID, #channel.account_id, Value); set_account_id(UUID, Value) -> set_account_id(UUID, kz_term:to_binary(Value)). --spec set_authorized(ne_binary(), boolean() | ne_binary()) -> 'ok'. +-spec set_authorized(kz_term:ne_binary(), boolean() | kz_term:ne_binary()) -> 'ok'. set_authorized(UUID, Value) -> ecallmgr_fs_channels:update(UUID, #channel.is_authorized, kz_term:is_true(Value)). --spec renew(atom(), ne_binary()) -> +-spec renew(atom(), kz_term:ne_binary()) -> {'ok', channel()} | {'error', 'timeout' | 'badarg'}. renew(Node, UUID) -> @@ -193,8 +193,8 @@ renew(Node, UUID) -> {'error', _}=E -> E end. --spec channel_data(atom(), ne_binary()) -> {'ok', kz_proplist()} | - freeswitch:fs_api_error(). +-spec channel_data(atom(), kz_term:ne_binary()) -> {'ok', kz_term:proplist()} | + freeswitch:fs_api_error(). channel_data(Node, UUID) -> case freeswitch:api(Node, 'uuid_dump', UUID) of {'error', _}=E -> E; @@ -206,7 +206,7 @@ channel_data(Node, UUID) -> to_json(Channel) -> kz_json:from_list(to_props(Channel)). --spec to_props(channel()) -> kz_proplist(). +-spec to_props(channel()) -> kz_term:proplist(). to_props(Channel) -> props:filter_undefined( [{<<"account_billing">>, Channel#channel.account_billing} @@ -249,11 +249,11 @@ to_props(Channel) -> ,{<<"uuid">>, Channel#channel.uuid} ]). --spec to_api_json(ne_binary() | channel()) -> kz_json:object(). +-spec to_api_json(kz_term:ne_binary() | channel()) -> kz_json:object(). to_api_json(Channel) -> kz_json:from_list(to_api_props(Channel)). --spec to_api_props(ne_binary() | channel()) -> kz_proplist(). +-spec to_api_props(kz_term:ne_binary() | channel()) -> kz_term:proplist(). to_api_props(#channel{}=Channel) -> props:filter_undefined( [{<<"Account-Billing">>, Channel#channel.account_billing} @@ -298,7 +298,7 @@ to_api_props(?NE_BINARY=CallId) -> {'ok', #channel{}=Channel} = fetch(CallId, 'record'), to_api_props(Channel). --spec channel_ccvs(channel() | kz_json:object() | kz_proplist()) -> kz_proplist(). +-spec channel_ccvs(channel() | kz_json:object() | kz_term:proplist()) -> kz_term:proplist(). channel_ccvs(#channel{}=Channel) -> props:filter_undefined( [{<<"Account-ID">>, Channel#channel.account_id} @@ -342,7 +342,7 @@ channel_ccvs([_|_]=Props) -> channel_ccvs(JObj) -> channel_ccvs(kz_json:to_proplist(JObj)). --spec channel_cavs(channel() | kz_proplist() | kz_json:object()) -> kz_proplist(). +-spec channel_cavs(channel() | kz_term:proplist() | kz_json:object()) -> kz_term:proplist(). channel_cavs(#channel{cavs='undefined'}) -> []; channel_cavs(#channel{cavs=CAVs}) -> CAVs; channel_cavs([_|_]=Props) -> props:get_value(<<"custom_application_vars">>, Props, []); @@ -385,7 +385,7 @@ init([Node, Options]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -399,7 +399,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('bind_to_events', #state{node=Node}=State) -> %% If the freeswitch version is updated so Kazoo can %% support for nightmare transfer bind for channel queries @@ -429,7 +429,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'event', [UUID | Props]}, #state{node=Node, options=Options}=State) -> kz_util:spawn(fun handle_fs_event/4, [UUID, Props, Node, Options]), {'noreply', State}; @@ -455,7 +455,7 @@ handle_info(_Info, State) -> lager:debug("unhandled message: ~p", [_Info]), {'noreply', State}. --spec handle_fs_event(api_binary(), kzd_freeswitch:data(), atom(), kz_proplist()) -> 'ok'. +-spec handle_fs_event(kz_term:api_binary(), kzd_freeswitch:data(), atom(), kz_term:proplist()) -> 'ok'. handle_fs_event(UUID, Props, Node, Options) -> NewProps = case props:get_is_true(<<"Publish-Channel-State">>, Props) of 'undefined' -> @@ -511,7 +511,7 @@ code_change(_OldVsn, State, _Extra) -> %%% Internal functions %%%=================================================================== --spec handle_channel_req_legacy(ne_binary(), ne_binary(), atom(), pid()) -> 'ok'. +-spec handle_channel_req_legacy(kz_term:ne_binary(), kz_term:ne_binary(), atom(), pid()) -> 'ok'. handle_channel_req_legacy(UUID, FetchId, Node, Pid) -> kz_amqp_channel:consumer_pid(Pid), case fetch_channel(UUID) of @@ -523,7 +523,7 @@ handle_channel_req_legacy(UUID, FetchId, Node, Pid) -> ]) end. --spec handle_channel_req(ne_binary(), ne_binary(), kz_proplist(), atom(), pid()) -> 'ok'. +-spec handle_channel_req(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist(), atom(), pid()) -> 'ok'. handle_channel_req(UUID, FetchId, Props, Node, Pid) -> kz_amqp_channel:consumer_pid(Pid), ForUUID = props:get_value(<<"refer-for-channel-id">>, Props), @@ -540,7 +540,7 @@ handle_channel_req(UUID, FetchId, Props, Node, Pid) -> build_channel_resp(FetchId, Props, Node, URL, ForChannel, channel_ccvs(Channel)) end. --spec build_channel_resp(ne_binary(), kz_proplist(), atom(), ne_binary(), kz_proplist(), kz_proplist()) -> 'ok'. +-spec build_channel_resp(kz_term:ne_binary(), kz_term:proplist(), atom(), kz_term:ne_binary(), kz_term:proplist(), kz_term:proplist()) -> 'ok'. build_channel_resp(FetchId, Props, Node, URL, Channel, ChannelVars) -> %% NOTE %% valid properties to return are @@ -554,7 +554,7 @@ build_channel_resp(FetchId, Props, Node, URL, Channel, ChannelVars) -> ]), try_channel_resp(FetchId, Node, Resp). --spec channel_resp_dialprefix(kz_proplist(), kz_proplist(), kz_proplist()) -> ne_binary(). +-spec channel_resp_dialprefix(kz_term:proplist(), kz_term:proplist(), kz_term:proplist()) -> kz_term:ne_binary(). channel_resp_dialprefix(ReqProps, Channel, ChannelVars) -> Props = props:filter_undefined( [{<<"sip_invite_domain">>, props:get_value(<<"Realm">>, ChannelVars)} @@ -568,12 +568,12 @@ channel_resp_dialprefix(ReqProps, Channel, ChannelVars) -> ]), fs_props_to_binary(Props). --spec fs_props_to_binary(kz_proplist()) -> ne_binary(). +-spec fs_props_to_binary(kz_term:proplist()) -> kz_term:ne_binary(). fs_props_to_binary([{Hk,Hv}|T]) -> Rest = << <<",", K/binary, "='", (kz_term:to_binary(V))/binary, "'">> || {K,V} <- T >>, <<"[", Hk/binary, "='", (kz_term:to_binary(Hv))/binary, "'", Rest/binary, "]">>. --spec try_channel_resp(ne_binary(), atom(), kz_proplist()) -> 'ok'. +-spec try_channel_resp(kz_term:ne_binary(), atom(), kz_term:proplist()) -> 'ok'. try_channel_resp(FetchId, Node, Props) -> try ecallmgr_fs_xml:sip_channel_xml(Props) of {'ok', ConfigXml} -> @@ -585,14 +585,14 @@ try_channel_resp(FetchId, Node, Props) -> channel_not_found(Node, FetchId) end. --spec fetch_channel(ne_binary()) -> kz_proplist() | 'undefined'. +-spec fetch_channel(kz_term:ne_binary()) -> kz_term:proplist() | 'undefined'. fetch_channel(UUID) -> case fetch(UUID, 'proplist') of {'error', 'not_found'} -> fetch_remote(UUID); {'ok', Channel} -> Channel end. --spec fetch_remote(ne_binary()) -> api_object(). +-spec fetch_remote(kz_term:ne_binary()) -> kz_term:api_object(). fetch_remote(UUID) -> Command = [{<<"Call-ID">>, UUID} ,{<<"Active-Only">>, <<"true">>} @@ -610,16 +610,16 @@ fetch_remote(UUID) -> Props ++ CCVs end. --spec channel_not_found(atom(), ne_binary()) -> 'ok'. +-spec channel_not_found(atom(), kz_term:ne_binary()) -> 'ok'. channel_not_found(Node, FetchId) -> {'ok', Resp} = ecallmgr_fs_xml:not_found(), freeswitch:fetch_reply(Node, FetchId, 'channels', iolist_to_binary(Resp)). --spec process_event(api_binary(), kz_proplist(), atom()) -> any(). +-spec process_event(kz_term:api_binary(), kz_term:proplist(), atom()) -> any(). process_event(UUID, Props, Node) -> process_event(UUID, Props, Node, self()). --spec process_event(api_binary(), kz_proplist(), atom(), pid()) -> any(). +-spec process_event(kz_term:api_binary(), kz_term:proplist(), atom(), pid()) -> any(). process_event(UUID, Props, Node, Pid) -> kz_util:put_callid(UUID), kz_amqp_channel:consumer_pid(Pid), @@ -627,7 +627,7 @@ process_event(UUID, Props, Node, Pid) -> process_specific_event(EventName, UUID, Props, Node). --spec process_specific_event(ne_binary(), api_binary(), kz_proplist(), atom()) -> +-spec process_specific_event(kz_term:ne_binary(), kz_term:api_binary(), kz_term:proplist(), atom()) -> any(). process_specific_event(<<"CHANNEL_CREATE">>, UUID, Props, Node) -> _ = maybe_publish_channel_state(Props, Node), @@ -670,7 +670,7 @@ process_specific_event(<<"CHANNEL_UNBRIDGE">>, UUID, Props, _) -> process_specific_event(_EventName, _UUID, _Props, _Node) -> 'ok'. --spec maybe_publish_channel_state(kz_proplist(), atom()) -> 'ok'. +-spec maybe_publish_channel_state(kz_term:proplist(), atom()) -> 'ok'. maybe_publish_channel_state(Props, Node) -> %% NOTE: this will significantly reduce AMQP request however if a ecallmgr %% becomes disconnected any calls it previsouly controlled will not produce @@ -686,7 +686,7 @@ maybe_publish_channel_state(Props, Node) -> end end. --spec maybe_publish_restricted(kz_proplist()) -> 'ok'. +-spec maybe_publish_restricted(kz_term:proplist()) -> 'ok'. maybe_publish_restricted(Props) -> EcallmgrNode = kz_term:to_binary(node()), Event = ecallmgr_call_events:get_event_name(Props), @@ -698,7 +698,7 @@ maybe_publish_restricted(Props) -> lager:debug("channel state ~s for call controlled by another ecallmgr(~s), not publishing", [Event, _EventEcallmgr]) end. --spec props_to_record(kz_proplist(), atom()) -> channel(). +-spec props_to_record(kz_term:proplist(), atom()) -> channel(). props_to_record(Props, Node) -> UUID = props:get_value(<<"Unique-ID">>, Props), CCVs = ecallmgr_util:custom_channel_vars(Props), @@ -745,14 +745,14 @@ props_to_record(Props, Node) -> ,cavs=CAVs }. --spec other_leg_handling_locally(ne_binary()) -> boolean(). +-spec other_leg_handling_locally(kz_term:ne_binary()) -> boolean(). other_leg_handling_locally(OtherLeg) -> case fetch(OtherLeg, 'record') of {'ok', #channel{handling_locally=HandleLocally}} -> HandleLocally; _ -> 'false' end. --spec handling_locally(kz_proplist(), api_binary()) -> boolean(). +-spec handling_locally(kz_term:proplist(), kz_term:api_binary()) -> boolean(). handling_locally(Props, 'undefined') -> props:get_value(?GET_CCV(<<"Ecallmgr-Node">>), Props) =:= kz_term:to_binary(node()); @@ -763,7 +763,7 @@ handling_locally(Props, OtherLeg) -> _ -> other_leg_handling_locally(OtherLeg) end. --spec get_username(kz_proplist()) -> api_binary(). +-spec get_username(kz_term:proplist()) -> kz_term:api_binary(). get_username(Props) -> case props:get_first_defined([?GET_CCV(<<"Username">>) ,<<"variable_user_name">> @@ -775,7 +775,7 @@ get_username(Props) -> Username -> kz_term:to_lower_binary(Username) end. --spec get_realm(kz_proplist()) -> api_binary(). +-spec get_realm(kz_term:proplist()) -> kz_term:api_binary(). get_realm(Props) -> case props:get_first_defined([?GET_CCV(<<"Realm">>) ,<<"variable_domain_name">> @@ -787,7 +787,7 @@ get_realm(Props) -> Realm -> kz_term:to_lower_binary(Realm) end. --spec props_to_update(kz_proplist()) -> channel_updates(). +-spec props_to_update(kz_term:proplist()) -> channel_updates(). props_to_update(Props) -> UUID = props:get_value(<<"Unique-ID">>, Props), CCVs = ecallmgr_util:custom_channel_vars(Props), @@ -842,16 +842,16 @@ update_callee(UUID, Props) -> _ -> [] end. --spec maybe_update_callee_field(api_binary(), api_binary()) -> api_binary(). +-spec maybe_update_callee_field(kz_term:api_binary(), kz_term:api_binary()) -> kz_term:api_binary(). maybe_update_callee_field(Value, 'undefined') -> Value; maybe_update_callee_field(_Value, Existing) -> Existing. --spec get_other_leg(api_binary(), kz_proplist()) -> api_binary(). +-spec get_other_leg(kz_term:api_binary(), kz_term:proplist()) -> kz_term:api_binary(). get_other_leg('undefined', _Props) -> 'undefined'; get_other_leg(UUID, Props) -> get_other_leg_name(UUID, Props, props:get_value(<<"Other-Leg-Channel-Name">>, Props)). --spec get_other_leg_name(ne_binary(), kz_proplist(), ne_binary()) -> api_binary(). +-spec get_other_leg_name(kz_term:ne_binary(), kz_term:proplist(), kz_term:ne_binary()) -> kz_term:api_binary(). get_other_leg_name(UUID, Props, _ChannelName) -> get_other_leg(UUID ,Props @@ -863,7 +863,7 @@ get_other_leg_name(UUID, Props, _ChannelName) -> ) ). --spec get_other_leg(ne_binary(), kz_proplist(), api_binary()) -> api_binary(). +-spec get_other_leg(kz_term:ne_binary(), kz_term:proplist(), kz_term:api_binary()) -> kz_term:api_binary(). get_other_leg(UUID, Props, 'undefined') -> maybe_other_bridge_leg(UUID ,Props @@ -872,8 +872,8 @@ get_other_leg(UUID, Props, 'undefined') -> ); get_other_leg(_UUID, _Props, OtherLeg) -> OtherLeg. --spec maybe_other_bridge_leg(ne_binary(), kz_proplist(), ne_binary(), ne_binary()) -> - api_binary(). +-spec maybe_other_bridge_leg(kz_term:ne_binary(), kz_term:proplist(), kz_term:ne_binary(), kz_term:ne_binary()) -> + kz_term:api_binary(). maybe_other_bridge_leg(UUID, _Props, UUID, OtherLeg) -> OtherLeg; maybe_other_bridge_leg(UUID, _Props, OtherLeg, UUID) -> OtherLeg; maybe_other_bridge_leg(UUID, Props, _, _) -> @@ -882,7 +882,7 @@ maybe_other_bridge_leg(UUID, Props, _, _) -> BridgeId -> BridgeId end. --spec maybe_update_interaction_id(kz_proplist(), atom()) -> 'ok'. +-spec maybe_update_interaction_id(kz_term:proplist(), atom()) -> 'ok'. maybe_update_interaction_id(Props, Node) -> case props:get_value(?GET_CUSTOM_HEADER(<<"Core-UUID">>), Props) of 'undefined' -> 'ok'; @@ -891,7 +891,7 @@ maybe_update_interaction_id(Props, Node) -> maybe_update_interaction_id(Props, Node, {CoreUUID, RemoteUUID}) end. --spec maybe_update_interaction_id(kz_proplist(), atom(), tuple()) -> 'ok'. +-spec maybe_update_interaction_id(kz_term:proplist(), atom(), tuple()) -> 'ok'. maybe_update_interaction_id(_Props, _Node, {CoreUUID, CoreUUID}) -> 'ok'; maybe_update_interaction_id(Props, Node, _) -> case props:get_value(?GET_CCV_HEADER(<<"replaces-call-id">>), Props) of @@ -908,6 +908,6 @@ maybe_update_interaction_id(Props, Node, _) -> end end. --spec new(kz_proplist(), atom()) -> 'ok'. +-spec new(kz_term:proplist(), atom()) -> 'ok'. new(Props, Node) -> ecallmgr_fs_channels:new(props_to_record(Props, Node)). diff --git a/applications/ecallmgr/src/ecallmgr_fs_channel_hold.erl b/applications/ecallmgr/src/ecallmgr_fs_channel_hold.erl index 1053a9043bc..73293c68579 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_channel_hold.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_channel_hold.erl @@ -26,7 +26,7 @@ -define(SERVER, ?MODULE). -record(state, {node = 'undefined' :: atom() - ,options = [] :: kz_proplist() + ,options = [] :: kz_term:proplist() }). -type state() :: #state{}. @@ -37,8 +37,8 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(atom()) -> startlink_ret(). --spec start_link(atom(), kz_proplist()) -> startlink_ret(). +-spec start_link(atom()) -> kz_types:startlink_ret(). +-spec start_link(atom(), kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Node) -> start_link(Node, []). start_link(Node, Options) -> gen_server:start_link(?SERVER, [Node, Options], []). @@ -58,7 +58,7 @@ start_link(Node, Options) -> %% {stop, Reason} %% @end %%-------------------------------------------------------------------- --spec init([atom() | kz_proplist()]) -> {'ok', state()}. +-spec init([atom() | kz_term:proplist()]) -> {'ok', state()}. init([Node, Options]) -> kz_util:put_callid(Node), gen_server:cast(self(), 'bind_to_record'), @@ -78,7 +78,7 @@ init([Node, Options]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -92,7 +92,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('bind_to_record', #state{node=Node}=State) -> gproc:reg({'p', 'l', ?FS_EVENT_REG_MSG(Node, <<"CHANNEL_HOLD">>)}), gproc:reg({'p', 'l', ?FS_EVENT_REG_MSG(Node, <<"CHANNEL_UNHOLD">>)}), @@ -111,7 +111,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'event', [UUID | Props]}, #state{node=Node}=State) -> _ = kz_util:spawn(fun process_event/3, [UUID, Props, Node]), {'noreply', State}; @@ -150,13 +150,13 @@ code_change(_OldVsn, State, _Extra) -> %%% Internal functions %%%=================================================================== --spec process_event(api_binary(), kz_proplist(), atom()) -> any(). +-spec process_event(kz_term:api_binary(), kz_term:proplist(), atom()) -> any(). process_event(UUID, Props, Node) -> kz_util:put_callid(UUID), EventName = props:get_value(<<"Event-Subclass">>, Props, props:get_value(<<"Event-Name">>, Props)), process_specific_event(EventName, UUID, Props, Node). --spec process_specific_event(ne_binary(), api_binary(), kz_proplist(), atom()) -> any(). +-spec process_specific_event(kz_term:ne_binary(), kz_term:api_binary(), kz_term:proplist(), atom()) -> any(). process_specific_event(<<"CHANNEL_HOLD">>, UUID, Props, _Node) -> ecallmgr_fs_channels:update(UUID, #channel.is_onhold, 'true'), ecallmgr_call_events:process_channel_event([UUID | Props]); diff --git a/applications/ecallmgr/src/ecallmgr_fs_channels.erl b/applications/ecallmgr/src/ecallmgr_fs_channels.erl index 6b87e7de241..f599b99298d 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_channels.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_channels.erl @@ -89,7 +89,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link({'local', ?SERVER}, ?MODULE, [{'responders', ?RESPONDERS} ,{'bindings', ?BINDINGS} @@ -98,7 +98,7 @@ start_link() -> ,{'consume_options', ?CONSUME_OPTIONS} ], []). --spec sync(atom(), ne_binaries()) -> 'ok'. +-spec sync(atom(), kz_term:ne_binaries()) -> 'ok'. sync(Node, Channels) -> gen_server:cast(?SERVER, {'sync_channels', Node, Channels}). @@ -110,7 +110,7 @@ summary() -> }], print_summary(ets:select(?CHANNELS_TBL, MatchSpec, 1)). --spec summary(text()) -> 'ok'. +-spec summary(kz_term:text()) -> 'ok'. summary(Node) when not is_atom(Node) -> summary(kz_term:to_atom(Node, 'true')); summary(Node) -> @@ -128,7 +128,7 @@ details() -> }], print_details(ets:select(?CHANNELS_TBL, MatchSpec, 1)). --spec details(text()) -> 'ok'. +-spec details(kz_term:text()) -> 'ok'. details(UUID) when not is_binary(UUID) -> details(kz_term:to_binary(UUID)); details(UUID) -> @@ -144,7 +144,7 @@ show_all() -> [ecallmgr_fs_channel:to_json(Channel) | Acc] end, [], ?CHANNELS_TBL). --spec per_minute_accounts() -> ne_binaries(). +-spec per_minute_accounts() -> kz_term:ne_binaries(). per_minute_accounts() -> MatchSpec = [{#channel{account_id = '$1' ,account_billing = <<"per_minute">> @@ -165,7 +165,7 @@ per_minute_accounts() -> ], lists:usort(lists:flatten(ets:select(?CHANNELS_TBL, MatchSpec))). --spec per_minute_channels(ne_binary()) -> [{atom(), ne_binary()}]. +-spec per_minute_channels(kz_term:ne_binary()) -> [{atom(), kz_term:ne_binary()}]. per_minute_channels(AccountId) -> MatchSpec = [{#channel{node = '$1' ,uuid = '$2' @@ -196,23 +196,23 @@ flush_node(Node) -> new(#channel{}=Channel) -> gen_server:call(?SERVER, {'new_channel', Channel}). --spec destroy(ne_binary(), atom()) -> 'ok'. +-spec destroy(kz_term:ne_binary(), atom()) -> 'ok'. destroy(UUID, Node) -> gen_server:cast(?SERVER, {'destroy_channel', UUID, Node}). --spec update(ne_binary(), pos_integer(), any()) -> 'ok'. +-spec update(kz_term:ne_binary(), pos_integer(), any()) -> 'ok'. update(UUID, Key, Value) -> updates(UUID, [{Key, Value}]). --spec updates(ne_binary(), channel_updates()) -> 'ok'. +-spec updates(kz_term:ne_binary(), channel_updates()) -> 'ok'. updates(UUID, Updates) -> gen_server:call(?SERVER, {'channel_updates', UUID, Updates}). -spec count() -> non_neg_integer(). count() -> ets:info(?CHANNELS_TBL, 'size'). --spec match_presence(ne_binary()) -> kz_proplist_kv(ne_binary(), atom()). +-spec match_presence(kz_term:ne_binary()) -> kz_term:proplist_kv(kz_term:ne_binary(), atom()). match_presence(PresenceId) -> MatchSpec = [{#channel{uuid = '$1' ,presence_id = '$2' @@ -223,7 +223,7 @@ match_presence(PresenceId) -> ], ets:select(?CHANNELS_TBL, MatchSpec). --spec handle_query_auth_id(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_query_auth_id(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_query_auth_id(JObj, _Props) -> 'true' = kapi_call:query_auth_id_req_v(JObj), AuthId = kz_json:get_value(<<"Auth-ID">>, JObj), @@ -238,7 +238,7 @@ handle_query_auth_id(JObj, _Props) -> ServerId = kz_json:get_value(<<"Server-ID">>, JObj), kapi_call:publish_query_auth_id_resp(ServerId, Resp). --spec handle_query_user_channels(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_query_user_channels(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_query_user_channels(JObj, _Props) -> 'true' = kapi_call:query_user_channels_req_v(JObj), UserChannels0 = case kz_json:get_value(<<"Realm">>, JObj) of @@ -256,7 +256,7 @@ handle_query_user_channels(JObj, _Props) -> UserChannels2 = lists:keymerge(1, UserChannels0, UserChannels1), handle_query_users_channels(JObj, UserChannels2). --spec handle_query_users_channels(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_query_users_channels(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_query_users_channels(JObj, Cs) -> Channels = [Channel || {_, Channel} <- Cs], send_user_query_resp(JObj, Channels). @@ -284,7 +284,7 @@ send_user_query_resp(JObj, Cs) -> lager:debug("sending back channel data to ~s", [ServerId]), kapi_call:publish_query_user_channels_resp(ServerId, Resp). --spec handle_query_account_channels(kz_json:object(), ne_binary()) -> 'ok'. +-spec handle_query_account_channels(kz_json:object(), kz_term:ne_binary()) -> 'ok'. handle_query_account_channels(JObj, _) -> AccountId = kz_json:get_value(<<"Account-ID">>, JObj), case find_account_channels(AccountId) of @@ -302,7 +302,7 @@ send_account_query_resp(JObj, Cs) -> lager:debug("sending back channel data to ~s", [ServerId]), kapi_call:publish_query_account_channels_resp(ServerId, Resp). --spec handle_query_channels(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_query_channels(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_query_channels(JObj, _Props) -> 'true' = kapi_call:query_channels_req_v(JObj), Fields = kz_json:get_value(<<"Fields">>, JObj, []), @@ -321,7 +321,7 @@ handle_query_channels(JObj, _Props) -> kapi_call:publish_query_channels_resp(kz_json:get_value(<<"Server-ID">>, JObj), Resp) end. --spec handle_channel_status(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_channel_status(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_channel_status(JObj, _Props) -> 'true' = kapi_call:channel_status_req_v(JObj), _ = kz_util:put_callid(JObj), @@ -353,14 +353,14 @@ handle_channel_status(JObj, _Props) -> kapi_call:publish_channel_status_resp(kz_json:get_value(<<"Server-ID">>, JObj), Resp) end. --spec maybe_send_empty_channel_resp(ne_binary(), kz_json:object()) -> 'ok'. +-spec maybe_send_empty_channel_resp(kz_term:ne_binary(), kz_json:object()) -> 'ok'. maybe_send_empty_channel_resp(CallId, JObj) -> case kz_json:is_true(<<"Active-Only">>, JObj) of 'true' -> 'ok'; 'false' -> send_empty_channel_resp(CallId, JObj) end. --spec send_empty_channel_resp(ne_binary(), kz_json:object()) -> 'ok'. +-spec send_empty_channel_resp(kz_term:ne_binary(), kz_json:object()) -> 'ok'. send_empty_channel_resp(CallId, JObj) -> Resp = [{<<"Call-ID">>, CallId} ,{<<"Status">>, <<"terminated">>} @@ -414,7 +414,7 @@ start_cleanup_ref() -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call({'new_channel', Channel}, _, State) -> ets:insert(?CHANNELS_TBL, Channel), {'reply', 'ok', State}; @@ -518,7 +518,7 @@ handle_cast(_Req, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'timeout', Ref, _Msg}, #state{max_channel_cleanup_ref=Ref}=State) -> maybe_cleanup_old_channels(), {'noreply', State#state{max_channel_cleanup_ref=start_cleanup_ref()}}; @@ -569,7 +569,7 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec find_by_auth_id(ne_binary()) -> +-spec find_by_auth_id(kz_term:ne_binary()) -> {'ok', kz_json:objects()} | {'error', 'not_found'}. find_by_auth_id(AuthorizingId) -> @@ -584,7 +584,7 @@ find_by_auth_id(AuthorizingId) -> ]} end. --spec has_channels_for_owner(ne_binary()) -> boolean(). +-spec has_channels_for_owner(kz_term:ne_binary()) -> boolean(). has_channels_for_owner(OwnerId) -> MatchSpec = [{#channel{owner_id = '$1' ,_ = '_' @@ -597,8 +597,8 @@ has_channels_for_owner(OwnerId) -> lager:info("Found ~p channels", [Count]), Count > 0. --spec find_by_authorizing_id(ne_binaries()) -> [] | kz_proplist(). --spec find_by_authorizing_id(ne_binaries(), kz_proplist()) -> [] | kz_proplist(). +-spec find_by_authorizing_id(kz_term:ne_binaries()) -> [] | kz_term:proplist(). +-spec find_by_authorizing_id(kz_term:ne_binaries(), kz_term:proplist()) -> [] | kz_term:proplist(). find_by_authorizing_id(AuthIds) -> find_by_authorizing_id(AuthIds, []). @@ -615,7 +615,7 @@ find_by_authorizing_id([AuthId|AuthIds], Acc) -> find_by_authorizing_id(AuthIds, lists:keymerge(1, Acc, Cs)) end. --spec find_by_user_realm(api_binary() | ne_binaries(), ne_binary()) -> [] | kz_proplist(). +-spec find_by_user_realm(kz_term:api_binary() | kz_term:ne_binaries(), kz_term:ne_binary()) -> [] | kz_term:proplist(). find_by_user_realm('undefined', Realm) -> Pattern = #channel{realm=kz_term:to_lower_binary(Realm) ,_='_'}, @@ -665,7 +665,7 @@ find_by_user_realm(Username, Realm) -> ] end. --spec find_account_channels(ne_binary()) -> +-spec find_account_channels(kz_term:ne_binary()) -> {'ok', kz_json:objects()} | {'error', 'not_found'}. find_account_channels(<<"all">>) -> @@ -685,18 +685,18 @@ find_account_channels(AccountId) -> ]} end. --spec build_matchspec_ors(ne_binaries()) -> tuple() | 'false'. +-spec build_matchspec_ors(kz_term:ne_binaries()) -> tuple() | 'false'. build_matchspec_ors(Usernames) -> lists:foldl(fun build_matchspec_ors_fold/2 ,'false' ,Usernames ). --spec build_matchspec_ors_fold(ne_binary(), tuple() | 'false') -> tuple(). +-spec build_matchspec_ors_fold(kz_term:ne_binary(), tuple() | 'false') -> tuple(). build_matchspec_ors_fold(Username, Acc) -> {'or', {'=:=', '$1', kz_term:to_lower_binary(Username)}, Acc}. --spec query_channels(ne_binaries(), api_binary()) -> kz_json:object(). +-spec query_channels(kz_term:ne_binaries(), kz_term:api_binary()) -> kz_json:object(). query_channels(Fields, 'undefined') -> query_channels(ets:match_object(?CHANNELS_TBL, #channel{_='_'}, 1) ,Fields @@ -708,7 +708,7 @@ query_channels(Fields, CallId) -> ,kz_json:new() ). --spec query_channels({[channel()], ets:continuation()} | '$end_of_table', ne_binary() | ne_binaries(), kz_json:object()) -> +-spec query_channels({[channel()], ets:continuation()} | '$end_of_table', kz_term:ne_binary() | kz_term:ne_binaries(), kz_json:object()) -> kz_json:object(). query_channels('$end_of_table', _, Channels) -> Channels; query_channels({[#channel{uuid=CallId}=Channel], Continuation} @@ -793,7 +793,7 @@ handle_channels_disconnected(LocalChannels) -> handle_channel_disconnected(Channel) -> publish_channel_connection_event(Channel, [{<<"Event-Name">>, <<"CHANNEL_DISCONNECTED">>}]). --spec publish_channel_connection_event(channel(), kz_proplist()) -> 'ok'. +-spec publish_channel_connection_event(channel(), kz_term:proplist()) -> 'ok'. publish_channel_connection_event(#channel{uuid=UUID ,direction=Direction ,node=Node @@ -819,7 +819,7 @@ publish_channel_connection_event(#channel{uuid=UUID kz_amqp_worker:cast(Event, fun kapi_call:publish_event/1), lager:debug("published channel connection event for ~s", [UUID]). --spec channel_call_state(boolean()) -> api_binary(). +-spec channel_call_state(boolean()) -> kz_term:api_binary(). channel_call_state('true') -> <<"ANSWERED">>; channel_call_state('false') -> @@ -844,7 +844,7 @@ connection_ccvs(#channel{account_id=AccountId ,{<<"Owner-ID">>, OwnerId} ]). --spec connection_cavs(channel()) -> api_object(). +-spec connection_cavs(channel()) -> kz_term:api_object(). connection_cavs(#channel{cavs=CAVs}) when is_list(CAVs) -> kz_json:from_list(CAVs); connection_cavs(#channel{}) -> 'undefined'. @@ -900,7 +900,7 @@ cleanup_old_channels(MaxAge) -> N end. --type old_channel() :: [ne_binary() | atom() | gregorian_seconds()]. +-type old_channel() :: [kz_term:ne_binary() | atom() | kz_time:gregorian_seconds()]. -type old_channels() :: [old_channel(),...]. -spec hangup_old_channels(old_channels()) -> 'ok'. diff --git a/applications/ecallmgr/src/ecallmgr_fs_command.erl b/applications/ecallmgr/src/ecallmgr_fs_command.erl index ad5a30eb9c8..4648d8a26ff 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_command.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_command.erl @@ -26,7 +26,7 @@ %% set channel and call variables in FreeSWITCH %% @end %%-------------------------------------------------------------------- --spec set(atom(), api_ne_binary(), kz_proplist()) -> ecallmgr_util:send_cmd_ret(). +-spec set(atom(), kz_term:api_ne_binary(), kz_term:proplist()) -> ecallmgr_util:send_cmd_ret(). set(_, _, []) -> 'ok'; set(_Node, 'undefined', _Props) -> lager:warning("no UUID for setting on node ~s: ~p", [_Node, _Props]); @@ -44,7 +44,7 @@ set(Node, UUID, Props) -> %% set channel and call variables in FreeSWITCH (in background) %% @end %%-------------------------------------------------------------------- --spec bg_set(atom(), api_ne_binary(), kz_proplist()) -> ecallmgr_util:send_cmd_ret(). +-spec bg_set(atom(), kz_term:api_ne_binary(), kz_term:proplist()) -> ecallmgr_util:send_cmd_ret(). bg_set(_, _, []) -> 'ok'; bg_set(_Node, 'undefined', _Props) -> lager:warning("no UUID for setting on node ~s: ~p", [_Node, _Props]); @@ -62,7 +62,7 @@ bg_set(Node, UUID, Props) -> %% unset channel and call variables in FreeSWITCH %% @end %%-------------------------------------------------------------------- --spec unset(atom(), api_ne_binary(), kz_proplist()) -> ecallmgr_util:send_cmd_ret(). +-spec unset(atom(), kz_term:api_ne_binary(), kz_term:proplist()) -> ecallmgr_util:send_cmd_ret(). unset(_, _, []) -> 'ok'; unset(_Node, 'undefined', _Props) -> lager:warning("no UUID for unsetting on node ~s: ~p", [_Node, _Props]); @@ -76,7 +76,7 @@ unset(Node, UUID, Props) -> %% unset channel and call variables in FreeSWITCH (in background) %% @end %%-------------------------------------------------------------------- --spec bg_unset(atom(), api_ne_binary(), kz_proplist()) -> ecallmgr_util:send_cmd_ret(). +-spec bg_unset(atom(), kz_term:api_ne_binary(), kz_term:proplist()) -> ecallmgr_util:send_cmd_ret(). bg_unset(_, _, []) -> 'ok'; bg_unset(_Node, 'undefined', _Props) -> lager:warning("no UUID for unsetting on node ~s: ~p", [_Node, _Props]); @@ -90,7 +90,7 @@ bg_unset(Node, UUID, Props) -> %% export channel and call variables in FreeSWITCH %% @end %%-------------------------------------------------------------------- --spec export(atom(), api_ne_binary(), kz_proplist()) -> ecallmgr_util:send_cmd_ret(). +-spec export(atom(), kz_term:api_ne_binary(), kz_term:proplist()) -> ecallmgr_util:send_cmd_ret(). export(_, _, []) -> 'ok'; export(_Node, 'undefined', _Props) -> lager:warning("no UUID for exporting on node ~s: ~p", [_Node, _Props]); @@ -109,7 +109,7 @@ export(Node, UUID, Props) -> %% %% @end %%-------------------------------------------------------------------- --spec bridge_export(atom(), ne_binary(), kz_proplist()) -> ecallmgr_util:send_cmd_ret(). +-spec bridge_export(atom(), kz_term:ne_binary(), kz_term:proplist()) -> ecallmgr_util:send_cmd_ret(). bridge_export(_, _, []) -> 'ok'; bridge_export(_Node, 'undefined', _Props) -> lager:warning("no UUID for bridge_export on node ~s: ~p", [_Node, _Props]); @@ -128,7 +128,7 @@ bridge_export(Node, UUID, Props) -> %% %% @end %%-------------------------------------------------------------------- --spec record_call(atom(), ne_binary(), kz_proplist()) -> ecallmgr_util:send_cmd_ret(). +-spec record_call(atom(), kz_term:ne_binary(), kz_term:proplist()) -> ecallmgr_util:send_cmd_ret(). record_call(Node, UUID, Args) -> lager:debug("execute on node ~p: uuid_record(~p)", [Node, Args]), case freeswitch:api(Node, 'uuid_record', Args) of @@ -154,7 +154,7 @@ record_call(Node, UUID, Args) -> Error end. --spec maybe_export_vars(atom(), ne_binary(), kz_proplist()) -> kz_proplist(). +-spec maybe_export_vars(atom(), kz_term:ne_binary(), kz_term:proplist()) -> kz_term:proplist(). maybe_export_vars(Node, UUID, Props) -> lists:foldl(fun({<<"Hold-Media">> = K, V}, Acc) -> _ = export(Node, UUID, [{K, V}]), @@ -169,7 +169,7 @@ maybe_export_vars(Node, UUID, Props) -> api(Node, Cmd, Args) -> freeswitch:api(Node, Cmd, Args). --spec api(atom(), ne_binary(), atom(), list()) -> ecallmgr_util:send_cmd_ret(). +-spec api(atom(), kz_term:ne_binary(), atom(), list()) -> ecallmgr_util:send_cmd_ret(). api(_, _, _, []) -> 'ok'; api(Node, UUID, Cmd, Args) when is_list(Args)-> @@ -179,7 +179,7 @@ api(Node, UUID, Cmd, Args) bgapi(Node, Cmd, Args) -> freeswitch:bgapi(Node, Cmd, Args). --spec bgapi(atom(), ne_binary(), atom(), list()) -> ecallmgr_util:send_cmd_ret(). +-spec bgapi(atom(), kz_term:ne_binary(), atom(), list()) -> ecallmgr_util:send_cmd_ret(). bgapi(_, _, _, []) -> 'ok'; bgapi(Node, UUID, Cmd, Args) when is_list(Args)-> diff --git a/applications/ecallmgr/src/ecallmgr_fs_conference.erl b/applications/ecallmgr/src/ecallmgr_fs_conference.erl index 5d945ccd385..5b275623945 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_conference.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_conference.erl @@ -44,8 +44,8 @@ ]). -record(state, {node = 'undefined' :: atom() - ,options = [] :: kz_proplist() - ,events = [] :: ne_binaries() + ,options = [] :: kz_term:proplist() + ,events = [] :: kz_term:ne_binaries() }). -type state() :: #state{}. @@ -56,8 +56,8 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(atom()) -> startlink_ret(). --spec start_link(atom(), kz_proplist()) -> startlink_ret(). +-spec start_link(atom()) -> kz_types:startlink_ret(). +-spec start_link(atom(), kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Node) -> start_link(Node, []). start_link(Node, Options) -> gen_server:start_link(?SERVER, [Node, Options], []). @@ -72,7 +72,7 @@ start_link(Node, Options) -> %% Initializes the server %% @end %%-------------------------------------------------------------------- --spec init([node() | kz_proplist()]) -> {'ok', state()}. +-spec init([node() | kz_term:proplist()]) -> {'ok', state()}. init([Node, Options]) -> process_flag('trap_exit', 'true'), kz_util:put_callid(?DEFAULT_LOG_SYSTEM_ID), @@ -100,7 +100,7 @@ init([Node, Options]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', 'ok', State}. @@ -114,7 +114,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('bind_to_events', #state{node=Node}=State) -> case gproc:reg({'p', 'l', ?FS_EVENT_REG_MSG(Node, <<"conference::maintenance">>)}) =:= 'true' andalso gproc:reg({'p', 'l', ?FS_OPTION_MSG(Node)}) =:= 'true' @@ -135,7 +135,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'event', Props}, #state{node=Node ,events=Events ,options=Options @@ -182,7 +182,7 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec init_props(kzd_freeswitch:data(), kz_proplist()) -> kzd_freeswitch:data(). +-spec init_props(kzd_freeswitch:data(), kz_term:proplist()) -> kzd_freeswitch:data(). init_props(Props, Options) -> case props:get_is_true(<<"Publish-Channel-State">>, Props) of 'undefined' -> @@ -193,14 +193,14 @@ init_props(Props, Options) -> _Value -> Props end. --spec handle_conference_event(atom(), ne_binaries(), kzd_freeswitch:data(), kz_proplist()) -> 'ok'. +-spec handle_conference_event(atom(), kz_term:ne_binaries(), kzd_freeswitch:data(), kz_term:proplist()) -> 'ok'. handle_conference_event(Node, Events, [_UUID | FSProps], Options) -> Props = init_props(FSProps, Options), Action = props:get_value(<<"Action">>, Props), process_event(Action, Props, Node), maybe_publish_event(Action, Props, Node, Events). --spec process_event(ne_binary(), kzd_freeswitch:data(), atom()) -> any(). +-spec process_event(kz_term:ne_binary(), kzd_freeswitch:data(), atom()) -> any(). process_event(<<"conference-create">>, Props, Node) -> _ = ecallmgr_fs_conferences:create(Props, Node), ConferenceId = props:get_value(<<"Conference-Name">>, Props), @@ -269,7 +269,7 @@ publish_event(Action, #conference{handling_locally=IsLocal} = Conference, Props, 'false' -> lager:debug("conference control on another node, not publishing event ~s", [Action]) end. --spec publish_event(kz_proplist()) -> 'ok'. +-spec publish_event(kz_term:proplist()) -> 'ok'. publish_event(Event) -> kz_amqp_worker:cast(Event, fun kapi_conference:publish_event/1). diff --git a/applications/ecallmgr/src/ecallmgr_fs_conferences.erl b/applications/ecallmgr/src/ecallmgr_fs_conferences.erl index 2d58a530605..c5dd9019a95 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_conferences.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_conferences.erl @@ -78,7 +78,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link({'local', ?SERVER}, ?MODULE, [{'responders', ?RESPONDERS} @@ -96,7 +96,7 @@ summary() -> -spec count() -> non_neg_integer(). count() -> ets:info(?CONFERENCES_TBL, 'size'). --spec summary(text()) -> 'ok'. +-spec summary(kz_term:text()) -> 'ok'. summary(Node) when not is_atom(Node) -> summary(kz_term:to_atom(Node, 'true')); summary(Node) -> @@ -108,26 +108,26 @@ details() -> MatchSpec = [{#conference{_ = '_'}, [], ['$_']}], print_details(ets:select(?CONFERENCES_TBL, MatchSpec, 1)). --spec details(text()) -> 'ok'. +-spec details(kz_term:text()) -> 'ok'. details(UUID) when not is_binary(UUID) -> details(kz_term:to_binary(UUID)); details(UUID) -> MatchSpec = [{#conference{uuid=UUID, _ = '_'}, [], ['$_']}], print_details(ets:select(?CONFERENCES_TBL, MatchSpec, 1)). --spec create(kz_proplist(), atom()) -> conference(). +-spec create(kz_term:proplist(), atom()) -> conference(). create(Props, Node) -> gen_server:call(?SERVER, {'conference_create', Props, Node}). --spec update(ne_binary(), kz_proplist() | {integer(), any()}) -> 'ok'. +-spec update(kz_term:ne_binary(), kz_term:proplist() | {integer(), any()}) -> 'ok'. update(UUID, Update) -> gen_server:call(?SERVER, {'conference_update', UUID, Update}). --spec destroy(ne_binary()) -> 'ok'. +-spec destroy(kz_term:ne_binary()) -> 'ok'. destroy(UUID) -> gen_server:call(?SERVER, {'conference_destroy', UUID}). --spec node(ne_binary()) -> +-spec node(kz_term:ne_binary()) -> {'ok', atom()} | {'error', 'not_found'}. node(Name) -> @@ -141,7 +141,7 @@ node(Name) -> _ -> {'error', 'not_found'} end. --spec conference(ne_binary()) -> {'ok', conference()} | {'error', 'not_found'}. +-spec conference(kz_term:ne_binary()) -> {'ok', conference()} | {'error', 'not_found'}. conference(UUID) -> case ets:match_object(?CONFERENCES_TBL, #conference{uuid=UUID, _ = '_'}) of %% TODO: this ignores conferences on multiple nodes until big-conferences @@ -153,7 +153,7 @@ conference(UUID) -> _ -> {'error', 'not_found'} end. --spec participants(conference() | ne_binary()) -> participants(). +-spec participants(conference() | kz_term:ne_binary()) -> participants(). participants(#conference{name=Name}) -> participants(Name); participants(Name) -> %% Note: used the conference name supports participants on multiple nodes @@ -167,11 +167,11 @@ participants_to_json(Participants) -> participant_create(Props, Node) -> gen_server:call(?SERVER, {'participant_create', Props, Node}). --spec participant_update(ne_binary(), kz_proplist()) -> 'ok'. +-spec participant_update(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. participant_update(CallId, Update) -> gen_server:call(?SERVER, {'participant_update', CallId, Update}). --spec participant_get(ne_binary()) -> participant(). +-spec participant_get(kz_term:ne_binary()) -> participant(). participant_get(CallId) -> case ets:lookup(?PARTICIPANTS_TBL, CallId) of [Participant=#participant{}] -> @@ -180,7 +180,7 @@ participant_get(CallId) -> lager:error("No participant data by call-id ~p", [CallId]) end. --spec participant_destroy(ne_binary()) -> 'ok'. +-spec participant_destroy(kz_term:ne_binary()) -> 'ok'. participant_destroy(CallId) -> gen_server:call(?SERVER, {'participant_destroy', CallId}). @@ -190,14 +190,14 @@ sync_node(Node) -> gen_server:cast(?SERVER, {'sync_node', Node}). -spec flush_node(atom()) -> 'ok'. flush_node(Node) -> gen_server:cast(?SERVER, {'flush_node', Node}). --spec handle_search_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_search_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_search_req(JObj, Props) -> case kz_json:get_ne_binary_value(<<"Conference-ID">>, JObj) of 'undefined' -> handle_search_account(JObj, Props); ConferenceId -> handle_search_conference(JObj, Props, ConferenceId) end. --spec handle_search_conference(kz_json:object(), kz_proplist(), ne_binary()) -> 'ok'. +-spec handle_search_conference(kz_json:object(), kz_term:proplist(), kz_term:ne_binary()) -> 'ok'. handle_search_conference(JObj, _Props, Name) -> lager:info("received search request for conference name ~s", [Name]), case ets:match_object(?CONFERENCES_TBL, #conference{name=Name, _ = '_'}) of @@ -238,7 +238,7 @@ handle_search_conference(JObj, _Props, Name) -> kapi_conference:publish_error(kz_api:server_id(JObj), Error) end. --spec handle_search_account(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_search_account(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_search_account(JObj, _Props) -> AccountId = kz_json:get_value(<<"Account-ID">>, JObj), lager:info("received search request for account ~s", [AccountId]), @@ -262,7 +262,7 @@ handle_search_account(JObj, _Props) -> kapi_conference:publish_search_resp(kz_api:server_id(JObj), Resp) end. --spec conference_resp(conference()) -> {ne_binary(), kz_json:object()}. +-spec conference_resp(conference()) -> {kz_term:ne_binary(), kz_json:object()}. conference_resp(#conference{uuid=UUID ,name=Name ,start_time=StartTime @@ -323,7 +323,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call({'conference_create', Props, Node}, _, State) -> lager:debug("created conference ~p", [Props]), Conference = conference_from_props(Props, Node), @@ -379,7 +379,7 @@ handle_call(_Req, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'sync_node', Node}, State) -> Sync = list_conferences(Node), Conferences = get_conference_dictionary(Sync), @@ -419,7 +419,7 @@ handle_cast(_Req, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Msg, State) -> lager:debug("unhandled msg: ~p", [_Msg]), {'noreply', State}. @@ -432,7 +432,7 @@ handle_info(_Msg, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. @@ -471,7 +471,7 @@ code_change(_OldVsn, State, _Extra) -> {'ok', State}. conference_from_props(Props, Node) -> conference_from_props(Props, Node, #conference{}). --spec conference_from_props(kz_proplist(), atom(), conference()) -> conference(). +-spec conference_from_props(kz_term:proplist(), atom(), conference()) -> conference(). conference_from_props(Props, Node, Conference) -> CtrlNode = kz_term:to_atom(props:get_value(?GET_CCV(<<"Ecallmgr-Node">>), Props), 'true'), Conference#conference{node = Node @@ -512,7 +512,7 @@ participants_to_json([Participant|Participants], JObjs) -> participant_to_json(#participant{}=Participant) -> kz_json:from_list(participant_to_props(Participant)). --spec participant_to_props(participant()) -> kz_proplist(). +-spec participant_to_props(participant()) -> kz_term:proplist(). participant_to_props(#participant{uuid=UUID ,conference_name=ConfName ,conference_uuid=ConfUUID @@ -538,7 +538,7 @@ participant_to_props(#participant{uuid=UUID ,{<<"Switch-Hostname">>, Node} ]). --spec conference_to_props(conference()) -> kz_proplist(). +-spec conference_to_props(conference()) -> kz_term:proplist(). conference_to_props(#conference{name=Name ,uuid=UUID ,node=Node @@ -593,7 +593,7 @@ list_conferences(Node) -> {'error', _} -> [] end. --spec xml_list_to_records(xml_els(), atom()) -> conferences() | participants(). +-spec xml_list_to_records(kz_types:xml_els(), atom()) -> conferences() | participants(). xml_list_to_records(Xml, Node) -> xml_list_to_records(Xml, Node, []). xml_list_to_records(#xmlElement{name='conferences' @@ -619,7 +619,7 @@ xml_list_to_records(#xmlElement{name='conference' [Conference | Participants ++ Recs]; xml_list_to_records(_, _, Recs) -> Recs. --spec xml_to_conference(xml_el(), atom()) -> conference(). +-spec xml_to_conference(kz_types:xml_el(), atom()) -> conference(). xml_to_conference(#xmlElement{name='conference' ,attributes=Attrs }, Node) -> @@ -630,7 +630,7 @@ xml_to_conference(#xmlElement{name='conference' ,switch_external_ip=ecallmgr_fs_nodes:sip_external_ip(Node) }). --spec xml_attrs_to_conference(xml_attribs(), conference()) -> +-spec xml_attrs_to_conference(kz_types:xml_attribs(), conference()) -> conference(). xml_attrs_to_conference([], Conference) -> Conference; xml_attrs_to_conference([#xmlAttribute{name=Name, value=Value} @@ -639,7 +639,7 @@ xml_attrs_to_conference([#xmlAttribute{name=Name, value=Value} C = xml_attr_to_conference(Conference, Name, Value), xml_attrs_to_conference(Attrs, C). --spec xml_attr_to_conference(conference(), xml_attrib_name(), xml_attrib_value()) -> +-spec xml_attr_to_conference(conference(), kz_types:xml_attrib_name(), kz_types:xml_attrib_value()) -> conference(). xml_attr_to_conference(Conference, 'name', Value) -> Conference#conference{name=kz_term:to_binary(Value)}; @@ -667,7 +667,7 @@ xml_attr_to_conference(Conference, _Name, _Value) -> lager:debug("unhandled conference k/v ~s: ~p", [_Name, _Value]), Conference. --spec xml_members_to_participants(xml_els(), conference()) -> participants(). +-spec xml_members_to_participants(kz_types:xml_els(), conference()) -> participants(). xml_members_to_participants([], _) -> []; xml_members_to_participants([#xmlElement{name='members' ,content=XmlElements @@ -683,7 +683,7 @@ xml_members_to_participants([#xmlElement{name='members' xml_members_to_participants([_|XmlElements], Conference) -> xml_members_to_participants(XmlElements, Conference). --spec xml_member_to_participant(xml_els(), participant()) -> participant(). +-spec xml_member_to_participant(kz_types:xml_els(), participant()) -> participant(). xml_member_to_participant([], Participant) -> Participant; xml_member_to_participant([#xmlElement{name='uuid' ,content=UUID @@ -699,11 +699,11 @@ xml_member_to_participant([#xmlElement{name='uuid' xml_member_to_participant([_|XmlElements], Participant) -> xml_member_to_participant(XmlElements, Participant). --spec xml_text_to_binary(xml_els()) -> ne_binary(). +-spec xml_text_to_binary(kz_types:xml_els()) -> kz_term:ne_binary(). xml_text_to_binary(XmlElements) -> iolist_to_binary([V || #xmlText{value=V} <- XmlElements]). --spec maybe_destroy_conference(ne_binary()) -> boolean(). +-spec maybe_destroy_conference(kz_term:ne_binary()) -> boolean(). maybe_destroy_conference(UUID) -> case ets:match(?PARTICIPANTS_TBL, #participant{conference_uuid=UUID, _ = '_'}) of [] -> @@ -838,7 +838,7 @@ print_participant_details([#participant{uuid=UUID print_participant_flags(Props), print_participant_details(Participants). --spec print_participant_flags(kz_proplist()) -> 'ok'. +-spec print_participant_flags(kz_term:proplist()) -> 'ok'. print_participant_flags([]) -> 'ok'; print_participant_flags([{Flag, 'true'}|Props]) -> %% Cheating, all this typing today... diff --git a/applications/ecallmgr/src/ecallmgr_fs_conferences_shared.erl b/applications/ecallmgr/src/ecallmgr_fs_conferences_shared.erl index f9e42d56c5d..28f6a89cd25 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_conferences_shared.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_conferences_shared.erl @@ -41,7 +41,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link({'local', ?MODULE}, ?MODULE, [{'responders', ?RESPONDERS} @@ -81,7 +81,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Req, _From, State) -> lager:debug("unhandled call from ~p: ~p", [_From, _Req]), {'noreply', State}. @@ -96,7 +96,7 @@ handle_call(_Req, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Req, State) -> lager:debug("unhandled cast: ~p", [_Req]), {'noreply', State}. @@ -111,7 +111,7 @@ handle_cast(_Req, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Msg, State) -> lager:debug("unhandled msg: ~p", [_Msg]), {'noreply', State}. @@ -154,7 +154,7 @@ terminate(_Reason, _State) -> -spec code_change(any(), state(), any()) -> {'ok', state()}. code_change(_OldVsn, State, _Extra) -> {'ok', State}. --spec handle_dial_req(kapi_conference:doc(), kz_proplist()) -> 'ok'. +-spec handle_dial_req(kapi_conference:doc(), kz_term:proplist()) -> 'ok'. handle_dial_req(JObj, _Props) -> 'true' = kapi_conference:dial_v(JObj), ConferenceId = kz_json:get_ne_binary_value(<<"Conference-ID">>, JObj), @@ -166,7 +166,7 @@ handle_dial_req(JObj, _Props) -> end, lager:debug("finished dialing"). --spec maybe_exec_dial(atom(), ne_binary(), kapi_conference:doc()) -> 'ok'. +-spec maybe_exec_dial(atom(), kz_term:ne_binary(), kapi_conference:doc()) -> 'ok'. maybe_exec_dial(ConferenceNode, ConferenceId, JObj) -> {Loopbacks, Endpoints} = lists:splitwith(fun is_loopback/1, kz_json:get_list_value(<<"Endpoints">>, JObj, [])), @@ -176,7 +176,7 @@ maybe_exec_dial(ConferenceNode, ConferenceId, JObj) -> is_loopback(Endpoint) -> <<"loopback">> =:= kz_json:get_ne_binary_value(<<"Invite-Format">>, Endpoint). --spec maybe_exec_dial(atom(), ne_binary(), kapi_conference:doc(), kz_json:objects(), kz_json:objects()) -> 'ok'. +-spec maybe_exec_dial(atom(), kz_term:ne_binary(), kapi_conference:doc(), kz_json:objects(), kz_json:objects()) -> 'ok'. maybe_exec_dial(ConferenceNode, ConferenceId, JObj, Endpoints, Loopbacks) -> lager:info("conference ~s is running on ~s, dialing out", [ConferenceId, ConferenceNode]), _ = (catch gproc:reg({'p', 'l', ?FS_EVENT_REG_MSG(ConferenceNode, <<"conference::maintenance">>)})), @@ -186,9 +186,9 @@ maybe_exec_dial(ConferenceNode, ConferenceId, JObj, Endpoints, Loopbacks) -> handle_responses(ConferenceNode, JObj, EPResps ++ LBResps). --type exec_response() :: {ne_binary(), {'ok' | 'error', kz_proplist()}}. +-type exec_response() :: {kz_term:ne_binary(), {'ok' | 'error', kz_term:proplist()}}. -type exec_responses() :: [exec_response()]. --spec exec_endpoints(atom(), ne_binary(), kapi_conference:doc(), kz_json:objects()) -> +-spec exec_endpoints(atom(), kz_term:ne_binary(), kapi_conference:doc(), kz_json:objects()) -> exec_responses(). exec_endpoints(_ConferenceNode, _ConferenceId, _JObj, []) -> lager:debug("no endpoints to dial out to"), @@ -201,7 +201,7 @@ exec_endpoints(ConferenceNode, ConferenceId, JObj, Endpoints) -> ), Resps. --type exec_acc() :: {atom(), ne_binary(), kapi_conference:doc(), exec_responses()}. +-type exec_acc() :: {atom(), kz_term:ne_binary(), kapi_conference:doc(), exec_responses()}. update_endpoint(Endpoint, EndpointCallId) -> Updates = [{fun kz_json:insert_value/3, <<"Outbound-Call-ID">>, EndpointCallId} @@ -242,7 +242,7 @@ exec_endpoint(Endpoint, {ConferenceNode, ConferenceId, JObj, Resps}) -> {ConferenceNode, ConferenceId, JObj, [{EndpointCallId, error_resp(EndpointId, Msg)} | Resps]} end. --spec exec_loopbacks(atom(), ne_binary(), kapi_conference:doc(), kz_json:objects()) -> +-spec exec_loopbacks(atom(), kz_term:ne_binary(), kapi_conference:doc(), kz_json:objects()) -> exec_responses(). exec_loopbacks(_ConferenceNode, _ConferenceId, _JObj, []) -> lager:debug("no loopbacks to dial out to"), @@ -271,7 +271,7 @@ exec_loopback(Loopback, {ConferenceNode, ConferenceId, JObj, Resps}) -> ), exec_endpoint(Endpoint, {ConferenceNode, ConferenceId, kz_json:delete_key(<<"Outbound-Call-ID">>, JObj), Resps}). --spec success_resp(ne_binary()) -> {'ok', kz_proplist()}. +-spec success_resp(kz_term:ne_binary()) -> {'ok', kz_term:proplist()}. success_resp(EndpointId) -> {'ok' ,[{<<"Message">>, <<"dialing endpoints">>} @@ -280,7 +280,7 @@ success_resp(EndpointId) -> ] }. --spec error_resp(ne_binary(), ne_binary()) -> {'error', kz_proplist()}. +-spec error_resp(kz_term:ne_binary(), kz_term:ne_binary()) -> {'error', kz_term:proplist()}. error_resp(EndpointId, Error) -> {'error' ,[{<<"Status">>, <<"error">>} @@ -297,15 +297,15 @@ handle_responses(ConferenceNode, JObj, Responses) -> publish_resp(JObj, BaseResponses). --spec handle_response(atom(), kapi_conference:doc(), exec_response()) -> kz_proplist(). +-spec handle_response(atom(), kapi_conference:doc(), exec_response()) -> kz_term:proplist(). handle_response(_ConferenceNode, _JObj, {_CallId, {'error', Resp}}) -> Resp; handle_response(ConferenceNode, JObj, {LoopbackCallId, {'ok', Resp}}) -> BuiltResp = handle_call_startup(ConferenceNode, JObj, LoopbackCallId, Resp), props:insert_value(<<"Call-ID">>, LoopbackCallId, BuiltResp). --spec handle_call_startup(atom(), kapi_conference:doc(), ne_binary(), kz_proplist()) -> - kz_proplist(). +-spec handle_call_startup(atom(), kapi_conference:doc(), kz_term:ne_binary(), kz_term:proplist()) -> + kz_term:proplist(). handle_call_startup(ConferenceNode, JObj, LoopbackCallId, Resp) -> case wait_for_bowout(LoopbackCallId ,'undefined' @@ -332,14 +332,14 @@ handle_call_startup(ConferenceNode, JObj, LoopbackCallId, Resp) -> ) end. --spec wait_for_bowout(ne_binary(), api_ne_binary(), pos_integer()) -> - {'ok', ne_binary(), ne_binary(), kz_proplist()} | +-spec wait_for_bowout(kz_term:ne_binary(), kz_term:api_ne_binary(), pos_integer()) -> + {'ok', kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()} | {'error', 'timeout'} | - {'error', ne_binary(), ne_binary()}. --spec wait_for_bowout(ne_binary(), api_ne_binary(), pos_integer(), kz_proplist()) -> - {'ok', ne_binary(), ne_binary(), kz_proplist()} | + {'error', kz_term:ne_binary(), kz_term:ne_binary()}. +-spec wait_for_bowout(kz_term:ne_binary(), kz_term:api_ne_binary(), pos_integer(), kz_term:proplist()) -> + {'ok', kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()} | {'error', 'timeout'} | - {'error', ne_binary(), ne_binary()}. + {'error', kz_term:ne_binary(), kz_term:ne_binary()}. wait_for_bowout(LoopbackALeg, LoopbackBLeg, Timeout) -> wait_for_bowout(LoopbackALeg, LoopbackBLeg, Timeout, []). wait_for_bowout(LoopbackALeg, LoopbackBLeg, Timeout, ChannelProps) -> @@ -414,7 +414,7 @@ handle_bowout(LoopbackALeg, LoopbackBLeg, Timeout, ChannelProps, Start, Props) - wait_for_bowout(LoopbackALeg, LoopbackBLeg, kz_time:decr_timeout(Timeout, Start), ChannelProps) end. --spec register_for_events(atom(), ne_binary()) -> 'ok'. +-spec register_for_events(atom(), kz_term:ne_binary()) -> 'ok'. register_for_events(ConferenceNode, EndpointCallId) -> _ = [(catch gproc:reg({'p', 'l', ?FS_CALL_EVENT_REG_MSG(ConferenceNode, EndpointCallId)})) ,(catch gproc:reg({'p', 'l', ?FS_CALL_EVENTS_PROCESS_REG(ConferenceNode, EndpointCallId)})) @@ -422,7 +422,7 @@ register_for_events(ConferenceNode, EndpointCallId) -> ], 'ok'. --spec start_call_handlers(atom(), kapi_conference:doc(), ne_binary()) -> api_ne_binary(). +-spec start_call_handlers(atom(), kapi_conference:doc(), kz_term:ne_binary()) -> kz_term:api_ne_binary(). start_call_handlers(Node, JObj, CallId) -> FetchId = kz_api:msg_id(JObj), CCVs = kz_json:new(), @@ -432,7 +432,7 @@ start_call_handlers(Node, JObj, CallId) -> get_control_queue(CtlPid). --spec get_control_queue(pid()) -> api_ne_binary(). +-spec get_control_queue(pid()) -> kz_term:api_ne_binary(). get_control_queue(CtlPid) -> try erlang:is_process_alive(CtlPid) andalso ecallmgr_call_control:queue_name(CtlPid) @@ -459,7 +459,7 @@ get_control_queue(CtlPid) -> get_control_queue(CtlPid) end. --spec add_participant(kapi_conference:doc(), ne_binary(), api_ne_binary(), kz_proplist()) -> 'ok'. +-spec add_participant(kapi_conference:doc(), kz_term:ne_binary(), kz_term:api_ne_binary(), kz_term:proplist()) -> 'ok'. add_participant(_JObj, _CallId, 'undefined', _ChannelProps) -> lager:info("not adding participant, no control queue"); add_participant(JObj, CallId, ControlQueue, ChannelProps) -> @@ -492,7 +492,7 @@ publish_resp(JObj, BaseResps) -> ,fun(P) -> kapi_conference:publish_dial_resp(kz_api:server_id(JObj), P) end ). --spec maybe_start_conference(kapi_conference:doc(), ne_binary()) -> 'ok'. +-spec maybe_start_conference(kapi_conference:doc(), kz_term:ne_binary()) -> 'ok'. maybe_start_conference(JObj, ConferenceId) -> lager:info("conference ~s is not running yet", [ConferenceId]), case find_media_server(kz_json:get_ne_binary_value(<<"Target-Call-ID">>, JObj), kz_api:node(JObj)) of @@ -502,7 +502,7 @@ maybe_start_conference(JObj, ConferenceId) -> maybe_exec_dial(MediaServer, ConferenceId, JObj) end. --spec find_media_server(api_ne_binary(), ne_binary()) -> atom(). +-spec find_media_server(kz_term:api_ne_binary(), kz_term:ne_binary()) -> atom(). find_media_server('undefined', IssuerNode) -> IssuerNodeInfo = kz_nodes:node_to_json(IssuerNode), MyZone = kz_config:zone('binary'), @@ -527,7 +527,7 @@ find_media_server(TargetCallId, IssuerNode) -> end end. --spec find_media_server_from_statuses(ne_binary(), ne_binary(), kz_json:objects()) -> atom(). +-spec find_media_server_from_statuses(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:objects()) -> atom(). find_media_server_from_statuses(TargetCallId, IssuerNode, []) -> lager:info("no one has record of ~s", [TargetCallId]), find_media_server('undefined', IssuerNode); @@ -551,8 +551,8 @@ find_media_server_from_statuses(TargetCallId, IssuerNode, [Status|Statuses]) -> end end. --spec query_cluster_for_call(ne_binary()) -> {'ok', kz_json:objects()} | - {'error', any()}. +-spec query_cluster_for_call(kz_term:ne_binary()) -> {'ok', kz_json:objects()} | + {'error', any()}. query_cluster_for_call(CallId) -> Req = [{<<"Call-ID">>, CallId} ,{<<"Fields">>, <<"all">>} diff --git a/applications/ecallmgr/src/ecallmgr_fs_config.erl b/applications/ecallmgr/src/ecallmgr_fs_config.erl index d7c48ed366c..a1592d90c0a 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_config.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_config.erl @@ -26,7 +26,7 @@ -include("ecallmgr.hrl"). -record(state, {node :: atom() - ,options = [] :: kz_proplist() + ,options = [] :: kz_term:proplist() }). -type state() :: #state{}. @@ -37,8 +37,8 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(atom()) -> startlink_ret(). --spec start_link(atom(), kz_proplist()) -> startlink_ret(). +-spec start_link(atom()) -> kz_types:startlink_ret(). +-spec start_link(atom(), kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Node) -> start_link(Node, []). start_link(Node, Options) -> gen_server:start_link(?SERVER, [Node, Options], []). @@ -53,7 +53,7 @@ start_link(Node, Options) -> %% Initializes the server %% @end %%-------------------------------------------------------------------- --spec init([atom() | kz_proplist()]) -> {'ok', state()}. +-spec init([atom() | kz_term:proplist()]) -> {'ok', state()}. init([Node, Options]) -> process_flag('trap_exit', 'true'), kz_util:put_callid(Node), @@ -75,7 +75,7 @@ init([Node, Options]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -89,7 +89,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('bind_to_configuration', #state{node=Node}=State) -> case freeswitch:bind(Node, 'configuration') of 'ok' -> {'noreply', State}; @@ -110,7 +110,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'fetch', 'configuration', <<"configuration">>, <<"name">>, Conf, ID, []}, #state{node=Node}=State) -> lager:debug("fetch configuration request from ~s: ~s", [Node, ID]), _ = kz_util:spawn(fun handle_config_req/4, [Node, ID, Conf, 'undefined']), @@ -172,7 +172,7 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec handle_config_req(atom(), ne_binary(), ne_binary(), kz_proplist() | 'undefined') -> fs_sendmsg_ret(). +-spec handle_config_req(atom(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist() | 'undefined') -> fs_sendmsg_ret(). handle_config_req(Node, Id, <<"acl.conf">>, _Props) -> kz_util:put_callid(Id), @@ -229,13 +229,13 @@ handle_config_req(Node, Id, Conf, Data) -> _ -> 'ok' end. --spec config_req_not_handled(atom(), ne_binary(), ne_binary()) -> fs_sendmsg_ret(). +-spec config_req_not_handled(atom(), kz_term:ne_binary(), kz_term:ne_binary()) -> fs_sendmsg_ret(). config_req_not_handled(Node, Id, Conf) -> {'ok', NotHandled} = ecallmgr_fs_xml:not_found(), lager:debug("ignoring conf ~s: ~s", [Conf, Id]), freeswitch:fetch_reply(Node, Id, 'configuration', iolist_to_binary(NotHandled)). --spec generate_acl_xml(api_object()) -> api_binary(). +-spec generate_acl_xml(kz_term:api_object()) -> kz_term:api_binary(). generate_acl_xml('undefined') -> 'undefined'; generate_acl_xml(SysconfResp) -> @@ -260,13 +260,13 @@ default_sip_profiles(Node) -> ,JObj ). --spec default_sip_profile() -> kz_proplist(). +-spec default_sip_profile() -> kz_term:proplist(). default_sip_profile() -> [{<<"Settings">>, kz_json:from_list(default_sip_settings())} ,{<<"Gateways">>, kz_json:from_list(default_sip_gateways())} ]. --spec default_sip_settings() -> kz_proplist(). +-spec default_sip_settings() -> kz_term:proplist(). default_sip_settings() -> [{<<"message-threads">>, <<"10">>} ,{<<"auth-calls">>, <<"true">>} @@ -435,7 +435,7 @@ maybe_convert_sound(<<"dnuos-", _/binary>>, Key, Value, Profile) -> maybe_convert_sound(_, _, _, Profile) -> Profile. --spec fetch_conference_config(atom(), ne_binary(), ne_binary(), kz_proplist()) -> fs_sendmsg_ret(). +-spec fetch_conference_config(atom(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> fs_sendmsg_ret(). fetch_conference_config(Node, Id, <<"COMMAND">>, Data) -> maybe_fetch_conference_profile(Node, Id, props:get_value(<<"profile_name">>, Data)); fetch_conference_config(Node, Id, <<"REQUEST_PARAMS">>, Data) -> @@ -472,7 +472,7 @@ handle_conference_params_response(_Error) -> lager:debug("failed to lookup conference params, error:~p", [_Error]), ecallmgr_fs_xml:not_found(). --spec maybe_fetch_conference_profile(atom(), ne_binary(), api_binary()) -> fs_sendmsg_ret(). +-spec maybe_fetch_conference_profile(atom(), kz_term:ne_binary(), kz_term:api_binary()) -> fs_sendmsg_ret(). maybe_fetch_conference_profile(Node, Id, 'undefined') -> lager:debug("failed to lookup undefined conference profile"), {'ok', XmlResp} = ecallmgr_fs_xml:not_found(), @@ -506,13 +506,13 @@ maybe_fetch_conference_profile(Node, Id, Profile) -> end, send_conference_profile_xml(Node, Id, XmlResp). --spec send_conference_profile_xml(atom(), ne_binary(), iolist()) -> fs_sendmsg_ret(). +-spec send_conference_profile_xml(atom(), kz_term:ne_binary(), iolist()) -> fs_sendmsg_ret(). send_conference_profile_xml(Node, Id, XmlResp) -> lager:debug("sending conference profile XML to ~s: ~s", [Node, XmlResp]), freeswitch:fetch_reply(Node, Id, 'configuration', iolist_to_binary(XmlResp)). --spec fetch_mod_kazoo_config(atom(), ne_binary(), ne_binary(), kz_proplist()) -> fs_sendmsg_ret(). +-spec fetch_mod_kazoo_config(atom(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> fs_sendmsg_ret(). fetch_mod_kazoo_config(Node, Id, <<"COMMAND">>, _Data) -> config_req_not_handled(Node, Id, <<"kazoo.conf">>); fetch_mod_kazoo_config(Node, Id, <<"REQUEST_PARAMS">>, Data) -> @@ -522,7 +522,7 @@ fetch_mod_kazoo_config(Node, Id, Event, _Data) -> lager:debug("unhandled mod kazoo config event : ~p : ~p", [Node, Event]), config_req_not_handled(Node, Id, <<"kazoo.conf">>). --spec fetch_mod_kazoo_config_action(atom(), ne_binary(), api_ne_binary(), kz_proplist()) -> fs_sendmsg_ret(). +-spec fetch_mod_kazoo_config_action(atom(), kz_term:ne_binary(), kz_term:api_ne_binary(), kz_term:proplist()) -> fs_sendmsg_ret(). fetch_mod_kazoo_config_action(Node, Id, <<"request-filter">>, _Data) -> {'ok', Xml} = ecallmgr_fs_xml:event_filters_resp_xml(?FS_EVENT_FILTERS), lager:debug("replying with xml response for request-filter params request"), diff --git a/applications/ecallmgr/src/ecallmgr_fs_event_stream.erl b/applications/ecallmgr/src/ecallmgr_fs_event_stream.erl index c3a3f1c8080..0ef2893d1eb 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_event_stream.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_event_stream.erl @@ -21,7 +21,7 @@ -define(SERVER, ?MODULE). --type bindings() :: atom() | [atom(),...] | ne_binary() | ne_binaries(). +-type bindings() :: atom() | [atom(),...] | kz_term:ne_binary() | kz_term:ne_binaries(). -record(state, {node :: atom() ,bindings :: bindings() @@ -29,9 +29,9 @@ ,ip :: inet:ip_address() | 'undefined' ,port :: inet:port_number() | 'undefined' ,socket :: inet:socket() | 'undefined' - ,idle_alert = 'infinity' :: kz_timeout() - ,switch_url :: api_ne_binary() - ,switch_uri :: api_ne_binary() + ,idle_alert = 'infinity' :: timeout() + ,switch_url :: kz_term:api_ne_binary() + ,switch_uri :: kz_term:api_ne_binary() ,switch_info = 'false' :: boolean() }). -type state() :: #state{}. @@ -43,7 +43,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(atom(), bindings(), bindings()) -> startlink_ret(). +-spec start_link(atom(), bindings(), bindings()) -> kz_types:startlink_ret(). start_link(Node, Bindings, Subclasses) -> gen_server:start_link(?SERVER, [Node, Bindings, Subclasses], []). @@ -86,7 +86,7 @@ init([Node, Bindings, Subclasses]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -100,7 +100,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('connect', #state{ip=IP, port=Port, idle_alert=Timeout}=State) -> PacketType = ecallmgr_config:get_integer(<<"tcp_packet_type">>, 2), case gen_tcp:connect(IP, Port, [{'mode', 'binary'} @@ -131,7 +131,7 @@ handle_cast(_Msg, #state{idle_alert=Timeout}=State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'tcp', Socket, Data}, #state{socket=Socket ,node=Node ,switch_info='false' @@ -199,7 +199,7 @@ handle_info(_Msg, #state{idle_alert=Timeout}=State) -> lager:debug("unhandled message: ~p", [_Msg]), {'noreply', State, Timeout}. --spec handle_fs_props(api_binary(), kzd_freeswitch:data(), atom(), ne_binary(), ne_binary()) -> pid(). +-spec handle_fs_props(kz_term:api_binary(), kzd_freeswitch:data(), atom(), kz_term:ne_binary(), kz_term:ne_binary()) -> pid(). handle_fs_props(UUID, Props, Node, SwitchURI, SwitchURL) -> kz_util:put_callid(UUID), EventName = props:get_value(<<"Event-Subclass">>, Props, props:get_value(<<"Event-Name">>, Props)), @@ -268,11 +268,11 @@ request_event_stream(#state{node=Node}=State) -> {'stop', ErrorReason} end. --spec get_event_bindings(state()) -> atoms(). +-spec get_event_bindings(state()) -> kz_term:atoms(). get_event_bindings(State) -> get_event_bindings(State, []). --spec get_event_bindings(state(), atoms()) -> atoms(). +-spec get_event_bindings(state(), kz_term:atoms()) -> kz_term:atoms(). get_event_bindings(#state{bindings='undefined' ,subclasses='undefined' ,idle_alert='infinity' @@ -307,12 +307,12 @@ get_event_bindings(#state{bindings=Binding}=State, Acc) when is_binary(Binding) ,[kz_term:to_atom(Binding, 'true') | Acc] ). --spec maybe_bind(atom(), atoms()) -> - {'ok', {text(), inet:port_number()}} | +-spec maybe_bind(atom(), kz_term:atoms()) -> + {'ok', {kz_term:text(), inet:port_number()}} | {'error', any()} | {'EXIT', any()}. --spec maybe_bind(atom(), atoms(), non_neg_integer()) -> - {'ok', {text(), inet:port_number()}} | +-spec maybe_bind(atom(), kz_term:atoms(), non_neg_integer()) -> + {'ok', {kz_term:text(), inet:port_number()}} | {'error', any()} | {'EXIT', any()}. maybe_bind(Node, Bindings) -> @@ -336,7 +336,7 @@ maybe_bind(Node, Bindings, Attempts) -> maybe_bind(Node, Bindings, Attempts+1) end. --spec idle_alert_timeout() -> kz_timeout(). +-spec idle_alert_timeout() -> timeout(). idle_alert_timeout() -> case ecallmgr_config:get_integer(<<"event_stream_idle_alert">>, 0) of Timeout when Timeout =< 30 -> 'infinity'; diff --git a/applications/ecallmgr/src/ecallmgr_fs_event_stream_sup.erl b/applications/ecallmgr/src/ecallmgr_fs_event_stream_sup.erl index 90802fcc6dd..e3b1762c382 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_event_stream_sup.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_event_stream_sup.erl @@ -30,7 +30,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link(atom(), kz_proplist()) -> startlink_ret(). +-spec start_link(atom(), kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Node, Options) -> supervisor:start_link({'local', sup_name(Node)}, ?MODULE, [Node, Options]). @@ -41,7 +41,7 @@ sup_name(Node) -> ]), kz_term:to_atom(Name, 'true'). --spec add_child(atom(), {'CUSTOM', atom()} | atom()) -> sup_startchild_ret(). +-spec add_child(atom(), {'CUSTOM', atom()} | atom()) -> kz_types:sup_startchild_ret(). add_child(Node, {'CUSTOM', Subclass}) -> supervisor:start_child(sup_name(Node), custom_child(Node, Subclass)); add_child(Node, Event) -> @@ -60,7 +60,7 @@ add_child(Node, Event) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(list()) -> sup_init_ret(). +-spec init(list()) -> kz_types:sup_init_ret(). init([Node, _Props]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, @@ -71,11 +71,11 @@ init([Node, _Props]) -> {'ok', {SupFlags, ?CHILDREN}}. --spec event_child(atom(), atom()) -> sup_child_spec(). +-spec event_child(atom(), atom()) -> kz_types:sup_child_spec(). event_child(Node, Event) -> ?WORKER_NAME_ARGS_TYPE(Event, 'ecallmgr_fs_event_stream', [Node, Event, 'undefined'], 'transient'). --spec custom_child(atom(), atom()) -> sup_child_spec(). +-spec custom_child(atom(), atom()) -> kz_types:sup_child_spec(). custom_child(Node, Subclass) -> ?WORKER_NAME_ARGS_TYPE(Subclass, 'ecallmgr_fs_event_stream', [Node, 'CUSTOM', Subclass], 'transient'). diff --git a/applications/ecallmgr/src/ecallmgr_fs_fax.erl b/applications/ecallmgr/src/ecallmgr_fs_fax.erl index e52f174b0af..bdc01d9acc6 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_fax.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_fax.erl @@ -13,7 +13,7 @@ -include_lib("kazoo_stdlib/include/kz_types.hrl"). --spec receive_fax(atom(), ne_binary(), kz_json:object()) -> kz_proplist(). +-spec receive_fax(atom(), kz_term:ne_binary(), kz_json:object()) -> kz_term:proplist(). receive_fax(Node, UUID, JObj) -> Sets = props:filter_undefined( lists:foldl(fun(Header, Acc) -> diff --git a/applications/ecallmgr/src/ecallmgr_fs_flite.erl b/applications/ecallmgr/src/ecallmgr_fs_flite.erl index 439df741428..47114a42cd6 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_flite.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_flite.erl @@ -20,8 +20,8 @@ %% TTS command helpers %% @end %%-------------------------------------------------------------------- --spec call_command(atom(), ne_binary(), kz_json:object()) -> - {ne_binary(), ne_binary()}. +-spec call_command(atom(), kz_term:ne_binary(), kz_json:object()) -> + {kz_term:ne_binary(), kz_term:ne_binary()}. call_command(Node, UUID, JObj) -> _ = ecallmgr_fs_command:set(Node, UUID ,[{<<"tts_engine">>, <<"flite">>} @@ -29,7 +29,7 @@ call_command(Node, UUID, JObj) -> ]), {<<"speak">>, kz_json:get_value(<<"Text">>, JObj)}. --spec voice(api_binary() | kz_json:object()) -> ne_binary(). +-spec voice(kz_term:api_binary() | kz_json:object()) -> kz_term:ne_binary(). voice('undefined') -> <<"slt">>; voice(<<"male">>) -> <<"rms">>; voice(<<"female">>) -> <<"slt">>; diff --git a/applications/ecallmgr/src/ecallmgr_fs_loopback.erl b/applications/ecallmgr/src/ecallmgr_fs_loopback.erl index e6ce3324a92..9c987307918 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_loopback.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_loopback.erl @@ -18,15 +18,15 @@ ). -define(LOOPBACK_FILTERED, "Filtered-By-Loopback"). --spec filter(atom(), ne_binary(), kzd_freeswitch:data()) -> kz_proplist(). +-spec filter(atom(), kz_term:ne_binary(), kzd_freeswitch:data()) -> kz_term:proplist(). filter(Node, UUID, Props) -> filter(?IS_LOOPBACK(Props), Node, UUID, Props, 'false'). --spec filter(atom(), ne_binary(), kzd_freeswitch:data(), boolean()) -> kz_proplist(). +-spec filter(atom(), kz_term:ne_binary(), kzd_freeswitch:data(), boolean()) -> kz_term:proplist(). filter(Node, UUID, Props, Update) -> filter(?IS_LOOPBACK(Props), Node, UUID, Props, Update). --spec filter(boolean(), atom(), ne_binary(), kzd_freeswitch:data(), boolean()) -> kz_proplist(). +-spec filter(boolean(), atom(), kz_term:ne_binary(), kzd_freeswitch:data(), boolean()) -> kz_term:proplist(). filter('false', _Node, _UUID, Props, _) -> Props; filter('true', Node, UUID, Props, Update) -> case lists:foldl(fun filter_loopback/2, [], Props) of @@ -41,25 +41,25 @@ filter('true', Node, UUID, Props, Update) -> maybe_update_ccvs(Update, Funs, updated_props(Filtered, UpdateCCVs)) end. --spec updated_props(kz_proplist(), kz_proplist()) -> kz_proplist(). +-spec updated_props(kz_term:proplist(), kz_term:proplist()) -> kz_term:proplist(). updated_props(Filtered, New0) -> New = [{ecallmgr_util:get_fs_key(K), V} || {K, V} <- New0], New ++ [{<<"variable_", K/binary>>, V} || {K, V} <- New] ++ Filtered. --spec maybe_update_ccvs(boolean(), fun(), kz_proplist()) -> kz_proplist(). +-spec maybe_update_ccvs(boolean(), fun(), kz_term:proplist()) -> kz_term:proplist(). maybe_update_ccvs('false', _Fun, Filtered) -> Filtered; maybe_update_ccvs('true', Fun, Filtered) -> kz_util:spawn(Fun), Filtered. --spec filter_loopback({ne_binary(), any()}, kz_proplist()) -> kz_proplist(). +-spec filter_loopback({kz_term:ne_binary(), any()}, kz_term:proplist()) -> kz_term:proplist(). filter_loopback({<>, V}, Acc) -> [{<>, V} | Acc]; filter_loopback({<<"variable_", ?CHANNEL_VAR_PREFIX, ?CHANNEL_LOOPBACK_HEADER_PREFIX, K/binary>>, V}, Acc) -> [{<>, V} | Acc]; filter_loopback(_, Acc) -> Acc. --spec filter_props({ne_binary(), any()}, {kz_proplist(), kz_proplist()}) -> {kz_proplist(), kz_proplist()}. +-spec filter_props({kz_term:ne_binary(), any()}, {kz_term:proplist(), kz_term:proplist()}) -> {kz_term:proplist(), kz_term:proplist()}. filter_props({?GET_CCV(Key), _V}, {Clear, Filtered}) -> {[?CCV(Key) | Clear], Filtered}; filter_props({?CCV(_)=Key, _V}, {Clear, Filtered}) -> diff --git a/applications/ecallmgr/src/ecallmgr_fs_msg.erl b/applications/ecallmgr/src/ecallmgr_fs_msg.erl index 012bc066e41..26070f5390e 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_msg.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_msg.erl @@ -24,7 +24,7 @@ -export([process_fs_event/2]). -record(state, {node :: atom() - ,options :: kz_proplist() + ,options :: kz_term:proplist() }). -type state() :: #state{}. @@ -55,8 +55,8 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(atom()) -> startlink_ret(). --spec start_link(atom(), kz_proplist()) -> startlink_ret(). +-spec start_link(atom()) -> kz_types:startlink_ret(). +-spec start_link(atom(), kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Node) -> start_link(Node, []). start_link(Node, Options) -> NodeBin = kz_term:to_binary(Node), @@ -80,7 +80,7 @@ start_link(Node, Options) -> %% Initializes the server %% @end %%-------------------------------------------------------------------- --spec init([atom() | kz_proplist()]) -> {'ok', state()}. +-spec init([atom() | kz_term:proplist()]) -> {'ok', state()}. init([Node, Options]) -> process_flag('trap_exit', 'true'), kz_util:put_callid(Node), @@ -103,7 +103,7 @@ init([Node, Options]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -117,7 +117,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('bind_to_msg_events', #state{node=Node}=State) -> gproc:reg({'p', 'l', ?FS_EVENT_REG_MSG(Node, <<"KZ::DELIVERY_REPORT">>)}), gproc:reg({'p', 'l', ?FS_EVENT_REG_MSG(Node, <<"SMS::DELIVERY_REPORT">>)}), @@ -136,7 +136,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'event', Props}, #state{node=Node}=State) -> _ = kz_util:spawn(fun process_fs_event/2, [Node, Props]), {'noreply', State, 'hibernate'}; @@ -191,7 +191,7 @@ code_change(_OldVsn, State, _Extra) -> %%% Internal functions %%%=================================================================== --spec handle_message_route(kz_json:object(), kz_proplist()) -> no_return(). +-spec handle_message_route(kz_json:object(), kz_term:proplist()) -> no_return(). handle_message_route(JObj, Props) -> _ = kz_util:put_callid(JObj), Node = props:get_value('node', Props), @@ -202,7 +202,7 @@ handle_message_route(JObj, Props) -> 'true' -> send_message(JObj, Props, Endpoints) end. --spec send_message(kz_json:object(), kz_proplist(), kz_json:objects()) -> no_return(). +-spec send_message(kz_json:object(), kz_term:proplist(), kz_json:objects()) -> no_return(). send_message(JObj, Props, [Endpoint]) -> Node = props:get_value('node', Props), case format_endpoint(Endpoint, Props, JObj) of @@ -214,7 +214,7 @@ send_message(JObj, Props, [Endpoint]) -> freeswitch:sendevent_custom(Node, 'SMS::SEND_MESSAGE', EvtProps) end. --spec build_message_headers(kz_json:object(), kz_json:object()) -> kz_proplist(). +-spec build_message_headers(kz_json:object(), kz_json:object()) -> kz_term:proplist(). build_message_headers(JObj, Endpoint) -> Body = kz_json:get_value(<<"Body">>, JObj), MessageId = kz_json:get_value(<<"Message-ID">>, JObj), @@ -255,11 +255,11 @@ build_message_headers(JObj, Endpoint) -> ]), kz_json:foldl(fun headers_foldl/3, Header, CCVs). --spec headers_foldl(kz_json:path(), kz_json:json_term(), kz_proplist()) -> kz_proplist(). +-spec headers_foldl(kz_json:path(), kz_json:json_term(), kz_term:proplist()) -> kz_term:proplist(). headers_foldl(K, V, Acc) -> [{kz_term:to_list(?GET_CCV(K)), kz_term:to_list(V)} | Acc]. --spec get_uri(api_binary()) -> api_binary(). +-spec get_uri(kz_term:api_binary()) -> kz_term:api_binary(). get_uri('undefined') -> 'undefined'; get_uri(<<">=Uri) -> Uri; get_uri(<<"sip", _/binary>>=Uri) -> Uri; @@ -283,12 +283,12 @@ send_error(Node, JObj, Err) -> ], kz_amqp_worker:cast(Payload, fun(A) -> kapi_sms:publish_targeted_delivery(ServerId, A) end). --spec format_endpoint(kz_json:object(), kz_proplist(), kz_json:object()) -> - {'ok', kz_proplist()} | - {'error', ne_binary()}. --spec format_endpoint(kz_json:object(), kz_proplist(), kz_json:object(), ne_binary()) -> - {'ok', kz_proplist()} | - {'error', ne_binary()}. +-spec format_endpoint(kz_json:object(), kz_term:proplist(), kz_json:object()) -> + {'ok', kz_term:proplist()} | + {'error', kz_term:ne_binary()}. +-spec format_endpoint(kz_json:object(), kz_term:proplist(), kz_json:object(), kz_term:ne_binary()) -> + {'ok', kz_term:proplist()} | + {'error', kz_term:ne_binary()}. format_endpoint(Endpoint, Props, JObj) -> format_endpoint( Endpoint @@ -323,9 +323,9 @@ format_endpoint(Endpoint, _Props, _JObj, <<"username">>) -> E end. --spec format_route_endpoint(kz_json:object(), kz_proplist(), kz_json:object()) -> - {'ok', kz_proplist()} | - {'error', ne_binary()}. +-spec format_route_endpoint(kz_json:object(), kz_term:proplist(), kz_json:object()) -> + {'ok', kz_term:proplist()} | + {'error', kz_term:ne_binary()}. format_route_endpoint(Endpoint, _Props, _JObj) -> ToURI = kz_json:get_value(<<"Route">>, Endpoint), [#uri{user=_ToUser @@ -338,7 +338,7 @@ format_route_endpoint(Endpoint, _Props, _JObj) -> ,{"to_sip_port", kz_term:to_list(ToPort)} ])}. --spec format_bounce_endpoint(kz_json:object(), kz_proplist(), kz_json:object()) -> {'ok', kz_proplist()} | {'error', ne_binary()}. +-spec format_bounce_endpoint(kz_json:object(), kz_term:proplist(), kz_json:object()) -> {'ok', kz_term:proplist()} | {'error', kz_term:ne_binary()}. format_bounce_endpoint(Endpoint, Props, JObj) -> CCVs = kz_json:get_value(<<"Custom-Channel-Vars">>, JObj), ToDID = kz_json:get_value(<<"To-DID">>, Endpoint), @@ -356,7 +356,7 @@ format_bounce_endpoint(Endpoint, Props, JObj) -> ,{"to_sip_port", kz_term:to_list(ToPort)} ])}. --spec process_fs_event(atom(), kz_proplist()) -> any(). +-spec process_fs_event(atom(), kz_term:proplist()) -> any(). process_fs_event(Node, Props) -> process_fs_event( props:get_value(<<"Event-Name">>, Props), @@ -364,7 +364,7 @@ process_fs_event(Node, Props) -> Node, lists:usort(Props)). --spec process_fs_event(ne_binary(), ne_binary(), atom(), kz_proplist()) -> any(). +-spec process_fs_event(kz_term:ne_binary(), kz_term:ne_binary(), atom(), kz_term:proplist()) -> any(). process_fs_event(<<"CUSTOM">>, <<"KZ::DELIVERY_REPORT">>, Node, Props) -> process_fs_event(<<"CUSTOM">>, <<"SMS::DELIVERY_REPORT">>, Node, Props); process_fs_event(<<"CUSTOM">>, <<"SMS::DELIVERY_REPORT">>, Node, Props) -> @@ -396,7 +396,7 @@ get_event_uris(Props, EventProps) -> Acc ++ get_event_uris_props(T, Props) end, EventProps, Uris). --spec get_event_uris_props(tuple() | ne_binary(), kz_proplist() | ne_binary()) -> kz_proplist(). +-spec get_event_uris_props(tuple() | kz_term:ne_binary(), kz_term:proplist() | kz_term:ne_binary()) -> kz_term:proplist(). get_event_uris_props({K, F}, Props) -> get_event_uris_props( get_uri( props:get_value(F, Props) ), K); get_event_uris_props('undefined', _) -> []; @@ -410,6 +410,6 @@ get_event_uris_props(Uri, Base) -> is_ccv({?GET_CCV(_K), _V}) -> 'true'; is_ccv(_) -> 'false'. --spec get_ccvs(kz_proplist()) -> kz_proplist(). +-spec get_ccvs(kz_term:proplist()) -> kz_term:proplist(). get_ccvs(Props) -> [{K, V} || {?GET_CCV(K), V} <- [P || P <- Props, is_ccv(P)]]. diff --git a/applications/ecallmgr/src/ecallmgr_fs_node.erl b/applications/ecallmgr/src/ecallmgr_fs_node.erl index 24bcb4825f5..152ad449fb1 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_node.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_node.erl @@ -40,7 +40,7 @@ -define(UPTIME_S, ecallmgr_config:get_integer(<<"fs_node_uptime_s">>, 600)). --type interface() :: {ne_binary(), kz_proplist()}. +-type interface() :: {kz_term:ne_binary(), kz_term:proplist()}. -type interfaces() :: [interface()]. -define(DEFAULT_FS_COMMANDS, [kz_json:from_list([{<<"load">>, <<"mod_sofia">>}]) @@ -99,9 +99,9 @@ ]). -record(state, {node :: atom() - ,options = [] :: kz_proplist() + ,options = [] :: kz_term:proplist() ,interfaces = [] :: interfaces() - ,start_cmds_pid_ref :: pid_ref() | 'undefined' + ,start_cmds_pid_ref :: kz_term:pid_ref() | 'undefined' }). -type state() :: #state{}. @@ -146,7 +146,7 @@ ,{<<"Expires">>, {fun replay_expires/1, <<"expires">>}} ]). --type fs_node() :: atom() | ne_binary() | pid(). +-type fs_node() :: atom() | kz_term:ne_binary() | pid(). %%%=================================================================== %%% API @@ -155,8 +155,8 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(atom()) -> startlink_ret(). --spec start_link(atom(), kz_proplist()) -> startlink_ret(). +-spec start_link(atom()) -> kz_types:startlink_ret(). +-spec start_link(atom(), kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Node) -> start_link(Node, []). start_link(Node, Options) when is_atom(Node) -> QueueName = <<(kz_term:to_binary(Node))/binary @@ -185,7 +185,7 @@ sync_interfaces(Srv) -> sync_interface(Srv) -> sync_interface(Srv, <>). --spec sync_interface(fs_node(), ne_binary()) -> 'ok'. +-spec sync_interface(fs_node(), kz_term:ne_binary()) -> 'ok'. sync_interface(Srv, Profile) -> gen_server:cast(find_srv(Srv), {'sync_interface', Profile}). @@ -193,7 +193,7 @@ sync_interface(Srv, Profile) -> sync_capabilities(Srv) -> gen_server:cast(find_srv(Srv), 'sync_capabilities'). --spec hostname(fs_node()) -> api_binary(). +-spec hostname(fs_node()) -> kz_term:api_binary(). hostname(Srv) -> case fs_node(Srv) of 'undefined' -> 'undefined'; @@ -202,23 +202,23 @@ hostname(Srv) -> Hostname end. --spec sip_url(fs_node()) -> api_binary(). +-spec sip_url(fs_node()) -> kz_term:api_binary(). sip_url(Srv) -> sip_url(Srv, <>). --spec sip_url(fs_node(), ne_binary()) -> api_binary(). +-spec sip_url(fs_node(), kz_term:ne_binary()) -> kz_term:api_binary(). sip_url(Srv, Profile) -> gen_server:call(find_srv(Srv), {'sip_url', Profile}). --spec sip_external_ip(fs_node()) -> api_binary(). +-spec sip_external_ip(fs_node()) -> kz_term:api_binary(). sip_external_ip(Srv) -> sip_external_ip(Srv, <>). --spec sip_external_ip(fs_node(), ne_binary()) -> api_binary(). +-spec sip_external_ip(fs_node(), kz_term:ne_binary()) -> kz_term:api_binary(). sip_external_ip(Srv, Profile) -> gen_server:call(find_srv(Srv), {'sip_external_ip', Profile}). --spec handle_reload_acls(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_reload_acls(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_reload_acls(JObj, Props) -> 'true' = kapi_switch:reload_acls_v(JObj), @@ -228,7 +228,7 @@ handle_reload_acls(JObj, Props) -> {'error', _E} -> lager:debug("reloadacl failed with error: ~p", [_E]) end. --spec handle_reload_gateways(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_reload_gateways(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_reload_gateways(JObj, Props) -> 'true' = kapi_switch:reload_gateways_v(JObj), @@ -276,7 +276,7 @@ fetch_timeout(_Node) -> %% Initializes the server %% @end %%-------------------------------------------------------------------- --spec init([atom() | kz_proplist()]) -> {'ok', state()}. +-spec init([atom() | kz_term:proplist()]) -> {'ok', state()}. init([Node, Options]) -> process_flag('trap_exit', 'true'), kz_util:put_callid(Node), @@ -305,7 +305,7 @@ init([Node, Options]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call({'sip_external_ip', Profile}, _, #state{interfaces=Interfaces}=State) -> ExternalIP = case props:get_value(Profile, Interfaces) of 'undefined' -> 'undefined'; @@ -336,7 +336,7 @@ handle_call('node', _, #state{node=Node}=State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('sync_interfaces', #state{node=Node ,interfaces=Interfaces }=State) -> @@ -365,7 +365,7 @@ handle_cast(_Req, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info('sync_interfaces', #state{node=Node ,interfaces=Interfaces }=State) -> @@ -433,14 +433,14 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --type cmd_result() :: {'ok', {atom(), nonempty_string()}, ne_binary()} | - {'error', {atom(), nonempty_string()}, ne_binary()} | - {'timeout', {atom(), ne_binary()}}. +-type cmd_result() :: {'ok', {atom(), nonempty_string()}, kz_term:ne_binary()} | + {'error', {atom(), nonempty_string()}, kz_term:ne_binary()} | + {'timeout', {atom(), kz_term:ne_binary()}}. -type cmd_results() :: [cmd_result()] | {'error', 'retry'}. --spec run_start_cmds(atom(), kz_proplist()) -> pid_ref(). --spec run_start_cmds(atom(), kz_proplist(), pid()) -> any(). +-spec run_start_cmds(atom(), kz_term:proplist()) -> kz_term:pid_ref(). +-spec run_start_cmds(atom(), kz_term:proplist(), pid()) -> any(). run_start_cmds(Node, Options) -> kz_util:spawn_monitor(fun run_start_cmds/3, [Node, Options, self()]). @@ -461,7 +461,7 @@ is_restarting(Node) when is_atom(Node) -> 'false' end. --spec is_restarting_status(ne_binary()) -> boolean(). +-spec is_restarting_status(kz_term:ne_binary()) -> boolean(). is_restarting_status(UP) -> case re:run(UP, <<"UP (\\d+) years, (\\d+) days, (\\d+) hours, (\\d+) minutes, (\\d+) seconds, (\\d+) milliseconds, (\\d+) microseconds">>, [{'capture', 'all_but_first', 'binary'}]) of {'match', [Years, Days, Hours, Minutes, Seconds, _Mille, _Micro]} -> @@ -475,7 +475,7 @@ is_restarting_status(UP) -> 'nomatch' -> 'false' end. --spec run_start_cmds(atom(), kz_proplist(), pid(), boolean() | kz_json:objects()) -> 'ok'. +-spec run_start_cmds(atom(), kz_term:proplist(), pid(), boolean() | kz_json:objects()) -> 'ok'. run_start_cmds(Node, Options, Parent, 'true') -> lager:debug("node ~s is considered restarting", [Node]), run_start_cmds(Node, Options, Parent, ?FS_CMDS(Node)); @@ -506,14 +506,14 @@ sync(Parent) -> sync_interfaces(Parent), sync_capabilities(Parent). --spec process_cmds(atom(), kz_proplist(), kz_json:objects()) -> cmd_results(). +-spec process_cmds(atom(), kz_term:proplist(), kz_json:objects()) -> cmd_results(). process_cmds(_Node, _Options, []) -> lager:info("no freeswitch commands to run, seems suspect. Is your ecallmgr connected to the same AMQP as the kapps running sysconf?"), []; process_cmds(Node, Options, Cmds) when is_list(Cmds) -> lists:foldl(fun(Cmd, Acc) -> process_cmd(Node, Options, Cmd, Acc) end, [], Cmds). --spec process_cmd(atom(), kz_proplist(), kz_json:object(), cmd_results()) -> cmd_results(). +-spec process_cmd(atom(), kz_term:proplist(), kz_json:object(), cmd_results()) -> cmd_results(). process_cmd(Node, Options, JObj, Acc0) -> kz_json:foldl(fun(ApiCmd, ApiArg, Acc) -> lager:debug("process ~s: ~s: ~s", [Node, ApiCmd, ApiArg]), @@ -523,14 +523,14 @@ process_cmd(Node, Options, JObj, Acc0) -> ,JObj ). --spec process_cmd(atom(), kz_proplist(), ne_binary(), kz_json:json_term(), cmd_results()) -> cmd_results(). --spec process_cmd(atom(), kz_proplist(), ne_binary(), kz_json:json_term(), cmd_results(), 'list'|'binary') -> cmd_results(). +-spec process_cmd(atom(), kz_term:proplist(), kz_term:ne_binary(), kz_json:json_term(), cmd_results()) -> cmd_results(). +-spec process_cmd(atom(), kz_term:proplist(), kz_term:ne_binary(), kz_json:json_term(), cmd_results(), 'list'|'binary') -> cmd_results(). process_cmd(Node, Options, ApiCmd0, ApiArg, Acc) -> process_cmd(Node, Options, ApiCmd0, ApiArg, Acc, 'binary'). process_cmd(Node, Options, ApiCmd0, ApiArg, Acc, ArgFormat) -> execute_command(Node, Options, ApiCmd0, ApiArg, Acc, ArgFormat). --spec execute_command(atom(), kz_proplist(), ne_binary(), kz_json:json_term(), cmd_results(), 'list'|'binary') -> +-spec execute_command(atom(), kz_term:proplist(), kz_term:ne_binary(), kz_json:json_term(), cmd_results(), 'list'|'binary') -> cmd_results(). execute_command(Node, Options, ApiCmd0, ApiArg, Acc, ArgFormat) -> ApiCmd = kz_term:to_atom(ApiCmd0, ?FS_CMD_SAFELIST), @@ -551,11 +551,11 @@ execute_command(Node, Options, ApiCmd0, ApiArg, Acc, ArgFormat) -> [Error | Acc] end. --spec format_args('list'|'binary', api_terms()) -> api_terms(). +-spec format_args('list'|'binary', kz_term:api_terms()) -> kz_term:api_terms(). format_args('list', Args) -> kz_term:to_list(Args); format_args('binary', Args) -> kz_term:to_binary(Args). --spec process_resp(atom(), api_terms(), ne_binaries(), cmd_results()) -> cmd_results(). +-spec process_resp(atom(), kz_term:api_terms(), kz_term:ne_binaries(), cmd_results()) -> cmd_results(). process_resp(ApiCmd, ApiArg, [<<>>|Resps], Acc) -> process_resp(ApiCmd, ApiArg, Resps, Acc); process_resp(ApiCmd, ApiArg, [<<"+OK Reloading XML">>|Resps], Acc) -> @@ -573,7 +573,7 @@ process_resp(ApiCmd, ApiArg, [<<"-ERR ", Err/binary>>|Resps], Acc) -> end; process_resp(_, _, [], Acc) -> Acc. --spec was_bad_error(ne_binary(), atom(), any()) -> boolean(). +-spec was_bad_error(kz_term:ne_binary(), atom(), any()) -> boolean(). was_bad_error(<<"[Module already loaded]">>, 'load', _) -> 'false'; was_bad_error(_E, _, _) -> 'true'. @@ -648,14 +648,14 @@ node_interfaces(Node, CurrInterfaces) -> Interfaces -> Interfaces end. --spec interfaces(atom() | binary()) -> api_object(). +-spec interfaces(atom() | binary()) -> kz_term:api_object(). interfaces(Node) -> gen_server:call(find_srv(Node), 'interfaces'). --spec interface(atom() | binary()) -> api_object(). +-spec interface(atom() | binary()) -> kz_term:api_object(). interface(Node) -> interface(Node, <>). --spec interface(atom() | binary(), ne_binary()) -> api_object(). +-spec interface(atom() | binary(), kz_term:ne_binary()) -> kz_term:api_object(). interface(Node, Profile) -> gen_server:call(find_srv(Node), {'interface', Profile}). diff --git a/applications/ecallmgr/src/ecallmgr_fs_node_command.erl b/applications/ecallmgr/src/ecallmgr_fs_node_command.erl index 9a0853cbc7c..78f65da45af 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_node_command.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_node_command.erl @@ -15,7 +15,7 @@ -define(NODE_CMD_CONFIG, <<"node_commands">>). --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, Props) -> Node = props:get_value('node', Props), Options = props:get_value('node_options', Props), @@ -24,7 +24,7 @@ handle_req(JObj, Props) -> Args = kz_json:get_value(<<"Args">>, JObj), exec_cmd(Cmd, Args, JObj, Node, Options). --spec exec_cmd(ne_binary(), api_object(), kz_json:object(), atom(), kz_proplist()) -> 'ok'. +-spec exec_cmd(kz_term:ne_binary(), kz_term:api_object(), kz_json:object(), atom(), kz_term:proplist()) -> 'ok'. exec_cmd(<<"send_http">>, 'undefined', JObj, _Node, _Options) -> lager:debug("received http_send command with empty arguments"), reply_error(<<"no arguments">>, JObj); @@ -45,7 +45,7 @@ exec_cmd(<<"send_http">>, Args, JObj, Node, Options) -> exec_cmd(Cmd, _Args, JObj, _Node, _Options) -> reply_error(<>, JObj). --spec reply_error(ne_binary(), kz_json:object()) -> 'ok'. +-spec reply_error(kz_term:ne_binary(), kz_json:object()) -> 'ok'. reply_error(Error, JObj) -> Values = [{<<"Result">>, <<"error">>} ,{<<"Error">>, Error} @@ -56,7 +56,7 @@ reply_error(Error, JObj) -> Queue = kz_api:server_id(JObj), kz_amqp_worker:cast(API, fun(P) -> kapi_switch:publish_reply(Queue, P) end). --spec reply_error(ne_binary(), kz_json:object(), kz_json:object()) -> 'ok'. +-spec reply_error(kz_term:ne_binary(), kz_json:object(), kz_json:object()) -> 'ok'. reply_error(Error, EventData, JObj) -> Values = [{<<"Result">>, <<"error">>} ,{<<"Error">>, Error} @@ -69,7 +69,7 @@ reply_error(Error, EventData, JObj) -> kz_amqp_worker:cast(API, fun(P) -> kapi_switch:publish_reply(Queue, P) end). -spec reply_success(kz_json:object()) -> 'ok'. --spec reply_success(kz_json:object(), kz_proplist()) -> 'ok'. +-spec reply_success(kz_json:object(), kz_term:proplist()) -> 'ok'. reply_success(JObj) -> reply_success(JObj, []). reply_success(JObj, Response) -> @@ -82,7 +82,7 @@ reply_success(JObj, Response) -> Queue = kz_api:server_id(JObj), kz_amqp_worker:cast(API, fun(P) -> kapi_switch:publish_reply(Queue, P) end). --spec send_http(atom(), binary(), binary(), binary(), ne_binary(), kz_json:object(), boolean()) -> 'ok'. +-spec send_http(atom(), binary(), binary(), binary(), kz_term:ne_binary(), kz_json:object(), boolean()) -> 'ok'. send_http(Node, Version, File, Url, Method, JObj, DeleteOnSuccess) -> lager:debug("processing http_send command : ~s / ~s", [File, Url]), Args = <>, @@ -100,7 +100,7 @@ send_http_api_and_callback_funs(Version)-> 'false' -> {fun freeswitch:bgapi/5, fun send_http_cb/3} end. --spec send_http_cb(atom(), ne_binary(), list()) -> 'ok'. +-spec send_http_cb(atom(), kz_term:ne_binary(), list()) -> 'ok'. send_http_cb('ok', <<"+OK", _/binary>>, [JobId, JObj, DeleteOnSuccess, File, Node]) -> lager:debug("processed http_send command with success : ~s", [JobId]), _ = maybe_delete_file(Node, File, DeleteOnSuccess), @@ -109,7 +109,7 @@ send_http_cb(_, Reply, [JobId, JObj | _]) -> lager:debug("error processing http_send : ~p : ~s", [Reply, JobId]), reply_error(Reply, JObj). --spec send_http_cb(atom(), ne_binary(), kz_proplist(), list()) -> 'ok'. +-spec send_http_cb(atom(), kz_term:ne_binary(), kz_term:proplist(), list()) -> 'ok'. send_http_cb('ok', <<"+OK", _/binary>>, _FSProps, [JobId, JObj, DeleteOnSuccess, File, Node]) -> lager:debug("processed http_send command with success : ~s", [JobId]), _ = maybe_delete_file(Node, File, DeleteOnSuccess), diff --git a/applications/ecallmgr/src/ecallmgr_fs_node_sup.erl b/applications/ecallmgr/src/ecallmgr_fs_node_sup.erl index 68eaed02a81..49fc66c5efe 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_node_sup.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_node_sup.erl @@ -43,59 +43,59 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link(atom(), kz_proplist()) -> startlink_ret(). +-spec start_link(atom(), kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Node, Options) -> supervisor:start_link({'local', Node}, ?MODULE, [Node, Options]). --spec node_srv(pid()) -> api_pid(). +-spec node_srv(pid()) -> kz_term:api_pid(). node_srv(Supervisor) -> srv(which_children(Supervisor), "edon_"). --spec authn_srv(pid()) -> api_pid(). +-spec authn_srv(pid()) -> kz_term:api_pid(). authn_srv(Supervisor) -> srv(which_children(Supervisor), "nhtua_"). --spec route_sup_srv(pid()) -> api_pid(). +-spec route_sup_srv(pid()) -> kz_term:api_pid(). route_sup_srv(Supervisor) -> srv(which_children(Supervisor), "pus_etuor_"). --spec route_srv(pid()) -> api_pid(). +-spec route_srv(pid()) -> kz_term:api_pid(). route_srv(Supervisor) -> srv(which_children(route_sup_srv(Supervisor)), "etuor_"). --spec channel_srv(pid()) -> api_pid(). +-spec channel_srv(pid()) -> kz_term:api_pid(). channel_srv(Supervisor) -> srv(which_children(Supervisor), "lennahc_"). --spec config_srv(pid()) -> api_pid(). +-spec config_srv(pid()) -> kz_term:api_pid(). config_srv(Supervisor) -> srv(which_children(Supervisor), "gifnoc_"). --spec resource_srv(pid()) -> api_pid(). +-spec resource_srv(pid()) -> kz_term:api_pid(). resource_srv(Supervisor) -> srv(which_children(Supervisor), "ecruoser_"). --spec notify_srv(pid()) -> api_pid(). +-spec notify_srv(pid()) -> kz_term:api_pid(). notify_srv(Supervisor) -> srv(which_children(Supervisor), "yfiton_"). --spec authz_srv(pid()) -> api_pid(). +-spec authz_srv(pid()) -> kz_term:api_pid(). authz_srv(Supervisor) -> srv(which_children(Supervisor), "zhtua_"). --spec cdr_srv(pid()) -> api_pid(). +-spec cdr_srv(pid()) -> kz_term:api_pid(). cdr_srv(Supervisor) -> srv(which_children(Supervisor), "rdc_"). --spec conference_srv(pid()) -> api_pid(). +-spec conference_srv(pid()) -> kz_term:api_pid(). conference_srv(Supervisor) -> srv(which_children(Supervisor), "ecnerefnoc_"). --spec event_stream_sup(pid()) -> api_pid(). +-spec event_stream_sup(pid()) -> kz_term:api_pid(). event_stream_sup(Supervisor) -> srv(which_children(Supervisor), "pus_maerts_tneve_"). --spec msg_srv(pid()) -> api_pid(). +-spec msg_srv(pid()) -> kz_term:api_pid(). msg_srv(Supervisor) -> srv(which_children(Supervisor), "gsm_"). @@ -112,7 +112,7 @@ msg_srv(Supervisor) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(list()) -> sup_init_ret(). +-spec init(list()) -> kz_types:sup_init_ret(). init([Node, Options]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, @@ -141,7 +141,7 @@ child_name(NodeB, Args, Module, <<"worker">>) -> Mod = kz_term:to_atom(<<"ecallmgr_fs_", Module/binary>>, 'true'), ?WORKER_NAME_ARGS_TYPE(Name, Mod, Args, 'transient'). --spec srv([{atom(), pid(), any(), any()}] | tuple(), list()) -> api_pid(). +-spec srv([{atom(), pid(), any(), any()}] | tuple(), list()) -> kz_term:api_pid(). srv([], _) -> 'undefined'; srv([{Name, Pid, _, _} | Children], Suffix) -> %% FIXME: use lists:suffix @@ -158,17 +158,17 @@ maybe_correct_modules(Modules) maybe_correct_modules(kz_json:from_list(FixedModules)); maybe_correct_modules(JObj) -> set_order(JObj). --spec fix_module_type(ne_binary()) -> kz_json:object(). +-spec fix_module_type(kz_term:ne_binary()) -> kz_json:object(). fix_module_type(<<"pus_", _/binary>>) -> kz_json:from_list([{<<"type">>, <<"supervisor">>}]); fix_module_type(_) -> kz_json:from_list([{<<"type">>, <<"worker">>}]). --spec maybe_module_deprecated(ne_binary()) -> ne_binary(). +-spec maybe_module_deprecated(kz_term:ne_binary()) -> kz_term:ne_binary(). maybe_module_deprecated(<<"route">>) -> <<"route_sup">>; maybe_module_deprecated(Mod) -> Mod. --spec fix_module(ne_binary() | string()) -> {ne_binary(), kz_json:object()}. +-spec fix_module(kz_term:ne_binary() | string()) -> {kz_term:ne_binary(), kz_json:object()}. fix_module(Mod) when not is_binary(Mod)-> fix_module(kz_term:to_binary(Mod)); diff --git a/applications/ecallmgr/src/ecallmgr_fs_nodes.erl b/applications/ecallmgr/src/ecallmgr_fs_nodes.erl index 1a7ce2ea910..43ff044d162 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_nodes.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_nodes.erl @@ -68,15 +68,15 @@ -record(node, {node :: atom() ,cookie :: atom() ,connected = 'false' :: boolean() - ,started = kz_time:now_s() :: gregorian_seconds() - ,client_version :: api_binary() - ,options = [] :: kz_proplist() + ,started = kz_time:now_s() :: kz_time:gregorian_seconds() + ,client_version :: kz_term:api_binary() + ,options = [] :: kz_term:proplist() }). -type fs_node() :: #node{}. -record(capability, {node :: atom() | '$1' | '_' - ,name :: ne_binary() | '$1' | '$2' | '_' - ,module :: ne_binary() | '_' + ,name :: kz_term:ne_binary() | '$1' | '$2' | '_' + ,module :: kz_term:ne_binary() | '_' ,is_loaded = 'false' :: boolean() | '$3' | '_' }). -type capability() :: #capability{}. @@ -86,7 +86,7 @@ -record(state, {nodes = dict:new() :: dict:dict() %fs_nodes() ,self = self() :: pid() - ,init_pidref :: pid_ref() | 'undefined' + ,init_pidref :: kz_term:pid_ref() | 'undefined' }). -type state() :: #state{}. @@ -94,7 +94,7 @@ %%% API %%%=================================================================== --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link({'local', ?SERVER}, ?MODULE , [{'responders', ?RESPONDERS} @@ -106,8 +106,8 @@ start_link() -> %% returns 'ok' or {'error', some_error_atom_explaining_more} -spec add(atom()) -> 'ok' | {'error', 'no_connection'}. --spec add(atom(), kz_proplist() | atom()) -> 'ok' | {'error', 'no_connection'}. --spec add(atom(), atom(), kz_proplist() | atom()) -> 'ok' | {'error', 'no_connection'}. +-spec add(atom(), kz_term:proplist() | atom()) -> 'ok' | {'error', 'no_connection'}. +-spec add(atom(), atom(), kz_term:proplist() | atom()) -> 'ok' | {'error', 'no_connection'}. add(Node) -> add(Node, []). @@ -137,17 +137,17 @@ nodeup(Node) when is_atom(Node) -> remove(Node) when is_atom(Node) -> gen_server:cast(?SERVER, {'rm_fs_node', Node}). --spec connected() -> atoms() | kz_proplist_kv(atom(), gregorian_seconds()). +-spec connected() -> kz_term:atoms() | kz_term:proplist_kv(atom(), kz_time:gregorian_seconds()). connected() -> connected('false'). -spec connected('false') -> [atom()]; - ('true') -> [{atom(), gregorian_seconds()}]. + ('true') -> [{atom(), kz_time:gregorian_seconds()}]. connected(Verbose) -> gen_server:call(?SERVER, {'connected_nodes', Verbose}). -spec flush() -> 'ok'. --spec flush(ne_binary(), ne_binary()) -> 'ok'. +-spec flush(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. flush() -> do_flush(<<>>). flush(User, Realm) -> @@ -169,7 +169,7 @@ do_flush(Args) -> is_node_up(Node) when is_atom(Node) -> gen_server:call(?SERVER, {'is_node_up', Node}). --spec sip_url(atom() | text()) -> api_binary(). +-spec sip_url(atom() | kz_term:text()) -> kz_term:api_binary(). sip_url(Node) when not is_atom(Node) -> sip_url(kz_term:to_atom(Node, 'true')); sip_url(Node) when is_atom(Node) -> @@ -182,7 +182,7 @@ sip_url(Node) when is_atom(Node) -> _Else -> 'undefined' end. --spec sip_external_ip(atom() | text()) -> api_binary(). +-spec sip_external_ip(atom() | kz_term:text()) -> kz_term:api_binary(). sip_external_ip(Node) when not is_atom(Node) -> sip_external_ip(kz_term:to_atom(Node, 'true')); sip_external_ip(Node) when is_atom(Node) -> @@ -204,7 +204,7 @@ summary() -> print_summary(gen_server:call(?SERVER, 'nodes')). -spec details() -> 'ok'. --spec details(text() | atom()) -> 'ok'. +-spec details(kz_term:text() | atom()) -> 'ok'. details() -> print_details(gen_server:call(?SERVER, 'nodes')). @@ -219,7 +219,7 @@ details(NodeName) when is_atom(NodeName) -> print_details([{'undefined', Node}]) end. --spec has_capability(atom(), ne_binary() | kz_json:object()) -> boolean(). +-spec has_capability(atom(), kz_term:ne_binary() | kz_json:object()) -> boolean(). has_capability(Node, Capability) when is_binary(Capability) -> MatchSpec = [{#capability{node='$1' ,name='$2' @@ -248,7 +248,7 @@ remove_capabilities(Node) -> }], ets:select_delete(?CAPABILITY_TBL, MatchSpec). --spec remove_capability(atom(), ne_binary()) -> non_neg_integer(). +-spec remove_capability(atom(), kz_term:ne_binary()) -> non_neg_integer(). remove_capability(Node, Name) -> MatchSpec = [{#capability{node='$1' ,name='$2' @@ -261,10 +261,10 @@ remove_capability(Node, Name) -> }], ets:select_delete(?CAPABILITY_TBL, MatchSpec). --spec get_capability(atom(), ne_binary()) -> - capability() | api_object(). --spec get_capability(atom(), ne_binary(), 'json' | 'record') -> - capability() | api_object(). +-spec get_capability(atom(), kz_term:ne_binary()) -> + capability() | kz_term:api_object(). +-spec get_capability(atom(), kz_term:ne_binary(), 'json' | 'record') -> + capability() | kz_term:api_object(). get_capability(Node, Capability) -> get_capability(Node, Capability, 'json'). get_capability(Node, Capability, Format) -> @@ -300,12 +300,12 @@ format_capabilities('record', Results) -> Results; format_capabilities('json', Results) -> [capability_to_json(Result) || Result <- Results]. --spec format_capability('json' | 'record', [capability()]) -> api_object() | capability(). +-spec format_capability('json' | 'record', [capability()]) -> kz_term:api_object() | capability(). format_capability('record', [Capability]) -> Capability; format_capability('json', [Capability]) -> capability_to_json(Capability); format_capability(_, []) -> 'undefined'. --spec set_capability(atom(), ne_binary(), boolean()) -> 'ok'. +-spec set_capability(atom(), kz_term:ne_binary(), boolean()) -> 'ok'. set_capability(Node, Capability, Toggle) when is_boolean(Toggle) -> gen_server:call(?SERVER, {'set_capability', Node, Capability, Toggle}). @@ -327,7 +327,7 @@ capability_to_json(#capability{node=Node ,{<<"is_loaded">>, IsLoaded} ]). --spec handle_fs_xml_flush(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_fs_xml_flush(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_fs_xml_flush(JObj, _Props) -> 'true' = kapi_switch:fs_xml_flush_v(JObj), Username = kz_json:get_value(<<"Username">>, JObj), @@ -370,7 +370,7 @@ init([]) -> %% @end %% #state{nodes=[{FSNode, HandlerPid}]} %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call({'is_node_up', Node}, _From, #state{nodes=Nodes}=State) -> Resp = case dict:find(Node, Nodes) of 'error' -> 'false'; @@ -445,7 +445,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'fs_nodeup', NodeName}, State) -> _ = kz_util:spawn(fun maybe_handle_nodeup/2, [NodeName, State]), {'noreply', State}; @@ -478,7 +478,7 @@ handle_cast(_Cast, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info('expire_sip_subscriptions', Cache) -> Now = kz_time:now_s(), DeleteSpec = [{#sip_subscription{expires = '$1', timestamp = '$2', _ = '_'}, @@ -507,7 +507,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. @@ -547,7 +547,7 @@ call_control_fs_nodeup(NodeName) -> Pids = gproc:lookup_pids({'p', 'l', 'call_control'}), call_control_fs_nodeup(Pids, NodeName). --spec call_control_fs_nodeup(pids(), atom()) -> 'ok'. +-spec call_control_fs_nodeup(kz_term:pids(), atom()) -> 'ok'. call_control_fs_nodeup([], _) -> 'ok'; call_control_fs_nodeup([Pid|Pids], NodeName) -> _ = ecallmgr_call_control:fs_nodeup(Pid, NodeName), @@ -558,7 +558,7 @@ call_control_fs_nodedown(NodeName) -> Pids = gproc:lookup_pids({'p', 'l', 'call_control'}), call_control_fs_nodedown(Pids, NodeName). --spec call_control_fs_nodedown(pids(), atom()) -> 'ok'. +-spec call_control_fs_nodedown(kz_term:pids(), atom()) -> 'ok'. call_control_fs_nodedown([], _) -> 'ok'; call_control_fs_nodedown([Pid|Pids], NodeName) -> _ = ecallmgr_call_control:fs_nodedown(Pid, NodeName), @@ -580,7 +580,7 @@ maybe_handle_nodedown(NodeName, #state{nodes=Nodes}=State) -> _Else -> 'ok' end. --spec maybe_add_node(text(), text(), kz_proplist(), state()) -> +-spec maybe_add_node(kz_term:text(), kz_term:text(), kz_term:proplist(), state()) -> 'ok' | {'error', any()}. maybe_add_node(NodeName, Cookie, Options, #state{self=Srv, nodes=Nodes}) -> case dict:find(NodeName, Nodes) of @@ -724,7 +724,7 @@ close_node(#node{node=NodeName}) -> _ = ecallmgr_fs_sup:remove_node(NodeName), ecallmgr_fs_pinger_sup:remove_node(NodeName). --spec create_node(text(), text(), kz_proplist()) -> fs_node(). +-spec create_node(kz_term:text(), kz_term:text(), kz_term:proplist()) -> fs_node(). create_node(NodeName, Cookie, Options) when not is_atom(NodeName) -> create_node(kz_term:to_atom(NodeName, 'true'), Cookie, Options); create_node(NodeName, Cookie, Options) when not is_atom(Cookie) -> @@ -736,14 +736,14 @@ create_node(NodeName, Cookie, Options) -> ,options=Options }. --spec get_fs_cookie(atom(), kz_proplist()) -> atom(). +-spec get_fs_cookie(atom(), kz_term:proplist()) -> atom(). get_fs_cookie('undefined', Props) -> kz_term:to_atom(props:get_value('cookie', Props, erlang:get_cookie())); get_fs_cookie(Cookie, _) when is_atom(Cookie) -> Cookie. -spec get_fs_client_version(fs_node()) -> fs_node(); - (atom()) -> api_binary(). + (atom()) -> kz_term:api_binary(). get_fs_client_version(#node{node=NodeName}=Node) -> Node#node{client_version=get_fs_client_version(NodeName)}; get_fs_client_version(NodeName) -> diff --git a/applications/ecallmgr/src/ecallmgr_fs_notify.erl b/applications/ecallmgr/src/ecallmgr_fs_notify.erl index 5ad4202615d..713d114e3e0 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_notify.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_notify.erl @@ -24,7 +24,7 @@ ]). -record(state, {node :: atom() - ,options :: kz_proplist() + ,options :: kz_term:proplist() }). -type state() :: #state{}. @@ -67,8 +67,8 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(atom()) -> startlink_ret(). --spec start_link(atom(), kz_proplist()) -> startlink_ret(). +-spec start_link(atom()) -> kz_types:startlink_ret(). +-spec start_link(atom(), kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Node) -> start_link(Node, []). start_link(Node, Options) -> gen_listener:start_link(?SERVER @@ -80,7 +80,7 @@ start_link(Node, Options) -> ] ,[Node, Options]). --spec presence_probe(kz_json:object(), kz_proplist()) -> 'ok'. +-spec presence_probe(kz_json:object(), kz_term:proplist()) -> 'ok'. presence_probe(JObj, _Props) -> 'true' = kapi_presence:probe_v(JObj), _ = kz_util:put_callid(JObj), @@ -92,7 +92,7 @@ presence_probe(JObj, _Props) -> end, resp_to_probe(State, Username, Realm). --spec resp_to_probe(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec resp_to_probe(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. resp_to_probe(State, User, Realm) -> PresenceId = <>, PresenceUpdate = [{<<"Presence-ID">>, PresenceId} @@ -102,7 +102,7 @@ resp_to_probe(State, User, Realm) -> ], kz_amqp_worker:cast(PresenceUpdate, fun kapi_presence:publish_update/1). --spec notify_api(kz_json:object(), kz_proplist()) -> 'ok'. +-spec notify_api(kz_json:object(), kz_term:proplist()) -> 'ok'. notify_api(JObj, _Props) -> 'true' = kapi_switch:notify_v(JObj), kz_util:put_callid(JObj), @@ -111,12 +111,12 @@ notify_api(JObj, _Props) -> ,JObj ). --spec notify(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec notify(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. notify(Username, Realm, Event) -> JObj = kz_json:from_list([{<<"Event">>, Event}]), maybe_send_notify(Username, Realm, JObj). --spec maybe_send_notify(ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec maybe_send_notify(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. maybe_send_notify(Username, Realm, JObj) -> lager:info("looking up registration information for ~s@~s", [Username, Realm]), case ecallmgr_registrar:lookup_registration(Realm, Username) of @@ -133,7 +133,7 @@ maybe_send_notify(Username, Realm, JObj) -> end end. --spec send_notify(atom(), ne_binary(), ne_binary(), kz_json:object(), ne_binary()) -> 'ok'. +-spec send_notify(atom(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> 'ok'. send_notify(Node, Username, Realm, JObj, Contact) -> AOR = To = From = kzsip_uri:ruri(#uri{user=Username, domain=Realm}), SIPHeaders = <<"X-KAZOO-AOR : ", AOR/binary, "\r\n">>, @@ -154,7 +154,7 @@ send_notify(Node, Username, Realm, JObj, Contact) -> lager:info("send NOTIFY with Event '~s' (has body? ~w) to '~s@~s' via ~s: ~p" ,[Event, (Body =/= 'undefined'), Username, Realm, Node, Resp]). --spec mwi_update(kz_json:object(), kz_proplist()) -> no_return(). +-spec mwi_update(kz_json:object(), kz_term:proplist()) -> no_return(). mwi_update(JObj, Props) -> _ = kz_util:put_callid(JObj), 'true' = kapi_presence:mwi_unsolicited_update_v(JObj), @@ -167,7 +167,7 @@ mwi_update(JObj, Props) -> send_mwi_update(JObj, Username, Realm, Node, Registration) end. --spec send_mwi_update(kz_json:object(), ne_binary(), ne_binary(), atom(), kz_json:object()) -> 'ok'. +-spec send_mwi_update(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), atom(), kz_json:object()) -> 'ok'. send_mwi_update(JObj, Username, Realm, Node, Registration) -> ToURI = #uri{user=kz_json:get_value(<<"To-User">>, Registration, Username) ,domain=kz_json:get_value(<<"To-Host">>, Registration, Realm) @@ -205,7 +205,7 @@ send_mwi_update(JObj, Username, Realm, Node, Registration) -> lager:debug("sent MWI update to '~s' via ~s: ~p", [Contact, Node, Resp]) end. --spec register_overwrite(kz_json:object(), kz_proplist()) -> no_return(). +-spec register_overwrite(kz_json:object(), kz_term:proplist()) -> no_return(). register_overwrite(JObj, Props) -> Node = props:get_value('node', Props), Username = kz_json:get_binary_value(<<"Username">>, JObj, <<"unknown">>), @@ -261,7 +261,7 @@ register_overwrite(JObj, Props) -> ,Node ]). --spec ensure_contact_user(ne_binary(), ne_binary(), ne_binary()) -> api_binary(). +-spec ensure_contact_user(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_binary(). ensure_contact_user(OriginalContact, Username, Realm) -> ecallmgr_util:fix_contact(OriginalContact, Username, Realm). @@ -275,7 +275,7 @@ ensure_contact_user(OriginalContact, Username, Realm) -> %% Initializes the server %% @end %%-------------------------------------------------------------------- --spec init([atom() | kz_proplist()]) -> {'ok', state()}. +-spec init([atom() | kz_term:proplist()]) -> {'ok', state()}. init([Node, Options]) -> process_flag('trap_exit', 'true'), kz_util:put_callid(Node), @@ -297,7 +297,7 @@ init([Node, Options]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -311,7 +311,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> {'noreply', State}. @@ -325,7 +325,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'EXIT', _, 'noconnection'}, State) -> {stop, {'shutdown', 'noconnection'}, State}; handle_info({'EXIT', _, Reason}, State) -> diff --git a/applications/ecallmgr/src/ecallmgr_fs_pinger.erl b/applications/ecallmgr/src/ecallmgr_fs_pinger.erl index c7ece2a7a1c..008b53f5a1b 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_pinger.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_pinger.erl @@ -27,7 +27,7 @@ -define(SERVER, ?MODULE). -record(state, {node = 'undefined' :: atom() - ,options = [] :: kz_proplist() + ,options = [] :: kz_term:proplist() ,timeout = 2 * ?MILLISECONDS_IN_SECOND }). -type state() :: #state{}. @@ -35,7 +35,7 @@ %%%=================================================================== %%% API %%%=================================================================== --spec start_link(atom(), kz_proplist()) -> startlink_ret(). +-spec start_link(atom(), kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Node, Options) -> gen_server:start_link(?SERVER, [Node, Options], []). @@ -54,7 +54,7 @@ start_link(Node, Options) -> %% {stop, Reason} %% @end %%-------------------------------------------------------------------- --spec init([atom() | kz_proplist()]) -> {'ok', state()}. +-spec init([atom() | kz_term:proplist()]) -> {'ok', state()}. init([Node, Props]) -> kz_util:put_callid(Node), self() ! 'initialize_pinger', @@ -76,7 +76,7 @@ init([Node, Props]) -> %% @end %% #state{nodes=[{FSNode, HandlerPid}]} %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, #state{timeout=Timeout}=State) -> {'reply', {'error', 'not_implemented'}, State, Timeout}. @@ -90,7 +90,7 @@ handle_call(_Request, _From, #state{timeout=Timeout}=State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, #state{timeout=Timeout}=State) -> lager:debug("unhandled cast: ~p", [_Msg]), {'noreply', State, Timeout}. @@ -105,7 +105,7 @@ handle_cast(_Msg, #state{timeout=Timeout}=State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info('initialize_pinger', #state{node=Node, options=Props}=State) -> kz_notify:system_alert("node ~s disconnected from ~s", [Node, node()]), _ = case props:get_value('cookie', Props) of diff --git a/applications/ecallmgr/src/ecallmgr_fs_pinger_sup.erl b/applications/ecallmgr/src/ecallmgr_fs_pinger_sup.erl index 4ba2f3a3a8f..df3564ed52a 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_pinger_sup.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_pinger_sup.erl @@ -29,16 +29,16 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec add_node(atom(), kz_proplist()) -> sup_startchild_ret(). +-spec add_node(atom(), kz_term:proplist()) -> kz_types:sup_startchild_ret(). add_node(Node, Options) -> ChildSpec = ?WORKER_NAME_ARGS_TYPE(Node, 'ecallmgr_fs_pinger', [Node, Options], 'transient'), supervisor:start_child(?SERVER, ChildSpec). --spec find_pinger(atom()) -> api_pid(). +-spec find_pinger(atom()) -> kz_term:api_pid(). find_pinger(Node) -> Workers = supervisor:which_children(?MODULE), find_pinger(Workers, Node). @@ -67,7 +67,7 @@ remove_node(Node) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 2, diff --git a/applications/ecallmgr/src/ecallmgr_fs_presence.erl b/applications/ecallmgr/src/ecallmgr_fs_presence.erl index c2eb4a367f7..21d33ba95d9 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_presence.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_presence.erl @@ -24,8 +24,8 @@ -define(SERVER, ?MODULE). -record(state, {node = 'undefined' :: atom() - ,event :: ne_binary() - ,options = [] :: kz_proplist() + ,event :: kz_term:ne_binary() + ,options = [] :: kz_term:proplist() }). -type state() :: #state{}. @@ -36,8 +36,8 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(atom()) -> startlink_ret(). --spec start_link(atom(), kz_proplist()) -> startlink_ret(). +-spec start_link(atom()) -> kz_types:startlink_ret(). +-spec start_link(atom(), kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Node) -> start_link(Node, []). start_link(Node, Options) -> gen_server:start_link(?SERVER, [Node, Options], []). @@ -57,7 +57,7 @@ start_link(Node, Options) -> %% {stop, Reason} %% @end %%-------------------------------------------------------------------- --spec init([atom() | kz_proplist()]) -> {'ok', state()}. +-spec init([atom() | kz_term:proplist()]) -> {'ok', state()}. init([Node, Options]) -> kz_util:put_callid(Node), Event = application:get_env(?APP, 'presence_event', <<"PRESENCE_IN">>), @@ -78,7 +78,7 @@ init([Node, Options]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -92,7 +92,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('bind_to_record', #state{node=Node, event=Event}=State) -> case gproc:reg({'p', 'l', ?FS_EVENT_REG_MSG(Node, Event)}) =:= 'true' andalso gproc:reg({'p', 'l', ?FS_OPTION_MSG(Node)}) =:= 'true' @@ -114,7 +114,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'event', [UUID | Props]}, #state{node=Node ,options=Options ,event=Event @@ -158,7 +158,7 @@ code_change(_OldVsn, State, _Extra) -> %%% Internal functions %%%=================================================================== --spec init_props(kz_proplist(), kz_proplist()) -> kz_proplist(). +-spec init_props(kz_term:proplist(), kz_term:proplist()) -> kz_term:proplist(). init_props(Props, Options) -> case props:get_is_true(<<"Publish-Channel-State">>, Props) of 'undefined' -> @@ -169,18 +169,18 @@ init_props(Props, Options) -> _Value -> Props end. --spec handle_presence_event(ne_binary(), api_binary(), kz_proplist(), atom(), kz_proplist()) -> any(). +-spec handle_presence_event(kz_term:ne_binary(), kz_term:api_binary(), kz_term:proplist(), atom(), kz_term:proplist()) -> any(). handle_presence_event(BindingEvent, UUID, FSProps, Node, Options) -> kz_util:put_callid(UUID), Props = init_props(FSProps, Options), EventName = props:get_value(<<"Event-Subclass">>, Props, props:get_value(<<"Event-Name">>, Props)), process_specific_event(BindingEvent, EventName, UUID, Props, Node). --spec process_specific_event(ne_binary(), ne_binary(), api_binary(), kz_proplist(), atom()) -> any(). +-spec process_specific_event(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary(), kz_term:proplist(), atom()) -> any(). process_specific_event(Event, Event, UUID, Props, Node) -> maybe_build_presence_event(Node, UUID, Props). --spec maybe_build_presence_event(atom(), api_binary(), kz_proplist()) -> any(). +-spec maybe_build_presence_event(atom(), kz_term:api_binary(), kz_term:proplist()) -> any(). maybe_build_presence_event(Node, UUID, Props) -> Routines = [fun check_proto/3 ,fun check_publish_state/3 @@ -190,23 +190,23 @@ maybe_build_presence_event(Node, UUID, Props) -> 'false' -> 'ok' end. --spec check_proto(atom(), api_binary(), kz_proplist()) -> boolean(). +-spec check_proto(atom(), kz_term:api_binary(), kz_term:proplist()) -> boolean(). check_proto(_Node, _UUID, Props) -> Proto = props:get_value(<<"proto">>, Props), check_proto(Proto). --spec check_proto(api_binary()) -> boolean(). +-spec check_proto(kz_term:api_binary()) -> boolean(). check_proto(<<"any">>) -> 'true'; check_proto(_Proto) -> lager:debug("presence proto ~p not handled", [_Proto]), 'false'. --spec check_publish_state(atom(), api_binary(), kz_proplist()) -> boolean(). +-spec check_publish_state(atom(), kz_term:api_binary(), kz_term:proplist()) -> boolean(). check_publish_state(_Node, _UUID, Props) -> props:is_true(<<"Force-Publish-Event-State">>, Props, 'false') orelse props:is_true(<<"Publish-Channel-State">>, Props, 'true'). --spec realm(kz_proplist()) -> ne_binary(). +-spec realm(kz_term:proplist()) -> kz_term:ne_binary(). realm(Props) -> props:get_first_defined([?GET_CCV(<<"Realm">>) ,<<"variable_sip_invite_domain">> @@ -214,21 +214,21 @@ realm(Props) -> ,<<"variable_sip_to_host">> ], Props, ?DEFAULT_REALM). --spec get_user_realm(kz_proplist()) -> {ne_binary(), ne_binary()}. +-spec get_user_realm(kz_term:proplist()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. get_user_realm(Props) -> case binary:split(from(Props), <<"@">>, ['global']) of [Username, Realm | _] -> {Username, Realm}; [From] -> {From, realm(Props)} end. --spec from(kz_proplist()) -> ne_binary(). +-spec from(kz_term:proplist()) -> kz_term:ne_binary(). from(Props) -> props:get_first_defined([<<"from">> ,<<"variable_presence_id">> ,<<"Channel-Presence-ID">> ], Props). --spec to_user(kz_proplist()) -> ne_binary(). +-spec to_user(kz_term:proplist()) -> kz_term:ne_binary(). to_user(Props) -> to_user(direction(Props), Props). @@ -241,12 +241,12 @@ to_user(<<"recipient">>, Props) -> ,<<"variable_sip_from_user">> ], Props). --spec expires(ne_binary()) -> integer(). +-spec expires(kz_term:ne_binary()) -> integer(). expires(<<"early">>) -> 0; expires(<<"confirmed">>) -> 0; expires(<<"terminated">>) -> 20. --spec build_presence_event(atom(), api_binary(), kz_proplist()) -> any(). +-spec build_presence_event(atom(), kz_term:api_binary(), kz_term:proplist()) -> any(). build_presence_event(_Node, UUID, Props) -> ToTag = kzd_freeswitch:to_tag(Props), FromTag = kzd_freeswitch:from_tag(Props), @@ -288,29 +288,29 @@ build_presence_event(_Node, UUID, Props) -> lager:debug("sending presence ~s to ~s/~s in realm ~s", [State, FromUser, ToUser, Realm]), kz_amqp_worker:cast(Payload, fun kapi_presence:publish_dialog/1). --spec direction(kz_proplist()) -> ne_binary(). +-spec direction(kz_term:proplist()) -> kz_term:ne_binary(). direction(Props) -> case props:get_value(<<"Presence-Call-Direction">>, Props) of <<"inbound">> -> <<"initiator">>; <<"outbound">> -> <<"recipient">> end. --spec status(kz_proplist()) -> ne_binary(). +-spec status(kz_term:proplist()) -> kz_term:ne_binary(). status(Props) -> kz_term:to_lower_binary(props:get_binary_value(<<"status">>, Props)). --spec answer_state(kz_proplist()) -> ne_binary(). +-spec answer_state(kz_term:proplist()) -> kz_term:ne_binary(). answer_state(Props) -> kz_term:to_lower_binary(props:get_value(<<"Answer-State">>, Props)). --spec presence_status(kz_proplist()) -> ne_binary(). +-spec presence_status(kz_term:proplist()) -> kz_term:ne_binary(). presence_status(Props) -> Status = status(Props), AnswerState = answer_state(Props), Direction = direction(Props), presence_status(Direction, Status, AnswerState). --spec presence_status(ne_binary(), ne_binary(), ne_binary()) -> ne_binary(). +-spec presence_status(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). presence_status(_, _, <<"answered">>) -> <<"confirmed">>; presence_status(_, _, <<"hangup">>) -> <<"terminated">>; presence_status(_, <<"hangup">>, _) -> <<"terminated">>; diff --git a/applications/ecallmgr/src/ecallmgr_fs_recordings.erl b/applications/ecallmgr/src/ecallmgr_fs_recordings.erl index 6a45b8b4282..7386f0ac87f 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_recordings.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_recordings.erl @@ -23,7 +23,7 @@ -define(SERVER, ?MODULE). -record(state, {node = 'undefined' :: atom() - ,options = [] :: kz_proplist() + ,options = [] :: kz_term:proplist() }). -type state() :: #state{}. @@ -34,8 +34,8 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(atom()) -> startlink_ret(). --spec start_link(atom(), kz_proplist()) -> startlink_ret(). +-spec start_link(atom()) -> kz_types:startlink_ret(). +-spec start_link(atom(), kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Node) -> start_link(Node, []). start_link(Node, Options) -> gen_server:start_link(?SERVER, [Node, Options], []). @@ -76,7 +76,7 @@ init([Node, Options]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -90,7 +90,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('bind_to_record', #state{node=Node}=State) -> case gproc:reg({'p', 'l', ?FS_EVENT_REG_MSG(Node, <<"RECORD_START">>)}) =:= 'true' andalso gproc:reg({'p', 'l', ?FS_EVENT_REG_MSG(Node, <<"RECORD_STOP">>)}) =:= 'true' @@ -113,7 +113,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'event', Props}, #state{node=Node ,options=Options }=State) -> @@ -159,7 +159,7 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec init_props(kz_proplist(), kz_proplist()) -> kz_proplist(). +-spec init_props(kz_term:proplist(), kz_term:proplist()) -> kz_term:proplist(). init_props(Props, Options) -> case props:get_is_true(<<"Publish-Channel-State">>, Props) of 'undefined' -> @@ -170,20 +170,20 @@ init_props(Props, Options) -> _Value -> Props end. --spec handle_record_event(atom(), kz_proplist(), kz_proplist()) -> 'ok'. +-spec handle_record_event(atom(), kz_term:proplist(), kz_term:proplist()) -> 'ok'. handle_record_event(Node, [UUID | FSProps], Options) -> kz_util:put_callid(UUID), Props = init_props(FSProps, Options), process_event(UUID, Props, Node), maybe_publish_record_event(Props). --spec process_event(api_binary(), kz_proplist(), atom()) -> any(). +-spec process_event(kz_term:api_binary(), kz_term:proplist(), atom()) -> any(). process_event(UUID, Props, Node) -> kz_util:put_callid(UUID), EventName = kzd_freeswitch:event_name(Props), process_specific_event(EventName, UUID, Props, Node). --spec process_specific_event(ne_binary(), api_binary(), kz_proplist(), atom()) -> any(). +-spec process_specific_event(kz_term:ne_binary(), kz_term:api_binary(), kz_term:proplist(), atom()) -> any(). process_specific_event(<<"RECORD_STOP">>, UUID, Props, Node) -> IsLocal = props:is_true(<<"Force-Publish-Event-State">>, Props, 'true') orelse (props:is_true(<<"Publish-Channel-State">>, Props, 'true') @@ -195,7 +195,7 @@ process_specific_event(<<"RECORD_START">>, _UUID, _Props, _Node) -> 'ok'; process_specific_event(_Event, _UUID, _Props, _Node) -> lager:debug("event ~s for callid ~s not handled in recordings (~s)", [_Event, _UUID, _Node]). --spec maybe_publish_record_event(kz_proplist()) -> 'ok'. +-spec maybe_publish_record_event(kz_term:proplist()) -> 'ok'. maybe_publish_record_event(Props) -> case props:is_true(<<"Force-Publish-Event-State">>, Props, 'false') orelse (props:is_true(<<"Publish-Channel-State">>, Props, 'true') @@ -206,7 +206,7 @@ maybe_publish_record_event(Props) -> 'false' -> lager:debug("not publishing record event ~s", [kzd_freeswitch:event_name(Props)]) end. --spec maybe_store_recording(boolean(), api_binary(), kz_proplist(), ne_binary(), atom()) -> +-spec maybe_store_recording(boolean(), kz_term:api_binary(), kz_term:proplist(), kz_term:ne_binary(), atom()) -> 'ok' | 'error' | ecallmgr_util:send_cmd_ret() | @@ -244,15 +244,15 @@ maybe_store_recording('true', _, Props, CallId, Node) -> ecallmgr_call_command:exec_cmd(Node, CallId, JObj, 'undefined') end. --spec media_transfer_method(kz_proplist()) -> ne_binary(). +-spec media_transfer_method(kz_term:proplist()) -> kz_term:ne_binary(). media_transfer_method(Props) -> kzd_freeswitch:ccv(Props, <<"Media-Transfer-Method">>, <<"put">>). --spec handling_locally(kz_proplist()) -> boolean(). +-spec handling_locally(kz_term:proplist()) -> boolean(). handling_locally(Props) -> handling_locally(Props, kzd_freeswitch:other_leg_call_id(Props)). --spec handling_locally(kz_proplist(), api_binary()) -> boolean(). +-spec handling_locally(kz_term:proplist(), kz_term:api_binary()) -> boolean(). handling_locally(Props, 'undefined') -> props:get_value(?GET_CCV(<<"Ecallmgr-Node">>), Props) =:= kz_term:to_binary(node()); @@ -263,7 +263,7 @@ handling_locally(Props, OtherLeg) -> _ -> other_leg_handling_locally(OtherLeg) end. --spec other_leg_handling_locally(ne_binary()) -> boolean(). +-spec other_leg_handling_locally(kz_term:ne_binary()) -> boolean(). other_leg_handling_locally(OtherLeg) -> case ecallmgr_fs_channel:fetch(OtherLeg, 'record') of {'ok', #channel{handling_locally=HandleLocally}} -> HandleLocally; diff --git a/applications/ecallmgr/src/ecallmgr_fs_resource.erl b/applications/ecallmgr/src/ecallmgr_fs_resource.erl index 290d4698883..0c7fb31f4f5 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_resource.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_resource.erl @@ -26,7 +26,7 @@ -define(SERVER, ?MODULE). -record(state, {node :: atom() - ,options :: kz_proplist() + ,options :: kz_term:proplist() }). -type state() :: #state{}. @@ -48,8 +48,8 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(atom()) -> startlink_ret(). --spec start_link(atom(), kz_proplist()) -> startlink_ret(). +-spec start_link(atom()) -> kz_types:startlink_ret(). +-spec start_link(atom(), kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Node) -> start_link(Node, []). start_link(Node, Options) -> gen_listener:start_link(?SERVER @@ -61,7 +61,7 @@ start_link(Node, Options) -> ], [Node, Options]). --spec handle_originate_req(kz_json:object(), kz_proplist()) -> sup_startchild_ret(). +-spec handle_originate_req(kz_json:object(), kz_term:proplist()) -> kz_types:sup_startchild_ret(). handle_originate_req(JObj, Props) -> _ = kz_util:put_callid(JObj), Node = props:get_value('node', Props), @@ -83,7 +83,7 @@ handle_originate_req(JObj, Props) -> %% {stop, Reason} %% @end %%-------------------------------------------------------------------- --spec init([atom() | kz_proplist()]) -> {'ok', state()}. +-spec init([atom() | kz_term:proplist()]) -> {'ok', state()}. init([Node, Options]) -> process_flag('trap_exit', 'true'), kz_util:put_callid(Node), @@ -104,7 +104,7 @@ init([Node, Options]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -118,7 +118,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> {'noreply', State}. @@ -132,7 +132,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'update_options', NewOptions}, State) -> {'noreply', State#state{options=NewOptions}, 'hibernate'}; handle_info({'EXIT', _, 'noconnection'}, State) -> diff --git a/applications/ecallmgr/src/ecallmgr_fs_route.erl b/applications/ecallmgr/src/ecallmgr_fs_route.erl index fffbf24e3f5..65204f7d78e 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_route.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_route.erl @@ -23,9 +23,9 @@ -define(SERVER, ?MODULE). -record(state, {node = 'undefined' :: atom() - ,options = [] :: kz_proplist() - ,switch_url :: api_binary() - ,switch_uri :: api_binary() + ,options = [] :: kz_term:proplist() + ,switch_url :: kz_term:api_binary() + ,switch_uri :: kz_term:api_binary() ,switch_info = 'false' :: boolean() }). -type state() :: #state{}. @@ -37,8 +37,8 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(atom()) -> startlink_ret(). --spec start_link(atom(), kz_proplist()) -> startlink_ret(). +-spec start_link(atom()) -> kz_types:startlink_ret(). +-spec start_link(atom(), kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Node) -> start_link(Node, []). start_link(Node, Options) -> gen_server:start_link(?SERVER, [Node, Options], []). @@ -58,7 +58,7 @@ start_link(Node, Options) -> %% {stop, Reason} %% @end %%-------------------------------------------------------------------- --spec init([atom() | kz_proplist()]) -> {'ok', state()}. +-spec init([atom() | kz_term:proplist()]) -> {'ok', state()}. init([Node, Options]) -> process_flag('trap_exit', 'true'), kz_util:put_callid(Node), @@ -81,7 +81,7 @@ init([Node, Options]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -95,7 +95,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('bind_to_dialplan', #state{node=Node}=State) -> case freeswitch:bind(Node, 'dialplan') of 'ok' -> {'noreply', State}; @@ -124,7 +124,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'fetch', Section, Tag, Key, Value, FSId, FSData} ,#state{node=Node, switch_info='false'}=State @@ -170,7 +170,7 @@ handle_info(_Other, State) -> lager:debug("unhandled msg: ~p", [_Other]), {'noreply', State}. --spec handle_fetch(ne_binary(), ne_binary(), ne_binary(), kzd_freeswitch:data(), atom()) -> 'ok'. +-spec handle_fetch(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kzd_freeswitch:data(), atom()) -> 'ok'. handle_fetch(Section, FSId, CallId, FSData, Node) -> EventName = props:get_value(<<"Event-Name">>, FSData), SubClass = props:get_value(<<"Event-Subclass">>, FSData), diff --git a/applications/ecallmgr/src/ecallmgr_fs_route_sup.erl b/applications/ecallmgr/src/ecallmgr_fs_route_sup.erl index a89a4eec77f..1e4cdfba8db 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_route_sup.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_route_sup.erl @@ -29,8 +29,8 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link(atom()) -> startlink_ret(). --spec start_link(atom(), kz_proplist()) -> startlink_ret(). +-spec start_link(atom()) -> kz_types:startlink_ret(). +-spec start_link(atom(), kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Node) -> start_link(Node, []). start_link(Node, Options) -> supervisor:start_link(?MODULE, [Node, Options]). @@ -48,7 +48,7 @@ start_link(Node, Options) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init(Args) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, diff --git a/applications/ecallmgr/src/ecallmgr_fs_router_call.erl b/applications/ecallmgr/src/ecallmgr_fs_router_call.erl index 09f1b69abfa..e82ce29cfe0 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_router_call.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_router_call.erl @@ -28,7 +28,7 @@ -define(DEFAULT_BINDINGS, [?DEFAULT_FREESWITCH_CONTEXT]). -record(state, {node = 'undefined' :: atom() - ,options = [] :: kz_proplist() + ,options = [] :: kz_term:proplist() }). -type state() :: #state{}. @@ -39,8 +39,8 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(atom()) -> startlink_ret(). --spec start_link(atom(), kz_proplist()) -> startlink_ret(). +-spec start_link(atom()) -> kz_types:startlink_ret(). +-spec start_link(atom(), kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Node) -> start_link(Node, []). start_link(Node, Options) -> gen_server:start_link(?SERVER, [Node, Options], []). @@ -55,7 +55,7 @@ start_link(Node, Options) -> %% Initializes the server %% @end %%-------------------------------------------------------------------- --spec init([atom() | kz_proplist()]) -> {'ok', state()}. +-spec init([atom() | kz_term:proplist()]) -> {'ok', state()}. init([Node, Options]) -> process_flag('trap_exit', 'true'), kz_util:put_callid(Node), @@ -77,7 +77,7 @@ init([Node, Options]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -91,7 +91,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('bind_to_dialplan', #state{node=Node}=State) -> Bindings = ecallmgr_config:get_ne_binaries(?BINDINGS_CFG_KEY, ?DEFAULT_BINDINGS, Node), case ecallmgr_fs_router_util:register_bindings(Node, ?FETCH_SECTION, Bindings) of @@ -114,7 +114,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'route', Section, _EventName, _SubClass, _Context, Id, 'undefined', _FSData} ,#state{node=Node}=State ) -> @@ -140,7 +140,7 @@ handle_info(_Other, State) -> lager:debug("unhandled msg: ~p", [_Other]), {'noreply', State}. --spec interaction_props(atom(), ne_binary(), kz_proplist()) -> kz_proplist(). +-spec interaction_props(atom(), kz_term:ne_binary(), kz_term:proplist()) -> kz_term:proplist(). interaction_props(Node, CallId, FSData) -> case props:get_value(?GET_CCV(<>), FSData) of 'undefined' -> @@ -181,7 +181,7 @@ code_change(_OldVsn, State, _Extra) -> %%% Internal functions %%%=================================================================== --spec process_route_req(atom(), atom(), ne_binary(), ne_binary(), kzd_freeswitch:data()) -> 'ok'. +-spec process_route_req(atom(), atom(), kz_term:ne_binary(), kz_term:ne_binary(), kzd_freeswitch:data()) -> 'ok'. process_route_req(Section, Node, FetchId, CallId, Props) -> kz_util:put_callid(CallId), case kz_term:is_true(props:get_value(<<"variable_recovered">>, Props)) of @@ -194,7 +194,7 @@ process_route_req(Section, Node, FetchId, CallId, Props) -> ecallmgr_fs_router_util:reply_affirmative(Section, Node, FetchId, CallId, JObj, Props) end. --spec do_process_route_req(atom(), atom(), ne_binary(), ne_binary(), kzd_freeswitch:data()) -> 'ok'. +-spec do_process_route_req(atom(), atom(), kz_term:ne_binary(), kz_term:ne_binary(), kzd_freeswitch:data()) -> 'ok'. do_process_route_req(Section, Node, FetchId, CallId, Props) -> Filtered = ecallmgr_fs_loopback:filter(Node, CallId, Props), case ecallmgr_fs_router_util:search_for_route(Section, Node, FetchId, CallId, Filtered) of @@ -206,14 +206,14 @@ do_process_route_req(Section, Node, FetchId, CallId, Props) -> maybe_start_call_handling(Node, FetchId, CallId, JObj) end. --spec maybe_start_call_handling(atom(), ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec maybe_start_call_handling(atom(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. maybe_start_call_handling(Node, FetchId, CallId, JObj) -> case kz_json:get_value(<<"Method">>, JObj) of <<"error">> -> lager:debug("sent error response to ~s, not starting call handling", [Node]); _Else -> start_call_handling(Node, FetchId, CallId, JObj) end. --spec start_call_handling(atom(), ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec start_call_handling(atom(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. start_call_handling(Node, FetchId, CallId, JObj) -> ServerQ = kz_json:get_value(<<"Server-ID">>, JObj), CCVs = diff --git a/applications/ecallmgr/src/ecallmgr_fs_router_text.erl b/applications/ecallmgr/src/ecallmgr_fs_router_text.erl index c94fd6c222e..e757942f0e7 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_router_text.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_router_text.erl @@ -28,7 +28,7 @@ -define(DEFAULT_BINDINGS, [?DEFAULT_FREESWITCH_CONTEXT]). -record(state, {node = 'undefined' :: atom() - ,options = [] :: kz_proplist() + ,options = [] :: kz_term:proplist() }). -type state() :: #state{}. @@ -39,8 +39,8 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(atom()) -> startlink_ret(). --spec start_link(atom(), kz_proplist()) -> startlink_ret(). +-spec start_link(atom()) -> kz_types:startlink_ret(). +-spec start_link(atom(), kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Node) -> start_link(Node, []). start_link(Node, Options) -> gen_server:start_link(?SERVER, [Node, Options], []). @@ -60,7 +60,7 @@ start_link(Node, Options) -> %% {stop, Reason} %% @end %%-------------------------------------------------------------------- --spec init([atom() | kz_proplist()]) -> {'ok', state()}. +-spec init([atom() | kz_term:proplist()]) -> {'ok', state()}. init([Node, Options]) -> process_flag('trap_exit', 'true'), kz_util:put_callid(Node), @@ -82,7 +82,7 @@ init([Node, Options]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -96,7 +96,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('bind_to_chatplan', #state{node=Node}=State) -> Bindings = ecallmgr_config:get_ne_binaries(?BINDINGS_CFG_KEY, ?DEFAULT_BINDINGS, Node), case ecallmgr_fs_router_util:register_bindings(Node, ?FETCH_SECTION, Bindings) of @@ -119,7 +119,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'route', Section, EventName, SubClass, Context, FSId, 'undefined', FSData}, State) -> MsgId = kz_binary:rand_hex(16), handle_info({'route', Section, EventName, SubClass, Context, FSId, MsgId, [{<<"Unique-ID">>, MsgId} | FSData]}, State); @@ -175,14 +175,14 @@ should_expand_var({<>, _}) -> 'true'; should_expand_var({<<"sip_", _/binary>>, _}) -> 'true'; should_expand_var(_) -> 'false'. --spec init_message_props(kz_proplist()) -> kz_proplist(). +-spec init_message_props(kz_term:proplist()) -> kz_term:proplist(). init_message_props(Props) -> Routines = [fun add_message_missing_props/1 ,fun expand_message_vars/1 ], lists:foldl(fun(F,P) -> F(P) end, Props, Routines). --spec add_message_missing_props(kz_proplist()) -> kz_proplist(). +-spec add_message_missing_props(kz_term:proplist()) -> kz_term:proplist(). add_message_missing_props(Props) -> props:insert_values([{<<"Call-Direction">>, <<"outbound">>} ,{<<"Resource-Type">>,<<"sms">>} @@ -193,26 +193,26 @@ add_message_missing_props(Props) -> ,Props ). --spec expand_message_vars(kz_proplist()) -> kz_proplist(). +-spec expand_message_vars(kz_term:proplist()) -> kz_term:proplist(). expand_message_vars(Props) -> lists:foldl(fun expand_message_var/2 ,Props ,props:filter(fun should_expand_var/1, Props) ). --spec expand_message_var({ne_binary(), ne_binary()}, kz_proplist()) -> - kz_proplist(). +-spec expand_message_var({kz_term:ne_binary(), kz_term:ne_binary()}, kz_term:proplist()) -> + kz_term:proplist(). expand_message_var({K,V}, Ac) -> case props:get_value(<<"variable_", K/binary>>, Ac) of 'undefined' -> props:set_value(<<"variable_", K/binary>>, V, Ac); _ -> Ac end. --spec process_route_req(atom(), atom(), ne_binary(), ne_binary(), kz_proplist()) -> 'ok'. +-spec process_route_req(atom(), atom(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. process_route_req(Section, Node, FetchId, MsgId, Props) -> do_process_route_req(Section, Node, FetchId, MsgId, init_message_props(Props)). --spec do_process_route_req(atom(), atom(), ne_binary(), ne_binary(), kz_proplist()) -> 'ok'. +-spec do_process_route_req(atom(), atom(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. do_process_route_req(Section, Node, FetchId, MsgId, Props) -> case ecallmgr_fs_router_util:search_for_route(Section, Node, FetchId, MsgId, Props) of 'ok' -> @@ -221,7 +221,7 @@ do_process_route_req(Section, Node, FetchId, MsgId, Props) -> start_message_handling(Node, FetchId, MsgId, JObj) end. --spec start_message_handling(atom(), ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec start_message_handling(atom(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. start_message_handling(_Node, FetchId, MsgId, JObj) -> ServerQ = kz_api:server_id(JObj), CCVs = kz_json:get_json_value(<<"Custom-Channel-Vars">>, JObj, kz_json:new()), diff --git a/applications/ecallmgr/src/ecallmgr_fs_router_util.erl b/applications/ecallmgr/src/ecallmgr_fs_router_util.erl index daf88e20aca..f878524e1f1 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_router_util.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_router_util.erl @@ -21,13 +21,13 @@ %%%=================================================================== -type search_ret() :: 'ok' | {'ok', kz_json:object()}. --spec search_for_route(atom(), atom(), ne_binary(), ne_binary(), kzd_freeswitch:data()) -> +-spec search_for_route(atom(), atom(), kz_term:ne_binary(), kz_term:ne_binary(), kzd_freeswitch:data()) -> search_ret(). search_for_route(Section, Node, FetchId, CallId, Props) -> Authz = ecallmgr_config:is_true(<<"authz_enabled">>, 'false'), search_for_route(Section, Node, FetchId, CallId, Props, Authz). --spec search_for_route(atom(), atom(), ne_binary(), ne_binary(), kzd_freeswitch:data(), boolean()) -> +-spec search_for_route(atom(), atom(), kz_term:ne_binary(), kz_term:ne_binary(), kzd_freeswitch:data(), boolean()) -> search_ret(). search_for_route(Section, Node, FetchId, CallId, Props, 'false') -> do_search_for_route(Section, Node, FetchId, CallId, Props, 'undefined'); @@ -36,7 +36,7 @@ search_for_route(Section, Node, FetchId, CallId, Props, 'true') -> lager:debug("authz worker in ~p", [AuthzWorker]), do_search_for_route(Section, Node, FetchId, CallId, Props, AuthzWorker). --spec do_search_for_route(atom(), atom(), ne_binary(), ne_binary(), kzd_freeswitch:data(), api_pid_ref()) -> +-spec do_search_for_route(atom(), atom(), kz_term:ne_binary(), kz_term:ne_binary(), kzd_freeswitch:data(), kz_term:api_pid_ref()) -> search_ret(). do_search_for_route(Section, Node, FetchId, CallId, Props, AuthzWorker) -> Request = route_req(CallId, FetchId, Props, Node), @@ -53,19 +53,19 @@ do_search_for_route(Section, Node, FetchId, CallId, Props, AuthzWorker) -> maybe_wait_for_authz(Section, Node, FetchId, CallId, JObj, Props, AuthzWorker) end. --spec spawn_authorize_call_fun(atom(), ne_binary(), kzd_freeswitch:data()) -> pid_ref(). +-spec spawn_authorize_call_fun(atom(), kz_term:ne_binary(), kzd_freeswitch:data()) -> kz_term:pid_ref(). spawn_authorize_call_fun(Node, CallId, Props) -> Ref = make_ref(), Pid = kz_util:spawn(fun authorize_call_fun/5, [self(), Ref, Node, CallId, Props]), {Pid, Ref}. --spec authorize_call_fun(pid(), reference(), atom(), ne_binary(), kzd_freeswitch:data()) -> +-spec authorize_call_fun(pid(), reference(), atom(), kz_term:ne_binary(), kzd_freeswitch:data()) -> {'authorize_reply', reference(), ecallmgr_fs_authz:authz_reply()}. authorize_call_fun(Parent, Ref, Node, CallId, Props) -> kz_util:put_callid(CallId), Parent ! {'authorize_reply', Ref, ecallmgr_fs_authz:authorize(Props, CallId, Node)}. --spec maybe_wait_for_authz(atom(), atom(), ne_binary(), ne_binary(), kz_json:object(), kz_proplist(), 'undefined' | pid_ref()) -> search_ret(). +-spec maybe_wait_for_authz(atom(), atom(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), kz_term:proplist(), 'undefined' | kz_term:pid_ref()) -> search_ret(). maybe_wait_for_authz(Section, Node, FetchId, CallId, JObj, Props, 'undefined') -> CCVs = kz_json:get_value(<<"Custom-Channel-Vars">>, JObj, kz_json:new()), J = kz_json:set_value(<<"Custom-Channel-Vars">> @@ -79,7 +79,7 @@ maybe_wait_for_authz(Section, Node, FetchId, CallId, JObj, Props, AuthzWorker) - 'false' -> reply_affirmative(Section, Node, FetchId, CallId, JObj, Props) end. --spec wait_for_authz(atom(), atom(), ne_binary(), ne_binary(), kz_json:object(), kz_proplist(), pid_ref()) -> search_ret(). +-spec wait_for_authz(atom(), atom(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), kz_term:proplist(), kz_term:pid_ref()) -> search_ret(). wait_for_authz(Section, Node, FetchId, CallId, JObj, Props, {Pid, Ref}) -> lager:info("waiting for authz reply from worker ~p", [Pid]), receive @@ -97,7 +97,7 @@ wait_for_authz(Section, Node, FetchId, CallId, JObj, Props, {Pid, Ref}) -> end. %% Reply with a 402 for unauthzed calls --spec reply_forbidden(atom(), atom(), ne_binary()) -> 'ok'. +-spec reply_forbidden(atom(), atom(), kz_term:ne_binary()) -> 'ok'. reply_forbidden(Section, Node, FetchId) -> lager:info("received forbidden route response for ~s, sending 403 Incoming call barred", [FetchId]), Props = [{<<"Method">>, <<"error">>} @@ -111,7 +111,7 @@ reply_forbidden(Section, Node, FetchId) -> {'error', Reason} -> lager:debug("node ~s rejected our ~s route unauthz: ~p", [Node, Section, Reason]) end. --spec reply_affirmative(atom(), atom(), ne_binary(), ne_binary(), kz_json:object(), kz_proplist()) -> search_ret(). +-spec reply_affirmative(atom(), atom(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), kz_term:proplist()) -> search_ret(). reply_affirmative(Section, Node, FetchId, _CallId, JObj, Props) -> lager:info("received affirmative route response for request ~s", [FetchId]), {'ok', XML} = route_resp_xml(Section, JObj, Props), @@ -132,7 +132,7 @@ route_resp_xml(Fun, Section, JObj, Props) route_resp_xml(_, Section, JObj, Props) -> ecallmgr_fs_xml:route_resp_xml(Section, JObj, Props). --spec route_req(ne_binary(), ne_binary(), kz_proplist(), atom()) -> kz_proplist(). +-spec route_req(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist(), atom()) -> kz_term:proplist(). route_req(CallId, FetchId, Props, Node) -> AccountId = kzd_freeswitch:account_id(Props), props:filter_empty( @@ -168,7 +168,7 @@ route_req(CallId, FetchId, Props, Node) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]). --spec route_req_ccvs(ne_binary(), kz_proplist()) -> kz_proplist(). +-spec route_req_ccvs(kz_term:ne_binary(), kz_term:proplist()) -> kz_term:proplist(). route_req_ccvs(FetchId, Props) -> {RedirectedBy, RedirectedReason} = get_redirected(Props), CCVs = ecallmgr_util:custom_channel_vars(Props), @@ -188,12 +188,12 @@ route_req_ccvs(FetchId, Props) -> %% check content-type and decode properly %% some sip clients send text/html with entities encoded %% some other use application/vnd.3gpp.sms --spec get_body(kz_proplist()) -> api_binary(). +-spec get_body(kz_term:proplist()) -> kz_term:api_binary(). get_body(Props) -> props:get_value(<<"body">>, Props). --spec get_redirected(kz_proplist()) -> - {api_binary(), api_binary()}. +-spec get_redirected(kz_term:proplist()) -> + {kz_term:api_binary(), kz_term:api_binary()}. get_redirected(Props) -> case props:get_value(<<"variable_last_bridge_hangup_cause">>, Props) of <<"REDIRECTION_TO_NEW_DESTINATION">> -> @@ -206,10 +206,10 @@ get_redirected(Props) -> _ -> {'undefined' , 'undefined'} end. --spec register_bindings(atom(), atom(), ne_binaries()) -> boolean(). +-spec register_bindings(atom(), atom(), kz_term:ne_binaries()) -> boolean(). register_bindings(Node, Section, Bindings) -> lists:all(fun(Binding) -> register_binding(Node, Section, Binding) end, Bindings). --spec register_binding(atom(), atom(), ne_binary()) -> boolean(). +-spec register_binding(atom(), atom(), kz_term:ne_binary()) -> boolean(). register_binding(Node, Section, Binding) -> gproc:reg({'p', 'l', ?FS_ROUTE_MSG(Node, Section, Binding)}) =:= 'true'. diff --git a/applications/ecallmgr/src/ecallmgr_fs_sup.erl b/applications/ecallmgr/src/ecallmgr_fs_sup.erl index 77f211070ee..a2c2773fcdc 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_sup.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_sup.erl @@ -34,17 +34,17 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec add_node(atom(), kz_proplist()) -> sup_startchild_ret(). +-spec add_node(atom(), kz_term:proplist()) -> kz_types:sup_startchild_ret(). add_node(Node, Options) -> Args = [Node, Options], ChildSpec = ?SUPER_NAME_ARGS_TYPE(Node, 'ecallmgr_fs_node_sup', Args, 'transient'), supervisor:start_child(?SERVER, ChildSpec). --spec find_node(atom()) -> api_pid(). +-spec find_node(atom()) -> kz_term:api_pid(). find_node(Node) -> find_node(supervisor:which_children(?SERVER), Node). @@ -70,7 +70,7 @@ remove_node(Node) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, diff --git a/applications/ecallmgr/src/ecallmgr_fs_xml.erl b/applications/ecallmgr/src/ecallmgr_fs_xml.erl index 219fe0024b7..5fe214510c3 100644 --- a/applications/ecallmgr/src/ecallmgr_fs_xml.erl +++ b/applications/ecallmgr/src/ecallmgr_fs_xml.erl @@ -58,15 +58,15 @@ sip_profiles_xml(JObj) -> {'ok', xmerl:export([SectionEl], 'fs_xml')}. --spec sip_channel_xml(kz_proplist()) -> {'ok', iolist()}. +-spec sip_channel_xml(kz_term:proplist()) -> {'ok', iolist()}. sip_channel_xml(Props) -> ParamsEl = params_el([param_el(K, V) || {K, V} <- Props]), ChannelEl = channel_el(props:get_value(<<"uuid">>, Props), ParamsEl), SectionEl = section_el(<<"channels">>, ChannelEl), {'ok', xmerl:export([SectionEl], 'fs_xml')}. --spec authn_resp_xml(api_terms()) -> {'ok', iolist()}. --spec authn_resp_xml(ne_binary(), kz_json:object()) -> {'ok', xml_els()}. +-spec authn_resp_xml(kz_term:api_terms()) -> {'ok', iolist()}. +-spec authn_resp_xml(kz_term:ne_binary(), kz_json:object()) -> {'ok', kz_types:xml_els()}. authn_resp_xml([_|_]=RespProp) -> authn_resp_xml(props:get_value(<<"Auth-Method">>, RespProp) ,kz_json:from_list(RespProp) @@ -122,9 +122,9 @@ authn_resp_xml(_Method, _JObj) -> lager:debug("unknown method ~s", [_Method]), empty_response(). --spec reverse_authn_resp_xml(api_terms()) -> {'ok', iolist()}. --spec reverse_authn_resp_xml(ne_binary(), kz_json:object()) -> - {'ok', xml_els()}. +-spec reverse_authn_resp_xml(kz_term:api_terms()) -> {'ok', iolist()}. +-spec reverse_authn_resp_xml(kz_term:ne_binary(), kz_json:object()) -> + {'ok', kz_types:xml_els()}. reverse_authn_resp_xml([_|_]=RespProp) -> reverse_authn_resp_xml(props:get_value(<<"Auth-Method">>, RespProp) ,kz_json:from_list(RespProp) @@ -159,7 +159,7 @@ reverse_authn_resp_xml(_Method, _JObj) -> empty_response() -> {'ok', ""}. %""). --spec conference_resp_xml(api_terms()) -> {'ok', iolist()}. +-spec conference_resp_xml(kz_term:api_terms()) -> {'ok', iolist()}. conference_resp_xml([_|_]=Resp) -> Ps = props:get_value(<<"Profiles">>, Resp, kz_json:new()), CCs = props:get_value(<<"Caller-Controls">>, Resp, kz_json:new()), @@ -218,7 +218,7 @@ conference_profile_xml(Name, Params) -> ParamEls = [param_el(K, V) || {K, V} <- kz_json:to_proplist(Params)], profile_el(Name, ParamEls). --spec route_resp_xml(atom(), api_terms(), kz_proplist()) -> {'ok', iolist()}. +-spec route_resp_xml(atom(), kz_term:api_terms(), kz_term:proplist()) -> {'ok', iolist()}. route_resp_xml(Section, [_|_]=RespProp, Props) -> route_resp_xml(Section, kz_json:from_list(RespProp), Props); route_resp_xml(Section, RespJObj, Props) -> route_resp_xml(kz_json:get_value(<<"Method">>, RespJObj) @@ -228,10 +228,10 @@ route_resp_xml(Section, RespJObj, Props) -> ). %% Prop = Route Response --type route_resp_fold_acc() :: {pos_integer(), xml_els()}. +-type route_resp_fold_acc() :: {pos_integer(), kz_types:xml_els()}. -spec route_resp_fold(kz_json:object(), route_resp_fold_acc()) -> route_resp_fold_acc(). --spec route_resp_fold(kz_json:object(), route_resp_fold_acc(), ne_binary()) -> +-spec route_resp_fold(kz_json:object(), route_resp_fold_acc(), kz_term:ne_binary()) -> route_resp_fold_acc(). route_resp_fold(RouteJObj, {Idx, Acc}) -> case ecallmgr_util:build_channel(RouteJObj) of @@ -269,7 +269,7 @@ should_bypass_media(RouteJObj) -> _ -> "false" %% default to not bypassing media end. --spec route_resp_xml(ne_binary(), kz_json:objects(), kz_json:object(), kz_proplist()) -> {'ok', iolist()}. +-spec route_resp_xml(kz_term:ne_binary(), kz_json:objects(), kz_json:object(), kz_term:proplist()) -> {'ok', iolist()}. route_resp_xml(<<"bridge">>, Routes, JObj, Props) -> lager:debug("creating a bridge XML response"), LogEl = route_resp_log_winning_node(), @@ -370,7 +370,7 @@ route_resp_bridge_id() -> Action = action_el(<<"export">>, [?SET_CCV(<<"Bridge-ID">>, <<"${UUID}">>)], 'true'), condition_el(Action, ?GET_CCV(<<"Bridge-ID">>), <<"^$">>). --spec unset_custom_sip_headers(kz_proplist()) -> xml_els(). +-spec unset_custom_sip_headers(kz_term:proplist()) -> kz_types:xml_els(). unset_custom_sip_headers(Props) -> case get_custom_sip_headers(Props) of [] -> []; @@ -386,14 +386,14 @@ not_found() -> SectionEl = section_el(<<"result">>, <<"Route Not Found">>, ResultEl), {'ok', xmerl:export([SectionEl], 'fs_xml')}. --spec route_resp_log_winning_node() -> xml_el(). +-spec route_resp_log_winning_node() -> kz_types:xml_el(). route_resp_log_winning_node() -> action_el(<<"log">>, [<<"NOTICE log|${uuid}|", (kz_term:to_binary(node()))/binary, " won call control">>]). route_resp_set_winning_node() -> action_el(<<"export">>, [?SET_CCV(<<"Ecallmgr-Node">>, (kz_term:to_binary(node())))]). --spec route_resp_ringback(kz_json:object()) -> xml_el(). +-spec route_resp_ringback(kz_json:object()) -> kz_types:xml_el(). route_resp_ringback(JObj) -> case kz_json:get_value(<<"Ringback-Media">>, JObj) of 'undefined' -> @@ -405,35 +405,35 @@ route_resp_ringback(JObj) -> action_el(<<"set">>, <<"ringback=", (kz_term:to_binary(Stream))/binary>>) end. --spec route_resp_ccvs(kz_json:object()) -> xml_els(). +-spec route_resp_ccvs(kz_json:object()) -> kz_types:xml_els(). route_resp_ccvs(JObj) -> case kz_json:get_json_value(<<"Custom-Channel-Vars">>, JObj) of 'undefined' -> []; CCVs -> [action_el(<<"kz_multiset">>, route_ccvs_list(kz_json:to_proplist(CCVs)))] end. --spec route_resp_cavs(kz_json:object()) -> xml_els(). +-spec route_resp_cavs(kz_json:object()) -> kz_types:xml_els(). route_resp_cavs(JObj) -> case kz_json:get_json_value(<<"Custom-Application-Vars">>, JObj) of 'undefined' -> []; CAVs -> [action_el(<<"kz_multiset">>, route_cavs_list(kz_json:to_proplist(CAVs)))] end. --spec route_ccvs_list(kz_proplist()) -> ne_binary(). +-spec route_ccvs_list(kz_term:proplist()) -> kz_term:ne_binary(). route_ccvs_list(CCVs) -> L = [kz_term:to_list(ecallmgr_util:get_fs_kv(K, V)) || {K, V} <- CCVs ], <<"^^|", (kz_term:to_binary(string:join(L, "|")))/binary>>. --spec route_cavs_list(kz_proplist()) -> ne_binary(). +-spec route_cavs_list(kz_term:proplist()) -> kz_term:ne_binary(). route_cavs_list(CAVs) -> L = [kz_term:to_list(ecallmgr_util:get_fs_kv(?CAV(K), V)) || {K, V} <- CAVs ], <<"^^|", (kz_term:to_binary(string:join(L, "|")))/binary>>. --spec route_resp_transfer_ringback(kz_json:object()) -> xml_el(). +-spec route_resp_transfer_ringback(kz_json:object()) -> kz_types:xml_el(). route_resp_transfer_ringback(JObj) -> case kz_json:get_value(<<"Transfer-Media">>, JObj) of 'undefined' -> @@ -445,7 +445,7 @@ route_resp_transfer_ringback(JObj) -> action_el(<<"set">>, <<"transfer_ringback=", (kz_term:to_binary(Stream))/binary>>) end. --spec route_resp_pre_park_action(kz_json:object()) -> 'undefined' | xml_el(). +-spec route_resp_pre_park_action(kz_json:object()) -> 'undefined' | kz_types:xml_el(). route_resp_pre_park_action(JObj) -> case kz_json:get_value(<<"Pre-Park">>, JObj) of <<"ring_ready">> -> action_el(<<"ring_ready">>); @@ -453,21 +453,21 @@ route_resp_pre_park_action(JObj) -> _Else -> 'undefined' end. --spec maybe_start_dtmf_action(kz_proplist()) -> 'undefined' | xml_el(). +-spec maybe_start_dtmf_action(kz_term:proplist()) -> 'undefined' | kz_types:xml_el(). maybe_start_dtmf_action(Props) -> case ecallmgr_config:is_true(<<"should_detect_inband_dtmf">>) of 'false' -> 'undefined'; 'true' -> check_dtmf_type(Props) end. --spec check_dtmf_type(kz_proplist()) -> 'undefined' | xml_el(). +-spec check_dtmf_type(kz_term:proplist()) -> 'undefined' | kz_types:xml_el(). check_dtmf_type(Props) -> case props:get_value(<<"variable_switch_r_sdp">>, Props, <<"101 telephone-event">>) of <<"101 telephone-event">> -> 'undefined'; _ -> action_el(<<"start_dtmf">>) end. --spec get_leg_vars(kz_json:object() | kz_proplist()) -> iolist(). +-spec get_leg_vars(kz_json:object() | kz_term:proplist()) -> iolist(). get_leg_vars([]) -> []; get_leg_vars([_|_]=Prop) -> ["[^^", ?BRIDGE_CHANNEL_VAR_SEPARATOR @@ -479,14 +479,14 @@ get_leg_vars([_|_]=Prop) -> ]; get_leg_vars(JObj) -> get_leg_vars(kz_json:to_proplist(JObj)). --spec get_channel_vars(kz_json:object() | kz_proplist()) -> iolist(). +-spec get_channel_vars(kz_json:object() | kz_term:proplist()) -> iolist(). get_channel_vars([]) -> []; get_channel_vars([_|_]=Prop) -> P = Prop ++ [{<<"Overwrite-Channel-Vars">>, <<"true">>}], ["{", string:join([kz_term:to_list(V) || V <- lists:foldr(fun get_channel_vars/2, [], P)], ","), "}"]; get_channel_vars(JObj) -> get_channel_vars(kz_json:to_proplist(JObj)). --spec get_channel_vars({binary(), binary() | kz_json:object()}, ne_binaries()) -> iolist(). +-spec get_channel_vars({binary(), binary() | kz_json:object()}, kz_term:ne_binaries()) -> iolist(). get_channel_vars({<<"Custom-Channel-Vars">>, JObj}, Vars) -> kz_json:foldl(fun get_channel_vars_fold/3, Vars, JObj); @@ -594,15 +594,15 @@ sip_headers_fold(K, V, Vars0) -> ])). -define(EXPANDABLE_MACROS, ecallmgr_config:get_json(<<"expandable_macros">>, ?DEFAULT_EXPANDABLE_MACROS)). --spec maybe_expand_macro(ne_binary()) -> ne_binary(). +-spec maybe_expand_macro(kz_term:ne_binary()) -> kz_term:ne_binary(). maybe_expand_macro(HeaderValue) -> kz_json:get_ne_binary_value(HeaderValue, ?EXPANDABLE_MACROS, HeaderValue). --spec diversion_headers_fold(ne_binaries(), iolist()) -> iolist(). +-spec diversion_headers_fold(kz_term:ne_binaries(), iolist()) -> iolist(). diversion_headers_fold(Vs, Vars0) -> lists:foldl(fun diversion_header_fold/2, Vars0, Vs). --spec diversion_header_fold(ne_binary(), iolist()) -> iolist(). +-spec diversion_header_fold(kz_term:ne_binary(), iolist()) -> iolist(). diversion_header_fold(<<_/binary>> = V, Vars0) -> lager:debug("setting diversion ~s on the channel", [V]), [list_to_binary(["sip_h_Diversion=", V]) | Vars0]. @@ -635,7 +635,7 @@ get_application_vars_fold(K, V, Acc) -> | Acc ]. --spec codec_mappings(ne_binary()) -> ne_binary(). +-spec codec_mappings(kz_term:ne_binary()) -> kz_term:ne_binary(). codec_mappings(<<"G722_32">>) -> <<"G7221@32000h">>; codec_mappings(<<"G722_16">>) -> @@ -650,13 +650,13 @@ codec_mappings(Codec) -> encode_fs_val(Prefix, V) -> list_to_binary([Prefix, "='", escape(V, $\'), "'"]). --spec escape(text(), char()) -> ne_binary(). +-spec escape(kz_term:text(), char()) -> kz_term:ne_binary(). escape(V, C) -> iolist_to_binary([encode(A, C) || <> <= kz_term:to_binary(V)]). encode(C, C) -> [$\\, C]; encode(C, _) -> C. --spec get_channel_params(kz_json:object() | kz_proplist()) -> kz_proplist(). +-spec get_channel_params(kz_json:object() | kz_term:proplist()) -> kz_term:proplist(). get_channel_params(Props) when is_list(Props) -> [get_channel_params_fold(K, V) || {K, V} <- Props]; get_channel_params(JObj) -> @@ -665,8 +665,8 @@ get_channel_params(JObj) -> kz_json:get_value(<<"Custom-Channel-Vars">>, JObj, kz_json:new()) )). --spec get_channel_params_fold(ne_binary(), ne_binary()) -> - {ne_binary(), ne_binary()}. +-spec get_channel_params_fold(kz_term:ne_binary(), kz_term:ne_binary()) -> + {kz_term:ne_binary(), kz_term:ne_binary()}. get_channel_params_fold(Key, Val) -> case lists:keyfind(Key, 1, ?SPECIAL_CHANNEL_VARS) of 'false' -> @@ -675,7 +675,7 @@ get_channel_params_fold(Key, Val) -> {Prefix, ecallmgr_util:maybe_sanitize_fs_value(Key, Val)} end. --spec get_custom_sip_headers(kz_json:object() | kz_proplist()) -> kz_json:json_proplist(). +-spec get_custom_sip_headers(kz_json:object() | kz_term:proplist()) -> kz_json:json_proplist(). get_custom_sip_headers([_|_]=Props) -> [normalize_custom_sip_header_name(P) || P <- props:filter(fun is_custom_sip_header/1, Props)]; get_custom_sip_headers(JObj) -> @@ -689,7 +689,7 @@ normalize_custom_sip_header_name(A) -> A. is_custom_sip_header({<<"variable_sip_h_X-", _/binary>>, _}) -> 'true'; is_custom_sip_header(_) -> 'false'. --spec arrange_acl_node({ne_binary(), kz_json:object()}, orddict:orddict()) -> orddict:orddict(). +-spec arrange_acl_node({kz_term:ne_binary(), kz_json:object()}, orddict:orddict()) -> orddict:orddict(). arrange_acl_node({_, JObj}, Dict) -> AclList = kz_json:get_value(<<"network-list-name">>, JObj), @@ -704,22 +704,22 @@ arrange_acl_node({_, JObj}, Dict) -> orddict:store(AclList, prepend_child(acl_list_el(AclList), NodeEl), Dict) end. --spec hunt_context(kz_proplist()) -> api_binary(). +-spec hunt_context(kz_term:proplist()) -> kz_term:api_binary(). hunt_context(Props) -> props:get_value(<<"Hunt-Context">>, Props, ?DEFAULT_FREESWITCH_CONTEXT). --spec context(kz_json:object()) -> api_binary(). +-spec context(kz_json:object()) -> kz_term:api_binary(). context(JObj) -> kz_json:get_value(<<"Context">>, JObj, ?DEFAULT_FREESWITCH_CONTEXT). --spec context(kz_json:object(), kz_proplist()) -> api_binary(). +-spec context(kz_json:object(), kz_term:proplist()) -> kz_term:api_binary(). context(JObj, Props) -> kz_json:get_value(<<"Context">>, JObj, hunt_context(Props)). %%%------------------------------------------------------------------- %% XML record creators and helpers %%%------------------------------------------------------------------- --spec acl_node_el(xml_attrib_value(), xml_attrib_value()) -> xml_el(). +-spec acl_node_el(kz_types:xml_attrib_value(), kz_types:xml_attrib_value()) -> kz_types:xml_el(). acl_node_el(Type, CIDR) -> #xmlElement{name='node' ,attributes=[xml_attrib('type', Type) @@ -727,9 +727,9 @@ acl_node_el(Type, CIDR) -> ] }. --spec acl_list_el(xml_attrib_value()) -> xml_el(). --spec acl_list_el(xml_attrib_value(), xml_attrib_value()) -> xml_el(). --spec acl_list_el(xml_attrib_value(), xml_attrib_value(), xml_els()) -> xml_el(). +-spec acl_list_el(kz_types:xml_attrib_value()) -> kz_types:xml_el(). +-spec acl_list_el(kz_types:xml_attrib_value(), kz_types:xml_attrib_value()) -> kz_types:xml_el(). +-spec acl_list_el(kz_types:xml_attrib_value(), kz_types:xml_attrib_value(), kz_types:xml_els()) -> kz_types:xml_el(). acl_list_el(Name) -> acl_list_el(Name, <<"deny">>). acl_list_el(Name, Default) -> @@ -742,15 +742,15 @@ acl_list_el(Name, Default, Children) -> ,content=Children }. --spec network_list_el(xml_els()) -> xml_el(). +-spec network_list_el(kz_types:xml_els()) -> kz_types:xml_el(). network_list_el(ListsEls) -> #xmlElement{name='network-lists', content=ListsEls}. --spec config_el(ne_binary(), xml_el() | xml_els()) -> xml_el() | xml_els(). +-spec config_el(kz_term:ne_binary(), kz_types:xml_el() | kz_types:xml_els()) -> kz_types:xml_el() | kz_types:xml_els(). config_el(Name, Content) -> config_el(Name, <<"configuration ", (kz_term:to_binary(Name))/binary, " built by kazoo">>, Content). --spec config_el(ne_binary(), ne_binary(), xml_el() | xml_els()) -> xml_el() | xml_els(). +-spec config_el(kz_term:ne_binary(), kz_term:ne_binary(), kz_types:xml_el() | kz_types:xml_els()) -> kz_types:xml_el() | kz_types:xml_els(). config_el(Name, Desc, #xmlElement{}=Content) -> config_el(Name, Desc, [Content]); config_el(Name, Desc, Content) -> @@ -761,12 +761,12 @@ config_el(Name, Desc, Content) -> ,content=Content }. --spec channel_el(api_binary(), xml_el() | xml_els()) -> xml_el() | xml_els(). +-spec channel_el(kz_term:api_binary(), kz_types:xml_el() | kz_types:xml_els()) -> kz_types:xml_el() | kz_types:xml_els(). channel_el('undefined', Content) -> Content; channel_el(UUID, Content) -> channel_el(UUID, <<"channel ", (kz_term:to_binary(UUID))/binary, " tracked by kazoo">>, Content). --spec channel_el(ne_binary(), ne_binary(), xml_el() | xml_els()) -> xml_el(). +-spec channel_el(kz_term:ne_binary(), kz_term:ne_binary(), kz_types:xml_el() | kz_types:xml_els()) -> kz_types:xml_el(). channel_el(UUID, Desc, #xmlElement{}=Content) -> channel_el(UUID, Desc, [Content]); channel_el(UUID, Desc, Content) -> @@ -777,8 +777,8 @@ channel_el(UUID, Desc, Content) -> ,content=Content }. --spec section_el(xml_attrib_value(), xml_el() | xml_els()) -> xml_el(). --spec section_el(xml_attrib_value(), xml_attrib_value(), xml_el() | xml_els()) -> xml_el(). +-spec section_el(kz_types:xml_attrib_value(), kz_types:xml_el() | kz_types:xml_els()) -> kz_types:xml_el(). +-spec section_el(kz_types:xml_attrib_value(), kz_types:xml_attrib_value(), kz_types:xml_el() | kz_types:xml_els()) -> kz_types:xml_el(). section_el(Name, #xmlElement{}=Content) -> section_el(Name, [Content]); section_el(Name, Content) -> @@ -797,7 +797,7 @@ section_el(Name, Desc, Content) -> ,content=Content }. --spec domain_el(xml_attrib_value(), xml_el() | xml_els()) -> xml_el(). +-spec domain_el(kz_types:xml_attrib_value(), kz_types:xml_el() | kz_types:xml_els()) -> kz_types:xml_el(). domain_el(Name, Child) when not is_list(Child) -> domain_el(Name, [Child]); domain_el(Name, Children) -> @@ -806,7 +806,7 @@ domain_el(Name, Children) -> ,content=Children }. --spec user_el(xml_attrib_value() | kz_proplist(), xml_els()) -> xml_el(). +-spec user_el(kz_types:xml_attrib_value() | kz_term:proplist(), kz_types:xml_els()) -> kz_types:xml_el(). user_el(Id, Children) when not is_list(Id) -> user_el(user_el_default_props(Id), Children); user_el(Props, Children) -> @@ -819,7 +819,7 @@ user_el(Props, Children) -> ,content=Children }. --spec user_el_props(ne_binary(), ne_binary(), api_integer()) -> kz_proplist(). +-spec user_el_props(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_integer()) -> kz_term:proplist(). user_el_props(Number, Username, 'undefined') -> [{'number-alias', Number} ,{'cacheable', ecallmgr_config:get_integer(<<"user_cache_time_in_ms">> @@ -838,11 +838,11 @@ user_el_props(Number, Username, Expires) -> | user_el_default_props(Username) ]. --spec user_el_default_props(xml_attrib_value()) -> kz_proplist(). +-spec user_el_default_props(kz_types:xml_attrib_value()) -> kz_term:proplist(). user_el_default_props(Id) -> [{'id', Id}]. --spec chat_user_el(xml_attrib_value(), xml_attrib_value()) -> xml_el(). +-spec chat_user_el(kz_types:xml_attrib_value(), kz_types:xml_attrib_value()) -> kz_types:xml_el(). chat_user_el(Name, Commands) -> #xmlElement{name='user' ,attributes=[xml_attrib('name', Name) @@ -850,13 +850,13 @@ chat_user_el(Name, Commands) -> ] }. --spec params_el(xml_els()) -> xml_el(). +-spec params_el(kz_types:xml_els()) -> kz_types:xml_el(). params_el(Children) -> #xmlElement{name='params' ,content=Children }. --spec param_el(xml_attrib_value(), xml_attrib_value()) -> xml_el(). +-spec param_el(kz_types:xml_attrib_value(), kz_types:xml_attrib_value()) -> kz_types:xml_el(). param_el(<<"moh-sound">> = Name, MediaName) -> Value = ecallmgr_util:media_path(MediaName, kz_util:get_callid(), kz_json:new()), #xmlElement{name='param' @@ -878,7 +878,7 @@ param_el(Name, Value) -> ] }. --spec maybe_param_el(xml_attrib_value(), xml_attrib_value()) -> xml_el() | 'undefined'. +-spec maybe_param_el(kz_types:xml_attrib_value(), kz_types:xml_attrib_value()) -> kz_types:xml_el() | 'undefined'. maybe_param_el(Name, Value) -> case kz_term:is_empty(Value) of 'true' -> 'undefined'; @@ -933,13 +933,13 @@ chat_permissions_el(Profiles) -> ,content=Profiles }. --spec variables_el(xml_els()) -> xml_el(). +-spec variables_el(kz_types:xml_els()) -> kz_types:xml_el(). variables_el(Children) -> #xmlElement{name='variables' ,content=Children }. --spec variable_el(xml_attrib_value(), xml_attrib_value()) -> xml_el(). +-spec variable_el(kz_types:xml_attrib_value(), kz_types:xml_attrib_value()) -> kz_types:xml_el(). variable_el(Name, Value) -> #xmlElement{name='variable' ,attributes=[xml_attrib('name', Name) @@ -947,13 +947,13 @@ variable_el(Name, Value) -> ] }. --spec registration_headers_el(xml_els()) -> xml_el(). +-spec registration_headers_el(kz_types:xml_els()) -> kz_types:xml_el(). registration_headers_el(Children) -> #xmlElement{name='registration-headers' ,content=Children }. --spec header_el(xml_attrib_value(), xml_attrib_value()) -> xml_el(). +-spec header_el(kz_types:xml_attrib_value(), kz_types:xml_attrib_value()) -> kz_types:xml_el(). header_el(Name, Value) -> #xmlElement{name='header' ,attributes=[xml_attrib('name', Name) @@ -961,15 +961,15 @@ header_el(Name, Value) -> ] }. --spec context_el(xml_attrib_value(), xml_els()) -> xml_el(). +-spec context_el(kz_types:xml_attrib_value(), kz_types:xml_els()) -> kz_types:xml_el(). context_el(Name, Children) -> #xmlElement{name='context' ,attributes=[xml_attrib('name', Name)] ,content=Children }. --spec extension_el(xml_els()) -> xml_el(). --spec extension_el(xml_attrib_value(), xml_attrib_value() | 'undefined', xml_els()) -> xml_el(). +-spec extension_el(kz_types:xml_els()) -> kz_types:xml_el(). +-spec extension_el(kz_types:xml_attrib_value(), kz_types:xml_attrib_value() | 'undefined', kz_types:xml_els()) -> kz_types:xml_el(). extension_el(Children) -> #xmlElement{name='extension' ,content=Children @@ -988,7 +988,7 @@ extension_el(Name, Continue, Children) -> ,content=[Child || Child <- Children, Child =/= 'undefined'] }. --spec condition_el(xml_el() | xml_els() | 'undefined') -> xml_el(). +-spec condition_el(kz_types:xml_el() | kz_types:xml_els() | 'undefined') -> kz_types:xml_el(). condition_el(Child) when not is_list(Child) -> condition_el([Child]); condition_el(Children) -> @@ -996,7 +996,7 @@ condition_el(Children) -> ,content=[Child || Child <- Children, Child =/= 'undefined'] }. --spec condition_el(xml_el() | xml_els() | 'undefined', xml_attrib_value(), xml_attrib_value()) -> xml_el(). +-spec condition_el(kz_types:xml_el() | kz_types:xml_els() | 'undefined', kz_types:xml_attrib_value(), kz_types:xml_attrib_value()) -> kz_types:xml_el(). condition_el(Child, Field, Expression) when not is_list(Child) -> condition_el([Child], Field, Expression); condition_el(Children, Field, Expression) -> @@ -1007,9 +1007,9 @@ condition_el(Children, Field, Expression) -> ] }. --spec action_el(xml_attrib_value()) -> xml_el(). --spec action_el(xml_attrib_value(), xml_attrib_value()) -> xml_el(). --spec action_el(xml_attrib_value(), xml_attrib_value(), boolean()) -> xml_el(). +-spec action_el(kz_types:xml_attrib_value()) -> kz_types:xml_el(). +-spec action_el(kz_types:xml_attrib_value(), kz_types:xml_attrib_value()) -> kz_types:xml_el(). +-spec action_el(kz_types:xml_attrib_value(), kz_types:xml_attrib_value(), boolean()) -> kz_types:xml_el(). action_el(App) -> #xmlElement{name='action' ,attributes=[xml_attrib('application', App)] @@ -1028,7 +1028,7 @@ action_el(App, Data, Inline) -> ] }. --spec result_el(xml_attrib_value()) -> xml_el(). +-spec result_el(kz_types:xml_attrib_value()) -> kz_types:xml_el(). result_el(Status) -> #xmlElement{name='result' ,attributes=[xml_attrib('status', Status)] @@ -1041,11 +1041,11 @@ room_el(Name, Status) -> ] }. --spec prepend_child(xml_el(), xml_el()) -> xml_el(). +-spec prepend_child(kz_types:xml_el(), kz_types:xml_el()) -> kz_types:xml_el(). prepend_child(#xmlElement{content=Contents}=El, Child) -> El#xmlElement{content=[Child|Contents]}. --spec xml_attrib(xml_attrib_name(), xml_attrib_value()) -> xml_attrib(). +-spec xml_attrib(kz_types:xml_attrib_name(), kz_types:xml_attrib_value()) -> kz_types:xml_attrib(). xml_attrib(Name, Value) when is_atom(Name) -> #xmlAttribute{name=Name, value=kz_term:to_list(Value)}. @@ -1129,7 +1129,7 @@ sofia_gateway_vars_el(JObj) -> ] end, [], kz_json:get_keys(JObj)). --spec sofia_gateways_xml_to_json(xml_el() | xml_els()) -> kz_json:object(). +-spec sofia_gateways_xml_to_json(kz_types:xml_el() | kz_types:xml_els()) -> kz_json:object(). sofia_gateways_xml_to_json(Xml) -> lists:foldl(fun sofia_gateway_xml_to_json/2 ,kz_json:new() @@ -1157,7 +1157,7 @@ sofia_gateway_xml_to_json(Xml, JObj) -> ], kz_json:set_value(Id, kz_json:from_list(Props), JObj). --spec sofia_gateway_vars_xml_to_json(xml_el() | xml_els(), kz_json:object()) -> kz_json:object(). +-spec sofia_gateway_vars_xml_to_json(kz_types:xml_el() | kz_types:xml_els(), kz_json:object()) -> kz_json:object(). sofia_gateway_vars_xml_to_json(#xmlElement{}=Xml, JObj) -> sofia_gateway_vars_xml_to_json([Xml], JObj); sofia_gateway_vars_xml_to_json([], JObj) -> @@ -1167,7 +1167,7 @@ sofia_gateway_vars_xml_to_json([Var|Vars], JObj) -> Value = kz_xml:get_value("/variable/@value", Var), sofia_gateway_vars_xml_to_json(Vars, kz_json:set_value(Key, Value, JObj)). --spec event_filters_resp_xml(ne_binaries()) -> {'ok', iolist()}. +-spec event_filters_resp_xml(kz_term:ne_binaries()) -> {'ok', iolist()}. event_filters_resp_xml(Headers) -> EventFiltersEl = event_filters_xml(Headers), ConfigurationEl = config_el(<<"kazoo.conf">>, <<"Built by Kazoo">>, [EventFiltersEl]), diff --git a/applications/ecallmgr/src/ecallmgr_maintenance.erl b/applications/ecallmgr/src/ecallmgr_maintenance.erl index 51f251e1a5f..94b909d0a8a 100644 --- a/applications/ecallmgr/src/ecallmgr_maintenance.erl +++ b/applications/ecallmgr/src/ecallmgr_maintenance.erl @@ -104,12 +104,12 @@ -include("ecallmgr.hrl"). --spec add_fs_node(text()) -> 'ok'. +-spec add_fs_node(kz_term:text()) -> 'ok'. add_fs_node(FSNode) -> FSNodes = get_fs_nodes(node()), add_fs_node(FSNode, FSNodes, fun ecallmgr_config:set/2). --spec add_fs_node(text(), text() | boolean()) -> 'ok'. +-spec add_fs_node(kz_term:text(), kz_term:text() | boolean()) -> 'ok'. add_fs_node(FSNode, AsDefault) when not is_boolean(AsDefault) -> add_fs_node(FSNode, kz_term:is_true(AsDefault)); add_fs_node(FSNode, 'true') -> @@ -119,12 +119,12 @@ add_fs_node(FSNode, 'false') -> FSNodes = get_fs_nodes(node()), add_fs_node(FSNode, FSNodes, fun ecallmgr_config:set_node/2). --spec remove_fs_node(text() | atom()) -> 'ok'. +-spec remove_fs_node(kz_term:text() | atom()) -> 'ok'. remove_fs_node(FSNode) -> FSNodes = get_fs_nodes(node()), remove_fs_node(FSNode, FSNodes, fun ecallmgr_config:set/2). --spec remove_fs_node(text(), text() | boolean()) -> 'ok'. +-spec remove_fs_node(kz_term:text(), kz_term:text() | boolean()) -> 'ok'. remove_fs_node(FSNode, AsDefault) when not is_boolean(AsDefault) -> remove_fs_node(FSNode, kz_term:is_true(AsDefault)); remove_fs_node(FSNode, 'true') -> @@ -147,7 +147,7 @@ get_fs_nodes() -> -spec carrier_acls() -> 'no_return'. carrier_acls() -> carrier_acls('false'). --spec carrier_acls(boolean() | text()) -> 'no_return'. +-spec carrier_acls(boolean() | kz_term:text()) -> 'no_return'. carrier_acls(AsDefault) when not is_boolean(AsDefault) -> carrier_acls(kz_term:is_true(AsDefault)); carrier_acls('true') -> @@ -155,8 +155,8 @@ carrier_acls('true') -> carrier_acls('false') -> list_acls(get_acls(), ?FS_CARRIER_ACL_LIST). --spec test_carrier_ip(ne_binary()) -> 'ok'. --spec test_carrier_ip(ne_binary(), ne_binary() | ne_binaries()) -> 'ok'. +-spec test_carrier_ip(kz_term:ne_binary()) -> 'ok'. +-spec test_carrier_ip(kz_term:ne_binary(), kz_term:ne_binary() | kz_term:ne_binaries()) -> 'ok'. test_carrier_ip(IP) -> Nodes = ecallmgr_fs_nodes:connected(), test_carrier_ip(IP, Nodes). @@ -168,13 +168,13 @@ test_carrier_ip(IP, [Node|Nodes]) -> test_carrier_ip(IP, Node) -> test_ip_against_acl(IP, Node, ?FS_CARRIER_ACL_LIST). --spec allow_carrier(ne_binary()) -> 'no_return'. +-spec allow_carrier(kz_term:ne_binary()) -> 'no_return'. allow_carrier(Name) -> allow_carrier(Name, Name, 'false'). --spec allow_carrier(ne_binary(), ne_binary()) -> 'no_return'. +-spec allow_carrier(kz_term:ne_binary(), kz_term:ne_binary()) -> 'no_return'. allow_carrier(Name, IP) -> allow_carrier(Name, IP, 'false'). --spec allow_carrier(ne_binary(), ne_binary(), boolean() | text()) -> 'no_return'. +-spec allow_carrier(kz_term:ne_binary(), kz_term:ne_binary(), boolean() | kz_term:text()) -> 'no_return'. allow_carrier(Name, IP, AsDefault) when not is_boolean(AsDefault) -> allow_carrier(Name, IP, kz_term:is_true(AsDefault)); allow_carrier(Name, IP0, 'true') -> @@ -194,13 +194,13 @@ allow_carrier(Name, IP0, 'false') -> ,fun ecallmgr_config:set_node/2 ). --spec deny_carrier(ne_binary()) -> 'no_return'. +-spec deny_carrier(kz_term:ne_binary()) -> 'no_return'. deny_carrier(Name) -> deny_carrier(Name, Name, 'false'). --spec deny_carrier(ne_binary(), ne_binary()) -> 'no_return'. +-spec deny_carrier(kz_term:ne_binary(), kz_term:ne_binary()) -> 'no_return'. deny_carrier(Name, IP) -> deny_carrier(Name, IP, 'false'). --spec deny_carrier(ne_binary(), ne_binary(), boolean() | text()) -> 'no_return'. +-spec deny_carrier(kz_term:ne_binary(), kz_term:ne_binary(), boolean() | kz_term:text()) -> 'no_return'. deny_carrier(Name, IP, AsDefault) when not is_boolean(AsDefault) -> deny_carrier(Name, IP, kz_term:is_true(AsDefault)); deny_carrier(Name, IP0, 'true') -> @@ -223,7 +223,7 @@ deny_carrier(Name, IP0, 'false') -> -spec sbc_acls() -> 'no_return'. sbc_acls() -> sbc_acls('false'). --spec sbc_acls(boolean() | text()) -> 'no_return'. +-spec sbc_acls(boolean() | kz_term:text()) -> 'no_return'. sbc_acls(AsDefault) when not is_boolean(AsDefault) -> sbc_acls(kz_term:is_true(AsDefault)); sbc_acls('true') -> @@ -231,8 +231,8 @@ sbc_acls('true') -> sbc_acls('false') -> list_acls(get_acls(), ?FS_SBC_ACL_LIST). --spec test_sbc_ip(ne_binary()) -> 'ok'. --spec test_sbc_ip(ne_binary(), ne_binary() | ne_binaries()) -> 'ok'. +-spec test_sbc_ip(kz_term:ne_binary()) -> 'ok'. +-spec test_sbc_ip(kz_term:ne_binary(), kz_term:ne_binary() | kz_term:ne_binaries()) -> 'ok'. test_sbc_ip(IP) -> Nodes = ecallmgr_fs_nodes:connected(), test_sbc_ip(IP, Nodes). @@ -244,13 +244,13 @@ test_sbc_ip(IP, [Node|Nodes]) -> test_sbc_ip(IP, Node) -> test_ip_against_acl(IP, Node, ?FS_SBC_ACL_LIST). --spec allow_sbc(ne_binary()) -> 'no_return'. +-spec allow_sbc(kz_term:ne_binary()) -> 'no_return'. allow_sbc(Name) -> allow_sbc(Name, Name, 'false'). --spec allow_sbc(ne_binary(), ne_binary()) -> 'no_return'. +-spec allow_sbc(kz_term:ne_binary(), kz_term:ne_binary()) -> 'no_return'. allow_sbc(Name, IP) -> allow_sbc(Name, IP, 'false'). --spec allow_sbc(ne_binary(), ne_binary(), boolean() | text()) -> 'no_return'. +-spec allow_sbc(kz_term:ne_binary(), kz_term:ne_binary(), boolean() | kz_term:text()) -> 'no_return'. allow_sbc(Name, IP, AsDefault) when not is_boolean(AsDefault) -> allow_sbc(Name, IP, kz_term:is_true(AsDefault)); allow_sbc(Name, IP0, 'true') -> @@ -270,13 +270,13 @@ allow_sbc(Name, IP0, 'false') -> ,fun ecallmgr_config:set_node/2 ). --spec deny_sbc(ne_binary()) -> 'no_return'. +-spec deny_sbc(kz_term:ne_binary()) -> 'no_return'. deny_sbc(Name) -> deny_sbc(Name, Name, 'false'). --spec deny_sbc(ne_binary(), ne_binary()) -> 'no_return'. +-spec deny_sbc(kz_term:ne_binary(), kz_term:ne_binary()) -> 'no_return'. deny_sbc(Name, IP) -> deny_sbc(Name, IP, 'false'). --spec deny_sbc(ne_binary(), ne_binary(), boolean() | text()) -> 'no_return'. +-spec deny_sbc(kz_term:ne_binary(), kz_term:ne_binary(), boolean() | kz_term:text()) -> 'no_return'. deny_sbc(Name, IP, AsDefault) when not is_boolean(AsDefault) -> deny_sbc(Name, IP, kz_term:is_true(AsDefault)); deny_sbc(Name, IP0, 'true') -> @@ -300,7 +300,7 @@ deny_sbc(Name, IP0, 'false') -> acl_summary() -> list_acls(get_acls(), 'undefined'). --spec acl_summary(api_binary() | boolean()) -> 'no_return'. +-spec acl_summary(kz_term:api_binary() | boolean()) -> 'no_return'. acl_summary(AsDefault) when not is_boolean(AsDefault) -> acl_summary(kz_term:is_true(AsDefault)); acl_summary('true') -> @@ -308,14 +308,14 @@ acl_summary('true') -> acl_summary('false') -> list_acls(get_acls(), 'undefined'). --spec remove_acl(text()) -> 'no_return'. +-spec remove_acl(kz_term:text()) -> 'no_return'. remove_acl(Name) -> remove_acl(kz_term:to_binary(Name) ,get_acls() ,fun ecallmgr_config:set/2 ). --spec remove_acl(text(), text() | boolean()) -> 'no_return'. +-spec remove_acl(kz_term:text(), kz_term:text() | boolean()) -> 'no_return'. remove_acl(Name, AsDefault) when not is_boolean(AsDefault) -> remove_acl(Name, kz_term:is_true(AsDefault)); remove_acl(Name, 'true') -> @@ -329,7 +329,7 @@ remove_acl(Name, 'false') -> ,fun ecallmgr_config:set_node/2 ). --spec maybe_reload_acls(text(), text(), non_neg_integer()) -> 'no_return'. +-spec maybe_reload_acls(kz_term:text(), kz_term:text(), non_neg_integer()) -> 'no_return'. maybe_reload_acls(_Name, _Action, 0) -> io:format("Timeout during updating ACLs, try reload ACLs and flush config later:~n"), io:format("Use these commands:~n"), @@ -348,7 +348,7 @@ maybe_reload_acls(Name, Action, Tries) -> maybe_reload_acls(Name, Action, Tries - 1) end. --spec has_acl(text(), text(), kz_json:object()) -> 'true' | 'false'. +-spec has_acl(kz_term:text(), kz_term:text(), kz_json:object()) -> 'true' | 'false'. has_acl(Name, Action, ACLs) -> FilteredACLs = filter_acls(ACLs), _ = case kz_json:get_value(Name, FilteredACLs) of @@ -368,13 +368,13 @@ reload_acls() -> ], 'no_return'. --spec test_ip_against_acl(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec test_ip_against_acl(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. test_ip_against_acl(IP, NodeBin, AclList) -> Node = kz_term:to_atom(NodeBin, 'true'), {'ok', Bool} = freeswitch:api(Node, 'acl', <>), io:format("IP ~s on node ~s would be ~s~n", [IP, NodeBin, acl_action(Bool)]). --spec acl_action(ne_binary()) -> ne_binary(). +-spec acl_action(kz_term:ne_binary()) -> kz_term:ne_binary(). acl_action(Bool) -> case kz_term:is_true(Bool) of 'true' -> <<"accepted">>; @@ -395,7 +395,7 @@ node_details() -> ecallmgr_fs_nodes:details(), 'no_return'. --spec node_details(text()) -> 'no_return'. +-spec node_details(kz_term:text()) -> 'no_return'. node_details(NodeName) -> ecallmgr_fs_nodes:details(NodeName), 'no_return'. @@ -405,7 +405,7 @@ channel_summary() -> ecallmgr_fs_channels:summary(), 'no_return'. --spec channel_summary(text()) -> 'no_return'. +-spec channel_summary(kz_term:text()) -> 'no_return'. channel_summary(Node) -> ecallmgr_fs_channels:summary(Node), 'no_return'. @@ -415,7 +415,7 @@ channel_details() -> ecallmgr_fs_channels:details(), 'no_return'. --spec channel_details(text()) -> 'no_return'. +-spec channel_details(kz_term:text()) -> 'no_return'. channel_details(UUID) -> ecallmgr_fs_channels:details(UUID), 'no_return'. @@ -425,7 +425,7 @@ sync_channels() -> lists:foreach(fun ecallmgr_fs_node:sync_channels/1 ,gproc:lookup_pids({'p', 'l', 'fs_node'})). --spec sync_channels(text()) -> 'ok'. +-spec sync_channels(kz_term:text()) -> 'ok'. sync_channels(Node) -> N = kz_term:to_atom(Node, 'true'), _ = [ecallmgr_fs_node:sync_channels(Srv) @@ -439,7 +439,7 @@ conference_summary() -> ecallmgr_fs_conferences:summary(), 'no_return'. --spec conference_summary(text()) -> 'no_return'. +-spec conference_summary(kz_term:text()) -> 'no_return'. conference_summary(Node) -> ecallmgr_fs_conferences:summary(Node), 'no_return'. @@ -449,7 +449,7 @@ conference_details() -> ecallmgr_fs_conferences:details(), 'no_return'. --spec conference_details(text()) -> 'no_return'. +-spec conference_details(kz_term:text()) -> 'no_return'. conference_details(UUID) -> ecallmgr_fs_conferences:details(UUID), 'no_return'. @@ -459,7 +459,7 @@ sync_conferences() -> lists:foreach(fun ecallmgr_fs_conferences:sync_node/1 ,ecallmgr_fs_nodes:connected()). --spec sync_conferences(text()) -> 'ok'. +-spec sync_conferences(kz_term:text()) -> 'ok'. sync_conferences(Node) -> N = kz_term:to_atom(Node, 'true'), ecallmgr_fs_conferences:sync_node(N), @@ -477,11 +477,11 @@ flush_node_conferences(Node) -> flush_registrar() -> ecallmgr_registrar:flush(). --spec flush_registrar(text()) -> 'ok'. +-spec flush_registrar(kz_term:text()) -> 'ok'. flush_registrar(Realm) -> ecallmgr_registrar:flush(Realm). --spec flush_registrar(text(), text()) -> 'ok'. +-spec flush_registrar(kz_term:text(), kz_term:text()) -> 'ok'. flush_registrar(Username, Realm) -> ecallmgr_registrar:flush(Username, Realm). @@ -490,7 +490,7 @@ registrar_summary() -> ecallmgr_registrar:summary(), 'no_return'. --spec registrar_summary(text()) -> 'no_return'. +-spec registrar_summary(kz_term:text()) -> 'no_return'. registrar_summary(Realm) -> ecallmgr_registrar:summary(Realm), 'no_return'. @@ -500,12 +500,12 @@ registrar_details() -> ecallmgr_registrar:details(), 'no_return'. --spec registrar_details(text()) -> 'no_return'. +-spec registrar_details(kz_term:text()) -> 'no_return'. registrar_details(Realm) -> ecallmgr_registrar:details(Realm), 'no_return'. --spec registrar_details(text(), text()) -> 'no_return'. +-spec registrar_details(kz_term:text(), kz_term:text()) -> 'no_return'. registrar_details(Username, Realm) -> ecallmgr_registrar:details(Username, Realm), 'no_return'. @@ -533,14 +533,14 @@ show_calls() -> io:format("This function is depreciated, please use channel_summary or channel_details~n"), 'no_return'. --spec check_sync(text(), text()) -> 'ok'. +-spec check_sync(kz_term:text(), kz_term:text()) -> 'ok'. check_sync(Username, Realm) -> ecallmgr_fs_notify:notify(kz_term:to_binary(Username) ,kz_term:to_binary(Realm) ,<<"check-sync">> ). --spec add_fs_node(text(), ne_binaries(), function()) -> 'ok' | {'error', any()}. +-spec add_fs_node(kz_term:text(), kz_term:ne_binaries(), function()) -> 'ok' | {'error', any()}. add_fs_node(FSNode, FSNodes, ConfigFun) when not is_binary(FSNode) -> add_fs_node(kz_term:to_binary(FSNode), FSNodes, ConfigFun); add_fs_node(FSNode, FSNodes, ConfigFun) -> @@ -553,7 +553,7 @@ add_fs_node(FSNode, FSNodes, ConfigFun) -> end, ecallmgr_fs_nodes:add(kz_term:to_atom(FSNode, 'true')). --spec remove_fs_node(text(), ne_binaries(), function()) -> 'ok' | {'error', any()}. +-spec remove_fs_node(kz_term:text(), kz_term:ne_binaries(), function()) -> 'ok' | {'error', any()}. remove_fs_node(FSNode, FSNodes, ConfigFun) when not is_binary(FSNode) -> remove_fs_node(kz_term:to_binary(FSNode), FSNodes, ConfigFun); remove_fs_node(FSNode, FSNodes, ConfigFun) -> @@ -566,7 +566,7 @@ remove_fs_node(FSNode, FSNodes, ConfigFun) -> end, ecallmgr_fs_nodes:remove(kz_term:to_atom(FSNode, 'true')). --spec get_fs_nodes(ne_binary() | atom()) -> ne_binaries(). +-spec get_fs_nodes(kz_term:ne_binary() | atom()) -> kz_term:ne_binaries(). get_fs_nodes(Node) -> case ?FS_NODES(Node) of [_|_]=FSNodes -> FSNodes; @@ -576,7 +576,7 @@ get_fs_nodes(Node) -> [] end. --spec modify_acls(ne_binary(), ne_binary(), kz_json:object(), function(), function()) -> 'no_return'. +-spec modify_acls(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), function(), function()) -> 'no_return'. modify_acls(Name, IP, ACLS, ACLFun, ConfigFun) -> ACL = ACLFun(IP), io:format("updating ~s ACLs ~s(~s) to ~s traffic~n" @@ -608,7 +608,7 @@ remove_acl(Name, ACLs, ConfigFun) -> end, maybe_reload_acls(Name, 'remove', 4). --spec list_acls(kz_json:object(), api_binary()) -> 'no_return'. +-spec list_acls(kz_json:object(), kz_term:api_binary()) -> 'no_return'. list_acls(ACLs, Network) -> ThinBar = "+--------------------------------+--------------------+---------------+-------+------------------+----------------------------------+\n", ThickBar = "+================================+====================+===============+=======+==================+==================================+\n", @@ -658,7 +658,7 @@ maybe_print_acl(Network, FormatString, ACL) -> -spec get_acls() -> kz_json:object(). get_acls() -> get_acls(node()). --spec get_acls(atom() | ne_binary()) -> kz_json:object(). +-spec get_acls(atom() | kz_term:ne_binary()) -> kz_json:object(). get_acls(Node) -> ACLs = ecallmgr_config:fetch(<<"acls">>, 'undefined', Node), case kz_json:is_json_object(ACLs) of @@ -676,20 +676,20 @@ filter_acls(ACLs) -> filter_acls_fun({_Name, ACL}) -> kz_json:get_value(<<"authorizing_type">>, ACL) =:= 'undefined'. --spec carrier_acl(ne_binary()) -> kz_json:object(). +-spec carrier_acl(kz_term:ne_binary()) -> kz_json:object(). carrier_acl(IP) -> carrier_acl(IP, <<"allow">>). --spec carrier_acl(ne_binary(), ne_binary()) -> kz_json:object(). +-spec carrier_acl(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). carrier_acl(IP, Type) -> kz_json:from_list([{<<"type">>, Type} ,{<<"network-list-name">>, ?FS_CARRIER_ACL_LIST} ,{<<"cidr">>, kz_network_utils:to_cidr(IP)} ]). --spec sbc_acl(ne_binary()) -> kz_json:object(). +-spec sbc_acl(kz_term:ne_binary()) -> kz_json:object(). sbc_acl(IP) -> sbc_acl(IP, <<"allow">>). --spec sbc_acl(ne_binary(), ne_binary()) -> kz_json:object(). +-spec sbc_acl(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). sbc_acl(IP, Type) -> kz_json:from_list([{<<"type">>, Type} ,{<<"network-list-name">>, ?FS_SBC_ACL_LIST} @@ -716,8 +716,8 @@ disable_local_resource_authz() -> ecallmgr_config:set_default(<<"authz_local_resources">>, 'false'), io:format("turned off authz for local resources; calls to local resources will no longer require authorization~n"). --spec limit_channel_uptime(ne_binary()) -> 'ok'. --spec limit_channel_uptime(ne_binary(), ne_binary() | boolean()) -> 'ok'. +-spec limit_channel_uptime(kz_term:ne_binary()) -> 'ok'. +-spec limit_channel_uptime(kz_term:ne_binary(), kz_term:ne_binary() | boolean()) -> 'ok'. limit_channel_uptime(MaxAge) -> limit_channel_uptime(MaxAge, 'true'). limit_channel_uptime(MaxAge, AsDefault) -> @@ -725,7 +725,7 @@ limit_channel_uptime(MaxAge, AsDefault) -> io:format("updating max channel uptime to ~p (use 0 to disable check)~n", [MaxAge]). -spec hangup_long_running_channels() -> 'ok'. --spec hangup_long_running_channels(text() | pos_integer()) -> 'ok'. +-spec hangup_long_running_channels(kz_term:text() | pos_integer()) -> 'ok'. hangup_long_running_channels() -> MaxAge = ecallmgr_fs_channels:max_channel_uptime(), hangup_long_running_channels(MaxAge). diff --git a/applications/ecallmgr/src/ecallmgr_originate.erl b/applications/ecallmgr/src/ecallmgr_originate.erl index a61f28891dd..905157e733e 100644 --- a/applications/ecallmgr/src/ecallmgr_originate.erl +++ b/applications/ecallmgr/src/ecallmgr_originate.erl @@ -26,18 +26,18 @@ -define(SERVER, ?MODULE). --type created_uuid() :: {'fs' | 'api', ne_binary()}. +-type created_uuid() :: {'fs' | 'api', kz_term:ne_binary()}. -record(state, {node :: atom() - ,server_id :: api_binary() - ,controller_q :: api_binary() + ,server_id :: kz_term:api_binary() + ,controller_q :: kz_term:api_binary() ,originate_req = kz_json:new() :: kz_json:object() ,uuid :: created_uuid() | 'undefined' - ,action :: api_binary() - ,app :: api_binary() - ,dialstrings :: api_binary() - ,queue :: api_binary() - ,control_pid :: api_pid() - ,tref :: api_reference() + ,action :: kz_term:api_binary() + ,app :: kz_term:api_binary() + ,dialstrings :: kz_term:api_binary() + ,queue :: kz_term:api_binary() + ,control_pid :: kz_term:api_pid() + ,tref :: kz_term:api_reference() ,fetch_id = kz_binary:rand_hex(16) }). -type state() :: #state{}. @@ -66,7 +66,7 @@ %% @public %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(atom(), kz_json:object()) -> startlink_ret(). +-spec start_link(atom(), kz_json:object()) -> kz_types:startlink_ret(). start_link(Node, JObj) -> gen_listener:start_link(?SERVER ,[{'bindings', ?BINDINGS} @@ -83,7 +83,7 @@ start_link(Node, JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec handle_call_events(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_call_events(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_call_events(JObj, Props) -> Srv = props:get_value('server', Props), case props:get_value('uuid', Props) =:= kz_json:get_binary_value(<<"Call-ID">>, JObj) @@ -106,7 +106,7 @@ handle_call_events(JObj, Props) -> %% %% @end %%-------------------------------------------------------------------- --spec handle_originate_execute(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_originate_execute(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_originate_execute(JObj, Props) -> 'true' = kapi_dialplan:originate_execute_v(JObj), Srv = props:get_value('server', Props), @@ -148,7 +148,7 @@ init([Node, JObj]) -> }} end. --spec bind_to_events({'ok', ne_binary()}, atom()) -> 'ok'. +-spec bind_to_events({'ok', kz_term:ne_binary()}, atom()) -> 'ok'. bind_to_events({'ok', <<"mod_kazoo", _/binary>>}, Node) -> 'ok' = freeswitch:event(Node, ['CUSTOM', 'loopback::bowout']); bind_to_events(_, Node) -> @@ -168,7 +168,7 @@ bind_to_events(_, Node) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -182,7 +182,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', Q}}, State) -> lager:debug("starting originate request"), gen_listener:cast(self(), {'get_originate_action'}), @@ -347,7 +347,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'event', [_|Props]}, #state{uuid=UUID}=State) -> {'noreply', State#state{uuid=handle_fs_event(Props, UUID)}}; handle_info({'tcp', _, Data}, State) -> @@ -425,7 +425,7 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec get_originate_action(ne_binary(), kz_json:object()) -> ne_binary(). +-spec get_originate_action(kz_term:ne_binary(), kz_json:object()) -> kz_term:ne_binary(). get_originate_action(<<"fax">>, JObj) -> lager:debug("got originate with action fax"), Data = kz_json:get_value(<<"Application-Data">>, JObj), @@ -451,7 +451,7 @@ get_originate_action(_, _) -> lager:debug("got originate with action park"), ?ORIGINATE_PARK. --spec get_transfer_action(kz_json:object(), api_binary()) -> ne_binary(). +-spec get_transfer_action(kz_json:object(), kz_term:api_binary()) -> kz_term:ne_binary(). get_transfer_action(_JObj, 'undefined') -> <<"error">>; get_transfer_action(JObj, Route) -> Context = ?DEFAULT_FREESWITCH_CONTEXT, @@ -460,7 +460,7 @@ get_transfer_action(JObj, Route) -> ," XML ", Context, "' inline" ]). --spec intercept_unbridged_only(ne_binary() | 'undefined', kz_json:object()) -> ne_binary(). +-spec intercept_unbridged_only(kz_term:ne_binary() | 'undefined', kz_json:object()) -> kz_term:ne_binary(). intercept_unbridged_only('undefined', JObj) -> get_bridge_action(JObj); intercept_unbridged_only(ExistingCallId, JObj) -> @@ -471,7 +471,7 @@ intercept_unbridged_only(ExistingCallId, JObj) -> <<" 'set:intercept_unbridged_only=false,intercept:", ExistingCallId/binary, "' inline ">> end. --spec get_bridge_action(kz_json:object()) -> ne_binary(). +-spec get_bridge_action(kz_json:object()) -> kz_term:ne_binary(). get_bridge_action(JObj) -> Data = kz_json:get_value(<<"Application-Data">>, JObj), case ecallmgr_util:build_channel(Data) of @@ -491,7 +491,7 @@ maybe_update_node(JObj, Node) -> end end. --spec get_eavesdrop_action(kz_json:object()) -> ne_binary(). +-spec get_eavesdrop_action(kz_json:object()) -> kz_term:ne_binary(). get_eavesdrop_action(JObj) -> {CallId, Group} = case kz_json:get_value(<<"Eavesdrop-Group-ID">>, JObj) of 'undefined' -> {kz_json:get_binary_value(<<"Eavesdrop-Call-ID">>, JObj), <<>>}; @@ -504,7 +504,7 @@ get_eavesdrop_action(JObj) -> 'undefined' -> <> end. --spec build_originate_args(ne_binary(), state(), kz_json:object(), ne_binary()) -> api_binary(). +-spec build_originate_args(kz_term:ne_binary(), state(), kz_json:object(), kz_term:ne_binary()) -> kz_term:api_binary(). build_originate_args(Action, State, JObj, FetchId) -> case kz_json:get_value(<<"Endpoints">>, JObj, []) of [] -> @@ -519,8 +519,8 @@ build_originate_args(Action, State, JObj, FetchId) -> build_originate_args_from_endpoints(Action, UpdatedEndpoints, JObj, FetchId) end. --spec build_originate_args_from_endpoints(ne_binary(), kz_json:objects(), kz_json:object(), ne_binary()) -> - ne_binary(). +-spec build_originate_args_from_endpoints(kz_term:ne_binary(), kz_json:objects(), kz_json:object(), kz_term:ne_binary()) -> + kz_term:ne_binary(). build_originate_args_from_endpoints(Action, Endpoints, JObj, FetchId) -> lager:debug("building originate command arguments"), DialSeparator = ecallmgr_util:get_dial_separator(JObj, Endpoints), @@ -531,7 +531,7 @@ build_originate_args_from_endpoints(Action, Endpoints, JObj, FetchId) -> list_to_binary([ChannelVars, DialStrings, " ", Action]). --spec get_channel_vars(kz_json:object(), ne_binary()) -> iolist(). +-spec get_channel_vars(kz_json:object(), kz_term:ne_binary()) -> iolist(). get_channel_vars(JObj, FetchId) -> CCVs = [{<<"Fetch-ID">>, FetchId} ,{<<"Ecallmgr-Node">>, kz_term:to_binary(node())} @@ -540,28 +540,28 @@ get_channel_vars(JObj, FetchId) -> J = kz_json:from_list_recursive([{<<"Custom-Channel-Vars">>, add_ccvs(JObj, CCVs)}]), ecallmgr_fs_xml:get_channel_vars(kz_json:merge(JObj, J)). --spec add_ccvs(kz_json:object(), kz_proplist()) -> kz_proplist(). +-spec add_ccvs(kz_json:object(), kz_term:proplist()) -> kz_term:proplist(). add_ccvs(JObj, Props) -> Routines = [fun maybe_add_loopback/2 ,fun maybe_add_origination_uuid/2 ], lists:foldl(fun(Fun, Acc) -> Fun(JObj, Acc) end, Props, Routines). --spec maybe_add_origination_uuid(kz_json:object(), kz_proplist()) -> kz_proplist(). +-spec maybe_add_origination_uuid(kz_json:object(), kz_term:proplist()) -> kz_term:proplist(). maybe_add_origination_uuid(JObj, Props) -> case kz_json:get_ne_binary_value(<<"Outbound-Call-ID">>, JObj) of 'undefined' -> Props; CallId -> [{<<"Origination-Call-ID">>, CallId} | Props] end. --spec maybe_add_loopback(kz_json:object(), kz_proplist()) -> kz_proplist(). +-spec maybe_add_loopback(kz_json:object(), kz_term:proplist()) -> kz_term:proplist(). maybe_add_loopback(JObj, Props) -> case kz_json:get_binary_boolean(<<"Simplify-Loopback">>, JObj) of 'undefined' -> Props; SimpliFly -> add_loopback(kz_term:is_true(SimpliFly)) ++ Props end. --spec add_loopback(boolean()) -> kz_proplist(). +-spec add_loopback(boolean()) -> kz_term:proplist(). add_loopback('true') -> [{<<"Simplify-Loopback">>, 'true'} ,{<<"Loopback-Bowout">>, 'true'} @@ -571,9 +571,9 @@ add_loopback('false') -> ,{<<"Loopback-Bowout">>, 'false'} ]. --spec originate_execute(atom(), ne_binary(), pos_integer()) -> - {'ok', ne_binary()} | - {'error', ne_binary() | 'timeout' | 'crash'}. +-spec originate_execute(atom(), kz_term:ne_binary(), pos_integer()) -> + {'ok', kz_term:ne_binary()} | + {'error', kz_term:ne_binary() | 'timeout' | 'crash'}. originate_execute(Node, Dialstrings, Timeout) -> lager:debug("executing originate on ~s: ~s", [Node, Dialstrings]), case freeswitch:api(Node @@ -598,13 +598,13 @@ originate_execute(Node, Dialstrings, Timeout) -> {'error', <<"unspecified">>} end. --spec set_music_on_hold(atom(), ne_binary(), api_binary()) -> 'ok'. +-spec set_music_on_hold(atom(), kz_term:ne_binary(), kz_term:api_binary()) -> 'ok'. set_music_on_hold(_, _, 'undefined') -> 'ok'; set_music_on_hold(Node, UUID, Media) -> Resp = ecallmgr_fs_command:set(Node, UUID, [{<<"Hold-Media">>, Media}]), lager:debug("setting Hold-Media resp: ~p", [Resp]). --spec bind_to_call_events(ne_binary()) -> 'ok'. +-spec bind_to_call_events(kz_term:ne_binary()) -> 'ok'. bind_to_call_events(CallId) -> lager:debug("binding to call events for ~s", [CallId]), Options = [{'callid', CallId} @@ -617,7 +617,7 @@ unbind_from_call_events() -> lager:debug("unbind from call events"), gen_listener:rm_binding(self(), 'call', []). --spec update_uuid(api_binary(), ne_binary()) -> 'ok'. +-spec update_uuid(kz_term:api_binary(), kz_term:ne_binary()) -> 'ok'. update_uuid(OldUUID, NewUUID) -> kz_util:put_callid(NewUUID), lager:debug("updating call id from ~s to ~s", [OldUUID, NewUUID]), @@ -668,21 +668,21 @@ get_unset_vars(JObj) -> ] end. --spec maybe_fix_ignore_early_media(strings()) -> string(). +-spec maybe_fix_ignore_early_media(kz_term:strings()) -> string(). maybe_fix_ignore_early_media(Export) -> case lists:member("ignore_early_media", Export) of 'true' -> ""; 'false' -> "^unset:ignore_early_media" end. --spec maybe_fix_group_confirm(strings()) -> string(). +-spec maybe_fix_group_confirm(kz_term:strings()) -> string(). maybe_fix_group_confirm(Export) -> case lists:member("group_confirm_key", Export) of 'true' -> ""; 'false' -> "^unset:group_confirm_key^unset:group_confirm_cancel_timeout^unset:group_confirm_file" end. --spec maybe_fix_fs_auto_answer_bug(strings()) -> string(). +-spec maybe_fix_fs_auto_answer_bug(kz_term:strings()) -> string(). maybe_fix_fs_auto_answer_bug(Export) -> case lists:member("sip_auto_answer", Export) of 'true' -> ""; @@ -690,7 +690,7 @@ maybe_fix_fs_auto_answer_bug(Export) -> "^unset:sip_h_Call-Info^unset:sip_h_Alert-Info^unset:alert_info^unset:sip_invite_params^set:sip_auto_answer=false" end. --spec maybe_fix_caller_id(strings(), kz_json:object()) -> string(). +-spec maybe_fix_caller_id(kz_term:strings(), kz_json:object()) -> string(). maybe_fix_caller_id(Export, JObj) -> Fix = [ {lists:member("origination_callee_id_name", Export), kz_json:get_value(<<"Outbound-Callee-ID-Name">>, JObj), "effective_caller_id_name"} @@ -698,7 +698,7 @@ maybe_fix_caller_id(Export, JObj) -> ], string:join([ "^set:" ++ Key ++ "=" ++ erlang:binary_to_list(Value) || {IsTrue, Value, Key} <- Fix, IsTrue ], ":"). --spec publish_error(ne_binary(), created_uuid() | api_binary(), kz_json:object(), api_binary()) -> 'ok'. +-spec publish_error(kz_term:ne_binary(), created_uuid() | kz_term:api_binary(), kz_json:object(), kz_term:api_binary()) -> 'ok'. publish_error(_, _, _, 'undefined') -> 'ok'; publish_error(Error, {_, UUID}, Request, ServerId) -> publish_error(Error, UUID, Request, ServerId); @@ -712,11 +712,11 @@ publish_error(Error, UUID, Request, ServerId) -> ], kz_api:publish_error(ServerId, props:filter_undefined(E)). --spec cleanup_error(ne_binary()) -> ne_binary(). +-spec cleanup_error(kz_term:ne_binary()) -> kz_term:ne_binary(). cleanup_error(<<"-ERR ", E/binary>>) -> E; cleanup_error(E) -> E. --spec publish_originate_ready(ne_binary(), created_uuid() | ne_binary(), kz_json:object(), api_binary(), api_binary()) -> 'ok'. +-spec publish_originate_ready(kz_term:ne_binary(), created_uuid() | kz_term:ne_binary(), kz_json:object(), kz_term:api_binary(), kz_term:api_binary()) -> 'ok'. publish_originate_ready(CtrlQ, {_, UUID}, Request, Q, ServerId) -> publish_originate_ready(CtrlQ, UUID, Request, Q, ServerId); publish_originate_ready(CtrlQ, UUID, Request, Q, ServerId) -> @@ -728,7 +728,7 @@ publish_originate_ready(CtrlQ, UUID, Request, Q, ServerId) -> ], kapi_dialplan:publish_originate_ready(ServerId, Props). --spec publish_originate_resp(api_binary(), kz_json:object()) -> 'ok'. +-spec publish_originate_resp(kz_term:api_binary(), kz_json:object()) -> 'ok'. publish_originate_resp('undefined', _) -> 'ok'; publish_originate_resp(ServerId, JObj) -> Resp = kz_json:set_values([{<<"Event-Category">>, <<"resource">>} @@ -736,7 +736,7 @@ publish_originate_resp(ServerId, JObj) -> ], JObj), kapi_resource:publish_originate_resp(ServerId, Resp). --spec publish_originate_resp(api_binary(), kz_json:object(), ne_binary()) -> 'ok'. +-spec publish_originate_resp(kz_term:api_binary(), kz_json:object(), kz_term:ne_binary()) -> 'ok'. publish_originate_resp('undefined', _JObj, _UUID) -> 'ok'; publish_originate_resp(ServerId, JObj, UUID) -> Resp = kz_json:set_values([{<<"Event-Category">>, <<"resource">>} @@ -746,7 +746,7 @@ publish_originate_resp(ServerId, JObj, UUID) -> ], JObj), kapi_resource:publish_originate_resp(ServerId, Resp). --spec publish_originate_started(api_binary(), ne_binary(), kz_json:object(), ne_binary()) -> 'ok'. +-spec publish_originate_started(kz_term:api_binary(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> 'ok'. publish_originate_started('undefined', _, _, _) -> 'ok'; publish_originate_started(ServerId, CallId, JObj, CtrlQ) -> Resp = kz_json:from_list( @@ -757,7 +757,7 @@ publish_originate_started(ServerId, CallId, JObj, CtrlQ) -> ]), kapi_resource:publish_originate_started(ServerId, Resp). --spec publish_originate_uuid(api_binary(), created_uuid() | ne_binary(), kz_json:object(), ne_binary()) -> 'ok'. +-spec publish_originate_uuid(kz_term:api_binary(), created_uuid() | kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> 'ok'. publish_originate_uuid('undefined', _, _, _) -> 'ok'; publish_originate_uuid(ServerId, UUID, JObj, CtrlQueue) -> Resp = props:filter_undefined( @@ -872,7 +872,7 @@ fix_hold_media(Endpoint) -> put('hold_media', kz_json:get_value(<<"Hold-Media">>, Endpoint)), kz_json:delete_key(<<"Hold-Media">>, Endpoint). --spec should_update_uuid(api_binary(), kz_proplist()) -> boolean(). +-spec should_update_uuid(kz_term:api_binary(), kz_term:proplist()) -> boolean(). should_update_uuid(OldUUID, Props) -> case props:get_value(<<"Event-Subclass">>, Props, props:get_value(<<"Event-Name">>, Props)) of <<"loopback::bowout">> -> diff --git a/applications/ecallmgr/src/ecallmgr_originate_sup.erl b/applications/ecallmgr/src/ecallmgr_originate_sup.erl index 40b91eaea50..ffdcf067170 100644 --- a/applications/ecallmgr/src/ecallmgr_originate_sup.erl +++ b/applications/ecallmgr/src/ecallmgr_originate_sup.erl @@ -25,11 +25,11 @@ %%-------------------------------------------------------------------- %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec start_originate_proc(atom(), kz_json:object()) -> sup_startchild_ret(). +-spec start_originate_proc(atom(), kz_json:object()) -> kz_types:sup_startchild_ret(). start_originate_proc(Node, JObj) -> supervisor:start_child(?SERVER, [Node, JObj]). @@ -46,7 +46,7 @@ start_originate_proc(Node, JObj) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 5, diff --git a/applications/ecallmgr/src/ecallmgr_registrar.erl b/applications/ecallmgr/src/ecallmgr_registrar.erl index 7accc5d6593..3bd1f33b630 100644 --- a/applications/ecallmgr/src/ecallmgr_registrar.erl +++ b/applications/ecallmgr/src/ecallmgr_registrar.erl @@ -71,46 +71,46 @@ -define(EXPIRES_MISSING_VALUE, 0). -record(state, {started = kz_time:now_s() - ,queue :: api_binary() + ,queue :: kz_term:api_binary() }). -type state() :: #state{}. --record(registration, {id :: {ne_binary(), ne_binary()} | '_' | '$1' - ,username :: api_ne_binary() | '_' - ,realm :: api_ne_binary() | '_' | '$1' - ,network_port :: api_ne_binary() | '_' - ,network_ip :: api_ne_binary() | '_' - ,to_host = ?DEFAULT_REALM :: ne_binary() | '_' - ,to_user = <<"nouser">> :: ne_binary() | '_' - ,from_host = ?DEFAULT_REALM :: ne_binary() | '_' - ,from_user = <<"nouser">> :: ne_binary() | '_' - ,call_id :: api_ne_binary() | '_' - ,user_agent :: api_ne_binary() | '_' +-record(registration, {id :: {kz_term:ne_binary(), kz_term:ne_binary()} | '_' | '$1' + ,username :: kz_term:api_ne_binary() | '_' + ,realm :: kz_term:api_ne_binary() | '_' | '$1' + ,network_port :: kz_term:api_ne_binary() | '_' + ,network_ip :: kz_term:api_ne_binary() | '_' + ,to_host = ?DEFAULT_REALM :: kz_term:ne_binary() | '_' + ,to_user = <<"nouser">> :: kz_term:ne_binary() | '_' + ,from_host = ?DEFAULT_REALM :: kz_term:ne_binary() | '_' + ,from_user = <<"nouser">> :: kz_term:ne_binary() | '_' + ,call_id :: kz_term:api_ne_binary() | '_' + ,user_agent :: kz_term:api_ne_binary() | '_' ,expires = ?EXPIRES_MISSING_VALUE :: non_neg_integer() | '_' | '$1' - ,contact :: api_ne_binary() | '_' - ,previous_contact :: api_binary() | '_' - ,original_contact :: api_ne_binary() | '_' - ,last_registration = kz_time:now_s() :: gregorian_seconds() | '_' | '$2' - ,initial_registration = kz_time:now_s() :: gregorian_seconds() | '_' - ,registrar_node :: api_ne_binary() | '_' - ,registrar_hostname :: api_ne_binary() | '_' + ,contact :: kz_term:api_ne_binary() | '_' + ,previous_contact :: kz_term:api_binary() | '_' + ,original_contact :: kz_term:api_ne_binary() | '_' + ,last_registration = kz_time:now_s() :: kz_time:gregorian_seconds() | '_' | '$2' + ,initial_registration = kz_time:now_s() :: kz_time:gregorian_seconds() | '_' + ,registrar_node :: kz_term:api_ne_binary() | '_' + ,registrar_hostname :: kz_term:api_ne_binary() | '_' ,suppress_unregister = 'true' :: boolean() | '_' ,register_overwrite_notify = 'false' :: boolean() | '_' - ,account_db :: api_binary() | '_' - ,account_id :: api_binary() | '_' - ,authorizing_id :: api_binary() | '_' - ,authorizing_type :: api_binary() | '_' - ,owner_id :: api_binary() | '_' - ,presence_id :: api_binary() | '_' + ,account_db :: kz_term:api_binary() | '_' + ,account_id :: kz_term:api_binary() | '_' + ,authorizing_id :: kz_term:api_binary() | '_' + ,authorizing_type :: kz_term:api_binary() | '_' + ,owner_id :: kz_term:api_binary() | '_' + ,presence_id :: kz_term:api_binary() | '_' ,initial = 'true' :: boolean() | '_' - ,account_realm :: api_binary() | '_' | '$2' - ,account_name :: api_binary() | '_' - ,proxy :: api_binary() | '_' - ,proxy_ip :: api_binary() | '_' - ,proxy_port :: api_integer() | '_' - ,bridge_uri :: api_binary() | '_' - ,source_ip :: api_binary() | '_' - ,source_port :: api_binary() | '_' + ,account_realm :: kz_term:api_binary() | '_' | '$2' + ,account_name :: kz_term:api_binary() | '_' + ,proxy :: kz_term:api_binary() | '_' + ,proxy_ip :: kz_term:api_binary() | '_' + ,proxy_port :: kz_term:api_integer() | '_' + ,bridge_uri :: kz_term:api_binary() | '_' + ,source_ip :: kz_term:api_binary() | '_' + ,source_port :: kz_term:api_binary() | '_' }). -type registration() :: #registration{}. @@ -123,7 +123,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link({'local', ?SERVER} ,?MODULE @@ -136,20 +136,20 @@ start_link() -> ,[] ). --spec handle_reg_success(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_reg_success(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_reg_success(JObj, _Props) -> 'true' = kapi_registration:success_v(JObj), _ = kz_util:put_callid(JObj), Registration = create_registration(JObj), insert_registration(Registration). --spec handle_reg_query(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_reg_query(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_reg_query(JObj, Props) -> 'true' = kapi_registration:query_req_v(JObj), _ = kz_util:put_callid(JObj), maybe_resp_to_query(JObj, props:get_value('registrar_age', Props)). --spec handle_reg_flush(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_reg_flush(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_reg_flush(JObj, _Props) -> 'true' = kapi_registration:flush_v(JObj), Username = kz_json:get_value(<<"Username">>, JObj), @@ -159,7 +159,7 @@ handle_reg_flush(JObj, _Props) -> ), flush(Username, Realm). --spec handle_fs_reg(atom(), kz_proplist()) -> 'ok'. +-spec handle_fs_reg(atom(), kz_term:proplist()) -> 'ok'. handle_fs_reg(Node, Props) -> kz_util:put_callid(kzd_freeswitch:call_id(Props)), @@ -181,8 +181,8 @@ handle_fs_reg(Node, Props) -> ), kz_amqp_worker:cast(Req, fun kapi_registration:publish_success/1). --spec lookup_contact(ne_binary(), ne_binary()) -> - {'ok', ne_binary()} | +-spec lookup_contact(kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | {'error', 'not_found'}. lookup_contact(<<>>, _Username) -> {'error', 'not_found'}; lookup_contact(_Realm, <<>>) -> {'error', 'not_found'}; @@ -203,8 +203,8 @@ lookup_contact(<<_/binary>> = Realm, <<_/binary>> = Username) -> {'ok', Contact} end. --spec lookup_original_contact(ne_binary(), ne_binary()) -> - {'ok', ne_binary()} | +-spec lookup_original_contact(kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | {'error', 'not_found'}. lookup_original_contact(Realm, Username) -> case kz_term:is_empty(Realm) @@ -222,7 +222,7 @@ lookup_original_contact(Realm, Username) -> end end. --spec lookup_registration(ne_binary(), ne_binary()) -> +-spec lookup_registration(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', 'not_found'}. lookup_registration(Realm, Username) -> @@ -232,7 +232,7 @@ lookup_registration(Realm, Username) -> 'undefined' -> fetch_registration(Username, Realm) end. --spec get_registration(ne_binary(), ne_binary()) -> 'undefined' | registration(). +-spec get_registration(kz_term:ne_binary(), kz_term:ne_binary()) -> 'undefined' | registration(). get_registration(Realm, Username) -> case ets:lookup(?MODULE, registration_id(Username, Realm)) of [#registration{}=Registration] -> Registration; @@ -249,7 +249,7 @@ summary() -> ], print_summary(ets:select(?MODULE, MatchSpec, 1)). --spec summary(text()) -> 'ok'. +-spec summary(kz_term:text()) -> 'ok'. summary(Realm) when not is_binary(Realm) -> summary(kz_term:to_binary(Realm)); summary(Realm) -> @@ -279,7 +279,7 @@ details() -> ], print_details(ets:select(?MODULE, MatchSpec, 1)). --spec details(text()) -> 'ok'. +-spec details(kz_term:text()) -> 'ok'. details(User) when not is_binary(User) -> details(kz_term:to_binary(User)); details(User) -> @@ -303,7 +303,7 @@ details(User) -> print_details(ets:select(?MODULE, MatchSpec, 1)) end. --spec details(text(), text()) -> 'ok'. +-spec details(kz_term:text(), kz_term:text()) -> 'ok'. details(Username, Realm) when not is_binary(Username) -> details(kz_term:to_binary(Username), Realm); details(Username, Realm) when not is_binary(Realm) -> @@ -326,7 +326,7 @@ sync() -> flush() -> gen_server:cast(?SERVER, 'flush'). --spec flush(text()) -> 'ok'. +-spec flush(kz_term:text()) -> 'ok'. flush(Realm) when not is_binary(Realm)-> flush(kz_term:to_binary(Realm)); flush(Realm) -> @@ -335,7 +335,7 @@ flush(Realm) -> _Else -> gen_server:cast(?SERVER, {'flush', Realm}) end. --spec flush(text() | 'undefined', text()) -> 'ok'. +-spec flush(kz_term:text() | 'undefined', kz_term:text()) -> 'ok'. flush('undefined', Realm) -> flush(Realm); flush(Username, Realm) when not is_binary(Realm) -> @@ -382,7 +382,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Msg, _From, State) -> {'noreply', State}. @@ -396,7 +396,7 @@ handle_call(_Msg, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('registrar_sync', #state{queue=Q}=State) -> Payload = kz_api:default_headers(Q, ?APP_NAME, ?APP_VERSION), kz_amqp_worker:cast(Payload, fun kapi_registration:publish_sync/1), @@ -464,7 +464,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info('expire', State) -> kz_util:put_callid(?DEFAULT_LOG_SYSTEM_ID), _ = expire_objects(), @@ -549,7 +549,7 @@ insert_registration(#registration{}=Registration) -> ,Registration#registration.contact ]). --spec fetch_registration(ne_binary(), ne_binary()) -> +-spec fetch_registration(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', 'not_found'}. fetch_registration(Username, Realm) -> @@ -566,7 +566,7 @@ fetch_registration(Username, Realm) -> {'error', 'not_found'} end. --spec query_for_registration(api_terms()) -> +-spec query_for_registration(kz_term:api_terms()) -> {'ok', kz_json:objects()} | {'error', any()}. query_for_registration(Reg) -> @@ -576,7 +576,7 @@ query_for_registration(Reg) -> ,2 * ?MILLISECONDS_IN_SECOND ). --spec find_newest_fetched_registration(ne_binary(), ne_binary(), kz_json:objects()) -> +-spec find_newest_fetched_registration(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:objects()) -> {'ok', kz_json:object()} | {'error', 'not_found'}. find_newest_fetched_registration(Username, Realm, JObjs) -> @@ -625,8 +625,8 @@ sort_fetched_registrations(A, B) -> kz_json:get_integer_value(<<"Event-Timestamp">>, B) =< kz_json:get_integer_value(<<"Event-Timestamp">>, A). --spec fetch_contact(ne_binary(), ne_binary()) -> - {'ok', ne_binary()} | +-spec fetch_contact(kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | {'error', 'not_found'}. fetch_contact(Username, Realm) -> case fetch_registration(Username, Realm) of @@ -641,8 +641,8 @@ fetch_contact(Username, Realm) -> Error end. --spec fetch_original_contact(ne_binary(), ne_binary()) -> - {'ok', ne_binary()} | +-spec fetch_original_contact(kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | {'error', 'not_found'}. fetch_original_contact(Username, Realm) -> case fetch_registration(Username, Realm) of @@ -711,7 +711,7 @@ build_query_spec(JObj, CountOnly) -> } ]. --spec build_query_spec_maybe_username(ne_binary(), kz_json:object()) -> any(). +-spec build_query_spec_maybe_username(kz_term:ne_binary(), kz_json:object()) -> any(). build_query_spec_maybe_username(Realm, JObj) -> case kz_json:get_value(<<"Username">>, JObj) of 'undefined' -> @@ -780,7 +780,7 @@ filter(Fields, JObj) -> ) ). --spec registration_id(ne_binary(), ne_binary()) -> {ne_binary(), ne_binary()}. +-spec registration_id(kz_term:ne_binary(), kz_term:ne_binary()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. registration_id(Username, Realm) -> {kz_term:to_lower_binary(Username), kz_term:to_lower_binary(Realm)}. @@ -904,7 +904,7 @@ augment_registration(Reg, JObj) -> ) }. --spec fix_contact(api_binary()) -> api_binary(). +-spec fix_contact(kz_term:api_binary()) -> kz_term:api_binary(). fix_contact('undefined') -> 'undefined'; fix_contact(Contact) -> binary:replace(Contact @@ -913,7 +913,7 @@ fix_contact(Contact) -> ,['global'] ). --spec bridge_uri(api_binary(), api_binary(), binary(), binary()) -> api_binary(). +-spec bridge_uri(kz_term:api_binary(), kz_term:api_binary(), binary(), binary()) -> kz_term:api_binary(). bridge_uri(_Contact, 'undefined', _, _) -> 'undefined'; bridge_uri('undefined', _Proxy, _, _) -> 'undefined'; bridge_uri(Contact, Proxy, Username, Realm) -> @@ -931,14 +931,14 @@ bridge_uri(Contact, Proxy, Username, Realm) -> }, kzsip_uri:ruri(BridgeUri). --spec bridge_uri_options(map()) -> kz_proplist(). +-spec bridge_uri_options(map()) -> kz_term:proplist(). bridge_uri_options(Options) -> Routines = [fun bridge_uri_transport/2 ,fun bridge_uri_path/2 ], lists:foldl(fun(Fun, Acc) -> Fun(Options, Acc) end, [], Routines). --spec bridge_uri_transport(map(), kz_proplist()) -> kz_proplist(). +-spec bridge_uri_transport(map(), kz_term:proplist()) -> kz_term:proplist(). bridge_uri_transport(#{uri_contact := UriContact}, Acc) -> case application:get_env(?APP, 'use_transport_for_fs_path', 'false') of 'true' -> @@ -949,11 +949,11 @@ bridge_uri_transport(#{uri_contact := UriContact}, Acc) -> 'false' -> Acc end. --spec bridge_uri_path(map(), kz_proplist()) -> kz_proplist(). +-spec bridge_uri_path(map(), kz_term:proplist()) -> kz_term:proplist(). bridge_uri_path(#{uri_proxy := UriProxy}, Acc) -> [{<<"fs_path">>, kzsip_uri:ruri(UriProxy)} | Acc]. --spec existing_or_new_registration(ne_binary(), ne_binary()) -> registration(). +-spec existing_or_new_registration(kz_term:ne_binary(), kz_term:ne_binary()) -> registration(). existing_or_new_registration(Username, Realm) -> case ets:lookup(?MODULE, registration_id(Username, Realm)) of [#registration{contact=Contact}=Reg] -> @@ -1162,7 +1162,7 @@ registration_notify(#registration{previous_contact=PrevContact ]), kapi_presence:publish_register_overwrite(Props). --spec to_props(registration()) -> kz_proplist(). +-spec to_props(registration()) -> kz_term:proplist(). to_props(Reg) -> props:filter_undefined( [{<<"Username">>, Reg#registration.username} @@ -1209,7 +1209,7 @@ oldest_registrar() -> kz_nodes:whapp_zone_count(?APP_NAME) =:= 1 orelse kz_nodes:whapp_oldest_node(?APP_NAME, 'true') =:= node(). --spec get_fs_contact(kz_proplist()) -> ne_binary(). +-spec get_fs_contact(kz_term:proplist()) -> kz_term:ne_binary(). get_fs_contact(Props) -> Contact = props:get_first_defined([<<"Contact">>, <<"contact">>], Props), [User, AfterAt] = binary:split(Contact, <<"@">>), % only one @ allowed @@ -1279,14 +1279,14 @@ print_property(<<"Expires">> =Key, Value, #registration{expires=Expires print_property(Key, Value, _) -> io:format("~-19s: ~s~n", [Key, kz_term:to_binary(Value)]). --type contact_param() :: {'uri', ne_binary()} | - {'hostport', ne_binary()} | - {'transport', ne_binary()} | - {'fs_path', ne_binary()} | - {'received', ne_binary()}. +-type contact_param() :: {'uri', kz_term:ne_binary()} | + {'hostport', kz_term:ne_binary()} | + {'transport', kz_term:ne_binary()} | + {'fs_path', kz_term:ne_binary()} | + {'received', kz_term:ne_binary()}. -type contact_params() :: [contact_param()]. --spec breakup_contact(text()) -> contact_params(). +-spec breakup_contact(kz_term:text()) -> contact_params(). breakup_contact(Contact) when is_binary(Contact) -> C = binary:replace(Contact, [<<$'>>, <<$<>>, <<$>>>, <<"sip:">>], <<>>, ['global']), [Uri|Parameters] = binary:split(C, <<";">>, ['global']), @@ -1295,7 +1295,7 @@ breakup_contact(Contact) when is_binary(Contact) -> breakup_contact(Contact) -> breakup_contact(kz_term:to_binary(Contact)). --spec proxy_path(api_binary(), api_binary(), api_integer()) -> binary(). +-spec proxy_path(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_integer()) -> binary(). proxy_path('undefined', 'undefined', 'undefined') -> <<>>; proxy_path('undefined', 'undefined', Port) -> proxy_path('undefined', <<>>, Port); proxy_path('undefined', IP, 'undefined') -> IP; @@ -1307,7 +1307,7 @@ proxy_path(Proxy, _, Port) -> _ -> Proxy1 end. --spec find_contact_parameters(ne_binaries(), kz_proplist()) -> kz_proplist(). +-spec find_contact_parameters(kz_term:ne_binaries(), kz_term:proplist()) -> kz_term:proplist(). find_contact_parameters([], Props) -> Props; find_contact_parameters([<<"transport=", Transport/binary>>|Parameters], Props) -> find_contact_parameters(Parameters, [{'transport', kz_term:to_lower_binary(Transport)}|Props]); @@ -1318,7 +1318,7 @@ find_contact_parameters([<<"received=", Received/binary>>|Parameters], Props) -> find_contact_parameters([_|Parameters], Props) -> find_contact_parameters(Parameters, Props). --spec get_contact_hostport(ne_binary()) -> ne_binary(). +-spec get_contact_hostport(kz_term:ne_binary()) -> kz_term:ne_binary(). get_contact_hostport(Uri) -> case binary:split(Uri, <<"@">>) of [_, Hostport] -> Hostport; diff --git a/applications/ecallmgr/src/ecallmgr_sup.erl b/applications/ecallmgr/src/ecallmgr_sup.erl index addd4e38b6c..3237d2202b3 100644 --- a/applications/ecallmgr/src/ecallmgr_sup.erl +++ b/applications/ecallmgr/src/ecallmgr_sup.erl @@ -29,7 +29,7 @@ %%-------------------------------------------------------------------- %% @public %% @doc Starts the supervisor --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -46,7 +46,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/ecallmgr/src/ecallmgr_util.erl b/applications/ecallmgr/src/ecallmgr_util.erl index 2770749938a..122753f7ac3 100644 --- a/applications/ecallmgr/src/ecallmgr_util.erl +++ b/applications/ecallmgr/src/ecallmgr_util.erl @@ -66,20 +66,20 @@ -type send_cmd_ret() :: fs_sendmsg_ret() | fs_api_ret(). -export_type([send_cmd_ret/0]). --record(bridge_endpoint, {invite_format = <<"username">> :: ne_binary() - ,endpoint_type = <<"sip">> :: ne_binary() - ,ip_address :: api_binary() - ,username :: api_binary() - ,user :: api_binary() - ,realm :: api_binary() - ,number :: api_binary() - ,route :: api_binary() - ,proxy_address :: api_binary() - ,forward_address :: api_binary() - ,transport :: api_binary() - ,span = <<"1">> :: ne_binary() - ,channel_selection = <<"a">> :: ne_binary() - ,interface = <<"RR">> :: ne_binary() % for Skype +-record(bridge_endpoint, {invite_format = <<"username">> :: kz_term:ne_binary() + ,endpoint_type = <<"sip">> :: kz_term:ne_binary() + ,ip_address :: kz_term:api_binary() + ,username :: kz_term:api_binary() + ,user :: kz_term:api_binary() + ,realm :: kz_term:api_binary() + ,number :: kz_term:api_binary() + ,route :: kz_term:api_binary() + ,proxy_address :: kz_term:api_binary() + ,forward_address :: kz_term:api_binary() + ,transport :: kz_term:api_binary() + ,span = <<"1">> :: kz_term:ne_binary() + ,channel_selection = <<"a">> :: kz_term:ne_binary() + ,interface = <<"RR">> :: kz_term:ne_binary() % for Skype ,sip_interface ,channel_vars = ["[",[],"]"] :: iolist() ,header_vars = ["[",[],"]"] :: iolist() @@ -94,7 +94,7 @@ %% send the SendMsg proplist to the freeswitch node %% @end %%-------------------------------------------------------------------- --spec send_cmd(atom(), ne_binary(), text(), text()) -> send_cmd_ret(). +-spec send_cmd(atom(), kz_term:ne_binary(), kz_term:text(), kz_term:text()) -> send_cmd_ret(). send_cmd(_Node, _UUID, <<"kz_multiset">>, <<"^^">>) -> 'ok'; send_cmd(Node, UUID, App, Args) when not is_list(App) -> send_cmd(Node, UUID, kz_term:to_list(App), Args); @@ -158,13 +158,13 @@ send_cmd(Node, UUID, App, Args) -> dialplan_application("blind_xfer") -> "transfer"; dialplan_application(App) -> App. --spec get_expires(kz_proplist()) -> integer(). +-spec get_expires(kz_term:proplist()) -> integer(). get_expires(Props) -> Expiry = kz_term:to_integer(props:get_first_defined([<<"Expires">>, <<"expires">>], Props, 300)), round(Expiry * 1.25). --spec get_interface_list(atom()) -> ne_binaries(). +-spec get_interface_list(atom()) -> kz_term:ne_binaries(). get_interface_list(Node) -> case freeswitch:api(Node, 'sofia', "status") of {'ok', Response} -> @@ -180,8 +180,8 @@ get_interface_list(Node) -> _Else -> [] end. --spec get_interface_properties(atom()) -> kz_proplist(). --spec get_interface_properties(atom(), ne_binary()) -> kz_proplist(). +-spec get_interface_properties(atom()) -> kz_term:proplist(). +-spec get_interface_properties(atom(), kz_term:ne_binary()) -> kz_term:proplist(). get_interface_properties(Node) -> [{Interface, get_interface_properties(Node, Interface)} || Interface <- get_interface_list(Node)]. @@ -200,7 +200,7 @@ get_interface_properties(Node, Interface) -> end. %% retrieves the sip address for the 'to' field --spec get_sip_to(kz_proplist()) -> ne_binary(). +-spec get_sip_to(kz_term:proplist()) -> kz_term:ne_binary(). get_sip_to(Props) -> get_sip_to(Props, kzd_freeswitch:original_call_direction(Props)). @@ -225,8 +225,8 @@ get_sip_to(Props, _) -> end. %% retrieves the sip address for the 'from' field --spec get_sip_from(kz_proplist()) -> ne_binary(). --spec get_sip_from(kz_proplist(), api_binary()) -> ne_binary(). +-spec get_sip_from(kz_term:proplist()) -> kz_term:ne_binary(). +-spec get_sip_from(kz_term:proplist(), kz_term:api_binary()) -> kz_term:ne_binary(). get_sip_from(Props) -> get_sip_from(Props, kzd_freeswitch:original_call_direction(Props)). @@ -254,7 +254,7 @@ get_sip_from(Props, _) -> ], Props, Default). %% retrieves the sip address for the 'request' field --spec get_sip_request(kz_proplist()) -> ne_binary(). +-spec get_sip_request(kz_term:proplist()) -> kz_term:ne_binary(). get_sip_request(Props) -> U = props:get_first_defined([<<"Hunt-Destination-Number">> ,<<"variable_sip_req_uri">> @@ -276,11 +276,11 @@ get_sip_request(Props) -> ), <>. --spec get_orig_ip(kz_proplist()) -> api_binary(). +-spec get_orig_ip(kz_term:proplist()) -> kz_term:api_binary(). get_orig_ip(Prop) -> props:get_first_defined([<<"X-AUTH-IP">>, <<"ip">>], Prop). --spec get_orig_port(kz_proplist()) -> api_binary(). +-spec get_orig_port(kz_term:proplist()) -> kz_term:api_binary(). get_orig_port(Prop) -> case props:get_first_defined([<<"X-AUTH-PORT">>, <<"port">>], Prop) of <<>> -> 'undefined'; @@ -288,7 +288,7 @@ get_orig_port(Prop) -> Port -> Port end. --spec get_sip_interface_from_db(ne_binaries()) -> ne_binary(). +-spec get_sip_interface_from_db(kz_term:ne_binaries()) -> kz_term:ne_binary(). get_sip_interface_from_db([FsPath]) -> NetworkMap = ecallmgr_config:get_json(<<"network_map">>, kz_json:new()), case map_fs_path_to_sip_profile(FsPath, NetworkMap) of @@ -301,7 +301,7 @@ get_sip_interface_from_db([FsPath]) -> Else end. --spec map_fs_path_to_sip_profile(ne_binary(), kz_json:object()) -> api_binary(). +-spec map_fs_path_to_sip_profile(kz_term:ne_binary(), kz_json:object()) -> kz_term:api_binary(). map_fs_path_to_sip_profile(FsPath, NetworkMap) -> SIPInterfaceObj = kz_json:filter(fun({K, _}) -> kz_network_utils:verify_cidr(FsPath, K) @@ -311,14 +311,14 @@ map_fs_path_to_sip_profile(FsPath, NetworkMap) -> {[V|_], _Keys} -> kz_json:get_ne_value(<<"custom_sip_interface">>, V) end. --spec conference_channel_vars(kzd_freeswitch:data()) -> kz_proplist(). +-spec conference_channel_vars(kzd_freeswitch:data()) -> kz_term:proplist(). conference_channel_vars(Props) -> [conference_channel_var_map(KV) || KV <- conference_channel_vars(Props, [])]. conference_channel_vars(Props, Initial) -> lists:foldl(fun conference_channel_vars_fold/2, Initial, Props). --spec conference_channel_vars_fold({ne_binary(), ne_binary()}, kz_proplist()) -> kz_proplist(). +-spec conference_channel_vars_fold({kz_term:ne_binary(), kz_term:ne_binary()}, kz_term:proplist()) -> kz_term:proplist(). conference_channel_vars_fold({Key, V}, Acc) -> case lists:member(Key, ?CONFERENCE_VARS) of 'true' -> [{Key, V} | Acc]; @@ -332,15 +332,15 @@ conference_channel_var_map({Key, Value}=KV) -> Fun -> {Key, Fun(Value)} end. --spec channel_var_map({ne_binary(), ne_binary()}) -> {ne_binary(), ne_binary() | ne_binaries()}. +-spec channel_var_map({kz_term:ne_binary(), kz_term:ne_binary()}) -> {kz_term:ne_binary(), kz_term:ne_binary() | kz_term:ne_binaries()}. channel_var_map({Key, <<"ARRAY::", Serialized/binary>>}) -> {Key, binary:split(Serialized, <<"|:">>, ['global'])}; channel_var_map({Key, Other}) -> {Key, Other}. %% Extract custom channel variables to include in the event --spec custom_channel_vars(kzd_freeswitch:data()) -> kz_proplist(). --spec custom_channel_vars(kz_proplist(), kz_proplist()) -> kz_proplist(). --spec custom_channel_vars_fold({ne_binary(), ne_binary()}, kz_proplist()) -> kz_proplist(). +-spec custom_channel_vars(kzd_freeswitch:data()) -> kz_term:proplist(). +-spec custom_channel_vars(kz_term:proplist(), kz_term:proplist()) -> kz_term:proplist(). +-spec custom_channel_vars_fold({kz_term:ne_binary(), kz_term:ne_binary()}, kz_term:proplist()) -> kz_term:proplist(). custom_channel_vars(Props) -> lists:map(fun channel_var_map/1, custom_channel_vars(Props, [])). @@ -348,7 +348,7 @@ custom_channel_vars(Props, Initial) -> CCVs = lists:foldl(fun custom_channel_vars_fold/2, Initial, Props), maybe_update_referred_ccv(Props, channel_vars_sort(CCVs)). --spec channel_vars_sort(kz_proplist()) -> kz_proplist(). +-spec channel_vars_sort(kz_term:proplist()) -> kz_term:proplist(). channel_vars_sort(ChannelVars) -> lists:usort(fun channel_var_sort/2, ChannelVars). @@ -366,9 +366,9 @@ custom_channel_vars_fold({?GET_CCV_HEADER(Key), V}, Acc) -> end; custom_channel_vars_fold(_, Acc) -> Acc. --spec custom_application_vars(kzd_freeswitch:data()) -> kz_proplist(). --spec custom_application_vars(kz_proplist(), kz_proplist()) -> kz_proplist(). --spec custom_application_vars_fold({ne_binary(), ne_binary()}, kz_proplist()) -> kz_proplist(). +-spec custom_application_vars(kzd_freeswitch:data()) -> kz_term:proplist(). +-spec custom_application_vars(kz_term:proplist(), kz_term:proplist()) -> kz_term:proplist(). +-spec custom_application_vars_fold({kz_term:ne_binary(), kz_term:ne_binary()}, kz_term:proplist()) -> kz_term:proplist(). custom_application_vars(Props) -> lists:map(fun application_var_map/1, custom_application_vars(Props, [])). @@ -376,7 +376,7 @@ custom_application_vars(Props, Initial) -> CCVs = lists:foldl(fun custom_application_vars_fold/2, Initial, Props), maybe_update_referred_ccv(Props, application_vars_sort(CCVs)). --spec application_vars_sort(kz_proplist()) -> kz_proplist(). +-spec application_vars_sort(kz_term:proplist()) -> kz_term:proplist(). application_vars_sort(ApplicationVars) -> lists:usort(fun application_var_sort/2, ApplicationVars). @@ -394,19 +394,19 @@ custom_application_vars_fold({?GET_CAV_HEADER(Key), V}, Acc) -> end; custom_application_vars_fold(_, Acc) -> Acc. --spec application_var_map({ne_binary(), ne_binary()}) -> {ne_binary(), ne_binary() | ne_binaries()}. +-spec application_var_map({kz_term:ne_binary(), kz_term:ne_binary()}) -> {kz_term:ne_binary(), kz_term:ne_binary() | kz_term:ne_binaries()}. application_var_map({Key, <<"ARRAY::", Serialized/binary>>}) -> {Key, binary:split(Serialized, <<"|:">>, ['global'])}; application_var_map({Key, Other}) -> {Key, Other}. --spec maybe_update_referred_ccv(kz_proplist(), kz_proplist()) -> kz_proplist(). +-spec maybe_update_referred_ccv(kz_term:proplist(), kz_term:proplist()) -> kz_term:proplist(). maybe_update_referred_ccv(Props, CCVs) -> ReferTo = props:get_value(<<"variable_sip_refer_to">>, Props), update_referred_by_ccv(props:get_value(<<"variable_sip_h_Referred-By">>, Props) ,update_referred_to_ccv(ReferTo, CCVs) ). --spec update_referred_by_ccv(api_binary(), kz_proplist()) -> kz_proplist(). +-spec update_referred_by_ccv(kz_term:api_binary(), kz_term:proplist()) -> kz_term:proplist(). update_referred_by_ccv('undefined', CCVs) -> props:delete(<<"Referred-By">>, CCVs); update_referred_by_ccv(ReferredBy, CCVs) -> props:set_value(<<"Referred-By">> @@ -414,7 +414,7 @@ update_referred_by_ccv(ReferredBy, CCVs) -> ,CCVs ). --spec update_referred_to_ccv(api_binary(), kz_proplist()) -> kz_proplist(). +-spec update_referred_to_ccv(kz_term:api_binary(), kz_term:proplist()) -> kz_term:proplist(). update_referred_to_ccv('undefined', CCVs) -> props:delete(<<"Referred-To">>, CCVs); update_referred_to_ccv(ReferredTo, CCVs) -> props:set_value(<<"Referred-To">> @@ -424,11 +424,11 @@ update_referred_to_ccv(ReferredTo, CCVs) -> %% convert a raw FS string of headers to a proplist %% "Event-Name: NAME\nEvent-Timestamp: 1234\n" -> [{<<"Event-Name">>, <<"NAME">>}, {<<"Event-Timestamp">>, <<"1234">>}] --spec eventstr_to_proplist(text()) -> kz_proplist(). +-spec eventstr_to_proplist(kz_term:text()) -> kz_term:proplist(). eventstr_to_proplist(EvtStr) -> [to_kv(X, ": ") || X <- string:tokens(kz_term:to_list(EvtStr), "\n")]. --spec to_kv(nonempty_string(), nonempty_string()) -> {ne_binary(), ne_binary()}. +-spec to_kv(nonempty_string(), nonempty_string()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. to_kv(X, Separator) -> [K, V] = string:tokens(X, Separator), [{V1, _}] = kz_http_util:parse_query_string(list_to_binary(V)), @@ -438,7 +438,7 @@ fix_value("Event-Date-Timestamp", TStamp) -> kz_time:microseconds_to_seconds(kz_term:to_integer(TStamp)); fix_value(_K, V) -> V. --spec unserialize_fs_array(api_binary()) -> ne_binaries(). +-spec unserialize_fs_array(kz_term:api_binary()) -> kz_term:ne_binaries(). unserialize_fs_array('undefined') -> []; unserialize_fs_array(<<"ARRAY::", Serialized/binary>>) -> binary:split(Serialized, <<"|:">>, ['global']); @@ -448,7 +448,7 @@ unserialize_fs_array(List) unserialize_fs_array(Single) -> [Single]. --spec unserialize_fs_props(kz_proplist()) -> kz_proplist(). +-spec unserialize_fs_props(kz_term:proplist()) -> kz_term:proplist(). unserialize_fs_props(Props) -> lists:map(fun unserialize_fs_prop/1, Props). @@ -459,7 +459,7 @@ unserialize_fs_prop(KV) -> KV. %% convert a raw FS list of vars to a proplist %% "Event-Name=NAME,Event-Timestamp=1234" -> [{<<"Event-Name">>, <<"NAME">>}, {<<"Event-Timestamp">>, <<"1234">>}] --spec varstr_to_proplist(nonempty_string()) -> kz_proplist(). +-spec varstr_to_proplist(nonempty_string()) -> kz_term:proplist(). varstr_to_proplist(VarStr) -> [to_kv(X, "=") || X <- string:tokens(kz_term:to_list(VarStr), ",")]. @@ -473,7 +473,7 @@ get_setting(Setting, Default) -> {'ok', ecallmgr_config:get(Setting, Default)}. -spec is_node_up(atom()) -> boolean(). is_node_up(Node) -> ecallmgr_fs_nodes:is_node_up(Node). --spec is_node_up(atom(), ne_binary()) -> boolean(). +-spec is_node_up(atom(), kz_term:ne_binary()) -> boolean(). is_node_up(Node, UUID) -> ecallmgr_fs_nodes:is_node_up(Node) andalso ecallmgr_fs_channel:exists(UUID). @@ -484,27 +484,27 @@ is_node_up(Node, UUID) -> %% set channel and call variables in FreeSWITCH %% @end %%-------------------------------------------------------------------- --spec multi_set_args(atom(), ne_binary(), kz_proplist()) -> binary(). +-spec multi_set_args(atom(), kz_term:ne_binary(), kz_term:proplist()) -> binary(). multi_set_args(Node, UUID, KVs) -> multi_set_args(Node, UUID, KVs, <>). --spec multi_set_args(atom(), ne_binary(), kz_proplist(), ne_binary()) -> binary(). +-spec multi_set_args(atom(), kz_term:ne_binary(), kz_term:proplist(), kz_term:ne_binary()) -> binary(). multi_set_args(Node, UUID, KVs, Separator) -> multi_set_args(Node, UUID, KVs, Separator, ?FS_MULTI_VAR_SEP_PREFIX). --spec multi_set_args(atom(), ne_binary(), kz_proplist(), ne_binary(), binary() | string()) -> binary(). +-spec multi_set_args(atom(), kz_term:ne_binary(), kz_term:proplist(), kz_term:ne_binary(), binary() | string()) -> binary(). multi_set_args(Node, UUID, KVs, Separator, Prefix) -> fs_args_to_binary(lists:reverse(process_fs_kv(Node, UUID, KVs, 'set')), Separator, Prefix). --spec multi_unset_args(atom(), ne_binary(), kz_proplist()) -> binary(). +-spec multi_unset_args(atom(), kz_term:ne_binary(), kz_term:proplist()) -> binary(). multi_unset_args(Node, UUID, KVs) -> multi_unset_args(Node, UUID, KVs, <>). --spec multi_unset_args(atom(), ne_binary(), kz_proplist(), ne_binary()) -> binary(). +-spec multi_unset_args(atom(), kz_term:ne_binary(), kz_term:proplist(), kz_term:ne_binary()) -> binary(). multi_unset_args(Node, UUID, KVs, Separator) -> multi_unset_args(Node, UUID, KVs, Separator, ?FS_MULTI_VAR_SEP_PREFIX). --spec multi_unset_args(atom(), ne_binary(), kz_proplist(), ne_binary(), binary() | string()) -> binary(). +-spec multi_unset_args(atom(), kz_term:ne_binary(), kz_term:proplist(), kz_term:ne_binary(), binary() | string()) -> binary(). multi_unset_args(Node, UUID, KVs, Separator, Prefix) -> fs_args_to_binary(lists:reverse(process_fs_kv(Node, UUID, KVs, 'unset')), Separator, Prefix). @@ -514,16 +514,16 @@ fs_args_to_binary([_]=Args) -> fs_args_to_binary(Args) -> fs_args_to_binary(Args, <>). --spec fs_args_to_binary(list(), ne_binary()) -> binary(). +-spec fs_args_to_binary(list(), kz_term:ne_binary()) -> binary(). fs_args_to_binary(Args, Sep) -> fs_args_to_binary(Args, Sep, ?FS_MULTI_VAR_SEP_PREFIX). --spec fs_args_to_binary(list(), ne_binary(), binary() | string()) -> binary(). +-spec fs_args_to_binary(list(), kz_term:ne_binary(), binary() | string()) -> binary(). fs_args_to_binary(Args, Sep, Prefix) -> Bins = [list_to_binary([Sep, Arg]) || Arg <- Args], list_to_binary([Prefix, Bins]). --spec process_fs_kv(atom(), ne_binary(), kz_proplist(), atom()) -> [binary()]. +-spec process_fs_kv(atom(), kz_term:ne_binary(), kz_term:proplist(), atom()) -> [binary()]. process_fs_kv(_, _, [], _) -> []; process_fs_kv(Node, UUID, [{K, V}|KVs], Action) -> X1 = format_fs_kv(K, V, UUID, Action), @@ -546,7 +546,7 @@ process_fs_kv_fold(_Node, _UUID, K, 'unset', Acc) process_fs_kv_fold(_, _, _, _, Acc) -> Acc. --spec format_fs_kv(ne_binary(), binary(), ne_binary(), atom()) -> [binary()]. +-spec format_fs_kv(kz_term:ne_binary(), binary(), kz_term:ne_binary(), atom()) -> [binary()]. format_fs_kv(Key, Value, UUID, 'unset') -> case get_fs_key_and_value(Key, Value, UUID) of 'skip' -> []; @@ -561,8 +561,8 @@ format_fs_kv(Key, Value, UUID, _) -> KVs -> [< binary(). +-spec get_fs_key(kz_term:ne_binary()) -> binary(). get_fs_key(?CCV(Key)) -> get_fs_key(Key); get_fs_key(?CAV(_)=CAV) -> CAV; get_fs_key(<<"X-", _/binary>>=Key) -> <<"sip_h_", Key/binary>>; @@ -585,12 +585,12 @@ get_fs_key(Key) -> {_, Prefix} -> Prefix end. --spec get_fs_key_and_value(ne_binary() - ,ne_binary() | ne_binaries() | kz_json:object() - ,ne_binary() +-spec get_fs_key_and_value(kz_term:ne_binary() + ,kz_term:ne_binary() | kz_term:ne_binaries() | kz_json:object() + ,kz_term:ne_binary() ) -> - {ne_binary(), binary()} | - [{ne_binary(), binary()}] | + {kz_term:ne_binary(), binary()} | + [{kz_term:ne_binary(), binary()}] | 'skip'. get_fs_key_and_value(<<"Hold-Media">>=Key, Media, UUID) -> {get_fs_key(Key), media_path(Media, 'extant', UUID, kz_json:new())}; @@ -627,7 +627,7 @@ get_fs_key_and_value(_, _, _) -> 'skip'. %% @doc %% @end %%-------------------------------------------------------------------- --spec maybe_sanitize_fs_value(text(), text()) -> binary(). +-spec maybe_sanitize_fs_value(kz_term:text(), kz_term:text()) -> binary(). maybe_sanitize_fs_value(<<"Outbound-Caller-ID-Name">>, Val) -> re:replace(Val, <<"[^a-zA-Z0-9-\s]">>, <<>>, ['global', {'return', 'binary'}]); maybe_sanitize_fs_value(<<"Outbound-Callee-ID-Name">>, Val) -> @@ -652,14 +652,14 @@ maybe_sanitize_fs_value(_, Val) -> Val. %% endpoints with the invite format of "route" (about 100ms per endpoint) %% @end %%-------------------------------------------------------------------- --type bridge_channel() :: ne_binary(). --type bridge_channels() :: ne_binaries(). +-type bridge_channel() :: kz_term:ne_binary(). +-type bridge_channels() :: kz_term:ne_binaries(). -type build_return() :: bridge_channel() | {'worker', pid()}. -type build_returns() :: [build_return()]. -type bridge_endpoints() :: [bridge_endpoint()]. --spec build_bridge_string(kz_json:objects()) -> ne_binary(). --spec build_bridge_string(kz_json:objects(), ne_binary()) -> ne_binary(). +-spec build_bridge_string(kz_json:objects()) -> kz_term:ne_binary(). +-spec build_bridge_string(kz_json:objects(), kz_term:ne_binary()) -> kz_term:ne_binary(). build_bridge_string(Endpoints) -> build_bridge_string(Endpoints, ?SEPARATOR_SINGLE). @@ -700,7 +700,7 @@ endpoint_jobjs_to_records([Endpoint|Endpoints], IncludeVars, BridgeEndpoints) -> ) end. --spec endpoint_key(kz_json:object()) -> api_binaries(). +-spec endpoint_key(kz_json:object()) -> kz_term:api_binaries(). endpoint_key(Endpoint) -> [kz_json:get_value(<<"Invite-Format">>, Endpoint) ,kz_json:get_value(<<"To-User">>, Endpoint) @@ -749,18 +749,18 @@ endpoint_jobj_to_record_vars(Endpoint, #bridge_endpoint{include_channel_vars='fa ), Bridge#bridge_endpoint{header_vars=ecallmgr_fs_xml:get_leg_vars(Props)}. --spec get_endpoint_span(kz_json:object()) -> ne_binary(). +-spec get_endpoint_span(kz_json:object()) -> kz_term:ne_binary(). get_endpoint_span(Endpoint) -> kz_json:get_binary_value([<<"Endpoint-Options">>, <<"Span">>], Endpoint, <<"1">>). --spec get_endpoint_channel_selection(kz_json:object()) -> ne_binary(). +-spec get_endpoint_channel_selection(kz_json:object()) -> kz_term:ne_binary(). get_endpoint_channel_selection(Endpoint) -> case kz_json:get_binary_value([<<"Endpoint-Options">>, <<"Span">>], Endpoint) of <<"descending">> -> <<"A">>; _Else -> <<"a">> end. --spec get_endpoint_interface(kz_json:object()) -> ne_binary(). +-spec get_endpoint_interface(kz_json:object()) -> kz_term:ne_binary(). get_endpoint_interface(Endpoint) -> case kz_json:is_true([<<"Endpoint-Options">>, <<"Skype-RR">>], Endpoint, 'false') of 'false' -> kz_json:get_value([<<"Endpoint-Options">>, <<"Skype-Interface">>], Endpoint); @@ -792,7 +792,7 @@ call_waiting_map(Endpoint) -> maybe_add_respond_header(Endpoint, OwnerId) end. --spec maybe_add_respond_header(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec maybe_add_respond_header(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). maybe_add_respond_header(Endpoint, OwnerId) -> case ecallmgr_fs_channels:has_channels_for_owner(OwnerId) of 'true' -> @@ -927,7 +927,7 @@ maybe_failover(Endpoint) -> 'false' -> build_sip_channel(endpoint_jobj_to_record(Endpoint)) end. --spec get_sip_contact(bridge_endpoint()) -> ne_binary(). +-spec get_sip_contact(bridge_endpoint()) -> kz_term:ne_binary(). -ifdef(TEST). get_sip_contact(#bridge_endpoint{invite_format = <<"route">>, route = <<"loopback/", Route/binary>>}) -> <<"loopback/", Route/binary, "/", (?DEFAULT_FREESWITCH_CONTEXT)/binary>>; @@ -957,7 +957,7 @@ get_sip_contact(#bridge_endpoint{ip_address='undefined' get_sip_contact(#bridge_endpoint{ip_address=IPAddress}) -> IPAddress. -endif. --spec maybe_clean_contact(ne_binary(), bridge_endpoint()) -> ne_binary(). +-spec maybe_clean_contact(kz_term:ne_binary(), bridge_endpoint()) -> kz_term:ne_binary(). maybe_clean_contact(<<"sip:", Contact/binary>>, _Endpoint) -> Contact; maybe_clean_contact(<<"sips:", Contact/binary>>, _Endpoint) -> Contact; maybe_clean_contact(Contact, #bridge_endpoint{invite_format = <<"route">>}) -> @@ -967,7 +967,7 @@ maybe_clean_contact(Contact, #bridge_endpoint{invite_format = <<"loopback">>}) - maybe_clean_contact(Contact, _) -> re:replace(Contact, <<"^.*?[^=]sip:">>, <<>>, [{'return', 'binary'}]). --spec ensure_username_present(ne_binary(), bridge_endpoint()) -> ne_binary(). +-spec ensure_username_present(kz_term:ne_binary(), bridge_endpoint()) -> kz_term:ne_binary(). ensure_username_present(Contact, #bridge_endpoint{invite_format = <<"route">>}) -> Contact; ensure_username_present(Contact, #bridge_endpoint{invite_format = <<"loopback">>}) -> @@ -978,13 +978,13 @@ ensure_username_present(Contact, Endpoint) -> _ -> <<(guess_username(Endpoint))/binary, "@", Contact/binary>> end. --spec guess_username(bridge_endpoint()) -> ne_binary(). +-spec guess_username(bridge_endpoint()) -> kz_term:ne_binary(). guess_username(#bridge_endpoint{number=Number}) when is_binary(Number) -> Number; guess_username(#bridge_endpoint{username=Username}) when is_binary(Username) -> Username; guess_username(#bridge_endpoint{user=User}) when is_binary(User) -> User; guess_username(_) -> <<"kazoo">>. --spec maybe_replace_fs_path(ne_binary(), bridge_endpoint()) -> ne_binary(). +-spec maybe_replace_fs_path(kz_term:ne_binary(), bridge_endpoint()) -> kz_term:ne_binary(). maybe_replace_fs_path(Contact, #bridge_endpoint{proxy_address='undefined'}) -> Contact; maybe_replace_fs_path(Contact, #bridge_endpoint{proxy_address = <<"sip:", _/binary>> = Proxy}) -> case re:replace(Contact, <<";fs_path=[^;?]*">>, <<";fs_path=", Proxy/binary>>, [{'return', 'binary'}]) of @@ -996,7 +996,7 @@ maybe_replace_fs_path(Contact, #bridge_endpoint{proxy_address = <<"sip:", _/bina maybe_replace_fs_path(Contact, #bridge_endpoint{proxy_address=Proxy}=Endpoint) -> maybe_replace_fs_path(Contact, Endpoint#bridge_endpoint{proxy_address = <<"sip:", Proxy/binary>>}). --spec maybe_replace_transport(ne_binary(), bridge_endpoint()) -> ne_binary(). +-spec maybe_replace_transport(kz_term:ne_binary(), bridge_endpoint()) -> kz_term:ne_binary(). maybe_replace_transport(Contact, #bridge_endpoint{transport='undefined'}) -> Contact; maybe_replace_transport(Contact, #bridge_endpoint{transport=Transport}) -> case re:replace(Contact @@ -1011,7 +1011,7 @@ maybe_replace_transport(Contact, #bridge_endpoint{transport=Transport}) -> Updated -> Updated end. --spec maybe_format_user(ne_binary(), bridge_endpoint()) -> ne_binary(). +-spec maybe_format_user(kz_term:ne_binary(), bridge_endpoint()) -> kz_term:ne_binary(). maybe_format_user(Contact, #bridge_endpoint{invite_format = <<"username">> ,user=User }) when User =/= 'undefined' -> @@ -1029,7 +1029,7 @@ maybe_format_user(Contact, #bridge_endpoint{invite_format = <<"1npan">>, number= re:replace(Contact, "^[^\@]+", knm_converters:to_1npan(Number), [{'return', 'binary'}]); maybe_format_user(Contact, _) -> Contact. --spec maybe_set_interface(ne_binary(), bridge_endpoint()) -> ne_binary(). +-spec maybe_set_interface(kz_term:ne_binary(), bridge_endpoint()) -> kz_term:ne_binary(). maybe_set_interface(<<"sofia/", _/binary>>=Contact, _) -> Contact; maybe_set_interface(<<"loopback/", _/binary>>=Contact, _) -> Contact; maybe_set_interface(Contact, #bridge_endpoint{sip_interface='undefined'}=Endpoint) -> @@ -1046,7 +1046,7 @@ maybe_set_interface(Contact, #bridge_endpoint{sip_interface= <<"sofia/", _/binar maybe_set_interface(Contact, #bridge_endpoint{sip_interface=SIPInterface}) -> <<"sofia/", SIPInterface/binary, "/", Contact/binary>>. --spec append_channel_vars(ne_binary(), bridge_endpoint()) -> ne_binary(). +-spec append_channel_vars(kz_term:ne_binary(), bridge_endpoint()) -> kz_term:ne_binary(). append_channel_vars(Contact, #bridge_endpoint{include_channel_vars='false' ,header_vars=["[",[],"]"] }) -> @@ -1069,8 +1069,8 @@ append_channel_vars(Contact, #bridge_endpoint{channel_vars=ChannelVars}) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec create_masquerade_event(ne_binary(), ne_binary()) -> ne_binary(). --spec create_masquerade_event(ne_binary(), ne_binary(), boolean()) -> ne_binary(). +-spec create_masquerade_event(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). +-spec create_masquerade_event(kz_term:ne_binary(), kz_term:ne_binary(), boolean()) -> kz_term:ne_binary(). create_masquerade_event(Application, EventName) -> create_masquerade_event(Application, EventName, 'true'). @@ -1089,16 +1089,16 @@ create_masquerade_event(Application, EventName, Boolean) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec media_path(ne_binary()) -> ne_binary(). +-spec media_path(kz_term:ne_binary()) -> kz_term:ne_binary(). media_path(MediaName) -> media_path(MediaName, 'new', kz_binary:rand_hex(16), kz_json:new()). --spec media_path(ne_binary(), kz_json:object()) -> ne_binary(). +-spec media_path(kz_term:ne_binary(), kz_json:object()) -> kz_term:ne_binary(). media_path(MediaName, JObj) -> media_path(MediaName, 'new', kz_binary:rand_hex(16), JObj). --spec media_path(ne_binary(), ne_binary(), kz_json:object()) -> ne_binary(). +-spec media_path(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> kz_term:ne_binary(). media_path(MediaName, UUID, JObj) -> media_path(MediaName, 'new', UUID, JObj). --spec media_path(api_binary(), media_types(), ne_binary(), kz_json:object()) -> ne_binary(). +-spec media_path(kz_term:api_binary(), media_types(), kz_term:ne_binary(), kz_json:object()) -> kz_term:ne_binary(). media_path('undefined', _Type, _UUID, _) -> <<"silence_stream://5">>; media_path(<<>>, _Type, _UUID, _) -> <<"silence_stream://5">>; media_path(MediaName, Type, UUID, JObj) when not is_binary(MediaName) -> @@ -1124,14 +1124,14 @@ media_path(MediaName, Type, UUID, JObj) -> kz_term:to_binary(get_fs_playback(Path)) end. --spec fax_filename(ne_binary()) -> file:filename_all(). +-spec fax_filename(kz_term:ne_binary()) -> file:filename_all(). fax_filename(UUID) -> Ext = ecallmgr_config:get_ne_binary(<<"default_fax_extension">>, <<".tiff">>), filename:join([ecallmgr_config:get_ne_binary(<<"fax_file_path">>, <<"/tmp/">>) ,<<(amqp_util:encode(UUID))/binary, Ext/binary>> ]). --spec recording_filename(ne_binary()) -> file:filename_all(). +-spec recording_filename(kz_term:ne_binary()) -> file:filename_all(). recording_filename(<<"local_stream://", MediaName/binary>>) -> recording_filename(MediaName); recording_filename(MediaName) -> Ext = recording_extension(MediaName), @@ -1146,11 +1146,11 @@ recording_filename(MediaName) -> ), RecordingName. --spec recording_directory(ne_binary()) -> ne_binary(). +-spec recording_directory(kz_term:ne_binary()) -> kz_term:ne_binary(). recording_directory(<<"/", _/binary>> = FullPath) -> filename:dirname(FullPath); recording_directory(_RelativePath) -> ecallmgr_config:get_ne_binary(<<"recording_file_path">>, <<"/tmp/">>). --spec recording_extension(ne_binary()) -> ne_binary(). +-spec recording_extension(kz_term:ne_binary()) -> kz_term:ne_binary(). recording_extension(MediaName) -> case filename:extension(MediaName) of Empty when Empty =:= <<>>; @@ -1168,11 +1168,11 @@ recording_extension(MediaName) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_fs_playback(ne_binary()) -> ne_binary(). +-spec get_fs_playback(kz_term:ne_binary()) -> kz_term:ne_binary(). get_fs_playback(<> = URI) -> URI; get_fs_playback(URI) -> maybe_playback_via_vlc(URI). --spec maybe_playback_via_vlc(ne_binary()) -> ne_binary(). +-spec maybe_playback_via_vlc(kz_term:ne_binary()) -> kz_term:ne_binary(). maybe_playback_via_vlc(URI) -> case ecallmgr_config:is_true(<<"use_vlc">>, 'false') of 'false' -> maybe_playback_via_shout(URI); @@ -1181,7 +1181,7 @@ maybe_playback_via_vlc(URI) -> <<"vlc://", URI/binary>> end. --spec maybe_playback_via_shout(ne_binary()) -> ne_binary(). +-spec maybe_playback_via_shout(kz_term:ne_binary()) -> kz_term:ne_binary(). maybe_playback_via_shout(URI) -> case filename:extension(URI) =:= <<".mp3">> andalso ecallmgr_config:is_true(<<"use_shout">>, 'false') @@ -1192,7 +1192,7 @@ maybe_playback_via_shout(URI) -> binary:replace(URI, [<<"http">>, <<"https">>], <<"shout">>) end. --spec maybe_playback_via_http_cache(ne_binary()) -> ne_binary(). +-spec maybe_playback_via_http_cache(kz_term:ne_binary()) -> kz_term:ne_binary(). maybe_playback_via_http_cache(<> = URI) -> lager:debug("media is streamed via http_cache, using ~s", [URI]), URI; @@ -1208,19 +1208,19 @@ maybe_playback_via_http_cache(URI) -> %% given a proplist of a FS event, return the Kazoo-equivalent app name(s). %% a FS event could have multiple Kazoo equivalents --spec convert_fs_evt_name(ne_binary()) -> ne_binaries(). +-spec convert_fs_evt_name(kz_term:ne_binary()) -> kz_term:ne_binaries(). convert_fs_evt_name(EvtName) -> [WhAppEvt || {FSEvt, WhAppEvt} <- ?FS_APPLICATION_NAMES, FSEvt =:= EvtName]. %% given a Kazoo Dialplan Application name, return the FS-equivalent event name %% A Kazoo Dialplan Application name is 1-to-1 with the FS-equivalent --spec convert_kazoo_app_name(ne_binary()) -> ne_binaries(). +-spec convert_kazoo_app_name(kz_term:ne_binary()) -> kz_term:ne_binaries(). convert_kazoo_app_name(App) -> [EvtName || {EvtName, AppName} <- ?FS_APPLICATION_NAMES, App =:= AppName]. -type media_types() :: 'new' | 'extant'. --spec lookup_media(ne_binary(), media_types(), ne_binary(), kz_json:object()) -> - {'ok', ne_binary()} | +-spec lookup_media(kz_term:ne_binary(), media_types(), kz_term:ne_binary(), kz_json:object()) -> + {'ok', kz_term:ne_binary()} | {'error', any()}. lookup_media(MediaName, Type, CallId, JObj) -> case kz_cache:fetch_local(?ECALLMGR_UTIL_CACHE @@ -1234,8 +1234,8 @@ lookup_media(MediaName, Type, CallId, JObj) -> request_media_url(MediaName, Type, CallId, JObj) end. --spec request_media_url(ne_binary(), media_types(), ne_binary(), kz_json:object()) -> - {'ok', ne_binary()} | +-spec request_media_url(kz_term:ne_binary(), media_types(), kz_term:ne_binary(), kz_json:object()) -> + {'ok', kz_term:ne_binary()} | {'error', any()}. request_media_url(MediaName, Type, CallId, JObj) -> MsgProps = props:filter_undefined( @@ -1271,7 +1271,7 @@ request_media_url(MediaName, Type, CallId, JObj) -> E end. --spec media_url_cache_props(ne_binary()) -> kz_cache:store_options(). +-spec media_url_cache_props(kz_term:ne_binary()) -> kz_cache:store_options(). media_url_cache_props(<<"/", _/binary>> = MediaName) -> case binary:split(MediaName, <<"/">>, ['global']) of [<<>>, AccountId, MediaId] -> @@ -1293,15 +1293,15 @@ media_url_cache_props(<<"tts://", Text/binary>>) -> [{'origin', {'db', <<"tts">>, Id}}]; media_url_cache_props(_MediaName) -> []. --spec custom_sip_headers(kz_proplist()) -> kz_proplist(). +-spec custom_sip_headers(kz_term:proplist()) -> kz_term:proplist(). custom_sip_headers(Props) -> lists:foldl(fun maybe_aggregate_headers/2 ,[] ,props:filter(fun is_custom_sip_header/1, Props) ). --spec maybe_aggregate_headers({ne_binary(), ne_binary()}, kz_proplist()) -> - kz_proplist(). +-spec maybe_aggregate_headers({kz_term:ne_binary(), kz_term:ne_binary()}, kz_term:proplist()) -> + kz_term:proplist(). maybe_aggregate_headers(KV, Acc) -> {K, V} = normalize_custom_sip_header_name(KV), maybe_aggregate_headers(K, V, Acc). @@ -1326,7 +1326,7 @@ is_custom_sip_header({?GET_CCV_HEADER(_), _}) -> 'false'; is_custom_sip_header({<<"variable_sip_h_", _/binary>>, _}) -> 'true'; is_custom_sip_header(_Header) -> 'false'. --spec maybe_add_expires_deviation(api_integer()) -> api_integer(). +-spec maybe_add_expires_deviation(kz_term:api_integer()) -> kz_term:api_integer(). maybe_add_expires_deviation('undefined') -> 'undefined'; maybe_add_expires_deviation(Expires) when not is_integer(Expires) -> maybe_add_expires_deviation(kz_term:to_integer(Expires)); @@ -1334,14 +1334,14 @@ maybe_add_expires_deviation(0) -> 0; maybe_add_expires_deviation(Expires) -> Expires + ?EXPIRES_DEVIATION_TIME. --spec maybe_add_expires_deviation_ms(api_integer()) -> api_integer(). +-spec maybe_add_expires_deviation_ms(kz_term:api_integer()) -> kz_term:api_integer(). maybe_add_expires_deviation_ms('undefined') -> 'undefined'; maybe_add_expires_deviation_ms(Expires) when not is_integer(Expires) -> maybe_add_expires_deviation_ms(kz_term:to_integer(Expires)); maybe_add_expires_deviation_ms(Expires) -> maybe_add_expires_deviation(Expires) * ?MILLISECONDS_IN_SECOND. --spec get_dial_separator(api_object() | ne_binary(), kz_json:objects()) -> ne_binary(). +-spec get_dial_separator(kz_term:api_object() | kz_term:ne_binary(), kz_json:objects()) -> kz_term:ne_binary(). get_dial_separator(?DIAL_METHOD_SINGLE, _Endpoints) -> ?SEPARATOR_SINGLE; get_dial_separator(?DIAL_METHOD_SIMUL, [_, _|_]) -> ?SEPARATOR_SIMULTANEOUS; get_dial_separator(?DIAL_METHOD_SIMUL, [_]) -> ?SEPARATOR_SINGLE; @@ -1351,7 +1351,7 @@ get_dial_separator(JObj, Endpoints) -> ,Endpoints ). --spec fix_contact(api_binary() | list(), ne_binary(), ne_binary()) -> api_binary(). +-spec fix_contact(kz_term:api_binary() | list(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_binary(). fix_contact('undefined', _, _) -> 'undefined'; fix_contact(<<";", _/binary>> = OriginalContact, Username, Realm) -> fix_contact(<<"sip:", Username/binary, "@", Realm/binary, OriginalContact/binary>>, Username, Realm); diff --git a/applications/ecallmgr/src/freeswitch.erl b/applications/ecallmgr/src/freeswitch.erl index 3ab98fb04fe..5b9aba8d5ff 100644 --- a/applications/ecallmgr/src/freeswitch.erl +++ b/applications/ecallmgr/src/freeswitch.erl @@ -76,9 +76,9 @@ bind(Node, Type, Timeout) -> ?FS_MODULE:bind(Node, Type, Timeout). fetch_reply(Node, FetchID, Section, Reply) -> ?FS_MODULE:fetch_reply(Node, FetchID, Section, Reply). fetch_reply(Node, FetchID, Section, Reply, Timeout) -> ?FS_MODULE:fetch_reply(Node, FetchID, Section, Reply, Timeout). --spec api(atom(), text()) -> fs_api_return(). --spec api(atom(), text(), text()) -> fs_api_return(). --spec api(atom(), text(), text(), kz_timeout()) -> fs_api_return(). +-spec api(atom(), kz_term:text()) -> fs_api_return(). +-spec api(atom(), kz_term:text(), kz_term:text()) -> fs_api_return(). +-spec api(atom(), kz_term:text(), kz_term:text(), timeout()) -> fs_api_return(). api(Node, Cmd) -> ?FS_MODULE:api(Node, Cmd). api(Node, Cmd, Args) -> ?FS_MODULE:api(Node, Cmd, Args). api(Node, Cmd, Args, Timeout) -> ?FS_MODULE:api(Node, Cmd, Args, Timeout). @@ -96,7 +96,7 @@ bgapi(Node, Cmd, Args, Fun) -> ?FS_MODULE:bgapi(Node, Cmd, Args, Fun). -spec bgapi(atom(), atom(), string() | binary(), fun(), list()) -> fs_api_return(). bgapi(Node, Cmd, Args, Fun, CallBackParams) -> ?FS_MODULE:bgapi(Node, Cmd, Args, Fun, CallBackParams). --spec bgapi(atom(), ne_binary(), list(), atom(), string() | binary(), fun()) -> fs_api_return(). +-spec bgapi(atom(), kz_term:ne_binary(), list(), atom(), string() | binary(), fun()) -> fs_api_return(). bgapi(Node, UUID, CallBackParams, Cmd, Args, Fun) -> ?FS_MODULE:bgapi(Node, UUID, CallBackParams, Cmd, Args, Fun). -type event() :: atom() | kz_json:object(). @@ -114,7 +114,7 @@ sendevent(Node, EventName, Headers) -> ?FS_MODULE:sendevent(Node, EventName, Hea -spec sendevent_custom(atom(), atom(), list()) -> 'ok'. sendevent_custom(Node, SubClassName, Headers) -> ?FS_MODULE:sendevent_custom(Node, SubClassName, Headers). --spec sendmsg(atom(), ne_binary(), list()) -> fs_api_return(). +-spec sendmsg(atom(), kz_term:ne_binary(), list()) -> fs_api_return(). sendmsg(Node, UUID, Headers) -> ?FS_MODULE:sendmsg(Node, UUID, Headers). -spec config(atom()) -> 'ok'. diff --git a/applications/ecallmgr/src/mod_kazoo.erl b/applications/ecallmgr/src/mod_kazoo.erl index e4ec2aad0c1..fc3e879cf87 100644 --- a/applications/ecallmgr/src/mod_kazoo.erl +++ b/applications/ecallmgr/src/mod_kazoo.erl @@ -125,9 +125,9 @@ fetch_reply(Node, FetchID, Section, Reply, Timeout) -> {'error', 'exception'} end. --spec api(atom(), text()) -> fs_api_return(). --spec api(atom(), text(), text()) -> fs_api_return(). --spec api(atom(), text(), text(), kz_timeout()) -> fs_api_return(). +-spec api(atom(), kz_term:text()) -> fs_api_return(). +-spec api(atom(), kz_term:text(), kz_term:text()) -> fs_api_return(). +-spec api(atom(), kz_term:text(), kz_term:text(), timeout()) -> fs_api_return(). api(Node, Cmd) -> api(Node, Cmd, ""). api(Node, Cmd, Args) -> @@ -246,7 +246,7 @@ bgapi(Node, Cmd, Args, Fun, CallBackParams) when is_function(Fun, 3) -> {'api', Result} -> Result end. --spec bgapi(atom(), ne_binary(), list(), atom(), string() | binary(), fun()) -> fs_api_return(). +-spec bgapi(atom(), kz_term:ne_binary(), list(), atom(), string() | binary(), fun()) -> fs_api_return(). bgapi(Node, UUID, CallBackParams, Cmd, Args, Fun) when is_function(Fun, 6) -> Self = self(), _ = kz_util:spawn( @@ -320,7 +320,7 @@ sendevent(Node, EventName, Headers) -> sendevent_custom(Node, SubClassName, Headers) -> gen_server:cast({'mod_kazoo', Node}, {'sendevent', 'CUSTOM', SubClassName, Headers}). --spec sendmsg(atom(), ne_binary(), list()) -> fs_api_return(). +-spec sendmsg(atom(), kz_term:ne_binary(), list()) -> fs_api_return(). sendmsg(Node, UUID, Headers) -> gen_server:call({'mod_kazoo', Node}, {'sendmsg', UUID, Headers}). diff --git a/applications/fax/src/fax.hrl b/applications/fax/src/fax.hrl index 740562927fd..30c859277c9 100644 --- a/applications/fax/src/fax.hrl +++ b/applications/fax/src/fax.hrl @@ -21,9 +21,9 @@ ]} ]). --record(fax_storage, {id :: api_binary() - ,attachment_id :: api_binary() - ,db :: api_binary() +-record(fax_storage, {id :: kz_term:api_binary() + ,attachment_id :: kz_term:api_binary() + ,db :: kz_term:api_binary() }). -type fax_storage() :: #fax_storage{}. diff --git a/applications/fax/src/fax_app.erl b/applications/fax/src/fax_app.erl index 57715a7c852..ec3219372f1 100644 --- a/applications/fax/src/fax_app.erl +++ b/applications/fax/src/fax_app.erl @@ -17,7 +17,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = kapps_maintenance:bind('migrate', 'fax_maintenance', 'migrate'), fax_sup:start_link(). diff --git a/applications/fax/src/fax_cloud.erl b/applications/fax/src/fax_cloud.erl index 9f171dc76c9..1d8533056ae 100644 --- a/applications/fax/src/fax_cloud.erl +++ b/applications/fax/src/fax_cloud.erl @@ -25,7 +25,7 @@ %%% API %%%=================================================================== --spec handle_job_notify(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_job_notify(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_job_notify(JObj, _Props) -> case kz_json:get_value(<<"Event-Name">>, JObj) of <<"outbound_fax_error">> -> @@ -53,7 +53,7 @@ handle_job_notify(JObj, _Props) -> process_job_outcome(PrinterId, CloudJobId, kz_json:get_value(<<"Event-Name">>, JObj)) end. --spec process_job_outcome(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec process_job_outcome(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. process_job_outcome(PrinterId, JobId, <<"outbound_fax_error">>) -> process_job_outcome(PrinterId, JobId, <<"ABORTED">>); process_job_outcome(PrinterId, JobId, <<"outbound_fax">>) -> @@ -61,7 +61,7 @@ process_job_outcome(PrinterId, JobId, <<"outbound_fax">>) -> process_job_outcome(PrinterId, JobId, Status) -> update_job_status(PrinterId, JobId, Status). --spec handle_push(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_push(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_push(JObj, _Props) -> 'true' = kapi_xmpp:event_v(JObj), AppName = kz_json:get_value(<<"Application-Name">>, JObj), @@ -70,7 +70,7 @@ handle_push(JObj, _Props) -> JID = kz_json:get_value(<<"JID">>, JObj), handle_push_event(JID, AppName, AppEvent, AppData). --spec handle_push_event(ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec handle_push_event(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. handle_push_event(_JID, <<"GCP">>, <<"Queued-Job">>, PrinterId) -> URL = <>, case get_printer_oauth_credentials(PrinterId) of @@ -95,7 +95,7 @@ handle_push_event(_JID, <<"GCP">>, <<"Queued-Job">>, PrinterId) -> handle_push_event(JID, AppName, AppEvent, AppData) -> lager:debug("unhandled xmpp push event ~s/~s/~s/~p",[JID, AppName, AppEvent, AppData]). --spec maybe_process_job(kz_json:objects(), ne_binary()) -> 'ok'. +-spec maybe_process_job(kz_json:objects(), kz_term:ne_binary()) -> 'ok'. maybe_process_job([], _Authorization) -> 'ok'; maybe_process_job([JObj | JObjs], Authorization) -> JobId = kz_doc:id(JObj), @@ -125,7 +125,7 @@ maybe_fax_number(A, B) -> _Other -> B end. --spec fetch_ticket(ne_binary(), ne_binary()) -> kz_json:object(). +-spec fetch_ticket(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). fetch_ticket(JobId, Authorization) -> URL = <>, Headers = [?GPC_PROXY_HEADER @@ -139,7 +139,7 @@ fetch_ticket(JobId, Authorization) -> kz_json:new() end. --spec update_job_status(ne_binary(), ne_binary(), ne_binary() | kz_json:object()) -> any(). +-spec update_job_status(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary() | kz_json:object()) -> any(). update_job_status(PrinterId, JobId, <<"IN_PROGRESS">>=Status) -> StateObj = kz_json:set_value(<<"state">>, kz_json:set_value(<<"type">>, Status, kz_json:new()), kz_json:new()), update_job_status(PrinterId, JobId, StateObj); @@ -166,7 +166,7 @@ update_job_status(PrinterId, JobId, Status) -> lager:debug("error getting printer (~s) oauth credentials when updating job (~s) status : ~p",[PrinterId, JobId, E]) end. --spec send_update_job_status(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec send_update_job_status(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. send_update_job_status(JobId, Status, Authorization) -> Headers = [?GPC_PROXY_HEADER ,{"Authorization",Authorization} @@ -192,8 +192,8 @@ send_update_job_status(JobId, Status, Authorization) -> lager:debug("unexpected response sending update_job_status: ~p", [_Response]) end. --spec download_file(ne_binary(), ne_binary()) -> - {'ok', ne_binary(), ne_binary()} | +-spec download_file(kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary(), kz_term:ne_binary()} | {'error', any()}. download_file(URL, Authorization) -> Headers = [?GPC_PROXY_HEADER , {"Authorization",Authorization}], @@ -217,7 +217,7 @@ download_file(URL, Authorization) -> {'error', Response} end. --spec maybe_save_fax_document(kz_json:object(), ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec maybe_save_fax_document(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. maybe_save_fax_document(Job, JobId, PrinterId, FaxNumber, FileURL ) -> case save_fax_document(Job, JobId, PrinterId, FaxNumber) of {'ok', JObj} -> @@ -228,7 +228,7 @@ maybe_save_fax_document(Job, JobId, PrinterId, FaxNumber, FileURL ) -> lager:debug("got error saving fax job ~s : ~p", [JobId, _E]) end. --spec maybe_save_fax_attachment(kz_json:object(), ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec maybe_save_fax_attachment(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. maybe_save_fax_attachment(JObj, JobId, PrinterId, FileURL ) -> case get_printer_oauth_credentials(PrinterId) of {'ok', Authorization} -> @@ -246,7 +246,7 @@ maybe_save_fax_attachment(JObj, JobId, PrinterId, FileURL ) -> lager:debug("error getting printer (~s) oauth credentials for JobId (~s) : ~p",[PrinterId, JobId, E]) end. --spec save_fax_document(kz_json:object(), ne_binary(), ne_binary(), ne_binary()) -> +-spec save_fax_document(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. save_fax_document(Job, JobId, PrinterId, FaxNumber ) -> @@ -309,7 +309,7 @@ save_fax_document(Job, JobId, PrinterId, FaxNumber ) -> ), kz_datamgr:save_doc(?KZ_FAXES_DB, Doc). --spec get_faxbox_doc(ne_binary()) -> +-spec get_faxbox_doc(kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. get_faxbox_doc(PrinterId) -> @@ -319,7 +319,7 @@ get_faxbox_doc(PrinterId) -> fetch_faxbox_doc(PrinterId) end. --spec fetch_faxbox_doc(ne_binary()) -> +-spec fetch_faxbox_doc(kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. fetch_faxbox_doc(PrinterId) -> @@ -341,7 +341,7 @@ maybe_get_faxbox_owner_email(FaxBoxDoc) -> OwnerId -> get_faxbox_owner_email(FaxBoxDoc, OwnerId) end. --spec get_faxbox_owner_email(kz_json:object(), ne_binary()) -> +-spec get_faxbox_owner_email(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). get_faxbox_owner_email(FaxBoxDoc, OwnerId) -> AccountId = kz_doc:account_id(FaxBoxDoc), @@ -356,8 +356,8 @@ get_faxbox_owner_email(FaxBoxDoc, OwnerId) -> FaxBoxDoc end. --spec get_printer_oauth_credentials(ne_binary()) -> - {'ok', ne_binary()} | +-spec get_printer_oauth_credentials(kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | {'error', any()}. get_printer_oauth_credentials(PrinterId) -> case kz_cache:peek_local(?CACHE_NAME, {'gcp', PrinterId }) of @@ -366,8 +366,8 @@ get_printer_oauth_credentials(PrinterId) -> fetch_printer_oauth_credentials(PrinterId) end. --spec fetch_printer_oauth_credentials(ne_binary()) -> - {'ok', ne_binary()} | +-spec fetch_printer_oauth_credentials(kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | {'error', any()}. fetch_printer_oauth_credentials(PrinterId) -> case get_faxbox_doc(PrinterId) of @@ -381,11 +381,11 @@ fetch_printer_oauth_credentials(PrinterId) -> {'ok', Auth} end. --spec handle_faxbox_edited(kz_json:object(), kz_proplist()) -> pid(). +-spec handle_faxbox_edited(kz_json:object(), kz_term:proplist()) -> pid(). handle_faxbox_edited(JObj, Props) -> handle_faxbox_created(JObj, Props). --spec handle_faxbox_created(kz_json:object(), kz_proplist()) -> pid(). +-spec handle_faxbox_created(kz_json:object(), kz_term:proplist()) -> pid(). handle_faxbox_created(JObj, _Props) -> 'true' = kapi_conf:doc_update_v(JObj), ID = kz_json:get_value(<<"ID">>, JObj), @@ -395,7 +395,7 @@ handle_faxbox_created(JObj, _Props) -> AppId = kapps_account_config:get(ResellerId, ?CONFIG_CAT, <<"cloud_oauth_app">>), kz_util:spawn(fun check_registration/3, [AppId, State, Doc]). --spec check_registration(ne_binary(), ne_binary(), kz_json:object() ) -> 'ok'. +-spec check_registration(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object() ) -> 'ok'. check_registration('undefined', _, _JObj) -> 'ok'; check_registration(_, 'undefined', _JObj) -> 'ok'; check_registration(_, <<"expired">>, _JObj) -> 'ok'; @@ -413,7 +413,7 @@ check_registration(AppId, <<"registered">>, JObj) -> end; check_registration(_, _, _JObj) -> 'ok'. --spec process_registration_result(boolean(), ne_binary(), kz_json:object(), kz_json:object() ) -> any(). +-spec process_registration_result(boolean(), kz_term:ne_binary(), kz_json:object(), kz_json:object() ) -> any(). process_registration_result('true', AppId, JObj, Result) -> _AccountId = kz_doc:account_id(JObj), _PrinterId = kz_json:get_value(<<"pvt_cloud_printer_id">>, JObj), @@ -481,7 +481,7 @@ update_printer(JObj) -> {'ok', _} = kz_datamgr:ensure_saved(?KZ_FAXES_DB, JObj), 'ok'. --spec handle_faxbox_deleted(kz_json:object(), kz_proplist()) -> any(). +-spec handle_faxbox_deleted(kz_json:object(), kz_term:proplist()) -> any(). handle_faxbox_deleted(JObj, _Props) -> lager:debug("faxbox_deleted ~p",[JObj]), 'true' = kapi_conf:doc_update_v(JObj), diff --git a/applications/fax/src/fax_init.erl b/applications/fax/src/fax_init.erl index 24e160364b0..920bb111490 100644 --- a/applications/fax/src/fax_init.erl +++ b/applications/fax/src/fax_init.erl @@ -15,7 +15,7 @@ %% @public %% @doc Starts the app for inclusion in a supervisor tree %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> _ = declare_exchanges(), Dispatch = cowboy_router:compile([ diff --git a/applications/fax/src/fax_jobs.erl b/applications/fax/src/fax_jobs.erl index e028022c07d..c0435caa531 100644 --- a/applications/fax/src/fax_jobs.erl +++ b/applications/fax/src/fax_jobs.erl @@ -39,8 +39,8 @@ ,numbers => #{} }). --record(state, {account_id :: ne_binary() - ,queue = 'undefined' :: api_binary() +-record(state, {account_id :: kz_term:ne_binary() + ,queue = 'undefined' :: kz_term:api_binary() ,jobs = #{} ,limits = #{} ,stale = 0 :: integer() @@ -66,7 +66,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(ne_binary()) -> startlink_ret(). +-spec start_link(kz_term:ne_binary()) -> kz_types:startlink_ret(). start_link(AccountId) -> case gen_listener:start_link(?SERVER(AccountId) ,?MODULE @@ -101,7 +101,7 @@ start_link(AccountId) -> %% {stop, Reason} %% @end %%-------------------------------------------------------------------- --spec init([ne_binary()]) -> {'ok', state(), kz_timeout()}. +-spec init([kz_term:ne_binary()]) -> {'ok', state(), timeout()}. init([AccountId]) -> _ = kz_util:spawn(fun cleanup_jobs/1, [AccountId]), State = #state{account_id=AccountId @@ -124,7 +124,7 @@ init([AccountId]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State, ?POLLING_INTERVAL}. @@ -138,7 +138,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'job_status',{JobId, <<"start">>, ServerId}}, #state{jobs=#{pending := Pending ,running := Running }=Jobs @@ -186,7 +186,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info('timeout', #state{queue='undefined'}=State) -> {'noreply', State, ?POLLING_INTERVAL}; handle_info('timeout', #state{account_id=AccountId @@ -293,7 +293,7 @@ invalidate_job(Job, #state{account_id=AccountId}=State) -> kz_datamgr:del_doc(?KZ_FAXES_DB, kz_doc:id(Job)), State. --spec distribute_job(ne_binary(), kz_json:object(), state()) -> state(). +-spec distribute_job(kz_term:ne_binary(), kz_json:object(), state()) -> state(). distribute_job(ToNumber, Job, #state{account_id=AccountId ,queue=Q ,jobs=#{pending := Pending @@ -320,7 +320,7 @@ distribute_job(ToNumber, Job, #state{account_id=AccountId }}) end. --spec handle_start_account(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_start_account(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_start_account(JObj, _Props) -> 'true' = kapi_fax:start_account_v(JObj), AccountId = kapi_fax:account_id(JObj), @@ -331,17 +331,17 @@ handle_start_account(JObj, _Props) -> 'ok' end. --spec is_running(ne_binary()) -> boolean(). +-spec is_running(kz_term:ne_binary()) -> boolean(). is_running(AccountId) -> kz_globals:where_is(?FAX_OUTBOUND_SERVER(AccountId)) =/= 'undefined'. --spec is_number_valid(api_binary(), ne_binary()) -> boolean(). +-spec is_number_valid(kz_term:api_binary(), kz_term:ne_binary()) -> boolean(). is_number_valid('undefined', _AccountId) -> 'false'; is_number_valid(<<>>, _AccountId) -> 'false'; is_number_valid(Number, AccountId) -> knm_converters:is_reconcilable(Number, AccountId). --spec number(kz_json:object()) -> api_binary(). +-spec number(kz_json:object()) -> kz_term:api_binary(). number(JObj) -> case kz_json:get_value([<<"value">>, <<"to">>], JObj) of 'undefined' -> 'undefined'; @@ -349,7 +349,7 @@ number(JObj) -> Number -> Number end. --spec check_pending(ne_binary(), map(), map()) -> map(). +-spec check_pending(kz_term:ne_binary(), map(), map()) -> map(). check_pending(JobId, #{number := ToNumber, start := Start}, #{pending := Pending, numbers := Numbers} = Map) -> case kz_time:now_ms() - Start > ?MAX_WAIT_FOR_PENDING of 'true' -> @@ -361,7 +361,7 @@ check_pending(JobId, #{number := ToNumber, start := Start}, #{pending := Pending Map end. --spec check_running(ne_binary(), map(), map()) -> map(). +-spec check_running(kz_term:ne_binary(), map(), map()) -> map(). check_running(JobId, #{number := ToNumber, start := Start}, #{running := Running, numbers := Numbers} = Map) -> case kz_time:now_ms() - Start > ?MAX_WAIT_FOR_RUNNING of 'true' -> @@ -373,7 +373,7 @@ check_running(JobId, #{number := ToNumber, start := Start}, #{running := Running Map end. --spec get_account_jobs(ne_binary()) -> kz_json:objects(). +-spec get_account_jobs(kz_term:ne_binary()) -> kz_json:objects(). get_account_jobs(AccountId) -> Upto = kz_time:now_s(), ViewOptions = [{'limit', 100} @@ -414,7 +414,7 @@ lock_account_job(Doc, JObj, Jobs) -> Jobs end. --spec cleanup_jobs(ne_binary()) -> 'ok'. +-spec cleanup_jobs(kz_term:ne_binary()) -> 'ok'. cleanup_jobs(AccountId) -> ViewOptions = [{'key', AccountId} ], diff --git a/applications/fax/src/fax_jobs_sup.erl b/applications/fax/src/fax_jobs_sup.erl index 00bf909fbc1..07d030e8a75 100644 --- a/applications/fax/src/fax_jobs_sup.erl +++ b/applications/fax/src/fax_jobs_sup.erl @@ -21,7 +21,7 @@ -define(CHILDREN, [?WORKER_TYPE('fax_jobs', 'transient')]). --spec start_account_jobs(ne_binary()) -> sup_startchild_ret(). +-spec start_account_jobs(kz_term:ne_binary()) -> kz_types:sup_startchild_ret(). start_account_jobs(AccountId) -> supervisor:start_child(?MODULE, [AccountId]). @@ -29,7 +29,7 @@ start_account_jobs(AccountId) -> %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -42,7 +42,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 5, diff --git a/applications/fax/src/fax_maintenance.erl b/applications/fax/src/fax_maintenance.erl index db04f25cec4..f7b6f2ec24d 100644 --- a/applications/fax/src/fax_maintenance.erl +++ b/applications/fax/src/fax_maintenance.erl @@ -36,7 +36,7 @@ migrate() -> migrate_outbound_faxes(), 'ok'. --spec migrate(ne_binaries() | ne_binary()) -> 'ok'. +-spec migrate(kz_term:ne_binaries() | kz_term:ne_binary()) -> 'ok'. migrate([]) -> 'ok'; migrate(<<"override_existing_documents">>) -> Accounts = kapps_util:get_all_accounts(), @@ -49,7 +49,7 @@ migrate([Account|Accounts]) -> migrate(Account) -> migrate_faxes(Account, ?DEFAULT_MIGRATE_OPTIONS). --spec migrate(ne_binaries() | ne_binary(), ne_binary() | kz_proplist()) -> 'ok'. +-spec migrate(kz_term:ne_binaries() | kz_term:ne_binary(), kz_term:ne_binary() | kz_term:proplist()) -> 'ok'. migrate([], _) -> 'ok'; migrate(Accounts, <<"override_existing_documents">>) -> migrate(Accounts, ?OVERRIDE_DOCS); @@ -66,7 +66,7 @@ migrate_faxes_fold(AccountDb, Current, Total, Options) -> _ = migrate_faxes(AccountDb, Options), Current + 1. --spec migrate_faxes(atom() | string() | binary(), kz_proplist()) -> 'ok'. +-spec migrate_faxes(atom() | string() | binary(), kz_term:proplist()) -> 'ok'. migrate_faxes(Account, Options) when not is_binary(Account) -> migrate_faxes(kz_term:to_binary(Account), Options); migrate_faxes(Account, Options) -> @@ -74,9 +74,9 @@ migrate_faxes(Account, Options) -> recover_private_media(Account), migrate_faxes_to_modb(Account, Options). --spec migrate_private_media(ne_binary()) -> 'ok'. --spec migrate_private_media(ne_binary(), kz_json:object(), ne_binary()) -> 'ok'. --spec maybe_migrate_private_media(ne_binary(), kz_json:object()) -> 'ok'. +-spec migrate_private_media(kz_term:ne_binary()) -> 'ok'. +-spec migrate_private_media(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> 'ok'. +-spec maybe_migrate_private_media(kz_term:ne_binary(), kz_json:object()) -> 'ok'. migrate_private_media(Account) -> AccountDb = case kz_datamgr:db_exists(Account) of @@ -108,9 +108,9 @@ migrate_private_media(AccountDb, Doc, <<"tiff">>) -> 'ok'; migrate_private_media(_AccountDb, _JObj, _MediaType) -> 'ok'. --spec recover_private_media(ne_binary()) -> 'ok'. --spec recover_private_media(ne_binary(), kz_json:object(), ne_binary()) -> 'ok'. --spec maybe_recover_private_media(ne_binary(), kz_json:object()) -> 'ok'. +-spec recover_private_media(kz_term:ne_binary()) -> 'ok'. +-spec recover_private_media(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> 'ok'. +-spec maybe_recover_private_media(kz_term:ne_binary(), kz_json:object()) -> 'ok'. recover_private_media(Account) -> AccountDb = case kz_datamgr:db_exists(Account) of @@ -137,9 +137,9 @@ recover_private_media(AccountDb, Doc, _MediaType) -> {'ok', _ } = kz_datamgr:ensure_saved(AccountDb, kz_doc:set_type(Doc, <<"private_media">>)), 'ok'. --spec migrate_faxes_to_modb(ne_binary(), kz_proplist()) -> 'ok'. --spec maybe_migrate_fax_to_modb(ne_binary(), kz_json:object(), kz_proplist()) -> 'ok'. --spec migrate_fax_to_modb(ne_binary(), ne_binary(), kz_json:object(), kz_proplist()) -> 'ok'. +-spec migrate_faxes_to_modb(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. +-spec maybe_migrate_fax_to_modb(kz_term:ne_binary(), kz_json:object(), kz_term:proplist()) -> 'ok'. +-spec migrate_fax_to_modb(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), kz_term:proplist()) -> 'ok'. migrate_faxes_to_modb(Account, Options) -> AccountDb = case kz_datamgr:db_exists(Account) of @@ -200,8 +200,8 @@ migrate_fax_to_modb(AccountDb, DocId, JObj, Options) -> -spec flush() -> 'ok'. flush() -> kz_cache:flush_local(?CACHE_NAME). --spec account_jobs(ne_binary()) -> 'no_return'. --spec account_jobs(ne_binary(), ne_binary()) -> 'no_return'. +-spec account_jobs(kz_term:ne_binary()) -> 'no_return'. +-spec account_jobs(kz_term:ne_binary(), kz_term:ne_binary()) -> 'no_return'. account_jobs(AccountId) -> account_jobs(AccountId, <<"pending">>). @@ -234,8 +234,8 @@ account_jobs(AccountId, State) -> io:format("+--------------------------------+-------------------+-----------------+----------------------------------+----------------------------------+----------------------+----------------------+~n", []), 'no_return'. --spec faxbox_jobs(ne_binary()) -> 'no_return'. --spec faxbox_jobs(ne_binary(), ne_binary()) -> 'no_return'. +-spec faxbox_jobs(kz_term:ne_binary()) -> 'no_return'. +-spec faxbox_jobs(kz_term:ne_binary(), kz_term:ne_binary()) -> 'no_return'. faxbox_jobs(FaxboxId) -> faxbox_jobs(FaxboxId, <<"pending">>). @@ -354,7 +354,7 @@ update_job(JobID, State, JObj) -> migrate_outbound_faxes() -> migrate_outbound_faxes(?DEFAULT_BATCH_SIZE). --spec migrate_outbound_faxes(ne_binary() | integer() | kz_proplist()) -> 'ok'. +-spec migrate_outbound_faxes(kz_term:ne_binary() | integer() | kz_term:proplist()) -> 'ok'. migrate_outbound_faxes(Number) when is_binary(Number) -> migrate_outbound_faxes(kz_term:to_integer(Number)); migrate_outbound_faxes(Number) when is_integer(Number) -> @@ -373,14 +373,14 @@ migrate_outbound_faxes(Options) -> ]) end. --spec migrate_outbound_faxes(kz_json:objects(), api_binary()) -> api_binary(). +-spec migrate_outbound_faxes(kz_json:objects(), kz_term:api_binary()) -> kz_term:api_binary(). migrate_outbound_faxes([], Acc) -> Acc; migrate_outbound_faxes([JObj | JObjs], _Acc) -> DocId = kz_doc:id(JObj), maybe_migrate_outbound_fax(DocId), migrate_outbound_faxes(JObjs, DocId). --spec maybe_migrate_outbound_fax(ne_binary()) -> 'ok'. +-spec maybe_migrate_outbound_fax(kz_term:ne_binary()) -> 'ok'. maybe_migrate_outbound_fax(<<"_design/", _/binary>>) -> 'ok'; maybe_migrate_outbound_fax(DocId) -> case kz_datamgr:open_doc(?KZ_FAXES_DB, DocId) of @@ -388,7 +388,7 @@ maybe_migrate_outbound_fax(DocId) -> {'error', _E} -> io:format("error opening document ~s in faxes db~n", [DocId]) end. --spec maybe_migrate_outbound_fax(api_binary(), kz_json:object()) -> 'ok'. +-spec maybe_migrate_outbound_fax(kz_term:api_binary(), kz_json:object()) -> 'ok'. maybe_migrate_outbound_fax(<<"fax">>, JObj) -> case kz_json:get_value(<<"pvt_job_status">>, JObj) of <<"failed">> -> migrate_outbound_fax(JObj); @@ -413,14 +413,14 @@ migrate_outbound_fax(JObj) -> {'error', _E} -> io:format("error ~p moving document ~s/~s to ~s/~s~n", [_E, FromDB, FromId, ToDB, ToId]) end. --spec next_key(binary()) -> ne_binary(). +-spec next_key(binary()) -> kz_term:ne_binary(). next_key(<<>>) -> <<"\ufff0">>; next_key(Bin) -> <>. --spec load_smtp_attachment(ne_binary(), ne_binary()) -> 'ok'. --spec load_smtp_attachment(ne_binary(), ne_binary(), binary()) -> 'ok'. +-spec load_smtp_attachment(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. +-spec load_smtp_attachment(kz_term:ne_binary(), kz_term:ne_binary(), binary()) -> 'ok'. load_smtp_attachment(DocId, Filename) -> case file:read_file(Filename) of {'ok', FileContents} -> diff --git a/applications/fax/src/fax_monitor.erl b/applications/fax/src/fax_monitor.erl index 987c2ee01e8..0bdcef88050 100644 --- a/applications/fax/src/fax_monitor.erl +++ b/applications/fax/src/fax_monitor.erl @@ -36,7 +36,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> case gen_server:start_link(?SERVER, ?MODULE, [], []) of {'error', {'already_started', Pid}} @@ -61,7 +61,7 @@ start_link() -> %% {stop, Reason} %% @end %%-------------------------------------------------------------------- --spec init([]) -> {'ok', state(), kz_timeout()}. +-spec init([]) -> {'ok', state(), timeout()}. init([]) -> {'ok', #state{}, ?POLLING_INTERVAL}. @@ -79,7 +79,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State, ?POLLING_INTERVAL}. @@ -93,7 +93,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> lager:debug("unhandled cast: ~p", [_Msg]), {'noreply', State, ?POLLING_INTERVAL}. @@ -108,7 +108,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info('timeout', State) -> ViewOptions = ['reduce' ,'group' @@ -163,13 +163,13 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec distribute_accounts(ne_binaries()) -> ne_binaries(). +-spec distribute_accounts(kz_term:ne_binaries()) -> kz_term:ne_binaries(). distribute_accounts([]) -> []; distribute_accounts([AccountId|AccountIds]) -> maybe_start_account(fax_jobs:is_running(AccountId), AccountId), distribute_accounts(AccountIds). --spec maybe_start_account(boolean(), ne_binary()) -> 'ok'. +-spec maybe_start_account(boolean(), kz_term:ne_binary()) -> 'ok'. maybe_start_account('true', _AccountId) -> 'ok'; maybe_start_account('false', AccountId) -> lager:debug("sending start fax account jobs for ~s", [AccountId]), diff --git a/applications/fax/src/fax_request.erl b/applications/fax/src/fax_request.erl index 82ac239c1e2..8a4190fdde9 100644 --- a/applications/fax/src/fax_request.erl +++ b/applications/fax/src/fax_request.erl @@ -34,20 +34,20 @@ -record(state, {call :: kapps_call:call() | 'undefined' ,action = 'receive' :: 'receive' | 'transmit' - ,owner_id :: api_ne_binary() - ,faxbox_id :: api_ne_binary() - ,fax_doc :: api_object() + ,owner_id :: kz_term:api_ne_binary() + ,faxbox_id :: kz_term:api_ne_binary() + ,fax_doc :: kz_term:api_object() ,storage :: fax_storage() - ,fax_option :: api_ne_binary() - ,fax_result :: api_object() - ,fax_notify = 'undefined' :: api_object() + ,fax_option :: kz_term:api_ne_binary() + ,fax_result :: kz_term:api_object() + ,fax_notify = 'undefined' :: kz_term:api_object() ,fax_store_count = 0 :: integer() - ,fax_id = 'undefined' :: api_ne_binary() - ,account_id = 'undefined' :: api_ne_binary() - ,fax_status :: api_object() + ,fax_id = 'undefined' :: kz_term:api_ne_binary() + ,account_id = 'undefined' :: kz_term:api_ne_binary() + ,fax_status :: kz_term:api_object() ,page = 0 ::integer() - ,status :: api_ne_binary() - ,monitor :: pid_ref() | 'undefined' + ,status :: kz_term:api_ne_binary() + ,monitor :: kz_term:pid_ref() | 'undefined' }). -type state() :: #state{}. @@ -77,7 +77,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(kapps_call:call(), kz_json:object(), fax_storage()) -> startlink_ret(). +-spec start_link(kapps_call:call(), kz_json:object(), fax_storage()) -> kz_types:startlink_ret(). start_link(Call, JObj, Storage) -> gen_listener:start_link({'local', kz_term:to_atom(Storage#fax_storage.id, 'true')} ,?MODULE @@ -87,13 +87,13 @@ start_link(Call, JObj, Storage) -> ,[Call, JObj, Storage] ). --spec handle_fax_event(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_fax_event(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_fax_event(JObj, Props) -> Srv = props:get_value('server', Props), Event = kz_json:get_value(<<"Application-Event">>, JObj), gen_server:cast(Srv, {'fax_status', Event , JObj}). --spec handle_channel_event(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_channel_event(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_channel_event(JObj, Props) -> Srv = props:get_value('server', Props), Event = kz_api:event_name(JObj), @@ -142,7 +142,7 @@ init([Call, JObj, Storage]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -241,7 +241,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'DOWN', Ref, 'process', Pid, 'normal'}, #state{monitor={Pid, Ref}}=State) -> {'noreply', State, ?POLL_INTERVAL}; handle_info({'DOWN', Ref, 'process', Pid, Reason}, #state{monitor={Pid, Ref}}=State) -> @@ -361,7 +361,7 @@ maybe_update_fax_settings(#state{call=Call {'error', _} -> maybe_update_fax_settings_from_account(State) end. --spec get_faxbox_notify_list(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec get_faxbox_notify_list(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). get_faxbox_notify_list(FaxBoxDoc, AccountDb) -> DefaultNotify = default_notify(FaxBoxDoc), case kz_json:get_value(<<"owner_id">>, FaxBoxDoc) of @@ -380,7 +380,7 @@ get_faxbox_notify_list(FaxBoxDoc, AccountDb) -> default_notify(FaxBoxDoc) -> kz_json:get_value([<<"notifications">>,<<"inbound">>], FaxBoxDoc, kz_json:new()). --spec maybe_add_owner_to_notify_list(list(), api_binary()) -> kz_json:object(). +-spec maybe_add_owner_to_notify_list(list(), kz_term:api_binary()) -> kz_json:object(). maybe_add_owner_to_notify_list(List, 'undefined') -> kz_json:set_value([<<"email">>, <<"send_to">>], List, kz_json:new()); maybe_add_owner_to_notify_list(List, OwnerEmail) -> @@ -404,7 +404,7 @@ update_fax_settings(Call, JObj) -> ChannelVars = build_fax_settings(Call, JObj), kapps_call_command:set(kz_json:from_list(ChannelVars), 'undefined', Call). --spec build_fax_settings(kapps_call:call(), kz_json:object()) -> kz_proplist(). +-spec build_fax_settings(kapps_call:call(), kz_json:object()) -> kz_term:proplist(). build_fax_settings(Call, JObj) -> props:filter_undefined( [case kz_json:is_true(<<"override_fax_identity">>, JObj, 'true') of @@ -428,13 +428,13 @@ build_fax_settings(Call, JObj) -> ,{<<"Origination-Call-ID">>, kapps_call:call_id(Call)} ]). --spec callee_name(kz_json:object()) -> ne_binary(). +-spec callee_name(kz_json:object()) -> kz_term:ne_binary(). callee_name(JObj) -> kz_term:to_binary( kz_json:get_first_defined([<<"caller_name">>,<<"name">>], JObj) ). --spec overridden_callee_id(kapps_call:call(), kz_json:object()) -> ne_binary(). +-spec overridden_callee_id(kapps_call:call(), kz_json:object()) -> kz_term:ne_binary(). overridden_callee_id(Call, JObj) -> kz_term:to_binary( kz_json:get_first_defined([<<"caller_id">>,<<"fax_identity">>], JObj @@ -442,7 +442,7 @@ overridden_callee_id(Call, JObj) -> ) ). --spec overridden_fax_identity(kapps_call:call(), kz_json:object()) -> ne_binary(). +-spec overridden_fax_identity(kapps_call:call(), kz_json:object()) -> kz_term:ne_binary(). overridden_fax_identity(Call, JObj) -> kz_term:to_binary( kz_json:get_first_defined([<<"fax_identity">>,<<"caller_id">>], JObj @@ -464,7 +464,7 @@ end_receive_fax(JObj, #state{call=Call}=State) -> end_receive_fax(#state{}=State) -> {'noreply', State#state{monitor=store_document(State)}}. --spec store_document(state()) -> pid_ref(). +-spec store_document(state()) -> kz_term:pid_ref(). store_document(#state{}=State) -> kz_util:spawn_monitor(fun store_document/2, [self(), State]). @@ -481,7 +481,7 @@ store_document(Pid, #state{fax_result=JObj gen_server:cast(Pid, 'store_document') end. --spec store_attachment(state()) -> pid_ref(). +-spec store_attachment(state()) -> kz_term:pid_ref(). store_attachment(#state{}=State) -> kz_util:spawn_monitor(fun store_attachment/2, [self(), State]). @@ -500,7 +500,7 @@ store_attachment(Pid, #state{call=Call {'error', _} -> gen_server:cast(Pid, 'store_attachment') end. --spec get_fs_filename(state()) -> ne_binary(). +-spec get_fs_filename(state()) -> kz_term:ne_binary(). get_fs_filename(#state{storage=#fax_storage{attachment_id=AttachmentId}}) -> LocalPath = kapps_config:get_binary(?CONFIG_CAT, <<"fax_file_path">>, <<"/tmp/">>), <>. @@ -570,7 +570,7 @@ fax_fields(JObj) -> || {<<"Fax-", _/binary>> = K, V} <- kz_json:to_proplist(JObj) ]). --spec notify_fields(kapps_call:call(), kz_json:object()) -> kz_proplist(). +-spec notify_fields(kapps_call:call(), kz_json:object()) -> kz_term:proplist(). notify_fields(Call, JObj) -> props:filter_empty( [{<<"From-User">>, kapps_call:from_user(Call)} @@ -643,15 +643,15 @@ notify_success(#state{call=Call ]), kapps_notify_publisher:cast(Message, fun kapi_notifications:publish_fax_inbound/1). --spec send_error_status(state(), ne_binary(), api_object()) -> 'ok'. +-spec send_error_status(state(), kz_term:ne_binary(), kz_term:api_object()) -> 'ok'. send_error_status(State, Status, FaxInfo) -> send_status(State, Status, ?FAX_ERROR, FaxInfo). --spec send_status(state(), ne_binary(), api_object()) -> 'ok'. +-spec send_status(state(), kz_term:ne_binary(), kz_term:api_object()) -> 'ok'. send_status(State, Status, FaxInfo) -> send_status(State, Status, ?FAX_RECEIVE, FaxInfo). --spec send_status(state(), ne_binary(), ne_binary(), api_object()) -> 'ok'. +-spec send_status(state(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_object()) -> 'ok'. send_status(#state{call=Call ,account_id=AccountId ,page=Page @@ -677,7 +677,7 @@ send_status(#state{call=Call ]), kapi_fax:publish_status(Payload). --spec new_request(kz_json:object(), kz_proplist()) -> sup_startchild_ret(). +-spec new_request(kz_json:object(), kz_term:proplist()) -> kz_types:sup_startchild_ret(). new_request(JObj, _Props) -> 'true' = kapi_fax:req_v(JObj), Call = kapps_call:from_json(kz_json:get_value(<<"Call">>, JObj)), @@ -688,7 +688,7 @@ new_request(JObj, _Props) -> NewCall = kapps_call:kvs_store_proplist(Props, Call), fax_requests_sup:new(NewCall, JObj, Storage). --spec cancel(ne_binary()) -> 'ok'. +-spec cancel(kz_term:ne_binary()) -> 'ok'. cancel(Id) -> case whereis(kz_term:to_atom(Id, 'true')) of 'undefined' -> io:format("job ~s not found", [Id]); diff --git a/applications/fax/src/fax_requests_sup.erl b/applications/fax/src/fax_requests_sup.erl index e3cf51caa2d..fd38f44ef0b 100644 --- a/applications/fax/src/fax_requests_sup.erl +++ b/applications/fax/src/fax_requests_sup.erl @@ -32,15 +32,15 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec new(kapps_call:call(), kz_json:object(), fax_storage()) -> sup_startchild_ret(). +-spec new(kapps_call:call(), kz_json:object(), fax_storage()) -> kz_types:sup_startchild_ret(). new(Call, JObj, Storage) -> supervisor:start_child(?SERVER, [Call, JObj, Storage]). --spec workers() -> pids(). +-spec workers() -> kz_term:pids(). workers() -> [ Pid || {_, Pid, 'worker', [_]} <- supervisor:which_children(?SERVER)]. @@ -57,7 +57,7 @@ workers() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 0, diff --git a/applications/fax/src/fax_shared_listener.erl b/applications/fax/src/fax_shared_listener.erl index 3fa95a043e6..ff46c22db3e 100644 --- a/applications/fax/src/fax_shared_listener.erl +++ b/applications/fax/src/fax_shared_listener.erl @@ -92,7 +92,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'bindings', ?BINDINGS} ,{'responders', ?RESPONDERS} @@ -134,7 +134,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -148,7 +148,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener',{'created_queue',_Queue}}, State) -> {'noreply', State}; handle_cast({'gen_listener',{'is_consuming',_IsConsuming}}, State) -> @@ -167,7 +167,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> lager:debug("unhandled message: ~p", [_Info]), {'noreply', State}. diff --git a/applications/fax/src/fax_smtp.erl b/applications/fax/src/fax_smtp.erl index 6616e048f67..89695a91fad 100644 --- a/applications/fax/src/fax_smtp.erl +++ b/applications/fax/src/fax_smtp.erl @@ -35,24 +35,24 @@ -define(ERROR_NO_VALID_ATTACHMENT, <<"no valid attachment">>). --record(state, {options = [] :: kz_proplist() - ,from :: api_ne_binary() - ,to :: api_ne_binary() - ,doc :: api_object() +-record(state, {options = [] :: kz_term:proplist() + ,from :: kz_term:api_ne_binary() + ,to :: kz_term:api_ne_binary() + ,doc :: kz_term:api_object() ,filename :: file:filename_all() | 'undefined' - ,content_type :: api_ne_binary() + ,content_type :: kz_term:api_ne_binary() ,peer_ip :: peer() - ,owner_id :: api_binary() - ,owner_email :: api_binary() - ,faxbox_email :: api_binary() - ,faxbox :: api_object() + ,owner_id :: kz_term:api_binary() + ,owner_email :: kz_term:api_binary() + ,faxbox_email :: kz_term:api_binary() + ,faxbox :: kz_term:api_object() ,has_smtp_errors = 'false' :: boolean() - ,errors = [] :: ne_binaries() - ,original_number :: api_binary() - ,number :: api_binary() - ,account_id :: api_binary() - ,session_id :: api_binary() - ,proxy :: api_binary() + ,errors = [] :: kz_term:ne_binaries() + ,original_number :: kz_term:api_binary() + ,number :: kz_term:api_binary() + ,account_id :: kz_term:api_binary() + ,session_id :: kz_term:api_binary() + ,proxy :: kz_term:api_binary() }). -type state() :: #state{}. @@ -60,7 +60,7 @@ -type peer() :: {inet:ip_address(), non_neg_integer()}. --spec init(ne_binary(), non_neg_integer(), peer(), kz_proplist()) -> +-spec init(kz_term:ne_binary(), non_neg_integer(), peer(), kz_term:proplist()) -> {'ok', string(), #state{}} | {'stop', _, string()}. init(Hostname, SessionCount, Address, Options) -> @@ -103,7 +103,7 @@ handle_EHLO(Hostname, Extensions, #state{options=Options, proxy = Proxy}=State) end, {'ok', filter_extensions(MyExtensions, Options), State}. --spec filter_extensions(kz_proplist(), kz_proplist()) -> kz_proplist(). +-spec filter_extensions(kz_term:proplist(), kz_term:proplist()) -> kz_term:proplist(). filter_extensions(BuilIn, Options) -> Extensions = props:get_value('extensions', Options, ?SMTP_EXTENSIONS), lists:filter(fun({N,_}) -> not props:is_defined(N, Extensions) end, BuilIn) ++ Extensions. @@ -144,7 +144,7 @@ handle_RCPT_extension(Extension, _State) -> lager:debug(Error), 'error'. --spec handle_DATA(binary(), ne_binaries(), binary(), state()) -> +-spec handle_DATA(binary(), kz_term:ne_binaries(), binary(), state()) -> {'ok', string(), state()} | {'error', string(), state()}. handle_DATA(From, To, <<>>, State) -> @@ -186,7 +186,7 @@ handle_DATA(From, To, Data, #state{options=Options}=State) -> }} end. --spec handle_DATA_exception(kz_proplist(), list(), binary()) -> 'ok'. +-spec handle_DATA_exception(kz_term:proplist(), list(), binary()) -> 'ok'. handle_DATA_exception(Options, Reference, Data) -> case props:get_is_true('dump', Options, 'false') of 'false' -> 'ok'; @@ -300,7 +300,7 @@ maybe_faxbox_log(#state{faxbox='undefined', account_id=AccountId}=State) -> maybe_faxbox_log(#state{faxbox=JObj, account_id=AccountId}=State) -> maybe_faxbox_log(AccountId, JObj, State). --spec maybe_faxbox_log(ne_binary(), kz_json:object(), state()) -> 'ok'. +-spec maybe_faxbox_log(kz_term:ne_binary(), kz_json:object(), state()) -> 'ok'. maybe_faxbox_log(AccountId, JObj, State) -> case kz_json:is_true(<<"log_errors">>, JObj, 'false') orelse ( kapps_account_config:get_global(AccountId, ?CONFIG_CAT, <<"log_faxbox_errors">>, 'true') @@ -340,14 +340,14 @@ faxbox_log(#state{account_id=AccountId}=State) -> kazoo_modb:save_doc(AccountId, Doc), maybe_system_report(State). --spec error_doc() -> ne_binary(). +-spec error_doc() -> kz_term:ne_binary(). error_doc() -> {Year, Month, _} = erlang:date(), <<(kz_term:to_binary(Year))/binary,(kz_date:pad_month(Month))/binary ,"-",(kz_binary:rand_hex(16))/binary >>. --spec to_proplist(state()) -> kz_proplist(). +-spec to_proplist(state()) -> kz_term:proplist(). to_proplist(#state{}=State) -> props:filter_undefined( [{<<"To">>, State#state.to} @@ -366,14 +366,14 @@ to_proplist(#state{}=State) -> ]). --spec faxbox_to_proplist(api_object()) -> kz_proplist(). +-spec faxbox_to_proplist(kz_term:api_object()) -> kz_term:proplist(). faxbox_to_proplist('undefined') -> []; faxbox_to_proplist(JObj) -> props:filter_undefined( [{<<"FaxBox-ID">>, kz_doc:id(JObj)}] ). --spec faxdoc_to_proplist(api_object()) -> kz_proplist(). +-spec faxdoc_to_proplist(kz_term:api_object()) -> kz_term:proplist(). faxdoc_to_proplist('undefined') -> []; faxdoc_to_proplist(JObj) -> props:filter_undefined( @@ -451,7 +451,7 @@ check_number(#state{faxbox=FaxBoxDoc, number=Number, errors=Errors}=State) -> -spec check_permissions(state()) -> {'ok', state()} | {'error', string(), state()}. --spec check_permissions(state(), ne_binaries()) -> +-spec check_permissions(state(), kz_term:ne_binaries()) -> {'ok', state()} | {'error', string(), state()}. check_permissions(#state{from=_From @@ -553,7 +553,7 @@ maybe_faxbox_domain(#state{faxbox_email=Domain}=State) -> State#state{errors=[Error]} end. --spec maybe_faxbox_by_owner_email(ne_binary(), state()) -> state(). +-spec maybe_faxbox_by_owner_email(kz_term:ne_binary(), state()) -> state(). maybe_faxbox_by_owner_email(AccountId, #state{errors=Errors ,from=From }=State) -> @@ -577,7 +577,7 @@ maybe_faxbox_by_owner_email(AccountId, #state{errors=Errors maybe_faxbox_by_rules(AccountId, State#state{errors=[Error | Errors]}) end. --spec maybe_faxbox_by_owner_id(ne_binary(), ne_binary(),state()) -> state(). +-spec maybe_faxbox_by_owner_id(kz_term:ne_binary(), kz_term:ne_binary(),state()) -> state(). maybe_faxbox_by_owner_id(AccountId, OwnerId, #state{errors=Errors, from=From}=State) -> ViewOptions = [{'key', OwnerId}, 'include_docs'], AccountDb = kz_util:format_account_db(AccountId), @@ -609,7 +609,7 @@ maybe_faxbox_by_owner_id(AccountId, OwnerId, #state{errors=Errors, from=From}=St ) end. --spec maybe_faxbox_by_rules(ne_binary() | kz_json:objects(), state()) -> state(). +-spec maybe_faxbox_by_rules(kz_term:ne_binary() | kz_json:objects(), state()) -> state(). maybe_faxbox_by_rules(AccountId, #state{errors=Errors}=State) when is_binary(AccountId) -> ViewOptions = ['include_docs'], @@ -702,7 +702,7 @@ add_fax_document(#state{from=From %% ==================================================================== %% Internal functions %% ==================================================================== --spec process_message(ne_binary(), ne_binary(), kz_proplist(), kz_proplist(), binary() | mimemail:mimetuple(), state()) -> +-spec process_message(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist(), kz_term:proplist(), binary() | mimemail:mimetuple(), state()) -> {'ok', state()}. process_message(<<"multipart">>, Multipart, _Headers, _Parameters, Body, #state{errors=Errors}=State) -> lager:debug("processing multipart/~s", [Multipart]), @@ -747,7 +747,7 @@ process_parts([{Type, SubType, _Headers, Parameters, BodyPart} ), process_parts(Parts, maybe_ignore_no_valid_attachment(NewState)). --spec maybe_process_part(ne_binary(), kz_proplist(), binary() | mimemail:mimetuple(), state()) -> +-spec maybe_process_part(kz_term:ne_binary(), kz_term:proplist(), binary() | mimemail:mimetuple(), state()) -> {'ok', state()}. maybe_process_part(<<"multipart/", Multipart/binary>>, _Parameters, Body, #state{errors=Errors}=State) -> lager:debug("processing multipart/~s", [Multipart]), @@ -796,7 +796,7 @@ maybe_process_part(CT, _Parameters, Body, State) -> {'ok', State} end. --spec process_part(ne_binary(), binary() | mimemail:mimetuple(), state()) -> {'ok', state()}. +-spec process_part(kz_term:ne_binary(), binary() | mimemail:mimetuple(), state()) -> {'ok', state()}. process_part(CT, Body, State) -> lager:debug("part is ~s", [CT]), Extension = kz_mime:to_extension(CT), @@ -817,7 +817,7 @@ maybe_ignore_no_valid_attachment(#state{errors=Errors}=State) -> ,has_smtp_errors='true' }. --spec is_allowed_content_type(ne_binary()) -> boolean(). +-spec is_allowed_content_type(kz_term:ne_binary()) -> boolean(). is_allowed_content_type(CT) -> AllowedCT = kapps_config:get(?CONFIG_CAT, <<"allowed_content_types">>, ?DEFAULT_ALLOWED_CONTENT_TYPES), DeniedCT = kapps_config:get(?CONFIG_CAT, <<"denied_content_types">>, ?DEFAULT_DENIED_CONTENT_TYPES), @@ -825,7 +825,7 @@ is_allowed_content_type(CT) -> DeniedBy = content_type_matched_by(CT, DeniedCT, <<>>), byte_size(AllowedBy) > byte_size(DeniedBy). --spec content_type_matched_by(ne_binary(), [ne_binary() | kz_json:object()], binary()) -> binary(). +-spec content_type_matched_by(kz_term:ne_binary(), [kz_term:ne_binary() | kz_json:object()], binary()) -> binary(). content_type_matched_by(CT, [CT | _T], _) -> CT; content_type_matched_by(CT, [Type | T], GreaterMatch) when is_binary(Type) -> @@ -839,7 +839,7 @@ content_type_matched_by(CT, [Type | T], GreaterMatch) -> content_type_matched_by(_CT, [], GreaterMatch) -> GreaterMatch. --spec content_type_matched_json(ne_binary(), kz_json:object()) -> binary(). +-spec content_type_matched_json(kz_term:ne_binary(), kz_json:object()) -> binary(). content_type_matched_json(CT, Type) -> case kz_json:is_json_object(Type) of 'false' -> <<>>; @@ -847,7 +847,7 @@ content_type_matched_json(CT, Type) -> content_type_matched_json(CT, Type, <<"type">>) end. --spec content_type_matched_json(ne_binary(), kz_json:object(), ne_binary()) -> binary(). +-spec content_type_matched_json(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> binary(). content_type_matched_json(CT, Type, <<"type">> = Field) -> case kz_json:get_binary_value(Field, Type) of CT -> CT; @@ -862,13 +862,13 @@ content_type_matched_json(CT, Type, <<"prefix">> = Field) -> {_, _} -> <<>> end. --spec maybe_process_image(ne_binary(), binary() | mimemail:mimetuple(), state()) -> +-spec maybe_process_image(kz_term:ne_binary(), binary() | mimemail:mimetuple(), state()) -> {'ok', state()}. maybe_process_image(CT, Body, State) -> Size = kapps_config:get_binary(?CONFIG_CAT, <<"image_min_size">>, <<"700x10">>), maybe_process_image(CT, Body, Size, State). --spec maybe_process_image(ne_binary(), binary() | mimemail:mimetuple(), ne_binary(), state()) -> +-spec maybe_process_image(kz_term:ne_binary(), binary() | mimemail:mimetuple(), kz_term:ne_binary(), state()) -> {'ok', state()}. maybe_process_image(CT, Body, Size, State) -> {MinX, MinY} = case re:split(Size, "x") of @@ -891,11 +891,11 @@ maybe_process_image(CT, Body, Size, State) -> {'ok', State} end. --spec write_tmp_file(ne_binary(), binary() | mimemail:mimetuple()) -> - {'ok', api_binary()} | +-spec write_tmp_file(kz_term:ne_binary(), binary() | mimemail:mimetuple()) -> + {'ok', kz_term:api_binary()} | {'error', any()}. --spec write_tmp_file(api_binary() , ne_binary(), binary() | mimemail:mimetuple()) -> - {'ok', api_binary()} | +-spec write_tmp_file(kz_term:api_binary() , kz_term:ne_binary(), binary() | mimemail:mimetuple()) -> + {'ok', kz_term:api_binary()} | {'error', any()}. write_tmp_file(Extension, Body) -> write_tmp_file('undefined', Extension, Body). diff --git a/applications/fax/src/fax_sup.erl b/applications/fax/src/fax_sup.erl index d2feb4a36c1..5c50ea1d3ba 100644 --- a/applications/fax/src/fax_sup.erl +++ b/applications/fax/src/fax_sup.erl @@ -50,7 +50,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -84,7 +84,7 @@ smtp_sessions() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/fax/src/fax_util.erl b/applications/fax/src/fax_util.erl index ed3b8c0153c..5489be16edd 100644 --- a/applications/fax/src/fax_util.erl +++ b/applications/fax/src/fax_util.erl @@ -20,16 +20,16 @@ -define(RETRY_SAVE_ATTACHMENT_DELAY, 5000). --spec fax_properties(kz_json:object()) -> kz_proplist(). +-spec fax_properties(kz_json:object()) -> kz_term:proplist(). fax_properties(JObj) -> [{kz_json:normalize_key(K), V} || {<<"Fax-", K/binary>>, V} <- kz_json:to_proplist(JObj)]. -spec collect_channel_props(kz_json:object()) -> - kz_proplist(). --spec collect_channel_props(kz_json:object(), kz_proplist() | ne_binaries()) -> - kz_proplist(). --spec collect_channel_props(kz_json:object(), kz_proplist() | ne_binaries(), kz_proplist()) -> - kz_proplist(). + kz_term:proplist(). +-spec collect_channel_props(kz_json:object(), kz_term:proplist() | kz_term:ne_binaries()) -> + kz_term:proplist(). +-spec collect_channel_props(kz_json:object(), kz_term:proplist() | kz_term:ne_binaries(), kz_term:proplist()) -> + kz_term:proplist(). collect_channel_props(JObj) -> collect_channel_props(JObj, ?FAX_CHANNEL_DESTROY_PROPS). @@ -43,7 +43,7 @@ collect_channel_props(JObj, List, Acc) -> [collect_channel_prop(Key, JObj) | Acc0] end, Acc, List). --spec collect_channel_prop(ne_binary(), kz_json:object()) -> +-spec collect_channel_prop(kz_term:ne_binary(), kz_json:object()) -> {kz_json:path(), kz_json:json_term()}. collect_channel_prop(<<"Hangup-Code">> = Key, JObj) -> <<"sip:", Code/binary>> = kz_json:get_value(Key, JObj, <<"sip:500">>), @@ -58,28 +58,28 @@ collect_channel_prop(Key, JObj) -> %% it has an extension (for the associated content type) %% @end %%-------------------------------------------------------------------- --spec attachment_name(binary(), ne_binary()) -> ne_binary(). +-spec attachment_name(binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). attachment_name(Filename, CT) -> Generators = [fun maybe_generate_random_filename/1 ,fun(A) -> maybe_attach_extension(A, CT) end ], lists:foldl(fun(F, A) -> F(A) end, Filename, Generators). --spec maybe_generate_random_filename(binary()) -> ne_binary(). +-spec maybe_generate_random_filename(binary()) -> kz_term:ne_binary(). maybe_generate_random_filename(A) -> case kz_term:is_empty(A) of 'true' -> kz_term:to_hex_binary(crypto:strong_rand_bytes(16)); 'false' -> A end. --spec maybe_attach_extension(ne_binary(), ne_binary()) -> ne_binary(). +-spec maybe_attach_extension(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). maybe_attach_extension(A, CT) -> case kz_term:is_empty(filename:extension(A)) of 'false' -> A; 'true' -> <> end. --spec save_fax_docs(kz_json:objects(), binary(), ne_binary()) -> +-spec save_fax_docs(kz_json:objects(), binary(), kz_term:ne_binary()) -> 'ok' | {'error', any()}. save_fax_docs([], _FileContents, _CT) -> 'ok'; @@ -93,12 +93,12 @@ save_fax_docs([Doc|Docs], FileContents, CT) -> Else -> Else end. --spec save_fax_attachment(api_object(), binary(), ne_binary())-> +-spec save_fax_attachment(kz_term:api_object(), binary(), kz_term:ne_binary())-> {'ok', kz_json:object()} | - {'error', ne_binary()}. --spec save_fax_attachment(api_object(), binary(), ne_binary(), ne_binary(), non_neg_integer())-> + {'error', kz_term:ne_binary()}. +-spec save_fax_attachment(kz_term:api_object(), binary(), kz_term:ne_binary(), kz_term:ne_binary(), non_neg_integer())-> {'ok', kz_json:object()} | - {'error', ne_binary()}. + {'error', kz_term:ne_binary()}. save_fax_attachment(JObj, FileContents, CT) -> MaxStorageRetry = kapps_config:get_integer(?CONFIG_CAT, <<"max_storage_retry">>, 5), ContentsMD5 = kz_term:to_hex_binary(erlang:md5(FileContents)), @@ -127,7 +127,7 @@ save_fax_attachment(JObj, FileContents, CT, Name, Count) -> save_fax_attachment(J, FileContents, CT, Name, Count-1) end. --spec attempt_save(kz_json:object(), binary(), ne_binary(), ne_binary()) -> +-spec attempt_save(kz_json:object(), binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:objcet()} | kz_datamgr:data_error(). attempt_save(JObj, FileContents, CT, Name) -> @@ -136,7 +136,7 @@ attempt_save(JObj, FileContents, CT, Name) -> kz_datamgr:put_attachment(?KZ_FAXES_DB, kz_doc:id(JObj), Name, FileContents, Opts). --spec check_fax_attachment(ne_binary(), ne_binary())-> +-spec check_fax_attachment(kz_term:ne_binary(), kz_term:ne_binary())-> {'ok', kz_json:object()} | {'missing', kz_json:object()} | {'error', any()}. @@ -167,7 +167,7 @@ save_fax_doc_completed(JObj)-> {'error', E} end. --spec notify_email_list(api_binary(), api_binary(), ne_binary() | list()) -> list(). +-spec notify_email_list(kz_term:api_binary(), kz_term:api_binary(), kz_term:ne_binary() | list()) -> list(). notify_email_list(From, OwnerEmail, Email) when is_binary(Email) -> notify_email_list(From, OwnerEmail, [Email]); notify_email_list('undefined', 'undefined', List) -> @@ -183,7 +183,7 @@ notify_email_list(From, OwnerEmail, List) -> filter_numbers(Number) -> << <> || <> <= Number, is_digit(X)>>. --spec is_valid_caller_id(api_binary(), ne_binary()) -> boolean(). +-spec is_valid_caller_id(kz_term:api_binary(), kz_term:ne_binary()) -> boolean(). is_valid_caller_id('undefined', _) -> 'false'; is_valid_caller_id(<<>>, _) -> 'false'; is_valid_caller_id(Number, AccountId) -> @@ -198,7 +198,7 @@ is_digit(N) when is_integer(N), N =< $9 -> true; is_digit(_) -> false. --spec normalize_content_type(text()) -> ne_binary(). +-spec normalize_content_type(kz_term:text()) -> kz_term:ne_binary(). normalize_content_type(<<"image/tif">>) -> <<"image/tiff">>; normalize_content_type(<<"image/x-tif">>) -> <<"image/tiff">>; normalize_content_type(<<"image/tiff">>) -> <<"image/tiff">>; diff --git a/applications/fax/src/fax_worker.erl b/applications/fax/src/fax_worker.erl index 10557e5b2d0..f171ae64f64 100644 --- a/applications/fax/src/fax_worker.erl +++ b/applications/fax/src/fax_worker.erl @@ -35,19 +35,19 @@ -define(MAX_MOVE_RETRY, 5). -define(MAX_MOVE_NOTIFY_MSG, "failed to move fax outbound document ~s from faxes database to account ~s modb"). --record(state, {queue_name :: api_binary() - ,job_id :: api_binary() - ,job :: api_object() - ,account_id :: api_binary() - ,status :: api_ne_binary() - ,fax_status :: api_object() - ,pages :: api_integer() +-record(state, {queue_name :: kz_term:api_binary() + ,job_id :: kz_term:api_binary() + ,job :: kz_term:api_object() + ,account_id :: kz_term:api_binary() + ,status :: kz_term:api_ne_binary() + ,fax_status :: kz_term:api_object() + ,pages :: kz_term:api_integer() ,page = 0 :: integer() - ,file :: api_ne_binary() - ,callid :: ne_binary() - ,controller :: ne_binary() - ,stage :: api_binary() - ,resp :: api_object() + ,file :: kz_term:api_ne_binary() + ,callid :: kz_term:ne_binary() + ,controller :: kz_term:ne_binary() + ,stage :: kz_term:api_binary() + ,resp :: kz_term:api_object() ,move_retry = 0 :: integer() }). -type state() :: #state{}. @@ -98,7 +98,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(fax_job()) -> startlink_ret(). +-spec start_link(fax_job()) -> kz_types:startlink_ret(). start_link(FaxJob) -> CallId = kz_binary:rand_hex(16), _JobId = kapi_fax:job_id(FaxJob), @@ -114,19 +114,19 @@ start_link(FaxJob) -> ] ,[FaxJob, CallId]). --spec handle_tx_resp(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_tx_resp(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_tx_resp(JObj, Props) -> Srv = props:get_value('server', Props), gen_server:cast(Srv, {'tx_resp', kz_api:msg_id(JObj), JObj}). --spec handle_fax_event(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_fax_event(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_fax_event(JObj, Props) -> Srv = props:get_value('server', Props), JobId = kz_call_event:authorizing_id(JObj), Event = kz_call_event:application_event(JObj), gen_server:cast(Srv, {'fax_status', Event , JobId, JObj}). --spec handle_job_status_query(kz_json:object(), kz_proplist()) -> any(). +-spec handle_job_status_query(kz_json:object(), kz_term:proplist()) -> any(). handle_job_status_query(JObj, Props) -> 'true' = kapi_fax:query_status_v(JObj), Srv = props:get_value('server', Props), @@ -150,7 +150,7 @@ handle_job_status_query(JObj, Props) -> %% {stop, Reason} %% @end %%-------------------------------------------------------------------- --spec init([kz_json:object() | ne_binary()]) -> {'ok', state()}. +-spec init([kz_json:object() | kz_term:ne_binary()]) -> {'ok', state()}. init([FaxJob, CallId]) -> CtrlQ = kz_api:server_id(FaxJob), JobId = kapi_fax:job_id(FaxJob), @@ -176,7 +176,7 @@ init([FaxJob, CallId]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -190,7 +190,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'tx_resp', JobId, JObj}, #state{job_id=JobId ,job=Job ,resp='undefined' @@ -415,7 +415,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info('timeout', #state{stage='undefined'}=State) -> {'noreply', State}; handle_info('timeout', #state{stage=Stage, job=JObj}=State) -> @@ -434,7 +434,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. @@ -478,10 +478,10 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec attempt_to_acquire_job(ne_binary(), ne_binary()) -> +-spec attempt_to_acquire_job(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. --spec attempt_to_acquire_job(kz_json:object(), ne_binary(), api_binary()) -> +-spec attempt_to_acquire_job(kz_json:object(), kz_term:ne_binary(), kz_term:api_binary()) -> {'ok', kz_json:object()} | {'error', any()}. attempt_to_acquire_job(Id, Q) -> @@ -650,11 +650,11 @@ release_successful_job(Resp, JObj) -> ]), release_job(Result, JObj, Resp). --spec release_job(kz_proplist(), kz_json:object()) -> release_ret(). +-spec release_job(kz_term:proplist(), kz_json:object()) -> release_ret(). release_job(Result, JObj) -> release_job(Result, JObj, kz_json:new()). --spec release_job(kz_proplist(), kz_json:object(), kz_json:object()) -> release_ret(). +-spec release_job(kz_term:proplist(), kz_json:object(), kz_json:object()) -> release_ret(). release_job(Result, JObj, Resp) -> Success = props:is_true(<<"success">>, Result, 'false'), Updaters = [fun(J) -> kz_json:set_value(<<"tx_result">>, kz_json:from_list(Result), J) end @@ -728,7 +728,7 @@ apply_reschedule_rules({[Rule | Rules], [Key | Keys]}, JObj) -> apply_reschedule_rules({Rules, Keys}, JObj) end. --spec get_attempt_value(api_binary() | integer()) -> integer(). +-spec get_attempt_value(kz_term:api_binary() | integer()) -> integer(). get_attempt_value(X) when is_integer(X) -> X; get_attempt_value('undefined') -> -1; get_attempt_value(<<"any">>) -> -1; @@ -742,7 +742,7 @@ set_default_update_fields(JObj) -> ,JObj ). --spec maybe_notify(kz_json:object(), kz_json:object(), ne_binary()) -> any(). +-spec maybe_notify(kz_json:object(), kz_json:object(), kz_term:ne_binary()) -> any(). maybe_notify(JObj, Resp, <<"completed">>) -> Message = notify_fields(JObj, Resp), kapps_notify_publisher:cast(Message, fun kapi_notifications:publish_fax_outbound/1); @@ -755,7 +755,7 @@ maybe_notify(JObj, Resp, <<"failed">>) -> maybe_notify(_JObj, _Resp, Status) -> lager:debug("notify Status ~p not handled",[Status]). --spec maybe_move_doc(kz_json:object(), ne_binary()) -> +-spec maybe_move_doc(kz_json:object(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. maybe_move_doc(JObj, <<"completed">>) -> @@ -782,13 +782,13 @@ move_doc(JObj) -> lager:debug("moving fax outbound document ~s from faxes to ~s with id ~s", [FromId, AccountMODb, ToId]), kazoo_modb:move_doc(FromDB, {<<"fax">>, FromId}, ToDB, ToId, Options). --spec fax_error(kz_json:object()) -> api_binary(). +-spec fax_error(kz_json:object()) -> kz_term:api_binary(). fax_error(JObj) -> kz_json:get_first_defined([ [<<"Application-Data">>, <<"Fax-Result-Text">>] , [<<"tx_result">>, <<"result_text">>] ], JObj). --spec notify_fields(kz_json:object(), kz_json:object()) -> kz_proplist(). +-spec notify_fields(kz_json:object(), kz_json:object()) -> kz_term:proplist(). notify_fields(JObj, Resp) -> <<"sip:", HangupCode/binary>> = kz_json:get_value(<<"Hangup-Code">>, Resp, <<"sip:0">>), HangupCause = kz_json:get_value(<<"Hangup-Cause">>, Resp), @@ -824,7 +824,7 @@ notify_fields(JObj, Resp) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]). --spec fax_fields(api_object()) -> kz_proplist(). +-spec fax_fields(kz_term:api_object()) -> kz_term:proplist(). fax_fields('undefined') -> []; fax_fields(JObj) -> [{K,V} || {<<"Fax-", _/binary>> = K, V} <- kz_json:to_proplist(JObj)]. @@ -842,7 +842,7 @@ fetch_document(JObj) -> AttachmentNames -> fetch_document_from_attachment(JObj, AttachmentNames) end. --spec fetch_document_from_attachment(kz_json:object(), ne_binaries()) -> kz_http:ret(). +-spec fetch_document_from_attachment(kz_json:object(), kz_term:ne_binaries()) -> kz_http:ret(). fetch_document_from_attachment(JObj, [AttachmentName|_]) -> DefaultContentType = kz_mime:from_extension(filename:extension(AttachmentName)), ContentType = kz_doc:attachment_content_type(JObj, AttachmentName, DefaultContentType), @@ -865,9 +865,9 @@ fetch_document_from_url(JObj) -> lager:debug("making ~s request to '~s'", [Method, Url]), kz_http:req(Method, Url, Headers, Body). --spec prepare_contents(ne_binary(), kz_proplist(), ne_binary()) -> - {'ok', ne_binary()} | - {'error', ne_binary()}. +-spec prepare_contents(kz_term:ne_binary(), kz_term:proplist(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | + {'error', kz_term:ne_binary()}. prepare_contents(JobId, RespHeaders, RespContent) -> lager:debug("preparing fax contents"), CT = props:get_value("content-type", RespHeaders, <<"application/octet-stream">>), @@ -878,9 +878,9 @@ prepare_contents(JobId, RespHeaders, RespContent) -> {'error', _}=Error -> Error end. --spec prepare_contents(ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> - {'ok', ne_binary()} | - {'error', ne_binary()}. +-spec prepare_contents(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | + {'error', kz_term:ne_binary()}. prepare_contents(<<"image/tiff">>, JobId, RespContent, TmpDir) -> OutputFile = list_to_binary([TmpDir, JobId, ".tiff"]), kz_util:write_file(OutputFile, RespContent), @@ -925,9 +925,9 @@ prepare_contents(CT, _JobId, _RespContent, _TmpDir) -> lager:debug("unsupported file type: ~p", [CT]), {'error', list_to_binary(["file type '", CT, "' is unsupported"])}. --spec convert_openoffice_document(ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> - {'ok', ne_binary()} | - {'error', ne_binary()}. +-spec convert_openoffice_document(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | + {'error', kz_term:ne_binary()}. convert_openoffice_document(CT, TmpDir, JobId, RespContent) -> Extension = kz_mime:to_extension(CT), InputFile = list_to_binary([TmpDir, JobId, ".", Extension]), @@ -944,7 +944,7 @@ convert_openoffice_document(CT, TmpDir, JobId, RespContent) -> {'error', <<"can not convert file, try uploading a tiff">>} end. --spec get_sizes(ne_binary()) -> {integer(), non_neg_integer()}. +-spec get_sizes(kz_term:ne_binary()) -> {integer(), non_neg_integer()}. get_sizes(OutputFile) when is_binary(OutputFile) -> CmdCount = kapps_config:get_binary(?CONFIG_CAT, <<"count_pages_command">>, ?COUNT_PAGES_CMD), Cmd = io_lib:format(CmdCount, [OutputFile]), @@ -956,7 +956,7 @@ get_sizes(OutputFile) when is_binary(OutputFile) -> FileSize = filelib:file_size(kz_term:to_list(OutputFile)), {NumberOfPages, FileSize}. --spec send_fax(ne_binary(), kz_json:object(), ne_binary()) -> 'ok'. +-spec send_fax(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> 'ok'. send_fax(JobId, JObj, Q) -> SendFax = fun() -> send_fax(JobId, JObj, Q, get_did(JObj)) end, maybe_ensure_valid_caller_id(JObj, SendFax). @@ -978,7 +978,7 @@ ensure_valid_caller_id(JObj, SendFax) -> gen_server:cast(self(), {'error', 'invalid_cid', CIDNum}) end. --spec send_fax(ne_binary(), kz_json:object(), ne_binary(), binary() | 'undefined') -> 'ok'. +-spec send_fax(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary(), binary() | 'undefined') -> 'ok'. send_fax(_JobId, _JObj, _Q, 'undefined') -> gen_server:cast(self(), {'error', 'invalid_number', <<"(undefined)">>}); send_fax(_JobId, _JObj, _Q, <<>>) -> @@ -1021,7 +1021,7 @@ send_fax(JobId, JObj, Q, ToDID) -> lager:debug("sending fax originate request ~s with call-id ~s", [JobId, CallId]), kapi_offnet_resource:publish_req(Request). --spec get_hunt_account_id(ne_binary()) -> api_binary(). +-spec get_hunt_account_id(kz_term:ne_binary()) -> kz_term:api_binary(). get_hunt_account_id(AccountId) -> AccountDb = kz_util:format_account_db(AccountId), Options = [{'key', <<"no_match">>}, 'include_docs'], @@ -1030,7 +1030,7 @@ get_hunt_account_id(AccountId) -> _ -> 'undefined' end. --spec maybe_hunt_account_id(api_object(), ne_binary()) -> api_binary(). +-spec maybe_hunt_account_id(kz_term:api_object(), kz_term:ne_binary()) -> kz_term:api_binary(). maybe_hunt_account_id('undefined', _) -> 'undefined'; maybe_hunt_account_id(JObj, AccountId) -> case kz_json:get_value(<<"module">>, JObj) of @@ -1040,39 +1040,39 @@ maybe_hunt_account_id(JObj, AccountId) -> maybe_hunt_account_id(kz_json:get_value([<<"children">>, <<"_">>], JObj), AccountId) end. --spec resource_ccvs(ne_binary()) -> kz_json:object(). +-spec resource_ccvs(kz_term:ne_binary()) -> kz_json:object(). resource_ccvs(JobId) -> kz_json:from_list([{<<"Authorizing-ID">>, JobId} ,{<<"Authorizing-Type">>, <<"outbound_fax">>} ,{<<"RTCP-MUX">>, false} ]). --spec get_did(kz_json:object()) -> api_binary(). +-spec get_did(kz_json:object()) -> kz_term:api_binary(). get_did(JObj) -> case kz_json:is_true(<<"bypass_e164">>, JObj, 'false') of 'true' -> kz_json:get_value(<<"to_number">>, JObj); 'false' -> knm_converters:normalize(kz_json:get_value(<<"to_number">>, JObj)) end. --spec get_proxy_url(ne_binary()) -> ne_binary(). +-spec get_proxy_url(kz_term:ne_binary()) -> kz_term:ne_binary(). get_proxy_url(JobId) -> Hostname = kz_network_utils:get_hostname(), Port = integer_to_binary(?PORT), list_to_binary(["http://", Hostname, ":", Port, "/fax/", JobId, ".tiff"]). --spec send_status(state(), ne_binary()) -> any(). +-spec send_status(state(), kz_term:ne_binary()) -> any(). send_status(State, Status) -> send_status(State, Status, ?FAX_SEND, 'undefined'). --spec send_error_status(state(), ne_binary()) -> any(). +-spec send_error_status(state(), kz_term:ne_binary()) -> any(). send_error_status(State, Status) -> send_status(State, Status, ?FAX_ERROR, 'undefined'). --spec send_status(state(), ne_binary(), api_object()) -> any(). +-spec send_status(state(), kz_term:ne_binary(), kz_term:api_object()) -> any(). send_status(State, Status, FaxInfo) -> send_status(State, Status, ?FAX_SEND, FaxInfo). --spec send_status(state(), ne_binary(), ne_binary(), api_object()) -> any(). +-spec send_status(state(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_object()) -> any(). send_status(#state{job=JObj ,page=Page ,job_id=JobId @@ -1097,7 +1097,7 @@ send_status(#state{job=JObj ]), kapi_fax:publish_status(Payload). --spec send_reply_status(ne_binary(), ne_binary(), ne_binary(), ne_binary(), ne_binary(), api_object()) -> 'ok'. +-spec send_reply_status(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_object()) -> 'ok'. send_reply_status(Q, MsgId, JobId, Status, AccountId, JObj) -> Payload = props:filter_undefined( [{<<"Job-ID">>, JobId} @@ -1109,7 +1109,7 @@ send_reply_status(Q, MsgId, JobId, Status, AccountId, JObj) -> ]), kapi_fax:publish_targeted_status(Q, Payload). --spec send_control_status(ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec send_control_status(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. send_control_status(CtrlQ, Q, JobId, FaxState) -> Payload = [{<<"Job-ID">>, JobId} ,{<<"Fax-State">>, FaxState} @@ -1118,12 +1118,12 @@ send_control_status(CtrlQ, Q, JobId, FaxState) -> Publisher = fun(P) -> kapi_fax:publish_targeted_status(CtrlQ, P) end, kz_amqp_worker:cast(Payload, Publisher). --spec handle_start_job(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_start_job(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_start_job(JObj, _Props) -> 'true' = kapi_fax:start_job_v(JObj), fax_worker_sup:start_fax_job(JObj). --spec validate_tiff(ne_binary()) -> {'ok', ne_binary()} | {'error', ne_binary()}. +-spec validate_tiff(kz_term:ne_binary()) -> {'ok', kz_term:ne_binary()} | {'error', kz_term:ne_binary()}. validate_tiff(Filename) -> case file:read_file_info(Filename) of {'ok', _} -> @@ -1134,7 +1134,7 @@ validate_tiff(Filename) -> {'error', <<"could not convert input file">>} end. --spec validate_tiff_content(ne_binary()) -> {'ok', ne_binary()} | {'error', ne_binary()}. +-spec validate_tiff_content(kz_term:ne_binary()) -> {'ok', kz_term:ne_binary()} | {'error', kz_term:ne_binary()}. validate_tiff_content(Filename) -> case os:find_executable("tiff2pdf") of 'false' -> diff --git a/applications/fax/src/fax_worker_sup.erl b/applications/fax/src/fax_worker_sup.erl index 7fdd5982de7..7afd89cb5c2 100644 --- a/applications/fax/src/fax_worker_sup.erl +++ b/applications/fax/src/fax_worker_sup.erl @@ -30,7 +30,7 @@ start_fax_job(FaxJob) -> %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -43,7 +43,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 5, diff --git a/applications/fax/src/fax_xmpp.erl b/applications/fax/src/fax_xmpp.erl index a66b3b83b0b..f2412f88300 100644 --- a/applications/fax/src/fax_xmpp.erl +++ b/applications/fax/src/fax_xmpp.erl @@ -41,14 +41,14 @@ -type xmpp_client() :: #client{}. %% escalus --record(state, {faxbox_id :: api_ne_binary() - ,printer_id :: api_ne_binary() - ,oauth_app_id :: api_ne_binary() +-record(state, {faxbox_id :: kz_term:api_ne_binary() + ,printer_id :: kz_term:api_ne_binary() + ,oauth_app_id :: kz_term:api_ne_binary() ,refresh_token :: oauth_refresh_token() | 'undefined' ,connected = 'false' :: boolean() ,session :: xmpp_client() | 'undefined' - ,jid :: api_ne_binary() - ,monitor :: api_reference() + ,jid :: kz_term:api_ne_binary() + ,monitor :: kz_term:api_reference() }). -type state() :: #state{}. @@ -57,7 +57,7 @@ %%-define(SERVER(P), {{'via', 'kz_globals', {'xmpp', P}}). -define(SERVER(P), {'via', 'kz_globals', ?NAME(P)}). --spec start_link(ne_binary()) -> startlink_ret(). +-spec start_link(kz_term:ne_binary()) -> kz_types:startlink_ret(). start_link(PrinterId) -> lager:debug("starting new xmpp process for ~s", [PrinterId]), case gen_server:start_link(?SERVER(PrinterId), ?MODULE, [PrinterId], []) of @@ -67,24 +67,24 @@ start_link(PrinterId) -> Other -> Other end. --spec stop(ne_binary()) -> 'ok'. +-spec stop(kz_term:ne_binary()) -> 'ok'. stop(PrinterId) -> case kz_globals:whereis_name(?NAME(PrinterId)) of 'undefined' -> 'ok'; Pid -> gen_server:cast(Pid, 'stop') end. --spec init(ne_binaries()) -> {'ok', state(), pos_integer()}. +-spec init(kz_term:ne_binaries()) -> {'ok', state(), pos_integer()}. init([PrinterId]) -> process_flag('trap_exit', 'true'), gen_server:cast(self(), 'start'), {'ok', #state{faxbox_id=PrinterId}, ?POLLING_INTERVAL}. --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', 'ok', State}. --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('start', #state{faxbox_id=FaxBoxId} = State) -> case kz_datamgr:open_doc(?KZ_FAXES_DB, FaxBoxId) of {'ok', JObj} -> @@ -127,7 +127,7 @@ handle_cast('subscribe', #state{jid=MyJID handle_cast('stop', State) -> {'stop', 'normal', State}; handle_cast(_Msg, State) -> {'noreply', State}. --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'stanza', _Client, #xmlel{}=Packet}, State) -> process_received_packet(Packet, State), {'noreply', State, ?POLLING_INTERVAL}; @@ -158,7 +158,7 @@ terminate(_Reason, _State) -> -spec code_change(any(), state(), any()) -> {'ok', state()}. code_change(_OldVsn, State, _Extra) -> {'ok', State}. --spec get_sub_msg(ne_binary()) -> ne_binary(). +-spec get_sub_msg(kz_term:ne_binary()) -> kz_term:ne_binary(). get_sub_msg(JID) -> BareJID = kapi_xmpp:jid_short(JID), Document = <<"" @@ -189,7 +189,7 @@ process_received_packet(#xmlel{name = <<"message">>}=Xml process_received_packet(#xmlel{name=Type}=Xml, _State) -> lager:debug("received xml element ~s : ~s", [Type, exml:to_pretty_iolist(Xml)]). --spec send_notify(ne_binary(), ne_binary()) -> any(). +-spec send_notify(kz_term:ne_binary(), kz_term:ne_binary()) -> any(). send_notify(PrinterId, JID) -> Payload = props:filter_undefined( [{<<"Event-Name">>, <<"push">>} @@ -202,7 +202,7 @@ send_notify(PrinterId, JID) -> lager:debug("received xmpp push for printer ~s", [PrinterId]), kz_amqp_worker:cast(Payload, fun kapi_xmpp:publish_event/1). --spec connect(ne_binary(), ne_binary()) -> +-spec connect(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', xmpp_client()} | {'error', any()}. connect(JID, Password) -> @@ -246,7 +246,7 @@ handle_start(JObj, State) -> ,refresh_token=RefreshToken }. --spec auth_xoauth2(escalus_connection:client(), kz_proplist()) -> 'ok'. +-spec auth_xoauth2(escalus_connection:client(), kz_term:proplist()) -> 'ok'. auth_xoauth2(Conn, Props) -> Username = get_property(username, Props), Password = get_property(password, Props), @@ -292,7 +292,7 @@ start_all_printers() -> 'ok'. --spec send_start_printer(ne_binary(), ne_binary()) -> any(). +-spec send_start_printer(kz_term:ne_binary(), kz_term:ne_binary()) -> any(). send_start_printer(PrinterId, JID) -> Payload = props:filter_undefined( [{<<"Event-Name">>, <<"start">>} @@ -304,13 +304,13 @@ send_start_printer(PrinterId, JID) -> ]), kz_amqp_worker:cast(Payload, fun kapi_xmpp:publish_event/1). --spec handle_printer_start(kz_json:object(), kz_proplist()) -> sup_startchild_ret(). +-spec handle_printer_start(kz_json:object(), kz_term:proplist()) -> kz_types:sup_startchild_ret(). handle_printer_start(JObj, _Props) -> 'true' = kapi_xmpp:event_v(JObj), PrinterId = kz_json:get_value(<<"Application-Data">>, JObj), fax_xmpp_sup:start_printer(PrinterId). --spec handle_printer_stop(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_printer_stop(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_printer_stop(JObj, _Props) -> 'true' = kapi_xmpp:event_v(JObj), PrinterId = kz_json:get_value(<<"Application-Data">>, JObj), diff --git a/applications/fax/src/fax_xmpp_sup.erl b/applications/fax/src/fax_xmpp_sup.erl index a549e9c7a9e..916d1516a06 100644 --- a/applications/fax/src/fax_xmpp_sup.erl +++ b/applications/fax/src/fax_xmpp_sup.erl @@ -31,11 +31,11 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec start_printer(ne_binary()) -> sup_startchild_ret(). +-spec start_printer(kz_term:ne_binary()) -> kz_types:sup_startchild_ret(). start_printer(PrinterId) -> supervisor:start_child(?SERVER, [PrinterId]). @@ -52,7 +52,7 @@ start_printer(PrinterId) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 25, diff --git a/applications/fax/src/kapi_xmpp.erl b/applications/fax/src/kapi_xmpp.erl index 5551547051a..84935563599 100644 --- a/applications/fax/src/kapi_xmpp.erl +++ b/applications/fax/src/kapi_xmpp.erl @@ -40,7 +40,7 @@ --spec event(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec event(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. event(Prop) when is_list(Prop) -> case event_v(Prop) of 'true' -> kz_api:build_message(Prop, ?XMPP_EVENT_HEADERS, ?OPTIONAL_XMPP_EVENT_HEADERS); @@ -48,14 +48,14 @@ event(Prop) when is_list(Prop) -> end; event(JObj) -> event(kz_json:to_proplist(JObj)). --spec event_v(api_terms()) -> boolean(). +-spec event_v(kz_term:api_terms()) -> boolean(). event_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?XMPP_EVENT_HEADERS, ?XMPP_EVENT_VALUES, ?XMPP_EVENT_TYPES); event_v(JObj) -> event_v(kz_json:to_proplist(JObj)). --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, Props) -> JID = props:get_value('jid', Props, <<"*">>), Events = props:get_value('restrict_to', Props, [<<"*">>]), @@ -66,7 +66,7 @@ bind_q(Q, [Event|T], JID) -> bind_q(Q, T, JID); bind_q(_Q, [], _JID) -> 'ok'. --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Queue, Props) -> JID = props:get_value('jid', Props, <<"*">>), Events = props:get_value('restrict_to', Props, [<<"*">>]), @@ -87,8 +87,8 @@ declare_exchanges() -> amqp_util:new_exchange(?XMPP_EXCHANGE, <<"fanout">>). --spec publish_event(api_terms()) -> 'ok'. --spec publish_event(api_terms(), ne_binary()) -> 'ok'. +-spec publish_event(kz_term:api_terms()) -> 'ok'. +-spec publish_event(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_event(Event) -> publish_event(Event, ?DEFAULT_CONTENT_TYPE). publish_event(Event, ContentType) when is_list(Event) -> JID = props:get_value(<<"JID">>, Event), @@ -104,18 +104,18 @@ regexp_get(Jid, Regex) -> re:run(Jid, Regex, [{'capture', 'all_but_first', 'binary'}]), ShortJid. --spec jid_short(ne_binary()) -> ne_binary(). +-spec jid_short(kz_term:ne_binary()) -> kz_term:ne_binary(). jid_short(JID) -> regexp_get(JID, <<"^([^/]*)">>). --spec jid_username(ne_binary()) -> ne_binary(). +-spec jid_username(kz_term:ne_binary()) -> kz_term:ne_binary(). jid_username(JID) -> regexp_get(JID, <<"^([^@]*)">>). --spec jid_server(ne_binary()) -> ne_binary(). +-spec jid_server(kz_term:ne_binary()) -> kz_term:ne_binary(). jid_server(JID) -> regexp_get(JID, <<"^[^@]*[@]([^/]*)">>). --spec jid_resource(ne_binary()) -> ne_binary(). +-spec jid_resource(kz_term:ne_binary()) -> kz_term:ne_binary(). jid_resource(JID) -> regexp_get(JID, <<"^[^/]*[/](.*)">>). diff --git a/applications/frontier/src/cb_access_lists.erl b/applications/frontier/src/cb_access_lists.erl index 7ebe310ec4b..c4e3e50cfbe 100644 --- a/applications/frontier/src/cb_access_lists.erl +++ b/applications/frontier/src/cb_access_lists.erl @@ -86,7 +86,7 @@ validate_acls(Context, ?HTTP_DELETE) -> validate_delete_acls(thing_doc(Context)). -spec thing_doc(cb_context:context()) -> cb_context:context(). --spec thing_doc(cb_context:context(), ne_binary(), api_binary()) -> cb_context:context(). +-spec thing_doc(cb_context:context(), kz_term:ne_binary(), kz_term:api_binary()) -> cb_context:context(). thing_doc(Context) -> case cb_context:req_nouns(Context) of [{<<"access_lists">>, []}, {<<"accounts">>, [AccountId]} | _] -> @@ -111,7 +111,7 @@ thing_doc(Context, ThingId, Type) -> thing_id_not_found(Context1, ThingId) end. --spec thing_id_not_found(cb_context:context(), ne_binary()) -> cb_context:context(). +-spec thing_id_not_found(cb_context:context(), kz_term:ne_binary()) -> cb_context:context(). thing_id_not_found(Context, ThingId) -> cb_context:add_system_error('bad_identifier' ,kz_json:from_list([{<<"cause">>, <<"Identifier was not found">>} @@ -133,7 +133,7 @@ validate_get_acls(Context, Doc) -> crossbar_util:response(AccessLists, Context). -spec validate_delete_acls(cb_context:context()) -> cb_context:context(). --spec validate_delete_acls(cb_context:context(), api_object()) -> cb_context:context(). +-spec validate_delete_acls(cb_context:context(), kz_term:api_object()) -> cb_context:context(). validate_delete_acls(Context) -> case cb_context:resp_status(Context) of 'success' -> validate_delete_acls(Context, cb_context:doc(Context)); @@ -150,7 +150,7 @@ validate_delete_acls(Context, Doc) -> -spec validate_set_acls(cb_context:context()) -> cb_context:context(). --spec validate_set_acls(cb_context:context(), kz_json:object(), api_object()) -> +-spec validate_set_acls(cb_context:context(), kz_json:object(), kz_term:api_object()) -> cb_context:context(). validate_set_acls(Context) -> lager:debug("access lists data is valid, setting on thing"), diff --git a/applications/frontier/src/frontier_handle_acl.erl b/applications/frontier/src/frontier_handle_acl.erl index e21b279c48d..6cb233b35d9 100644 --- a/applications/frontier/src/frontier_handle_acl.erl +++ b/applications/frontier/src/frontier_handle_acl.erl @@ -14,7 +14,7 @@ -include("frontier.hrl"). --spec handle_acl_req(kz_json:object(), kz_proplist()) -> any(). +-spec handle_acl_req(kz_json:object(), kz_term:proplist()) -> any(). handle_acl_req(Reqest, _Props) -> 'true' = kapi_frontier:acls_req_v(Reqest), Entity = kz_json:get_value(<<"Entity">>, Reqest), @@ -35,8 +35,8 @@ send_response(Reqest, Responses) -> lager:debug("publishing response"), kapi_frontier:publish_acls_resp(ServerID, Resp). --spec make_section(kz_json:objects(), ne_binary()) -> kz_json:object(). --spec make_section(ne_binary(), api_binary(), api_binaries(), api_binary()) -> kz_json:object(). +-spec make_section(kz_json:objects(), kz_term:ne_binary()) -> kz_json:object(). +-spec make_section(kz_term:ne_binary(), kz_term:api_binary(), kz_term:api_binaries(), kz_term:api_binary()) -> kz_json:object(). make_section([], _) -> kz_json:new(); make_section([JObj], Section) -> @@ -54,7 +54,7 @@ make_section(Section, Order, CIDRs, UserAgent) -> ]), kz_json:from_list([{Section, kz_json:from_list(Props)}]). --spec lookup_acl_records(ne_binary(), boolean()) -> kz_json:objects(). +-spec lookup_acl_records(kz_term:ne_binary(), boolean()) -> kz_json:objects(). lookup_acl_records(Entity, IncludeRealm) -> lager:debug("Handle acl request for ~s", [Entity]), Realm = frontier_utils:extract_realm(Entity), @@ -67,11 +67,11 @@ lookup_acl_records(Entity, IncludeRealm) -> make_deny_acl(Entity, IncludeRealm) end. --spec lookup_acl_records(ne_binary()) -> kz_json:objects(). +-spec lookup_acl_records(kz_term:ne_binary()) -> kz_json:objects(). lookup_acl_records(Entity) -> lookup_acl_records(Entity, 'true'). --spec run_acl_query(ne_binary(), boolean()) -> kz_json:objects(). +-spec run_acl_query(kz_term:ne_binary(), boolean()) -> kz_json:objects(). run_acl_query(Entity, IncludeRealm) -> ViewOpts = build_view_options(Entity, IncludeRealm), {'ok', UserDb} = kapps_util:get_account_by_realm(frontier_utils:extract_realm(Entity)), @@ -85,7 +85,7 @@ run_acl_query(Entity, IncludeRealm) -> [] end. --spec build_view_options(ne_binary(), boolean()) -> kz_proplist(). +-spec build_view_options(kz_term:ne_binary(), boolean()) -> kz_term:proplist(). build_view_options(Entity, IncludeRealm) -> case binary:split(Entity, <<"@">>) of [User, _OnRealm] = Keys -> @@ -96,7 +96,7 @@ build_view_options(Entity, IncludeRealm) -> [JustRealm] -> [{'key', JustRealm}] end. --spec make_deny_acl(ne_binary(), boolean()) -> kz_json:objects(). +-spec make_deny_acl(kz_term:ne_binary(), boolean()) -> kz_json:objects(). make_deny_acl(Entity, IncludeRealm) -> Realm = frontier_utils:extract_realm(Entity), IsDevice = Realm =/= Entity, @@ -121,6 +121,6 @@ make_deny_acl(Entity, IncludeRealm) -> _ -> [Record] end. --spec make_deny_acl(ne_binary()) -> kz_json:objects(). +-spec make_deny_acl(kz_term:ne_binary()) -> kz_json:objects(). make_deny_acl(Entity) -> make_deny_acl(Entity, 'true'). diff --git a/applications/frontier/src/frontier_handle_rate.erl b/applications/frontier/src/frontier_handle_rate.erl index 3d91e0c48e2..24bcba67dd0 100644 --- a/applications/frontier/src/frontier_handle_rate.erl +++ b/applications/frontier/src/frontier_handle_rate.erl @@ -29,30 +29,30 @@ is_device_defaults(JObj) -> frontier_utils:is_device(JObj) andalso IsDefaultRates. --spec names() -> ne_binaries(). +-spec names() -> kz_term:ne_binaries(). names() -> [<<"registrations">> ,<<"invites">> ,<<"total_packets">> ]. --spec methods() -> ne_binaries(). +-spec methods() -> kz_term:ne_binaries(). methods() -> [<<"REGISTER">> ,<<"INVITE">> ,<<"TOTAL">> ]. --spec name_to_method(ne_binary()) -> ne_binary(). +-spec name_to_method(kz_term:ne_binary()) -> kz_term:ne_binary(). name_to_method(Name) -> Props = lists:zip(names(), methods()), props:get_value(Name, Props). --spec resolve_method(ne_binary()) -> ne_binary(). +-spec resolve_method(kz_term:ne_binary()) -> kz_term:ne_binary(). resolve_method(Method) -> props:get_value(Method, lists:zip(methods(), names())). --spec handle_rate_req(kz_json:object(), kz_proplist()) -> any(). +-spec handle_rate_req(kz_json:object(), kz_term:proplist()) -> any(). handle_rate_req(JObj, _Props) -> Entity = kz_json:get_value(<<"Entity">>, JObj), IncludeRealm = kz_json:is_true(<<"With-Realm">>, JObj, 'false'), @@ -61,7 +61,7 @@ handle_rate_req(JObj, _Props) -> Limits = lookup_rate_limit_records(Entity, IncludeRealm, MethodList), send_response(Limits, JObj). --spec lookup_methods(kz_json:object()) -> api_binaries(). +-spec lookup_methods(kz_json:object()) -> kz_term:api_binaries(). lookup_methods(JObj) -> Method = kz_json:get_value(<<"Method">>, JObj), MethodName = case Method of @@ -87,11 +87,11 @@ send_response(Limits, Reqest) -> kapi_frontier:publish_ratelimits_resp(Srv, kz_json:merge_jobjs(Limits, RespStub)). --spec lookup_rate_limit_records(ne_binary()) -> kz_json:object(). +-spec lookup_rate_limit_records(kz_term:ne_binary()) -> kz_json:object(). lookup_rate_limit_records(Entity) -> lookup_rate_limit_records(Entity, 'true', names()). --spec lookup_rate_limit_records(ne_binary(), boolean(), ne_binaries()) -> kz_json:object(). +-spec lookup_rate_limit_records(kz_term:ne_binary(), boolean(), kz_term:ne_binaries()) -> kz_json:object(). lookup_rate_limit_records(Entity, IncludeRealm, MethodList) -> lager:info("Handle rate limit request for ~s", [Entity]), Realm = frontier_utils:extract_realm(Entity), @@ -105,7 +105,7 @@ lookup_rate_limit_records(Entity, IncludeRealm, MethodList) -> end, lists:foldl(fun fold_responses/2, kz_json:new(), lists:flatten(Responses)). --spec build_list_of_querynames(ne_binary(), boolean()) -> ne_binaries(). +-spec build_list_of_querynames(kz_term:ne_binary(), boolean()) -> kz_term:ne_binaries(). build_list_of_querynames(Entity, IncludeRealm) -> Realm = frontier_utils:extract_realm(Entity), Username = frontier_utils:extract_username(Entity), @@ -120,7 +120,7 @@ build_list_of_querynames(Entity, IncludeRealm) -> 'false' -> [QueryName] end. --spec run_rate_limits_query(ne_binary(), ne_binary(), boolean(), ne_binaries()) -> kz_json:objects(). +-spec run_rate_limits_query(kz_term:ne_binary(), kz_term:ne_binary(), boolean(), kz_term:ne_binaries()) -> kz_json:objects(). run_rate_limits_query(Entity, AccountDB, IncludeRealm, MethodList) -> EntityList = build_list_of_querynames(Entity, IncludeRealm), Rates = fetch_rates(EntityList, IncludeRealm, MethodList, AccountDB), @@ -138,7 +138,7 @@ run_rate_limits_query(Entity, AccountDB, IncludeRealm, MethodList) -> end, Rates ++ FromSysCOnfig. --spec to_json_key(ne_binary()) -> ne_binary(). +-spec to_json_key(kz_term:ne_binary()) -> kz_term:ne_binary(). to_json_key(Token) -> Tokens = binary:split(Token, <<"_">>), kz_binary:join([kz_binary:ucfirst(T) || T <- Tokens], <<"-">>). @@ -169,7 +169,7 @@ fold_responses(Record, Acc) -> end, kz_json:set_value(Type, S3, Acc). --spec make_deny_rates(ne_binary(), boolean(), ne_binaries()) -> kz_json:objects(). +-spec make_deny_rates(kz_term:ne_binary(), boolean(), kz_term:ne_binaries()) -> kz_json:objects(). make_deny_rates(Entity, IncludeRealm, MethodList) -> Rates = deny_rates_for_entity(Entity, MethodList), Realm = frontier_utils:extract_realm(Entity), @@ -181,7 +181,7 @@ make_deny_rates(Entity, IncludeRealm, MethodList) -> end. %% Kamailio expects -1 for unkown entities --spec deny_rates_for_entity(ne_binary(), ne_binaries()) -> kz_json:objects(). +-spec deny_rates_for_entity(kz_term:ne_binary(), kz_term:ne_binaries()) -> kz_json:objects(). deny_rates_for_entity(Entity, MethodList) -> lists:flatmap(fun(Method) -> construct_records(Method, Entity, -1, -1) @@ -189,7 +189,7 @@ deny_rates_for_entity(Entity, MethodList) -> ,MethodList ). --spec construct_records(ne_binary(), ne_binary(), ne_binary() | integer(), ne_binary() | integer()) -> +-spec construct_records(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary() | integer(), kz_term:ne_binary() | integer()) -> kz_json:objects(). construct_records(Method, Entity, RPM, RPS) -> {Name, Type} = case binary:split(Entity, <<"@">>) of @@ -209,11 +209,11 @@ construct_records(Method, Entity, RPM, RPS) -> || JObj <- [RPMObject, RPSObject] ]. --spec section_type(ne_binary()) -> ne_binary(). +-spec section_type(kz_term:ne_binary()) -> kz_term:ne_binary(). section_type(<<"realm">>) -> <<"account">>; section_type(<<"device">>) -> <<"device">>. --spec fetch_rates_from_sys_config(ne_binary() | ne_binaries(), ne_binary(), ne_binaries()) -> +-spec fetch_rates_from_sys_config(kz_term:ne_binary() | kz_term:ne_binaries(), kz_term:ne_binary(), kz_term:ne_binaries()) -> kz_json:objects(). fetch_rates_from_sys_config(_, _, []) -> lager:info("sysconfig: Empty request - empty response"), @@ -234,7 +234,7 @@ fetch_rates_from_sys_config(<<_/binary>> = Entity, Type, MethodList) -> end end, [], MethodList). --spec fetch_rates(ne_binaries(), boolean(), ne_binaries(), ne_binary()) -> kz_json:objects(). +-spec fetch_rates(kz_term:ne_binaries(), boolean(), kz_term:ne_binaries(), kz_term:ne_binary()) -> kz_json:objects(). fetch_rates(_, _, [], _) -> lager:info("document: Empty request - empty response"), []; @@ -258,7 +258,7 @@ fetch_rates(EntityList, IncludeRealm, MethodList, AccountDB) -> {_, Partial} -> Partial ++ fetch_from_parents(AccountDB, MethodList, Realm) end. --spec fetch_from_parents(ne_binary(), ne_binaries(), ne_binary()) -> kz_json:objects(). +-spec fetch_from_parents(kz_term:ne_binary(), kz_term:ne_binaries(), kz_term:ne_binary()) -> kz_json:objects(). fetch_from_parents(AccountDb, MethodList, Realm) -> case kz_account:fetch(AccountDb) of {'ok', JObj} -> @@ -268,7 +268,7 @@ fetch_from_parents(AccountDb, MethodList, Realm) -> lager:info("Cant't access to db: ~p", [_Reason]) end. --spec check_fallbacks(ne_binaries(), ne_binaries(), ne_binary()) -> kz_json:objects(). +-spec check_fallbacks(kz_term:ne_binaries(), kz_term:ne_binaries(), kz_term:ne_binary()) -> kz_json:objects(). check_fallbacks(Tree, MethodList, Realm) -> Result = lists:foldl(fun (X, Acc) -> check_fallback(X, Acc, MethodList, Realm) end, 'empty', Tree), case Result of @@ -276,7 +276,7 @@ check_fallbacks(Tree, MethodList, Realm) -> _ -> Result end. --spec check_fallback(ne_binary(), atom() | kz_json:objects(), ne_binaries(), ne_binary()) -> +-spec check_fallback(kz_term:ne_binary(), atom() | kz_json:objects(), kz_term:ne_binaries(), kz_term:ne_binary()) -> atom() | kz_json:objects(). check_fallback(AccountId, 'empty', MethodList, Realm) -> AccountDB = kz_util:format_account_id(AccountId, 'encoded'), @@ -297,7 +297,7 @@ check_fallback(_, Acc, _, _) -> Acc. -type couch_ret() :: {'ok', kz_json:object()} | {'error', any()}. --spec build_results(couch_ret(), ne_binaries(), ne_binary()) -> kz_json:objects(). +-spec build_results(couch_ret(), kz_term:ne_binaries(), kz_term:ne_binary()) -> kz_json:objects(). build_results({'error', _Reason}, _, _) -> lager:error("Can't fetch data from db: ~p", [_Reason]), []; @@ -305,7 +305,7 @@ build_results({'ok', JObj}, MethodList, Realm) -> Limits = kz_json:get_value(<<"account">>, JObj), lists:foldl(fun (M, Acc) -> build(M, Acc, Limits, Realm) end,[],MethodList). --spec build(ne_binary(), kz_json:objects(), kz_json:object(), ne_binary()) -> kz_json:objects(). +-spec build(kz_term:ne_binary(), kz_json:objects(), kz_json:object(), kz_term:ne_binary()) -> kz_json:objects(). build(Method, Acc, JObj, Realm) -> PerMinute = kz_json:get_value([?MINUTE, Method], JObj), PerSecond = kz_json:get_value([?SECOND, Method], JObj), diff --git a/applications/frontier/src/frontier_maintenance.erl b/applications/frontier/src/frontier_maintenance.erl index 980d8a4a02d..95819e3af8d 100644 --- a/applications/frontier/src/frontier_maintenance.erl +++ b/applications/frontier/src/frontier_maintenance.erl @@ -16,7 +16,7 @@ ,update_system_default/2 ]). --spec lookup_acls(ne_binary()) -> 'ok'. +-spec lookup_acls(kz_term:ne_binary()) -> 'ok'. lookup_acls(Entity) -> io:format("looking for ACL records for ~s:~n", [Entity]), lists:foreach(fun print_acl_record/1, frontier_handle_acl:lookup_acl_records(Entity)). @@ -30,14 +30,14 @@ print_acl_record(Record) -> io:format("~s ~s use policy ~s for cidrs:~n",[Type, Name, Policy]), lists:foreach(fun(CIDR) -> io:format(" ~s~n", [CIDR]) end, CIDRs). --spec lookup_rate_limits(ne_binary()) -> 'ok'. +-spec lookup_rate_limits(kz_term:ne_binary()) -> 'ok'. lookup_rate_limits(Entity) -> Limits = frontier_handle_rate:lookup_rate_limit_records(Entity), lists:foreach(fun(S) -> print_limits(S, kz_json:get_value(S, Limits)) end ,[<<"Device">>, <<"Realm">>] ). --spec print_limits(ne_binary(), kz_json:object()) -> 'ok'. +-spec print_limits(kz_term:ne_binary(), kz_json:object()) -> 'ok'. print_limits(Section, Rates) -> Name = kz_json:get_value(<<"Name">>, Rates), Min = kz_json:get_value(<<"Minute">>, Rates, kz_json:new()), @@ -51,7 +51,7 @@ print_limits(Section, Rates) -> ) end, Keys). --spec update_system_default(ne_binary(), ne_binary()) -> 'ok'. +-spec update_system_default(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. update_system_default(Path, Value) -> Keys = binary:split(Path, <<".">>, ['global']), NewRate = kz_term:to_integer(Value), diff --git a/applications/frontier/src/frontier_shared_listener.erl b/applications/frontier/src/frontier_shared_listener.erl index 3b8fc11e424..2fae05a0a5e 100644 --- a/applications/frontier/src/frontier_shared_listener.erl +++ b/applications/frontier/src/frontier_shared_listener.erl @@ -46,7 +46,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'responders', ?RESPONDERS} ,{'bindings', ?BINDINGS} @@ -88,7 +88,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -102,7 +102,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _QueueNAme}}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'is_consuming', _IsConsuming}}, State) -> @@ -120,7 +120,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -132,7 +132,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/frontier/src/frontier_sup.erl b/applications/frontier/src/frontier_sup.erl index 54bc5b85e97..998de6035dc 100644 --- a/applications/frontier/src/frontier_sup.erl +++ b/applications/frontier/src/frontier_sup.erl @@ -30,7 +30,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -47,7 +47,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, diff --git a/applications/frontier/src/frontier_utils.erl b/applications/frontier/src/frontier_utils.erl index 23dfaa364ae..0a3968139e9 100644 --- a/applications/frontier/src/frontier_utils.erl +++ b/applications/frontier/src/frontier_utils.erl @@ -19,26 +19,26 @@ ,get_entity_type/1 ]). --spec get_entity_type(ne_binary()) -> ne_binary(). +-spec get_entity_type(kz_term:ne_binary()) -> kz_term:ne_binary(). get_entity_type(Entity) -> case binary:split(Entity, <<"@">>) of [_, _] -> <<"device">>; [_] -> <<"realm">> end. --spec is_device_entity(ne_binary()) -> boolean(). +-spec is_device_entity(kz_term:ne_binary()) -> boolean(). is_device_entity(Entity) -> Realm = extract_realm(Entity), Realm =/= Entity. --spec extract_realm(ne_binary()) -> ne_binary(). +-spec extract_realm(kz_term:ne_binary()) -> kz_term:ne_binary(). extract_realm(Entity) -> case binary:split(Entity, <<"@">>) of [_, OnRealm] -> OnRealm; [JustRealm] -> JustRealm end. --spec extract_username(ne_binary()) -> api_binary(). +-spec extract_username(kz_term:ne_binary()) -> kz_term:api_binary(). extract_username(Entity) -> case binary:split(Entity, <<"@">>) of [Username, _] -> Username; diff --git a/applications/frontier/src/kapi_frontier.erl b/applications/frontier/src/kapi_frontier.erl index 931bfc24538..6954fad0801 100644 --- a/applications/frontier/src/kapi_frontier.erl +++ b/applications/frontier/src/kapi_frontier.erl @@ -66,7 +66,7 @@ -define(ACL_FLUSH_TYPES, []). --spec ratelimits_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec ratelimits_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. ratelimits_resp(Prop) when is_list(Prop) -> case ratelimits_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?RESP_HEADERS, ?OPTIONAL_RESP_HEADERS); @@ -74,24 +74,24 @@ ratelimits_resp(Prop) when is_list(Prop) -> end; ratelimits_resp(JObj) -> ratelimits_resp(kz_json:to_proplist(JObj)). --spec publish_ratelimits_resp(ne_binary(), kz_json:object()) -> ok. --spec publish_ratelimits_resp(ne_binary(), api_terms(), ne_binary()) -> ok. +-spec publish_ratelimits_resp(kz_term:ne_binary(), kz_json:object()) -> ok. +-spec publish_ratelimits_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> ok. publish_ratelimits_resp(Srv, JObj) -> publish_ratelimits_resp(Srv, JObj, ?DEFAULT_CONTENT_TYPE). publish_ratelimits_resp(Srv, Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?RATELIMITS_RESP_VALUES, fun ratelimits_resp/1), amqp_util:targeted_publish(Srv, Payload, ContentType). --spec ratelimits_req_v(api_terms()) -> boolean(). +-spec ratelimits_req_v(kz_term:api_terms()) -> boolean(). ratelimits_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?REQ_HEADERS, ?RATELIMITS_REQ_VALUES, ?REQ_TYPES); ratelimits_req_v(JObj) -> ratelimits_req_v(kz_json:to_proplist(JObj)). --spec ratelimits_resp_v(api_terms()) -> boolean(). +-spec ratelimits_resp_v(kz_term:api_terms()) -> boolean(). ratelimits_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?RESP_HEADERS, ?RATELIMITS_RESP_VALUES, ?RATELIMITS_RESP_TYPES); ratelimits_resp_v(JObj) -> ratelimits_req_v(kz_json:to_proplist(JObj)). --spec acls_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec acls_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. acls_resp(Prop) when is_list(Prop) -> case acls_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?RESP_HEADERS, ?OPTIONAL_RESP_HEADERS); @@ -99,32 +99,32 @@ acls_resp(Prop) when is_list(Prop) -> end; acls_resp(JObj) -> acls_resp(kz_json:to_proplist(JObj)). --spec publish_acls_resp(ne_binary(), kz_json:object()) -> ok. --spec publish_acls_resp(ne_binary(), api_terms(), ne_binary()) -> ok. +-spec publish_acls_resp(kz_term:ne_binary(), kz_json:object()) -> ok. +-spec publish_acls_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> ok. publish_acls_resp(Srv, JObj) -> publish_acls_resp(Srv, JObj, ?DEFAULT_CONTENT_TYPE). publish_acls_resp(Srv, Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?ACL_RESP_VALUES, fun acls_resp/1), amqp_util:targeted_publish(Srv, Payload, ContentType). --spec acls_req_v(api_terms()) -> boolean(). +-spec acls_req_v(kz_term:api_terms()) -> boolean(). acls_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?REQ_HEADERS, ?ACL_REQ_VALUES, ?REQ_TYPES); acls_req_v(JObj) -> acls_req_v(kz_json:to_proplist(JObj)). --spec acls_resp_v(api_terms()) -> boolean(). +-spec acls_resp_v(kz_term:api_terms()) -> boolean(). acls_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?RESP_HEADERS, ?ACL_RESP_VALUES, ?ACL_RESP_TYPES); acls_resp_v(JObj) -> acls_resp_v(kz_json:to_proplist(JObj)). --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Q, _Props) -> amqp_util:bind_q_to_exchange(Q, ?ROUTE_KEY, ?FRONTIER_EXCHANGE). --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Q, _Props) -> amqp_util:unbind_q_from_exchange(Q, ?ROUTE_KEY, ?FRONTIER_EXCHANGE). --spec flush(api_terms()) -> +-spec flush(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. flush(Prop) when is_list(Prop) -> @@ -134,13 +134,13 @@ flush(Prop) when is_list(Prop) -> end; flush(JObj) -> flush(kz_json:to_proplist(JObj)). --spec flush_v(api_terms()) -> boolean(). +-spec flush_v(kz_term:api_terms()) -> boolean(). flush_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?ACL_FLUSH_HEADERS, ?ACL_FLUSH_VALUES, ?ACL_FLUSH_TYPES); flush_v(JObj) -> flush_v(kz_json:to_proplist(JObj)). --spec publish_flush(api_terms()) -> 'ok'. --spec publish_flush(api_terms(), ne_binary()) -> 'ok'. +-spec publish_flush(kz_term:api_terms()) -> 'ok'. +-spec publish_flush(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_flush(JObj) -> publish_flush(JObj, ?DEFAULT_CONTENT_TYPE). publish_flush(API, ContentType) -> diff --git a/applications/hangups/src/hangups_app.erl b/applications/hangups/src/hangups_app.erl index 861beb727d6..a64ddc6bd18 100644 --- a/applications/hangups/src/hangups_app.erl +++ b/applications/hangups/src/hangups_app.erl @@ -18,7 +18,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = declare_exchanges(), hangups_sup:start_link(). diff --git a/applications/hangups/src/hangups_channel_destroy.erl b/applications/hangups/src/hangups_channel_destroy.erl index cd6566494d4..235d5416089 100644 --- a/applications/hangups/src/hangups_channel_destroy.erl +++ b/applications/hangups/src/hangups_channel_destroy.erl @@ -23,7 +23,7 @@ %% %% @end %%-------------------------------------------------------------------- --spec handle_req(kz_call_event:doc(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_call_event:doc(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Props) -> 'true' = kapi_call:event_v(JObj), HangupCause = kz_call_event:hangup_cause(JObj, <<"unknown">>), @@ -32,7 +32,7 @@ handle_req(JObj, _Props) -> 'false' -> alert_about_hangup(HangupCause, JObj) end. --spec alert_about_hangup(ne_binary(), kz_call_event:doc()) -> 'ok'. +-spec alert_about_hangup(kz_term:ne_binary(), kz_call_event:doc()) -> 'ok'. alert_about_hangup(HangupCause, JObj) -> lager:debug("abnormal call termination: ~s", [HangupCause]), AccountId = kz_call_event:account_id(JObj, <<"unknown">>), @@ -54,7 +54,7 @@ alert_about_hangup(HangupCause, JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec maybe_add_hangup_specific(ne_binary(), kz_call_event:doc()) -> kz_proplist(). +-spec maybe_add_hangup_specific(kz_term:ne_binary(), kz_call_event:doc()) -> kz_term:proplist(). maybe_add_hangup_specific(<<"UNALLOCATED_NUMBER">>, JObj) -> maybe_add_number_info(JObj); maybe_add_hangup_specific(<<"NO_ROUTE_DESTINATION">>, JObj) -> @@ -68,7 +68,7 @@ maybe_add_hangup_specific(_HangupCause, JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec maybe_add_number_info(kz_call_event:doc()) -> kz_proplist(). +-spec maybe_add_number_info(kz_call_event:doc()) -> kz_term:proplist(). maybe_add_number_info(JObj) -> Destination = find_destination(JObj), Props = kz_json:recursive_to_proplist(JObj), @@ -89,7 +89,7 @@ maybe_add_number_info(JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec build_account_tree(ne_binary()) -> kz_proplist(). +-spec build_account_tree(kz_term:ne_binary()) -> kz_term:proplist(). build_account_tree(AccountId) -> {'ok', AccountDoc} = kz_account:fetch(AccountId), [{AncestorId, ?NE_BINARY=kz_account:fetch_name(AncestorId)} @@ -102,7 +102,7 @@ build_account_tree(AccountId) -> %% %% @end %%-------------------------------------------------------------------- --spec find_realm(kz_call_event:doc(), ne_binary()) -> ne_binary(). +-spec find_realm(kz_call_event:doc(), kz_term:ne_binary()) -> kz_term:ne_binary(). find_realm(JObj, <<_/binary>> = AccountId) -> case kz_call_event:account_id(JObj) of undefined -> @@ -119,14 +119,14 @@ find_realm(JObj, <<_/binary>> = AccountId) -> %% %% @end %%-------------------------------------------------------------------- --spec find_destination(kz_call_event:doc()) -> ne_binary(). +-spec find_destination(kz_call_event:doc()) -> kz_term:ne_binary(). find_destination(JObj) -> case catch binary:split(kz_json:get_value(<<"Request">>, JObj), <<"@">>) of [Num|_] -> Num; _ -> use_to_as_destination(JObj) end. --spec use_to_as_destination(kz_call_event:doc()) -> ne_binary(). +-spec use_to_as_destination(kz_call_event:doc()) -> kz_term:ne_binary(). use_to_as_destination(JObj) -> AccountId = kz_call_event:account_id(JObj), case catch binary:split(kz_json:get_value(<<"To-Uri">>, JObj), <<"@">>) of @@ -140,7 +140,7 @@ use_to_as_destination(JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec find_source(kz_call_event:doc()) -> ne_binary(). +-spec find_source(kz_call_event:doc()) -> kz_term:ne_binary(). find_source(JObj) -> AccountId = kz_call_event:account_id(JObj), case catch binary:split(kz_json:get_value(<<"From-Uri">>, JObj), <<"@">>) of @@ -154,13 +154,13 @@ find_source(JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec find_direction(kz_call_event:doc()) -> ne_binary(). +-spec find_direction(kz_call_event:doc()) -> kz_term:ne_binary(). find_direction(JObj) -> kz_call_event:call_direction(JObj, <<"unknown">>). %% @public --spec start_meters(ne_binary()) -> 'ok'. --spec start_meters(ne_binary(), ne_binary()) -> 'ok'. +-spec start_meters(kz_term:ne_binary()) -> 'ok'. +-spec start_meters(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. start_meters(HangupCause) -> folsom_metrics:new_meter(hangups_util:meter_name(HangupCause)). start_meters(AccountId, HangupCause) -> @@ -172,7 +172,7 @@ start_meters(AccountId, HangupCause) -> %% %% @end %%-------------------------------------------------------------------- --spec add_to_meters(ne_binary(), ne_binary()) -> 'ok'. +-spec add_to_meters(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. add_to_meters(AccountId, HangupCause) -> lager:debug("add to meter ~s/~s", [AccountId, HangupCause]), @@ -189,8 +189,8 @@ add_to_meters(AccountId, HangupCause) -> %% %% @end %%-------------------------------------------------------------------- --spec notify_meters(ne_binary()) -> any(). --spec notify_meters(ne_binary(), ne_binary()) -> any(). +-spec notify_meters(kz_term:ne_binary()) -> any(). +-spec notify_meters(kz_term:ne_binary(), kz_term:ne_binary()) -> any(). notify_meters(HangupCause) -> folsom_metrics_meter:mark(hangups_util:meter_name(HangupCause)). diff --git a/applications/hangups/src/hangups_config.erl b/applications/hangups/src/hangups_config.erl index c25a7e69848..e62d1aa0d68 100644 --- a/applications/hangups/src/hangups_config.erl +++ b/applications/hangups/src/hangups_config.erl @@ -25,10 +25,10 @@ ,<<"PICKED_OFF">> ]). --spec monitored_hangup_causes() -> ne_binaries(). +-spec monitored_hangup_causes() -> kz_term:ne_binaries(). monitored_hangup_causes() -> kapps_config:get(?APP_NAME, <<"hangups_to_monitor">>, ?DEFAULT_MONITORED). --spec ignored_hangup_causes() -> ne_binaries(). +-spec ignored_hangup_causes() -> kz_term:ne_binaries(). ignored_hangup_causes() -> kapps_config:get(?APP_NAME, <<"ignore_hangup_causes">>, ?DEFAULT_IGNORED). diff --git a/applications/hangups/src/hangups_listener.erl b/applications/hangups/src/hangups_listener.erl index 1a2ee2a0a46..67fe32e4b1c 100644 --- a/applications/hangups/src/hangups_listener.erl +++ b/applications/hangups/src/hangups_listener.erl @@ -46,7 +46,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'responders', ?RESPONDERS} ,{'bindings', ?BINDINGS} @@ -89,7 +89,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -103,7 +103,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener',{'created_queue',_QueueName}}, State) -> {'noreply', State}; handle_cast({'gen_listener',{'is_consuming',_IsConsuming}}, State) -> @@ -122,7 +122,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> lager:debug("unhandled msg: ~p", [_Info]), {'noreply', State}. @@ -135,7 +135,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/hangups/src/hangups_maintenance.erl b/applications/hangups/src/hangups_maintenance.erl index fdf0aa4af89..5c73423d247 100644 --- a/applications/hangups/src/hangups_maintenance.erl +++ b/applications/hangups/src/hangups_maintenance.erl @@ -26,8 +26,8 @@ -include("hangups.hrl"). -spec hangups_summary() -> 'ok'. --spec hangup_summary(ne_binary()) -> 'ok'. --spec hangup_summary(ne_binary(), ne_binary()) -> 'ok'. +-spec hangup_summary(kz_term:ne_binary()) -> 'ok'. +-spec hangup_summary(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. hangups_summary() -> Hangups = [{Name, hangups_query_listener:meter_resp(Name)} @@ -54,7 +54,7 @@ hangup_summary(HangupCause, AccountId) -> ], print_stats(Hangups). --spec account_summary(ne_binary()) -> 'ok'. +-spec account_summary(kz_term:ne_binary()) -> 'ok'. account_summary(AccountId) -> io:format("checking hangups summary for account ~s~n", [AccountId]), Hangups = [{Name, hangups_query_listener:meter_resp(Name)} @@ -67,7 +67,7 @@ account_summary(AccountId) -> ," ~-30s | ~-32s | ~-10s | ~-10s | ~-10s | ~-10s |~n" ). --spec print_stats(kz_proplist()) -> 'ok'. +-spec print_stats(kz_term:proplist()) -> 'ok'. print_stats([]) -> io:format("No data found for request\n"); print_stats(Stats) -> io:format(?STAT_SUMMARY_FORMAT @@ -75,7 +75,7 @@ print_stats(Stats) -> ), lists:foreach(fun print_stat/1, lists:keysort(1, Stats)). --spec print_stat({ne_binary(), kz_proplist()}) -> 'ok'. +-spec print_stat({kz_term:ne_binary(), kz_term:proplist()}) -> 'ok'. print_stat({Name, Stats}) -> AccountId = case hangups_util:meter_account_id(Name) of 'undefined' -> <<>>; @@ -95,13 +95,13 @@ print_stat({Name, Stats}) -> ]). %% @public --spec activate_monitor(ne_binary(), ne_binary()) -> 'ok'. +-spec activate_monitor(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. activate_monitor(AccountId, HangupCause) -> hangups_channel_destroy:start_meters(HangupCause), hangups_channel_destroy:start_meters(AccountId, HangupCause). %% @public --spec activate_monitors(ne_binary(), ne_binary()) -> 'ok'. +-spec activate_monitors(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. activate_monitors(AccountId, ThresholdOneMinute) -> F = fun(HangupCause) -> ConfigName = hangups_util:meter_name(HangupCause), @@ -113,7 +113,7 @@ activate_monitors(AccountId, ThresholdOneMinute) -> end, lists:foreach(F, hangups_config:monitored_hangup_causes()). --spec set_metric(ne_binary(), ne_binary()) -> 'ok'. +-spec set_metric(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. set_metric(Metric, LoadAvg) -> case is_valid_request(Metric, LoadAvg) of 'false' -> 'ok'; @@ -125,7 +125,7 @@ set_metric(Metric, LoadAvg) -> ) end. --spec set_metric(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec set_metric(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. set_metric(AccountId, Metric, LoadAvg) -> case is_valid_request(Metric, LoadAvg) of 'false' -> 'ok'; @@ -138,7 +138,7 @@ set_metric(AccountId, Metric, LoadAvg) -> ) end. --spec set_threshold(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec set_threshold(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. set_threshold(HangupCause, Metric, LoadAvg) -> case is_valid_request(HangupCause, Metric, LoadAvg) of 'false' -> 'ok'; @@ -146,7 +146,7 @@ set_threshold(HangupCause, Metric, LoadAvg) -> save_threshold(HangupCause, Metric, LoadAvg, fun kapps_config:set_default/3) end. --spec set_threshold(ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec set_threshold(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. set_threshold(AccountId, HangupCause, Metric, LoadAvg) -> case is_valid_request(HangupCause, Metric, LoadAvg) of 'false' -> 'ok'; @@ -155,20 +155,20 @@ set_threshold(AccountId, HangupCause, Metric, LoadAvg) -> save_threshold(HangupCause, Metric, LoadAvg, SaveFun) end. --type save_fun() :: fun((ne_binary(), kz_json:path(), kz_json:json_term()) -> any()). --spec account_save_fun(ne_binary()) -> save_fun(). +-type save_fun() :: fun((kz_term:ne_binary(), kz_json:path(), kz_json:json_term()) -> any()). +-spec account_save_fun(kz_term:ne_binary()) -> save_fun(). account_save_fun(AccountId) -> fun(Cfg, K, V) -> kapps_account_config:set(AccountId, Cfg, K, V) end. --spec save_threshold(ne_binary(), ne_binary(), ne_binary(), save_fun()) -> 'ok'. +-spec save_threshold(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), save_fun()) -> 'ok'. save_threshold(HangupCause, Metric, LoadAvg, SaveFun) -> ConfigName = hangups_util:meter_name(HangupCause), SaveFun(ConfigName, Metric, LoadAvg), io:format("set ~s for ~s to ~p~n", [Metric, ConfigName, LoadAvg]). --spec is_valid_request(ne_binary(), ne_binary()) -> boolean(). +-spec is_valid_request(kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_valid_request(Metric, LoadAvg) -> lists:all(fun is_valid_request_param/1 ,[{fun is_valid_threshold_name/1, Metric} @@ -176,7 +176,7 @@ is_valid_request(Metric, LoadAvg) -> ] ). --spec is_valid_request(ne_binary(), ne_binary(), ne_binary()) -> boolean(). +-spec is_valid_request(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_valid_request(HangupCause, Metric, LoadAvg) -> lists:all(fun is_valid_request_param/1 ,[{fun is_valid_threshold_name/1, Metric} @@ -189,7 +189,7 @@ is_valid_request(HangupCause, Metric, LoadAvg) -> is_valid_request_param({F, V}) -> F(V). --spec is_valid_hangup_cause(ne_binary()) -> 'true'. +-spec is_valid_hangup_cause(kz_term:ne_binary()) -> 'true'. is_valid_hangup_cause(HangupCause) -> HangupCauses = hangups_config:monitored_hangup_causes(), case lists:member(HangupCause, HangupCauses) of @@ -204,13 +204,13 @@ is_valid_hangup_cause(HangupCause) -> end. %% @public --spec set_monitor_threshold(text(), text()) -> boolean(). +-spec set_monitor_threshold(kz_term:text(), kz_term:text()) -> boolean(). set_monitor_threshold(HangupCause, TOM) -> ThresholdOnMinute = kz_term:to_float(TOM), update_monitor_thresholds(HangupCause, ThresholdOnMinute) andalso set_monitor_threshold(HangupCause, <<"one">>, ThresholdOnMinute). --spec update_monitor_thresholds(ne_binary(), float()) -> boolean(). +-spec update_monitor_thresholds(kz_term:ne_binary(), float()) -> boolean(). update_monitor_thresholds(HangupCause, ThresholdOnMinute) -> Scales = [{<<"five">>, 5} ,{<<"fifteen">>, 15} @@ -227,8 +227,8 @@ update_monitor_thresholds(HangupCause, ThresholdOnMinute) -> ). %% @public --spec set_monitor_threshold(ne_binary(), ne_binary(), float()) -> boolean(). --spec set_monitor_threshold(ne_binary(), ne_binary(), float(), boolean()) -> boolean(). +-spec set_monitor_threshold(kz_term:ne_binary(), kz_term:ne_binary(), float()) -> boolean(). +-spec set_monitor_threshold(kz_term:ne_binary(), kz_term:ne_binary(), float(), boolean()) -> boolean(). set_monitor_threshold(HangupCause, ThresholdName, T) -> Threshold = kz_term:to_float(T), set_monitor_threshold(kz_term:to_upper_binary(HangupCause) @@ -252,7 +252,7 @@ set_monitor_threshold(HangupCause, ThresholdName, Threshold, 'true') -> end, 'true'. --spec is_valid_threshold_name(ne_binary()) -> boolean(). +-spec is_valid_threshold_name(kz_term:ne_binary()) -> boolean(). is_valid_threshold_name(<<"one">>) -> 'true'; is_valid_threshold_name(<<"five">>) -> 'true'; is_valid_threshold_name(<<"fifteen">>) -> 'true'; @@ -262,7 +262,7 @@ is_valid_threshold_name(_Metric) -> io:format("metric '~s' is invalid~n", [_Metric]), 'false'. --spec is_valid_load_avg(ne_binary() | number()) -> boolean(). +-spec is_valid_load_avg(kz_term:ne_binary() | number()) -> boolean(). is_valid_load_avg(V) -> try kz_term:to_float(V) of F when F >= 0.0 -> 'true'; diff --git a/applications/hangups/src/hangups_monitoring.erl b/applications/hangups/src/hangups_monitoring.erl index 64b0f26db9f..3f483559e56 100644 --- a/applications/hangups/src/hangups_monitoring.erl +++ b/applications/hangups/src/hangups_monitoring.erl @@ -43,7 +43,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_server:start_link(?SERVER, [], []). @@ -81,7 +81,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -95,7 +95,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> lager:debug("unhandled cast: ~p", [_Msg]), {'noreply', State}. @@ -110,7 +110,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(?STAT_CHECK_MSG, State) -> _P = kz_util:spawn(fun check_stats/0), {'noreply', State#state{stat_timer_ref=start_timer()}, 'hibernate'}; @@ -154,7 +154,7 @@ start_timer() -> erlang:send_after(?MILLISECONDS_IN_MINUTE, self(), ?STAT_CHECK_MSG). -spec check_stats() -> 'ok'. --spec check_stats(ne_binary()) -> 'ok'. +-spec check_stats(kz_term:ne_binary()) -> 'ok'. check_stats() -> kz_util:put_callid(?MODULE), lists:foreach(fun check_stats/1, hangups_config:monitored_hangup_causes()). @@ -167,7 +167,7 @@ check_stats(HC) -> 'error':{'badmatch', []} -> 'ok' end. --spec maybe_alert(ne_binary(), list()) -> 'ok'. +-spec maybe_alert(kz_term:ne_binary(), list()) -> 'ok'. maybe_alert(HangupCause, Stats) -> case metrics_exceeded(HangupCause, Stats) of [] -> 'ok'; @@ -178,13 +178,13 @@ maybe_alert(HangupCause, Stats) -> send_alert(HangupCause) end. --spec metrics_exceeded(ne_binary(), list()) -> atoms(). +-spec metrics_exceeded(kz_term:ne_binary(), list()) -> kz_term:atoms(). metrics_exceeded(HangupCause, Stats) -> [Key || Key <- props:get_keys(Stats), threshold_exceeded(HangupCause, Stats, Key) ]. --spec threshold_exceeded(ne_binary(), list(), atom()) -> boolean(). +-spec threshold_exceeded(kz_term:ne_binary(), list(), atom()) -> boolean(). threshold_exceeded(_HangupCause, _Stats, 'acceleration') -> 'false'; threshold_exceeded(_HangupCause, _Stats, 'count') -> 'false'; threshold_exceeded(_HangupCause, _Stats, 'mean') -> 'false'; @@ -199,7 +199,7 @@ is_threshold_exceeded(Value, Threshold, Key) -> Threshold > 0.0 andalso Value > Threshold * folsom_minutes(Key). --spec send_alert(ne_binary()) -> 'ok'. +-spec send_alert(kz_term:ne_binary()) -> 'ok'. send_alert(HangupCause) -> Meter = hangups_util:meter_name(HangupCause), kz_notify:detailed_alert("~s alerted past configured threshold" @@ -213,7 +213,7 @@ folsom_minutes('five') -> 5; folsom_minutes('fifteen') -> 15; folsom_minutes('day') -> 1440. --spec folsom_field(atom()) -> ne_binary(). +-spec folsom_field(atom()) -> kz_term:ne_binary(). folsom_field('one') -> <<"one">>; folsom_field('five') -> <<"five">>; folsom_field('fifteen') -> <<"fifteen">>; diff --git a/applications/hangups/src/hangups_query_listener.erl b/applications/hangups/src/hangups_query_listener.erl index f1c5a2e3d39..f92b7834c07 100644 --- a/applications/hangups/src/hangups_query_listener.erl +++ b/applications/hangups/src/hangups_query_listener.erl @@ -48,7 +48,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'responders', ?RESPONDERS} ,{'bindings', ?BINDINGS} @@ -57,8 +57,8 @@ start_link() -> ,{'consume_options', ?CONSUME_OPTIONS} ], []). --spec handle_query(kz_json:object(), kz_proplist()) -> any(). --spec handle_query(kz_json:object(), ne_binary(), boolean()) -> any(). +-spec handle_query(kz_json:object(), kz_term:proplist()) -> any(). +-spec handle_query(kz_json:object(), kz_term:ne_binary(), boolean()) -> any(). handle_query(JObj, _Props) -> 'true' = kapi_hangups:query_req_v(JObj), AccountId = kz_json:get_value(<<"Account-ID">>, JObj), @@ -73,8 +73,8 @@ handle_query(JObj, N, 'false') -> lager:debug("finding meter stats for '~p'", [N]), publish_resp(JObj, meter_resp(N)). --spec meter_resp(ne_binary()) -> kz_proplist(). --spec meter_resp(ne_binary(), kz_proplist()) -> kz_proplist(). +-spec meter_resp(kz_term:ne_binary()) -> kz_term:proplist(). +-spec meter_resp(kz_term:ne_binary(), kz_term:proplist()) -> kz_term:proplist(). meter_resp(<<"*">>) -> [{<<"meters">>, [kz_json:from_list(meter_resp(Name)) || {Name, _Info} <- folsom_metrics:get_metrics_info() @@ -98,7 +98,7 @@ meter_resp(N, [_|_]=Values) -> ++ Vs ). --spec publish_resp(kz_json:object(), kz_proplist()) -> 'ok'. +-spec publish_resp(kz_json:object(), kz_term:proplist()) -> 'ok'. publish_resp(JObj, Resp) -> Queue = kz_api:server_id(JObj), MsgId = kz_api:msg_id(JObj), @@ -110,13 +110,13 @@ publish_resp(JObj, Resp) -> ,PublishFun ). --spec publish_to(ne_binary(), kz_proplist()) -> 'ok'. +-spec publish_to(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. publish_to(Queue, API) -> kapi_hangups:publish_query_resp(Queue ,kz_api:default_headers(?APP_NAME, ?APP_VERSION) ++ API ). --spec get_accel(kz_proplist()) -> kz_proplist(). +-spec get_accel(kz_term:proplist()) -> kz_term:proplist(). get_accel(AccelVs) -> [{kz_term:to_binary(K), V} || {K, V} <- AccelVs @@ -156,7 +156,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -170,7 +170,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener',{'created_queue',_QueueName}}, State) -> {'noreply', State}; handle_cast({'gen_listener',{'is_consuming',_IsConsuming}}, State) -> @@ -189,7 +189,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> lager:debug("unhandled msg: ~p", [_Info]), {'noreply', State}. @@ -202,7 +202,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/hangups/src/hangups_sup.erl b/applications/hangups/src/hangups_sup.erl index c72107d6c4c..9760ac1b9ea 100644 --- a/applications/hangups/src/hangups_sup.erl +++ b/applications/hangups/src/hangups_sup.erl @@ -34,7 +34,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -51,7 +51,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/hangups/src/hangups_util.erl b/applications/hangups/src/hangups_util.erl index 54ca39a07c2..9a730ef066a 100644 --- a/applications/hangups/src/hangups_util.erl +++ b/applications/hangups/src/hangups_util.erl @@ -21,8 +21,8 @@ -define(METER_PREFIX_LIST, "hangups"). -define(METER_PREFIX, <>). --spec meter_name(ne_binary()) -> ne_binary(). --spec meter_name(ne_binary(), api_binary()) -> ne_binary(). +-spec meter_name(kz_term:ne_binary()) -> kz_term:ne_binary(). +-spec meter_name(kz_term:ne_binary(), kz_term:api_binary()) -> kz_term:ne_binary(). meter_name(<<"*">>) -> <<"*">>; meter_name(HangupCause) -> <>. @@ -31,18 +31,18 @@ meter_name(HangupCause, 'undefined') -> meter_name(HangupCause, AccountId) -> <>. --spec meter_prefix() -> ne_binary(). +-spec meter_prefix() -> kz_term:ne_binary(). meter_prefix() -> ?METER_PREFIX. --spec meter_account_id(ne_binary()) -> api_binary(). +-spec meter_account_id(kz_term:ne_binary()) -> kz_term:api_binary(). meter_account_id(Name) -> case binary:split(Name, <<".">>, ['global']) of [?METER_PREFIX, _HC, AccountId] -> AccountId; _ -> 'undefined' end. --spec meter_hangup_cause(ne_binary()) -> api_binary(). +-spec meter_hangup_cause(kz_term:ne_binary()) -> kz_term:api_binary(). meter_hangup_cause(Name) -> case binary:split(Name, <<".">>, ['global']) of [?METER_PREFIX, HangupCause, _AccountId] -> HangupCause; @@ -50,11 +50,11 @@ meter_hangup_cause(Name) -> _ -> 'undefined' end. --spec is_hangup_meter(ne_binary()) -> boolean(). +-spec is_hangup_meter(kz_term:ne_binary()) -> boolean(). is_hangup_meter(<>) -> 'true'; is_hangup_meter(_) -> 'false'. --spec is_hangup_meter(ne_binary(), ne_binary()) -> boolean(). +-spec is_hangup_meter(kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_hangup_meter(Name, HangupCause) -> Size = byte_size(HangupCause), case Name of @@ -63,7 +63,7 @@ is_hangup_meter(Name, HangupCause) -> _ -> 'false' end. --spec is_hangup_meter(ne_binary(), ne_binary(), ne_binary()) -> boolean(). +-spec is_hangup_meter(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_hangup_meter(Name, <<"*">>, AccountId) -> case binary:split(Name, <<".">>, ['global']) of [?METER_PREFIX, _HC, AccountId] -> 'true'; diff --git a/applications/hotornot/src/hon_rater.erl b/applications/hotornot/src/hon_rater.erl index abc3c64b944..b2b00bc5941 100644 --- a/applications/hotornot/src/hon_rater.erl +++ b/applications/hotornot/src/hon_rater.erl @@ -19,7 +19,7 @@ init() -> ], 'ok'. --spec handle_req(kapi_rate:req(), kz_proplist()) -> 'ok'. +-spec handle_req(kapi_rate:req(), kz_term:proplist()) -> 'ok'. handle_req(RateReq, _Props) -> 'true' = kapi_rate:req_v(RateReq), _ = kz_util:put_callid(RateReq), @@ -58,8 +58,8 @@ maybe_empty_mobile_log(RateReq) -> _ -> "" end. --spec get_rate_data(kapi_rate:req(), api_ne_binary()) -> - {'ok', api_terms()} | +-spec get_rate_data(kapi_rate:req(), kz_term:api_ne_binary()) -> + {'ok', kz_term:api_terms()} | {'error', 'no_rate_found'}. get_rate_data(RateReq, <<"mobile">>) -> ToDID = kz_json:get_value(<<"To-DID">>, RateReq), @@ -93,8 +93,8 @@ get_rate_data(RateReq, _AuthType) -> get_rate_data(RateReq, ToDID, FromDID, Rates) end. --spec get_rate_data(kapi_rate:req(), ne_binary(), api_binary(), kz_json:objects()) -> - {'ok', api_terms()} | +-spec get_rate_data(kapi_rate:req(), kz_term:ne_binary(), kz_term:api_binary(), kz_json:objects()) -> + {'ok', kz_term:api_terms()} | {'error', 'no_rate_found'}. get_rate_data(RateReq, ToDID, FromDID, Rates) -> lager:debug("candidate rates found, filtering"), @@ -119,8 +119,8 @@ get_rate_data_from_sorted(RateReq, _ToDID, _FromDID, [Rate|_]) -> ), {'ok', rate_resp(Rate, RateReq)}. --spec maybe_get_rate_discount(kapi_rate:req()) -> api_binary(). --spec maybe_get_rate_discount(kapi_rate:req(), api_binary()) -> api_binary(). +-spec maybe_get_rate_discount(kapi_rate:req()) -> kz_term:api_binary(). +-spec maybe_get_rate_discount(kapi_rate:req(), kz_term:api_binary()) -> kz_term:api_binary(). maybe_get_rate_discount(RateReq) -> maybe_get_rate_discount(RateReq, kz_json:get_value(<<"Account-ID">>, RateReq)). @@ -138,7 +138,7 @@ maybe_get_rate_discount(RateReq, AccountId) -> kz_json:get_value([<<"pvt_discounts">>, Classification, <<"percentage">>], Def) end. --spec rate_resp(kz_json:object(), kapi_rate:req()) -> kz_proplist(). +-spec rate_resp(kz_json:object(), kapi_rate:req()) -> kz_term:proplist(). rate_resp(Rate, RateReq) -> RateCost = kzd_rate:rate_cost(Rate), RateSurcharge = kzd_rate:surcharge(Rate), @@ -168,7 +168,7 @@ rate_resp(Rate, RateReq) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]. --spec should_update_callee_id(ne_binary() | kapi_rate:req()) -> boolean(). +-spec should_update_callee_id(kz_term:ne_binary() | kapi_rate:req()) -> boolean(). should_update_callee_id(?NE_BINARY = AccountId) -> case kz_account:fetch(AccountId) of {'ok', AccountDoc} -> diff --git a/applications/hotornot/src/hon_trie.erl b/applications/hotornot/src/hon_trie.erl index 5950d289b2a..3ae804af1cf 100644 --- a/applications/hotornot/src/hon_trie.erl +++ b/applications/hotornot/src/hon_trie.erl @@ -44,10 +44,10 @@ -define(STATE_READY(Trie, RatedeckDb), {'ready', Trie, RatedeckDb}). -define(STATE_BUILDING(Trie, RatedeckDb, PidRef), {'building', Trie, RatedeckDb, PidRef}). --type state() :: ?STATE_READY(trie:trie(), ne_binary()) | - ?STATE_BUILDING(trie:trie() | 'undefined', ne_binary(), pid_ref()). +-type state() :: ?STATE_READY(trie:trie(), kz_term:ne_binary()) | + ?STATE_BUILDING(trie:trie() | 'undefined', kz_term:ne_binary(), kz_term:pid_ref()). --spec start_link(ne_binary()) -> {'ok', pid()}. +-spec start_link(kz_term:ne_binary()) -> {'ok', pid()}. start_link(RatedeckDb) -> case hotornot_config:trie_module() of ?MODULE -> @@ -57,7 +57,7 @@ start_link(RatedeckDb) -> hon_trie_lru:start_link(RatedeckDb) end. --spec trie_proc_name(ne_binary()) -> atom(). +-spec trie_proc_name(kz_term:ne_binary()) -> atom(). trie_proc_name(Ratedeck) -> RatedeckDb = kzd_ratedeck:format_ratedeck_db(Ratedeck), kz_term:to_atom(<<"hon_trie_", RatedeckDb/binary>>, 'true'). @@ -75,8 +75,8 @@ match_did(ToDID, _AccountId, RatedeckId) -> end. -else. --spec match_did(ne_binary(), api_ne_binary()) -> match_return(). --spec match_did(ne_binary(), api_ne_binary(), api_ne_binary()) -> match_return(). +-spec match_did(kz_term:ne_binary(), kz_term:api_ne_binary()) -> match_return(). +-spec match_did(kz_term:ne_binary(), kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> match_return(). match_did(ToDID, AccountId) -> match_did(ToDID, AccountId, 'undefined'). @@ -89,12 +89,12 @@ match_did(ToDID, AccountId, RatedeckId) -> {'ok', {_Prefix, RateIds}} -> load_rates(Ratedeck, RateIds) end. --spec load_rates(ne_binary(), ne_binaries()) -> {'ok', kzd_rate:docs()}. +-spec load_rates(kz_term:ne_binary(), kz_term:ne_binaries()) -> {'ok', kzd_rate:docs()}. load_rates(Ratedeck, RateIds) -> RatedeckDb = kzd_ratedeck:format_ratedeck_db(Ratedeck), {'ok', lists:foldl(fun(R, Acc) -> load_rate(R, Acc, RatedeckDb) end, [], RateIds)}. --spec load_rate(ne_binary(), kz_json:objects(), ne_binary()) -> kzd_rate:docs(). +-spec load_rate(kz_term:ne_binary(), kz_json:objects(), kz_term:ne_binary()) -> kzd_rate:docs(). load_rate(RateId, Acc, RatedeckDb) -> case kz_datamgr:open_cache_doc(RatedeckDb, RateId) of {'error', _} -> Acc; @@ -115,20 +115,20 @@ rebuild() -> {'error', E} end. --spec init([ne_binary()]) -> {'ok', state()}. +-spec init([kz_term:ne_binary()]) -> {'ok', state()}. init([RatedeckDb]) -> kz_util:put_callid(trie_proc_name(RatedeckDb)), PidRef = start_builder(RatedeckDb), lager:debug("building trie for ~s in ~p", [RatedeckDb, PidRef]), {'ok', ?STATE_BUILDING('undefined', RatedeckDb, PidRef)}. --spec start_builder(ne_binary()) -> pid_ref(). +-spec start_builder(kz_term:ne_binary()) -> kz_term:pid_ref(). start_builder(RatedeckDb) -> PidRef = spawn_monitor(?MODULE, 'build_trie', [self(), RatedeckDb]), _ = erlang:send_after(hotornot_config:trie_build_timeout_ms(), self(), {'build_timeout', PidRef}), PidRef. --spec handle_call(any(), pid_ref(), state()) -> +-spec handle_call(any(), kz_term:pid_ref(), state()) -> {'noreply', state()} | {'reply', match_return(), state()}. handle_call({'match_did', _DID}, _From, ?STATE_BUILDING('undefined', _RatedeckDb, _PidRef)=State) -> @@ -196,7 +196,7 @@ terminate(_Reason, ?STATE_READY(_, _)) -> code_change(_Vsn, State, _Extra) -> {'ok', State}. --spec handle_db_update(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_db_update(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_db_update(ConfUpdate, _Props) -> 'true' = kapi_conf:doc_update_v(ConfUpdate), @@ -210,7 +210,7 @@ process_conf_update(ConfUpdate, <<"database">>) -> process_conf_update(_ConfUpdate, _Type) -> lager:debug("ignoring conf update to ~s: ~p", [_Type, _ConfUpdate]). --spec process_db_update(ne_binary(), ne_binary()) -> 'ok'. +-spec process_db_update(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. process_db_update(?KZ_RATES_DB=RatedeckId, ?DB_EDITED) -> {'ok', Pid} = gen_server:call(trie_proc_name(RatedeckId), 'rebuild'), lager:info("ratedeck ~s changed, rebuilding trie in ~p", [Pid]); @@ -230,7 +230,7 @@ process_db_update(?MATCH_RATEDECK_DB_ENCODED(_)=RatedeckDb, ?DB_DELETED) -> process_db_update(_Db, _Action) -> lager:debug("ignoring ~s: ~s", [_Db, _Action]). --spec maybe_start_trie_server(ne_binary()) -> 'ok'. +-spec maybe_start_trie_server(kz_term:ne_binary()) -> 'ok'. maybe_start_trie_server(RatedeckDb) -> case hon_tries_sup:start_trie(RatedeckDb) of {'ok', Pid} -> @@ -244,13 +244,13 @@ maybe_start_trie_server(RatedeckDb) -> lager:debug("failed to start trie for ~s: ~p", [RatedeckDb, _E]) end. --spec build_trie(pid(), ne_binary()) -> 'ok'. +-spec build_trie(pid(), kz_term:ne_binary()) -> 'ok'. build_trie(Server, Database) -> build_trie(Server, Database, trie:new(), fetch_rates(Database, 0)). -define(LIMIT, 5000). --spec build_trie(pid(), ne_binary(), trie:trie(), kazoo_data:get_results_return()) -> +-spec build_trie(pid(), kz_term:ne_binary(), trie:trie(), kazoo_data:get_results_return()) -> 'ok'. build_trie(Server, _Database, Trie, {'ok', []}) -> gen_server:cast(Server, ?BUILT_TRIE(self(), Trie)); @@ -279,7 +279,7 @@ add_result(Result, Trie) -> Prefix = kz_term:to_list(kz_json:get_value(<<"key">>, Result)), trie:append(Prefix, Id, Trie). --spec fetch_rates(ne_binary(), non_neg_integer()) -> +-spec fetch_rates(kz_term:ne_binary(), non_neg_integer()) -> kazoo_data:get_results_return(). fetch_rates(Database, StartKey) -> Options = props:filter_undefined([{'startkey', StartKey} diff --git a/applications/hotornot/src/hon_trie_lru.erl b/applications/hotornot/src/hon_trie_lru.erl index a7a87316282..9a2095d6a54 100644 --- a/applications/hotornot/src/hon_trie_lru.erl +++ b/applications/hotornot/src/hon_trie_lru.erl @@ -38,12 +38,12 @@ -define(CHECK_MSG(ExpiresS), {'check_trie', ExpiresS}). --type state() :: ?STATE_READY(trie:trie(), ne_binary(), reference()). --type rate_entry() :: {ne_binary(), gregorian_seconds()}. +-type state() :: ?STATE_READY(trie:trie(), kz_term:ne_binary(), reference()). +-type rate_entry() :: {kz_term:ne_binary(), kz_time:gregorian_seconds()}. -type rate_entries() :: [rate_entry()]. --spec start_link(ne_binary()) -> {'ok', pid()}. --spec start_link(ne_binary(), pos_integer()) -> {'ok', pid()}. +-spec start_link(kz_term:ne_binary()) -> {'ok', pid()}. +-spec start_link(kz_term:ne_binary(), pos_integer()) -> {'ok', pid()}. start_link(RatedeckDb) -> start_link(RatedeckDb, hotornot_config:lru_expires_s()). @@ -51,7 +51,7 @@ start_link(RatedeckDb, ExpiresS) -> ProcName = hon_trie:trie_proc_name(RatedeckDb), gen_server:start_link({'local', ProcName}, ?MODULE, [RatedeckDb, ExpiresS], []). --spec stop(ne_binary()) -> 'ok'. +-spec stop(kz_term:ne_binary()) -> 'ok'. stop(<<_/binary>>=RatedeckId) -> ProcName = hon_trie:trie_proc_name(RatedeckId), case whereis(ProcName) of @@ -59,12 +59,12 @@ stop(<<_/binary>>=RatedeckId) -> Pid -> catch gen_server:call(Pid, 'stop') end. --spec cache_rates(ne_binary(), kzd_rate:docs()) -> 'ok'. +-spec cache_rates(kz_term:ne_binary(), kzd_rate:docs()) -> 'ok'. cache_rates(RatedeckId, Rates) -> ProcName = hon_trie:trie_proc_name(RatedeckId), gen_server:call(ProcName, {'cache_rates', Rates}). --spec init([ne_binary() | pos_integer()]) -> {'ok', state()}. +-spec init([kz_term:ne_binary() | pos_integer()]) -> {'ok', state()}. init([RatedeckDb, ExpiresS]) -> kz_util:put_callid(hon_trie:trie_proc_name(RatedeckDb)), lager:info("starting LRU for ~s", [RatedeckDb]), @@ -80,7 +80,7 @@ start_expires_check_timer(ExpiresS) -> erlang:start_timer(Check, self(), ?CHECK_MSG(ExpiresS)). -endif. --spec handle_call(any(), pid_ref(), state()) -> +-spec handle_call(any(), kz_term:pid_ref(), state()) -> {'noreply', state()} | {'reply', match_return(), state()}. handle_call({'match_did', DID}, _From, ?STATE_READY(Trie, RatedeckDb, CheckRef)) -> @@ -120,7 +120,7 @@ check_expired_entries(Trie, ExpiresS) -> ), UpdatedTrie. --spec check_if_expired(prefix(), [{ne_binary(), pos_integer()}], {pid(), pos_integer()}) -> +-spec check_if_expired(prefix(), [{kz_term:ne_binary(), pos_integer()}], {pid(), pos_integer()}) -> {pid(), pos_integer()}. check_if_expired(Prefix, Rates, {Trie, OldestTimestamp}=Acc) -> case expired_rates(Rates, OldestTimestamp) of @@ -129,8 +129,8 @@ check_if_expired(Prefix, Rates, {Trie, OldestTimestamp}=Acc) -> {trie:erase(Prefix, Trie), OldestTimestamp} end. --spec expired_rates([{ne_binary(), pos_integer()}], pos_integer()) -> - [] | [{ne_binary(), pos_integer()}]. +-spec expired_rates([{kz_term:ne_binary(), pos_integer()}], pos_integer()) -> + [] | [{kz_term:ne_binary(), pos_integer()}]. expired_rates(Rates, OldestTimestamp) -> [RateId || {RateId, LastUsed} <- Rates, diff --git a/applications/hotornot/src/hon_tries_sup.erl b/applications/hotornot/src/hon_tries_sup.erl index 254326436a3..ffa45f009a3 100644 --- a/applications/hotornot/src/hon_tries_sup.erl +++ b/applications/hotornot/src/hon_tries_sup.erl @@ -32,21 +32,21 @@ %% API functions %% =================================================================== --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec start_trie(ne_binary()) -> startlink_ret(). +-spec start_trie(kz_term:ne_binary()) -> kz_types:startlink_ret(). start_trie(Ratedeck) -> RatedeckDb = kzd_ratedeck:format_ratedeck_db(Ratedeck), supervisor:start_child(?SERVER, ?WORKER_NAME_ARGS('hon_trie', RatedeckDb, [RatedeckDb])). --spec restart_trie(ne_binary()) -> startlink_ret(). +-spec restart_trie(kz_term:ne_binary()) -> kz_types:startlink_ret(). restart_trie(Ratedeck) -> RatedeckDb = kzd_ratedeck:format_ratedeck_db(Ratedeck), supervisor:restart_child(?SERVER, RatedeckDb). --spec stop_trie(server_ref()) -> 'ok' | {'error', any()}. +-spec stop_trie(kz_types:server_ref()) -> 'ok' | {'error', any()}. stop_trie(Pid) when is_pid(Pid) -> case [Id || {Id, P, _, _} <- supervisor:which_children(?SERVER), Pid =:= P @@ -79,7 +79,7 @@ upgrade() -> %% =================================================================== %% Supervisor callbacks %% =================================================================== --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), diff --git a/applications/hotornot/src/hon_util.erl b/applications/hotornot/src/hon_util.erl index 38d2dacfada..86117b65cb5 100644 --- a/applications/hotornot/src/hon_util.erl +++ b/applications/hotornot/src/hon_util.erl @@ -26,11 +26,11 @@ {'error', 'did_to_short'} | kz_datamgr:data_error(). --spec candidate_rates(ne_binary()) -> +-spec candidate_rates(kz_term:ne_binary()) -> candidate_rates_return(). --spec candidate_rates(ne_binary(), api_ne_binary()) -> +-spec candidate_rates(kz_term:ne_binary(), kz_term:api_ne_binary()) -> candidate_rates_return(). --spec candidate_rates(ne_binary(), api_ne_binary(), api_ne_binary()) -> +-spec candidate_rates(kz_term:ne_binary(), kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> candidate_rates_return(). candidate_rates(ToDID) -> candidate_rates(ToDID, 'undefined', 'undefined'). @@ -42,7 +42,7 @@ candidate_rates(ToDID, AccountId, RatedeckId) -> E164 = knm_converters:normalize(ToDID), find_candidate_rates(E164, AccountId, RatedeckId). --spec find_candidate_rates(ne_binary(), api_ne_binary(), api_ne_binary()) -> +-spec find_candidate_rates(kz_term:ne_binary(), kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> candidate_rates_return(). find_candidate_rates(E164, AccountId, RatedeckId) when byte_size(E164) > ?MIN_PREFIX_LEN -> @@ -54,7 +54,7 @@ find_candidate_rates(DID, _AccountId, _RatedeckId) -> lager:debug("DID ~s is too short", [DID]), {'error', 'did_too_short'}. --spec find_trie_rates(ne_binary(), api_ne_binary(), api_ne_binary()) -> +-spec find_trie_rates(kz_term:ne_binary(), kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> candidate_rates_return(). find_trie_rates(E164, AccountId, RatedeckId) -> case hon_trie:match_did(only_numeric(E164), AccountId, RatedeckId) of @@ -66,8 +66,8 @@ find_trie_rates(E164, AccountId, RatedeckId) -> Candidates end. --spec maybe_update_trie(ne_binary(), candidate_rates_return()) -> 'ok'. --spec maybe_update_trie(ne_binary(), candidate_rates_return(), atom()) -> 'ok'. +-spec maybe_update_trie(kz_term:ne_binary(), candidate_rates_return()) -> 'ok'. +-spec maybe_update_trie(kz_term:ne_binary(), candidate_rates_return(), atom()) -> 'ok'. maybe_update_trie(RatedeckId, Candidates) -> maybe_update_trie(RatedeckId, Candidates, hotornot_config:trie_module()). maybe_update_trie(RatedeckId, {'ok', [_|_]=Rates}, 'hon_trie_lru') -> @@ -75,9 +75,9 @@ maybe_update_trie(RatedeckId, {'ok', [_|_]=Rates}, 'hon_trie_lru') -> maybe_update_trie(_RatedeckId, _Candidates, _Module) -> 'ok'. --spec fetch_candidate_rates(ne_binary(), api_ne_binary(), api_ne_binary()) -> +-spec fetch_candidate_rates(kz_term:ne_binary(), kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> candidate_rates_return(). --spec fetch_candidate_rates(ne_binary(), api_ne_binary(), api_ne_binary(), ne_binaries()) -> +-spec fetch_candidate_rates(kz_term:ne_binary(), kz_term:api_ne_binary(), kz_term:api_ne_binary(), kz_term:ne_binaries()) -> candidate_rates_return(). fetch_candidate_rates(E164, AccountId, RatedeckId) -> fetch_candidate_rates(E164, AccountId, RatedeckId, build_keys(E164)). @@ -100,7 +100,7 @@ fetch_candidate_rates(E164, AccountId, RatedeckId, Keys) -> } end. --spec fetch_rates_from_ratedeck(ne_binary(), [integer()]) -> +-spec fetch_rates_from_ratedeck(kz_term:ne_binary(), [integer()]) -> kz_datamgr:get_results_return(). fetch_rates_from_ratedeck(RatedeckDb, Keys) -> kz_datamgr:get_results(RatedeckDb @@ -110,8 +110,8 @@ fetch_rates_from_ratedeck(RatedeckDb, Keys) -> ] ). --spec account_ratedeck(api_ne_binary()) -> ne_binary(). --spec account_ratedeck(api_ne_binary(), api_ne_binary()) -> ne_binary(). +-spec account_ratedeck(kz_term:api_ne_binary()) -> kz_term:ne_binary(). +-spec account_ratedeck(kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> kz_term:ne_binary(). -ifdef(TEST). account_ratedeck(_AccountId) -> ?KZ_RATES_DB. @@ -136,7 +136,7 @@ account_ratedeck(AccountId, _RatedeckId) -> kzd_ratedeck:format_ratedeck_db(RatedeckId) end. --spec reseller_ratedeck(ne_binary(), api_ne_binary()) -> ne_binary(). +-spec reseller_ratedeck(kz_term:ne_binary(), kz_term:api_ne_binary()) -> kz_term:ne_binary(). reseller_ratedeck(_AccountId, 'undefined') -> lager:debug("no reseller for ~s, using default ratedeck", [_AccountId]), hotornot_config:default_ratedeck(); @@ -156,7 +156,7 @@ reseller_ratedeck(_AccountId, ResellerId) -> end. -endif. --spec build_keys(ne_binary()) -> [integer()]. +-spec build_keys(kz_term:ne_binary()) -> [integer()]. build_keys(Number) -> case only_numeric(Number) of <<>> -> []; @@ -173,7 +173,7 @@ is_numeric(N) -> N >= $0 andalso N =< $9. --spec build_keys(binary(), ne_binary(), [integer()]) -> [integer()]. +-spec build_keys(binary(), kz_term:ne_binary(), [integer()]) -> [integer()]. build_keys(<>, Prefix, Acc) -> build_keys(Rest, <>, [kz_term:to_integer(<>) | Acc]); build_keys(<<>>, _, Acc) -> Acc. @@ -198,7 +198,7 @@ sort_rates(Rates) -> %% Private helper functions --spec matching_rate(kzd_rate:doc(), ne_binary(), kapi_rate:req()) -> boolean(). +-spec matching_rate(kzd_rate:doc(), kz_term:ne_binary(), kapi_rate:req()) -> boolean(). matching_rate(Rate, <<"direction">>, RateReq) -> case kz_json:get_value(<<"Direction">>, RateReq) of 'undefined' -> 'true'; @@ -277,7 +277,7 @@ options_match(RateOptions, RouteOptions) -> ,RouteOptions ). --spec maybe_add_resource_flag(kapi_rate:req(), ne_binary()) -> ne_binaries(). +-spec maybe_add_resource_flag(kapi_rate:req(), kz_term:ne_binary()) -> kz_term:ne_binaries(). maybe_add_resource_flag(RateReq, AccountId) -> case hotornot_config:should_account_filter_by_resource(AccountId) of 'true' -> diff --git a/applications/hotornot/src/hotornot.hrl b/applications/hotornot/src/hotornot.hrl index 401ce59c062..117c84fb6fe 100644 --- a/applications/hotornot/src/hotornot.hrl +++ b/applications/hotornot/src/hotornot.hrl @@ -11,10 +11,10 @@ -define(CACHE_NAME, 'hotornot_cache'). --type trunking_options() :: ne_binaries(). +-type trunking_options() :: kz_term:ne_binaries(). -type prefix() :: string(). -type match_return() :: {'error', any()} | - {'ok', {prefix(), ne_binaries()}}. + {'ok', {prefix(), kz_term:ne_binaries()}}. -define(HOTORNOT_HRL, 'true'). -endif. diff --git a/applications/hotornot/src/hotornot_app.erl b/applications/hotornot/src/hotornot_app.erl index 07ccd5c3623..12dfdafd3f5 100644 --- a/applications/hotornot/src/hotornot_app.erl +++ b/applications/hotornot/src/hotornot_app.erl @@ -22,7 +22,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_StartType, _StartArgs) -> _ = declare_exchanges(), hotornot_sup:start_link(). diff --git a/applications/hotornot/src/hotornot_config.erl b/applications/hotornot/src/hotornot_config.erl index 03b252e142e..685cd21750e 100644 --- a/applications/hotornot/src/hotornot_config.erl +++ b/applications/hotornot/src/hotornot_config.erl @@ -51,22 +51,22 @@ default_cost() -> default_internal_cost() -> kapps_config:get_float(?APP_NAME, <<"default_rate_internal_cost">>, 0.0). --spec filter_list() -> ne_binaries(). +-spec filter_list() -> kz_term:ne_binaries(). filter_list() -> kapps_config:get(?APP_NAME, <<"filter_list">>, [<<"direction">> ,<<"route_options">> ,<<"routes">> ]). --spec default_ratedeck() -> ne_binary(). +-spec default_ratedeck() -> kz_term:ne_binary(). default_ratedeck() -> kapps_config:get_ne_binary(?APP_NAME, <<"default_ratedeck">>, ?KZ_RATES_DB). --spec mobile_rate() -> api_object(). +-spec mobile_rate() -> kz_term:api_object(). mobile_rate() -> kapps_config:get_json(?APP_NAME, <<"mobile_rate">>). --spec ratedecks() -> ne_binaries(). +-spec ratedecks() -> kz_term:ne_binaries(). ratedecks() -> {'ok', Dbs} = kz_datamgr:db_list([{'startkey', ?KZ_RATES_DB} ,{'endkey', ?UNENCODED_RATEDECK_DB(<<"\ufff0">>)} @@ -108,16 +108,16 @@ trie_module() -> trie_build_timeout_ms() -> kapps_config:get_integer(?APP_NAME, <<"trie_build_timeout_ms">>, ?MILLISECONDS_IN_MINUTE). --spec rate_version() -> api_ne_binary(). +-spec rate_version() -> kz_term:api_ne_binary(). rate_version() -> kapps_config:get_ne_binary(?APP_NAME, <<"rate_version">>). --spec set_rate_version(ne_binary()) -> 'ok'. +-spec set_rate_version(kz_term:ne_binary()) -> 'ok'. set_rate_version(Version) -> kapps_config:set_string(?APP_NAME, <<"rate_version">>, Version), 'ok'. --spec should_account_filter_by_resource(ne_binary()) -> boolean(). +-spec should_account_filter_by_resource(kz_term:ne_binary()) -> boolean(). should_account_filter_by_resource(AccountId) -> kapps_account_config:get_from_reseller(AccountId, ?APP_NAME, <<"filter_by_resource_id">>, 'false'). diff --git a/applications/hotornot/src/hotornot_listener.erl b/applications/hotornot/src/hotornot_listener.erl index 3298ab45e90..2545ee240c5 100644 --- a/applications/hotornot/src/hotornot_listener.erl +++ b/applications/hotornot/src/hotornot_listener.erl @@ -47,7 +47,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> case hotornot_config:should_use_trie() of 'false' -> @@ -98,7 +98,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -112,7 +112,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _QueueName}}, State) -> {'noreply', State}; handle_cast({'gen_listener',{'is_consuming',_IsConsuming}}, State) -> @@ -133,7 +133,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> lager:debug("unhandled message: ~p", [_Info]), {'noreply', State}. @@ -146,7 +146,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Props} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/hotornot/src/hotornot_maintenance.erl b/applications/hotornot/src/hotornot_maintenance.erl index 43b435e73a0..ec735f6d14b 100644 --- a/applications/hotornot/src/hotornot_maintenance.erl +++ b/applications/hotornot/src/hotornot_maintenance.erl @@ -55,10 +55,10 @@ wait_for_rebuild(Pid, Ref) -> io:format("trie failed to build in ~p under ~p ms~n", [Pid, Timeout]) end. --spec rates_for_did(ne_binary()) -> 'ok'. --spec rates_for_did(ne_binary(), ne_binary()) -> 'ok'. --spec rates_for_did(ne_binary(), api_ne_binary(), trunking_options()) -> 'ok'. --spec rates_for_did(ne_binary(), api_ne_binary(), api_ne_binary(), trunking_options()) -> 'ok'. +-spec rates_for_did(kz_term:ne_binary()) -> 'ok'. +-spec rates_for_did(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. +-spec rates_for_did(kz_term:ne_binary(), kz_term:api_ne_binary(), trunking_options()) -> 'ok'. +-spec rates_for_did(kz_term:ne_binary(), kz_term:api_ne_binary(), kz_term:api_ne_binary(), trunking_options()) -> 'ok'. rates_for_did(DID) -> rates_for_did(DID, 'undefined', 'undefined', []). rates_for_did(DID, AccountId) -> @@ -99,7 +99,7 @@ print_matching(Matching) -> | Sorted ]). --spec rates_between(ne_binary(), ne_binary()) -> 'ok'. +-spec rates_between(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. rates_between(Pre, Post) -> ViewOpts = [{'startkey', kz_term:to_binary(Pre)} ,{'endkey', kz_term:to_binary(Post)} @@ -128,9 +128,9 @@ print_rate(Rate) -> ,kz_term:to_binary(kzd_rate:version(Rate, <<>>)) ]). --spec get_rate_version() -> api_binary(). +-spec get_rate_version() -> kz_term:api_binary(). get_rate_version() -> hotornot_config:rate_version(). --spec set_rate_version(ne_binary()) -> 'ok'. +-spec set_rate_version(kz_term:ne_binary()) -> 'ok'. set_rate_version(Version) -> hotornot_config:set_rate_version(Version). diff --git a/applications/hotornot/src/hotornot_sup.erl b/applications/hotornot/src/hotornot_sup.erl index f6dbc4303a1..d95d52f6485 100644 --- a/applications/hotornot/src/hotornot_sup.erl +++ b/applications/hotornot/src/hotornot_sup.erl @@ -28,7 +28,7 @@ %% API functions %% =================================================================== --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -52,7 +52,7 @@ upgrade() -> %% =================================================================== %% Supervisor callbacks %% =================================================================== --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), diff --git a/applications/hotornot/test/hon_trie_lru_pqc.erl b/applications/hotornot/test/hon_trie_lru_pqc.erl index 69f6f91d7e6..9878406eb5a 100644 --- a/applications/hotornot/test/hon_trie_lru_pqc.erl +++ b/applications/hotornot/test/hon_trie_lru_pqc.erl @@ -85,7 +85,7 @@ correct_parallel() -> ) ). --type cache() :: [{ne_binary(), {ne_binary(), gregorian_seconds()}}]. +-type cache() :: [{kz_term:ne_binary(), {kz_term:ne_binary(), kz_time:gregorian_seconds()}}]. initial_state() -> #model{}. diff --git a/applications/jonny5/src/j5_allotments.erl b/applications/jonny5/src/j5_allotments.erl index 4068b1be3c4..2ce70a06131 100644 --- a/applications/jonny5/src/j5_allotments.erl +++ b/applications/jonny5/src/j5_allotments.erl @@ -23,7 +23,7 @@ authorize(Request, Limits) -> Allotment = find_allotment(Request, Limits), maybe_consume_allotment(Allotment, Request, Limits). --spec maybe_consume_allotment(api_object(), j5_request:request(), j5_limits:limits()) -> j5_request:request(). +-spec maybe_consume_allotment(kz_term:api_object(), j5_request:request(), j5_limits:limits()) -> j5_request:request(). maybe_consume_allotment('undefined', Request, _) -> lager:debug("account has no allotment", []), Request; @@ -53,7 +53,7 @@ maybe_consume_allotment(Allotment, Request, Limits) -> j5_request:authorize(<<"allotment_", Classification/binary>>, Request, Limits) end. --spec maybe_group_consumed(binaries(), kz_json:object(), j5_limits:limits(), non_neg_integer()) -> non_neg_integer(). +-spec maybe_group_consumed(kz_term:binaries(), kz_json:object(), j5_limits:limits(), non_neg_integer()) -> non_neg_integer(). maybe_group_consumed([], _Allotment, _Limits, Acc) -> Acc; maybe_group_consumed([Member|Group], Allotment, Limits, Acc) when is_binary(Member) -> NewAllotment = kz_json:set_value(<<"classification">>, Member, Allotment), @@ -132,7 +132,7 @@ reconcile_allotment(Seconds, Allotment, Request, Limits) -> %% %% @end %%-------------------------------------------------------------------- --spec find_allotment(j5_request:request(), j5_limits:limits()) -> api_object(). +-spec find_allotment(j5_request:request(), j5_limits:limits()) -> kz_term:api_object(). find_allotment(Request, Limits) -> case j5_request:classification(Request) of 'undefined' -> 'undefined'; @@ -141,7 +141,7 @@ find_allotment(Request, Limits) -> find_allotment_by_classification(Direction, Classification, Limits) end. --spec find_allotment_by_classification(ne_binary(), ne_binary(), j5_limits:limits()) -> api_object(). +-spec find_allotment_by_classification(kz_term:ne_binary(), kz_term:ne_binary(), j5_limits:limits()) -> kz_term:api_object(). find_allotment_by_classification(Direction, Classification, Limits) -> DirectionalClassification = <>, case find_allotment_by_classification(DirectionalClassification, Limits) of @@ -150,7 +150,7 @@ find_allotment_by_classification(Direction, Classification, Limits) -> Allotment -> Allotment end. --spec find_allotment_by_classification(ne_binary(), j5_limits:limits()) -> api_object(). +-spec find_allotment_by_classification(kz_term:ne_binary(), j5_limits:limits()) -> kz_term:api_object(). find_allotment_by_classification(Classification, Limits) -> Allotments = j5_limits:allotments(Limits), lager:debug("checking if account ~s has any allotments for ~s" @@ -182,7 +182,7 @@ allotment_consumed_so_far(Allotment, Limits) -> Consumed + j5_channels:allotment_consumed(CycleStart, CycleSpan, Classification, Limits) end. --spec allotment_consumed_so_far(non_neg_integer(), non_neg_integer(), ne_binary(), j5_limits:limits(), 0..3) -> +-spec allotment_consumed_so_far(non_neg_integer(), non_neg_integer(), kz_term:ne_binary(), j5_limits:limits(), 0..3) -> integer() | {'error', any()}. allotment_consumed_so_far(_, _, _, _, Attempts) when Attempts > 2 -> 0; @@ -220,7 +220,7 @@ sum_allotment_consumed_so_far([JObj|JObjs], CycleStart, Seconds) -> sum_allotment_consumed_so_far(JObjs, CycleStart, Seconds + (Timestamp - CycleStart)) end. --spec add_transactions_view(ne_binary(), non_neg_integer(), non_neg_integer(), ne_binary(), j5_limits:limits(), 0..3) -> +-spec add_transactions_view(kz_term:ne_binary(), non_neg_integer(), non_neg_integer(), kz_term:ne_binary(), j5_limits:limits(), 0..3) -> integer() | {'error', any()}. add_transactions_view(LedgerDb, CycleStart, CycleEnd, Classification, Limits, Attempts) -> @@ -233,7 +233,7 @@ add_transactions_view(LedgerDb, CycleStart, CycleEnd, Classification, Limits, At %% %% @end %%-------------------------------------------------------------------- --spec cycle_start(ne_binary()) -> integer(). +-spec cycle_start(kz_term:ne_binary()) -> integer(). cycle_start(<<"monthly">>) -> {{Year, Month, _}, _} = calendar:universal_time(), calendar:datetime_to_gregorian_seconds({{Year, Month, 1}, {0, 0, 0}}); @@ -251,7 +251,7 @@ cycle_start(<<"minutely">>) -> {{Year, Month, Day}, {Hour, Min, _}} = calendar:universal_time(), calendar:datetime_to_gregorian_seconds({{Year, Month, Day}, {Hour, Min, 0}}). --spec cycle_span(ne_binary()) -> integer(). +-spec cycle_span(kz_term:ne_binary()) -> integer(). cycle_span(<<"monthly">>) -> 2629743; % avg days in month cycle_span(<<"weekly">>) -> ?SECONDS_IN_WEEK; cycle_span(<<"daily">>) -> ?SECONDS_IN_DAY; diff --git a/applications/jonny5/src/j5_authz_req.erl b/applications/jonny5/src/j5_authz_req.erl index f788aaf0b86..50c49a24d03 100644 --- a/applications/jonny5/src/j5_authz_req.erl +++ b/applications/jonny5/src/j5_authz_req.erl @@ -11,7 +11,7 @@ -include("jonny5.hrl"). --spec handle_req(kz_json:object(), kz_proplist()) -> any(). +-spec handle_req(kz_json:object(), kz_term:proplist()) -> any(). handle_req(JObj, _) -> 'true' = kapi_authz:authz_req_v(JObj), kz_util:put_callid(JObj), @@ -31,7 +31,7 @@ determine_account_id(Request) -> IP -> determine_account_id_from_ip(Request, IP) end. --spec determine_account_id_from_ip(j5_request:request(), ne_binary()) -> 'ok'. +-spec determine_account_id_from_ip(j5_request:request(), kz_term:ne_binary()) -> 'ok'. determine_account_id_from_ip(Request, IP) -> case kapps_util:get_ccvs_by_ip(IP) of {'ok', AccountCCVs} -> @@ -41,7 +41,7 @@ determine_account_id_from_ip(Request, IP) -> determine_account_id_from_number(Request) end. --spec maybe_inbound_account_by_ip(j5_request:request(), ne_binary()) -> 'ok'. +-spec maybe_inbound_account_by_ip(j5_request:request(), kz_term:ne_binary()) -> 'ok'. maybe_inbound_account_by_ip(Request, IP) -> AuthorizingType = kz_json:get_value(<<"Authorizing-Type">>, j5_request:ccvs(Request)), @@ -54,7 +54,7 @@ maybe_inbound_account_by_ip(Request, IP) -> maybe_account_limited(Request) end. --spec inbound_account_by_ip(j5_request:request(), ne_binary()) -> 'ok'. +-spec inbound_account_by_ip(j5_request:request(), kz_term:ne_binary()) -> 'ok'. inbound_account_by_ip(Request, IP) -> AccountId = j5_request:account_id(Request), lager:debug("source IP ~s belongs to account ~s, allowing" @@ -88,7 +88,7 @@ determine_account_id_from_number(Request) -> 'ok' end. --spec maybe_local_resource(ne_binary(), knm_number_options:extra_options(), j5_request:request()) -> 'ok'. +-spec maybe_local_resource(kz_term:ne_binary(), knm_number_options:extra_options(), j5_request:request()) -> 'ok'. maybe_local_resource(AccountId, Props, Request) -> case knm_number_options:is_local_number(Props) of 'true' -> maybe_authz_local_resource(AccountId, Request); @@ -98,7 +98,7 @@ maybe_local_resource(AccountId, Props, Request) -> ) end. --spec maybe_authz_local_resource(ne_binary(), j5_request:request()) -> 'ok'. +-spec maybe_authz_local_resource(kz_term:ne_binary(), j5_request:request()) -> 'ok'. maybe_authz_local_resource(AccountId, Request) -> case should_authz_local(Request) of 'false' -> allow_local_resource(AccountId, Request); @@ -109,7 +109,7 @@ maybe_authz_local_resource(AccountId, Request) -> ) end. --spec allow_local_resource(ne_binary(), j5_request:request()) -> 'ok'. +-spec allow_local_resource(kz_term:ne_binary(), j5_request:request()) -> 'ok'. allow_local_resource(AccountId, Request) -> Number = j5_request:number(Request), lager:debug("number ~s is a local number for account ~s, allowing" @@ -172,7 +172,7 @@ maybe_reseller_limited(Request) -> check_reseller_limits(Request, ResellerId) end. --spec check_reseller_limits(j5_request:request(), ne_binary()) -> 'ok'. +-spec check_reseller_limits(j5_request:request(), kz_term:ne_binary()) -> 'ok'. check_reseller_limits(Request, ResellerId) -> Limits = j5_limits:get(ResellerId), R = maybe_authorize(Request, Limits), @@ -213,7 +213,7 @@ maybe_authorize_exception(Request, Limits) -> _Else -> maybe_hard_limit(Request, Limits) end. --spec is_authorizing_mobile(api_ne_binary()) -> boolean(). +-spec is_authorizing_mobile(kz_term:api_ne_binary()) -> boolean(). is_authorizing_mobile(<<"mobile">>) -> 'true'; is_authorizing_mobile(_) -> 'false'. @@ -279,7 +279,7 @@ maybe_inbound_soft_limit(Request, Limits) -> ,<<"mobile">> ]). --spec maybe_get_outbound_flags(api_binary(), api_binary(), ne_binary()) -> api_binary(). +-spec maybe_get_outbound_flags(kz_term:api_binary(), kz_term:api_binary(), kz_term:ne_binary()) -> kz_term:api_binary(). maybe_get_outbound_flags('undefined', _AuthId, _AccountDb) -> 'undefined'; maybe_get_outbound_flags(_AuthType, 'undefined', _AccountDb) -> 'undefined'; maybe_get_outbound_flags(AuthType, AuthId, AccountDb) -> @@ -290,7 +290,7 @@ maybe_get_outbound_flags(AuthType, AuthId, AccountDb) -> _ -> 'undefined' end. --spec get_outbound_flags(kz_json:object()) -> api_binary(). +-spec get_outbound_flags(kz_json:object()) -> kz_term:api_binary(). get_outbound_flags(Endpoint) -> %%% TODO: without a kapps_call we can not support dynamic %%% flags yet @@ -338,7 +338,7 @@ send_response(Request) -> end. %% @private --spec trunk_usage(ne_binary()) -> ne_binary(). +-spec trunk_usage(kz_term:ne_binary()) -> kz_term:ne_binary(). trunk_usage(Id) -> Limits = j5_limits:get(Id), << diff --git a/applications/jonny5/src/j5_balance_check_req.erl b/applications/jonny5/src/j5_balance_check_req.erl index 806205ecdc3..539e660bd4b 100644 --- a/applications/jonny5/src/j5_balance_check_req.erl +++ b/applications/jonny5/src/j5_balance_check_req.erl @@ -12,7 +12,7 @@ -include("jonny5.hrl"). --spec handle_req(kz_json:object(), kz_proplist()) -> any(). +-spec handle_req(kz_json:object(), kz_term:proplist()) -> any(). handle_req(ReqJObj, _Props) -> 'true' = kapi_authz:balance_check_req_v(ReqJObj), kz_util:put_callid(?APP_NAME), @@ -22,7 +22,7 @@ handle_req(ReqJObj, _Props) -> ServerId = kz_api:server_id(ReqJObj), kapi_authz:publish_balance_check_resp(ServerId, Resp). --spec account_balance(ne_binary(), ne_binaries()) -> ne_binaries(). +-spec account_balance(kz_term:ne_binary(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). account_balance(AccountId, Acc) -> Limits = j5_limits:get(AccountId), [ {AccountId, j5_per_minute:maybe_credit_available(0, Limits)} | Acc ]. diff --git a/applications/jonny5/src/j5_channel_destroy.erl b/applications/jonny5/src/j5_channel_destroy.erl index c381ed2c526..0927d613f84 100644 --- a/applications/jonny5/src/j5_channel_destroy.erl +++ b/applications/jonny5/src/j5_channel_destroy.erl @@ -17,7 +17,7 @@ %% %% @end %%-------------------------------------------------------------------- --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Props) -> 'true' = kapi_call:event_v(JObj), kz_util:put_callid(JObj), diff --git a/applications/jonny5/src/j5_channels.erl b/applications/jonny5/src/j5_channels.erl index 46bfd551555..82658ad901e 100644 --- a/applications/jonny5/src/j5_channels.erl +++ b/applications/jonny5/src/j5_channels.erl @@ -39,8 +39,8 @@ -include("jonny5.hrl"). -include_lib("kazoo_apps/include/kz_hooks.hrl"). --record(state, {sync_ref :: api_reference() - ,sync_timer:: api_reference() +-record(state, {sync_ref :: kz_term:api_reference() + ,sync_timer:: kz_term:api_reference() }). -type state() :: #state{}. @@ -48,28 +48,28 @@ -define(TAB, ?MODULE). -define(SYNC_PERIOD, 900000). %% 15 minutes --record(channel, {call_id :: api_binary() | '$1' | '$2' | '_' - ,other_leg_call_id :: api_binary() | '$2' | '$3' | '_' - ,direction :: api_binary() | '_' - ,account_id :: api_binary() | '$1' | '_' - ,account_billing :: api_binary() | '$1' | '_' +-record(channel, {call_id :: kz_term:api_binary() | '$1' | '$2' | '_' + ,other_leg_call_id :: kz_term:api_binary() | '$2' | '$3' | '_' + ,direction :: kz_term:api_binary() | '_' + ,account_id :: kz_term:api_binary() | '$1' | '_' + ,account_billing :: kz_term:api_binary() | '$1' | '_' ,account_allotment = 'false' :: boolean() | '_' - ,reseller_id :: api_binary() | '$1' | '$2' | '_' - ,reseller_billing :: api_binary() | '$1' | '_' + ,reseller_id :: kz_term:api_binary() | '$1' | '$2' | '_' + ,reseller_billing :: kz_term:api_binary() | '$1' | '_' ,reseller_allotment = 'false' :: boolean() | '_' ,soft_limit = 'false' :: boolean() | '_' ,timestamp = kz_time:now_s() :: pos_integer() | '_' - ,answered_timestamp :: api_pos_integer() | '$1' | '_' - ,rate :: api_binary() | '_' - ,rate_increment :: api_binary() | '_' - ,rate_minimum :: api_binary() | '_' - ,rate_nocharge_time :: api_binary() | '_' - ,discount_percentage :: api_binary() | '_' - ,surcharge :: api_binary() | '_' - ,rate_name :: api_binary() | '_' - ,rate_description :: api_binary() | '_' - ,rate_id :: api_binary() | '_' - ,base_cost :: api_binary() | '_' + ,answered_timestamp :: kz_term:api_pos_integer() | '$1' | '_' + ,rate :: kz_term:api_binary() | '_' + ,rate_increment :: kz_term:api_binary() | '_' + ,rate_minimum :: kz_term:api_binary() | '_' + ,rate_nocharge_time :: kz_term:api_binary() | '_' + ,discount_percentage :: kz_term:api_binary() | '_' + ,surcharge :: kz_term:api_binary() | '_' + ,rate_name :: kz_term:api_binary() | '_' + ,rate_description :: kz_term:api_binary() | '_' + ,rate_id :: kz_term:api_binary() | '_' + ,base_cost :: kz_term:api_binary() | '_' }). -type channel() :: #channel{}. @@ -113,7 +113,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link({'local', ?SERVER} ,?MODULE @@ -133,7 +133,7 @@ sync() -> -spec flush() -> 'ok'. flush() -> gen_server:cast(?SERVER, 'flush_channels'). --spec total_calls(ne_binary()) -> non_neg_integer(). +-spec total_calls(kz_term:ne_binary()) -> non_neg_integer(). total_calls(AccountId) -> MatchSpec = [{#channel{account_id = AccountId ,call_id = '$1' @@ -154,7 +154,7 @@ total_calls(AccountId) -> ], count_unique_calls(ets:select(?TAB, MatchSpec)). --spec resource_consuming(ne_binary()) -> non_neg_integer(). +-spec resource_consuming(kz_term:ne_binary()) -> non_neg_integer(). resource_consuming(AccountId) -> MatchSpec = [{#channel{account_id = AccountId ,account_billing = '$1' @@ -181,7 +181,7 @@ resource_consuming(AccountId) -> ], count_unique_calls(ets:select(?TAB, MatchSpec)). --spec inbound_flat_rate(ne_binary()) -> non_neg_integer(). +-spec inbound_flat_rate(kz_term:ne_binary()) -> non_neg_integer(). inbound_flat_rate(AccountId) -> MatchSpec = [{#channel{account_id = AccountId ,account_billing = <<"flat_rate">> @@ -218,7 +218,7 @@ inbound_flat_rate(AccountId) -> ], ets:select_count(?TAB, MatchSpec). --spec outbound_flat_rate(ne_binary()) -> non_neg_integer(). +-spec outbound_flat_rate(kz_term:ne_binary()) -> non_neg_integer(). outbound_flat_rate(AccountId) -> MatchSpec = [{#channel{account_id = AccountId ,account_billing = <<"flat_rate">> @@ -255,7 +255,7 @@ outbound_flat_rate(AccountId) -> ], ets:select_count(?TAB, MatchSpec). --spec allotments(ne_binary()) -> non_neg_integer(). +-spec allotments(kz_term:ne_binary()) -> non_neg_integer(). allotments(AccountId) -> MatchSpec = [{#channel{account_id = AccountId ,account_allotment = 'true' @@ -275,7 +275,7 @@ allotments(AccountId) -> ets:select_count(?TAB, MatchSpec). --spec allotment_consumed(non_neg_integer(), non_neg_integer(), ne_binary(), ne_binary() | j5_limits:limits()) -> non_neg_integer(). +-spec allotment_consumed(non_neg_integer(), non_neg_integer(), kz_term:ne_binary(), kz_term:ne_binary() | j5_limits:limits()) -> non_neg_integer(). allotment_consumed(CycleStart, Span, Classification, AccountId) when is_binary(AccountId) -> MatchSpec = [{#channel{account_id = AccountId ,account_billing = <<"allotment_", Classification/binary>> @@ -299,7 +299,7 @@ allotment_consumed(CycleStart, Span, Classification, Limits) -> AccountId = j5_limits:account_id(Limits), allotment_consumed(CycleStart, Span, Classification, AccountId). --spec per_minute(ne_binary()) -> non_neg_integer(). +-spec per_minute(kz_term:ne_binary()) -> non_neg_integer(). per_minute(AccountId) -> MatchSpec = [{#channel{account_id = AccountId ,account_billing = <<"per_minute">> @@ -318,7 +318,7 @@ per_minute(AccountId) -> ], ets:select_count(?TAB, MatchSpec). --spec per_minute_cost(ne_binary()) -> non_neg_integer(). +-spec per_minute_cost(kz_term:ne_binary()) -> non_neg_integer(). per_minute_cost(AccountId) -> MatchSpec = [{#channel{account_id = AccountId ,account_billing = <<"per_minute">> @@ -339,7 +339,7 @@ per_minute_cost(AccountId) -> call_cost(Channel) + Cost end, 0, ets:select(?TAB, MatchSpec)). --spec real_per_minute_cost(ne_binary()) -> non_neg_integer(). +-spec real_per_minute_cost(kz_term:ne_binary()) -> non_neg_integer(). real_per_minute_cost(AccountId) -> MatchSpec = [{#channel{account_id = AccountId ,account_billing = <<"per_minute">> @@ -360,7 +360,7 @@ real_per_minute_cost(AccountId) -> call_cost(Channel, 0) + Cost end, 0, ets:select(?TAB, MatchSpec)). --spec accounts() -> ne_binaries(). +-spec accounts() -> kz_term:ne_binaries(). accounts() -> MatchSpec = [{#channel{account_id = '$1' ,reseller_id = '$2' @@ -372,7 +372,7 @@ accounts() -> ], accounts(ets:select(?TAB, MatchSpec), sets:new()). --spec accounts(any(), sets:set()) -> ne_binaries(). +-spec accounts(any(), sets:set()) -> kz_term:ne_binaries(). accounts([], Accounts) -> lists:reverse(sets:to_list(Accounts)); accounts([['undefined', 'undefined']|Ids], Accounts) -> @@ -389,7 +389,7 @@ accounts([[AccountId, ResellerId]|Ids], Accounts) -> ) ). --spec account(ne_binary()) -> channels(). +-spec account(kz_term:ne_binary()) -> channels(). account(AccountId) -> MatchSpec = [{#channel{account_id = AccountId ,_='_' @@ -406,7 +406,7 @@ account(AccountId) -> ], ets:select(?TAB, MatchSpec). --spec to_props(channel()) -> kz_proplist(). +-spec to_props(channel()) -> kz_term:proplist(). to_props(#channel{call_id=CallId ,other_leg_call_id=OtherLeg ,direction=Direction @@ -455,7 +455,7 @@ to_props(#channel{call_id=CallId -spec authorized(kz_json:object()) -> 'ok'. authorized(JObj) -> gen_server:cast(?SERVER, {'authorized', JObj}). --spec handle_authz_resp(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_authz_resp(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_authz_resp(JObj, _Props) -> 'true' = kapi_authz:authz_resp_v(JObj), case kz_json:is_true(<<"Is-Authorized">>, JObj) of @@ -463,13 +463,13 @@ handle_authz_resp(JObj, _Props) -> 'false' -> 'ok' end. --spec handle_rate_resp(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_rate_resp(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_rate_resp(JObj, Props) -> 'true' = kapi_rate:resp_v(JObj), Srv = props:get_value('server', Props), gen_server:cast(Srv, {'rate_resp', JObj}). --spec handle_channel_destroy(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_channel_destroy(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_channel_destroy(JObj, Props) -> 'true' = kapi_call:event_v(JObj), CallId = kz_call_event:call_id(JObj), @@ -516,7 +516,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -530,7 +530,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'rate_resp', JObj}, State) -> Props = props:filter_undefined( [{#channel.rate, kz_json:get_value(<<"Rate">>, JObj)} @@ -583,7 +583,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'synchronize_channels', SyncRef}, #state{sync_ref=SyncRef}=State) -> Req = kz_api:default_headers(?APP_NAME, ?APP_VERSION), _ = case kz_amqp_worker:call_collect(Req @@ -625,7 +625,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. @@ -698,11 +698,11 @@ from_jobj(JObj) -> ,soft_limit = kz_term:is_true(SoftLimit) }. --spec is_allotment(ne_binary()) -> boolean(). +-spec is_allotment(kz_term:ne_binary()) -> boolean(). is_allotment(<<"allotment_", _/binary>>) -> 'true'; is_allotment(_) -> 'false'. --type unique_channel() :: {ne_binary(), api_binary()}. +-type unique_channel() :: {kz_term:ne_binary(), kz_term:api_binary()}. -type unique_channels() :: [unique_channel()]. -spec count_unique_calls(unique_channels()) -> non_neg_integer(). @@ -742,7 +742,7 @@ fix_channel_disparity(LocalChannelIds, EcallmgrChannelIds) -> Disparity = sets:to_list(sets:subtract(LocalChannelIds, EcallmgrChannelIds)), fix_channel_disparity(Disparity). --spec fix_channel_disparity(ne_binaries()) -> 'ok'. +-spec fix_channel_disparity(kz_term:ne_binaries()) -> 'ok'. fix_channel_disparity([]) -> 'ok'; fix_channel_disparity([ChannelId|ChannelIds]) -> lager:debug("channel disparity with ecallmgr, removing ~s" diff --git a/applications/jonny5/src/j5_flat_rate.erl b/applications/jonny5/src/j5_flat_rate.erl index e812be8d4cc..a8879131f9f 100644 --- a/applications/jonny5/src/j5_flat_rate.erl +++ b/applications/jonny5/src/j5_flat_rate.erl @@ -73,9 +73,9 @@ eligible_for_flat_rate(Request) -> ). -spec maybe_get_resource_flat_rate(j5_request:request()) -> - {ne_binary(), ne_binary()}. + {kz_term:ne_binary(), kz_term:ne_binary()}. -spec maybe_get_resource_flat_rate(j5_request:request(), boolean()) -> - {ne_binary(), ne_binary()}. + {kz_term:ne_binary(), kz_term:ne_binary()}. maybe_get_resource_flat_rate(Request) -> maybe_get_resource_flat_rate(Request, ?SHOULD_LOOKUP_FLAT_RATE). @@ -174,7 +174,7 @@ consume_twoway_limits(Used, Limits) -> %% %% @end %%-------------------------------------------------------------------- --spec consume_limit(integer(), integer(), ne_binary()) -> integer(). +-spec consume_limit(integer(), integer(), kz_term:ne_binary()) -> integer(). consume_limit(-1, _, Type) -> lager:debug("account has unlimited ~s trunks", [Type]), 0; diff --git a/applications/jonny5/src/j5_limits.erl b/applications/jonny5/src/j5_limits.erl index 6b26e210986..33305126f97 100644 --- a/applications/jonny5/src/j5_limits.erl +++ b/applications/jonny5/src/j5_limits.erl @@ -29,8 +29,8 @@ -include("jonny5.hrl"). --record(limits, {account_id :: api_binary() - ,account_db :: api_binary() +-record(limits, {account_id :: kz_term:api_binary() + ,account_db :: kz_term:api_binary() ,enabled = 'true' :: boolean() ,calls = -1 :: tristate_integer() ,resource_consuming_calls = -1 :: tristate_integer() @@ -61,7 +61,7 @@ %% %% @end %%-------------------------------------------------------------------- --spec get(ne_binary()) -> limits(). +-spec get(kz_term:ne_binary()) -> limits(). get(Account) -> AccountId = kz_util:format_account_id(Account, 'raw'), case kz_cache:peek_local(?CACHE_NAME, ?LIMITS_KEY(AccountId)) of @@ -69,7 +69,7 @@ get(Account) -> {'error', 'not_found'} -> fetch(AccountId) end. --spec fetch(ne_binary()) -> limits(). +-spec fetch(kz_term:ne_binary()) -> limits(). fetch(Account) -> AccountId = kz_util:format_account_id(Account, 'raw'), AccountDb = kz_util:format_account_id(Account, 'encoded'), @@ -96,7 +96,7 @@ cached() -> %% %% @end %%-------------------------------------------------------------------- --spec to_props(ne_binary() | limits()) -> kz_proplist(). +-spec to_props(kz_term:ne_binary() | limits()) -> kz_term:proplist(). to_props(#limits{}=Limits) -> lists:zip(record_info('fields', 'limits'), tl(tuple_to_list(Limits))); to_props(Account) -> to_props(?MODULE:get(Account)). @@ -107,7 +107,7 @@ to_props(Account) -> to_props(?MODULE:get(Account)). %% %% @end %%-------------------------------------------------------------------- --spec account_id(limits()) -> api_binary(). +-spec account_id(limits()) -> kz_term:api_binary(). account_id(#limits{account_id=AccountId}) -> AccountId; account_id(_) -> 'undefined'. @@ -252,7 +252,7 @@ max_postpay(#limits{max_postpay_amount=MaxPostpay}) -> MaxPostpay. %% %% @end %%-------------------------------------------------------------------- --spec get_limit(ne_binary(), kz_json:object(), tristate_integer()) -> +-spec get_limit(kz_term:ne_binary(), kz_json:object(), tristate_integer()) -> tristate_integer(). get_limit(Key, JObj, Default) -> PrivateValue = get_private_limit(Key, JObj), @@ -264,7 +264,7 @@ get_limit(Key, JObj, Default) -> 'false' -> PublicValue end. --spec get_public_limit(ne_binary(), kz_json:object(), tristate_integer()) -> +-spec get_public_limit(kz_term:ne_binary(), kz_json:object(), tristate_integer()) -> non_neg_integer(). get_public_limit(Key, JObj, Default) -> case kz_json:get_integer_value(Key, JObj) of @@ -273,11 +273,11 @@ get_public_limit(Key, JObj, Default) -> Value -> Value end. --spec get_private_limit(ne_binary(), kz_json:object()) -> tristate_integer(). +-spec get_private_limit(kz_term:ne_binary(), kz_json:object()) -> tristate_integer(). get_private_limit(Key, JObj) -> kz_json:get_integer_value(<<"pvt_", Key/binary>>, JObj). --spec get_default_limit(ne_binary(), tristate_integer()) -> tristate_integer(). +-spec get_default_limit(kz_term:ne_binary(), tristate_integer()) -> tristate_integer(). get_default_limit(Key, Default) -> kapps_config:get_integer(?APP_NAME, <<"default_", Key/binary>>, Default). @@ -287,14 +287,14 @@ get_default_limit(Key, Default) -> %% %% @end %%-------------------------------------------------------------------- --spec get_limit_units(ne_binary(), kz_json:object(), float()) -> non_neg_integer(). +-spec get_limit_units(kz_term:ne_binary(), kz_json:object(), float()) -> non_neg_integer(). get_limit_units(Key, JObj, Default) -> case kz_json:get_float_value(<<"pvt_", Key/binary>>, JObj) of 'undefined' -> get_default_limit_units(Key, Default); Value -> wht_util:dollars_to_units(abs(Value)) end. --spec get_default_limit_units(ne_binary(), float()) -> non_neg_integer(). +-spec get_default_limit_units(kz_term:ne_binary(), float()) -> non_neg_integer(). get_default_limit_units(Key, Default) -> Value = kapps_config:get_float(?APP_NAME, <<"default_", Key/binary>>, Default), wht_util:dollars_to_units(abs(Value)). @@ -305,14 +305,14 @@ get_default_limit_units(Key, Default) -> %% %% @end %%-------------------------------------------------------------------- --spec get_limit_boolean(ne_binary(), kz_json:object(), boolean()) -> boolean(). +-spec get_limit_boolean(kz_term:ne_binary(), kz_json:object(), boolean()) -> boolean(). get_limit_boolean(Key, JObj, Default) -> case kz_json:get_value(<<"pvt_", Key/binary>>, JObj) of 'undefined' -> get_public_limit_boolean(Key, JObj, Default); Value -> kz_term:is_true(Value) end. --spec get_public_limit_boolean(ne_binary(), kz_json:object(), boolean()) -> boolean(). +-spec get_public_limit_boolean(kz_term:ne_binary(), kz_json:object(), boolean()) -> boolean(). %% NOTE: all other booleans (inbound_soft_limit, allow_postpay, etc) should %% not be made public via this helper. get_public_limit_boolean(<<"allow_prepay">> = Key, JObj, Default) -> @@ -323,7 +323,7 @@ get_public_limit_boolean(<<"allow_prepay">> = Key, JObj, Default) -> get_public_limit_boolean(Key, _, Default) -> get_default_limit_boolean(Key, Default). --spec get_default_limit_boolean(ne_binary(), boolean()) -> boolean(). +-spec get_default_limit_boolean(kz_term:ne_binary(), boolean()) -> boolean(). get_default_limit_boolean(Key, Default) -> kapps_config:get_is_true(?APP_NAME, <<"default_", Key/binary>>, Default). @@ -333,7 +333,7 @@ get_default_limit_boolean(Key, Default) -> %% %% @end %%-------------------------------------------------------------------- --spec get_bundled_inbound_limit(ne_binary(), kz_json:object()) -> non_neg_integer(). +-spec get_bundled_inbound_limit(kz_term:ne_binary(), kz_json:object()) -> non_neg_integer(). get_bundled_inbound_limit(AccountDb, JObj) -> case kz_json:get_ne_value(<<"pvt_bundled_inbound_trunks">>, JObj) of 'undefined' -> 0; @@ -342,7 +342,7 @@ get_bundled_inbound_limit(AccountDb, JObj) -> get_bundled_limit(AccountDb, View) end. --spec get_bundled_outbound_limit(ne_binary(), kz_json:object()) -> non_neg_integer(). +-spec get_bundled_outbound_limit(kz_term:ne_binary(), kz_json:object()) -> non_neg_integer(). get_bundled_outbound_limit(AccountDb, JObj) -> case kz_json:get_ne_value(<<"pvt_bundled_outbound_trunks">>, JObj) of 'undefined' -> 0; @@ -351,7 +351,7 @@ get_bundled_outbound_limit(AccountDb, JObj) -> get_bundled_limit(AccountDb, View) end. --spec get_bundled_twoway_limit(ne_binary(), kz_json:object()) -> non_neg_integer(). +-spec get_bundled_twoway_limit(kz_term:ne_binary(), kz_json:object()) -> non_neg_integer(). get_bundled_twoway_limit(AccountDb, JObj) -> case kz_json:get_ne_value(<<"pvt_bundled_twoway_trunks">>, JObj) of 'undefined' -> 0; @@ -360,7 +360,7 @@ get_bundled_twoway_limit(AccountDb, JObj) -> get_bundled_limit(AccountDb, View) end. --spec get_bundled_limit(ne_binary(), ne_binary()) -> non_neg_integer(). +-spec get_bundled_limit(kz_term:ne_binary(), kz_term:ne_binary()) -> non_neg_integer(). get_bundled_limit(AccountDb, View) -> case kz_datamgr:get_results(AccountDb, View, []) of {'ok', JObjs} -> filter_bundled_limit(JObjs); @@ -385,7 +385,7 @@ filter_bundled_limit(JObjs) -> %% %% @end %%-------------------------------------------------------------------- --spec get_limit_jobj(ne_binary()) -> kz_json:object() | {'error', any()}. +-spec get_limit_jobj(kz_term:ne_binary()) -> kz_json:object() | {'error', any()}. get_limit_jobj(AccountDb) -> case kz_datamgr:open_doc(AccountDb, <<"limits">>) of {'ok', JObj} -> JObj; @@ -398,7 +398,7 @@ get_limit_jobj(AccountDb) -> Error end. --spec create_default_limit_jobj(ne_binary()) -> kz_json:object(). +-spec create_default_limit_jobj(kz_term:ne_binary()) -> kz_json:object(). create_default_limit_jobj(AccountDb) -> TStamp = kz_time:now_s(), JObj = kz_json:from_list( @@ -419,7 +419,7 @@ create_default_limit_jobj(AccountDb) -> Error end. --spec create_limits(ne_binary(), ne_binary(), kz_json:object()) -> limits(). +-spec create_limits(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> limits(). create_limits(AccountId, AccountDb, JObj) -> #limits{account_id = AccountId ,account_db = AccountDb diff --git a/applications/jonny5/src/j5_request.erl b/applications/jonny5/src/j5_request.erl index fd6ae8b97c6..04752c3d30c 100644 --- a/applications/jonny5/src/j5_request.erl +++ b/applications/jonny5/src/j5_request.erl @@ -74,27 +74,27 @@ -include("jonny5.hrl"). --record(request, {account_id :: api_binary() - ,account_billing :: api_binary() +-record(request, {account_id :: kz_term:api_binary() + ,account_billing :: kz_term:api_binary() ,account_authorized = 'false' :: boolean() - ,reseller_id :: api_binary() - ,reseller_billing :: api_binary() + ,reseller_id :: kz_term:api_binary() + ,reseller_billing :: kz_term:api_binary() ,reseller_authorized = 'false' :: boolean() ,soft_limit = 'false' :: boolean() - ,call_id :: api_binary() - ,call_direction :: api_binary() - ,other_leg_call_id :: api_binary() - ,sip_to :: api_binary() - ,sip_from :: api_binary() - ,sip_request :: api_binary() - ,message_id :: api_binary() - ,server_id :: api_binary() - ,node :: api_binary() - ,classification :: api_binary() - ,number :: api_binary() + ,call_id :: kz_term:api_binary() + ,call_direction :: kz_term:api_binary() + ,other_leg_call_id :: kz_term:api_binary() + ,sip_to :: kz_term:api_binary() + ,sip_from :: kz_term:api_binary() + ,sip_request :: kz_term:api_binary() + ,message_id :: kz_term:api_binary() + ,server_id :: kz_term:api_binary() + ,node :: kz_term:api_binary() + ,classification :: kz_term:api_binary() + ,number :: kz_term:api_binary() ,billing_seconds = 0 :: non_neg_integer() ,answered_time = 0 :: non_neg_integer() - ,timestamp = 0 :: gregorian_seconds() + ,timestamp = 0 :: kz_time:gregorian_seconds() ,request_jobj = kz_json:new() :: kz_json:object() ,request_ccvs = kz_json:new() :: kz_json:object() }). @@ -137,7 +137,7 @@ from_jobj(JObj) -> ,request_ccvs = CCVs }. --spec from_ccvs(request(), kz_proplist()) -> request(). +-spec from_ccvs(request(), kz_term:proplist()) -> request(). from_ccvs(#request{request_ccvs=ReqCCVs ,request_jobj=ReqJObj }=Request, CCVs) -> @@ -149,7 +149,7 @@ from_ccvs(#request{request_ccvs=ReqCCVs }. --spec request_number(ne_binary(), kz_json:object()) -> ne_binary(). +-spec request_number(kz_term:ne_binary(), kz_json:object()) -> kz_term:ne_binary(). request_number(Number, CCVs) -> case kz_json:get_first_defined([<<"E164-Destination">> ,<<"Original-Number">> @@ -195,7 +195,7 @@ to_jobj(Request) -> %% %% @end %%-------------------------------------------------------------------- --spec authorize(ne_binary(), request(), j5_limits:limits()) -> request(). +-spec authorize(kz_term:ne_binary(), request(), j5_limits:limits()) -> request(). authorize(Reason ,#request{reseller_id=AccountId ,account_id=AccountId @@ -212,7 +212,7 @@ authorize(Reason authorized_by_account(Reason, Request) end. --spec authorized_by_reseller(ne_binary(), request()) -> request(). +-spec authorized_by_reseller(kz_term:ne_binary(), request()) -> request(). authorized_by_reseller(Reason, #request{reseller_id=_ResellerId}=Request) -> lager:debug("reseller ~s authorized channel: ~s" ,[_ResellerId, Reason] @@ -221,7 +221,7 @@ authorized_by_reseller(Reason, #request{reseller_id=_ResellerId}=Request) -> ,reseller_authorized='true' }. --spec authorized_by_account(ne_binary(), request()) -> request(). +-spec authorized_by_account(kz_term:ne_binary(), request()) -> request(). authorized_by_account(Reason, #request{account_id=_AccountId}=Request) -> lager:debug("account ~s authorized channel: ~s" ,[_AccountId, Reason] @@ -230,11 +230,11 @@ authorized_by_account(Reason, #request{account_id=_AccountId}=Request) -> ,account_authorized='true' }. --spec authorize_account(ne_binary(), request()) -> request(). +-spec authorize_account(kz_term:ne_binary(), request()) -> request(). authorize_account(Reason, Request) -> authorized_by_account(Reason, Request). --spec authorize_reseller(ne_binary(), request()) -> request(). +-spec authorize_reseller(kz_term:ne_binary(), request()) -> request(). authorize_reseller(Reason, Request) -> authorized_by_reseller(Reason, Request). @@ -244,7 +244,7 @@ authorize_reseller(Reason, Request) -> %% %% @end %%-------------------------------------------------------------------- --spec deny(ne_binary(), request(), j5_limits:limits()) -> request(). +-spec deny(kz_term:ne_binary(), request(), j5_limits:limits()) -> request(). deny(Reason ,#request{reseller_id=ResellerId ,account_id=AccountId @@ -267,7 +267,7 @@ deny(Reason } end. --spec deny_account(ne_binary(), request()) -> request(). +-spec deny_account(kz_term:ne_binary(), request()) -> request(). deny_account(Reason, #request{account_id=AccountId}=Request) -> lager:debug("account ~s denied channel: ~s" ,[AccountId, Reason] @@ -276,7 +276,7 @@ deny_account(Reason, #request{account_id=AccountId}=Request) -> ,account_authorized='false' }. --spec deny_reseller(ne_binary(), request()) -> request(). +-spec deny_reseller(kz_term:ne_binary(), request()) -> request(). deny_reseller(Reason, #request{reseller_id=ResellerId}=Request) -> lager:debug("reseller ~s denied channel: ~s" ,[ResellerId, Reason] @@ -319,11 +319,11 @@ is_authorized(#request{account_authorized=AccountAuthorized %% %% @end %%-------------------------------------------------------------------- --spec set_account_id(api_binary(), request()) -> request(). +-spec set_account_id(kz_term:api_binary(), request()) -> request(). set_account_id(AccountId, Request) -> Request#request{account_id=AccountId}. --spec account_id(request()) -> api_binary(). +-spec account_id(request()) -> kz_term:api_binary(). account_id(#request{account_id=AccountId}) -> AccountId. %%-------------------------------------------------------------------- @@ -332,11 +332,11 @@ account_id(#request{account_id=AccountId}) -> AccountId. %% %% @end %%-------------------------------------------------------------------- --spec set_reseller_id(api_binary(), request()) -> request(). +-spec set_reseller_id(kz_term:api_binary(), request()) -> request(). set_reseller_id(ResellerId, Request) -> Request#request{reseller_id=ResellerId}. --spec reseller_id(request()) -> api_binary(). +-spec reseller_id(request()) -> kz_term:api_binary(). reseller_id(#request{reseller_id=ResellerId}) -> ResellerId. %%-------------------------------------------------------------------- @@ -345,7 +345,7 @@ reseller_id(#request{reseller_id=ResellerId}) -> ResellerId. %% %% @end %%-------------------------------------------------------------------- --spec billing(request(), j5_limits:limits()) -> api_binary(). +-spec billing(request(), j5_limits:limits()) -> kz_term:api_binary(). billing(#request{account_billing=AccountBilling ,reseller_id=ResellerId ,reseller_billing=ResellerBilling @@ -356,10 +356,10 @@ billing(#request{account_billing=AccountBilling 'false' -> AccountBilling end. --spec account_billing(request()) -> api_binary(). +-spec account_billing(request()) -> kz_term:api_binary(). account_billing(#request{account_billing=Billing}) -> Billing. --spec reseller_billing(request()) -> api_binary(). +-spec reseller_billing(request()) -> kz_term:api_binary(). reseller_billing(#request{reseller_billing=Billing}) -> Billing. %%-------------------------------------------------------------------- @@ -385,7 +385,7 @@ soft_limit(#request{soft_limit=SoftLimit}) -> SoftLimit. %% %% @end %%-------------------------------------------------------------------- --spec other_leg_call_id(request()) -> api_binary(). +-spec other_leg_call_id(request()) -> kz_term:api_binary(). other_leg_call_id(#request{other_leg_call_id=CallId}) -> CallId. %%-------------------------------------------------------------------- @@ -423,7 +423,7 @@ billing_seconds(#request{billing_seconds=BillingSeconds}) -> %% %% @end %%-------------------------------------------------------------------- --spec call_direction(request()) -> api_binary(). +-spec call_direction(request()) -> kz_term:api_binary(). call_direction(#request{call_direction=CallDirection}) -> CallDirection. @@ -433,7 +433,7 @@ call_direction(#request{call_direction=CallDirection}) -> %% %% @end %%-------------------------------------------------------------------- --spec call_id(request()) -> api_binary(). +-spec call_id(request()) -> kz_term:api_binary(). call_id(#request{call_id=CallId}) -> CallId. %%-------------------------------------------------------------------- @@ -442,7 +442,7 @@ call_id(#request{call_id=CallId}) -> CallId. %% %% @end %%-------------------------------------------------------------------- --spec from(request()) -> api_binary(). +-spec from(request()) -> kz_term:api_binary(). from(#request{sip_from=From}) -> From. %%-------------------------------------------------------------------- @@ -451,7 +451,7 @@ from(#request{sip_from=From}) -> From. %% %% @end %%-------------------------------------------------------------------- --spec to(request()) -> api_binary(). +-spec to(request()) -> kz_term:api_binary(). to(#request{sip_to=To}) -> To. %%-------------------------------------------------------------------- @@ -460,7 +460,7 @@ to(#request{sip_to=To}) -> To. %% %% @end %%-------------------------------------------------------------------- --spec message_id(request()) -> api_binary(). +-spec message_id(request()) -> kz_term:api_binary(). message_id(#request{message_id=MessageId}) -> MessageId. %%-------------------------------------------------------------------- @@ -469,7 +469,7 @@ message_id(#request{message_id=MessageId}) -> MessageId. %% %% @end %%-------------------------------------------------------------------- --spec server_id(request()) -> api_binary(). +-spec server_id(request()) -> kz_term:api_binary(). server_id(#request{server_id=ServerId}) -> ServerId. %%-------------------------------------------------------------------- @@ -478,7 +478,7 @@ server_id(#request{server_id=ServerId}) -> ServerId. %% %% @end %%-------------------------------------------------------------------- --spec node(request()) -> api_binary(). +-spec node(request()) -> kz_term:api_binary(). node(#request{node=NodeId}) -> NodeId. %%-------------------------------------------------------------------- @@ -487,7 +487,7 @@ node(#request{node=NodeId}) -> NodeId. %% %% @end %%-------------------------------------------------------------------- --spec classification(request()) -> api_binary(). +-spec classification(request()) -> kz_term:api_binary(). classification(#request{classification=Classification}) -> Classification. %%-------------------------------------------------------------------- @@ -496,7 +496,7 @@ classification(#request{classification=Classification}) -> Classification. %% %% @end %%-------------------------------------------------------------------- --spec number(request()) -> ne_binary(). +-spec number(request()) -> kz_term:ne_binary(). number(#request{number=Number}) -> Number. %%-------------------------------------------------------------------- @@ -523,7 +523,7 @@ call_cost(#request{request_jobj=JObj}) -> calculate_call(#request{request_jobj=JObj}) -> wht_util:calculate_call(JObj). --spec caller_network_address(request()) -> api_binary(). +-spec caller_network_address(request()) -> kz_term:api_binary(). caller_network_address(#request{request_jobj=JObj}) -> kz_json:get_value(<<"From-Network-Addr">>, JObj). @@ -531,54 +531,54 @@ caller_network_address(#request{request_jobj=JObj}) -> rate(#request{request_ccvs=CCVs}) -> kz_json:get_integer_value(<<"Rate">>, CCVs). --spec rate_name(request()) -> ne_binary(). +-spec rate_name(request()) -> kz_term:ne_binary(). rate_name(#request{request_ccvs=CCVs}) -> kz_json:get_ne_binary_value(<<"Rate-Name">>, CCVs). --spec rate_description(request()) -> ne_binary(). +-spec rate_description(request()) -> kz_term:ne_binary(). rate_description(#request{request_ccvs=CCVs}) -> kz_json:get_ne_binary_value(<<"Rate-Description">>, CCVs). --spec rate_increment(request()) -> ne_binary(). +-spec rate_increment(request()) -> kz_term:ne_binary(). rate_increment(#request{request_ccvs=CCVs}) -> kz_json:get_integer_value(<<"Rate-Increment">>, CCVs, 0). --spec rate_minimum(request()) -> ne_binary(). +-spec rate_minimum(request()) -> kz_term:ne_binary(). rate_minimum(#request{request_ccvs=CCVs}) -> kz_json:get_integer_value(<<"Rate-Minimum">>, CCVs, 0). --spec rate_nocharge_time(request()) -> ne_binary(). +-spec rate_nocharge_time(request()) -> kz_term:ne_binary(). rate_nocharge_time(#request{request_ccvs=CCVs}) -> kz_json:get_integer_value(<<"Rate-NoCharge-Time">>, CCVs, 0). --spec caller_id_number(request()) -> api_binary(). +-spec caller_id_number(request()) -> kz_term:api_binary(). caller_id_number(#request{request_jobj=JObj}) -> kz_json:get_value(<<"Caller-ID-Number">>, JObj). --spec caller_id_name(request()) -> api_binary(). +-spec caller_id_name(request()) -> kz_term:api_binary(). caller_id_name(#request{request_jobj=JObj}) -> kz_json:get_value(<<"Caller-ID-Name">>, JObj). --spec callee_id_number(request()) -> api_binary(). +-spec callee_id_number(request()) -> kz_term:api_binary(). callee_id_number(#request{request_jobj=JObj}) -> kz_json:get_value(<<"Callee-ID-Number">>, JObj). --spec callee_id_name(request()) -> api_binary(). +-spec callee_id_name(request()) -> kz_term:api_binary(). callee_id_name(#request{request_jobj=JObj}) -> kz_json:get_value(<<"Callee-ID-Name">>, JObj). --spec resource_type(request()) -> api_binary(). +-spec resource_type(request()) -> kz_term:api_binary(). resource_type(#request{request_ccvs=CCVs}) -> kz_json:get_value(<<"Resource-Type">>, CCVs). --spec resource_id(request()) -> api_ne_binary(). +-spec resource_id(request()) -> kz_term:api_ne_binary(). resource_id(#request{request_ccvs=CCVs}) -> kz_json:get_ne_binary_value(<<"Resource-ID">>, CCVs). --spec account_trunk_usage(request()) -> api_binary(). +-spec account_trunk_usage(request()) -> kz_term:api_binary(). account_trunk_usage(#request{request_ccvs=CCVs}) -> kz_json:get_value(<<"Account-Trunk-Usage">>, CCVs). --spec reseller_trunk_usage(request()) -> api_binary(). +-spec reseller_trunk_usage(request()) -> kz_term:api_binary(). reseller_trunk_usage(#request{request_ccvs=CCVs}) -> kz_json:get_value(<<"Reseller-Trunk-Usage">>, CCVs). diff --git a/applications/jonny5/src/j5_util.erl b/applications/jonny5/src/j5_util.erl index 29acb5e029a..f4738fd6f04 100644 --- a/applications/jonny5/src/j5_util.erl +++ b/applications/jonny5/src/j5_util.erl @@ -12,7 +12,7 @@ -include("jonny5.hrl"). --spec remove_call_charges(api_binary(), api_binary()) -> 'ok'. +-spec remove_call_charges(kz_term:api_binary(), kz_term:api_binary()) -> 'ok'. remove_call_charges('undefined', _) -> 'ok'; remove_call_charges(_, 'undefined') -> 'ok'; remove_call_charges(AccountId, CallId) -> @@ -55,7 +55,7 @@ send_system_alert(Request) -> ,lists:foldr(fun(F, P) -> F(P) end, [], Routines) ). --spec add_limit_details(api_ne_binary(), ne_binary(), kz_proplist()) -> kz_proplist(). +-spec add_limit_details(kz_term:api_ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> kz_term:proplist(). add_limit_details('undefined', _, Props) -> Props; add_limit_details(Account, Prefix, Props) -> AccountId = kz_util:format_account_id(Account), @@ -94,7 +94,7 @@ outbound_trunks(AccountId, Limits) -> max_postpay(Limits) -> wht_util:units_to_dollars(j5_limits:max_postpay(Limits)). --spec get_account_name(api_binary()) -> ne_binary(). +-spec get_account_name(kz_term:api_binary()) -> kz_term:ne_binary(). get_account_name('undefined') -> <<"unknown">>; get_account_name(Account) -> case kz_account:fetch_name(Account) of @@ -102,7 +102,7 @@ get_account_name(Account) -> Name -> Name end. --spec current_balance(ne_binary()) -> ne_binary(). +-spec current_balance(kz_term:ne_binary()) -> kz_term:ne_binary(). current_balance(AccountId) -> case wht_util:current_balance(AccountId) of {'ok', Balance} -> wht_util:units_to_dollars(Balance); diff --git a/applications/jonny5/src/jonny5_app.erl b/applications/jonny5/src/jonny5_app.erl index d89605b113e..c87e7bdf1c5 100644 --- a/applications/jonny5/src/jonny5_app.erl +++ b/applications/jonny5/src/jonny5_app.erl @@ -17,7 +17,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = declare_exchanges(), jonny5_sup:start_link(). diff --git a/applications/jonny5/src/jonny5_listener.erl b/applications/jonny5/src/jonny5_listener.erl index 389289b8e14..74bef631287 100644 --- a/applications/jonny5/src/jonny5_listener.erl +++ b/applications/jonny5/src/jonny5_listener.erl @@ -47,7 +47,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link({'local', ?SERVER}, ?MODULE, [{'bindings', ?BINDINGS} ,{'responders', ?RESPONDERS} @@ -89,7 +89,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -103,7 +103,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> {'noreply', State}. @@ -117,7 +117,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -129,7 +129,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/jonny5/src/jonny5_maintenance.erl b/applications/jonny5/src/jonny5_maintenance.erl index 884dff4eb18..7614f2b94cc 100644 --- a/applications/jonny5/src/jonny5_maintenance.erl +++ b/applications/jonny5/src/jonny5_maintenance.erl @@ -42,7 +42,7 @@ print_authz_summary_header() -> io:format("| Account ID | Calls | Resource Calls | Allotments | Inbound Trunks | Outbound Trunks | Per Minute |~n"), io:format("+==================================+=======+================+============+================+=================+============+~n"). --spec authz_summary(ne_binaries()) -> 'no_return'. +-spec authz_summary(kz_term:ne_binaries()) -> 'no_return'. authz_summary([]) -> 'no_return'; authz_summary([AccountId|AccountIds]) -> io:format("| ~-32s | ~-5w | ~-14w | ~-10w | ~-14w | ~-15w | ~-10w |~n" @@ -60,7 +60,7 @@ authz_summary(<<_/binary>> = AccountId) -> print_authz_summary_header(), authz_summary([AccountId]). --spec authz_details(j5_channels:channels() | ne_binary()) -> 'no_return'. +-spec authz_details(j5_channels:channels() | kz_term:ne_binary()) -> 'no_return'. authz_details([]) -> io:format("~n", []), 'no_return'; @@ -92,7 +92,7 @@ authz_details([Channel|Channels]) -> authz_details(AccountId) -> authz_details(j5_channels:account(AccountId)). --spec authz_details_cost(kz_proplist(), non_neg_integer()) -> non_neg_integer(). +-spec authz_details_cost(kz_term:proplist(), non_neg_integer()) -> non_neg_integer(). authz_details_cost(Props, Timestamp) -> case props:get_integer_value(<<"Answered-Timestamp">>, Props) of 'undefined' -> 0; @@ -102,7 +102,7 @@ authz_details_cost(Props, Timestamp) -> wht_util:units_to_dollars(wht_util:call_cost(JObj)) end. --spec authz_details_duration(ne_binary(), kz_proplist(), non_neg_integer()) -> iolist(). +-spec authz_details_duration(kz_term:ne_binary(), kz_term:proplist(), non_neg_integer()) -> iolist(). authz_details_duration(Key, Props, Timestamp) -> case props:get_integer_value(Key, Props) of 'undefined' -> "0s"; @@ -121,7 +121,7 @@ limits_summary() -> limits_summary(Limits) end. --spec limits_summary([j5_limits:limits()] | ne_binary()) -> 'no_return'. +-spec limits_summary([j5_limits:limits()] | kz_term:ne_binary()) -> 'no_return'. limits_summary([]) -> 'no_return'; limits_summary([Limit|Limits]) -> case j5_limits:enabled(Limit) of @@ -185,7 +185,7 @@ limit_summary_header() -> io:format("| | | | | In | Out | Both | Burst | | |~n"), io:format("+==================================+=======+================+============+==========================+============+=============+~n"). --spec limits_details(atom() | string() | ne_binary()) -> 'no_return'. +-spec limits_details(atom() | string() | kz_term:ne_binary()) -> 'no_return'. limits_details(Account) when not is_binary(Account) -> limits_details(kz_term:to_binary(Account)); limits_details(Account) -> @@ -223,7 +223,7 @@ limits_details_allotments(JObj) -> Keys -> limits_details_allotments(Keys, JObj) end. --spec limits_details_allotments(ne_binaries(), kz_json:object()) -> 'ok'. +-spec limits_details_allotments(kz_term:ne_binaries(), kz_json:object()) -> 'ok'. limits_details_allotments([], _) -> 'ok'; limits_details_allotments([Key|Keys], JObj) -> io:format("~n", []), @@ -232,14 +232,14 @@ limits_details_allotments([Key|Keys], JObj) -> pretty_print_field(" Cycle", kz_json:get_value([Key, <<"cycle">>], JObj, <<"monthly">>)), limits_details_allotments(Keys, JObj). --spec pretty_print_field(text(), any()) -> 'ok'. +-spec pretty_print_field(kz_term:text(), any()) -> 'ok'. pretty_print_field(_, 'undefined') -> 'ok'; pretty_print_field(Name, Value) when is_number(Value) -> io:format("~-25s: ~w~n", [Name, Value]); pretty_print_field(Name, Value) -> io:format("~-25s: ~s~n", [Name, Value]). --spec current_balance(ne_binary()) -> iolist(). +-spec current_balance(kz_term:ne_binary()) -> iolist(). current_balance(AccountId) -> case wht_util:current_balance(AccountId) of {'ok', Balance} -> kz_term:to_list(wht_util:units_to_dollars(Balance)); diff --git a/applications/jonny5/src/jonny5_sup.erl b/applications/jonny5/src/jonny5_sup.erl index 3be3df5c8f0..561ecb1ffb4 100644 --- a/applications/jonny5/src/jonny5_sup.erl +++ b/applications/jonny5/src/jonny5_sup.erl @@ -37,7 +37,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -54,7 +54,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/konami/src/kapi_konami.erl b/applications/konami/src/kapi_konami.erl index 19408acec4d..bbaf450060b 100644 --- a/applications/konami/src/kapi_konami.erl +++ b/applications/konami/src/kapi_konami.erl @@ -25,25 +25,25 @@ ]). -define(TRANSFERRED_TYPES, []). --spec transferred(api_terms()) -> +-spec transferred(kz_term:api_terms()) -> {'ok', iolist()} | - {'error', ne_binary()}. + {'error', kz_term:ne_binary()}. transferred(API) -> case transferred_v(API) of 'true' -> kz_api:build_message(API, ?TRANSFERRED_HEADERS, ?OPTIONAL_TRANSFERRED_HEADERS); 'false' -> {'error', <<"API failed validation for transferred">>} end. --spec transferred_v(api_terms()) -> boolean(). +-spec transferred_v(kz_term:api_terms()) -> boolean(). transferred_v(API) -> kz_api:validate(API, ?TRANSFERRED_HEADERS, ?TRANSFERRED_VALUES, ?TRANSFERRED_TYPES). --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, Props) -> CallId = props:get_value('callid', Props), bind_q(Queue, CallId, props:get_value('restrict_to', Props)). --spec bind_q(ne_binary(), api_binary(), kz_proplist() | 'undefined') -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:api_binary(), kz_term:proplist() | 'undefined') -> 'ok'. bind_q(_Queue, 'undefined', 'undefined') -> 'ok'; bind_q(Queue, CallId, 'undefined') -> bind_for_transferred(Queue, CallId); @@ -56,12 +56,12 @@ bind_q(Queue, CallId, ['transferred'|Restrictions]) -> bind_q(Queue, CallId, [_Restriction|Restrictions]) -> bind_q(Queue, CallId, Restrictions). --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Queue, Props) -> CallId = props:get_value('callid', Props), unbind_q(Queue, CallId, props:get_value('restrict_to', Props)). --spec unbind_q(ne_binary(), api_binary(), kz_proplist() | 'undefined') -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:api_binary(), kz_term:proplist() | 'undefined') -> 'ok'. unbind_q(_Queue, 'undefined', 'undefined') -> 'ok'; unbind_q(Queue, CallId, 'undefined') -> unbind_for_transferred(Queue, CallId); @@ -78,23 +78,23 @@ unbind_q(Queue, CallId, [_Restriction|Restrictions]) -> declare_exchanges() -> amqp_util:kapps_exchange(). --spec publish_transferred(ne_binary(), api_terms()) -> 'ok'. +-spec publish_transferred(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. publish_transferred(TargetCallId, API) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?TRANSFERRED_VALUES, fun transferred/1), amqp_util:kapps_publish(transferred_routing_key(TargetCallId), Payload). --spec bind_for_transferred(ne_binary(), ne_binary()) -> 'ok'. +-spec bind_for_transferred(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. bind_for_transferred(Queue, CallId) -> manipulate_queue_bindings(Queue, transferred_routing_key(CallId), fun amqp_util:bind_q_to_kapps/2). --spec unbind_for_transferred(ne_binary(), ne_binary()) -> 'ok'. +-spec unbind_for_transferred(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. unbind_for_transferred(Queue, CallId) -> manipulate_queue_bindings(Queue, transferred_routing_key(CallId), fun amqp_util:unbind_q_from_kapps/2). --spec manipulate_queue_bindings(ne_binary(), ne_binary(), fun()) -> 'ok'. +-spec manipulate_queue_bindings(kz_term:ne_binary(), kz_term:ne_binary(), fun()) -> 'ok'. manipulate_queue_bindings(Queue, RoutingKey, Fun) -> Fun(Queue, RoutingKey). --spec transferred_routing_key(ne_binary()) -> ne_binary(). +-spec transferred_routing_key(kz_term:ne_binary()) -> kz_term:ne_binary(). transferred_routing_key(<<_/binary>> = CallId) -> <<"konami.transferred.", CallId/binary>>. diff --git a/applications/konami/src/konami_app.erl b/applications/konami/src/konami_app.erl index 516fe48daed..4534bd7e9c0 100644 --- a/applications/konami/src/konami_app.erl +++ b/applications/konami/src/konami_app.erl @@ -17,7 +17,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = declare_exchanges(), konami_sup:start_link(). diff --git a/applications/konami/src/konami_code_exe.erl b/applications/konami/src/konami_code_exe.erl index 846e1247c6c..8924ee3d5c1 100644 --- a/applications/konami/src/konami_code_exe.erl +++ b/applications/konami/src/konami_code_exe.erl @@ -12,7 +12,7 @@ -include("konami.hrl"). --spec handle(api_object(), kapps_call:call()) -> 'ok'. +-spec handle(kz_term:api_object(), kapps_call:call()) -> 'ok'. handle('undefined', _Call) -> lager:debug("no metaflow to execute"); handle(Metaflow, Call) -> @@ -39,7 +39,7 @@ handle(Metaflow, Call) -> kz_util:log_stacktrace(ST) end. --spec find_child_metaflow(api_binary(), kz_json:object()) -> api_object(). +-spec find_child_metaflow(kz_term:api_binary(), kz_json:object()) -> kz_term:api_object(). find_child_metaflow('undefined', Metaflow) -> kz_json:get_value([<<"children">>, <<"_">>], Metaflow); find_child_metaflow(Child, Metaflow) -> diff --git a/applications/konami/src/konami_code_statem.erl b/applications/konami/src/konami_code_statem.erl index f56009a6296..5ae1d86d459 100644 --- a/applications/konami/src/konami_code_statem.erl +++ b/applications/konami/src/konami_code_statem.erl @@ -34,25 +34,25 @@ -type listen_on() :: 'a' | 'b' | 'ab'. --record(state, {numbers :: api_object() - ,patterns :: api_object() - ,binding_digit = konami_config:binding_digit() :: ne_binary() +-record(state, {numbers :: kz_term:api_object() + ,patterns :: kz_term:api_object() + ,binding_digit = konami_config:binding_digit() :: kz_term:ne_binary() ,digit_timeout = konami_config:timeout() :: pos_integer() ,call :: kapps_call:call() | 'undefined' ,listen_on = 'a' :: listen_on() - ,a_digit_timeout_ref :: api_reference() + ,a_digit_timeout_ref :: kz_term:api_reference() ,a_collected_dtmf = <<>> :: binary() ,a_leg_armed = 'false' :: boolean() - ,b_digit_timeout_ref :: api_reference() + ,b_digit_timeout_ref :: kz_term:api_reference() ,b_collected_dtmf = <<>> :: binary() - ,b_endpoint_id :: api_binary() + ,b_endpoint_id :: kz_term:api_binary() ,b_leg_armed = 'false' :: boolean() - ,call_id :: api_ne_binary() - ,other_leg :: api_binary() + ,call_id :: kz_term:api_ne_binary() + ,other_leg :: kz_term:api_binary() }). -type state() :: #state{}. @@ -87,7 +87,7 @@ start(Call, JObj) -> gen_statem:start_link(?MODULE, {Call, JObj}, []). --spec event(pid(), ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec event(pid(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. event(ServerRef, CallId, <<"DTMF">>, JObj) -> gen_statem:cast(ServerRef, {'dtmf' ,CallId @@ -142,7 +142,7 @@ init({Call, JObj}) -> callback_mode() -> 'state_functions'. --spec unarmed(gen_statem:event_type(), any(), state()) -> handle_fsm_ret(state()). +-spec unarmed(gen_statem:event_type(), any(), state()) -> kz_types:handle_fsm_ret(state()). unarmed('cast', {'dtmf', CallId, BindingDigit}, #state{call_id=CallId ,listen_on='a' ,binding_digit=BindingDigit @@ -185,7 +185,7 @@ unarmed('cast', Evt, State) -> unarmed('info', _, State) -> {'next_state', ?FUNCTION_NAME, State}. --spec armed(gen_statem:event_type(), any(), state()) -> handle_fsm_ret(state()). +-spec armed(gen_statem:event_type(), any(), state()) -> kz_types:handle_fsm_ret(state()). armed('cast', {'dtmf', CallId, DTMF}, #state{call_id=CallId ,a_leg_armed='true' }=State) -> @@ -211,7 +211,7 @@ armed('info', {'timeout', Ref, 'digit_timeout'}, #state{b_digit_timeout_ref = Re ?WSD_NOTE(_OtherLeg, 'right', <<"disarming">>), {'next_state', 'unarmed', disarm_state(State), 'hibernate'}. --spec handle_event(any(), atom(), state()) -> handle_fsm_ret(state()). +-spec handle_event(any(), atom(), state()) -> kz_types:handle_fsm_ret(state()). handle_event(?EVENT(CallId, <<"metaflow_exe">>, Metaflow), StateName, #state{call=Call}=State) -> _Pid = proc_lib:spawn('konami_code_exe', 'handle', [Metaflow, Call]), lager:debug("recv metaflow exe request for ~s, processing in ~p", [CallId, _Pid]), @@ -288,7 +288,7 @@ format_status(_, [_Dict, #state{call_id=CallId %%%=================================================================== %%% Internal functions %%%=================================================================== --spec binding_digit(kapps_call:call(), kz_json:object()) -> ne_binary(). +-spec binding_digit(kapps_call:call(), kz_json:object()) -> kz_term:ne_binary(). binding_digit(Call, JObj) -> case kz_json:get_value(<<"Binding-Digit">>, JObj) of 'undefined' -> @@ -325,7 +325,7 @@ digit_timeout(Call, JObj) -> Timeout -> Timeout end. --spec is_a_leg(kapps_call:call(), api_object() | ne_binary()) -> boolean(). +-spec is_a_leg(kapps_call:call(), kz_term:api_object() | kz_term:ne_binary()) -> boolean(). is_a_leg(_Call, 'undefined') -> 'true'; is_a_leg(Call, <<_/binary>> = EndpointId) -> EndpointId =:= kapps_call:authorizing_id(Call); @@ -359,7 +359,7 @@ listen_on(Call, JObj) -> 'b' end. --spec has_metaflow(ne_binary(), kz_json:object(), kz_json:object()) -> +-spec has_metaflow(kz_term:ne_binary(), kz_json:object(), kz_json:object()) -> 'false' | {'number', kz_json:object()} | {'patterm', kz_json:object()}. @@ -369,7 +369,7 @@ has_metaflow(Collected, Ns, Ps) -> N -> N end. --spec has_number(ne_binary(), kz_json:object()) -> +-spec has_number(kz_term:ne_binary(), kz_json:object()) -> 'false' | {'number', kz_json:object()}. has_number(Collected, Ns) -> @@ -378,7 +378,7 @@ has_number(Collected, Ns) -> N -> {'number', N} end. --spec has_pattern(ne_binary(), kz_json:object()) -> +-spec has_pattern(kz_term:ne_binary(), kz_json:object()) -> 'false' | {'pattern', kz_json:object()}. has_pattern(Collected, Ps) -> @@ -447,14 +447,14 @@ maybe_handle_bleg_code(#state{numbers=Ns {'pattern', P} -> handle_pattern_metaflow(Call, P, OtherLeg) end. --spec handle_number_metaflow(kapps_call:call(), kz_json:object(), ne_binary()) -> 'ok'. +-spec handle_number_metaflow(kapps_call:call(), kz_json:object(), kz_term:ne_binary()) -> 'ok'. handle_number_metaflow(Call, N, DTMFLeg) -> Metaflow = kz_json:set_values([{[<<"data">>, <<"dtmf_leg">>], DTMFLeg}], N), _Pid = proc_lib:spawn('konami_code_exe', 'handle', [Metaflow, Call]), ?WSD_NOTE(DTMFLeg, 'right', <<"executing number metaflow">>), lager:debug("number exe in ~p: ~p", [_Pid, Metaflow]). --spec handle_pattern_metaflow(kapps_call:call(), kz_json:object(), ne_binary()) -> 'ok'. +-spec handle_pattern_metaflow(kapps_call:call(), kz_json:object(), kz_term:ne_binary()) -> 'ok'. handle_pattern_metaflow(Call, P, DTMFLeg) -> Metaflow = kz_json:set_values([{[<<"data">>, <<"dtmf_leg">>], DTMFLeg}], P), _Pid = proc_lib:spawn('konami_code_exe', 'handle', [Metaflow, Call]), @@ -475,8 +475,8 @@ arm_bleg(#state{digit_timeout=Timeout}=State) -> ,b_leg_armed='true' }. --spec maybe_fast_rearm(ne_binary(), ne_binary(), binary()) -> binary(). --spec maybe_fast_rearm(ne_binary(), ne_binary(), binary(), boolean()) -> binary(). +-spec maybe_fast_rearm(kz_term:ne_binary(), kz_term:ne_binary(), binary()) -> binary(). +-spec maybe_fast_rearm(kz_term:ne_binary(), kz_term:ne_binary(), binary(), boolean()) -> binary(). maybe_fast_rearm(DTMF, BindingDigit, Collected) -> maybe_fast_rearm(DTMF, BindingDigit, Collected @@ -488,7 +488,7 @@ maybe_fast_rearm(DoubleBindingDigit, DoubleBindingDigit, <<>>, 'true') -> Double maybe_fast_rearm(DTMFisBindingDigit, DTMFisBindingDigit, _Collected, 'true') -> <<>>; maybe_fast_rearm(DTMF, _BindingDigit, Collected, 'true') -> <>. --spec add_aleg_dtmf(state(), ne_binary()) -> state(). +-spec add_aleg_dtmf(state(), kz_term:ne_binary()) -> state(). add_aleg_dtmf(#state{a_collected_dtmf=Collected ,a_digit_timeout_ref=OldRef ,digit_timeout=Timeout @@ -500,7 +500,7 @@ add_aleg_dtmf(#state{a_collected_dtmf=Collected ,a_collected_dtmf = maybe_fast_rearm(DTMF, BindingDigit, Collected) }. --spec add_bleg_dtmf(state(), ne_binary()) -> state(). +-spec add_bleg_dtmf(state(), kz_term:ne_binary()) -> state(). add_bleg_dtmf(#state{b_collected_dtmf=Collected ,b_digit_timeout_ref=OldRef ,digit_timeout=Timeout @@ -512,7 +512,7 @@ add_bleg_dtmf(#state{b_collected_dtmf=Collected ,b_collected_dtmf = maybe_fast_rearm(DTMF, BindingDigit, Collected) }. --spec maybe_add_call_event_bindings(api_ne_binary() | kapps_call:call()) -> 'ok'. +-spec maybe_add_call_event_bindings(kz_term:api_ne_binary() | kapps_call:call()) -> 'ok'. -spec maybe_add_call_event_bindings(kapps_call:call(), listen_on()) -> 'ok'. maybe_add_call_event_bindings('undefined') -> 'ok'; maybe_add_call_event_bindings(<<_/binary>> = Leg) -> konami_event_listener:add_call_binding(Leg); @@ -529,11 +529,11 @@ maybe_add_call_event_bindings(Call, 'ab') -> konami_event_listener:add_konami_binding(kapps_call:other_leg_call_id(Call)), maybe_add_call_event_bindings(Call). --spec b_endpoint_id(kz_json:object(), listen_on()) -> api_binary(). +-spec b_endpoint_id(kz_json:object(), listen_on()) -> kz_term:api_binary(). b_endpoint_id(_JObj, 'a') -> 'undefined'; b_endpoint_id(JObj, _ListenOn) -> kz_json:get_value(<<"Endpoint-ID">>, JObj). --spec handle_channel_answer(state(), ne_binary(), kz_json:object()) -> state(). +-spec handle_channel_answer(state(), kz_term:ne_binary(), kz_json:object()) -> state(). handle_channel_answer(#state{call_id=CallId}=State, CallId, _Evt) -> lager:debug("'a' leg ~s answered", [CallId]), State; @@ -557,7 +557,7 @@ handle_channel_answer(#state{call_id=_CallId lager:debug("channel ~s answered while on ~s and ~s", [_AnsweredId, _CallId, _OtherLeg]), State. --spec maybe_other_leg_answered(state(), ne_binary(), ne_binary()) -> state(). +-spec maybe_other_leg_answered(state(), kz_term:ne_binary(), kz_term:ne_binary()) -> state(). maybe_other_leg_answered(#state{b_endpoint_id=EndpointId ,call=Call }=State @@ -573,7 +573,7 @@ maybe_other_leg_answered(State, _CallId, _EndpointId) -> lager:debug("ignoring channel ~s answering for endpoint ~s", [_CallId, _EndpointId]), State. --spec handle_channel_bridge(state(), ne_binary(), ne_binary()) -> state(). +-spec handle_channel_bridge(state(), kz_term:ne_binary(), kz_term:ne_binary()) -> state(). handle_channel_bridge(#state{call_id=CallId ,other_leg=OtherLeg }=State, CallId, OtherLeg) -> @@ -615,7 +615,7 @@ handle_channel_bridge(#state{call_id=_CallId ,call=kapps_call:set_call_id(UUID, Call) }. --spec handle_channel_destroy(state(), ne_binary()) -> state(). +-spec handle_channel_destroy(state(), kz_term:ne_binary()) -> state(). handle_channel_destroy(#state{call_id=CallId ,listen_on='a' } diff --git a/applications/konami/src/konami_config.erl b/applications/konami/src/konami_config.erl index cf7c1c29d6b..f6dff211121 100644 --- a/applications/konami/src/konami_config.erl +++ b/applications/konami/src/konami_config.erl @@ -35,7 +35,7 @@ -type formatter_fun() :: fun((any()) -> any()). -spec numbers() -> kz_json:object(). --spec numbers(ne_binary()) -> kz_json:object(). +-spec numbers(kz_term:ne_binary()) -> kz_json:object(). numbers() -> kapps_config:get_json(<<"metaflows">>, <<"numbers">>, ?DEFAULT_NUMBERS). @@ -47,7 +47,7 @@ numbers(Account) -> end. -spec patterns() -> kz_json:object(). --spec patterns(ne_binary()) -> kz_json:object(). +-spec patterns(kz_term:ne_binary()) -> kz_json:object(). patterns() -> kapps_config:get_json(<<"metaflows">>, <<"patterns">>, ?DEFAULT_PATTERNS). @@ -59,7 +59,7 @@ patterns(Account) -> end. -spec binding_digit() -> <<_:8>>. --spec binding_digit(ne_binary()) -> <<_:8>>. +-spec binding_digit(kz_term:ne_binary()) -> <<_:8>>. binding_digit() -> BindingDigit = kapps_config:get_ne_binary(<<"metaflows">>, <<"binding_digit">>, ?DEFAULT_BINDING_DIGIT), constrain_binding_digit(BindingDigit). @@ -71,7 +71,7 @@ binding_digit(Account) -> get_attribute(KonamiDoc, <<"binding_digit">>, fun binding_digit/0, fun constrain_binding_digit/1) end. --spec constrain_binding_digit(ne_binary()) -> <<_:8>>. +-spec constrain_binding_digit(kz_term:ne_binary()) -> <<_:8>>. constrain_binding_digit(BindingDigit) -> case lists:member(BindingDigit, ?ANY_DIGIT) of 'true' -> BindingDigit; @@ -79,7 +79,7 @@ constrain_binding_digit(BindingDigit) -> end. -spec timeout() -> non_neg_integer(). --spec timeout(ne_binary()) -> non_neg_integer(). +-spec timeout(kz_term:ne_binary()) -> non_neg_integer(). timeout() -> kapps_config:get_integer(<<"metaflows">>, <<"digit_timeout_ms">>, ?DEFAULT_DIGIT_TIMEOUT). @@ -91,7 +91,7 @@ timeout(Account) -> end. -spec listen_on() -> 'a' | 'b' | 'ab'. --spec listen_on(ne_binary()) -> 'a' | 'b' | 'ab'. +-spec listen_on(kz_term:ne_binary()) -> 'a' | 'b' | 'ab'. listen_on() -> constrain_listen_on(kapps_config:get_ne_binary(<<"metaflows">>, <<"listen_on">>, ?DEFAULT_LISTEN_ON)). listen_on(Account) -> @@ -101,7 +101,7 @@ listen_on(Account) -> get_attribute(KonamiDoc, <<"listen_on">>, fun listen_on/0, fun constrain_listen_on/1) end. --spec constrain_listen_on(api_binary()) -> 'a' | 'b' | 'ab'. +-spec constrain_listen_on(kz_term:api_binary()) -> 'a' | 'b' | 'ab'. constrain_listen_on(<<"a">>) -> 'a'; constrain_listen_on(<<"b">>) -> 'b'; constrain_listen_on(<<"ab">>) -> 'ab'; @@ -111,8 +111,8 @@ constrain_listen_on(_) -> ?DEFAULT_LISTEN_ON. -spec identity(X) -> X. identity(X) -> X. --spec get_attribute(kz_json:object(), ne_binary(), default_fun()) -> any(). --spec get_attribute(kz_json:object(), ne_binary(), default_fun(), formatter_fun()) -> any(). +-spec get_attribute(kz_json:object(), kz_term:ne_binary(), default_fun()) -> any(). +-spec get_attribute(kz_json:object(), kz_term:ne_binary(), default_fun(), formatter_fun()) -> any(). get_attribute(JObj, K, DefaultFun) -> get_attribute(JObj, K, DefaultFun, fun identity/1). @@ -122,7 +122,7 @@ get_attribute(JObj, K, DefaultFun, FormatterFun) -> V -> FormatterFun(V) end. --spec konami_doc(ne_binary()) -> api_object(). +-spec konami_doc(kz_term:ne_binary()) -> kz_term:api_object(). konami_doc(Account) -> case kz_account:fetch(Account) of {'ok', JObj} -> kz_json:get_value(<<"metaflows">>, JObj); diff --git a/applications/konami/src/konami_event_listener.erl b/applications/konami/src/konami_event_listener.erl index d15bdda1f3f..10e963c60c9 100644 --- a/applications/konami/src/konami_event_listener.erl +++ b/applications/konami/src/konami_event_listener.erl @@ -105,7 +105,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link({'local', ?SERVER} ,?MODULE @@ -118,8 +118,8 @@ start_link() -> ,[] ). --spec bindings() -> [{ne_binary(), atoms() | ne_binaries()}]. --spec bindings(ne_binary()) -> [{ne_binary(), atoms() | ne_binaries()}]. +-spec bindings() -> [{kz_term:ne_binary(), kz_term:atoms() | kz_term:ne_binaries()}]. +-spec bindings(kz_term:ne_binary()) -> [{kz_term:ne_binary(), kz_term:atoms() | kz_term:ne_binaries()}]. bindings() -> [{props:get_value('callid', Props), props:get_value('restrict_to', Props)} || {'call', Props} <- gen_listener:bindings(?SERVER) @@ -131,18 +131,18 @@ bindings(CallId) -> props:get_value('callid', Props) =:= CallId ]. --spec add_konami_binding(api_binary()) -> 'ok'. +-spec add_konami_binding(kz_term:api_binary()) -> 'ok'. add_konami_binding('undefined') -> 'ok'; add_konami_binding(CallId) -> gen_listener:add_binding(?SERVER, ?KONAMI_BINDINGS(CallId)). --spec rm_konami_binding(api_binary()) -> 'ok'. +-spec rm_konami_binding(kz_term:api_binary()) -> 'ok'. rm_konami_binding('undefined') -> 'ok'; rm_konami_binding(<<_/binary>> = CallId) -> gen_listener:rm_binding(?SERVER, ?KONAMI_BINDINGS(CallId)). --spec add_call_binding(api_ne_binary() | kapps_call:call()) -> 'ok'. --spec add_call_binding(api_ne_binary() | kapps_call:call(), ne_binaries() | atoms()) -> 'ok'. +-spec add_call_binding(kz_term:api_ne_binary() | kapps_call:call()) -> 'ok'. +-spec add_call_binding(kz_term:api_ne_binary() | kapps_call:call(), kz_term:ne_binaries() | kz_term:atoms()) -> 'ok'. add_call_binding('undefined') -> 'ok'; add_call_binding(CallId) when is_binary(CallId) -> lager:debug("add fsm binding for call ~s: ~p", [CallId, ?TRACKED_CALL_EVENTS]), @@ -165,7 +165,7 @@ add_call_binding(Call, Events) -> catch gproc:reg(?KONAMI_REG({'pid', kapps_call:account_id(Call)})), add_call_binding(kapps_call:call_id_direct(Call), Events). --spec rm_call_binding(api_ne_binary() | kapps_call:call()) -> 'ok'. +-spec rm_call_binding(kz_term:api_ne_binary() | kapps_call:call()) -> 'ok'. rm_call_binding('undefined') -> 'ok'; rm_call_binding(CallId) -> catch gproc:unreg(?KONAMI_REG({'fsm', CallId})), @@ -174,7 +174,7 @@ rm_call_binding(CallId) -> 'false' -> really_remove_call_bindings(CallId) end. --spec rm_call_binding(api_binary(), ne_binaries()) -> 'ok'. +-spec rm_call_binding(kz_term:api_binary(), kz_term:ne_binaries()) -> 'ok'. rm_call_binding('undefined', _Evts) -> 'ok'; rm_call_binding(CallId, Events) -> catch gproc:unreg(?KONAMI_REG({'pid', CallId})), @@ -183,7 +183,7 @@ rm_call_binding(CallId, Events) -> 'false' -> really_remove_call_bindings(CallId, Events) end. --spec call_has_listeners(ne_binary()) -> boolean(). +-spec call_has_listeners(kz_term:ne_binary()) -> boolean(). call_has_listeners(CallId) -> Self = self(), case {fsms_for_callid(CallId), pids_for_callid(CallId)} of @@ -194,8 +194,8 @@ call_has_listeners(CallId) -> _ -> 'true' end. --spec really_remove_call_bindings(ne_binary()) -> 'ok'. --spec really_remove_call_bindings(ne_binary(), ne_binaries()) -> 'ok'. +-spec really_remove_call_bindings(kz_term:ne_binary()) -> 'ok'. +-spec really_remove_call_bindings(kz_term:ne_binary(), kz_term:ne_binaries()) -> 'ok'. really_remove_call_bindings(CallId) -> really_remove_call_bindings(CallId, ?TRACKED_CALL_EVENTS). @@ -203,7 +203,7 @@ really_remove_call_bindings(CallId, Events) -> gen_listener:rm_binding(?SERVER, ?DYN_BINDINGS(CallId, Events)), gen_listener:rm_binding(?SERVER, ?META_BINDINGS(CallId)). --spec handle_call_event(kz_json:object(), kz_proplist()) -> any(). +-spec handle_call_event(kz_json:object(), kz_term:proplist()) -> any(). handle_call_event(JObj, Props) -> 'true' = kapi_call:event_v(JObj) orelse kapi_dialplan:error_v(JObj), @@ -221,12 +221,12 @@ handle_call_event(JObj, _Props, Event) -> _ = relay_to_fsms(CallId, Event, JObj), relay_to_pids(CallId, JObj). --spec handle_originate_event(kz_json:object(), kz_proplist()) -> any(). +-spec handle_originate_event(kz_json:object(), kz_term:proplist()) -> any(). handle_originate_event(JObj, _Props) -> CallId = kz_json:get_first_defined([<<"Call-ID">>, <<"Outbound-Call-ID">>], JObj), relay_to_pids(CallId, JObj). --spec handle_metaflow_req(kz_json:object(), kz_proplist()) -> any(). +-spec handle_metaflow_req(kz_json:object(), kz_term:proplist()) -> any(). handle_metaflow_req(JObj, _Props) -> 'true' = kapi_metaflow:action_v(JObj), @@ -241,26 +241,26 @@ handle_metaflow_req(JObj, _Props) -> ]), relay_to_fsm(CallId, <<"metaflow_exe">>, Evt). --spec handle_konami(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_konami(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_konami(JObj, _Props) -> handle_konami_api(JObj, kz_json:get_value(<<"Event-Name">>, JObj)). --spec handle_konami_api(kz_json:object(), ne_binary()) -> 'ok'. +-spec handle_konami_api(kz_json:object(), kz_term:ne_binary()) -> 'ok'. handle_konami_api(JObj, <<"transferred">> = Event) -> 'true' = kapi_konami:transferred_v(JObj), Target = kz_json:get_value(<<"Target">>, JObj), relay_to_fsm(Target, Event, JObj). --spec queue_name() -> ne_binary(). +-spec queue_name() -> kz_term:ne_binary(). queue_name() -> gen_listener:queue_name(?SERVER). --spec relay_to_fsms(ne_binary(), ne_binary(), kz_json:object()) -> any(). +-spec relay_to_fsms(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> any(). relay_to_fsms(CallId, Event, JObj) -> [konami_code_statem:event(FSM, CallId, Event, JObj) || FSM <- fsms_for_callid(CallId) ]. --spec fsms_for_callid(api_ne_binary() | '_') -> pids(). +-spec fsms_for_callid(kz_term:api_ne_binary() | '_') -> kz_term:pids(). fsms_for_callid('undefined') -> []; fsms_for_callid(CallId) -> %% {{'p', 'l', Key}, PidToMatch, ValueToMatch} @@ -270,20 +270,20 @@ fsms_for_callid(CallId) -> gproc:select('p', [{MatchHead, Guard, [Result]}]). --spec fsms() -> pids(). +-spec fsms() -> kz_term:pids(). fsms() -> fsms_for_callid('_'). --spec metaflows() -> pids(). +-spec metaflows() -> kz_term:pids(). metaflows() -> pids_for_callid('_'). --spec relay_to_fsm(ne_binary(), ne_binary(), kz_json:object()) -> any(). +-spec relay_to_fsm(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> any(). relay_to_fsm(CallId, Event, JObj) -> [FSM | _] = fsms_for_callid(CallId), konami_code_statem:event(FSM, CallId, Event, JObj). --spec relay_to_pids(ne_binary(), kz_json:object()) -> any(). +-spec relay_to_pids(kz_term:ne_binary(), kz_json:object()) -> any(). relay_to_pids(CallId, JObj) -> [begin kapps_call_command:relay_event(Pid, JObj), @@ -292,7 +292,7 @@ relay_to_pids(CallId, JObj) -> || Pid <- pids_for_callid(CallId) ]. --spec pids_for_callid(ne_binary() | '_') -> pids(). +-spec pids_for_callid(kz_term:ne_binary() | '_') -> kz_term:pids(). pids_for_callid(CallId) -> %% {{'p', 'l', Key}, PidToMatch, ValueToMatch} MatchHead = {?KONAMI_REG({'pid', CallId}), '$1', '_'}, @@ -301,7 +301,7 @@ pids_for_callid(CallId) -> gproc:select('p', [{MatchHead, Guard, [Result]}]). --spec originate(api_terms()) -> 'ok'. +-spec originate(kz_term:api_terms()) -> 'ok'. originate(Req) -> gen_listener:cast(?SERVER, {'originate', Req}). %%%=================================================================== @@ -340,7 +340,7 @@ cleanup_timer() -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -354,7 +354,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'originate', Req}, State) -> catch kapi_resource:publish_originate_req(Req), {'noreply', State}; @@ -380,7 +380,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(?HOOK_EVT(AccountId, <<"CHANNEL_ANSWER">> = EventName, Event), State) -> _ = relay_to_fsms(AccountId, EventName, Event), {'noreply', State}; @@ -398,7 +398,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. @@ -432,8 +432,8 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec cleanup_bindings(server_ref()) -> 'ok'. --spec cleanup_bindings(server_ref(), gen_listener:bindings()) -> 'ok'. +-spec cleanup_bindings(kz_types:server_ref()) -> 'ok'. +-spec cleanup_bindings(kz_types:server_ref(), gen_listener:bindings()) -> 'ok'. cleanup_bindings(Srv) -> kz_util:put_callid(?MODULE), cleanup_bindings(Srv, gen_listener:bindings(Srv)). @@ -443,7 +443,7 @@ cleanup_bindings(Srv, [{Binding, Props}|Bindings]) -> maybe_remove_binding(Srv, Binding, Props, props:get_value('callid', Props)), cleanup_bindings(Srv, Bindings). --spec maybe_remove_binding(server_ref(), atom(), kz_proplist(), api_binary()) -> 'ok'. +-spec maybe_remove_binding(kz_types:server_ref(), atom(), kz_term:proplist(), kz_term:api_binary()) -> 'ok'. maybe_remove_binding(_Srv, _Binding, _Props, 'undefined') -> 'ok'; maybe_remove_binding(Srv, Binding, Props, CallId) -> case {fsms_for_callid(CallId), pids_for_callid(CallId)} of diff --git a/applications/konami/src/konami_listener.erl b/applications/konami/src/konami_listener.erl index 48f1b8d46ce..4875449c46b 100644 --- a/applications/konami/src/konami_listener.erl +++ b/applications/konami/src/konami_listener.erl @@ -55,7 +55,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'bindings', ?BINDINGS} ,{'responders', ?RESPONDERS} @@ -64,7 +64,7 @@ start_link() -> ,{'consume_options', ?CONSUME_OPTIONS} % optional to include ], []). --spec handle_metaflow(kz_json:object(), kz_proplist()) -> no_return(). +-spec handle_metaflow(kz_json:object(), kz_term:proplist()) -> no_return(). handle_metaflow(JObj, Props) -> 'true' = kapi_metaflow:binding_v(JObj), Call = kapps_call:from_json(kz_json:get_value(<<"Call">>, JObj)), @@ -76,7 +76,7 @@ handle_metaflow(JObj, Props) -> ), 'ok'. --spec handle_route_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_route_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_route_req(JObj, _Props) -> 'true' = kapi_route:req_v(JObj), kz_util:put_callid(JObj), @@ -89,7 +89,7 @@ handle_route_req(JObj, _Props) -> ,Call ). --spec handle_channel_create(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_channel_create(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_channel_create(JObj, _Props) -> 'true' = kapi_call:event_v(JObj), kz_util:put_callid(JObj), @@ -102,7 +102,7 @@ handle_channel_create(JObj, _Props) -> ,Call ). --spec maybe_start_metaflows(api_binary(), api_binary(), api_binary(), api_binary(), kapps_call:call()) -> 'ok'. +-spec maybe_start_metaflows(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. maybe_start_metaflows('undefined', _AuthorizingType, _AuthorizingId, _OwnerId, _CallId) -> lager:debug("no account id for ~s(~s) owned by ~s", [_AuthorizingId, _AuthorizingType, _OwnerId]); maybe_start_metaflows(AccountId, <<"device">>, DeviceId, OwnerId, CallId) -> @@ -119,7 +119,7 @@ maybe_start_metaflows(_AccountId, _AuthorizingType, _AuthorizingId, _OwnerId, _C ,[_AccountId, _AuthorizingId, _AuthorizingType, _OwnerId] ). --spec maybe_start_device_metaflows(ne_binary(), api_binary(), kapps_call:call()) -> 'ok'. +-spec maybe_start_device_metaflows(kz_term:ne_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. maybe_start_device_metaflows(_AccountId, 'undefined', _Call) -> 'ok'; maybe_start_device_metaflows(AccountId, DeviceId, Call) -> {'ok', Endpoint} = kz_datamgr:open_cache_doc(kapps_call:account_db(Call) @@ -127,7 +127,7 @@ maybe_start_device_metaflows(AccountId, DeviceId, Call) -> ), maybe_start_metaflows(AccountId, Call, kz_json:get_value(<<"metaflows">>, Endpoint)). --spec maybe_start_user_metaflows(ne_binary(), api_binary(), kapps_call:call()) -> 'ok'. +-spec maybe_start_user_metaflows(kz_term:ne_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. maybe_start_user_metaflows(_AccountId, 'undefined', _Call) -> 'ok'; maybe_start_user_metaflows(AccountId, UserId, Call) -> {'ok', User} = kz_datamgr:open_cache_doc(kapps_call:account_db(Call) @@ -135,7 +135,7 @@ maybe_start_user_metaflows(AccountId, UserId, Call) -> ), maybe_start_metaflows(AccountId, Call, kz_json:get_value(<<"metaflows">>, User)). --spec maybe_start_metaflows(ne_binary(), kapps_call:call(), api_object()) -> 'ok'. +-spec maybe_start_metaflows(kz_term:ne_binary(), kapps_call:call(), kz_term:api_object()) -> 'ok'. maybe_start_metaflows(_AccountId, _Call, 'undefined') -> 'ok'; maybe_start_metaflows(_AccountId, _Call, Metaflows) -> lager:debug("starting ~p", [Metaflows]). @@ -173,7 +173,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -187,7 +187,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _QueueNAme}}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'is_consuming', _IsConsuming}}, State) -> @@ -205,7 +205,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -217,7 +217,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/konami/src/konami_maintenance.erl b/applications/konami/src/konami_maintenance.erl index 95a7bc05f59..af603704205 100644 --- a/applications/konami/src/konami_maintenance.erl +++ b/applications/konami/src/konami_maintenance.erl @@ -15,7 +15,7 @@ -include("konami.hrl"). -record(builder_action, {module_fun_name :: atom() - ,metaflow_key :: ne_binary() + ,metaflow_key :: kz_term:ne_binary() ,builders = [] :: [{pos_integer(), atom()}] }). -type builder_action() :: #builder_action{}. @@ -36,7 +36,7 @@ add_default_metaflow() -> kapps_config:set_default(<<"metaflows">>, <<"default_metaflow">>, JObj) end). --spec add_default_account_metaflow(ne_binary()) -> 'ok'. +-spec add_default_account_metaflow(kz_term:ne_binary()) -> 'ok'. add_default_account_metaflow(AccountId) -> Default = kapps_account_config:get(AccountId, <<"metaflows">>, <<"default_metaflow">>, kz_json:new()), io:format("Welcome to the Default Account Metaflow builder for ~s~n", [AccountId]), @@ -125,11 +125,11 @@ pattern_builder(Default, SaveFun) -> } ). --spec print_builders(kz_proplist()) -> ['ok']. +-spec print_builders(kz_term:proplist()) -> ['ok']. print_builders(Builders) -> [io:format(" ~b. ~s~n", [N, builder_name(M)]) || {N, M} <- Builders]. --spec builder_name(ne_binary() | atom()) -> ne_binary(). +-spec builder_name(kz_term:ne_binary() | atom()) -> kz_term:ne_binary(). builder_name(<<"konami_", Name/binary>>) -> kz_binary:ucfirst(Name); builder_name(<<_/binary>> = Name) -> kz_binary:ucfirst(Name); builder_name(M) -> builder_name(kz_term:to_binary(M)). @@ -183,7 +183,7 @@ invalid_action(Default, SaveFun, BA) -> io:format("invalid option selected~n", []), builder_menu(Default, SaveFun, BA). --spec builder_modules(atom()) -> atoms(). +-spec builder_modules(atom()) -> kz_term:atoms(). builder_modules(F) -> {'ok', Modules} = application:get_key('konami', 'modules'), [M || M <- Modules, is_builder_module(M, F)]. diff --git a/applications/konami/src/konami_sup.erl b/applications/konami/src/konami_sup.erl index a0846087736..a48d7c5fa4c 100644 --- a/applications/konami/src/konami_sup.erl +++ b/applications/konami/src/konami_sup.erl @@ -30,7 +30,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -47,7 +47,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/konami/src/konami_util.erl b/applications/konami/src/konami_util.erl index bd2bf225e9a..9f441645784 100644 --- a/applications/konami/src/konami_util.erl +++ b/applications/konami/src/konami_util.erl @@ -14,7 +14,7 @@ -include("konami.hrl"). --spec listen_on_other_leg(kapps_call:call(), ne_binaries()) -> 'ok'. +-spec listen_on_other_leg(kapps_call:call(), kz_term:ne_binaries()) -> 'ok'. listen_on_other_leg(Call, Events) -> API = [{<<"Application-Name">>, <<"noop">>} ,{<<"B-Leg-Events">>, Events} @@ -24,7 +24,7 @@ listen_on_other_leg(Call, Events) -> lager:debug("sending noop for b leg events"), kapps_call_command:send_command(API, Call). --spec send_hangup_req(ne_binary()) -> 'ok'. +-spec send_hangup_req(kz_term:ne_binary()) -> 'ok'. send_hangup_req(CallId) -> API = [{<<"Call-ID">>, CallId} ,{<<"Action">>, <<"hangup">>} @@ -34,7 +34,7 @@ send_hangup_req(CallId) -> lager:debug("attempting to hangup ~s", [CallId]), kz_amqp_worker:cast(API, fun kapi_metaflow:publish_action/1). --spec send_break_req(ne_binary()) -> 'ok'. +-spec send_break_req(kz_term:ne_binary()) -> 'ok'. send_break_req(CallId) -> API = [{<<"Call-ID">>, CallId} ,{<<"Action">>, <<"break">>} diff --git a/applications/konami/src/module/konami_break.erl b/applications/konami/src/module/konami_break.erl index 0c70f783acc..7fbe718f6c6 100644 --- a/applications/konami/src/module/konami_break.erl +++ b/applications/konami/src/module/konami_break.erl @@ -42,7 +42,7 @@ number_builder(DefaultJObj) -> NumberJObj -> kz_json:set_value(K, NumberJObj, DefaultJObj) end. --spec number_builder_check(api_object()) -> api_object(). +-spec number_builder_check(kz_term:api_object()) -> kz_term:api_object(). number_builder_check('undefined') -> metaflow_jobj(kz_json:new()); number_builder_check(NumberJObj) -> @@ -52,7 +52,7 @@ number_builder_check(NumberJObj) -> {'ok', [Option]} = io:fread("What would you like to do: ", "~s"), number_builder_check_option(NumberJObj, Option). --spec number_builder_check_option(kz_json:object(), string()) -> api_object(). +-spec number_builder_check_option(kz_json:object(), string()) -> kz_term:api_object(). number_builder_check_option(NumberJObj, "e") -> metaflow_jobj(NumberJObj); number_builder_check_option(_NumberJObj, "d") -> diff --git a/applications/konami/src/module/konami_hangup.erl b/applications/konami/src/module/konami_hangup.erl index 81e1caa3ae5..425d65f1ee4 100644 --- a/applications/konami/src/module/konami_hangup.erl +++ b/applications/konami/src/module/konami_hangup.erl @@ -42,7 +42,7 @@ number_builder(DefaultJObj) -> NumberJObj -> kz_json:set_value(K, NumberJObj, DefaultJObj) end. --spec number_builder_check(api_object()) -> api_object(). +-spec number_builder_check(kz_term:api_object()) -> kz_term:api_object(). number_builder_check('undefined') -> metaflow_jobj(kz_json:new()); number_builder_check(NumberJObj) -> @@ -52,7 +52,7 @@ number_builder_check(NumberJObj) -> {'ok', [Option]} = io:fread("What would you like to do: ", "~s"), number_builder_check_option(NumberJObj, Option). --spec number_builder_check_option(kz_json:object(), string()) -> api_object(). +-spec number_builder_check_option(kz_json:object(), string()) -> kz_term:api_object(). number_builder_check_option(NumberJObj, "e") -> metaflow_jobj(NumberJObj); number_builder_check_option(_NumberJObj, "d") -> diff --git a/applications/konami/src/module/konami_hold.erl b/applications/konami/src/module/konami_hold.erl index 25ba559fb7e..71550fc2b78 100644 --- a/applications/konami/src/module/konami_hold.erl +++ b/applications/konami/src/module/konami_hold.erl @@ -42,7 +42,7 @@ handle(Data, Call) -> ), {'continue', Call}. --spec hold_leg(kapps_call:call(), ne_binary()) -> ne_binary(). +-spec hold_leg(kapps_call:call(), kz_term:ne_binary()) -> kz_term:ne_binary(). hold_leg(Call, RequestingLeg) when is_binary(RequestingLeg) -> case kapps_call:call_id(Call) of RequestingLeg -> kapps_call:other_leg_call_id(Call); @@ -62,7 +62,7 @@ number_builder(DefaultJObj) -> NumberJObj -> kz_json:set_value(K, NumberJObj, DefaultJObj) end. --spec number_builder_check(api_object()) -> api_object(). +-spec number_builder_check(kz_term:api_object()) -> kz_term:api_object(). number_builder_check('undefined') -> number_builder_moh(kz_json:new()); number_builder_check(NumberJObj) -> @@ -72,7 +72,7 @@ number_builder_check(NumberJObj) -> {'ok', [Option]} = io:fread("What would you like to do: ", "~s"), number_builder_check_option(NumberJObj, Option). --spec number_builder_check_option(kz_json:object(), string()) -> api_object(). +-spec number_builder_check_option(kz_json:object(), string()) -> kz_term:api_object(). number_builder_check_option(NumberJObj, "e") -> number_builder_moh(NumberJObj); number_builder_check_option(_NumberJObj, "d") -> diff --git a/applications/konami/src/module/konami_intercept.erl b/applications/konami/src/module/konami_intercept.erl index 3ddca75f50f..202b93e6830 100644 --- a/applications/konami/src/module/konami_intercept.erl +++ b/applications/konami/src/module/konami_intercept.erl @@ -42,7 +42,7 @@ maybe_update_metaflow(Data, Call, Results) -> maybe_update_metaflow(Data, Call, Results, CallId) end. --spec maybe_update_metaflow(kz_json:object(), kapps_call:call(), kz_json:objects(), api_binary()) -> +-spec maybe_update_metaflow(kz_json:object(), kapps_call:call(), kz_json:objects(), kz_term:api_binary()) -> {'stop', kapps_call:call()}. maybe_update_metaflow(Data, Call, Results, CallId) -> case [Result || Result <- Results, is_originate_uuid(Result, CallId)] of @@ -55,7 +55,7 @@ maybe_update_metaflow(Data, Call, Results, CallId) -> maybe_update_metaflow_control(Data, Call, CallId, ControlQueue, source_leg_of_dtmf(Data, Call)) end. --spec maybe_update_metaflow_control(kz_json:object(), kapps_call:call(), ne_binary(), ne_binary(), 'a' | 'b') -> +-spec maybe_update_metaflow_control(kz_json:object(), kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary(), 'a' | 'b') -> {'stop', kapps_call:call()}. maybe_update_metaflow_control(_Data, Call, CallId, ControlQueue, 'a') -> lager:debug("update ~s to ~s with ctl ~s", [kapps_call:call_id(Call), CallId, ControlQueue]), @@ -78,7 +78,7 @@ maybe_update_metaflow_control(_Data, Call, CallId, _ControlQueue, 'b') -> {'stop', Call}. --spec source_leg_of_dtmf(ne_binary() | kz_json:object(), kapps_call:call()) -> 'a' | 'b'. +-spec source_leg_of_dtmf(kz_term:ne_binary() | kz_json:object(), kapps_call:call()) -> 'a' | 'b'. source_leg_of_dtmf(<<_/binary>> = SourceDTMF, Call) -> case kapps_call:call_id(Call) =:= SourceDTMF of 'true' -> 'a'; @@ -87,7 +87,7 @@ source_leg_of_dtmf(<<_/binary>> = SourceDTMF, Call) -> source_leg_of_dtmf(Data, Call) -> source_leg_of_dtmf(kz_json:get_value(<<"dtmf_leg">>, Data), Call). --spec get_originate_req(kz_json:object(), kapps_call:call()) -> kz_proplist(). +-spec get_originate_req(kz_json:object(), kapps_call:call()) -> kz_term:proplist(). get_originate_req(Data, Call) -> SourceOfDTMF = kz_json:get_value(<<"dtmf_leg">>, Data), TargetType = kz_json:get_value(<<"target_type">>, Data), @@ -102,7 +102,7 @@ get_originate_req(Data, Call) -> Endpoints = build_endpoints(TargetType, TargetId, SourceDeviceId, Params, Call), build_originate(Endpoints, SourceOfDTMF, UnbridgedOnly, Call). --spec build_endpoints(ne_binary(), ne_binary(), ne_binary(), kz_json:object(), kapps_call:call()) -> kz_json:objects(). +-spec build_endpoints(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), kapps_call:call()) -> kz_json:objects(). build_endpoints(<<"device">>, Id, Id, _Params, _Call) -> lager:debug("skipping ~s since it same source device id", [Id]), []; @@ -129,7 +129,7 @@ build_endpoints(<<"user">>, OwnerId, SourceDeviceId, Params, Call) -> ,kz_attributes:owned_by(OwnerId, <<"device">>, Call) ). --spec build_originate(kz_json:objects(), ne_binary(), boolean(), kapps_call:call()) -> kz_proplist(). +-spec build_originate(kz_json:objects(), kz_term:ne_binary(), boolean(), kapps_call:call()) -> kz_term:proplist(). build_originate([], _CallId, _UnbridgedOnly, _Call) -> []; build_originate(Endpoints, CallId, UnbridgedOnly, Call) -> lager:debug("targeting ~s for intercept", [CallId]), @@ -153,7 +153,7 @@ build_originate(Endpoints, CallId, UnbridgedOnly, Call) -> ] ). --spec send_originate_req(kz_proplist(), kapps_call:call()) -> +-spec send_originate_req(kz_term:proplist(), kapps_call:call()) -> {'ok', kz_json:objects()} | {'timeout', kz_json:objects()} | {'error', any()}. @@ -173,14 +173,14 @@ is_resp([JObj|_]) -> is_resp(JObj) -> kapi_resource:originate_resp_v(JObj). --spec is_originate_uuid(kz_json:object(), api_binary()) -> boolean(). +-spec is_originate_uuid(kz_json:object(), kz_term:api_binary()) -> boolean(). is_originate_uuid(JObj, CallId) -> kapi_resource:originate_uuid_v(JObj) andalso (CallId =:= 'undefined' orelse CallId =:= kz_json:get_value(<<"Outbound-Call-ID">>, JObj) ). --spec find_device_id_for_leg(ne_binary()) -> api_binary(). +-spec find_device_id_for_leg(kz_term:ne_binary()) -> kz_term:api_binary(). find_device_id_for_leg(CallId) -> case kapps_util:amqp_pool_request([{<<"Fields">>, [<<"Authorizing-ID">>]} ,{<<"Call-ID">>, CallId} diff --git a/applications/konami/src/module/konami_move.erl b/applications/konami/src/module/konami_move.erl index 7a548fbd947..461578ac77f 100644 --- a/applications/konami/src/module/konami_move.erl +++ b/applications/konami/src/module/konami_move.erl @@ -40,7 +40,7 @@ maybe_update_metaflow(Data, Call, Results) -> maybe_update_metaflow(Data, Call, Results, CallId) end. --spec maybe_update_metaflow(kz_json:object(), kapps_call:call(), kz_json:objects(), api_binary()) -> +-spec maybe_update_metaflow(kz_json:object(), kapps_call:call(), kz_json:objects(), kz_term:api_binary()) -> {'stop', kapps_call:call()}. maybe_update_metaflow(Data, Call, Results, CallId) -> case [Result || Result <- Results, is_originate_uuid(Result, CallId)] of @@ -53,7 +53,7 @@ maybe_update_metaflow(Data, Call, Results, CallId) -> maybe_update_metaflow_control(Data, Call, CallId, ControlQueue, source_leg_of_dtmf(Data, Call)) end. --spec maybe_update_metaflow_control(kz_json:object(), kapps_call:call(), ne_binary(), ne_binary(), 'a' | 'b') -> +-spec maybe_update_metaflow_control(kz_json:object(), kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary(), 'a' | 'b') -> {'stop', kapps_call:call()}. maybe_update_metaflow_control(_Data, Call, CallId, ControlQueue, 'a') -> lager:debug("update ~s to ~s with ctl ~s", [kapps_call:call_id(Call), CallId, ControlQueue]), @@ -76,7 +76,7 @@ maybe_update_metaflow_control(_Data, Call, CallId, _ControlQueue, 'b') -> {'stop', Call}. --spec source_leg_of_dtmf(ne_binary() | kz_json:object(), kapps_call:call()) -> 'a' | 'b'. +-spec source_leg_of_dtmf(kz_term:ne_binary() | kz_json:object(), kapps_call:call()) -> 'a' | 'b'. source_leg_of_dtmf(<<_/binary>> = SourceDTMF, Call) -> case kapps_call:call_id(Call) =:= SourceDTMF of 'true' -> 'a'; @@ -85,7 +85,7 @@ source_leg_of_dtmf(<<_/binary>> = SourceDTMF, Call) -> source_leg_of_dtmf(Data, Call) -> source_leg_of_dtmf(kz_json:get_value(<<"dtmf_leg">>, Data), Call). --spec get_originate_req(kz_json:object(), kapps_call:call()) -> kz_proplist(). +-spec get_originate_req(kz_json:object(), kapps_call:call()) -> kz_term:proplist(). get_originate_req(Data, Call) -> SourceOfDTMF = kz_json:get_value(<<"dtmf_leg">>, Data), @@ -104,7 +104,7 @@ get_originate_req(Data, Call) -> Endpoints = build_endpoints(SourceDeviceId, OwnerId, Params, Call), build_originate(Endpoints, TargetCallId, Call). --spec build_endpoints(ne_binary(), ne_binary(), kz_json:object(), kapps_call:call()) -> kz_json:objects(). +-spec build_endpoints(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), kapps_call:call()) -> kz_json:objects(). build_endpoints(DeviceId, OwnerId, Params, Call) -> lager:debug("building endpoints against ~s(~s)", [DeviceId, OwnerId]), lists:foldr( @@ -122,7 +122,7 @@ build_endpoints(DeviceId, OwnerId, Params, Call) -> ,kz_attributes:owned_by(OwnerId, <<"device">>, Call) ). --spec build_originate(kz_json:objects(), ne_binary(), kapps_call:call()) -> kz_proplist(). +-spec build_originate(kz_json:objects(), kz_term:ne_binary(), kapps_call:call()) -> kz_term:proplist(). build_originate([], _CallId, _Call) -> []; build_originate(Endpoints, CallId, Call) -> lager:debug("targeting ~s for intercept", [CallId]), @@ -145,7 +145,7 @@ build_originate(Endpoints, CallId, Call) -> ] ). --spec send_originate_req(kz_proplist(), kapps_call:call()) -> +-spec send_originate_req(kz_term:proplist(), kapps_call:call()) -> {'ok', kz_json:objects()} | {'timeout', kz_json:objects()} | {'error', any()}. @@ -165,14 +165,14 @@ is_resp([JObj|_]) -> is_resp(JObj) -> kapi_resource:originate_resp_v(JObj). --spec is_originate_uuid(kz_json:object(), api_binary()) -> boolean(). +-spec is_originate_uuid(kz_json:object(), kz_term:api_binary()) -> boolean(). is_originate_uuid(JObj, CallId) -> kapi_resource:originate_uuid_v(JObj) andalso (CallId =:= 'undefined' orelse CallId =:= kz_json:get_value(<<"Outbound-Call-ID">>, JObj) ). --spec find_device_id_for_leg(ne_binary()) -> api_binary(). +-spec find_device_id_for_leg(kz_term:ne_binary()) -> kz_term:api_binary(). find_device_id_for_leg(CallId) -> case kapps_util:amqp_pool_request([{<<"Fields">>, [<<"Authorizing-ID">>]} ,{<<"Call-ID">>, CallId} diff --git a/applications/konami/src/module/konami_play.erl b/applications/konami/src/module/konami_play.erl index fbd21ba2380..ddd5ab39df7 100644 --- a/applications/konami/src/module/konami_play.erl +++ b/applications/konami/src/module/konami_play.erl @@ -29,7 +29,7 @@ handle(Data, Call) -> end, {'continue', Call}. --spec play(kz_json:object(), kapps_call:call(), ne_binary()) -> any(). +-spec play(kz_json:object(), kapps_call:call(), kz_term:ne_binary()) -> any(). play(Data, Call, Media) -> case kz_json:is_false(<<"answer">>, Data) of 'true' -> 'ok'; @@ -45,7 +45,7 @@ play(Data, Call, Media) -> ,Call ). --spec leg(kz_json:object(), kapps_call:call()) -> ne_binary(). +-spec leg(kz_json:object(), kapps_call:call()) -> kz_term:ne_binary(). leg(Data, Call) -> case kz_json:get_value(<<"dtmf_leg">>, Data) =:= kapps_call:call_id(Call) of 'true' -> @@ -54,7 +54,7 @@ leg(Data, Call) -> play_on(kz_json:get_value(<<"leg">>, Data, <<"both">>), 'b') end. --spec play_on(ne_binary(), 'a' | 'b') -> ne_binary(). +-spec play_on(kz_term:ne_binary(), 'a' | 'b') -> kz_term:ne_binary(). play_on(<<"both">>, _) -> <<"Both">>; play_on(<<"self">>, 'a') -> <<"A">>; play_on(<<"self">>, 'b') -> <<"B">>; @@ -74,7 +74,7 @@ number_builder(DefaultJObj) -> NumberJObj -> kz_json:set_value(K, NumberJObj, DefaultJObj) end. --spec number_builder_check(api_object()) -> api_object(). +-spec number_builder_check(kz_term:api_object()) -> kz_term:api_object(). number_builder_check('undefined') -> number_builder_media(kz_json:new()); number_builder_check(NumberJObj) -> @@ -84,7 +84,7 @@ number_builder_check(NumberJObj) -> {'ok', [Option]} = io:fread("What would you like to do: ", "~s"), number_builder_check_option(NumberJObj, Option). --spec number_builder_check_option(kz_json:object(), string()) -> api_object(). +-spec number_builder_check_option(kz_json:object(), string()) -> kz_term:api_object(). number_builder_check_option(NumberJObj, "e") -> number_builder_media(NumberJObj); number_builder_check_option(_NumberJObj, "d") -> @@ -98,18 +98,18 @@ number_builder_media(NumberJObj) -> {'ok', [Media]} = io:fread("What media file would you like to play? ", "~s"), number_builder_leg(NumberJObj, kz_term:to_binary(Media)). --spec number_builder_leg(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec number_builder_leg(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). number_builder_leg(NumberJObj, Media) -> {'ok', [Leg]} = io:fread("On what leg of the call ('self', 'peer', or 'both')? ", "~s"), metaflow_jobj(NumberJObj, Media, kz_term:to_binary(Leg)). --spec metaflow_jobj(kz_json:object(), ne_binary(), ne_binary()) -> kz_json:object(). +-spec metaflow_jobj(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). metaflow_jobj(NumberJObj, Media, Leg) -> kz_json:set_values([{<<"module">>, <<"play">>} ,{<<"data">>, play_data(Media, Leg)} ], NumberJObj). --spec play_data(ne_binary(), ne_binary()) -> kz_json:object(). +-spec play_data(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). play_data(Media, Leg) -> kz_json:from_list([{<<"id">>, Media} ,{<<"leg">>, Leg} diff --git a/applications/konami/src/module/konami_record_call.erl b/applications/konami/src/module/konami_record_call.erl index 7d9b944720e..c72cfe2a963 100644 --- a/applications/konami/src/module/konami_record_call.erl +++ b/applications/konami/src/module/konami_record_call.erl @@ -22,7 +22,7 @@ -spec handle(kz_json:object(), kapps_call:call()) -> {'continue', kapps_call:call()}. --spec handle(kz_json:object(), kapps_call:call(), ne_binary()) -> +-spec handle(kz_json:object(), kapps_call:call(), kz_term:ne_binary()) -> kapps_call:call(). handle(Data, Call) -> Call1 = handle(Data, Call, get_action(kz_json:get_ne_binary_value(<<"action">>, Data))), @@ -39,7 +39,7 @@ handle(Data, Call, <<"stop">> = Action) -> lager:debug("sent command to stop recording"), Call. --spec get_action(api_ne_binary()) -> ne_binary(). +-spec get_action(kz_term:api_ne_binary()) -> kz_term:ne_binary(). get_action('undefined') -> <<"start">>; get_action(<<"stop">>) -> <<"stop">>; get_action(_) -> <<"start">>. @@ -57,7 +57,7 @@ number_builder(DefaultJObj) -> NumberJObj -> kz_json:set_value(K, NumberJObj, DefaultJObj) end. --spec number_builder_check(api_object()) -> api_object(). +-spec number_builder_check(kz_term:api_object()) -> kz_term:api_object(). number_builder_check('undefined') -> number_builder_action(kz_json:new()); number_builder_check(NumberJObj) -> @@ -67,7 +67,7 @@ number_builder_check(NumberJObj) -> {'ok', [Option]} = io:fread("What would you like to do: ", "~s"), number_builder_check_option(NumberJObj, Option). --spec number_builder_check_option(kz_json:object(), string()) -> api_object(). +-spec number_builder_check_option(kz_json:object(), string()) -> kz_term:api_object(). number_builder_check_option(NumberJObj, "e") -> number_builder_action(NumberJObj); number_builder_check_option(_NumberJObj, "d") -> @@ -81,28 +81,28 @@ number_builder_action(NumberJObj) -> {'ok', [Action]} = io:fread("What action: 'start' or 'stop': ", "~s"), number_builder_time_limit(NumberJObj, kz_term:to_binary(Action)). --spec number_builder_time_limit(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec number_builder_time_limit(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). number_builder_time_limit(NumberJObj, Action) -> {'ok', [TimeLimit]} = io:fread("How many seconds to limit the recording to: ", "~d"), number_builder_format(NumberJObj, Action, TimeLimit). --spec number_builder_format(kz_json:object(), ne_binary(), pos_integer()) -> kz_json:object(). +-spec number_builder_format(kz_json:object(), kz_term:ne_binary(), pos_integer()) -> kz_json:object(). number_builder_format(NumberJObj, Action, TimeLimit) -> {'ok', [Format]} = io:fread("What format would you like the recording? ('wav' or 'mp3'): ", "~3s"), number_builder_url(NumberJObj, Action, TimeLimit, kz_term:to_binary(Format)). --spec number_builder_url(kz_json:object(), ne_binary(), pos_integer(), ne_binary()) -> kz_json:object(). +-spec number_builder_url(kz_json:object(), kz_term:ne_binary(), pos_integer(), kz_term:ne_binary()) -> kz_json:object(). number_builder_url(NumberJObj, Action, TimeLimit, Format) -> {'ok', [URL]} = io:fread("What URL to send the recording to at the end: ", "~s"), metaflow_jobj(NumberJObj, Action, TimeLimit, Format, kz_term:to_binary(URL)). --spec metaflow_jobj(kz_json:object(), ne_binary(), pos_integer(), ne_binary(), ne_binary()) -> kz_json:object(). +-spec metaflow_jobj(kz_json:object(), kz_term:ne_binary(), pos_integer(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). metaflow_jobj(NumberJObj, Action, TimeLimit, Format, URL) -> kz_json:set_values([{<<"module">>, <<"record_call">>} ,{<<"data">>, data(Action, TimeLimit, Format, URL)} ], NumberJObj). --spec data(ne_binary(), pos_integer(), ne_binary(), ne_binary()) -> kz_json:object(). +-spec data(kz_term:ne_binary(), pos_integer(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). data(Action, TimeLimit, Format, URL) -> kz_json:from_list([{<<"action">>, Action} ,{<<"time_limit">>, TimeLimit} diff --git a/applications/konami/src/module/konami_resume.erl b/applications/konami/src/module/konami_resume.erl index 80997455fa6..7ff74883e23 100644 --- a/applications/konami/src/module/konami_resume.erl +++ b/applications/konami/src/module/konami_resume.erl @@ -38,7 +38,7 @@ number_builder(DefaultJObj) -> NumberJObj -> kz_json:set_value(K, NumberJObj, DefaultJObj) end. --spec number_builder_check(api_object()) -> api_object(). +-spec number_builder_check(kz_term:api_object()) -> kz_term:api_object(). number_builder_check('undefined') -> metaflow_jobj(kz_json:new()); number_builder_check(NumberJObj) -> @@ -48,7 +48,7 @@ number_builder_check(NumberJObj) -> {'ok', [Option]} = io:fread("What would you like to do: ", "~s"), number_builder_check_option(NumberJObj, Option). --spec number_builder_check_option(kz_json:object(), string()) -> api_object(). +-spec number_builder_check_option(kz_json:object(), string()) -> kz_term:api_object(). number_builder_check_option(NumberJObj, "e") -> metaflow_jobj(NumberJObj); number_builder_check_option(_NumberJObj, "d") -> diff --git a/applications/konami/src/module/konami_transfer.erl b/applications/konami/src/module/konami_transfer.erl index 605e78b2e8a..5e5f9f661bd 100644 --- a/applications/konami/src/module/konami_transfer.erl +++ b/applications/konami/src/module/konami_transfer.erl @@ -57,21 +57,21 @@ -define(WSD_STOP(), ?WSD_ENABLED andalso webseq:stop(?WSD_ID)). --record(state, {transferor :: api_ne_binary() - ,transferee :: api_ne_binary() - ,target :: api_ne_binary() %% this is the real b-leg, if any - ,target_a_leg :: api_ne_binary() %% loopback-a - ,target_b_leg :: api_ne_binary() %% loopback-b - ,target_legs = [] :: ne_binaries() +-record(state, {transferor :: kz_term:api_ne_binary() + ,transferee :: kz_term:api_ne_binary() + ,target :: kz_term:api_ne_binary() %% this is the real b-leg, if any + ,target_a_leg :: kz_term:api_ne_binary() %% loopback-a + ,target_b_leg :: kz_term:api_ne_binary() %% loopback-b + ,target_legs = [] :: kz_term:ne_binaries() ,call :: kapps_call:call() | 'undefined' ,target_call = kapps_call:new() :: kapps_call:call() - ,takeback_dtmf :: api_ne_binary() + ,takeback_dtmf :: kz_term:api_ne_binary() ,transferor_dtmf = <<>> :: binary() - ,ringback :: api_ne_binary() - ,moh :: api_ne_binary() - ,extension :: api_ne_binary() - ,purgatory_ref :: api_reference() - ,event_node :: api_ne_binary() + ,ringback :: kz_term:api_ne_binary() + ,moh :: kz_term:api_ne_binary() + ,extension :: kz_term:api_ne_binary() + ,purgatory_ref :: kz_term:api_reference() + ,event_node :: kz_term:api_ne_binary() }). -type state() :: #state{}. @@ -144,11 +144,11 @@ handle(Data, Call) -> kz_util:log_stacktrace(ST) end. --spec get_extension(ne_binaries() | ne_binary()) -> ne_binary(). +-spec get_extension(kz_term:ne_binaries() | kz_term:ne_binary()) -> kz_term:ne_binary(). get_extension([Ext|_]) -> Ext; get_extension(<<_/binary>> = Ext) -> Ext. --spec pre_originate(gen_statem:event_type(), any(), state()) -> handle_fsm_ret(state()). +-spec pre_originate(gen_statem:event_type(), any(), state()) -> kz_types:handle_fsm_ret(state()). pre_originate('cast', ?EVENT(UUID, <<"CHANNEL_UNBRIDGE">>, _Evt) ,#state{call=Call ,moh=MOH @@ -185,7 +185,7 @@ pre_originate('cast', ?EVENT(_CallId, _EventName, _Evt), State) -> pre_originate('info', Evt, State) -> handle_info(Evt, ?FUNCTION_NAME, State). --spec attended_wait(gen_statem:event_type(), any(), state()) -> handle_fsm_ret(state()). +-spec attended_wait(gen_statem:event_type(), any(), state()) -> kz_types:handle_fsm_ret(state()). attended_wait('cast', ?EVENT(Transferor, <<"DTMF">>, Evt), #state{transferor=Transferor}=State) -> handle_transferor_dtmf(Evt, 'attended_wait', State); attended_wait('cast', ?EVENT(Transferee, <<"CHANNEL_DESTROY">>, _Evt) @@ -451,7 +451,7 @@ attended_wait('cast', Msg, State) -> attended_wait('info', Evt, State) -> handle_info(Evt, ?FUNCTION_NAME, State). --spec partial_wait(gen_statem:event_type(), any(), state()) -> handle_fsm_ret(state()). +-spec partial_wait(gen_statem:event_type(), any(), state()) -> kz_types:handle_fsm_ret(state()). partial_wait('cast', ?EVENT(Transferee, <<"CHANNEL_BRIDGE">>, Evt) ,#state{transferee=Transferee ,target=Target @@ -603,7 +603,7 @@ partial_wait('cast', Msg, State) -> partial_wait('info', Evt, State) -> handle_info(Evt, ?FUNCTION_NAME, State). --spec attended_answer(gen_statem:event_type(), any(), state()) -> handle_fsm_ret(state()). +-spec attended_answer(gen_statem:event_type(), any(), state()) -> kz_types:handle_fsm_ret(state()). attended_answer('cast', ?EVENT(Transferor, <<"DTMF">>, Evt), #state{transferor=Transferor}=State) -> handle_transferor_dtmf(Evt, 'attended_answer', State); attended_answer('cast', ?EVENT(Transferor, <<"CHANNEL_BRIDGE">>, Evt) @@ -717,7 +717,7 @@ attended_answer('cast', Msg, State) -> attended_answer('info', Evt, State) -> handle_info(Evt, ?FUNCTION_NAME, State). --spec finished(gen_statem:event_type(), any(), state()) -> handle_fsm_ret(state()). +-spec finished(gen_statem:event_type(), any(), state()) -> kz_types:handle_fsm_ret(state()). finished('cast', ?EVENT(Transferor, <<"CHANNEL_BRIDGE">>, Evt) ,#state{transferee=_Transferee ,target=Target @@ -815,7 +815,7 @@ finished('cast', _Msg, State) -> finished('info', Evt, State) -> handle_info(Evt, ?FUNCTION_NAME, State). --spec takeback(gen_statem:event_type(), any(), state()) -> handle_fsm_ret(state()). +-spec takeback(gen_statem:event_type(), any(), state()) -> kz_types:handle_fsm_ret(state()). takeback('cast', ?EVENT(Transferor, <<"CHANNEL_UNBRIDGE">>, _Evt) ,#state{transferor=Transferor ,call=Call @@ -934,7 +934,7 @@ takeback('cast', _Msg, State) -> takeback('info', Evt, State) -> handle_info(Evt, ?FUNCTION_NAME, State). --spec handle_info(any(), atom(), state()) -> handle_fsm_ret(state()). +-spec handle_info(any(), atom(), state()) -> kz_types:handle_fsm_ret(state()). handle_info({'amqp_msg', JObj}, StateName, #state{event_node='undefined'}=State) -> send_event(JObj), {'next_state', StateName, State}; @@ -1017,15 +1017,15 @@ init(_) -> {'ok', 'attended_wait', #state{}}. callback_mode() -> 'state_functions'. --spec add_transferor_bindings(ne_binary()) -> 'ok'. +-spec add_transferor_bindings(kz_term:ne_binary()) -> 'ok'. add_transferor_bindings(CallId) -> konami_event_listener:add_call_binding(CallId, ?TRANSFEROR_CALL_EVENTS). --spec add_transferee_bindings(ne_binary()) -> 'ok'. +-spec add_transferee_bindings(kz_term:ne_binary()) -> 'ok'. add_transferee_bindings(CallId) -> konami_event_listener:add_call_binding(CallId, ?TRANSFEREE_CALL_EVENTS). --spec originate_to_extension(ne_binary(), ne_binary(), kapps_call:call()) -> ne_binary(). +-spec originate_to_extension(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> kz_term:ne_binary(). originate_to_extension(Extension, TransferorLeg, Call) -> MsgId = kz_binary:rand_hex(4), CallerIdNumber = caller_id_number(Call, TransferorLeg), @@ -1085,31 +1085,31 @@ originate_to_extension(Extension, TransferorLeg, Call) -> konami_event_listener:originate(Request), TargetCallId. --spec create_call_id() -> ne_binary(). +-spec create_call_id() -> kz_term:ne_binary(). create_call_id() -> TargetCallId = <<"konami-transfer-", (kz_binary:rand_hex(4))/binary>>, bind_target_call_events(TargetCallId), TargetCallId. --spec bind_target_call_events(ne_binary()) -> 'ok'. +-spec bind_target_call_events(kz_term:ne_binary()) -> 'ok'. bind_target_call_events(CallId) -> konami_event_listener:add_call_binding(CallId, ?TARGET_CALL_EVENTS). --spec caller_id_name(kapps_call:call(), ne_binary()) -> ne_binary(). +-spec caller_id_name(kapps_call:call(), kz_term:ne_binary()) -> kz_term:ne_binary(). caller_id_name(Call, CallerLeg) -> case kapps_call:call_id(Call) of CallerLeg -> kapps_call:caller_id_name(Call); _CalleeLeg -> kapps_call:callee_id_name(Call) end. --spec caller_id_number(kapps_call:call(), ne_binary()) -> ne_binary(). +-spec caller_id_number(kapps_call:call(), kz_term:ne_binary()) -> kz_term:ne_binary(). caller_id_number(Call, CallerLeg) -> case kapps_call:call_id_direct(Call) of CallerLeg -> kapps_call:caller_id_number(Call); _CalleeLeg -> kapps_call:callee_id_number(Call) end. --spec connect_transferee_to_target(ne_binary(), kapps_call:call()) -> 'ok'. +-spec connect_transferee_to_target(kz_term:ne_binary(), kapps_call:call()) -> 'ok'. connect_transferee_to_target(Target, Call) -> issue_transferee_event(Target, Call), Flags = [{<<"Target-Call-ID">>, Target} @@ -1123,7 +1123,7 @@ connect_transferee_to_target(Target, Call) -> konami_util:listen_on_other_leg(Call, ?TARGET_CALL_EVENTS), connect(Flags, Call). --spec connect_transferor_to_target(ne_binary(), kapps_call:call()) -> 'ok'. +-spec connect_transferor_to_target(kz_term:ne_binary(), kapps_call:call()) -> 'ok'. connect_transferor_to_target(Transferor, TargetCall) -> Flags = [{<<"Target-Call-ID">>, Transferor} ,{<<"Continue-On-Fail">>, 'true'} @@ -1153,7 +1153,7 @@ connect_to_transferee(Call) -> ]), connect(Flags, Call). --spec connect(kz_proplist(), kapps_call:call()) -> 'ok'. +-spec connect(kz_term:proplist(), kapps_call:call()) -> 'ok'. connect(Flags, Call) -> Command = [{<<"Application-Name">>, <<"connect_leg">>} ,{<<"Call-ID">>, kapps_call:call_id(Call)} @@ -1196,7 +1196,7 @@ handle_transferor_dtmf(Evt end. -spec unbridge(kapps_call:call()) -> 'ok'. --spec unbridge(kapps_call:call(), ne_binary()) -> 'ok'. +-spec unbridge(kapps_call:call(), kz_term:ne_binary()) -> 'ok'. unbridge(Call) -> unbridge(Call, kapps_call:call_id(Call)). unbridge(Call, CallId) -> @@ -1229,7 +1229,7 @@ pattern_builder_regex(DefaultJObj) -> pattern_builder_regex(DefaultJObj) end. --spec pattern_builder_check(api_object()) -> api_object(). +-spec pattern_builder_check(kz_term:api_object()) -> kz_term:api_object(). pattern_builder_check('undefined') -> builder_takeback_dtmf(kz_json:new(), 'undefined'); pattern_builder_check(PatternJObj) -> @@ -1257,7 +1257,7 @@ number_builder(DefaultJObj) -> NumberJObj -> kz_json:set_value(K, NumberJObj, DefaultJObj) end. --spec number_builder_check(api_object()) -> api_object(). +-spec number_builder_check(kz_term:api_object()) -> kz_term:api_object(). number_builder_check('undefined') -> builder_target(kz_json:new()); number_builder_check(NumberJObj) -> @@ -1271,10 +1271,10 @@ number_builder_check(NumberJObj) -> ,fun builder_target/1 ). --type check_fun() :: fun((api_object()) -> api_object()). +-type check_fun() :: fun((kz_term:api_object()) -> kz_term:api_object()). -type build_fun() :: fun((kz_json:object()) -> kz_json:object()). --spec builder_check_option(kz_json:object(), string(), check_fun(), build_fun()) -> api_object(). +-spec builder_check_option(kz_json:object(), string(), check_fun(), build_fun()) -> kz_term:api_object(). builder_check_option(JObj, "e", _CheckFun, BuilderFun) -> BuilderFun(JObj); builder_check_option(_JObj, "d", _CheckFun, _BuilderFun) -> @@ -1288,17 +1288,17 @@ builder_target(JObj) -> {'ok', [Target]} = io:fread("What is the target extension/DID to transfer to? ", "~s"), builder_takeback_dtmf(JObj, kz_term:to_binary(Target)). --spec builder_takeback_dtmf(kz_json:object(), api_binary()) -> kz_json:object(). +-spec builder_takeback_dtmf(kz_json:object(), kz_term:api_binary()) -> kz_json:object(). builder_takeback_dtmf(JObj, Target) -> {'ok', [Takeback]} = io:fread("What is the takeback DTMF ('n' to use the default)? ", "~s"), builder_moh(JObj, Target, kz_term:to_binary(Takeback)). --spec builder_moh(kz_json:object(), api_binary(), ne_binary()) -> kz_json:object(). +-spec builder_moh(kz_json:object(), kz_term:api_binary(), kz_term:ne_binary()) -> kz_json:object(). builder_moh(JObj, Target, Takeback) -> {'ok', [MOH]} = io:fread("Any custom music-on-hold ('n' for none, 'h' for help')? ", "~s"), metaflow_jobj(JObj, Target, Takeback, kz_term:to_binary(MOH)). --spec metaflow_jobj(kz_json:object(), api_binary(), api_binary(), api_binary()) -> kz_json:object(). +-spec metaflow_jobj(kz_json:object(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary()) -> kz_json:object(). metaflow_jobj(JObj, Target, Takeback, <<"h">>) -> io:format("To set a system_media file as MOH, enter: /system_media/{MEDIA_ID}~n", []), io:format("To set an account's media file as MOH, enter: /{ACCOUNT_ID}/{MEDIA_ID}~n", []), @@ -1309,7 +1309,7 @@ metaflow_jobj(JObj, Target, Takeback, MOH) -> ,{<<"data">>, transfer_data(Target, Takeback, MOH)} ], JObj). --spec transfer_data(api_binary(), api_binary(), api_binary()) -> kz_json:object(). +-spec transfer_data(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary()) -> kz_json:object(). transfer_data(Target, Takeback, <<"n">>) -> transfer_data(Target, Takeback, 'undefined'); transfer_data(Target, <<"n">>, MOH) -> @@ -1321,8 +1321,8 @@ transfer_data(Target, Takeback, MOH) -> ,{<<"moh">>, MOH} ]). --spec find_moh(kz_json:object(), kapps_call:call()) -> api_binary(). --spec find_moh(kapps_call:call()) -> api_binary(). +-spec find_moh(kz_json:object(), kapps_call:call()) -> kz_term:api_binary(). +-spec find_moh(kapps_call:call()) -> kz_term:api_binary(). find_moh(Data, Call) -> case kz_json:get_value(<<"moh">>, Data) of 'undefined' -> find_moh(Call); @@ -1332,7 +1332,7 @@ find_moh(Call) -> {'ok', JObj} = kz_account:fetch(kapps_call:account_id(Call)), kz_json:get_value([<<"music_on_hold">>, <<"media_id">>], JObj). --spec issue_transferee_event(ne_binary(), kapps_call:call()) -> 'ok'. +-spec issue_transferee_event(kz_term:ne_binary(), kapps_call:call()) -> 'ok'. issue_transferee_event(Target, Call) -> kapi_call:publish_event( [{<<"Event-Name">>, <<"CHANNEL_TRANSFEREE">>} @@ -1353,8 +1353,8 @@ issue_transferee_event(Target, Call) -> %% We need to figure out which kapps call to issue the connect_leg against %% When the A-leg is the transferor, its ecallmgr control will be down at this %% point so use Target's call record; otherwise use the A-leg's. --spec how_to_transfer(kapps_call:call(), kapps_call:call(), ne_binary(), ne_binary(), ne_binary()) -> - {ne_binary(), kapps_call:call()}. +-spec how_to_transfer(kapps_call:call(), kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> + {kz_term:ne_binary(), kapps_call:call()}. how_to_transfer(OriginalCall, TargetCall, Transferor, Target, Transferee) -> case kapps_call:call_id(OriginalCall) of Transferor -> @@ -1371,23 +1371,23 @@ hangup_target(Call) -> ?WSD_NOTE(kapps_call:call_id(Call), 'right', <<"hangup sent">>), kapps_call_command:hangup(Call). --spec to_tonestream(api_binary()) -> api_binary(). +-spec to_tonestream(kz_term:api_binary()) -> kz_term:api_binary(). to_tonestream('undefined') -> 'undefined'; to_tonestream(<<"tone_stream://", _/binary>> = TS) -> <>; to_tonestream(Ringback) -> <<"tone_stream://", Ringback/binary, ";loops=-1">>. --spec maybe_start_transferor_ringback(kapps_call:call(), ne_binary(), api_binary()) -> 'ok'. +-spec maybe_start_transferor_ringback(kapps_call:call(), kz_term:ne_binary(), kz_term:api_binary()) -> 'ok'. maybe_start_transferor_ringback(_Call, _Transferor, 'undefined') -> 'ok'; maybe_start_transferor_ringback(Call, Transferor, Ringback) -> Command = kapps_call_command:play_command(Ringback, Transferor), lager:debug("playing ringback on ~s to ~s", [Transferor, Ringback]), kapps_call_command:send_command(kz_json:set_values([{<<"Insert-At">>, <<"now">>}], Command), Call). --spec maybe_cancel_timer(api_reference()) -> 'ok'. +-spec maybe_cancel_timer(kz_term:api_reference()) -> 'ok'. maybe_cancel_timer('undefined') -> 'ok'; maybe_cancel_timer(Ref) -> erlang:cancel_timer(Ref). --spec suppress_event(kz_json:object(), api_binary(), ne_binary()) -> 'ok'. +-spec suppress_event(kz_json:object(), kz_term:api_binary(), kz_term:ne_binary()) -> 'ok'. suppress_event(JObj, _EventNode, _OtherNode) -> lager:debug("supressing event ~s from ~s (we want events from ~s): ~s" ,[kz_call_event:event_name(JObj) @@ -1397,8 +1397,8 @@ suppress_event(JObj, _EventNode, _OtherNode) -> ]). -type connect_to() :: 'transferee' | 'transferor'. --spec handle_real_target(state(), ne_binary()) -> state(). --spec handle_real_target(state(), ne_binary(), connect_to()) -> state(). +-spec handle_real_target(state(), kz_term:ne_binary()) -> state(). +-spec handle_real_target(state(), kz_term:ne_binary(), connect_to()) -> state(). handle_real_target(State, ReplacementId) -> handle_real_target(State, ReplacementId, 'transferor'). diff --git a/applications/media_mgr/src/media_listener.erl b/applications/media_mgr/src/media_listener.erl index d0ae7adcbc5..da8bf04fa5f 100644 --- a/applications/media_mgr/src/media_listener.erl +++ b/applications/media_mgr/src/media_listener.erl @@ -39,7 +39,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'bindings', [{'media', []}]} ,{'responders', [{{?MODULE, 'handle_media_req'} @@ -47,7 +47,7 @@ start_link() -> ]} ], []). --spec handle_media_req(kz_json:object(), kz_proplist()) -> kz_amqp_worker:cast_return(). +-spec handle_media_req(kz_json:object(), kz_term:proplist()) -> kz_amqp_worker:cast_return(). handle_media_req(JObj, _Props) -> 'true' = kapi_media:req_v(JObj), _ = kz_util:put_callid(JObj), @@ -92,7 +92,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_supported'}, State}. @@ -106,7 +106,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> {'noreply', State}. @@ -120,7 +120,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -158,7 +158,7 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec send_error_resp(kz_json:object(), atom() | ne_binary()) -> +-spec send_error_resp(kz_json:object(), atom() | kz_term:ne_binary()) -> kz_amqp_worker:cast_return(). send_error_resp(JObj, ErrMsg) -> MediaName = kz_json:get_value(<<"Media-Name">>, JObj), @@ -173,7 +173,7 @@ send_error_resp(JObj, ErrMsg) -> Publisher = fun(P) -> kapi_media:publish_error(ServerId, P) end, kz_amqp_worker:cast(Error, Publisher). --spec send_media_resp(kz_json:object(), ne_binary()) -> +-spec send_media_resp(kz_json:object(), kz_term:ne_binary()) -> kz_amqp_worker:cast_return(). send_media_resp(JObj, StreamURL) -> lager:debug("media stream URL: ~s", [StreamURL]), diff --git a/applications/media_mgr/src/media_mgr_app.erl b/applications/media_mgr/src/media_mgr_app.erl index ae73d3f2731..6c158f0238a 100644 --- a/applications/media_mgr/src/media_mgr_app.erl +++ b/applications/media_mgr/src/media_mgr_app.erl @@ -22,7 +22,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = declare_exchanges(), media_mgr_sup:start_link(). diff --git a/applications/media_mgr/src/media_mgr_maintenance.erl b/applications/media_mgr/src/media_mgr_maintenance.erl index 946692f8122..c3c21421a65 100644 --- a/applications/media_mgr/src/media_mgr_maintenance.erl +++ b/applications/media_mgr/src/media_mgr_maintenance.erl @@ -12,9 +12,9 @@ -include("media.hrl"). --spec prompt_url(ne_binary()) -> 'ok'. --spec prompt_url(ne_binary(), ne_binary()) -> 'ok'. --spec prompt_url(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec prompt_url(kz_term:ne_binary()) -> 'ok'. +-spec prompt_url(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. +-spec prompt_url(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. prompt_url(PromptId) -> AccountId = ?KZ_MEDIA_DB, diff --git a/applications/media_mgr/src/media_mgr_sup.erl b/applications/media_mgr/src/media_mgr_sup.erl index f5bbf666f62..22fabeb06fd 100644 --- a/applications/media_mgr/src/media_mgr_sup.erl +++ b/applications/media_mgr/src/media_mgr_sup.erl @@ -27,7 +27,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -44,7 +44,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/milliwatt/src/milliwatt_app.erl b/applications/milliwatt/src/milliwatt_app.erl index 9fd0959f7ec..e2203d28fa2 100644 --- a/applications/milliwatt/src/milliwatt_app.erl +++ b/applications/milliwatt/src/milliwatt_app.erl @@ -18,7 +18,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = declare_exchanges(), milliwatt_sup:start_link(). diff --git a/applications/milliwatt/src/milliwatt_listener.erl b/applications/milliwatt/src/milliwatt_listener.erl index 911d477858f..70ac74dfddd 100644 --- a/applications/milliwatt/src/milliwatt_listener.erl +++ b/applications/milliwatt/src/milliwatt_listener.erl @@ -42,7 +42,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'bindings', ?BINDINGS} ,{'responders', ?RESPONDERS} @@ -84,7 +84,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -98,7 +98,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> {'noreply', State}. @@ -112,7 +112,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -124,7 +124,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/milliwatt/src/milliwatt_route_req.erl b/applications/milliwatt/src/milliwatt_route_req.erl index 2a0be18b6fe..b2c2c899819 100644 --- a/applications/milliwatt/src/milliwatt_route_req.erl +++ b/applications/milliwatt/src/milliwatt_route_req.erl @@ -24,7 +24,7 @@ -define(ROUTE_WIN_TIMEOUT_KEY, <<"route_win_timeout">>). -define(ROUTE_WIN_TIMEOUT, kapps_config:get_integer(?CONFIG_CAT, ?ROUTE_WIN_TIMEOUT_KEY, ?DEFAULT_ROUTE_WIN_TIMEOUT)). --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Props) -> 'true' = kapi_route:req_v(JObj), CallId = kz_json:get_value(<<"Call-ID">>, JObj), @@ -90,7 +90,7 @@ tone_or_echo(Call) -> maybe_echo_maybe_tone(Echo, Tone, To, From) end. --spec maybe_echo(kz_json:object(), ne_binary(), ne_binary()) -> +-spec maybe_echo(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'undefined' | 'echo'. maybe_echo(Echo, To, From) -> case rule_exist(Echo, To, From) of @@ -98,7 +98,7 @@ maybe_echo(Echo, To, From) -> 'false' -> 'undefined' end. --spec maybe_tone(kz_json:object(), ne_binary(), ne_binary()) -> +-spec maybe_tone(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'undefined' | 'tone'. maybe_tone(Tone, To, From) -> case rule_exist(Tone, To, From) of @@ -106,7 +106,7 @@ maybe_tone(Tone, To, From) -> 'false' -> 'undefined' end. --spec maybe_echo_maybe_tone(kz_json:object(), kz_json:object(), ne_binary(), ne_binary()) -> +-spec maybe_echo_maybe_tone(kz_json:object(), kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'undefined' | 'tone' | 'echo'. maybe_echo_maybe_tone(Echo, Tone, To, From) -> case {rule_exist(Echo, To, From) @@ -121,7 +121,7 @@ maybe_echo_maybe_tone(Echo, Tone, To, From) -> _ -> 'undefined' end. --spec rule_exist(kz_json:object(), ne_binary(), ne_binary()) -> boolean(). +-spec rule_exist(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). rule_exist(JObj, To, From) -> CallerIds = kz_json:get_ne_value(<<"caller_id">>, JObj, []), Numbers = kz_json:get_ne_value(<<"number">>, JObj, []), diff --git a/applications/milliwatt/src/milliwatt_sup.erl b/applications/milliwatt/src/milliwatt_sup.erl index 0001043256f..a6493eb3c90 100644 --- a/applications/milliwatt/src/milliwatt_sup.erl +++ b/applications/milliwatt/src/milliwatt_sup.erl @@ -27,7 +27,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -44,7 +44,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/notify/src/notify.hrl b/applications/notify/src/notify.hrl index fe26217da06..1a26b55d51d 100644 --- a/applications/notify/src/notify.hrl +++ b/applications/notify/src/notify.hrl @@ -12,7 +12,7 @@ -define(APP_NAME, <<"notify">>). -define(APP, 'notify'). --type respond_to() :: {api_binary(), ne_binary()}. +-type respond_to() :: {kz_term:api_binary(), kz_term:ne_binary()}. -type send_email_return() :: 'ok' | {'error', any()} | ['ok' | {'error', any()}]. -define(NOTIFY_HRL, true). diff --git a/applications/notify/src/notify_app.erl b/applications/notify/src/notify_app.erl index e6034e6ccf8..bb551db60ba 100644 --- a/applications/notify/src/notify_app.erl +++ b/applications/notify/src/notify_app.erl @@ -19,7 +19,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_StartType, _StartArgs) -> _ = declare_exchanges(), notify_sup:start_link(). diff --git a/applications/notify/src/notify_cnam_request.erl b/applications/notify/src/notify_cnam_request.erl index af329935dea..1fec063016f 100644 --- a/applications/notify/src/notify_cnam_request.erl +++ b/applications/notify/src/notify_cnam_request.erl @@ -41,7 +41,7 @@ init() -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Props) -> true = kapi_notifications:cnam_request_v(JObj), _ = kz_util:put_callid(JObj), @@ -83,7 +83,7 @@ handle_req(JObj, _Props) -> %% create the props used by the template render function %% @end %%-------------------------------------------------------------------- --spec create_template_props(kz_json:object(), kz_json:object()) -> kz_proplist(). +-spec create_template_props(kz_json:object(), kz_json:object()) -> kz_term:proplist(). create_template_props(Event, Account) -> Admin = notify_util:find_admin(Account), [{<<"request">>, notify_util:json_to_template_props(Event)} @@ -98,7 +98,7 @@ create_template_props(Event, Account) -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec build_and_send_email(iolist(), iolist(), iolist(), ne_binary() | ne_binaries(), kz_proplist()) -> send_email_return(). +-spec build_and_send_email(iolist(), iolist(), iolist(), kz_term:ne_binary() | kz_term:ne_binaries(), kz_term:proplist()) -> send_email_return(). build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) when is_list(To)-> [build_and_send_email(TxtBody, HTMLBody, Subject, T, Props) || T <- To]; build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) -> diff --git a/applications/notify/src/notify_deregister.erl b/applications/notify/src/notify_deregister.erl index 46aa8c62dcf..902fcc21498 100644 --- a/applications/notify/src/notify_deregister.erl +++ b/applications/notify/src/notify_deregister.erl @@ -43,7 +43,7 @@ init() -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec handle_req(kz_json:object(), kz_proplist()) -> any(). +-spec handle_req(kz_json:object(), kz_term:proplist()) -> any(). handle_req(JObj, _Props) -> true = kapi_notifications:deregister_v(JObj), _ = kz_util:put_callid(JObj), @@ -83,7 +83,7 @@ handle_req(JObj, _Props) -> %% create the props used by the template render function %% @end %%-------------------------------------------------------------------- --spec create_template_props(kz_json:object(), kz_json:object()) -> kz_proplist(). +-spec create_template_props(kz_json:object(), kz_json:object()) -> kz_term:proplist(). create_template_props(Event, Account) -> [{<<"last_registration">>, notify_util:json_to_template_props(Event)} ,{<<"account">>, notify_util:json_to_template_props(Account)} @@ -96,7 +96,7 @@ create_template_props(Event, Account) -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec build_and_send_email(iolist(), iolist(), iolist(), ne_binary() | ne_binaries(), kz_proplist()) -> send_email_return(). +-spec build_and_send_email(iolist(), iolist(), iolist(), kz_term:ne_binary() | kz_term:ne_binaries(), kz_term:proplist()) -> send_email_return(). build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) when is_list(To) -> [build_and_send_email(TxtBody, HTMLBody, Subject, T, Props) || T <- To]; build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) -> diff --git a/applications/notify/src/notify_fax_inbound_error_to_email.erl b/applications/notify/src/notify_fax_inbound_error_to_email.erl index faf80e7c131..efdc8b52c63 100644 --- a/applications/notify/src/notify_fax_inbound_error_to_email.erl +++ b/applications/notify/src/notify_fax_inbound_error_to_email.erl @@ -28,7 +28,7 @@ init() -> {'ok', _} = notify_util:compile_default_subject_template(?DEFAULT_SUBJ_TMPL, ?MOD_CONFIG_CAT), lager:debug("init done for ~s", [?MODULE]). --spec handle_req(kz_json:object(), kz_proplist()) -> any(). +-spec handle_req(kz_json:object(), kz_term:proplist()) -> any(). handle_req(JObj, _Props) -> 'true' = kapi_notifications:fax_inbound_error_v(JObj), _ = kz_util:put_callid(JObj), @@ -101,7 +101,7 @@ is_notice_enabled_default() -> %% create the props used by the template render function %% @end %%-------------------------------------------------------------------- --spec create_template_props(kz_json:object(), kz_json:objects(), kz_json:object()) -> kz_proplist(). +-spec create_template_props(kz_json:object(), kz_json:objects(), kz_json:object()) -> kz_term:proplist(). create_template_props(Event, Docs, Account) -> Now = kz_time:now_s(), @@ -151,7 +151,7 @@ fax_values(Event) -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec build_and_send_email(iolist(), iolist(), iolist(), ne_binary() | ne_binaries(), kz_proplist()) -> send_email_return(). +-spec build_and_send_email(iolist(), iolist(), iolist(), kz_term:ne_binary() | kz_term:ne_binaries(), kz_term:proplist()) -> send_email_return(). build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) when is_list(To) -> [build_and_send_email(TxtBody, HTMLBody, Subject, T, Props) || T <- To]; build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) -> diff --git a/applications/notify/src/notify_fax_inbound_to_email.erl b/applications/notify/src/notify_fax_inbound_to_email.erl index 64a00954a78..d53ff6e8f1f 100644 --- a/applications/notify/src/notify_fax_inbound_to_email.erl +++ b/applications/notify/src/notify_fax_inbound_to_email.erl @@ -28,7 +28,7 @@ init() -> {'ok', _} = notify_util:compile_default_subject_template(?DEFAULT_SUBJ_TMPL, ?MOD_CONFIG_CAT), lager:debug("init done for ~s", [?MODULE]). --spec handle_req(kz_json:object(), kz_proplist()) -> any(). +-spec handle_req(kz_json:object(), kz_term:proplist()) -> any(). handle_req(JObj, _Props) -> 'true' = kapi_notifications:fax_inbound_v(JObj), @@ -80,7 +80,7 @@ handle_req(JObj, _Props) -> %% create the props used by the template render function %% @end %%-------------------------------------------------------------------- --spec create_template_props(kz_json:object(), kz_json:objects(), kz_json:object()) -> kz_proplist(). +-spec create_template_props(kz_json:object(), kz_json:objects(), kz_json:object()) -> kz_term:proplist(). create_template_props(Event, [FaxDoc | _Others]=_Docs, Account) -> Now = kz_time:now_s(), @@ -125,7 +125,7 @@ fax_values(Event) -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec build_and_send_email(iolist(), iolist(), iolist(), ne_binary() | ne_binaries(), kz_proplist()) -> send_email_return(). +-spec build_and_send_email(iolist(), iolist(), iolist(), kz_term:ne_binary() | kz_term:ne_binaries(), kz_term:proplist()) -> send_email_return(). build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) when is_list(To) -> [build_and_send_email(TxtBody, HTMLBody, Subject, T, Props) || T <- To]; build_and_send_email(_TxtBody, _HTMLBody, _Subject, 'undefined', _Props) -> diff --git a/applications/notify/src/notify_fax_outbound_error_to_email.erl b/applications/notify/src/notify_fax_outbound_error_to_email.erl index 6f63d5c7368..6efd139794c 100644 --- a/applications/notify/src/notify_fax_outbound_error_to_email.erl +++ b/applications/notify/src/notify_fax_outbound_error_to_email.erl @@ -28,7 +28,7 @@ init() -> {'ok', _} = notify_util:compile_default_subject_template(?DEFAULT_SUBJ_TMPL, ?MOD_CONFIG_CAT), lager:debug("init done for ~s", [?MODULE]). --spec handle_req(kz_json:object(), kz_proplist()) -> any(). +-spec handle_req(kz_json:object(), kz_term:proplist()) -> any(). handle_req(JObj, _Props) -> 'true' = kapi_notifications:fax_outbound_error_v(JObj), _ = kz_util:put_callid(JObj), @@ -102,7 +102,7 @@ is_notice_enabled_default() -> %% create the props used by the template render function %% @end %%-------------------------------------------------------------------- --spec create_template_props(kz_json:object(), kz_json:objects(), kz_json:object()) -> kz_proplist(). +-spec create_template_props(kz_json:object(), kz_json:objects(), kz_json:object()) -> kz_term:proplist(). create_template_props(Event, Docs, Account) -> Now = kz_time:now_s(), @@ -152,7 +152,7 @@ fax_values(Event) -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec build_and_send_email(iolist(), iolist(), iolist(), ne_binary() | ne_binaries(), kz_proplist()) -> send_email_return(). +-spec build_and_send_email(iolist(), iolist(), iolist(), kz_term:ne_binary() | kz_term:ne_binaries(), kz_term:proplist()) -> send_email_return(). build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) when is_list(To) -> [build_and_send_email(TxtBody, HTMLBody, Subject, T, Props) || T <- To]; build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) -> diff --git a/applications/notify/src/notify_fax_outbound_to_email.erl b/applications/notify/src/notify_fax_outbound_to_email.erl index 101c611d4fc..83efa12bef4 100644 --- a/applications/notify/src/notify_fax_outbound_to_email.erl +++ b/applications/notify/src/notify_fax_outbound_to_email.erl @@ -28,7 +28,7 @@ init() -> {'ok', _} = notify_util:compile_default_subject_template(?DEFAULT_SUBJ_TMPL, ?MOD_CONFIG_CAT), lager:debug("init done for ~s", [?MODULE]). --spec handle_req(kz_json:object(), kz_proplist()) -> any(). +-spec handle_req(kz_json:object(), kz_term:proplist()) -> any(). handle_req(JObj, _Props) -> true = kapi_notifications:fax_outbound_v(JObj), _ = kz_util:put_callid(JObj), @@ -54,7 +54,7 @@ handle_req(JObj, _Props) -> end, notify_util:maybe_send_update(SendResult, RespQ, MsgId). --spec process_req(kzd_fax:doc(), kz_json:object(), kz_proplist()) -> send_email_return(). +-spec process_req(kzd_fax:doc(), kz_json:object(), kz_term:proplist()) -> send_email_return(). process_req(FaxDoc, JObj, _Props) -> Emails = kz_json:get_value([<<"notifications">>,<<"email">>,<<"send_to">>], FaxDoc, []), AccountId = kz_json:get_value(<<"Account-ID">>, JObj), @@ -96,7 +96,7 @@ process_req(FaxDoc, JObj, _Props) -> %% create the props used by the template render function %% @end %%-------------------------------------------------------------------- --spec create_template_props(kz_json:object(), kz_json:objects(), kz_json:object()) -> kz_proplist(). +-spec create_template_props(kz_json:object(), kz_json:objects(), kz_json:object()) -> kz_term:proplist(). create_template_props(Event, [FaxDoc | _Others]=_Docs, Account) -> Now = kz_time:now_s(), @@ -141,7 +141,7 @@ fax_values(Event) -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec build_and_send_email(iolist(), iolist(), iolist(), ne_binary() | ne_binaries(), kz_proplist(), ne_binary()) -> send_email_return(). +-spec build_and_send_email(iolist(), iolist(), iolist(), kz_term:ne_binary() | kz_term:ne_binaries(), kz_term:proplist(), kz_term:ne_binary()) -> send_email_return(). build_and_send_email(TxtBody, HTMLBody, Subject, To, Props, AccountDb) when is_list(To) -> [build_and_send_email(TxtBody, HTMLBody, Subject, T, Props, AccountDb) || T <- To]; build_and_send_email(TxtBody, HTMLBody, Subject, To, Props, AccountDb) -> diff --git a/applications/notify/src/notify_fax_util.erl b/applications/notify/src/notify_fax_util.erl index 7220ee7d977..a87bab9f199 100644 --- a/applications/notify/src/notify_fax_util.erl +++ b/applications/notify/src/notify_fax_util.erl @@ -20,7 +20,7 @@ %% create a friendly file name %% @end %%-------------------------------------------------------------------- --spec get_file_name(kz_proplist(), string()) -> ne_binary(). +-spec get_file_name(kz_term:proplist(), string()) -> kz_term:ne_binary(). get_file_name(Props, Ext) -> Fax = props:get_value(<<"fax">>, Props), CallerID = case {props:get_value(<<"caller_id_name">>, Fax), props:get_value(<<"caller_id_number">>, Fax)} of @@ -38,15 +38,15 @@ get_file_name(Props, Ext) -> %% %% @end %%-------------------------------------------------------------------- --spec get_attachment(ne_binary(), kz_proplist()) -> - {ne_binary(), ne_binary(), ne_binary()} | +-spec get_attachment(kz_term:ne_binary(), kz_term:proplist()) -> + {kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()} | {'error', any()}. get_attachment(Category, Props) -> UseDb = props:get_value(<<"account_db">>, Props, ?KZ_FAXES_DB), get_attachment(UseDb, Category, Props). --spec get_attachment(ne_binary(), ne_binary(), kz_proplist()) -> - {ne_binary(), ne_binary(), ne_binary()} | +-spec get_attachment(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> + {kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()} | {'error', any()}. get_attachment(UseDb, Category, Props) -> Fax = props:get_value(<<"fax">>, Props), @@ -65,10 +65,10 @@ get_attachment(UseDb, Category, Props) -> %% %% @end %%-------------------------------------------------------------------- --spec raw_attachment_binary(ne_binary(), ne_binary()) -> - {'ok', ne_binary(), ne_binary()}. --spec raw_attachment_binary(ne_binary(), ne_binary(), non_neg_integer()) -> - {'ok', ne_binary(), ne_binary()}. +-spec raw_attachment_binary(kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary(), kz_term:ne_binary()}. +-spec raw_attachment_binary(kz_term:ne_binary(), kz_term:ne_binary(), non_neg_integer()) -> + {'ok', kz_term:ne_binary(), kz_term:ne_binary()}. raw_attachment_binary(Db, FaxId) -> raw_attachment_binary(Db, FaxId, 2). @@ -97,8 +97,8 @@ raw_attachment_binary(Db, FaxId, Retries) when Retries > 0 -> %% %% @end %%-------------------------------------------------------------------- --spec convert_to_tiff(ne_binary(), kz_proplist(), ne_binary()) -> - {ne_binary(), ne_binary(), ne_binary()}. +-spec convert_to_tiff(kz_term:ne_binary(), kz_term:proplist(), kz_term:ne_binary()) -> + {kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()}. convert_to_tiff(AttachmentBin, Props, _ContentType) -> {<<"image/tiff">>, get_file_name(Props, "tiff"), AttachmentBin}. @@ -108,8 +108,8 @@ convert_to_tiff(AttachmentBin, Props, _ContentType) -> %% %% @end %%-------------------------------------------------------------------- --spec convert_to_pdf(ne_binary(), kz_proplist(), ne_binary()) -> - {ne_binary(), ne_binary(), ne_binary()} | +-spec convert_to_pdf(kz_term:ne_binary(), kz_term:proplist(), kz_term:ne_binary()) -> + {kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()} | {'error', any()}. convert_to_pdf(AttachmentBin, Props, <<"application/pdf">>) -> {<<"application/pdf">>, get_file_name(Props, "pdf"), AttachmentBin}; @@ -137,6 +137,6 @@ convert_to_pdf(AttachmentBin, Props, _ContentType) -> %% %% @end %%-------------------------------------------------------------------- --spec tmp_file_name(ne_binary()) -> string(). +-spec tmp_file_name(kz_term:ne_binary()) -> string(). tmp_file_name(Ext) -> kz_term:to_list(<<"/tmp/", (kz_binary:rand_hex(10))/binary, "_notify_fax.", Ext/binary>>). diff --git a/applications/notify/src/notify_first_occurrence.erl b/applications/notify/src/notify_first_occurrence.erl index 9547ca9fbb9..e0077a612ef 100644 --- a/applications/notify/src/notify_first_occurrence.erl +++ b/applications/notify/src/notify_first_occurrence.erl @@ -39,7 +39,7 @@ init() -> {ok, _} = notify_util:compile_default_subject_template(?DEFAULT_SUBJ_TMPL, ?MOD_CONFIG_CAT), lager:debug("init done for ~s", [?MODULE]). --spec handle_req(kz_json:object(), kz_proplist()) -> any(). +-spec handle_req(kz_json:object(), kz_term:proplist()) -> any(). handle_req(JObj, _Props) -> 'true' = kapi_notifications:first_occurrence_v(JObj), kz_util:put_callid(JObj), @@ -78,7 +78,7 @@ handle_req(JObj, _Props) -> %% create the props used by the template render function %% @end %%-------------------------------------------------------------------- --spec create_template_props(kz_json:object(), ne_binary()) -> kz_proplist(). +-spec create_template_props(kz_json:object(), kz_term:ne_binary()) -> kz_term:proplist(). create_template_props(Account, Occurrence) -> Admin = notify_util:find_admin(Account), [{<<"event">>, Occurrence} @@ -93,7 +93,7 @@ create_template_props(Account, Occurrence) -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec build_and_send_email(iolist(), iolist(), iolist(), api_binary() | ne_binaries(), kz_proplist()) -> send_email_return(). +-spec build_and_send_email(iolist(), iolist(), iolist(), kz_term:api_binary() | kz_term:ne_binaries(), kz_term:proplist()) -> send_email_return(). build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) when is_list(To) -> [build_and_send_email(TxtBody, HTMLBody, Subject, T, Props) || T <- To]; build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) -> diff --git a/applications/notify/src/notify_listener.erl b/applications/notify/src/notify_listener.erl index 1dcb19fe600..0cd9157898c 100644 --- a/applications/notify/src/notify_listener.erl +++ b/applications/notify/src/notify_listener.erl @@ -80,7 +80,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'responders', ?RESPONDERS} ,{'bindings', ?BINDINGS} @@ -124,7 +124,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', 'ok', State}. @@ -138,7 +138,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> {'noreply', State}. @@ -152,7 +152,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> lager:debug("unhandled message: ~p", [_Info]), {'noreply', State}. @@ -165,7 +165,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Props} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(JObj, _State) -> case should_handle(JObj) orelse should_handle_port(JObj) diff --git a/applications/notify/src/notify_low_balance.erl b/applications/notify/src/notify_low_balance.erl index 125e8e22ace..53ccc0f2ff1 100644 --- a/applications/notify/src/notify_low_balance.erl +++ b/applications/notify/src/notify_low_balance.erl @@ -38,7 +38,7 @@ init() -> {'ok', _} = notify_util:compile_default_subject_template(?DEFAULT_SUBJ_TMPL, ?MOD_CONFIG_CAT), lager:debug("init done for ~s", [?MODULE]). --spec handle_req(kz_json:object(), kz_proplist()) -> any(). +-spec handle_req(kz_json:object(), kz_term:proplist()) -> any(). handle_req(JObj, _Props) -> 'true' = kapi_notifications:low_balance_v(JObj), kz_util:put_callid(JObj), @@ -85,7 +85,7 @@ send(CurrentBalance, Account) -> %% create the props used by the template render function %% @end %%-------------------------------------------------------------------- --spec create_template_props(integer(), kz_json:object()) -> kz_proplist(). +-spec create_template_props(integer(), kz_json:object()) -> kz_term:proplist(). create_template_props(CurrentBalance, Account) -> Threshold = kz_account:low_balance_threshold(kz_doc:id(Account)), [{<<"account">>, notify_util:json_to_template_props(Account)} @@ -100,7 +100,7 @@ create_template_props(CurrentBalance, Account) -> %% %% @end %%-------------------------------------------------------------------- --spec pretty_print_dollars(float()) -> ne_binary(). +-spec pretty_print_dollars(float()) -> kz_term:ne_binary(). pretty_print_dollars(Amount) -> kz_term:to_binary(io_lib:format("$~.2f", [Amount])). @@ -110,7 +110,7 @@ pretty_print_dollars(Amount) -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec build_and_send_email(iolist(), iolist(), iolist(), ne_binary() | ne_binaries(), kz_proplist()) -> send_email_return(). +-spec build_and_send_email(iolist(), iolist(), iolist(), kz_term:ne_binary() | kz_term:ne_binaries(), kz_term:proplist()) -> send_email_return(). build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) when is_list(To) -> [build_and_send_email(TxtBody, HTMLBody, Subject, T, Props) || T <- To]; build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) -> @@ -138,12 +138,12 @@ build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) -> %% %% @end %%-------------------------------------------------------------------- --spec collect_recipients(ne_binary()) -> api_binaries() | api_binary(). +-spec collect_recipients(kz_term:ne_binary()) -> kz_term:api_binaries() | kz_term:api_binary(). collect_recipients(AccountId) -> {'ok', MasterAccountId} = kapps_util:get_master_account_id(), get_email(AccountId, MasterAccountId). --spec get_email(ne_binary(), ne_binary()) -> api_binaries() | api_binary(). +-spec get_email(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_binaries() | kz_term:api_binary(). get_email(MasterAccountId, MasterAccountId) -> AccountDb = kz_util:format_account_id(MasterAccountId, 'encoded'), lager:debug("attempting to email low balance to master account ~s" @@ -169,7 +169,7 @@ get_email(AccountId, MasterAccountId) -> get_email(MasterAccountId, MasterAccountId) end. --spec get_email(kz_json:object(), ne_binary(), ne_binary()) -> api_binaries() | api_binary(). +-spec get_email(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_binaries() | kz_term:api_binary(). get_email(JObj, AccountId, MasterAccountId) -> case find_billing_email(JObj) of 'undefined' -> @@ -181,7 +181,7 @@ get_email(JObj, AccountId, MasterAccountId) -> Email -> Email end. --spec find_billing_email(kz_json:object()) -> api_binaries() | api_binary(). +-spec find_billing_email(kz_json:object()) -> kz_term:api_binaries() | kz_term:api_binary(). find_billing_email(JObj) -> case is_notify_enabled(JObj) of 'false' -> 'undefined'; diff --git a/applications/notify/src/notify_maintenance.erl b/applications/notify/src/notify_maintenance.erl index 47327aee289..7a2386bd181 100644 --- a/applications/notify/src/notify_maintenance.erl +++ b/applications/notify/src/notify_maintenance.erl @@ -33,7 +33,7 @@ %% Returns whether an account's initial call notification has been sent %% @end %%-------------------------------------------------------------------- --spec check_initial_call(ne_binary()) -> 'ok'. +-spec check_initial_call(kz_term:ne_binary()) -> 'ok'. check_initial_call(Account) when is_binary(Account) -> AccountId = kz_util:format_account_id(Account, 'raw'), case kz_account:fetch(AccountId) of @@ -52,7 +52,7 @@ check_initial_call(Account) when is_binary(Account) -> %% Returns whether the initial_registration notification has been sent %% @end %%-------------------------------------------------------------------- --spec check_initial_registration(ne_binary()) -> 'ok'. +-spec check_initial_registration(kz_term:ne_binary()) -> 'ok'. check_initial_registration(Account) when is_binary(Account) -> AccountId = kz_util:format_account_id(Account, 'raw'), case kz_account:fetch(AccountId) of @@ -70,7 +70,7 @@ check_initial_registration(Account) when is_binary(Account) -> %% Configures the Relay key of the SMTP_Client System Config document. %% @end %%--------------------------------------------------------------------- --spec configure_smtp_relay(ne_binary()) -> 'ok' | 'failed'. +-spec configure_smtp_relay(kz_term:ne_binary()) -> 'ok' | 'failed'. configure_smtp_relay(Value) -> case update_smtp_client_document(<<"relay">>, Value) of {'ok', _} -> @@ -84,7 +84,7 @@ configure_smtp_relay(Value) -> %% Configures the username key of the SMTP_Client System Config document. %% @end %%-------------------------------------------------------------------- --spec configure_smtp_username(ne_binary()) -> 'ok' | 'failed'. +-spec configure_smtp_username(kz_term:ne_binary()) -> 'ok' | 'failed'. configure_smtp_username(Value) -> case update_smtp_client_document(<<"username">>, Value) of {'ok', _} -> @@ -99,7 +99,7 @@ configure_smtp_username(Value) -> %% Configures the password key of the SMTP_Client System Config document. %% @end %%-------------------------------------------------------------------- --spec configure_smtp_password(ne_binary()) -> 'ok' | 'failed'. +-spec configure_smtp_password(kz_term:ne_binary()) -> 'ok' | 'failed'. configure_smtp_password(Value) -> case update_smtp_client_document(<<"password">>, Value) of {'ok', _} -> @@ -114,7 +114,7 @@ configure_smtp_password(Value) -> %% Configures the username key of the SMTP_Client System Config document. %% @end %%-------------------------------------------------------------------- --spec configure_smtp_auth(ne_binary()) -> 'ok' | 'failed'. +-spec configure_smtp_auth(kz_term:ne_binary()) -> 'ok' | 'failed'. configure_smtp_auth(Value) -> case update_smtp_client_document(<<"auth">>, Value) of {'ok', _} -> @@ -129,7 +129,7 @@ configure_smtp_auth(Value) -> %% Configures the port key of the SMTP_Client System Config document. %% @end %%-------------------------------------------------------------------- --spec configure_smtp_port(ne_binary()) -> 'ok' | 'failed'. +-spec configure_smtp_port(kz_term:ne_binary()) -> 'ok' | 'failed'. configure_smtp_port(Value) -> case update_smtp_client_document(<<"port">>, Value) of {'ok', _} -> @@ -176,7 +176,7 @@ reload_smtp_configs() -> %% @doc %% @end %%-------------------------------------------------------------------- --spec template_files() -> ne_binaries(). +-spec template_files() -> kz_term:ne_binaries(). template_files() -> {'ok', Files} = file:list_dir(?TEMPLATE_PATH), lists:foldl( @@ -196,7 +196,7 @@ template_files() -> %% @doc %% @end %%-------------------------------------------------------------------- --spec template_ids() -> ne_binaries(). +-spec template_ids() -> kz_term:ne_binaries(). template_ids() -> {'ok', JObjs} = kz_datamgr:all_docs(?SYSTEM_CONFIG_DB), lists:foldl( @@ -217,7 +217,7 @@ template_ids() -> %% @doc %% @end %%-------------------------------------------------------------------- --spec match_file_to_db(ne_binaries(), ne_binaries()) -> kz_proplist(). +-spec match_file_to_db(kz_term:ne_binaries(), kz_term:ne_binaries()) -> kz_term:proplist(). match_file_to_db(Files, Ids) -> lists:foldl( fun(<<"notify_", FileKey/binary>>=File, Acc) -> @@ -266,9 +266,9 @@ module_exists(Module) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec compare_template_system_config(kz_proplist()) -> 'ok'. --spec compare_template_system_config(kz_proplist(), kz_json:object()) -> 'ok'. --spec compare_template_system_config(api_binaries(), api_binary(), api_binary()) -> +-spec compare_template_system_config(kz_term:proplist()) -> 'ok'. +-spec compare_template_system_config(kz_term:proplist(), kz_json:object()) -> 'ok'. +-spec compare_template_system_config(kz_term:api_binaries(), kz_term:api_binary(), kz_term:api_binary()) -> 'default' | 'file' | 'doc' | 'ok'. @@ -348,7 +348,7 @@ compare_template_system_config(DefaultTemplates, DocTemplate, FileTemplate) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec set_template(ne_binary(), ne_binary(), kz_json:object()) -> kz_json:object(). +-spec set_template(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). set_template(Key, Template, JObj) -> Default = kz_json:get_value(<<"default">>, JObj), kz_json:set_value( @@ -362,7 +362,7 @@ set_template(Key, Template, JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec open_file(list()) -> kz_proplist() | 'error'. +-spec open_file(list()) -> kz_term:proplist() | 'error'. open_file(File) -> case file:consult(File) of {'ok', Props} -> Props; @@ -374,7 +374,7 @@ open_file(File) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec open_system_config(ne_binary()) -> kz_json:object() | 'error' | 'not_found'. +-spec open_system_config(kz_term:ne_binary()) -> kz_json:object() | 'error' | 'not_found'. open_system_config(Id) -> case kz_datamgr:open_cache_doc(?SYSTEM_CONFIG_DB, Id) of {'ok', JObj} -> JObj; @@ -388,6 +388,6 @@ open_system_config(Id) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec update_smtp_client_document(ne_binary(), ne_binary()) -> {'ok', kz_json:object()} | {error, any()}. +-spec update_smtp_client_document(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {error, any()}. update_smtp_client_document(Key, Value) -> kapps_config:set(?SMTP_CLIENT_DOC, Key, Value). diff --git a/applications/notify/src/notify_new_account.erl b/applications/notify/src/notify_new_account.erl index d833fd8e023..27ab28595e5 100644 --- a/applications/notify/src/notify_new_account.erl +++ b/applications/notify/src/notify_new_account.erl @@ -40,7 +40,7 @@ init() -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Props) -> 'true' = kapi_notifications:new_account_v(JObj), kz_util:put_callid(JObj), @@ -89,7 +89,7 @@ handle_req(JObj, _Props) -> %% @end %%-------------------------------------------------------------------- -spec create_template_props(kz_json:object(), kz_json:object(), kz_json:object(), kz_json:objects()) -> - kz_proplist(). + kz_term:proplist(). create_template_props(Event, Admin, Account, AllDocs) -> Owners = [{kz_json:get_value([<<"doc">>, <<"_id">>], J1), kz_json:get_value(<<"doc">>, J1)} || J1 <- AllDocs, @@ -115,7 +115,7 @@ create_template_props(Event, Admin, Account, AllDocs) -> %% %% @end %%-------------------------------------------------------------------- --spec build_and_send_email(iolist(), iolist(), iolist(), api_binary() | ne_binaries(), kz_proplist()) -> send_email_return(). +-spec build_and_send_email(iolist(), iolist(), iolist(), kz_term:api_binary() | kz_term:ne_binaries(), kz_term:proplist()) -> send_email_return(). build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) when is_list(To) -> [build_and_send_email(TxtBody, HTMLBody, Subject, T, Props) || T <- To]; build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) -> diff --git a/applications/notify/src/notify_password_recovery.erl b/applications/notify/src/notify_password_recovery.erl index 3b7de33891c..69deb8b9145 100644 --- a/applications/notify/src/notify_password_recovery.erl +++ b/applications/notify/src/notify_password_recovery.erl @@ -40,7 +40,7 @@ init() -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Props) -> 'true' = kapi_notifications:password_recovery_v(JObj), kz_util:put_callid(JObj), @@ -79,7 +79,7 @@ handle_req(JObj, _Props) -> %% create the props used by the template render function %% @end %%-------------------------------------------------------------------- --spec create_template_props(kz_json:object(), kz_json:object()) -> kz_proplist(). +-spec create_template_props(kz_json:object(), kz_json:object()) -> kz_term:proplist(). create_template_props(Event, Account) -> User = kz_json:delete_key(<<"Request">>, Event), Request = kz_json:get_value(<<"Request">>, Event, kz_json:new()), @@ -96,7 +96,7 @@ create_template_props(Event, Account) -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec build_and_send_email(iolist(), iolist(), iolist(), ne_binary() | ne_binaries(), kz_proplist()) -> send_email_return(). +-spec build_and_send_email(iolist(), iolist(), iolist(), kz_term:ne_binary() | kz_term:ne_binaries(), kz_term:proplist()) -> send_email_return(). build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) when is_list(To)-> [build_and_send_email(TxtBody, HTMLBody, Subject, T, Props) || T <- To]; build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) -> diff --git a/applications/notify/src/notify_port_cancel.erl b/applications/notify/src/notify_port_cancel.erl index 34f60828e38..567b7c77dee 100644 --- a/applications/notify/src/notify_port_cancel.erl +++ b/applications/notify/src/notify_port_cancel.erl @@ -41,7 +41,7 @@ init() -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Props) -> 'true' = kapi_notifications:port_cancel_v(JObj), kz_util:put_callid(JObj), @@ -89,7 +89,7 @@ handle_req(JObj, _Props) -> %% create the props used by the template render function %% @end %%-------------------------------------------------------------------- --spec create_template_props(kz_json:object(), kz_json:object()) -> kz_proplist(). +-spec create_template_props(kz_json:object(), kz_json:object()) -> kz_term:proplist(). create_template_props(NotifyJObj, AccountJObj) -> Admin = notify_util:find_admin(kz_json:get_value(<<"Authorized-By">>, NotifyJObj)), @@ -108,7 +108,7 @@ create_template_props(NotifyJObj, AccountJObj) -> ,{<<"send_from">>, get_send_from(PortDoc, Admin)} ]. --spec get_send_from(kz_json:object(), kz_json:object()) -> ne_binary(). +-spec get_send_from(kz_json:object(), kz_json:object()) -> kz_term:ne_binary(). get_send_from(PortDoc, Admin) -> case kz_json:get_first_defined([<<"email">> ,[<<"Port">>, <<"email">>] @@ -118,26 +118,26 @@ get_send_from(PortDoc, Admin) -> Email -> Email end. --spec get_admin_send_from(kz_json:object()) -> ne_binary(). +-spec get_admin_send_from(kz_json:object()) -> kz_term:ne_binary(). get_admin_send_from(Admin) -> case kz_json:get_ne_value(<<"email">>, Admin) of 'undefined' -> get_default_from(); Email -> Email end. --spec get_default_from() -> ne_binary(). +-spec get_default_from() -> kz_term:ne_binary(). get_default_from() -> DefaultFrom = kz_term:to_binary(node()), kapps_config:get_binary(?MOD_CONFIG_CAT, <<"default_from">>, DefaultFrom). --spec find_numbers(kz_proplist(), kz_json:object()) -> ne_binaries(). +-spec find_numbers(kz_term:proplist(), kz_json:object()) -> kz_term:ne_binaries(). find_numbers(PortData, NotifyJObj) -> case props:get_value(<<"numbers">>, PortData) of 'undefined' -> find_numbers(NotifyJObj); Ns -> Ns end. --spec find_numbers(kz_json:object()) -> ne_binaries(). +-spec find_numbers(kz_json:object()) -> kz_term:ne_binaries(). find_numbers(NotifyJObj) -> [kz_json:get_value(<<"Number">>, NotifyJObj)]. @@ -150,7 +150,7 @@ find_port_info(NotifyJObj) -> kz_json:set_value(<<"port_id">>, PortRequestId, Doc) end. --spec find_port_doc(ne_binary()) -> kz_json:object(). +-spec find_port_doc(kz_term:ne_binary()) -> kz_json:object(). find_port_doc(PortRequestId) -> case kz_datamgr:open_cache_doc(?KZ_PORT_REQUESTS_DB, PortRequestId) of {'ok', PortDoc} -> PortDoc; @@ -163,7 +163,7 @@ find_port_doc(PortRequestId) -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec build_and_send_email(iolist(), iolist(), iolist(), ne_binary() | ne_binaries(), kz_proplist()) -> send_email_return(). +-spec build_and_send_email(iolist(), iolist(), iolist(), kz_term:ne_binary() | kz_term:ne_binaries(), kz_term:proplist()) -> send_email_return(). build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) when is_list(To)-> [build_and_send_email(TxtBody, HTMLBody, Subject, T, Props) || T <- To]; build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) -> diff --git a/applications/notify/src/notify_port_request.erl b/applications/notify/src/notify_port_request.erl index 02576f549a1..5922ca1f803 100644 --- a/applications/notify/src/notify_port_request.erl +++ b/applications/notify/src/notify_port_request.erl @@ -41,7 +41,7 @@ init() -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Props) -> 'true' = kapi_notifications:port_request_v(JObj), kz_util:put_callid(JObj), @@ -92,7 +92,7 @@ handle_req(JObj, _Props) -> %% create the props used by the template render function %% @end %%-------------------------------------------------------------------- --spec create_template_props(api_binary(), kz_json:object(), kz_json:object()) -> kz_proplist(). +-spec create_template_props(kz_term:api_binary(), kz_json:object(), kz_json:object()) -> kz_term:proplist(). create_template_props(<<"v2">>, NotifyJObj, AccountJObj) -> Admin = notify_util:find_admin(kz_json:get_value(<<"Authorized-By">>, NotifyJObj)), @@ -143,7 +143,7 @@ create_template_props(_, NotifyJObj, AccountJObj) -> ,{<<"send_from">>, get_send_from(PortDoc, Admin)} ]. --spec get_send_from(kz_json:object(), kz_json:object()) -> ne_binary(). +-spec get_send_from(kz_json:object(), kz_json:object()) -> kz_term:ne_binary(). get_send_from(PortDoc, Admin) -> case kz_json:get_first_defined([<<"email">> ,[<<"Port">>, <<"email">>] @@ -153,19 +153,19 @@ get_send_from(PortDoc, Admin) -> Email -> Email end. --spec get_admin_send_from(kz_json:object()) -> ne_binary(). +-spec get_admin_send_from(kz_json:object()) -> kz_term:ne_binary(). get_admin_send_from(Admin) -> case kz_json:get_ne_value(<<"email">>, Admin) of 'undefined' -> get_default_from(); Email -> Email end. --spec get_default_from() -> ne_binary(). +-spec get_default_from() -> kz_term:ne_binary(). get_default_from() -> DefaultFrom = kz_term:to_binary(node()), kapps_config:get_binary(?MOD_CONFIG_CAT, <<"default_from">>, DefaultFrom). --spec find_numbers(kz_proplist(), kz_json:object()) -> ne_binaries(). +-spec find_numbers(kz_term:proplist(), kz_json:object()) -> kz_term:ne_binaries(). find_numbers(PortData, NotifyJObj) -> Numbers = case props:get_value(<<"numbers">>, PortData) of 'undefined' -> find_numbers(NotifyJObj); @@ -173,7 +173,7 @@ find_numbers(PortData, NotifyJObj) -> end, [normalize_find_numbers(Number) || Number <- Numbers]. --spec find_numbers(kz_json:object()) -> ne_binaries() | kz_proplists(). +-spec find_numbers(kz_json:object()) -> kz_term:ne_binaries() | kz_term:proplists(). find_numbers(NotifyJObj) -> [kz_json:get_value(<<"Number">>, NotifyJObj)]. @@ -186,14 +186,14 @@ find_port_info(NotifyJObj) -> kz_json:set_value(<<"port_id">>, PortRequestId, Doc) end. --spec find_port_doc(ne_binary()) -> kz_json:object(). +-spec find_port_doc(kz_term:ne_binary()) -> kz_json:object(). find_port_doc(PortRequestId) -> case kz_datamgr:open_cache_doc(?KZ_PORT_REQUESTS_DB, PortRequestId) of {'ok', PortDoc} -> PortDoc; {'error', _} -> kz_json:new() end. --spec normalize_find_numbers(kz_proplist() | ne_binary()) -> ne_binary(). +-spec normalize_find_numbers(kz_term:proplist() | kz_term:ne_binary()) -> kz_term:ne_binary(). normalize_find_numbers({Number, _}) -> Number; normalize_find_numbers(Number) -> Number. @@ -203,7 +203,7 @@ normalize_find_numbers(Number) -> Number. %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec build_and_send_email(iolist(), iolist(), iolist(), ne_binary() | ne_binaries(), kz_proplist(), list()) -> send_email_return(). +-spec build_and_send_email(iolist(), iolist(), iolist(), kz_term:ne_binary() | kz_term:ne_binaries(), kz_term:proplist(), list()) -> send_email_return(). build_and_send_email(TxtBody, HTMLBody, Subject, To, Props, Attachements) when is_list(To)-> [build_and_send_email(TxtBody, HTMLBody, Subject, T, Props, Attachements) || T <- To]; build_and_send_email(TxtBody, HTMLBody, Subject, To, Props, Attachements) -> @@ -231,7 +231,7 @@ build_and_send_email(TxtBody, HTMLBody, Subject, To, Props, Attachements) -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --type attachment() :: {ne_binary(), ne_binary(), kz_proplist(), kz_proplist(), ne_binary()}. +-type attachment() :: {kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist(), kz_term:proplist(), kz_term:ne_binary()}. -type attachments() :: [attachment()]. -spec get_attachments(kz_json:object()) -> attachments(). @@ -252,7 +252,7 @@ get_number_attachments(JObj) -> _ -> [] end. --spec get_port_attachments(ne_binary()) -> attachments(). +-spec get_port_attachments(kz_term:ne_binary()) -> attachments(). get_port_attachments(PortRequestId) -> case kz_datamgr:open_cache_doc(?KZ_PORT_REQUESTS_DB, PortRequestId) of {'ok', PortJObj} -> @@ -261,11 +261,11 @@ get_port_attachments(PortRequestId) -> _ -> [] end. --spec fetch_attachments(kz_proplist(), ne_binary(), ne_binary()) -> attachments(). +-spec fetch_attachments(kz_term:proplist(), kz_term:ne_binary(), kz_term:ne_binary()) -> attachments(). fetch_attachments(Attachments, Db, Id) -> fetch_attachments(Attachments, Db, Id, []). --spec fetch_attachments(kz_proplist(), ne_binary(), ne_binary(), attachments()) -> attachments(). +-spec fetch_attachments(kz_term:proplist(), kz_term:ne_binary(), kz_term:ne_binary(), attachments()) -> attachments(). fetch_attachments([], _, _, EmailAttachments) -> EmailAttachments; fetch_attachments([{AttachmentName, AttachmentJObj}|Attachments], Db, Id, EmailAttachments) -> case kz_datamgr:fetch_attachment(Db, Id, fix_attachment_name(AttachmentName)) of @@ -277,7 +277,7 @@ fetch_attachments([{AttachmentName, AttachmentJObj}|Attachments], Db, Id, EmailA fetch_attachments(Attachments, Db, Id, EmailAttachments) end. --spec create_attachment(ne_binary(), kz_json:object(), ne_binary()) -> attachment(). +-spec create_attachment(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> attachment(). create_attachment(AttachmentName, AttachmentJObj, AttachmentBin) -> [Type, Subtype] = binary:split(kz_json:get_ne_value(<<"content_type">>, AttachmentJObj, <<"application/octet-stream">>), <<"/">>), @@ -296,7 +296,7 @@ create_attachment(AttachmentName, AttachmentJObj, AttachmentBin) -> %% %% @end %%-------------------------------------------------------------------- --spec fix_attachment_name(ne_binary() | list()) -> ne_binary(). +-spec fix_attachment_name(kz_term:ne_binary() | list()) -> kz_term:ne_binary(). fix_attachment_name(Name) when is_binary(Name) -> fix_attachment_name(kz_term:to_list(Name)); fix_attachment_name(Name) -> diff --git a/applications/notify/src/notify_ported.erl b/applications/notify/src/notify_ported.erl index a079413ebd9..91783633dae 100644 --- a/applications/notify/src/notify_ported.erl +++ b/applications/notify/src/notify_ported.erl @@ -40,7 +40,7 @@ init() -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Props) -> 'true' = kapi_notifications:ported_v(JObj), kz_util:put_callid(JObj), @@ -80,7 +80,7 @@ handle_req(JObj, _Props) -> %% create the props used by the template render function %% @end %%-------------------------------------------------------------------- --spec create_template_props(kz_json:object(), kz_json:object()) -> kz_proplist(). +-spec create_template_props(kz_json:object(), kz_json:object()) -> kz_term:proplist(). create_template_props(Event, Account) -> Admin = notify_util:find_admin(kz_json:get_value(<<"Authorized-By">>, Event)), [{<<"request">>, notify_util:json_to_template_props(Event)} @@ -96,7 +96,7 @@ create_template_props(Event, Account) -> %% %% @end %%-------------------------------------------------------------------- --spec get_send_from(kz_json:object()) -> ne_binary(). +-spec get_send_from(kz_json:object()) -> kz_term:ne_binary(). get_send_from(Admin) -> DefaultFrom = kz_term:to_binary(node()), case kapps_config:get_is_true(?MOD_CONFIG_CAT, <<"send_from_admin_email">>, 'true') of @@ -110,7 +110,7 @@ get_send_from(Admin) -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec build_and_send_email(iolist(), iolist(), iolist(), ne_binary() | ne_binaries(), kz_proplist()) -> send_email_return(). +-spec build_and_send_email(iolist(), iolist(), iolist(), kz_term:ne_binary() | kz_term:ne_binaries(), kz_term:proplist()) -> send_email_return(). build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) when is_list(To)-> [build_and_send_email(TxtBody, HTMLBody, Subject, T, Props) || T <- To]; build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) -> diff --git a/applications/notify/src/notify_sup.erl b/applications/notify/src/notify_sup.erl index adbc96835ea..cd97793ff99 100644 --- a/applications/notify/src/notify_sup.erl +++ b/applications/notify/src/notify_sup.erl @@ -34,7 +34,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -58,7 +58,7 @@ listener_proc() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/notify/src/notify_system_alert.erl b/applications/notify/src/notify_system_alert.erl index 555b08360ab..51ec45ce3a3 100644 --- a/applications/notify/src/notify_system_alert.erl +++ b/applications/notify/src/notify_system_alert.erl @@ -42,7 +42,7 @@ init() -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Props) -> 'true' = kapi_notifications:system_alert_v(JObj), @@ -76,11 +76,11 @@ handle_req(JObj, _Props) -> end, send_update(lists:flatten(SendResult), RespQ, MsgId). --spec send_update(send_email_return(), ne_binary(), ne_binary()) -> 'ok'. +-spec send_update(send_email_return(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. send_update(Result, RespQ, MsgId) -> notify_util:maybe_send_update(Result, RespQ, MsgId). --spec alert_using_POST(ne_binary(), kz_json:object()) -> 'ok' | {'error', any()}. +-spec alert_using_POST(kz_term:ne_binary(), kz_json:object()) -> 'ok' | {'error', any()}. alert_using_POST(Url, JObj) -> Headers = [{"Content-Type", "application/json"}], Encoded = kz_json:encode(JObj), @@ -111,7 +111,7 @@ alert_using_email('true', JObj) -> %% create the props used by the template render function %% @end %%-------------------------------------------------------------------- --spec create_template_props(kz_json:object()) -> kz_proplist(). +-spec create_template_props(kz_json:object()) -> kz_term:proplist(). create_template_props(Event) -> [{<<"request">>, notify_util:json_to_template_props( kz_json:delete_keys([<<"Details">> @@ -138,7 +138,7 @@ create_template_props(Event) -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec build_and_send_email(iolist(), iolist(), iolist(), ne_binary() | ne_binaries(), kz_proplist()) -> send_email_return(). +-spec build_and_send_email(iolist(), iolist(), iolist(), kz_term:ne_binary() | kz_term:ne_binaries(), kz_term:proplist()) -> send_email_return(). build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) when is_list(To)-> [build_and_send_email(TxtBody, HTMLBody, Subject, T, Props) || T <- To]; build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) -> diff --git a/applications/notify/src/notify_topup.erl b/applications/notify/src/notify_topup.erl index fb6d305d243..2c02f1200d8 100644 --- a/applications/notify/src/notify_topup.erl +++ b/applications/notify/src/notify_topup.erl @@ -40,7 +40,7 @@ init() -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Props) -> 'true' = kapi_notifications:topup_v(JObj), @@ -74,7 +74,7 @@ handle_req(JObj, _Props) -> %% NOTE: amount is expected to be in dollars %% @end %%-------------------------------------------------------------------- --spec create_template_props(kz_json:object(), kz_json:object()) -> kz_proplist(). +-spec create_template_props(kz_json:object(), kz_json:object()) -> kz_term:proplist(). create_template_props(_, AccountJObj) -> Amount = kz_json:get_value([<<"topup">>, <<"amount">>], AccountJObj), Threshold = kz_json:get_value([<<"topup">>, <<"threshold">>], AccountJObj), @@ -90,7 +90,7 @@ create_template_props(_, AccountJObj) -> %% %% @end %%-------------------------------------------------------------------- --spec pretty_print_dollars(float()) -> ne_binary(). +-spec pretty_print_dollars(float()) -> kz_term:ne_binary(). pretty_print_dollars(Amount) -> kz_term:to_binary(io_lib:format("$~.2f", [Amount])). @@ -100,7 +100,7 @@ pretty_print_dollars(Amount) -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec build_and_send_email(iolist(), iolist(), iolist(), ne_binary() | [ne_binary(),...], kz_proplist()) -> send_email_return(). +-spec build_and_send_email(iolist(), iolist(), iolist(), kz_term:ne_binary() | [kz_term:ne_binary(),...], kz_term:proplist()) -> send_email_return(). build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) when is_list(To)-> [build_and_send_email(TxtBody, HTMLBody, Subject, T, Props) || T <- To]; build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) -> diff --git a/applications/notify/src/notify_transaction.erl b/applications/notify/src/notify_transaction.erl index e1beb2ea138..39dcf812b0b 100644 --- a/applications/notify/src/notify_transaction.erl +++ b/applications/notify/src/notify_transaction.erl @@ -40,7 +40,7 @@ init() -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Props) -> true = kapi_notifications:transaction_v(JObj), @@ -75,7 +75,7 @@ handle_req(JObj, _Props) -> %% create the props used by the template render function %% @end %%-------------------------------------------------------------------- --spec create_template_props(kz_json:object(), kz_json:object()) -> kz_proplist(). +-spec create_template_props(kz_json:object(), kz_json:object()) -> kz_term:proplist(). create_template_props(Event, Account) -> props:filter_empty([{<<"account">>, notify_util:json_to_template_props(Account)} ,{<<"plan">>, notify_util:json_to_template_props(kz_json:get_value(<<"Service-Plan">>, Event))} @@ -89,7 +89,7 @@ create_template_props(Event, Account) -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec build_and_send_email(iolist(), iolist(), iolist(), ne_binary() | [ne_binary(),...], kz_proplist()) -> send_email_return(). +-spec build_and_send_email(iolist(), iolist(), iolist(), kz_term:ne_binary() | [kz_term:ne_binary(),...], kz_term:proplist()) -> send_email_return(). build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) when is_list(To)-> [build_and_send_email(TxtBody, HTMLBody, Subject, T, Props) || T <- To]; build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) -> @@ -159,7 +159,7 @@ transaction_data(Event) -> ). %% amount is expected to be in dollars --spec get_transaction_amount('undefined' | kz_proplist()) -> api_float(). +-spec get_transaction_amount('undefined' | kz_term:proplist()) -> kz_term:api_float(). get_transaction_amount('undefined') -> 'undefined'; get_transaction_amount(Props) -> case props:get_value(<<"amount">>, Props) of @@ -167,7 +167,7 @@ get_transaction_amount(Props) -> Amount -> kz_term:to_float(Amount) end. --spec purchase_order(kz_proplist()) -> binary(). +-spec purchase_order(kz_term:proplist()) -> binary(). purchase_order(Props) -> binary:replace(props:get_ne_binary_value(<<"purchase_order">>, Props, <<>>) ,<<"_">> diff --git a/applications/notify/src/notify_util.erl b/applications/notify/src/notify_util.erl index 44d5e420e2f..0767fa25f69 100644 --- a/applications/notify/src/notify_util.erl +++ b/applications/notify/src/notify_util.erl @@ -34,7 +34,7 @@ %% %% @end %%-------------------------------------------------------------------- --spec send_email(ne_binary(), api_binary(), any()) -> 'ok' | {'error', any()}. +-spec send_email(kz_term:ne_binary(), kz_term:api_binary(), any()) -> 'ok' | {'error', any()}. send_email(_, 'undefined', _) -> lager:debug("no email to send to"); send_email(_, <<>>, _) -> lager:debug("empty email to send to"); send_email(From, To, Email) -> @@ -71,8 +71,8 @@ send_email(From, To, Email) -> after 10 * ?MILLISECONDS_IN_SECOND -> {'error', 'timeout'} end. --spec send_update(api_binary(), ne_binary(), ne_binary()) -> 'ok'. --spec send_update(api_binary(), ne_binary(), ne_binary(), api_binary()) -> 'ok'. +-spec send_update(kz_term:api_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. +-spec send_update(kz_term:api_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary()) -> 'ok'. send_update(RespQ, MsgId, Status) -> send_update(RespQ, MsgId, Status, 'undefined'). send_update('undefined', _, _, _) -> lager:debug("no response queue to send update"); @@ -86,7 +86,7 @@ send_update(RespQ, MsgId, Status, Msg) -> lager:debug("notification update (~s) sending to ~s", [Status, RespQ]), kz_amqp_worker:cast(Prop, fun(P) -> kapi_notifications:publish_notify_update(RespQ, P) end). --spec maybe_send_update(send_email_return(), ne_binary(), ne_binary()) -> 'ok'. +-spec maybe_send_update(send_email_return(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. maybe_send_update('ok', RespQ, MsgId) -> send_update(RespQ, MsgId, <<"completed">>); maybe_send_update({'error', Reason}, RespQ, MsgId) -> send_update(RespQ, MsgId, <<"failed">>, Reason); maybe_send_update([LastResp|_]=Responses, RespQ, MsgId) -> @@ -110,7 +110,7 @@ maybe_send_update([LastResp|_]=Responses, RespQ, MsgId) -> %% %% @end %%-------------------------------------------------------------------- --spec json_to_template_props(api_object() | kz_json:objects()) -> 'undefined' | kz_proplist(). +-spec json_to_template_props(kz_term:api_object() | kz_json:objects()) -> 'undefined' | kz_term:proplist(). json_to_template_props('undefined') -> 'undefined'; json_to_template_props(JObj) -> normalize_proplist(kz_json:recursive_to_proplist(JObj)). @@ -121,7 +121,7 @@ json_to_template_props(JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec normalize_proplist(kz_proplist()) -> kz_proplist(). +-spec normalize_proplist(kz_term:proplist()) -> kz_term:proplist(). normalize_proplist(Props) -> [normalize_proplist_element(Elem) || Elem <- Props]. @@ -143,10 +143,10 @@ normalize_value(Value) -> %% %% @end %%-------------------------------------------------------------------- --spec compile_default_text_template(atom(), ne_binary()) -> {'ok', atom()}. --spec compile_default_html_template(atom(), ne_binary()) -> {'ok', atom()}. --spec compile_default_subject_template(atom(), ne_binary()) -> {'ok', atom()}. --spec compile_default_template(atom(), ne_binary(), atom()) -> {'ok', atom()}. +-spec compile_default_text_template(atom(), kz_term:ne_binary()) -> {'ok', atom()}. +-spec compile_default_html_template(atom(), kz_term:ne_binary()) -> {'ok', atom()}. +-spec compile_default_subject_template(atom(), kz_term:ne_binary()) -> {'ok', atom()}. +-spec compile_default_template(atom(), kz_term:ne_binary(), atom()) -> {'ok', atom()}. compile_default_text_template(TemplateModule, Category) -> compile_default_template(TemplateModule, Category, 'default_text_template'). @@ -187,7 +187,7 @@ get_default_template(Category, Key) -> %% %% @end %%-------------------------------------------------------------------- --spec render_template(api_binary(), atom(), kz_proplist()) -> +-spec render_template(kz_term:api_binary(), atom(), kz_term:proplist()) -> {'ok', string()} | {'error', any()}. render_template(Template, DefaultTemplate, Props) -> @@ -196,7 +196,7 @@ render_template(Template, DefaultTemplate, Props) -> Else -> Else end. --spec do_render_template(api_binary(), atom(), kz_proplist()) -> +-spec do_render_template(kz_term:api_binary(), atom(), kz_term:proplist()) -> {'ok', string()} | {'error', any()}. do_render_template('undefined', DefaultTemplate, Props) -> @@ -231,8 +231,8 @@ do_render_template(Template, DefaultTemplate, Props) -> %% in the event, parent account notification object, and then default. %% @end %%-------------------------------------------------------------------- --spec get_service_props(kz_json:object(), ne_binary()) -> kz_proplist(). --spec get_service_props(kz_json:object(), kz_json:object(), ne_binary()) -> kz_proplist(). +-spec get_service_props(kz_json:object(), kz_term:ne_binary()) -> kz_term:proplist(). +-spec get_service_props(kz_json:object(), kz_json:object(), kz_term:ne_binary()) -> kz_term:proplist(). get_service_props(Account, ConfigCat) -> get_service_props(kz_json:new(), Account, ConfigCat). @@ -264,7 +264,7 @@ get_service_props(Request, Account, ConfigCat) -> ,{<<"host">>, kz_term:to_binary(net_adm:localhost())} ]. --spec find_notification_settings(ne_binaries() | ne_binary(), ne_binaries()) -> kz_json:object(). +-spec find_notification_settings(kz_term:ne_binaries() | kz_term:ne_binary(), kz_term:ne_binaries()) -> kz_json:object(). find_notification_settings(_, []) -> lager:debug("unable to get service props, pvt_tree for the account was empty", []), kz_json:new(); @@ -284,7 +284,7 @@ find_notification_settings(_ConfigCat, _) -> ,[_ConfigCat]), kz_json:new(). --spec maybe_find_deprecated_settings(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec maybe_find_deprecated_settings(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). maybe_find_deprecated_settings(<<"fax_inbound_to_email">>, JObj) -> kz_json:get_ne_value([<<"notifications">>, <<"fax_to_email">>], JObj, kz_json:new()); maybe_find_deprecated_settings(<<"fax_outbound_to_email">>, JObj) -> @@ -302,14 +302,14 @@ maybe_find_deprecated_settings(_, _) -> kz_json:new(). %% account object %% @end %%-------------------------------------------------------------------- --spec get_rep_email(kz_json:object()) -> api_binary(). +-spec get_rep_email(kz_json:object()) -> kz_term:api_binary(). get_rep_email(JObj) -> case kapps_config:get_is_true(?NOTIFY_CONFIG_CAT, <<"search_rep_email">>, 'true') of 'true' -> find_rep_email(JObj); 'false' -> 'undefined' end. --spec find_rep_email(kz_json:object()) -> api_binary(). +-spec find_rep_email(kz_json:object()) -> kz_term:api_binary(). find_rep_email(JObj) -> AccountId = kz_doc:account_id(JObj), Admin = @@ -330,8 +330,8 @@ find_rep_email(JObj) -> %% a sub account object or sub account db name. %% @end %%-------------------------------------------------------------------- --type account_ids() :: ne_binaries(). --spec find_admin(api_binary() | account_ids() | kz_json:object()) -> kz_json:object(). +-type account_ids() :: kz_term:ne_binaries(). +-spec find_admin(kz_term:api_binary() | account_ids() | kz_json:object()) -> kz_json:object(). find_admin('undefined') -> kz_json:new(); find_admin([]) -> kz_json:new(); find_admin(Account) when is_binary(Account) -> @@ -385,7 +385,7 @@ get_account_doc(JObj) -> Account -> kz_account:fetch(Account) end. --spec category_to_file(ne_binary()) -> iolist() | 'undefined'. +-spec category_to_file(kz_term:ne_binary()) -> iolist() | 'undefined'. category_to_file(<<"notify.voicemail_to_email">>) -> [code:priv_dir(?APP), "/notify_voicemail_to_email.config"]; category_to_file(<<"notify.voicemail_full">>) -> @@ -427,7 +427,7 @@ category_to_file(<<"notify.topup">>) -> category_to_file(_) -> 'undefined'. --spec qr_code_image(api_binary()) -> kz_proplist() | 'undefined'. +-spec qr_code_image(kz_term:api_binary()) -> kz_term:proplist() | 'undefined'. qr_code_image('undefined') -> 'undefined'; qr_code_image(Text) -> lager:debug("create qr code for ~s", [Text]), @@ -443,7 +443,7 @@ qr_code_image(Text) -> 'undefined' end. --spec get_charset_params(kz_proplist()) -> {kz_proplist(), binary()}. +-spec get_charset_params(kz_term:proplist()) -> {kz_term:proplist(), binary()}. get_charset_params(Service) -> case props:get_value(<<"template_charset">>, Service) of <<>> -> {[], <<>>}; diff --git a/applications/notify/src/notify_voicemail_full.erl b/applications/notify/src/notify_voicemail_full.erl index 5c347011607..d50beac234f 100644 --- a/applications/notify/src/notify_voicemail_full.erl +++ b/applications/notify/src/notify_voicemail_full.erl @@ -41,7 +41,7 @@ init() -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Props) -> 'true' = kapi_notifications:voicemail_full_v(JObj), kz_util:put_callid(JObj), @@ -90,25 +90,25 @@ send(JObj, Account) -> build_and_send_email(TxtBody, HTMLBody, Subject, Emails, Props). --spec get_user_email(kz_json:object(), kz_json:object()) -> api_binary(). +-spec get_user_email(kz_json:object(), kz_json:object()) -> kz_term:api_binary(). get_user_email(UserJObj, Account) -> case kz_json:get_first_defined([<<"email">>, <<"username">>], UserJObj) of 'undefined' -> get_rep_email(Account); Email -> Email end. --spec get_rep_email(kz_json:object()) -> api_binary(). +-spec get_rep_email(kz_json:object()) -> kz_term:api_binary(). get_rep_email(Account) -> case notify_util:get_rep_email(Account) of 'undefined' -> get_sys_admin_email(); RepEmail -> RepEmail end. --spec get_sys_admin_email() -> api_binary(). +-spec get_sys_admin_email() -> kz_term:api_binary(). get_sys_admin_email() -> kapps_config:get_ne_binary_or_ne_binaries(?MOD_CONFIG_CAT, <<"default_to">>). --spec get_owner(ne_binary(), kzd_voicemail_box:doc(), api_binary()) -> +-spec get_owner(kz_term:ne_binary(), kzd_voicemail_box:doc(), kz_term:api_binary()) -> {'ok', kzd_user:doc()}. get_owner(AccountDb, VMBox) -> get_owner(AccountDb, VMBox, kzd_voicemail_box:owner_id(VMBox)). @@ -119,7 +119,7 @@ get_owner(AccountDb, _VMBox, OwnerId) -> lager:debug("attempting to load owner: ~s", [OwnerId]), {'ok', _} = kz_datamgr:open_cache_doc(AccountDb, OwnerId). --spec maybe_add_user_email(ne_binaries(), api_binary()) -> ne_binaries(). +-spec maybe_add_user_email(kz_term:ne_binaries(), kz_term:api_binary()) -> kz_term:ne_binaries(). maybe_add_user_email(BoxEmails, 'undefined') -> BoxEmails; maybe_add_user_email(BoxEmails, UserEmail) -> [UserEmail | BoxEmails]. @@ -129,7 +129,7 @@ maybe_add_user_email(BoxEmails, UserEmail) -> [UserEmail | BoxEmails]. %% create the props used by the template render function %% @end %%-------------------------------------------------------------------- --spec create_template_props(kz_json:object()) -> kz_proplist(). +-spec create_template_props(kz_json:object()) -> kz_term:proplist(). create_template_props(JObj) -> AccountDb = kz_util:format_account_db(kz_json:get_value(<<"Account-ID">>, JObj)), {'ok', AccountJObj} = kz_account:fetch(AccountDb), @@ -167,7 +167,7 @@ get_vm_doc(JObj) -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec build_and_send_email(iolist(), iolist(), iolist(), ne_binary() | ne_binaries(), kz_proplist()) -> send_email_return(). +-spec build_and_send_email(iolist(), iolist(), iolist(), kz_term:ne_binary() | kz_term:ne_binaries(), kz_term:proplist()) -> send_email_return(). build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) when is_list(To) -> [build_and_send_email(TxtBody, HTMLBody, Subject, T, Props) || T <- To]; build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) -> diff --git a/applications/notify/src/notify_voicemail_to_email.erl b/applications/notify/src/notify_voicemail_to_email.erl index 58b4fc608eb..aaa5a6a87af 100644 --- a/applications/notify/src/notify_voicemail_to_email.erl +++ b/applications/notify/src/notify_voicemail_to_email.erl @@ -35,7 +35,7 @@ init() -> {'ok', _} = notify_util:compile_default_subject_template(?DEFAULT_SUBJ_TMPL, ?MOD_CONFIG_CAT), lager:debug("init done for ~s", [?MODULE]). --spec handle_req(kz_json:object(), kz_proplist()) -> any(). +-spec handle_req(kz_json:object(), kz_term:proplist()) -> any(). handle_req(JObj, _Props) -> 'true' = kapi_notifications:voicemail_new_v(JObj), _ = kz_util:put_callid(JObj), @@ -65,7 +65,7 @@ handle_req(JObj, _Props) -> end, notify_util:maybe_send_update(SendResult, RespQ, MsgId). --spec continue_processing(kz_json:object(), ne_binary(), kz_json:object(), ne_binaries()) -> send_email_return(). +-spec continue_processing(kz_json:object(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binaries()) -> send_email_return(). continue_processing(JObj, AccountDb, VMBox, Emails) -> AccountDb = kz_util:format_account_db(kz_json:get_value(<<"Account-ID">>, JObj)), @@ -88,12 +88,12 @@ continue_processing(JObj, AccountDb, VMBox, Emails) -> build_and_send_email(TxtBody, HTMLBody, Subject, Emails, props:filter_undefined(Props)). --spec maybe_add_user_email(ne_binaries(), api_binary(), boolean()) -> ne_binaries(). +-spec maybe_add_user_email(kz_term:ne_binaries(), kz_term:api_binary(), boolean()) -> kz_term:ne_binaries(). maybe_add_user_email(BoxEmails, 'undefined', _) -> BoxEmails; maybe_add_user_email(BoxEmails, _UserEmail, 'false') -> BoxEmails; maybe_add_user_email(BoxEmails, UserEmail, 'true') -> [UserEmail | BoxEmails]. --spec get_owner(ne_binary(), kzd_voicemail_box:doc(), api_binary()) -> +-spec get_owner(kz_term:ne_binary(), kzd_voicemail_box:doc(), kz_term:api_binary()) -> {'ok', kzd_user:doc()}. get_owner(AccountDb, VMBox) -> get_owner(AccountDb, VMBox, kzd_voicemail_box:owner_id(VMBox)). @@ -113,7 +113,7 @@ get_owner(AccountDb, _VMBox, OwnerId) -> %% create the props used by the template render function %% @end %%-------------------------------------------------------------------- --spec create_template_props(kz_json:object(), ne_binary(), kz_json:object()) -> kz_proplist(). +-spec create_template_props(kz_json:object(), kz_term:ne_binary(), kz_json:object()) -> kz_term:proplist(). create_template_props(Event, Timezone, Account) -> CIDName = kz_json:get_value(<<"Caller-ID-Name">>, Event), CIDNum = kz_json:get_value(<<"Caller-ID-Number">>, Event), @@ -146,7 +146,7 @@ create_template_props(Event, Timezone, Account) -> ,{<<"account_id">>, kz_doc:account_id(Account)} ]. --spec magic_hash(kz_json:object()) -> api_binary(). +-spec magic_hash(kz_json:object()) -> kz_term:api_binary(). magic_hash(Event) -> AccountId = kz_json:get_value(<<"Account-ID">>, Event), VMBoxId = kz_json:get_value(<<"Voicemail-Box">>, Event), @@ -167,7 +167,7 @@ magic_hash(Event) -> %% process the AMQP requests %% @end %%-------------------------------------------------------------------- --spec build_and_send_email(iolist(), iolist(), iolist(), ne_binaries(), kz_proplist()) -> send_email_return(). +-spec build_and_send_email(iolist(), iolist(), iolist(), kz_term:ne_binaries(), kz_term:proplist()) -> send_email_return(). build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) -> Voicemail = props:get_value(<<"voicemail">>, Props), Service = props:get_value(<<"service">>, Props), @@ -236,7 +236,7 @@ build_and_send_email(TxtBody, HTMLBody, Subject, To, Props) -> %% create a friendly file name %% @end %%-------------------------------------------------------------------- --spec get_file_name(kz_json:object(), kz_proplist()) -> ne_binary(). +-spec get_file_name(kz_json:object(), kz_term:proplist()) -> kz_term:ne_binary(). get_file_name(MediaJObj, Props) -> %% CallerID_Date_Time.mp3 Voicemail = props:get_value(<<"voicemail">>, Props), @@ -256,7 +256,7 @@ get_file_name(MediaJObj, Props) -> binary:replace(kz_term:to_lower_binary(FName), <<" ">>, <<"_">>). --spec get_extension(kz_json:object()) -> ne_binary(). +-spec get_extension(kz_json:object()) -> kz_term:ne_binary(). get_extension(MediaJObj) -> case kz_json:get_value(<<"media_type">>, MediaJObj) of 'undefined' -> @@ -265,20 +265,20 @@ get_extension(MediaJObj) -> MediaType -> MediaType end. --spec attachment_to_extension(kz_json:object()) -> ne_binary(). +-spec attachment_to_extension(kz_json:object()) -> kz_term:ne_binary(). attachment_to_extension(AttachmentsJObj) -> kz_json:get_value(<<"extension">> ,kz_json:map(fun attachment_to_extension/2, AttachmentsJObj) ,kapps_config:get_ne_binary(<<"callflow">>, [<<"voicemail">>, <<"extension">>], <<"mp3">>) ). --spec attachment_to_extension(ne_binary(), kz_json:object()) -> {ne_binary(), ne_binary()}. +-spec attachment_to_extension(kz_term:ne_binary(), kz_json:object()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. attachment_to_extension(_Id, Meta) -> CT = kz_json:get_value(<<"content_type">>, Meta), Ext = mime_to_extension(CT), {<<"extension">>, Ext}. --spec mime_to_extension(ne_binary()) -> ne_binary(). +-spec mime_to_extension(kz_term:ne_binary()) -> kz_term:ne_binary(). mime_to_extension(<<"audio/mpeg">>) -> <<"mp3">>; mime_to_extension(_) -> <<"wav">>. @@ -288,7 +288,7 @@ mime_to_extension(_) -> <<"wav">>. %% %% @end %%-------------------------------------------------------------------- --spec preaty_print_length(integer() | api_object()) -> ne_binary(). +-spec preaty_print_length(integer() | kz_term:api_object()) -> kz_term:ne_binary(). preaty_print_length('undefined') -> <<"00:00">>; preaty_print_length(Milliseconds) when is_integer(Milliseconds) -> diff --git a/applications/omnipresence/src/kapi_omnipresence.erl b/applications/omnipresence/src/kapi_omnipresence.erl index 5bb99faede7..34a738b675c 100644 --- a/applications/omnipresence/src/kapi_omnipresence.erl +++ b/applications/omnipresence/src/kapi_omnipresence.erl @@ -64,7 +64,7 @@ %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec subscribe(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec subscribe(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. subscribe(Prop) when is_list(Prop) -> case subscribe_v(Prop) of 'true' -> kz_api:build_message(Prop, ?SUBSCRIBE_HEADERS, ?OPTIONAL_SUBSCRIBE_HEADERS); @@ -72,13 +72,13 @@ subscribe(Prop) when is_list(Prop) -> end; subscribe(JObj) -> subscribe(kz_json:to_proplist(JObj)). --spec subscribe_v(api_terms()) -> boolean(). +-spec subscribe_v(kz_term:api_terms()) -> boolean(). subscribe_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SUBSCRIBE_HEADERS, ?SUBSCRIBE_VALUES, ?SUBSCRIBE_TYPES); subscribe_v(JObj) -> subscribe_v(kz_json:to_proplist(JObj)). --spec publish_subscribe(api_terms()) -> 'ok'. --spec publish_subscribe(api_terms(), binary()) -> 'ok'. +-spec publish_subscribe(kz_term:api_terms()) -> 'ok'. +-spec publish_subscribe(kz_term:api_terms(), binary()) -> 'ok'. publish_subscribe(JObj) -> publish_subscribe(JObj, ?DEFAULT_CONTENT_TYPE). publish_subscribe(Req, ContentType) -> @@ -90,7 +90,7 @@ publish_subscribe(Req, ContentType) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec notify(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec notify(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. notify(Prop) when is_list(Prop) -> case notify_v(Prop) of 'true' -> kz_api:build_message(Prop, ?NOTIFY_HEADERS, ?OPTIONAL_NOTIFY_HEADERS); @@ -98,13 +98,13 @@ notify(Prop) when is_list(Prop) -> end; notify(JObj) -> notify(kz_json:to_proplist(JObj)). --spec notify_v(api_terms()) -> boolean(). +-spec notify_v(kz_term:api_terms()) -> boolean(). notify_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?NOTIFY_HEADERS, ?NOTIFY_VALUES, ?NOTIFY_TYPES); notify_v(JObj) -> notify_v(kz_json:to_proplist(JObj)). --spec publish_notify(api_terms()) -> 'ok'. --spec publish_notify(api_terms(), binary()) -> 'ok'. +-spec publish_notify(kz_term:api_terms()) -> 'ok'. +-spec publish_notify(kz_term:api_terms(), binary()) -> 'ok'. publish_notify(JObj) -> publish_notify(JObj, ?DEFAULT_CONTENT_TYPE). publish_notify(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?NOTIFY_VALUES, fun notify/1), @@ -115,7 +115,7 @@ publish_notify(Req, ContentType) -> %% %% @end %%-------------------------------------------------------------------- --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, Props) -> bind_q(Queue, props:get_value('restrict_to', Props), Props). @@ -144,8 +144,8 @@ bind_q(Queue, [_|Restrict], Props) -> bind_q(Queue, Restrict, Props); bind_q(_, [], _) -> 'ok'. --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. --spec unbind_q(ne_binary(), atoms() | 'undefined', kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:atoms() | 'undefined', kz_term:proplist()) -> 'ok'. unbind_q(Queue, Props) -> unbind_q(Queue, props:get_value('restrict_to', Props), Props). diff --git a/applications/omnipresence/src/omnip_subscriptions.erl b/applications/omnipresence/src/omnip_subscriptions.erl index 9abaece7fbd..712ffef8f33 100644 --- a/applications/omnipresence/src/omnip_subscriptions.erl +++ b/applications/omnipresence/src/omnip_subscriptions.erl @@ -62,26 +62,26 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_server:start_link({'local', ?SERVER}, ?MODULE, [], []). --spec handle_kamailio_subscribe(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_kamailio_subscribe(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_kamailio_subscribe(JObj, _Props) -> 'true' = kapi_omnipresence:subscribe_v(JObj), gen_server:cast(?SERVER, {'subscribe', JObj}). --spec handle_kamailio_notify(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_kamailio_notify(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_kamailio_notify(JObj, _Props) -> 'true' = kapi_omnipresence:notify_v(JObj), gen_server:cast(?SERVER, {'notify', JObj}). --spec handle_mwi_update(kz_json:object(), kz_proplist()) -> any(). +-spec handle_mwi_update(kz_json:object(), kz_term:proplist()) -> any(). handle_mwi_update(JObj, _Props) -> 'true' = kapi_presence:mwi_update_v(JObj), gen_server:cast(?SERVER, {'mwi', JObj}). --spec handle_dialog_update(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_dialog_update(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_dialog_update(JObj, _Props) -> 'true' = kapi_presence:dialog_v(JObj), gen_server:cast(?SERVER, {'dialog', JObj}). @@ -89,7 +89,7 @@ handle_dialog_update(JObj, _Props) -> -spec table_id() -> 'omnipresence_subscriptions'. table_id() -> 'omnipresence_subscriptions'. --spec table_config() -> kz_proplist(). +-spec table_config() -> kz_term:proplist(). table_config() -> ['protected', 'named_table', 'set' ,{'keypos', #omnip_subscription.call_id} @@ -129,7 +129,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> lager:debug("omnipresence subscriptions unhandled call : ~p", [_Request]), {'reply', {'error', 'not_implemented'}, State}. @@ -144,7 +144,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'sync', {<<"Start">>, Node}}, #state{sync_nodes=Nodes}=State) -> {'noreply', State#state{sync_nodes=[Node | Nodes]}}; handle_cast({'sync', {<<"End">>, Node}}, #state{sync_nodes=Nodes} = State) -> @@ -197,7 +197,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'timeout', Ref, ?EXPIRE_MESSAGE}=_R, #state{expire_ref=Ref, ready='true'}=State) -> case expire_old_subscriptions() of 0 -> 'ok'; @@ -353,7 +353,7 @@ expire_old_subscriptions() -> ,['true'] }]). --spec find_subscription(ne_binary()) -> +-spec find_subscription(kz_term:ne_binary()) -> {'ok', subscription()} | {'error', 'not_found'}. find_subscription(CallId) -> @@ -362,7 +362,7 @@ find_subscription(CallId) -> [#omnip_subscription{}=Sub] -> {'ok', Sub} end. --spec find_user_subscriptions(ne_binary(), ne_binary()) -> +-spec find_user_subscriptions(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', subscriptions()} | {'error', 'not_found'}. find_user_subscriptions(?OMNIPRESENCE_EVENT_ALL, User) -> @@ -396,8 +396,8 @@ find_subscriptions(MatchSpec) -> {'error', 'not_found'} end. --spec search_for_subscriptions(ne_binary() | '_', ne_binary()) -> subscriptions(). --spec search_for_subscriptions(ne_binary() | '_', ne_binary(), ne_binary() | '_') -> subscriptions(). +-spec search_for_subscriptions(kz_term:ne_binary() | '_', kz_term:ne_binary()) -> subscriptions(). +-spec search_for_subscriptions(kz_term:ne_binary() | '_', kz_term:ne_binary(), kz_term:ne_binary() | '_') -> subscriptions(). search_for_subscriptions(Event, Realm) -> MatchSpec = #omnip_subscription{realm=kz_term:to_lower_binary(Realm) @@ -501,7 +501,7 @@ notify(JObj) -> lager:debug("notify received for unexistent subscription ~s", [CallId]) end. --type msg() :: {ne_binary(), ne_binary(), ne_binary(), ne_binary()}. +-type msg() :: {kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()}. -type exec_fun() :: fun((atom(), msg()) -> 'ok'). -spec on_subscribe(msg()) -> 'ok'. diff --git a/applications/omnipresence/src/omnip_util.erl b/applications/omnipresence/src/omnip_util.erl index 46a9250f897..be0d11a3171 100644 --- a/applications/omnipresence/src/omnip_util.erl +++ b/applications/omnipresence/src/omnip_util.erl @@ -18,20 +18,20 @@ -include("omnipresence.hrl"). -include_lib("kazoo_sip/include/kzsip_uri.hrl"). --spec extract_user(ne_binary()) -> {ne_binary(), ne_binary(), ne_binaries()}. +-spec extract_user(kz_term:ne_binary()) -> {kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binaries()}. extract_user(User) -> [#uri{scheme=Proto, user=Username, domain=Realm}] = kzsip_uri:uris(User), {kz_term:to_binary(Proto), <>, [Username, Realm]}. --spec normalize_variables(kz_proplist()) -> kz_proplist(). +-spec normalize_variables(kz_term:proplist()) -> kz_term:proplist(). normalize_variables(Props) -> [{kz_json:normalize_key(K), V} || {K, V} <- Props]. --spec are_valid_uris(ne_binaries()) -> boolean(). +-spec are_valid_uris(kz_term:ne_binaries()) -> boolean(). are_valid_uris(L) -> lists:all(fun is_valid_uri/1, L). --spec is_valid_uri(ne_binary()) -> boolean(). +-spec is_valid_uri(kz_term:ne_binary()) -> boolean(). is_valid_uri(Uri) -> case binary:split(Uri, <<"@">>) of [_User, _Host] -> 'true'; diff --git a/applications/omnipresence/src/omnipresence.hrl b/applications/omnipresence/src/omnipresence.hrl index 319588683da..a19eb0e1227 100644 --- a/applications/omnipresence/src/omnipresence.hrl +++ b/applications/omnipresence/src/omnipresence.hrl @@ -26,34 +26,34 @@ -define(HANGUP_TIME, 10). -define(OTHER_TIME, 24 * ?SECONDS_IN_HOUR). --record(omnip_subscription, {user :: api_binary() | '_' %% user@realm.com - ,from :: api_binary() | <<>> | '_' %% user@realm.com - ,stalker :: api_binary() | '_' | '$2' % amqp queue to publish updates to +-record(omnip_subscription, {user :: kz_term:api_binary() | '_' %% user@realm.com + ,from :: kz_term:api_binary() | <<>> | '_' %% user@realm.com + ,stalker :: kz_term:api_binary() | '_' | '$2' % amqp queue to publish updates to ,expires = 0 :: non_neg_integer() | '_' | '$2' - ,timestamp = kz_time:now_s() :: gregorian_seconds() | '_' | '$1' - ,username :: api_binary() | '_' - ,realm :: api_binary() | '_' - ,normalized_user :: api_binary() | '_' | '$1' - ,normalized_from :: api_binary() | '_' | '$1' - ,event :: api_binary() | '_' - ,contact :: api_binary() | '_' - ,call_id :: api_binary() | '_' - ,subscription_id :: api_binary() | '_' - ,proxy_route :: api_binary() | '_' + ,timestamp = kz_time:now_s() :: kz_time:gregorian_seconds() | '_' | '$1' + ,username :: kz_term:api_binary() | '_' + ,realm :: kz_term:api_binary() | '_' + ,normalized_user :: kz_term:api_binary() | '_' | '$1' + ,normalized_from :: kz_term:api_binary() | '_' | '$1' + ,event :: kz_term:api_binary() | '_' + ,contact :: kz_term:api_binary() | '_' + ,call_id :: kz_term:api_binary() | '_' + ,subscription_id :: kz_term:api_binary() | '_' + ,proxy_route :: kz_term:api_binary() | '_' ,version = 1 :: non_neg_integer() | '_' ,last_sequence = 0 :: non_neg_integer() | '_' ,last_reply = 0 :: non_neg_integer() | '_' - ,last_body :: api_binary() | '_' - ,user_agent :: api_binary() | '_' + ,last_body :: kz_term:api_binary() | '_' + ,user_agent :: kz_term:api_binary() | '_' }). -type subscription() :: #omnip_subscription{}. -type subscriptions() :: [subscription()]. --record(channel, {call_id :: api_binary() - ,direction :: api_binary() - ,state :: api_binary() - ,to :: api_binary() +-record(channel, {call_id :: kz_term:api_binary() + ,direction :: kz_term:api_binary() + ,state :: kz_term:api_binary() + ,to :: kz_term:api_binary() }). -type channel() :: #channel{}. diff --git a/applications/omnipresence/src/omnipresence_app.erl b/applications/omnipresence/src/omnipresence_app.erl index dec984ffa25..3b5a64b09b9 100644 --- a/applications/omnipresence/src/omnipresence_app.erl +++ b/applications/omnipresence/src/omnipresence_app.erl @@ -17,7 +17,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = declare_exchanges(), omnipresence_sup:start_link(). diff --git a/applications/omnipresence/src/omnipresence_listener.erl b/applications/omnipresence/src/omnipresence_listener.erl index cedaedcc9ba..a8804aa4ebc 100644 --- a/applications/omnipresence/src/omnipresence_listener.erl +++ b/applications/omnipresence/src/omnipresence_listener.erl @@ -22,9 +22,9 @@ -define(SERVER, ?MODULE). --record(state, {subs_pid :: api_pid() - ,subs_ref :: api_reference() - ,queue :: api_binary() +-record(state, {subs_pid :: kz_term:api_pid() + ,subs_ref :: kz_term:api_reference() + ,queue :: kz_term:api_binary() ,consuming = 'false' :: boolean() ,sync = 'false' :: boolean() }). @@ -62,7 +62,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'bindings', ?BINDINGS} ,{'responders', ?RESPONDERS} @@ -107,7 +107,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -121,7 +121,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('find_subscriptions_srv', #state{subs_pid=_Pid}=State) -> case omnipresence_sup:subscriptions_srv() of 'undefined' -> @@ -169,7 +169,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'DOWN', Ref, 'process', Pid, _R}, #state{subs_pid=Pid ,subs_ref=Ref }=State) -> diff --git a/applications/omnipresence/src/omnipresence_maintenance.erl b/applications/omnipresence/src/omnipresence_maintenance.erl index 058d6b861b6..017061f2821 100644 --- a/applications/omnipresence/src/omnipresence_maintenance.erl +++ b/applications/omnipresence/src/omnipresence_maintenance.erl @@ -32,8 +32,8 @@ count_current_subscriptions() -> -define(SUBSCRIPTION_FORMAT_STR, " ~50.s | ~50.s | ~10.s | ~20.s |~n"). -spec current_subscriptions() -> 'ok'. --spec current_subscriptions(ne_binary()) -> 'ok'. --spec current_subscriptions(ne_binary(), ne_binary()) -> 'ok'. +-spec current_subscriptions(kz_term:ne_binary()) -> 'ok'. +-spec current_subscriptions(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. current_subscriptions() -> print_subscriptions( omnip_subscriptions:subscriptions_to_json( @@ -74,7 +74,7 @@ print_subscription(JObj, Now) -> ,kz_json:get_value(<<"event">>, JObj) ]). --spec subscribe(ne_binary(), ne_binary()) -> 'ok'. +-spec subscribe(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. subscribe(Realm, User) -> Prop = [{<<"User">>, <<"sip:", User/binary, "@", Realm/binary>>} ,{<<"Expires">>, 1} @@ -97,7 +97,7 @@ subscribe(Realm, User) -> io:format("Sent subscription for ~s@~s, recv'd error: ~p~n", [User, Realm, _E]) end. --spec send_mwi_update(ne_binary(), ne_binary() | integer(), ne_binary() | integer() ) -> 'ok'. +-spec send_mwi_update(kz_term:ne_binary(), kz_term:ne_binary() | integer(), kz_term:ne_binary() | integer() ) -> 'ok'. send_mwi_update(User, New, Saved) when is_binary(New) -> send_mwi_update(User, kz_term:to_integer(New), Saved); send_mwi_update(User, New, Saved) when is_binary(Saved) -> @@ -111,12 +111,12 @@ send_mwi_update(User, New, Saved) -> ], kz_amqp_worker:cast(Command, fun kapi_presence:publish_mwi_update/1). --spec reset_subscription(ne_binary()) -> any(). +-spec reset_subscription(kz_term:ne_binary()) -> any(). reset_subscription(User) -> [Username, Realm | _] = binary:split(User, <<"@">>, ['global']), reset_subscription(Username, Realm). --spec reset_subscription(ne_binary(), ne_binary()) -> any(). +-spec reset_subscription(kz_term:ne_binary(), kz_term:ne_binary()) -> any(). reset_subscription(User, Realm) -> API = [{<<"Realm">>, Realm} ,{<<"Username">>, User} @@ -125,7 +125,7 @@ reset_subscription(User, Realm) -> ], kz_amqp_worker:cast(API, fun kapi_presence:publish_reset/1). --spec reset_subscriber(ne_binary()) -> any(). +-spec reset_subscriber(kz_term:ne_binary()) -> any(). reset_subscriber(User) -> case omnip_subscriptions:find_user_subscriptions(?OMNIPRESENCE_EVENT_ALL, User) of {'ok', Subs} -> @@ -134,18 +134,18 @@ reset_subscriber(User) -> _ -> 'ok' end. --spec reset_subscriber(ne_binary(), ne_binary()) -> any(). +-spec reset_subscriber(kz_term:ne_binary(), kz_term:ne_binary()) -> any(). reset_subscriber(User, Realm) -> reset_subscriber(<>). --spec reset_account(ne_binary()) -> any(). +-spec reset_account(kz_term:ne_binary()) -> any(). reset_account(AccountId) -> case kz_account:fetch(AccountId) of {'ok', JObj} -> reset_realm(kz_account:realm(JObj)); {'error', _} = Error -> Error end. --spec reset_realm(ne_binary()) -> any(). +-spec reset_realm(kz_term:ne_binary()) -> any(). reset_realm(Realm) -> reset_subscription(<<"*">>, Realm). @@ -153,11 +153,11 @@ reset_realm(Realm) -> reset_zone() -> reset_zone(kz_term:to_binary(kz_config:zone())). --spec reset_zone(ne_binary()) -> any(). +-spec reset_zone(kz_term:ne_binary()) -> any(). reset_zone(Zone) -> reset_subscription(Zone, <<"*">>). --spec reset_server(ne_binary()) -> any(). +-spec reset_server(kz_term:ne_binary()) -> any(). reset_server(Server) -> reset_subscription(Server, <<"*">>). diff --git a/applications/omnipresence/src/omnipresence_shared_listener.erl b/applications/omnipresence/src/omnipresence_shared_listener.erl index dd4fff2fbc7..39081d0c731 100644 --- a/applications/omnipresence/src/omnipresence_shared_listener.erl +++ b/applications/omnipresence/src/omnipresence_shared_listener.erl @@ -25,8 +25,8 @@ -define(SERVER, ?MODULE). --record(state, {subs_pid :: api_pid() - ,subs_ref :: api_reference() +-record(state, {subs_pid :: kz_term:api_pid() + ,subs_ref :: kz_term:api_reference() }). -type state() :: #state{}. @@ -62,7 +62,7 @@ start_listener() -> %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link({'local', ?SERVER}, ?MODULE, [], []). @@ -102,7 +102,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -116,7 +116,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('find_subscriptions_srv', #state{subs_pid=_Pid}=State) -> case omnipresence_sup:subscriptions_srv() of 'undefined' -> @@ -151,7 +151,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'DOWN', Ref, 'process', Pid, _R}, #state{subs_pid=Pid ,subs_ref=Ref }=State) -> diff --git a/applications/omnipresence/src/omnipresence_sup.erl b/applications/omnipresence/src/omnipresence_sup.erl index ab1fb52eaf8..30033967a92 100644 --- a/applications/omnipresence/src/omnipresence_sup.erl +++ b/applications/omnipresence/src/omnipresence_sup.erl @@ -40,11 +40,11 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec subscriptions_srv() -> api_pid(). +-spec subscriptions_srv() -> kz_term:api_pid(). subscriptions_srv() -> case [P || {_, P, 'worker', ['omnip_subscriptions']} <- supervisor:which_children(?SERVER)] of [] -> 'undefined'; @@ -64,7 +64,7 @@ subscriptions_srv() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/pivot/src/pivot_app.erl b/applications/pivot/src/pivot_app.erl index e4a63aead70..c2a6a322992 100644 --- a/applications/pivot/src/pivot_app.erl +++ b/applications/pivot/src/pivot_app.erl @@ -17,7 +17,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = declare_exchanges(), pivot_sup:start_link(). diff --git a/applications/pivot/src/pivot_call.erl b/applications/pivot/src/pivot_call.erl index dff718fedf2..fbc30f93ff1 100644 --- a/applications/pivot/src/pivot_call.erl +++ b/applications/pivot/src/pivot_call.erl @@ -34,23 +34,23 @@ -type http_method() :: 'get' | 'post'. --record(state, {voice_uri :: api_ne_binary() - ,cdr_uri :: api_ne_binary() - ,request_format = <<"kazoo">> :: ne_binary() - ,request_body_format = <<"form">> :: ne_binary() +-record(state, {voice_uri :: kz_term:api_ne_binary() + ,cdr_uri :: kz_term:api_ne_binary() + ,request_format = <<"kazoo">> :: kz_term:ne_binary() + ,request_body_format = <<"form">> :: kz_term:ne_binary() ,method = 'get' :: http_method() ,call :: kapps_call:call() | 'undefined' ,request_id :: kz_http:req_id() | 'undefined' - ,request_params :: api_object() - ,response_code :: api_ne_binary() - ,response_headers :: binaries() | api_ne_binary() + ,request_params :: kz_term:api_object() + ,response_code :: kz_term:api_ne_binary() + ,response_headers :: kz_term:binaries() | kz_term:api_ne_binary() ,response_body = <<>> :: binary() - ,response_content_type :: api_binary() - ,response_pid :: api_pid() %% pid of the processing of the response - ,response_event_handlers = [] :: pids() - ,response_ref :: api_reference() %% monitor ref for the pid + ,response_content_type :: kz_term:api_binary() + ,response_pid :: kz_term:api_pid() %% pid of the processing of the response + ,response_event_handlers = [] :: kz_term:pids() + ,response_ref :: kz_term:api_reference() %% monitor ref for the pid ,debug = 'false' :: boolean() - ,requester_queue :: api_ne_binary() + ,requester_queue :: kz_term:api_ne_binary() }). -type state() :: #state{}. @@ -62,7 +62,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(kapps_call:call(), kz_json:object()) -> startlink_ret(). +-spec start_link(kapps_call:call(), kz_json:object()) -> kz_types:startlink_ret(). start_link(Call, JObj) -> CallId = kapps_call:call_id(Call), @@ -85,8 +85,8 @@ start_link(Call, JObj) -> -spec stop_call(pid(), kapps_call:call()) -> 'ok'. stop_call(Srv, Call) -> gen_listener:cast(Srv, {'stop', Call}). --spec new_request(pid(), ne_binary(), http_method()) -> 'ok'. --spec new_request(pid(), ne_binary(), http_method(), kz_json:object()) -> 'ok'. +-spec new_request(pid(), kz_term:ne_binary(), http_method()) -> 'ok'. +-spec new_request(pid(), kz_term:ne_binary(), http_method(), kz_json:object()) -> 'ok'. new_request(Srv, Uri, Method) -> gen_listener:cast(Srv, {'request', Uri, Method}). new_request(Srv, Uri, Method, Params) -> @@ -98,7 +98,7 @@ updated_call(Srv, Call) -> gen_listener:cast(Srv, {'updated_call', Call}). -spec usurp_executor(pid()) -> 'ok'. usurp_executor(Srv) -> gen_listener:cast(Srv, 'usurp'). --spec maybe_relay_event(kz_json:object(), kz_proplist()) -> 'ok'. +-spec maybe_relay_event(kz_json:object(), kz_term:proplist()) -> 'ok'. maybe_relay_event(JObj, Props) -> _ = case props:get_value('pid', Props) of P when is_pid(P) -> kapps_call_command:relay_event(P, JObj); @@ -111,7 +111,7 @@ maybe_relay_event(JObj, Props) -> end, relay_cdr_event(JObj, Props). --spec relay_cdr_event(kz_json:object(), kz_proplist()) -> 'ok'. +-spec relay_cdr_event(kz_json:object(), kz_term:proplist()) -> 'ok'. relay_cdr_event(JObj, Props) -> case kz_util:get_event_type(JObj) of {<<"call_event">>, <<"CHANNEL_DESTROY">>} -> @@ -175,7 +175,7 @@ init([Call, JObj]) -> %% {'stop', Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> {'reply', 'ok', state()}. +-spec handle_call(any(), kz_term:pid_ref(), state()) -> {'reply', 'ok', state()}. handle_call(_Request, _From, State) -> {'reply', 'ok', State}. @@ -393,7 +393,7 @@ handle_info(_Info, State) -> %% @doc %% Handling messaging bus events %% -%% @spec handle_event(JObj, State) -> {'noreply', kz_proplist()} | +%% @spec handle_event(JObj, State) -> {'noreply', kz_term:proplist()} | %% ignore %% @end %%-------------------------------------------------------------------- @@ -436,7 +436,7 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec send_req(kapps_call:call(), ne_binary(), http_method(), kz_json:object() | kz_proplist(), ne_binary(), boolean()) -> +-spec send_req(kapps_call:call(), kz_term:ne_binary(), http_method(), kz_json:object() | kz_term:proplist(), kz_term:ne_binary(), boolean()) -> {'ok', kz_http:req_id(), kapps_call:call()} | {'stop', kapps_call:call()}. send_req(Call, Uri, Method, BaseParams, ReqBodyFormat, Debug) when not is_list(BaseParams) -> @@ -453,7 +453,7 @@ send_req(Call, Uri, 'post', BaseParams, ReqBodyFormat, Debug) -> Headers = [{"Content-Type", req_content_type(ReqBodyFormat)}], send(UpdatedCall, Uri, 'post', Headers, format_request(Params, ReqBodyFormat), Debug). --spec send(kapps_call:call(), ne_binary(), http_method(), kz_proplist(), iolist(), boolean()) -> +-spec send(kapps_call:call(), kz_term:ne_binary(), http_method(), kz_term:proplist(), iolist(), boolean()) -> {'ok', kz_http:req_id(), kapps_call:call()} | {'stop', kapps_call:call()}. send(Call, Uri, Method, ReqHdrs, ReqBody, Debug) -> @@ -470,11 +470,11 @@ send(Call, Uri, Method, ReqHdrs, ReqBody, Debug) -> {'stop', Call} end. --spec normalize_resp_headers(kz_proplist()) -> kz_proplist(). +-spec normalize_resp_headers(kz_term:proplist()) -> kz_term:proplist(). normalize_resp_headers(Headers) -> [{kz_term:to_lower_binary(K), kz_term:to_binary(V)} || {K, V} <- Headers]. --spec handle_resp(api_binary(), kapps_call:call(), ne_binary(), binary()) -> 'ok'. +-spec handle_resp(kz_term:api_binary(), kapps_call:call(), kz_term:ne_binary(), binary()) -> 'ok'. handle_resp(RequesterQ, Call, CT, <<_/binary>> = RespBody) -> kz_util:put_callid(kapps_call:call_id(Call)), Srv = kzt_util:get_amqp_listener(Call), @@ -491,7 +491,7 @@ handle_resp(RequesterQ, Call, CT, <<_/binary>> = RespBody) -> ) end. --spec process_resp(api_binary(), kapps_call:call(), list() | binary(), binary()) -> +-spec process_resp(kz_term:api_binary(), kapps_call:call(), list() | binary(), binary()) -> {'stop', kapps_call:call()} | {'ok', kapps_call:call()} | {'request', kapps_call:call()} | @@ -536,7 +536,7 @@ process_resp(RequesterQ, Call, CT, RespBody) -> {'stop', Call} end. --spec publish_failed(kapps_call:call(), ne_binary()) -> 'ok'. +-spec publish_failed(kapps_call:call(), kz_term:ne_binary()) -> 'ok'. publish_failed(Call, RequesterQ) -> PubFun = fun(P) -> kapi_pivot:publish_failed(RequesterQ, P) end, kz_amqp_worker:cast([{<<"Call-ID">>, kapps_call:call_id(Call)} @@ -545,7 +545,7 @@ publish_failed(Call, RequesterQ) -> ,PubFun ). --spec uri(ne_binary(), iolist()) -> ne_binary(). +-spec uri(kz_term:ne_binary(), iolist()) -> kz_term:ne_binary(). uri(URI, QueryString) -> SuppliedQS = iolist_to_binary(QueryString), case kz_http_util:urlsplit(URI) of @@ -555,7 +555,7 @@ uri(URI, QueryString) -> kz_http_util:urlunsplit({Scheme, Host, Path, <>, Fragment}) end. --spec req_params(ne_binary(), kapps_call:call()) -> kz_proplist(). +-spec req_params(kz_term:ne_binary(), kapps_call:call()) -> kz_term:proplist(). req_params(Format, Call) -> FmtAtom = kz_term:to_atom(<<"kzt_", Format/binary>>, 'true'), try FmtAtom:req_params(Call) of @@ -566,7 +566,7 @@ req_params(Format, Call) -> 'error':'undef' -> [] end. --spec maybe_debug_req(kapps_call:call(), binary(), atom(), kz_proplist(), iolist(), boolean()) -> 'ok'. +-spec maybe_debug_req(kapps_call:call(), binary(), atom(), kz_term:proplist(), iolist(), boolean()) -> 'ok'. maybe_debug_req(_Call, _Uri, _Method, _ReqHdrs, _ReqBody, 'false') -> 'ok'; maybe_debug_req(Call, Uri, Method, ReqHdrs, ReqBody, 'true') -> Headers = kz_json:from_list([{fix_value(K), fix_value(V)} || {K, V} <- ReqHdrs]), @@ -576,7 +576,7 @@ maybe_debug_req(Call, Uri, Method, ReqHdrs, ReqBody, 'true') -> ,{<<"req_body">>, iolist_to_binary(ReqBody)} ]). --spec maybe_debug_resp(boolean(), kapps_call:call(), ne_binary(), kz_proplist(), binary()) -> 'ok'. +-spec maybe_debug_resp(boolean(), kapps_call:call(), kz_term:ne_binary(), kz_term:proplist(), binary()) -> 'ok'. maybe_debug_resp('false', _Call, _StatusCode, _RespHeaders, _RespBody) -> 'ok'; maybe_debug_resp('true', Call, StatusCode, RespHeaders, RespBody) -> Headers = kz_json:from_list([{fix_value(K), fix_value(V)} || {K, V} <- RespHeaders]), @@ -607,7 +607,7 @@ debug_json_error(Call, Msg, Before, After, RespBody) -> ]), store_debug(Call, JObj). --spec store_debug(kapps_call:call(), kz_proplist() | kz_json:object()) -> 'ok'. +-spec store_debug(kapps_call:call(), kz_term:proplist() | kz_json:object()) -> 'ok'. store_debug(Call, Doc) when is_list(Doc) -> store_debug(Call, kz_json:from_list(Doc)); store_debug(Call, DebugJObj) -> @@ -632,17 +632,17 @@ store_debug(Call, DebugJObj) -> lager:debug("failed to save debug doc: ~p", [_E]) end. --spec fix_value(number() | list()) -> number() | ne_binary(). +-spec fix_value(number() | list()) -> number() | kz_term:ne_binary(). fix_value(N) when is_number(N) -> N; fix_value(O) -> kz_term:to_lower_binary(O). --spec format_request(kz_json:object(), ne_binary()) -> iolist(). +-spec format_request(kz_json:object(), kz_term:ne_binary()) -> iolist(). format_request(Params, <<"form">>) -> kz_http_util:json_to_querystring(Params); format_request(Params, <<"json">>) -> kz_json:encode(Params). --spec req_content_type(ne_binary()) -> list(). +-spec req_content_type(kz_term:ne_binary()) -> list(). req_content_type(<<"form">>) -> "application/x-www-form-urlencoded"; req_content_type(<<"json">>) -> diff --git a/applications/pivot/src/pivot_calls_sup.erl b/applications/pivot/src/pivot_calls_sup.erl index 5798b92734e..bf6d2541e3d 100644 --- a/applications/pivot/src/pivot_calls_sup.erl +++ b/applications/pivot/src/pivot_calls_sup.erl @@ -32,11 +32,11 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec new(kapps_call:call(), kz_json:object()) -> sup_startchild_ret(). +-spec new(kapps_call:call(), kz_json:object()) -> kz_types:sup_startchild_ret(). new(Call, JObj) -> ExtraArgs = [Call, JObj], supervisor:start_child(?SERVER, ExtraArgs). @@ -58,7 +58,7 @@ workers() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 0, diff --git a/applications/pivot/src/pivot_handlers.erl b/applications/pivot/src/pivot_handlers.erl index 9cd811fa4b5..258bb76558c 100644 --- a/applications/pivot/src/pivot_handlers.erl +++ b/applications/pivot/src/pivot_handlers.erl @@ -12,7 +12,7 @@ -include("pivot.hrl"). --spec handle_pivot_req(kz_json:object(), kz_proplist()) -> any(). +-spec handle_pivot_req(kz_json:object(), kz_term:proplist()) -> any(). handle_pivot_req(JObj, _Props) -> 'true' = kapi_pivot:req_v(JObj), Call = kapps_call:from_json(kz_json:get_value(<<"Call">>, JObj)), diff --git a/applications/pivot/src/pivot_listener.erl b/applications/pivot/src/pivot_listener.erl index 5b3b79b99af..72b508f9388 100644 --- a/applications/pivot/src/pivot_listener.erl +++ b/applications/pivot/src/pivot_listener.erl @@ -45,7 +45,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'bindings', ?BINDINGS} ,{'responders', ?RESPONDERS} @@ -87,7 +87,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> +-spec handle_call(any(), kz_term:pid_ref(), state()) -> {'reply', {'error', 'not_implemented'}, state()}. handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. diff --git a/applications/pivot/src/pivot_sup.erl b/applications/pivot/src/pivot_sup.erl index 11288160b7f..31d4239ee54 100644 --- a/applications/pivot/src/pivot_sup.erl +++ b/applications/pivot/src/pivot_sup.erl @@ -30,7 +30,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -47,7 +47,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/pusher/src/kapi_pusher.erl b/applications/pusher/src/kapi_pusher.erl index f920d765a4e..ff0e2e113a5 100644 --- a/applications/pusher/src/kapi_pusher.erl +++ b/applications/pusher/src/kapi_pusher.erl @@ -47,7 +47,7 @@ -define(KEY_PUSH, <<"notification.push">>). --spec push_req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec push_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. push_req(Prop) when is_list(Prop) -> case push_req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?PUSH_REQ_HEADERS, ?OPTIONAL_PUSH_REQ_HEADERS); @@ -56,13 +56,13 @@ push_req(Prop) when is_list(Prop) -> push_req(JObj) -> push_req(kz_json:to_proplist(JObj)). --spec push_req_v(api_terms()) -> boolean(). +-spec push_req_v(kz_term:api_terms()) -> boolean(). push_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?PUSH_REQ_HEADERS, ?PUSH_REQ_VALUES, ?PUSH_REQ_TYPES); push_req_v(JObj) -> push_req_v(kz_json:to_proplist(JObj)). --spec push_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec push_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. push_resp(Prop) when is_list(Prop) -> case push_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?PUSH_RESP_HEADERS, ?OPTIONAL_PUSH_RESP_HEADERS); @@ -71,37 +71,37 @@ push_resp(Prop) when is_list(Prop) -> push_resp(JObj) -> push_resp(kz_json:to_proplist(JObj)). --spec push_resp_v(api_terms()) -> boolean(). +-spec push_resp_v(kz_term:api_terms()) -> boolean(). push_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?PUSH_RESP_HEADERS, ?PUSH_RESP_VALUES, ?PUSH_RESP_TYPES); push_resp_v(JObj) -> push_resp_v(kz_json:to_proplist(JObj)). --spec publish_push_req(api_terms()) -> 'ok'. --spec publish_push_req(api_terms(), binary()) -> 'ok'. +-spec publish_push_req(kz_term:api_terms()) -> 'ok'. +-spec publish_push_req(kz_term:api_terms(), binary()) -> 'ok'. publish_push_req(JObj) -> publish_push_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_push_req(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?PUSH_REQ_VALUES, fun push_req/1), amqp_util:basic_publish(?PUSH_EXCHANGE, push_routing_key(Req), Payload, ContentType). --spec publish_push_resp(api_terms()) -> 'ok'. --spec publish_push_resp(api_terms(), binary()) -> 'ok'. +-spec publish_push_resp(kz_term:api_terms()) -> 'ok'. +-spec publish_push_resp(kz_term:api_terms(), binary()) -> 'ok'. publish_push_resp(JObj) -> publish_push_resp(JObj, ?DEFAULT_CONTENT_TYPE). publish_push_resp(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?PUSH_RESP_VALUES, fun push_resp/1), amqp_util:basic_publish(?PUSH_EXCHANGE, push_routing_key(Req), Payload, ContentType). --spec publish_targeted_push_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_targeted_push_resp(ne_binary(), api_terms(), binary()) -> 'ok'. +-spec publish_targeted_push_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_targeted_push_resp(kz_term:ne_binary(), kz_term:api_terms(), binary()) -> 'ok'. publish_targeted_push_resp(RespQ, JObj) -> publish_targeted_push_resp(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_targeted_push_resp(RespQ, JObj, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(JObj, ?PUSH_RESP_VALUES, fun push_resp/1), amqp_util:targeted_publish(RespQ, Payload, ContentType). --spec push_routing_key(ne_binary() | api_terms()) -> ne_binary(). +-spec push_routing_key(kz_term:ne_binary() | kz_term:api_terms()) -> kz_term:ne_binary(). push_routing_key(Req) when is_list(Req) -> push_routing_key(props:get_value(<<"Token-Type">>, Req, <<"*">>), props:get_value(<<"Token">>, Req,<<"*">>)); push_routing_key(Req) -> @@ -111,8 +111,8 @@ push_routing_key(Type, Token) -> %% API Helpers --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. --spec bind_q(ne_binary(), ne_binary(), ne_binary(), api_binaries()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binaries()) -> 'ok'. bind_q(Queue, Props) -> Token = props:get_value('token', Props, <<"*">>), Type = props:get_value('type', Props, <<"*">>), @@ -127,8 +127,8 @@ bind_q(Queue, Type, Token, [_|Restrict]) -> bind_q(Queue, Type, Token, Restrict); bind_q(_Queue, _Type, _Token, []) -> 'ok'. --spec unbind_q(binary(), kz_proplist()) -> 'ok'. --spec unbind_q(ne_binary(), ne_binary(), ne_binary(), api_binaries()) -> 'ok'. +-spec unbind_q(binary(), kz_term:proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binaries()) -> 'ok'. unbind_q(Queue, Props) -> Token = props:get_value('token', Props, <<"*">>), Type = props:get_value('type', Props, <<"*">>), diff --git a/applications/pusher/src/modules/pm_apple.erl b/applications/pusher/src/modules/pm_apple.erl index 2bd6c7a0154..2a4c5c0497e 100644 --- a/applications/pusher/src/modules/pm_apple.erl +++ b/applications/pusher/src/modules/pm_apple.erl @@ -18,7 +18,7 @@ -record(state, {tab :: ets:tid()}). -type state() :: #state{}. --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_server:start_link({'local', ?SERVER}, ?MODULE, [],[]). @@ -27,11 +27,11 @@ init([]) -> kz_util:put_callid(?MODULE), {'ok', #state{tab=ets:new(?MODULE, [])}}. --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'push', JObj}, #state{tab=ETS}=State) -> TokenApp = kz_json:get_value(<<"Token-App">>, JObj), maybe_send_push_notification(get_apns(TokenApp, ETS), JObj), @@ -39,7 +39,7 @@ handle_cast({'push', JObj}, #state{tab=ETS}=State) -> handle_cast('stop', State) -> {'stop', 'normal', State}. --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Request, State) -> {'noreply', State}. @@ -52,7 +52,7 @@ terminate(_Reason, #state{tab=ETS}) -> code_change(_OldVsn, State, _Extra) -> {'ok', State}. --spec maybe_send_push_notification(api_pid(), kz_json:object()) -> any(). +-spec maybe_send_push_notification(kz_term:api_pid(), kz_json:object()) -> any(). maybe_send_push_notification('undefined', _) -> 'ok'; maybe_send_push_notification(Pid, JObj) -> TokenID = kz_json:get_value(<<"Token-ID">>, JObj), @@ -71,7 +71,7 @@ maybe_send_push_notification(Pid, JObj) -> ,#{apns_topic => APNsTopic} ). --spec get_apns(api_binary(), ets:tid()) -> api_pid(). +-spec get_apns(kz_term:api_binary(), ets:tid()) -> kz_term:api_pid(). get_apns('undefined', _) -> 'undefined'; get_apns(App, ETS) -> case ets:lookup(ETS, App) of @@ -79,13 +79,13 @@ get_apns(App, ETS) -> [{App, Pid}] -> Pid end. --spec maybe_load_apns(api_binary(), ets:tid()) -> api_pid(). +-spec maybe_load_apns(kz_term:api_binary(), ets:tid()) -> kz_term:api_pid(). maybe_load_apns(App, ETS) -> CertBin = kapps_config:get_ne_binary(?CONFIG_CAT, [<<"apple">>, <<"certificate">>], 'undefined', App), Host = kapps_config:get_ne_binary(?CONFIG_CAT, [<<"apple">>, <<"host">>], ?DEFAULT_APNS_HOST, App), maybe_load_apns(App, ETS, CertBin, Host). --spec maybe_load_apns(api_binary(), ets:tid(), api_ne_binary(), ne_binary()) -> api_pid(). +-spec maybe_load_apns(kz_term:api_binary(), ets:tid(), kz_term:api_ne_binary(), kz_term:ne_binary()) -> kz_term:api_pid(). maybe_load_apns(App, _, 'undefined', _) -> lager:debug("apple pusher certificate for app ~s not found", [App]), 'undefined'; @@ -126,6 +126,6 @@ apns_topic(JObj) -> end. %% Retains the old behaviour --spec default_apns_topic(ne_binary()) -> ne_binary(). +-spec default_apns_topic(kz_term:ne_binary()) -> kz_term:ne_binary(). default_apns_topic(TokenApp) -> re:replace(TokenApp, <<"\\.(?:dev|prod)$">>, <<>>, [{'return', 'binary'}]). diff --git a/applications/pusher/src/modules/pm_google.erl b/applications/pusher/src/modules/pm_google.erl index 90bdf325956..9ffccd20697 100644 --- a/applications/pusher/src/modules/pm_google.erl +++ b/applications/pusher/src/modules/pm_google.erl @@ -18,7 +18,7 @@ -record(state, {tab :: ets:tid()}). -type state() :: #state{}. --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_server:start_link({'local', ?SERVER}, ?MODULE, [],[]). @@ -28,11 +28,11 @@ init([]) -> lager:debug("starting server"), {'ok', #state{tab=ets:new(?MODULE, [])}}. --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'push', JObj}, #state{tab=ETS}=State) -> lager:debug("process a push"), TokenApp = kz_json:get_value(<<"Token-App">>, JObj), @@ -41,7 +41,7 @@ handle_cast({'push', JObj}, #state{tab=ETS}=State) -> handle_cast('stop', State) -> {'stop', 'normal', State}. --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Request, State) -> {'noreply', State}. @@ -54,7 +54,7 @@ terminate(_Reason, #state{tab=ETS}) -> code_change(_OldVsn, State, _Extra) -> {'ok', State}. --spec maybe_send_push_notification(api_pid(), kz_json:object()) -> any(). +-spec maybe_send_push_notification(kz_term:api_pid(), kz_json:object()) -> any(). maybe_send_push_notification('undefined', _JObj) -> lager:debug("no pid to send push"); maybe_send_push_notification(Pid, JObj) -> TokenID = kz_json:get_value(<<"Token-ID">>, JObj), @@ -65,7 +65,7 @@ maybe_send_push_notification(Pid, JObj) -> gcm:push(Pid, [TokenID], Message). --spec get_gcm(api_binary(), ets:tid()) -> api_pid(). +-spec get_gcm(kz_term:api_binary(), ets:tid()) -> kz_term:api_pid(). get_gcm('undefined', _) -> 'undefined'; get_gcm(App, ETS) -> case ets:lookup(ETS, App) of @@ -73,12 +73,12 @@ get_gcm(App, ETS) -> [{App, Pid}] -> Pid end. --spec maybe_load_gcm(api_binary(), ets:tid()) -> api_pid(). +-spec maybe_load_gcm(kz_term:api_binary(), ets:tid()) -> kz_term:api_pid(). maybe_load_gcm(App, ETS) -> lager:debug("loading gcm secret for ~s", [App]), maybe_load_gcm(App, ETS, kapps_config:get_binary(?CONFIG_CAT, <<"google">>, 'undefined', App)). --spec maybe_load_gcm(api_binary(), ets:tid(), api_binary()) -> api_pid(). +-spec maybe_load_gcm(kz_term:api_binary(), ets:tid(), kz_term:api_binary()) -> kz_term:api_pid(). maybe_load_gcm(App, _, 'undefined') -> lager:debug("google pusher secret for app ~s not found", [App]), 'undefined'; diff --git a/applications/pusher/src/pusher_app.erl b/applications/pusher/src/pusher_app.erl index 5d79e473f2c..4911db47bce 100644 --- a/applications/pusher/src/pusher_app.erl +++ b/applications/pusher/src/pusher_app.erl @@ -17,7 +17,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = declare_exchanges(), pusher_sup:start_link(). diff --git a/applications/pusher/src/pusher_listener.erl b/applications/pusher/src/pusher_listener.erl index 98f65b0b216..66382ef2509 100644 --- a/applications/pusher/src/pusher_listener.erl +++ b/applications/pusher/src/pusher_listener.erl @@ -29,8 +29,8 @@ -define(SERVER, ?MODULE). --record(state, {subs_pid :: api_pid() - ,subs_ref :: api_reference() +-record(state, {subs_pid :: kz_term:api_pid() + ,subs_ref :: kz_term:api_reference() }). -type state() :: #state{}. @@ -55,7 +55,7 @@ %%% API %%%=================================================================== --spec handle_push(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_push(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_push(JObj, _Props) -> Token = kz_json:get_value(<<"Token-ID">>, JObj), TokenType = kz_json:get_value(<<"Token-Type">>, JObj), @@ -70,15 +70,15 @@ handle_push(JObj, _Props) -> ), gen_server:cast(Module, {'push', JObj}). --spec handle_reg_success(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_reg_success(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_reg_success(JObj, _Props) -> UserAgent = kz_json:get_value(<<"User-Agent">>, JObj), UserAgentProperties = pusher_util:user_agent_push_properties(UserAgent), maybe_process_reg_success(UserAgentProperties, JObj). --spec maybe_process_reg_success(api_object(), kz_json:object()) -> 'ok'. --spec maybe_process_reg_success(api_binary(), kz_json:object(), kz_json:object(), kz_proplist()) -> 'ok'. +-spec maybe_process_reg_success(kz_term:api_object(), kz_json:object()) -> 'ok'. +-spec maybe_process_reg_success(kz_term:api_binary(), kz_json:object(), kz_json:object(), kz_term:proplist()) -> 'ok'. maybe_process_reg_success('undefined', _JObj) -> 'ok'; maybe_process_reg_success(UA, JObj) -> Contact = kz_json:get_value(<<"Contact">>, JObj), @@ -97,8 +97,8 @@ maybe_process_reg_success(Token, UA, JObj, Params) -> {'ok', TokenJObj} -> send_reply(Token, TokenJObj) end. --spec maybe_update_push_token(kz_json:object(), kz_json:object(), kz_proplist()) -> 'ok'. --spec maybe_update_push_token(api_binary(), api_binary(), kz_json:object(), kz_json:object(), kz_proplist()) -> 'ok'. +-spec maybe_update_push_token(kz_json:object(), kz_json:object(), kz_term:proplist()) -> 'ok'. +-spec maybe_update_push_token(kz_term:api_binary(), kz_term:api_binary(), kz_json:object(), kz_json:object(), kz_term:proplist()) -> 'ok'. maybe_update_push_token(UA, JObj, Params) -> AccountId = kz_json:get_first_defined([[<<"Custom-Channel-Vars">>, <<"Account-ID">>] ,<<"Account-ID">> @@ -125,7 +125,7 @@ maybe_update_push_token(AccountId, AuthorizingId, UA, JObj, Params) -> {'error', _} -> lager:debug("failed to open ~s in ~s", [AuthorizingId, AccountId]) end. --spec build_push(kz_json:object(), kz_json:object(), kz_proplist(), kz_json:object()) -> +-spec build_push(kz_json:object(), kz_json:object(), kz_term:proplist(), kz_json:object()) -> kz_json:object(). build_push(UA, JObj, Params, InitialAcc) -> kz_json:foldl( @@ -133,7 +133,7 @@ build_push(UA, JObj, Params, InitialAcc) -> build_push_fold(K, V, Acc, JObj, Params) end, InitialAcc, UA). --spec build_push_fold(kz_json:path(), kz_json:json_term(), kz_json:object(), kz_json:object(), kz_proplist()) -> kz_json:object(). +-spec build_push_fold(kz_json:path(), kz_json:json_term(), kz_json:object(), kz_json:object(), kz_term:proplist()) -> kz_json:object(). build_push_fold(K, V, Acc, JObj, Params) -> case props:get_value(V, Params) of 'undefined' -> @@ -144,7 +144,7 @@ build_push_fold(K, V, Acc, JObj, Params) -> V2 -> kz_json:set_value(K, V2, Acc) end. --spec send_reply(ne_binary(), kz_json:object()) -> 'ok'. +-spec send_reply(kz_term:ne_binary(), kz_json:object()) -> 'ok'. send_reply(Token, JObj) -> kz_cache:erase_local(?CACHE_NAME, Token), Queue = kz_json:get_value(<<"Server-ID">>, JObj), @@ -158,7 +158,7 @@ send_reply(Token, JObj) -> %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'bindings', ?BINDINGS} ,{'responders', ?RESPONDERS} @@ -202,7 +202,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -216,7 +216,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'kz_amqp_channel',{'new_channel',_IsNew}}, State) -> {'noreply', State}; handle_cast({'gen_listener',{'created_queue',_Queue}}, State) -> @@ -243,7 +243,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'DOWN', _Ref, 'process', _Pid, _R}, State) -> {'noreply', State}; handle_info(_Info, State) -> diff --git a/applications/pusher/src/pusher_module_sup.erl b/applications/pusher/src/pusher_module_sup.erl index aba8b2e9f8e..0d46f2126e8 100644 --- a/applications/pusher/src/pusher_module_sup.erl +++ b/applications/pusher/src/pusher_module_sup.erl @@ -31,7 +31,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -48,7 +48,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 1000, diff --git a/applications/pusher/src/pusher_sup.erl b/applications/pusher/src/pusher_sup.erl index 01bd77d429a..4a1918c21d1 100644 --- a/applications/pusher/src/pusher_sup.erl +++ b/applications/pusher/src/pusher_sup.erl @@ -30,7 +30,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -47,7 +47,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/pusher/src/pusher_util.erl b/applications/pusher/src/pusher_util.erl index 53ba0b4fb50..2a201abf011 100644 --- a/applications/pusher/src/pusher_util.erl +++ b/applications/pusher/src/pusher_util.erl @@ -34,7 +34,7 @@ -type keycert() :: {'undefined' | {'PrivateKeyInfo' | 'RSAPrivateKey', binary()} - ,api_binary() + ,kz_term:api_binary() }. -export_type([keycert/0]). @@ -61,8 +61,8 @@ keycert_fold({'RSAPrivateKey', Bin, 'not_encrypted'}, {'undefined', Cert}) -> keycert_fold(_Entry, KeyCert) -> KeyCert. --spec user_agent_push_properties(ne_binary()) -> api_object(). --spec user_agent_push_properties(ne_binary(), kz_json:objects()) -> api_object(). +-spec user_agent_push_properties(kz_term:ne_binary()) -> kz_term:api_object(). +-spec user_agent_push_properties(kz_term:ne_binary(), kz_json:objects()) -> kz_term:api_object(). user_agent_push_properties(UserAgent) -> UAs = kapps_config:get_json(?CONFIG_CAT, <<"User-Agents">>, kz_json:new()), user_agent_push_properties(UserAgent, kz_json:values(UAs)). diff --git a/applications/registrar/src/reg.hrl b/applications/registrar/src/reg.hrl index a05928d9574..3bd343ef997 100644 --- a/applications/registrar/src/reg.hrl +++ b/applications/registrar/src/reg.hrl @@ -9,27 +9,27 @@ -define(CACHE_NAME, 'registrar_cache'). --record(auth_user, {realm :: ne_binary() - ,username :: ne_binary() - ,password :: api_binary() - ,account_id :: api_binary() - ,account_db :: api_binary() - ,authorizing_type :: api_binary() - ,authorizing_id :: api_binary() - ,method :: api_binary() - ,owner_id :: api_binary() +-record(auth_user, {realm :: kz_term:ne_binary() + ,username :: kz_term:ne_binary() + ,password :: kz_term:api_binary() + ,account_id :: kz_term:api_binary() + ,account_db :: kz_term:api_binary() + ,authorizing_type :: kz_term:api_binary() + ,authorizing_id :: kz_term:api_binary() + ,method :: kz_term:api_binary() + ,owner_id :: kz_term:api_binary() ,suppress_unregister_notifications = 'false' :: boolean() ,register_overwrite_notify = 'false' :: boolean() - ,account_realm :: api_binary() - ,account_normalized_realm :: api_binary() - ,account_name :: api_binary() - ,nonce :: api_binary() - ,a3a8_key :: api_binary() - ,a3a8_kc :: api_binary() - ,a3a8_sres :: api_binary() - ,msisdn :: api_binary() - ,doc :: api_object() - ,request :: api_object() + ,account_realm :: kz_term:api_binary() + ,account_normalized_realm :: kz_term:api_binary() + ,account_name :: kz_term:api_binary() + ,nonce :: kz_term:api_binary() + ,a3a8_key :: kz_term:api_binary() + ,a3a8_kc :: kz_term:api_binary() + ,a3a8_sres :: kz_term:api_binary() + ,msisdn :: kz_term:api_binary() + ,doc :: kz_term:api_object() + ,request :: kz_term:api_object() }). -type auth_user() :: #auth_user{}. diff --git a/applications/registrar/src/reg_authn_req.erl b/applications/registrar/src/reg_authn_req.erl index 87f23d00047..16efe09d62c 100644 --- a/applications/registrar/src/reg_authn_req.erl +++ b/applications/registrar/src/reg_authn_req.erl @@ -24,7 +24,7 @@ -spec init() -> 'ok'. init() -> 'ok'. --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Props) -> 'true' = kapi_authn:req_v(JObj), _ = kz_util:put_callid(JObj), @@ -108,7 +108,7 @@ create_ccvs(#auth_user{doc=JObj}=AuthUser) -> ++ generate_security_ccvs(AuthUser)) ]). --spec maybe_get_presence_id(auth_user()) -> api_binary(). +-spec maybe_get_presence_id(auth_user()) -> kz_term:api_binary(). maybe_get_presence_id(#auth_user{account_db=AccountDb ,authorizing_id=DeviceId ,owner_id=OwnerId @@ -124,7 +124,7 @@ maybe_get_presence_id(#auth_user{account_db=AccountDb end end. --spec get_presence_id(api_binary(), api_binary(), api_binary()) -> api_binary(). +-spec get_presence_id(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary()) -> kz_term:api_binary(). get_presence_id('undefined', _, _) -> 'undefined'; get_presence_id(_, 'undefined', 'undefined') -> 'undefined'; get_presence_id(AccountDb, DeviceId, 'undefined') -> @@ -132,7 +132,7 @@ get_presence_id(AccountDb, DeviceId, 'undefined') -> get_presence_id(AccountDb, DeviceId, OwnerId) -> maybe_get_owner_presence_id(AccountDb, DeviceId, OwnerId). --spec maybe_get_owner_presence_id(ne_binary(), ne_binary(), ne_binary()) -> api_binary(). +-spec maybe_get_owner_presence_id(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_binary(). maybe_get_owner_presence_id(AccountDb, DeviceId, OwnerId) -> case kz_datamgr:open_cache_doc(AccountDb, OwnerId) of {'error', _} -> 'undefined'; @@ -143,7 +143,7 @@ maybe_get_owner_presence_id(AccountDb, DeviceId, OwnerId) -> end end. --spec get_device_presence_id(ne_binary(), ne_binary()) -> api_binary(). +-spec get_device_presence_id(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_binary(). get_device_presence_id(AccountDb, DeviceId) -> case kz_datamgr:open_cache_doc(AccountDb, DeviceId) of {'error', _} -> 'undefined'; @@ -154,14 +154,14 @@ get_device_presence_id(AccountDb, DeviceId) -> end end. --spec create_specific_ccvs(auth_user(), ne_binary()) -> kz_proplist(). +-spec create_specific_ccvs(auth_user(), kz_term:ne_binary()) -> kz_term:proplist(). create_specific_ccvs(#auth_user{msisdn=MSISDN}, ?GSM_ANY_METHOD) -> [{<<"Caller-ID">>, MSISDN} ,{<<"Caller-ID-Number">>, MSISDN} ]; create_specific_ccvs(_, _) -> []. --spec create_custom_sip_headers(api_binary(), auth_user()) -> api_object(). +-spec create_custom_sip_headers(kz_term:api_binary(), auth_user()) -> kz_term:api_object(). create_custom_sip_headers(?GSM_ANY_METHOD ,#auth_user{a3a8_kc=KC ,a3a8_sres=SRES @@ -182,11 +182,11 @@ create_custom_sip_headers(?GSM_ANY_METHOD ); create_custom_sip_headers(?ANY_AUTH_METHOD, _) -> 'undefined'. --spec create_custom_sip_headers(kz_proplist()) -> api_object(). +-spec create_custom_sip_headers(kz_term:proplist()) -> kz_term:api_object(). create_custom_sip_headers([]) -> 'undefined'; create_custom_sip_headers(Props) -> kz_json:from_list(Props). --spec get_tel_uri(api_binary()) -> api_binary(). +-spec get_tel_uri(kz_term:api_binary()) -> kz_term:api_binary(). get_tel_uri('undefined') -> 'undefined'; get_tel_uri(Number) -> <<"">>. @@ -196,7 +196,7 @@ get_tel_uri(Number) -> <<"">>. %% look up the user and realm in the database and return the result %% @end %%----------------------------------------------------------------------------- --spec lookup_auth_user(ne_binary(), ne_binary(), kz_json:object()) -> +-spec lookup_auth_user(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> {'ok', auth_user()} | {'error', any()}. lookup_auth_user(Username, Realm, Req) -> @@ -205,7 +205,7 @@ lookup_auth_user(Username, Realm, Req) -> {'ok', JObj} -> check_auth_user(JObj, Username, Realm, Req) end. --spec get_auth_user(ne_binary(), ne_binary()) -> +-spec get_auth_user(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', 'not_found'}. get_auth_user(Username, Realm) -> @@ -223,7 +223,7 @@ get_auth_user(Username, Realm) -> get_auth_user_in_account(Username, Realm, AccountDB) end. --spec get_auth_user_in_agg(ne_binary(), ne_binary()) -> +-spec get_auth_user_in_agg(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', 'not_found'}. get_auth_user_in_agg(Username, Realm) -> @@ -247,7 +247,7 @@ get_auth_user_in_agg(Username, Realm) -> {'ok', User} end. --spec get_auth_user_in_account(ne_binary(), ne_binary(), ne_binary()) -> +-spec get_auth_user_in_account(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', 'not_found'}. get_auth_user_in_account(Username, Realm, AccountDB) -> @@ -272,7 +272,7 @@ get_auth_user_in_account(Username, Realm, AccountDB) -> %% %% @end %%----------------------------------------------------------------------------- --spec check_auth_user(kz_json:object(), ne_binary(), ne_binary(), kz_json:object()) -> +-spec check_auth_user(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> {'ok', auth_user()} | {'error', 'disabled'}. check_auth_user(JObj, Username, Realm, Req) -> @@ -287,7 +287,7 @@ check_auth_user(JObj, Username, Realm, Req) -> {'error', 'disabled'} end. --spec jobj_to_auth_user(kz_json:object(), ne_binary(), ne_binary(), kz_json:object()) -> +-spec jobj_to_auth_user(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> {'ok', auth_user()} | {'error', any()}. jobj_to_auth_user(JObj, Username, Realm, Req) -> @@ -310,14 +310,14 @@ jobj_to_auth_user(JObj, Username, Realm, Req) -> }, maybe_auth_method(add_account_name(AuthUser), AuthDoc, Req, Method). --spec get_auth_type(kz_json:object()) -> ne_binary(). +-spec get_auth_type(kz_json:object()) -> kz_term:ne_binary(). get_auth_type(AuthDoc) -> case kz_json:get_first_defined([<<"endpoint_type">>, <<"device_type">>], AuthDoc) of <<"mobile">> -> <<"mobile">>; _ -> kz_doc:type(AuthDoc, <<"anonymous">>) end. --spec get_auth_value(kz_json:object()) -> api_object(). +-spec get_auth_value(kz_json:object()) -> kz_term:api_object(). get_auth_value(JObj) -> kz_json:get_first_defined([[<<"doc">>,<<"sip">>] ,<<"value">> @@ -337,7 +337,7 @@ add_account_name(#auth_user{account_id=AccountId}=AuthUser) -> } end. --spec get_auth_method(kz_json:object() | ne_binary()) -> ne_binary(). +-spec get_auth_method(kz_json:object() | kz_term:ne_binary()) -> kz_term:ne_binary(). get_auth_method(?GSM_ANY_METHOD=M) when is_binary(M)-> <<"gsm">>; get_auth_method(M) when is_binary(M) -> M; get_auth_method(JObj) -> @@ -348,7 +348,7 @@ get_auth_method(JObj) -> ,<<"password">> ). --spec maybe_auth_method(auth_user(), kz_json:object(), kz_json:object(), ne_binary()) -> +-spec maybe_auth_method(auth_user(), kz_json:object(), kz_json:object(), kz_term:ne_binary()) -> {'ok', auth_user()} | {'error', any()}. maybe_auth_method(AuthUser, JObj, Req, ?GSM_ANY_METHOD)-> @@ -376,7 +376,7 @@ maybe_auth_method(AuthUser, _JObj, _Req, ?ANY_AUTH_METHOD)-> -define(GSM_PRE_REGISTER_ROUTINES, [fun maybe_msisdn/1]). -define(GSM_REGISTER_ROUTINES, [fun maybe_msisdn/1]). --spec maybe_update_gsm(api_binary(), auth_user()) -> auth_user(). +-spec maybe_update_gsm(kz_term:api_binary(), auth_user()) -> auth_user(). maybe_update_gsm(<<"PRE-REGISTER">>, AuthUser) -> lists:foldl(fun(F,A) -> F(A) end, AuthUser, ?GSM_PRE_REGISTER_ROUTINES); maybe_update_gsm(<<"REGISTER">>, AuthUser) -> @@ -395,7 +395,7 @@ maybe_msisdn(#auth_user{msisdn='undefined' maybe_msisdn_from_callflows(AuthUser, <<"user">>, OwnerId); maybe_msisdn(AuthUser) -> AuthUser. --spec maybe_msisdn_from_callflows(auth_user(), ne_binary(), ne_binary()) -> auth_user(). +-spec maybe_msisdn_from_callflows(auth_user(), kz_term:ne_binary(), kz_term:ne_binary()) -> auth_user(). maybe_msisdn_from_callflows(#auth_user{account_db=AccountDB}=AuthUser ,Type ,Id @@ -444,7 +444,7 @@ gsm_auth(AuthUser) -> {'ok', AuthUser}. %% %% @end %%----------------------------------------------------------------------------- --spec get_account_id(kz_json:object()) -> api_binary(). +-spec get_account_id(kz_json:object()) -> kz_term:api_binary(). get_account_id(JObj) -> case get_account_db(JObj) of 'undefined' -> 'undefined'; @@ -457,7 +457,7 @@ get_account_id(JObj) -> %% %% @end %%----------------------------------------------------------------------------- --spec get_account_db(kz_json:object()) -> api_binary(). +-spec get_account_db(kz_json:object()) -> kz_term:api_binary(). get_account_db(JObj) -> case kz_json:get_first_defined([[<<"doc">>, <<"pvt_account_db">>] ,<<"pvt_account_db">> @@ -469,11 +469,11 @@ get_account_db(JObj) -> AccountDb -> kz_util:format_account_id(AccountDb, 'encoded') end. --spec remove_dashes(ne_binary()) -> ne_binary(). +-spec remove_dashes(kz_term:ne_binary()) -> kz_term:ne_binary(). remove_dashes(Bin) -> << <> || <> <= Bin, B =/= $->>. --spec encryption_method_map(kz_proplist(), api_binaries() | kz_json:object()) -> kz_proplist(). +-spec encryption_method_map(kz_term:proplist(), kz_term:api_binaries() | kz_json:object()) -> kz_term:proplist(). encryption_method_map(Props, []) -> Props; encryption_method_map(Props, [Method|Methods]) -> case props:get_value(Method, ?ENCRYPTION_MAP, []) of @@ -485,8 +485,8 @@ encryption_method_map(Props, JObj) -> Methods = kz_json:get_value(Key, JObj, []), encryption_method_map(Props, Methods). --spec generate_security_ccvs(auth_user()) -> kz_proplist(). --spec generate_security_ccvs(auth_user(), kz_proplist()) -> kz_proplist(). +-spec generate_security_ccvs(auth_user()) -> kz_term:proplist(). +-spec generate_security_ccvs(auth_user(), kz_term:proplist()) -> kz_term:proplist(). generate_security_ccvs(#auth_user{}=User) -> generate_security_ccvs(User, []). @@ -498,7 +498,7 @@ generate_security_ccvs(#auth_user{}=User, Acc0) -> {_, Acc} = lists:foldl(fun(F, Acc) -> F(Acc) end, {User, Acc0}, CCVFuns), Acc. --spec maybe_enforce_security({auth_user(), kz_proplist()}) -> {auth_user(), kz_proplist()}. +-spec maybe_enforce_security({auth_user(), kz_term:proplist()}) -> {auth_user(), kz_term:proplist()}. maybe_enforce_security({#auth_user{doc=JObj}=User, Acc}) -> case kz_json:is_true([<<"media">> ,<<"encryption">> @@ -509,6 +509,6 @@ maybe_enforce_security({#auth_user{doc=JObj}=User, Acc}) -> 'false' -> {User, Acc} end. --spec maybe_set_encryption_flags({auth_user(), kz_proplist()}) -> {auth_user(), kz_proplist()}. +-spec maybe_set_encryption_flags({auth_user(), kz_term:proplist()}) -> {auth_user(), kz_term:proplist()}. maybe_set_encryption_flags({#auth_user{doc=JObj}=User, Acc}) -> {User, encryption_method_map(Acc, JObj)}. diff --git a/applications/registrar/src/reg_route_req.erl b/applications/registrar/src/reg_route_req.erl index e5d6149b3f3..ae57942cef2 100644 --- a/applications/registrar/src/reg_route_req.erl +++ b/applications/registrar/src/reg_route_req.erl @@ -18,7 +18,7 @@ -spec init() -> 'ok'. init() -> 'ok'. --spec handle_route_req(kz_json:object(), kz_proplist()) -> any(). +-spec handle_route_req(kz_json:object(), kz_term:proplist()) -> any(). handle_route_req(JObj, _Props) -> 'true' = kapi_route:req_v(JObj), kz_util:put_callid(JObj), @@ -30,7 +30,7 @@ handle_route_req(JObj, _Props) -> end. -spec maybe_replay_route_req(kz_json:object(), kz_json:object()) -> 'ok'. --spec maybe_replay_route_req(kz_json:object(), kz_json:object(), api_binary()) -> 'ok'. +-spec maybe_replay_route_req(kz_json:object(), kz_json:object(), kz_term:api_binary()) -> 'ok'. maybe_replay_route_req(JObj, CCVs) -> maybe_replay_route_req(JObj, CCVs, kz_json:get_value(<<"From-Network-Addr">>, JObj)). @@ -57,8 +57,8 @@ maybe_replay_route_req(JObj, CCVs, IP) -> %% lookup auth by IP in cache/database and return the result %% @end %%----------------------------------------------------------------------------- --spec lookup_account_by_ip(ne_binary()) -> - {'ok', kz_proplist()} | +-spec lookup_account_by_ip(kz_term:ne_binary()) -> + {'ok', kz_term:proplist()} | {'error', 'not_founnd'}. lookup_account_by_ip(IP) -> lager:debug("looking up IP: ~s in db ~s", [IP, ?KZ_SIP_DB]), diff --git a/applications/registrar/src/registrar_app.erl b/applications/registrar/src/registrar_app.erl index 26e18196d87..fa7469b0e72 100644 --- a/applications/registrar/src/registrar_app.erl +++ b/applications/registrar/src/registrar_app.erl @@ -22,7 +22,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_StartType, _StartArgs) -> _ = declare_exchanges(), _ = registrar_maintenance:refresh_views(), diff --git a/applications/registrar/src/registrar_init.erl b/applications/registrar/src/registrar_init.erl index 63ee7a381b3..956bc223892 100644 --- a/applications/registrar/src/registrar_init.erl +++ b/applications/registrar/src/registrar_init.erl @@ -12,7 +12,7 @@ -include("reg.hrl"). --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> kz_util:spawn(fun init/0), 'ignore'. diff --git a/applications/registrar/src/registrar_maintenance.erl b/applications/registrar/src/registrar_maintenance.erl index 8a22eda239f..71253accf7c 100644 --- a/applications/registrar/src/registrar_maintenance.erl +++ b/applications/registrar/src/registrar_maintenance.erl @@ -14,7 +14,7 @@ -include("reg.hrl"). --spec device_by_ip(text()) -> 'ok'. +-spec device_by_ip(kz_term:text()) -> 'ok'. device_by_ip(IP) when not is_binary(IP) -> device_by_ip(kz_term:to_binary(IP)); device_by_ip(IP) -> @@ -26,7 +26,7 @@ device_by_ip(IP) -> io:format("Not found: ~p~n", [_E]) end. --spec pretty_print_device_by_ip(kz_proplist()) -> 'ok'. +-spec pretty_print_device_by_ip(kz_term:proplist()) -> 'ok'. pretty_print_device_by_ip([]) -> 'ok'; pretty_print_device_by_ip([{Key, Value}|Props]) -> io:format("~-39s: ~s~n", [Key, kz_term:to_binary(Value)]), diff --git a/applications/registrar/src/registrar_shared_listener.erl b/applications/registrar/src/registrar_shared_listener.erl index 27e73d222f1..841f39fe6c9 100644 --- a/applications/registrar/src/registrar_shared_listener.erl +++ b/applications/registrar/src/registrar_shared_listener.erl @@ -51,7 +51,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER ,[{'responders', ?RESPONDERS} @@ -97,7 +97,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Msg, _From, State) -> {'noreply', State}. @@ -111,7 +111,7 @@ handle_call(_Msg, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> {'noreply', State}. @@ -125,7 +125,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -137,7 +137,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Props} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/registrar/src/registrar_shared_listener_sup.erl b/applications/registrar/src/registrar_shared_listener_sup.erl index 5642c1b1bf5..3c58c2a27fe 100644 --- a/applications/registrar/src/registrar_shared_listener_sup.erl +++ b/applications/registrar/src/registrar_shared_listener_sup.erl @@ -32,7 +32,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> R = supervisor:start_link({'local', ?SERVER}, ?MODULE, []), case R of @@ -66,7 +66,7 @@ set_listeners(Count) -> _Else -> 'ok' end. --spec workers() -> pids(). +-spec workers() -> kz_term:pids(). workers() -> [Pid || {_, Pid, 'worker', [_]} <- supervisor:which_children(?SERVER)]. @@ -83,7 +83,7 @@ workers() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 0, diff --git a/applications/registrar/src/registrar_sup.erl b/applications/registrar/src/registrar_sup.erl index 80be2760638..01b513e0387 100644 --- a/applications/registrar/src/registrar_sup.erl +++ b/applications/registrar/src/registrar_sup.erl @@ -29,7 +29,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -46,7 +46,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/reorder/src/reorder_app.erl b/applications/reorder/src/reorder_app.erl index 36ac5454d8f..a0292cad39a 100644 --- a/applications/reorder/src/reorder_app.erl +++ b/applications/reorder/src/reorder_app.erl @@ -17,7 +17,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = declare_exchanges(), reorder_sup:start_link(). diff --git a/applications/reorder/src/reorder_listener.erl b/applications/reorder/src/reorder_listener.erl index a34baa8b038..f18251b3c0b 100644 --- a/applications/reorder/src/reorder_listener.erl +++ b/applications/reorder/src/reorder_listener.erl @@ -45,7 +45,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'bindings', ?BINDINGS} ,{'responders', ?RESPONDERS} @@ -87,7 +87,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -101,7 +101,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> {'noreply', State}. @@ -115,7 +115,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -127,7 +127,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/reorder/src/reorder_route_req.erl b/applications/reorder/src/reorder_route_req.erl index 490a7513eb8..26c89622888 100644 --- a/applications/reorder/src/reorder_route_req.erl +++ b/applications/reorder/src/reorder_route_req.erl @@ -12,7 +12,7 @@ -export([handle_req/2]). --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, Props) -> AccountId = kz_json:get_value([<<"Custom-Channel-Vars">>, <<"Account-ID">>], JObj), case kz_term:is_empty(AccountId) of @@ -23,7 +23,7 @@ handle_req(JObj, Props) -> maybe_known_number(ControllerQ, JObj) end. --spec maybe_known_number(ne_binary(), kz_json:object()) -> 'ok'. +-spec maybe_known_number(kz_term:ne_binary(), kz_json:object()) -> 'ok'. maybe_known_number(ControllerQ, JObj) -> Number = get_dest_number(JObj), case knm_number:lookup_account(Number) of @@ -34,7 +34,7 @@ maybe_known_number(ControllerQ, JObj) -> choose_response(ControllerQ, JObj, Reconcilable, <<"unknown_number">>) end. --spec choose_response(ne_binary(), kz_json:object(), boolean(), ne_binary()) -> 'ok'. +-spec choose_response(kz_term:ne_binary(), kz_json:object(), boolean(), kz_term:ne_binary()) -> 'ok'. choose_response(ControllerQ, JObj, Reconcilable, Type) -> case kapps_config:get_ne_binary(?CONFIG_CAT, [Type, <<"action">>], <<"respond">>) of <<"respond">> -> send_response(JObj, ControllerQ, Reconcilable, Type); @@ -42,7 +42,7 @@ choose_response(ControllerQ, JObj, Reconcilable, Type) -> <<"bridge">> -> maybe_send_bridge(JObj, ControllerQ, Reconcilable, Type) end. --spec send_response(kz_json:object(), ne_binary(), boolean(), ne_binary()) -> 'ok'. +-spec send_response(kz_json:object(), kz_term:ne_binary(), boolean(), kz_term:ne_binary()) -> 'ok'. send_response(JObj, ControllerQ, Reconcilable, <<"unknown_number">> = Type) -> Code = kapps_config:get_binary(?APP_NAME, [Type, <<"response_code">>], <<"604">>), Message = kapps_config:get_binary(?APP_NAME, [Type, <<"response_message">>], <<"Nope Nope Nope">>), @@ -52,7 +52,7 @@ send_response(JObj, ControllerQ, Reconcilable, <<"known_number">> = Type) -> Message = kapps_config:get_binary(?APP_NAME, [Type, <<"response_message">>], <<"PICNIC">>), send_response(JObj, ControllerQ, Reconcilable, Code, Message). --spec send_response(kz_json:object(), ne_binary(), boolean(), ne_binary(), api_binary()) -> 'ok'. +-spec send_response(kz_json:object(), kz_term:ne_binary(), boolean(), kz_term:ne_binary(), kz_term:api_binary()) -> 'ok'. send_response(JObj, ControllerQ, Reconcilable, Code, Message) -> lager:debug("sending response: ~s ~s", [Code, Message]), Resp = [{<<"Msg-ID">>, kz_json:get_value(<<"Msg-ID">>, JObj)} @@ -64,14 +64,14 @@ send_response(JObj, ControllerQ, Reconcilable, Code, Message) -> ], kapi_route:publish_resp(kz_json:get_value(<<"Server-ID">>, JObj), Resp). --spec maybe_send_transfer(kz_json:object(), ne_binary(), boolean(), ne_binary()) -> 'ok'. +-spec maybe_send_transfer(kz_json:object(), kz_term:ne_binary(), boolean(), kz_term:ne_binary()) -> 'ok'. maybe_send_transfer(JObj, ControllerQ, Reconcilable, Type) -> case kapps_config:get_ne_binary(?CONFIG_CAT, [Type, <<"transfer_target">>]) of 'undefined' -> send_response(JObj, ControllerQ, Reconcilable, Type); Number -> send_transfer(JObj, ControllerQ, Reconcilable, Number) end. --spec send_transfer(kz_json:object(), ne_binary(), boolean(), ne_binary()) -> 'ok'. +-spec send_transfer(kz_json:object(), kz_term:ne_binary(), boolean(), kz_term:ne_binary()) -> 'ok'. send_transfer(JObj, ControllerQ, Reconcilable, Number) -> lager:debug("sending transfer to ~s", [Number]), Route = kz_json:from_list([{<<"Invite-Format">>, <<"loopback">>} @@ -86,7 +86,7 @@ send_transfer(JObj, ControllerQ, Reconcilable, Number) -> ], kapi_route:publish_resp(kz_json:get_value(<<"Server-ID">>, JObj), Resp). --spec maybe_send_bridge(kz_json:object(), ne_binary(), boolean(), ne_binary()) -> 'ok'. +-spec maybe_send_bridge(kz_json:object(), kz_term:ne_binary(), boolean(), kz_term:ne_binary()) -> 'ok'. maybe_send_bridge(JObj, ControllerQ, Reconcilable, Type) -> AccountId = kapps_config:get_ne_binary(?CONFIG_CAT, [Type, <<"bridge_account_id">>]), EndpointId = kapps_config:get_ne_binary(?CONFIG_CAT, [Type, <<"bridge_endpoint_id">>]), @@ -101,7 +101,7 @@ maybe_send_bridge(JObj, ControllerQ, Reconcilable, Type) -> send_bridge(JObj, ControllerQ, Reconcilable, Type, Endpoint) end. --spec send_bridge(kz_json:object(), ne_binary(), boolean(), ne_binary(), kz_jobjs_return()) -> 'ok'. +-spec send_bridge(kz_json:object(), kz_term:ne_binary(), boolean(), kz_term:ne_binary(), kz_term:jobjs_return()) -> 'ok'. send_bridge(JObj, ControllerQ, Reconcilable, _Type, {'ok', Routes}) -> lager:debug("sending bridge to endpoint", []), Resp = [{<<"Msg-ID">>, kz_json:get_value(<<"Msg-ID">>, JObj)} @@ -114,7 +114,7 @@ send_bridge(JObj, ControllerQ, Reconcilable, _Type, {'ok', Routes}) -> send_bridge(JObj, ControllerQ, Type, Reconcilable, _) -> send_response(JObj, ControllerQ, Type, Reconcilable). --spec get_dest_number(kz_json:object()) -> ne_binary(). +-spec get_dest_number(kz_json:object()) -> kz_term:ne_binary(). get_dest_number(JObj) -> {User, _} = kapps_util:get_destination(JObj, ?APP_NAME, <<"inbound_user_field">>), case kapps_config:get_is_true(?CONFIG_CAT, <<"assume_inbound_e164">>, false) of @@ -128,7 +128,7 @@ get_dest_number(JObj) -> Number end. --spec assume_e164(ne_binary()) -> ne_binary(). +-spec assume_e164(kz_term:ne_binary()) -> kz_term:ne_binary(). assume_e164(<<$+, _/binary>> = Number) -> Number; assume_e164(Number) -> <<$+, Number/binary>>. diff --git a/applications/reorder/src/reorder_sup.erl b/applications/reorder/src/reorder_sup.erl index 270de4945b0..fb960b5d10c 100644 --- a/applications/reorder/src/reorder_sup.erl +++ b/applications/reorder/src/reorder_sup.erl @@ -28,7 +28,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -45,7 +45,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/skel/src/skel_app.erl b/applications/skel/src/skel_app.erl index e3f43452f68..ab01ea207c6 100644 --- a/applications/skel/src/skel_app.erl +++ b/applications/skel/src/skel_app.erl @@ -17,7 +17,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = declare_exchanges(), skel_sup:start_link(). diff --git a/applications/skel/src/skel_handlers.erl b/applications/skel/src/skel_handlers.erl index 00d71a71c0d..d518f3e124c 100644 --- a/applications/skel/src/skel_handlers.erl +++ b/applications/skel/src/skel_handlers.erl @@ -14,7 +14,7 @@ -include("skel.hrl"). --spec handle_route_req(kz_json:object(), kz_proplist()) -> any(). +-spec handle_route_req(kz_json:object(), kz_term:proplist()) -> any(). handle_route_req(JObj, Props) -> %% First validate the JSON 'true' = kapi_route:req_v(JObj), @@ -47,7 +47,7 @@ handle_route_req(JObj, Props) -> kapps_call:cache(Call, ?APP_NAME). %% receiving the route_win means we are in control of the call --spec handle_route_win(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_route_win(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_route_win(JObj, _Props) -> %% Yay, we have control of the call %% First, validate the JSON diff --git a/applications/skel/src/skel_listener.erl b/applications/skel/src/skel_listener.erl index 324e18232a1..156df3ce5ea 100644 --- a/applications/skel/src/skel_listener.erl +++ b/applications/skel/src/skel_listener.erl @@ -48,7 +48,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [ {'bindings', ?BINDINGS} @@ -86,7 +86,7 @@ init([]) -> %% {stop, Reason, Reply, State} | %% {stop, Reason, State} %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -97,7 +97,7 @@ handle_call(_Request, _From, State) -> %% {noreply, State, Timeout} | %% {stop, Reason, State} %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _QueueNAme}}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'is_consuming', _IsConsuming}}, State) -> @@ -112,7 +112,7 @@ handle_cast(_Msg, State) -> %% {noreply, State, Timeout} | %% {stop, Reason, State} %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -121,7 +121,7 @@ handle_info(_Info, State) -> %% @doc Allows listener to pass options to handlers %% @spec handle_event(JObj, State) -> {reply, Options} %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/skel/src/skel_sup.erl b/applications/skel/src/skel_sup.erl index 1ec04cee295..7b1e1556b92 100644 --- a/applications/skel/src/skel_sup.erl +++ b/applications/skel/src/skel_sup.erl @@ -29,7 +29,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -46,7 +46,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/spyvsspy/src/spyvsspy_app.erl b/applications/spyvsspy/src/spyvsspy_app.erl index 3afbfb17916..7abc214d23e 100644 --- a/applications/spyvsspy/src/spyvsspy_app.erl +++ b/applications/spyvsspy/src/spyvsspy_app.erl @@ -17,7 +17,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = declare_exchanges(), spyvsspy_sup:start_link(). diff --git a/applications/spyvsspy/src/spyvsspy_handlers.erl b/applications/spyvsspy/src/spyvsspy_handlers.erl index 6e5ecbf6be6..56dd4f3fdb6 100644 --- a/applications/spyvsspy/src/spyvsspy_handlers.erl +++ b/applications/spyvsspy/src/spyvsspy_handlers.erl @@ -14,7 +14,7 @@ -define(RESOURCE_TYPE_AUDIO, <<"audio">>). --spec handle_eavesdrop_req(kz_json:object(), kz_proplist()) -> any(). +-spec handle_eavesdrop_req(kz_json:object(), kz_term:proplist()) -> any(). handle_eavesdrop_req(JObj, _Props) -> 'true' = kapi_resource:eavesdrop_req_v(JObj), AccountId = kz_json:get_value(<<"Account-ID">>, JObj), @@ -27,13 +27,13 @@ handle_eavesdrop_req(JObj, _Props) -> {'error', E} -> respond_error(JObj, kz_term:to_binary(E)) end. --spec get_endpoints(ne_binary(), ne_binary()) -> +-spec get_endpoints(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:objects()} | {'error', any()}. get_endpoints(AccountId, EndpointId) -> kz_endpoint:build(EndpointId, new_call(AccountId)). --spec new_call(ne_binary()) -> kapps_call:call(). +-spec new_call(kz_term:ne_binary()) -> kapps_call:call(). new_call(AccountId) -> kapps_call:from_json( kz_json:from_list( @@ -44,14 +44,14 @@ new_call(AccountId) -> ) ). --spec get_group_and_call_id(kz_json:object()) -> {api_binary(), api_binary()}. +-spec get_group_and_call_id(kz_json:object()) -> {kz_term:api_binary(), kz_term:api_binary()}. get_group_and_call_id(JObj) -> case kz_json:get_value(<<"Eavesdrop-Group-ID">>, JObj) of 'undefined' -> {'undefined', kz_json:get_value(<<"Eavesdrop-Call-ID">>, JObj)}; GroupId -> {GroupId, kz_json:get_value(<<"Eavesdrop-Call-ID">>, JObj, <<"all">>)} end. --spec send_eavesdrop(kz_json:object(), kz_json:objects(), ne_binary()) -> 'ok'. +-spec send_eavesdrop(kz_json:object(), kz_json:objects(), kz_term:ne_binary()) -> 'ok'. send_eavesdrop(JObj, EPs, AccountId) -> {GroupId, CallId} = get_group_and_call_id(JObj), @@ -120,7 +120,7 @@ respond_success(JObj, OrigJObj) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]). --spec respond_error(kz_json:object(), ne_binary()) -> 'ok'. +-spec respond_error(kz_json:object(), kz_term:ne_binary()) -> 'ok'. respond_error(JObj, E) -> ServerId = kz_json:get_value(<<"Server-ID">>, JObj), respond(ServerId, [{<<"Status">>, <<"error">>} @@ -128,12 +128,12 @@ respond_error(JObj, E) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]). --spec respond(ne_binary(), kz_proplist()) -> 'ok'. +-spec respond(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. respond(ServerId, Props) -> lager:debug("respond to ~s: ~p", [ServerId, Props]), kapi_resource:publish_eavesdrop_resp(ServerId, Props). --spec send_originate_execute(kz_json:object(), ne_binary()) -> 'ok'. +-spec send_originate_execute(kz_json:object(), kz_term:ne_binary()) -> 'ok'. send_originate_execute(JObj, Q) -> Prop = [{<<"Call-ID">>, kz_json:get_value(<<"Call-ID">>, JObj)} ,{<<"Msg-ID">>, kz_json:get_value(<<"Msg-ID">>, JObj)} @@ -142,9 +142,9 @@ send_originate_execute(JObj, Q) -> kapi_dialplan:publish_originate_execute(kz_json:get_value(<<"Server-ID">>, JObj), Prop). -spec find_caller_id(kz_json:object()) -> - {ne_binary(), api_binary()}. --spec find_caller_id(kz_json:object(), kz_proplist()) -> - {ne_binary(), api_binary()}. + {kz_term:ne_binary(), kz_term:api_binary()}. +-spec find_caller_id(kz_json:object(), kz_term:proplist()) -> + {kz_term:ne_binary(), kz_term:api_binary()}. find_caller_id(JObj) -> find_caller_id(JObj, [{<<"Outbound-Caller-ID-Name">>, <<"Outbound-Caller-ID-Number">>} ,{<<"Caller-ID-Name">>, <<"Caller-ID-Number">>} diff --git a/applications/spyvsspy/src/spyvsspy_listener.erl b/applications/spyvsspy/src/spyvsspy_listener.erl index d28cd2cd543..1e917bb5e69 100644 --- a/applications/spyvsspy/src/spyvsspy_listener.erl +++ b/applications/spyvsspy/src/spyvsspy_listener.erl @@ -45,7 +45,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER ,[{'bindings', ?BINDINGS} @@ -89,7 +89,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -103,7 +103,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _QueueNAme}}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'is_consuming', _IsConsuming}}, State) -> @@ -122,7 +122,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> lager:debug("unhandled msg: ~p", [_Info]), {'noreply', State}. @@ -135,7 +135,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/spyvsspy/src/spyvsspy_sup.erl b/applications/spyvsspy/src/spyvsspy_sup.erl index 3d2fb99c215..bce9ea39b18 100644 --- a/applications/spyvsspy/src/spyvsspy_sup.erl +++ b/applications/spyvsspy/src/spyvsspy_sup.erl @@ -28,7 +28,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -45,7 +45,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/stats/src/stats_app.erl b/applications/stats/src/stats_app.erl index 95ca7faebf2..773e3164bb0 100644 --- a/applications/stats/src/stats_app.erl +++ b/applications/stats/src/stats_app.erl @@ -18,7 +18,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> stats_sup:start_link(). diff --git a/applications/stats/src/stats_handler.erl b/applications/stats/src/stats_handler.erl index d09fa944562..8368ec89a32 100644 --- a/applications/stats/src/stats_handler.erl +++ b/applications/stats/src/stats_handler.erl @@ -19,20 +19,20 @@ -include("stats.hrl"). --spec handle_req(kz_json:object(), kz_proplist()) -> 'no_node_name' | - 'no_tables' | - 'no_items' | - 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'no_node_name' | + 'no_tables' | + 'no_items' | + 'ok'. handle_req(JObj, _Props) -> Items = kz_json:recursive_to_proplist(JObj), Nodename = props:get_value(<<"nodename">>, Items), store_items(Nodename, table_def(), Items). --spec handle_event(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_event(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_event(JObj, Props) -> lager:debug("event occurred ~p ~p",[JObj, Props]). --spec get_db(ne_binary()) -> list(). +-spec get_db(kz_term:ne_binary()) -> list(). get_db(Table) -> case kz_cache:peek_local(?CACHE_NAME, Table) of {'ok', Records} -> Records; @@ -101,11 +101,11 @@ collect_items([{Domain, Items} | Rest], Db) -> ], collect_items(Rest, lists:keystore(Domain, 1, Db, {Domain, NewData})). --spec send(kz_json:objects() | ne_binary()) -> 'ok'. +-spec send(kz_json:objects() | kz_term:ne_binary()) -> 'ok'. send(Payload) when is_list(Payload) -> send(kz_json:encode(Payload)); send(Payload) -> amqp_util:targeted_publish(<<"statistics">>, Payload). --spec get_next(ne_binary(), list(), list()) -> ['endOfTable' | {list(), list()}]. +-spec get_next(kz_term:ne_binary(), list(), list()) -> ['endOfTable' | {list(), list()}]. get_next(Table, Row, Col) when is_list(Col), is_list(Row), is_binary(Table) -> get_next2(Row, Col, get_db(Table), table_order(Table)). diff --git a/applications/stats/src/stats_listener.erl b/applications/stats/src/stats_listener.erl index fee208d75cf..947a2987227 100644 --- a/applications/stats/src/stats_listener.erl +++ b/applications/stats/src/stats_listener.erl @@ -42,7 +42,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [ {'bindings', ?BINDINGS} @@ -85,7 +85,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -99,7 +99,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> {'noreply', State}. @@ -113,7 +113,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -125,7 +125,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/stats/src/stats_sup.erl b/applications/stats/src/stats_sup.erl index 8e768035c0f..6ef99c69573 100644 --- a/applications/stats/src/stats_sup.erl +++ b/applications/stats/src/stats_sup.erl @@ -29,7 +29,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -46,7 +46,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/stepswitch/src/kz_srs_util.erl b/applications/stepswitch/src/kz_srs_util.erl index 0a8dba800d8..6b016b77614 100644 --- a/applications/stepswitch/src/kz_srs_util.erl +++ b/applications/stepswitch/src/kz_srs_util.erl @@ -24,7 +24,7 @@ do_select_filter_action(<<"keep">>) -> 'keep'; do_select_filter_action(<<"drop">>) -> 'drop'; do_select_filter_action(Data) -> throw({invalid_filter_action, Data}). --spec select_filter_mode(kz_json:object(), ne_binaries(), ne_binary()) -> ne_binary(). +-spec select_filter_mode(kz_json:object(), kz_term:ne_binaries(), kz_term:ne_binary()) -> kz_term:ne_binary(). select_filter_mode(Params, ModesList, Default) -> do_select_filter_mode(kz_json:get_ne_binary_value(<<"mode">>, Params, Default), ModesList). do_select_filter_mode(Mode, ModesList) -> @@ -35,12 +35,12 @@ do_select_filter_mode(Mode, ModesList) -> -type source() :: 'number' | 'cid_number' | - {'request', ne_binary()} | - {'resource', ne_binary()} | - {'database', ne_binary()} | - {'database', ne_binary(), kz_proplist()}. + {'request', kz_term:ne_binary()} | + {'resource', kz_term:ne_binary()} | + {'database', kz_term:ne_binary()} | + {'database', kz_term:ne_binary(), kz_term:proplist()}. --spec get_source(ne_binary()) -> source(). +-spec get_source(kz_term:ne_binary()) -> source(). get_source(<<"number">>) -> 'number'; get_source(<<"cid_number">>) -> 'cid_number'; get_source(<<"service_plans">>) -> 'service_plans'; @@ -49,8 +49,8 @@ get_source(<<"resource:", Field/binary>>) -> {'resource', Field}; get_source(<<"database:", Selector/binary>>) -> {'database', Selector}; get_source(Type) -> throw({invalid_filter_type, Type}). --spec get_value(source(), any(), ne_binary(), kz_json:object(), ne_binary()) -> any(). --spec get_value(source(), any(), ne_binary(), kz_json:object(), ne_binary(), any()) -> any(). +-spec get_value(source(), any(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> any(). +-spec get_value(source(), any(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary(), any()) -> any(). get_value(Type, Resources, Number, OffnetJObj, DB) -> get_value(Type, Resources, Number, OffnetJObj, DB, 'undefined'). get_value('number', _Resources, Number, _OffnetJObj, _DB, _Default) -> @@ -91,7 +91,7 @@ get_value({'database', View, Options}, _Resources, _Number, _OffnetJObj, DB, Def get_value(Value, _Resources, _Number, _OffnetJObj, _DB, _Default) -> throw({'invalid_filter_value', Value}). --spec get_value_fold(ne_binary(), kz_json:object(), ne_binaries()) -> ne_binaries(). +-spec get_value_fold(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). get_value_fold(PlanId, JObj, Acc) -> case kz_json:is_json_object(JObj) of 'false' -> Acc; diff --git a/applications/stepswitch/src/resource_selectors/kz_srs_filter_list.erl b/applications/stepswitch/src/resource_selectors/kz_srs_filter_list.erl index be0d9193625..444227a159f 100644 --- a/applications/stepswitch/src/resource_selectors/kz_srs_filter_list.erl +++ b/applications/stepswitch/src/resource_selectors/kz_srs_filter_list.erl @@ -22,9 +22,9 @@ -define(DEFAULT_FILTER_MODE, <<"ne_subset_or_exact">>). -spec handle_req(stepswitch_resources:resources() - ,ne_binary() + ,kz_term:ne_binary() ,kapi_offnet_resource:req() - ,ne_binary() + ,kz_term:ne_binary() ,kz_json:object() ) -> stepswitch_resources:resources(). handle_req(Resources, Number, OffnetJObj, DB, Params) -> @@ -55,7 +55,7 @@ handle_req(Resources, Number, OffnetJObj, DB, Params) -> -spec filter_list(sets:set() ,sets:set() - ,ne_binary() + ,kz_term:ne_binary() ) -> boolean(). filter_list(Set, Set, <<"axact">>) -> 'true'; filter_list(SetA, SetB, <<"subset">>) -> sets:is_subset(SetA, SetB); diff --git a/applications/stepswitch/src/resource_selectors/kz_srs_filter_prefix.erl b/applications/stepswitch/src/resource_selectors/kz_srs_filter_prefix.erl index 6cdedd8d57f..cf9fc39beb0 100644 --- a/applications/stepswitch/src/resource_selectors/kz_srs_filter_prefix.erl +++ b/applications/stepswitch/src/resource_selectors/kz_srs_filter_prefix.erl @@ -17,7 +17,7 @@ ]). -define(DEFAULT_FILTER_MODE, <<"empty_fail">>). --spec handle_req(stepswitch_resources:resources(), ne_binary(), kapi_offnet_resource:req(), ne_binary(), kz_json:object()) -> +-spec handle_req(stepswitch_resources:resources(), kz_term:ne_binary(), kapi_offnet_resource:req(), kz_term:ne_binary(), kz_json:object()) -> stepswitch_resources:resources(). handle_req(Resources, Number, OffnetJObj, DB, Params) -> SourceA = kz_srs_util:get_source(kz_json:get_value(<<"value_a">>, Params)), @@ -60,12 +60,12 @@ maybe_db_type({'database', SelectorName}, Resources, PrefixSrc) -> {'database', View, Options}; maybe_db_type(Other, _Resources, _PrefixSrc) -> Other. --spec build_prefixes(ne_binary()) -> ne_binaries(). +-spec build_prefixes(kz_term:ne_binary()) -> kz_term:ne_binaries(). build_prefixes(<<"+", Rest/binary>>) -> build_prefixes(Rest); build_prefixes(<>) -> build_prefixes(Rest, D, [D]). --spec build_prefixes(ne_binary(), ne_binary(), ne_binaries()) -> ne_binaries(). +-spec build_prefixes(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). build_prefixes(<>, Prefix, Acc) -> build_prefixes(Rest, <>, [<> | Acc]); build_prefixes(<<>>, _, Acc) -> Acc. diff --git a/applications/stepswitch/src/resource_selectors/kz_srs_filter_regex.erl b/applications/stepswitch/src/resource_selectors/kz_srs_filter_regex.erl index a4bbc22f8c4..e697e44e32f 100644 --- a/applications/stepswitch/src/resource_selectors/kz_srs_filter_regex.erl +++ b/applications/stepswitch/src/resource_selectors/kz_srs_filter_regex.erl @@ -18,9 +18,9 @@ -define(DEFAULT_FILTER_MODE, <<"empty_fail">>). -spec handle_req(stepswitch_resources:resources() - ,ne_binary() + ,kz_term:ne_binary() ,kapi_offnet_resource:req() - ,ne_binary() + ,kz_term:ne_binary() ,kz_json:object() ) -> stepswitch_resources:resources(). handle_req(Resources, Number, OffnetJObj, DB, Params) -> @@ -35,10 +35,10 @@ handle_req(Resources, Number, OffnetJObj, DB, Params) -> filter_by_regex(Resources, ValueA, ValueB, Action, EmptyMode). -spec filter_by_regex(stepswitch_resources:resources() - ,ne_binary() - ,kz_proplists() + ,kz_term:ne_binary() + ,kz_term:proplists() ,atom() - ,ne_binary() + ,kz_term:ne_binary() ) -> stepswitch_resources:resources(). filter_by_regex(Resources, ValueA, Regexes, Action, EmptyMode) -> lager:debug("filter resources by ~s with regex rules, and ~s matched", [ValueA, Action]), @@ -50,7 +50,7 @@ filter_by_regex(Resources, ValueA, Regexes, Action, EmptyMode) -> ,Resources ). --spec evaluate_rules(ne_binary(), re:mp(), ne_binary(), atom(), ne_binary()) -> boolean(). +-spec evaluate_rules(kz_term:ne_binary(), re:mp(), kz_term:ne_binary(), atom(), kz_term:ne_binary()) -> boolean(). evaluate_rules(Id, [], _Data, 'keep', <<"empty_fail">>) -> lager:debug("resource ~s has empty rules, dropping", [Id]), 'false'; @@ -82,8 +82,8 @@ evaluate_rules(Id, Rules, Data, 'drop', _EmptyMode) -> 'false' end. --spec do_evaluate_rules(re:mp(), ne_binary()) -> - {'ok', ne_binary()} | +-spec do_evaluate_rules(re:mp(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | {'error', 'no_match'}. do_evaluate_rules([], _) -> {'error', 'no_match'}; do_evaluate_rules([Rule|Rules], Data) -> diff --git a/applications/stepswitch/src/resource_selectors/kz_srs_get_resources.erl b/applications/stepswitch/src/resource_selectors/kz_srs_get_resources.erl index 8b7f8813c8c..db6e3a65726 100644 --- a/applications/stepswitch/src/resource_selectors/kz_srs_get_resources.erl +++ b/applications/stepswitch/src/resource_selectors/kz_srs_get_resources.erl @@ -11,7 +11,7 @@ -include("stepswitch.hrl"). --spec handle_req(stepswitch_resources:resources(), ne_binary(), kapi_offnet_resource:req(), ne_binary(), kz_proplist()) -> +-spec handle_req(stepswitch_resources:resources(), kz_term:ne_binary(), kapi_offnet_resource:req(), kz_term:ne_binary(), kz_term:proplist()) -> stepswitch_resources:resources(). handle_req(Resources, _Number, OffnetJObj, _DB, _Params) -> NewResources = case kapi_offnet_resource:hunt_account_id(OffnetJObj) of @@ -22,7 +22,7 @@ handle_req(Resources, _Number, OffnetJObj, _DB, _Params) -> end, Resources ++ NewResources. --spec maybe_get_local_resources(ne_binary(), ne_binary()) -> stepswitch_resources:resources(). +-spec maybe_get_local_resources(kz_term:ne_binary(), kz_term:ne_binary()) -> stepswitch_resources:resources(). maybe_get_local_resources(HuntAccount, AccountId) -> case kz_util:is_in_account_hierarchy(HuntAccount, AccountId, 'true') of 'false' -> @@ -35,7 +35,7 @@ maybe_get_local_resources(HuntAccount, AccountId) -> get_resources(HuntAccount) end. --spec get_resources(api_binary()) -> stepswitch_resources:resources(). +-spec get_resources(kz_term:api_binary()) -> stepswitch_resources:resources(). get_resources('undefined') -> case kz_cache:fetch_local(?CACHE_NAME, 'global_resources') of {'ok', Resources} -> Resources; diff --git a/applications/stepswitch/src/resource_selectors/kz_srs_null.erl b/applications/stepswitch/src/resource_selectors/kz_srs_null.erl index dd7679dd22d..d2057d5ed9a 100644 --- a/applications/stepswitch/src/resource_selectors/kz_srs_null.erl +++ b/applications/stepswitch/src/resource_selectors/kz_srs_null.erl @@ -11,7 +11,7 @@ -include("stepswitch.hrl"). --spec handle_req(stepswitch_resources:resources(), ne_binary(), kapi_offnet_resource:req(), ne_binary(), kz_json:object()) -> +-spec handle_req(stepswitch_resources:resources(), kz_term:ne_binary(), kapi_offnet_resource:req(), kz_term:ne_binary(), kz_json:object()) -> stepswitch_resources:resources(). handle_req(_Resources, _Number, _OffnetJObj, _Db, _Params) -> []. diff --git a/applications/stepswitch/src/resource_selectors/kz_srs_order.erl b/applications/stepswitch/src/resource_selectors/kz_srs_order.erl index 763d6a10a72..7b54abbaaca 100644 --- a/applications/stepswitch/src/resource_selectors/kz_srs_order.erl +++ b/applications/stepswitch/src/resource_selectors/kz_srs_order.erl @@ -16,7 +16,7 @@ -define(DEFAULT_DESC_WEIGHT, 0). -define(DEFAULT_ASC_WEIGHT, 9999). --spec handle_req(stepswitch_resources:resources(), ne_binary(), kapi_offnet_resource:req(), ne_binary(), kz_json:object()) -> +-spec handle_req(stepswitch_resources:resources(), kz_term:ne_binary(), kapi_offnet_resource:req(), kz_term:ne_binary(), kz_json:object()) -> stepswitch_resources:resources(). handle_req([], _Number, _OffnetJObj, _DB, _Params) -> lager:warning("empty resource list", []), @@ -32,7 +32,7 @@ handle_req(Resources, Number, OffnetJObj, DB, Params) -> SortOrder = kz_json:get_ne_value(<<"direction">>, Params, ?DEFAULT_SORT_ORDER), order_by(Resources, Values, SortOrder). --spec order_by(stepswitch_resources:resources(), kz_json:object(), ne_binary()) -> +-spec order_by(stepswitch_resources:resources(), kz_json:object(), kz_term:ne_binary()) -> stepswitch_resources:resources(). order_by(Resources, Values, SortOrder) -> lists:sort(fun(R1, R2) -> @@ -45,7 +45,7 @@ order_by(Resources, Values, SortOrder) -> ,Resources ). --spec default_weight(ne_binary()) -> integer(). +-spec default_weight(kz_term:ne_binary()) -> integer(). default_weight(<<"ascend">>) -> ?DEFAULT_ASC_WEIGHT; default_weight(<<"descend">>) -> ?DEFAULT_DESC_WEIGHT. @@ -54,6 +54,6 @@ check_source({'database', _}) -> 'ok'; check_source({'resource', _}) -> 'ok'; check_source(Source) -> throw({invalid_source, Source}). --spec sort(integer(), integer(), ne_binary()) -> boolean(). +-spec sort(integer(), integer(), kz_term:ne_binary()) -> boolean(). sort(Lesser, Greater, <<"ascend">>) -> Lesser =< Greater; sort(Greater, Lesser, <<"descend">>) -> Lesser =< Greater. diff --git a/applications/stepswitch/src/stepswitch_app.erl b/applications/stepswitch/src/stepswitch_app.erl index 073e4ef1200..06dd7ae8b25 100644 --- a/applications/stepswitch/src/stepswitch_app.erl +++ b/applications/stepswitch/src/stepswitch_app.erl @@ -17,7 +17,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_StartType, _StartArgs) -> _ = declare_exchanges(), _ = stepswitch_maintenance:refresh(), diff --git a/applications/stepswitch/src/stepswitch_authn_req.erl b/applications/stepswitch/src/stepswitch_authn_req.erl index f88ebb11b02..a6a2c71b517 100644 --- a/applications/stepswitch/src/stepswitch_authn_req.erl +++ b/applications/stepswitch/src/stepswitch_authn_req.erl @@ -18,7 +18,7 @@ %% %% @end %%----------------------------------------------------------------------------- --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Props) -> 'true' = kapi_authn:req_v(JObj), _ = kz_util:put_callid(JObj), @@ -47,7 +47,7 @@ maybe_send_auth_resp(JObj) -> %% when provided with an IP %% @end %%----------------------------------------------------------------------------- --spec send_auth_resp(kz_json:object(), kz_proplist()) -> 'ok'. +-spec send_auth_resp(kz_json:object(), kz_term:proplist()) -> 'ok'. send_auth_resp(JObj, Props) -> Category = kz_json:get_value(<<"Event-Category">>, JObj), Username = props:get_value('username', Props), diff --git a/applications/stepswitch/src/stepswitch_bridge.erl b/applications/stepswitch/src/stepswitch_bridge.erl index bba65282fb4..9a6941c8910 100644 --- a/applications/stepswitch/src/stepswitch_bridge.erl +++ b/applications/stepswitch/src/stepswitch_bridge.erl @@ -33,12 +33,12 @@ -record(state, {endpoints = [] :: kz_json:objects() ,resource_req :: kapi_offnet_resource:req() - ,request_handler :: api_pid() - ,control_queue :: api_binary() - ,response_queue :: api_binary() - ,queue :: api_binary() - ,timeout :: api_reference() - ,call_id :: api_binary() + ,request_handler :: kz_term:api_pid() + ,control_queue :: kz_term:api_binary() + ,response_queue :: kz_term:api_binary() + ,queue :: kz_term:api_binary() + ,timeout :: kz_term:api_reference() + ,call_id :: kz_term:api_binary() }). -type state() :: #state{}. @@ -70,7 +70,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(kz_json:objects(), kapi_offnet_resource:req()) -> startlink_ret(). +-spec start_link(kz_json:objects(), kapi_offnet_resource:req()) -> kz_types:startlink_ret(). start_link(Endpoints, OffnetReq) -> CallId = kapi_offnet_resource:call_id(OffnetReq), Bindings = [?CALL_BINDING(CallId) @@ -128,7 +128,7 @@ init([Endpoints, OffnetReq]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> lager:debug("unhandled call: ~p", [_Request]), {'reply', {'error', 'not_implemented'}, State}. @@ -143,7 +143,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'kz_amqp_channel', _}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'created_queue', Q}}, State) -> @@ -178,7 +178,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info('bridge_timeout', #state{timeout='undefined'}=State) -> {'noreply', State}; handle_info('bridge_timeout', #state{response_queue=ResponseQ @@ -305,7 +305,7 @@ maybe_bridge_emergency(#state{resource_req=OffnetReq lager:debug("sent bridge command to ~s", [ControlQ]) end. --spec maybe_deny_emergency_bridge(state(), api_binary(), api_binary()) -> 'ok'. +-spec maybe_deny_emergency_bridge(state(), kz_term:api_binary(), kz_term:api_binary()) -> 'ok'. maybe_deny_emergency_bridge(#state{resource_req=OffnetReq}=State, 'undefined', Name) -> AccountId = kapi_offnet_resource:account_id(OffnetReq), case kapps_config:get_is_true(?SS_CONFIG_CAT @@ -323,7 +323,7 @@ maybe_deny_emergency_bridge(#state{control_queue=ControlQ}=State, Number, Name) kapi_dialplan:publish_command(ControlQ, build_bridge(State0, Number, Name)), lager:debug("sent bridge command to ~s", [ControlQ]). --spec update_endpoint_emergency_cid(state() | kz_json:object(), ne_binary(), api_binary()) -> state(). +-spec update_endpoint_emergency_cid(state() | kz_json:object(), kz_term:ne_binary(), kz_term:api_binary()) -> state(). update_endpoint_emergency_cid(#state{endpoints=Endpoints}=State, Number, Name) -> State#state{endpoints=[update_endpoint_emergency_cid(Endpoint, Number, Name) || Endpoint <- Endpoints @@ -343,14 +343,14 @@ update_endpoint_emergency_cid(Endpoint, Number, Name) -> kz_json:set_values(Props, Endpoint) end. --spec outbound_flags(kz_json:object()) -> api_binary(). +-spec outbound_flags(kz_json:object()) -> kz_term:api_binary(). outbound_flags(JObj) -> case kapi_offnet_resource:flags(JObj) of [] -> 'undefined'; Flags -> kz_binary:join(Flags, <<"|">>) end. --spec build_bridge(state(), api_binary(), api_binary()) -> kz_proplist(). +-spec build_bridge(state(), kz_term:api_binary(), kz_term:api_binary()) -> kz_term:proplist(). build_bridge(#state{endpoints=Endpoints ,resource_req=OffnetReq ,queue=Q @@ -399,8 +399,8 @@ build_bridge(#state{endpoints=Endpoints | kz_api:default_headers(Q, <<"call">>, <<"command">>, ?APP_NAME, ?APP_VERSION) ]). --spec bridge_from_uri(api_binary(), kapi_offnet_resource:req()) -> - api_binary(). +-spec bridge_from_uri(kz_term:api_binary(), kapi_offnet_resource:req()) -> + kz_term:api_binary(). bridge_from_uri(Number, OffnetReq) -> Realm = stepswitch_util:default_realm(OffnetReq), @@ -417,35 +417,35 @@ bridge_from_uri(Number, OffnetReq) -> FromURI end. --spec bridge_outbound_cid_name(kapi_offnet_resource:req()) -> api_binary(). +-spec bridge_outbound_cid_name(kapi_offnet_resource:req()) -> kz_term:api_binary(). bridge_outbound_cid_name(OffnetReq) -> case kapi_offnet_resource:outbound_caller_id_name(OffnetReq) of 'undefined' -> kapi_offnet_resource:emergency_caller_id_name(OffnetReq); Name -> Name end. --spec bridge_outbound_cid_number(kapi_offnet_resource:req()) -> api_binary(). +-spec bridge_outbound_cid_number(kapi_offnet_resource:req()) -> kz_term:api_binary(). bridge_outbound_cid_number(OffnetReq) -> case kapi_offnet_resource:outbound_caller_id_number(OffnetReq) of 'undefined' -> kapi_offnet_resource:emergency_caller_id_number(OffnetReq); Number -> Number end. --spec bridge_emergency_cid_name(kapi_offnet_resource:req()) -> api_binary(). +-spec bridge_emergency_cid_name(kapi_offnet_resource:req()) -> kz_term:api_binary(). bridge_emergency_cid_name(OffnetReq) -> case kapi_offnet_resource:emergency_caller_id_name(OffnetReq) of 'undefined' -> kapi_offnet_resource:outbound_caller_id_name(OffnetReq); Name -> Name end. --spec bridge_emergency_cid_number(kapi_offnet_resource:req()) -> api_ne_binary(). +-spec bridge_emergency_cid_number(kapi_offnet_resource:req()) -> kz_term:api_ne_binary(). bridge_emergency_cid_number(OffnetReq) -> case kapi_offnet_resource:emergency_caller_id_number(OffnetReq) of 'undefined' -> kapi_offnet_resource:outbound_caller_id_number(OffnetReq); Number -> Number end. --spec find_emergency_number(kapi_offnet_resource:req()) -> api_binary(). +-spec find_emergency_number(kapi_offnet_resource:req()) -> kz_term:api_binary(). find_emergency_number(OffnetReq) -> case ?SHOULD_ENSURE_E911_CID_VALID of 'true' -> ensure_valid_emergency_number(OffnetReq); @@ -454,7 +454,7 @@ find_emergency_number(OffnetReq) -> bridge_emergency_cid_number(OffnetReq) end. --spec ensure_valid_emergency_number(kapi_offnet_resource:req()) -> api_binary(). +-spec ensure_valid_emergency_number(kapi_offnet_resource:req()) -> kz_term:api_binary(). ensure_valid_emergency_number(OffnetReq) -> AccountId = kapi_offnet_resource:account_id(OffnetReq), lager:debug("ensuring emergency caller is valid for account ~s", [AccountId]), @@ -475,7 +475,7 @@ ensure_valid_emergency_number(OffnetReq) -> find_valid_emergency_number(Numbers) end. --spec find_valid_emergency_number(ne_binaries()) -> api_binary(). +-spec find_valid_emergency_number(kz_term:ne_binaries()) -> kz_term:api_binary(). find_valid_emergency_number([]) -> lager:info("no alternative e911 enabled numbers available", []), 'undefined'; @@ -483,7 +483,7 @@ find_valid_emergency_number([Number|_]) -> lager:info("found alternative emergency caller id number ~s", [Number]), Number. --spec default_emergency_number(ne_binary()) -> ne_binary(). +-spec default_emergency_number(kz_term:ne_binary()) -> kz_term:ne_binary(). default_emergency_number(Requested) -> case ?DEFAULT_EMERGENCY_CID_NUMBER of 'undefined' -> Requested; @@ -500,7 +500,7 @@ contains_emergency_endpoints([Endpoint|Endpoints]) -> 'false' -> contains_emergency_endpoints(Endpoints) end. --spec bridge_timeout(kapi_offnet_resource:req()) -> kz_proplist(). +-spec bridge_timeout(kapi_offnet_resource:req()) -> kz_term:proplist(). bridge_timeout(OffnetReq) -> lager:debug("attempt to connect to resources timed out"), [{<<"Call-ID">>, kapi_offnet_resource:call_id(OffnetReq)} @@ -512,7 +512,7 @@ bridge_timeout(OffnetReq) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]. --spec bridge_error(kz_json:object(), kapi_offnet_resource:req()) -> kz_proplist(). +-spec bridge_error(kz_json:object(), kapi_offnet_resource:req()) -> kz_term:proplist(). bridge_error(JObj, OffnetReq) -> lager:debug("error during outbound request: ~s", [kz_term:to_binary(kz_json:encode(JObj))]), [{<<"Call-ID">>, kapi_offnet_resource:call_id(OffnetReq)} @@ -524,7 +524,7 @@ bridge_error(JObj, OffnetReq) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]. --spec bridge_success(kz_json:object(), kapi_offnet_resource:req()) -> kz_proplist(). +-spec bridge_success(kz_json:object(), kapi_offnet_resource:req()) -> kz_term:proplist(). bridge_success(JObj, OffnetReq) -> lager:debug("outbound request successfully completed"), [{<<"Call-ID">>, kapi_offnet_resource:call_id(OffnetReq)} @@ -535,7 +535,7 @@ bridge_success(JObj, OffnetReq) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]. --spec bridge_failure(kz_json:object(), kapi_offnet_resource:req()) -> kz_proplist(). +-spec bridge_failure(kz_json:object(), kapi_offnet_resource:req()) -> kz_term:proplist(). bridge_failure(JObj, OffnetReq) -> lager:debug("resources for outbound request failed: ~s" ,[kz_json:get_value(<<"Disposition">>, JObj)] @@ -550,7 +550,7 @@ bridge_failure(JObj, OffnetReq) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]. --spec bridge_not_configured(kapi_offnet_resource:req()) -> kz_proplist(). +-spec bridge_not_configured(kapi_offnet_resource:req()) -> kz_term:proplist(). bridge_not_configured(OffnetReq) -> [{<<"Call-ID">>, kapi_offnet_resource:call_id(OffnetReq)} ,{<<"Msg-ID">>, kapi_offnet_resource:msg_id(OffnetReq)} @@ -584,8 +584,8 @@ send_deny_emergency_notification(OffnetReq) -> ], kapps_notify_publisher:cast(Props, fun kapi_notifications:publish_denied_emergency_bridge/1). --spec send_deny_emergency_response(kapi_offnet_resource:req(), ne_binary()) -> - {'ok', ne_binary()} | +-spec send_deny_emergency_response(kapi_offnet_resource:req(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | {'error', 'no_response'}. send_deny_emergency_response(OffnetReq, ControlQ) -> CallId = kapi_offnet_resource:call_id(OffnetReq), @@ -600,7 +600,7 @@ send_deny_emergency_response(OffnetReq, ControlQ) -> ), kz_call_response:send(CallId, ControlQ, Code, Cause, Media). --spec get_event_type(kz_json:object()) -> {ne_binary(), ne_binary(), ne_binary()}. +-spec get_event_type(kz_json:object()) -> {kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()}. get_event_type(JObj) -> {C, E} = kz_util:get_event_type(JObj), {C, E, kz_call_event:call_id(JObj)}. diff --git a/applications/stepswitch/src/stepswitch_cnam.erl b/applications/stepswitch/src/stepswitch_cnam.erl index 18ed412dafd..b0651ea121e 100644 --- a/applications/stepswitch/src/stepswitch_cnam.erl +++ b/applications/stepswitch/src/stepswitch_cnam.erl @@ -66,12 +66,12 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(any()) -> startlink_ret(). +-spec start_link(any()) -> kz_types:startlink_ret(). start_link(_) -> _ = ssl:start(), gen_server:start_link(?SERVER, [], []). --spec lookup(kz_json:object() | ne_binary()) -> kz_json:object(). +-spec lookup(kz_json:object() | kz_term:ne_binary()) -> kz_json:object(). lookup(<<_/binary>> = Number) -> Num = case ?DISABLE_NORMALIZE of 'false' -> knm_converters:normalize(Number); @@ -97,11 +97,11 @@ lookup(JObj) -> update_request(JObj, CNAM, 'false') end. --spec set_phone_number(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec set_phone_number(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). set_phone_number(Num, JObj) -> kz_json:set_value(<<"phone_number">>, kz_util:uri_encode(Num), JObj). --spec update_request(kz_json:object(), api_binary(), boolean()) -> kz_json:object(). +-spec update_request(kz_json:object(), kz_term:api_binary(), boolean()) -> kz_json:object(). update_request(JObj, 'undefined', _) -> JObj; update_request(JObj, CNAM, FromCache) -> Props = [{<<"Caller-ID-Name">>, CNAM} @@ -152,7 +152,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call({'render', Props, Template}, _, TemplateName) -> {'ok', TemplateName} = kz_template:compile(Template, TemplateName), {'ok', Result} = kz_template:render(TemplateName, Props), @@ -170,7 +170,7 @@ handle_call(_Request, _From, TemplateName) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, TemplateName) -> {'noreply', TemplateName}. @@ -184,7 +184,7 @@ handle_cast(_Msg, TemplateName) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, TemplateName) -> {'noreply', TemplateName}. @@ -196,7 +196,7 @@ handle_info(_Info, TemplateName) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _TemplateName) -> {'reply', []}. @@ -236,7 +236,7 @@ code_change(_OldVsn, TemplateName, _Extra) -> %% %% @end %%-------------------------------------------------------------------- --spec json_to_template_props(api_object()) -> 'undefined' | kz_proplist(). +-spec json_to_template_props(kz_term:api_object()) -> 'undefined' | kz_term:proplist(). json_to_template_props('undefined') -> 'undefined'; json_to_template_props(JObj) -> normalize_proplist(kz_json:recursive_to_proplist(JObj)). @@ -247,12 +247,12 @@ json_to_template_props(JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec normalize_proplist(kz_proplist()) -> kz_proplist(). +-spec normalize_proplist(kz_term:proplist()) -> kz_term:proplist(). normalize_proplist(Props) -> [normalize_proplist_element(Elem) || Elem <- Props]. --spec normalize_proplist_element({kz_proplist_key(), kz_proplist_value()}) -> - {kz_proplist_key(), kz_proplist_value()}. +-spec normalize_proplist_element({kz_term:proplist_key(), kz_term:proplist_value()}) -> + {kz_term:proplist_key(), kz_term:proplist_value()}. normalize_proplist_element({K, V}) when is_list(V) -> {normalize_value(K), normalize_proplist(V)}; normalize_proplist_element({K, V}) when is_binary(V) -> @@ -266,10 +266,10 @@ normalize_proplist_element(Else) -> normalize_value(Value) -> binary:replace(kz_term:to_lower_binary(Value), <<"-">>, <<"_">>, ['global']). --spec cache_key(ne_binary()) -> {'cnam', ne_binary()}. +-spec cache_key(kz_term:ne_binary()) -> {'cnam', kz_term:ne_binary()}. cache_key(Number) -> ?CACHE_KEY(Number). --spec fetch_cnam(ne_binary(), kz_json:object()) -> api_binary(). +-spec fetch_cnam(kz_term:ne_binary(), kz_json:object()) -> kz_term:api_binary(). fetch_cnam(Number, JObj) -> case make_request(Number, JObj) of 'undefined' -> 'undefined'; @@ -279,7 +279,7 @@ fetch_cnam(Number, JObj) -> CNAM end. --spec make_request(ne_binary(), kz_json:object()) -> api_binary(). +-spec make_request(kz_term:ne_binary(), kz_json:object()) -> kz_term:api_binary(). make_request(Number, JObj) -> Timeout = 2.99 * ?MILLISECONDS_IN_SECOND, case kz_util:runs_in(Timeout, fun request/2, [Number, JObj]) of @@ -287,7 +287,7 @@ make_request(Number, JObj) -> timeout -> undefined end. --spec request(ne_binary(), kz_json:object()) -> api_binary(). +-spec request(kz_term:ne_binary(), kz_json:object()) -> kz_term:api_binary(). request(Number, JObj) -> Url = kz_term:to_list(get_http_url(JObj)), case kz_http:req(get_http_method() @@ -314,7 +314,7 @@ request(Number, JObj) -> 'undefined' end. --spec get_http_url(kz_json:object()) -> ne_binary(). +-spec get_http_url(kz_json:object()) -> kz_term:ne_binary(). get_http_url(JObj) -> Template = kapps_config:get_binary(?CONFIG_CAT, <<"http_url">>, ?DEFAULT_URL), {'ok', SrcUrl} = render(JObj, Template), @@ -349,14 +349,14 @@ get_http_headers() -> ], maybe_enable_auth(Headers). --spec get_http_options(nonempty_string()) -> kz_proplist(). +-spec get_http_options(nonempty_string()) -> kz_term:proplist(). get_http_options(Url) -> Defaults = [{'connect_timeout', ?HTTP_CONNECT_TIMEOUT_MS} ,{'timeout', 1500} ], maybe_enable_ssl(Url, Defaults). --spec maybe_enable_ssl(nonempty_string(), kz_proplist()) -> kz_proplist(). +-spec maybe_enable_ssl(nonempty_string(), kz_term:proplist()) -> kz_term:proplist(). maybe_enable_ssl("https://" ++ _, Props) -> [{'ssl', [{'verify', 'verify_none'}]}|Props]; maybe_enable_ssl(_Url, Props) -> Props. @@ -387,8 +387,8 @@ get_http_method() -> _Else -> 'get' end. --spec render(kz_json:object(), ne_binary()) -> {'ok', iolist()} | - {'error', 'timeout'}. +-spec render(kz_json:object(), kz_term:ne_binary()) -> {'ok', iolist()} | + {'error', 'timeout'}. render(JObj, Template) -> case catch poolboy:checkout(?STEPSWITCH_CNAM_POOL, 'false', 1000) of W when is_pid(W) -> diff --git a/applications/stepswitch/src/stepswitch_cnam_pool_sup.erl b/applications/stepswitch/src/stepswitch_cnam_pool_sup.erl index df22afd943f..05093acba9c 100644 --- a/applications/stepswitch/src/stepswitch_cnam_pool_sup.erl +++ b/applications/stepswitch/src/stepswitch_cnam_pool_sup.erl @@ -32,7 +32,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -45,7 +45,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, diff --git a/applications/stepswitch/src/stepswitch_inbound.erl b/applications/stepswitch/src/stepswitch_inbound.erl index e10ea28cec6..1b28c15fd01 100644 --- a/applications/stepswitch/src/stepswitch_inbound.erl +++ b/applications/stepswitch/src/stepswitch_inbound.erl @@ -16,7 +16,7 @@ %% %% @end %%-------------------------------------------------------------------- --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(JObj, _Props) -> _ = kz_util:put_callid(JObj), 'true' = kapi_route:req_v(JObj), @@ -131,7 +131,7 @@ maybe_find_resource(_, JObj) -> ) end. --spec add_resource_id(kz_json:object(), kz_proplist()) -> kz_json:object(). +-spec add_resource_id(kz_json:object(), kz_term:proplist()) -> kz_json:object(). add_resource_id(JObj, ResourceProps) -> ResourceId = props:get_value('resource_id', ResourceProps), kz_json:set_values([{?CCV(<<"Resource-ID">>), ResourceId} @@ -146,7 +146,7 @@ add_resource_id(JObj, ResourceProps) -> ,JObj ). --spec maybe_add_t38_settings(kz_json:object(), kz_proplist()) -> kz_json:object(). +-spec maybe_add_t38_settings(kz_json:object(), kz_term:proplist()) -> kz_json:object(). maybe_add_t38_settings(JObj, ResourceProps) -> case props:get_value('fax_option', ResourceProps) of 'true' -> @@ -268,7 +268,7 @@ maybe_transition_port_in(NumberProps, JObj) -> 'true' -> transition_port_in(knm_number_options:number(NumberProps), JObj) end. --spec transition_port_in(ne_binary(), api_object()) -> any(). +-spec transition_port_in(kz_term:ne_binary(), kz_term:api_object()) -> any(). transition_port_in(Number, JObj) -> {ok, MasterAccountId} = kapps_util:get_master_account_id(), Comment = <<(?APP_NAME)/binary, "-", (?APP_VERSION)/binary, " automagic">>, @@ -314,8 +314,8 @@ is_number_blacklisted(Blacklist, JObj) -> 'true' end. --spec get_blacklists(ne_binary()) -> - {'ok', ne_binaries()} | +-spec get_blacklists(kz_term:ne_binary()) -> + {'ok', kz_term:ne_binaries()} | {'error', any()}. get_blacklists(AccountId) -> case kz_account:fetch(AccountId) of @@ -330,7 +330,7 @@ get_blacklists(AccountId) -> end end. --spec get_blacklist(ne_binary(), ne_binaries()) -> kz_json:object(). +-spec get_blacklist(kz_term:ne_binary(), kz_term:ne_binaries()) -> kz_json:object(). get_blacklist(AccountId, Blacklists) -> AccountDb = kz_util:format_account_id(AccountId, 'encoded'), lists:foldl( diff --git a/applications/stepswitch/src/stepswitch_listener.erl b/applications/stepswitch/src/stepswitch_listener.erl index 2a214b92c27..0586405d970 100644 --- a/applications/stepswitch/src/stepswitch_listener.erl +++ b/applications/stepswitch/src/stepswitch_listener.erl @@ -49,7 +49,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link({'local', ?SERVER}, ?MODULE, [{'bindings', ?BINDINGS} ,{'responders', ?RESPONDERS} @@ -92,7 +92,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -106,7 +106,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> {'noreply', State}. @@ -120,7 +120,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> lager:debug("unhandled message: ~p", [_Info]), {'noreply', State}. diff --git a/applications/stepswitch/src/stepswitch_local_extension.erl b/applications/stepswitch/src/stepswitch_local_extension.erl index fffe651f24f..0e2432aee2b 100644 --- a/applications/stepswitch/src/stepswitch_local_extension.erl +++ b/applications/stepswitch/src/stepswitch_local_extension.erl @@ -25,11 +25,11 @@ -record(state, {number_props = [] :: knm_number_options:extra_options() ,resource_req :: kapi_offnet_resource:req() ,request_handler :: pid() - ,control_queue :: api_binary() - ,response_queue :: api_binary() - ,queue :: api_binary() - ,timeout :: api_reference() - ,call_id :: api_binary() + ,control_queue :: kz_term:api_binary() + ,response_queue :: kz_term:api_binary() + ,queue :: kz_term:api_binary() + ,timeout :: kz_term:api_reference() + ,call_id :: kz_term:api_binary() }). -type state() :: #state{}. @@ -57,7 +57,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(knm_number_options:extra_options(), kapi_offnet_resource:req()) -> startlink_ret(). +-spec start_link(knm_number_options:extra_options(), kapi_offnet_resource:req()) -> kz_types:startlink_ret(). start_link(NumberProps, OffnetReq) -> CallId = kapi_offnet_resource:call_id(OffnetReq), Bindings = [?CALL_BINDING(CallId) @@ -115,7 +115,7 @@ init([NumberProps, OffnetReq]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> lager:debug("unhandled call: ~p", [_Request]), {'reply', {'error', 'not_implemented'}, State}. @@ -130,7 +130,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'kz_amqp_channel', _}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'created_queue', Q}}, State) -> @@ -168,7 +168,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info('local_extension_timeout', #state{timeout='undefined'}=State) -> {'noreply', State}; handle_info('local_extension_timeout', #state{response_queue=ResponseQ @@ -263,14 +263,14 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec outbound_flags(kapi_offnet_resource:req()) -> api_binary(). +-spec outbound_flags(kapi_offnet_resource:req()) -> kz_term:api_binary(). outbound_flags(OffnetJObj) -> case kapi_offnet_resource:flags(OffnetJObj) of [] -> 'undefined'; Flags -> kz_binary:join(Flags, <<"|">>) end. --spec build_local_extension(state()) -> kz_proplist(). +-spec build_local_extension(state()) -> kz_term:proplist(). build_local_extension(#state{number_props=Props ,resource_req=OffnetJObj ,queue=Q @@ -344,14 +344,14 @@ build_local_extension(#state{number_props=Props | kz_api:default_headers(Q, <<"call">>, <<"command">>, ?APP_NAME, ?APP_VERSION) ]). --spec get_account_realm(ne_binary()) -> ne_binary(). +-spec get_account_realm(kz_term:ne_binary()) -> kz_term:ne_binary(). get_account_realm(AccountId) -> case kz_account:fetch_realm(AccountId) of 'undefined' -> AccountId; Realm -> Realm end. --spec local_extension_caller_id(kz_json:object()) -> {api_binary(), api_binary()}. +-spec local_extension_caller_id(kz_json:object()) -> {kz_term:api_binary(), kz_term:api_binary()}. local_extension_caller_id(JObj) -> {kz_json:get_first_defined([<<"Outbound-Caller-ID-Name">> ,<<"Emergency-Caller-ID-Name">> @@ -361,13 +361,13 @@ local_extension_caller_id(JObj) -> ], JObj) }. --spec local_extension_callee_id(kz_json:object(), ne_binary()) -> {api_binary(), api_binary()}. +-spec local_extension_callee_id(kz_json:object(), kz_term:ne_binary()) -> {kz_term:api_binary(), kz_term:api_binary()}. local_extension_callee_id(JObj, Number) -> {kz_json:get_value(<<"Outbound-Callee-ID-Number">>, JObj, Number) ,kz_json:get_value(<<"Outbound-Callee-ID-Name">>, JObj, Number) }. --spec local_extension_timeout(kz_json:object()) -> kz_proplist(). +-spec local_extension_timeout(kz_json:object()) -> kz_term:proplist(). local_extension_timeout(Request) -> lager:debug("attempt to connect to resources timed out"), [{<<"Call-ID">>, kz_json:get_value(<<"Call-ID">>, Request)} @@ -379,7 +379,7 @@ local_extension_timeout(Request) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]. --spec local_extension_error(kz_json:object(), kz_json:object()) -> kz_proplist(). +-spec local_extension_error(kz_json:object(), kz_json:object()) -> kz_term:proplist(). local_extension_error(JObj, Request) -> lager:debug("error during outbound request: ~s", [kz_term:to_binary(kz_json:encode(JObj))]), [{<<"Call-ID">>, kz_json:get_value(<<"Call-ID">>, Request)} @@ -391,7 +391,7 @@ local_extension_error(JObj, Request) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]. --spec local_extension_success(kz_json:object()) -> kz_proplist(). +-spec local_extension_success(kz_json:object()) -> kz_term:proplist(). local_extension_success(Request) -> lager:debug("local extension request successfully completed"), [{<<"Call-ID">>, kz_json:get_value(<<"Call-ID">>, Request)} @@ -402,7 +402,7 @@ local_extension_success(Request) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]. --spec local_extension_failure(kz_json:object(), kapi_offnet_resource:req()) -> kz_proplist(). +-spec local_extension_failure(kz_json:object(), kapi_offnet_resource:req()) -> kz_term:proplist(). local_extension_failure(JObj, OffnetReq) -> lager:debug("resources for outbound request failed: ~s" ,[kz_json:get_value(<<"Disposition">>, JObj)] @@ -417,7 +417,7 @@ local_extension_failure(JObj, OffnetReq) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]. --spec get_event_type(kz_json:object()) -> {ne_binary(), ne_binary(), ne_binary()}. +-spec get_event_type(kz_json:object()) -> {kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()}. get_event_type(JObj) -> {C, E} = kz_util:get_event_type(JObj), {C, E, kz_call_event:call_id(JObj)}. diff --git a/applications/stepswitch/src/stepswitch_local_sms.erl b/applications/stepswitch/src/stepswitch_local_sms.erl index ccae1770938..3bc772dbd51 100644 --- a/applications/stepswitch/src/stepswitch_local_sms.erl +++ b/applications/stepswitch/src/stepswitch_local_sms.erl @@ -32,7 +32,7 @@ local_message_handling(Props, OffnetReq) -> send_route_win(FetchId, CallId, JObjResp) end. --spec sms_error(kz_json:object(), kapi_offnet_resource:req()) -> kz_proplist(). +-spec sms_error(kz_json:object(), kapi_offnet_resource:req()) -> kz_term:proplist(). sms_error(JObj, OffnetReq) -> lager:debug("error during outbound request: ~s" ,[kz_json:encode(kapi_offnet_resource:req_to_jobj(OffnetReq))] @@ -46,7 +46,7 @@ sms_error(JObj, OffnetReq) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]. --spec sms_success(kz_json:object(), kapi_offnet_resource:req()) -> kz_proplist(). +-spec sms_success(kz_json:object(), kapi_offnet_resource:req()) -> kz_term:proplist(). sms_success(JObj, OffnetReq) -> lager:debug("outbound request successfully completed"), [{<<"Call-ID">>, kapi_offnet_resource:call_id(OffnetReq)} @@ -57,11 +57,11 @@ sms_success(JObj, OffnetReq) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]. --spec send_sms_response(kz_json:object() | kz_proplist(), ne_binary()) -> 'ok'. +-spec send_sms_response(kz_json:object() | kz_term:proplist(), kz_term:ne_binary()) -> 'ok'. send_sms_response(JObj, ServerID) -> kz_amqp_worker:cast(JObj, fun(A) -> kapi_offnet_resource:publish_resp(ServerID, A) end). --spec send_route_win(ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec send_route_win(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. send_route_win(_FetchId, CallId, JObj) -> ServerQ = kz_api:server_id(JObj), CCVs = kz_json:get_value(<<"Custom-Channel-Vars">>, JObj, kz_json:new()), @@ -74,7 +74,7 @@ send_route_win(_FetchId, CallId, JObj) -> lager:debug("sending route_win to ~s", [ServerQ]), kz_amqp_worker:cast(Win, fun(Payload)-> kapi_route:publish_win(ServerQ, Payload) end). --spec delivery_from_req(kapi_offnet_resource:req(), binary(), api_binary(), api_boolean()) -> +-spec delivery_from_req(kapi_offnet_resource:req(), binary(), kz_term:api_binary(), kz_term:api_boolean()) -> kz_json:object(). delivery_from_req(OffnetReq, Status, DeliveryCode, DeliveryFailure) -> OffnetJObj = kapi_offnet_resource:req_to_jobj(OffnetReq), @@ -96,7 +96,7 @@ delivery_from_req(OffnetReq, Status, DeliveryCode, DeliveryFailure) -> ,kz_json:delete_keys(Keys, OffnetJObj) ). --spec request_caller_id(kapi_offnet_resource:req()) -> {ne_binary(), ne_binary()}. +-spec request_caller_id(kapi_offnet_resource:req()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. request_caller_id(OffnetReq) -> AccountId = kapi_offnet_resource:account_id(OffnetReq), {kapi_offnet_resource:outbound_caller_id_number(OffnetReq @@ -107,7 +107,7 @@ request_caller_id(OffnetReq) -> ) }. --spec route_req(ne_binary(), ne_binary(), knm_number_options:extra_options(), kapi_offnet_resource:req()) -> kz_proplist(). +-spec route_req(kz_term:ne_binary(), kz_term:ne_binary(), knm_number_options:extra_options(), kapi_offnet_resource:req()) -> kz_term:proplist(). route_req(CallId, FetchId, Props, OffnetReq) -> TargetAccountId = knm_number_options:account_id(Props), TargetAccountRealm = kz_account:fetch_realm(TargetAccountId), diff --git a/applications/stepswitch/src/stepswitch_maintenance.erl b/applications/stepswitch/src/stepswitch_maintenance.erl index ff2c9116553..8198854eb86 100644 --- a/applications/stepswitch/src/stepswitch_maintenance.erl +++ b/applications/stepswitch/src/stepswitch_maintenance.erl @@ -30,7 +30,7 @@ %% %% @end %%-------------------------------------------------------------------- --spec reverse_lookup(text()) -> 'ok'. +-spec reverse_lookup(kz_term:text()) -> 'ok'. reverse_lookup(Thing) when not is_binary(Thing) -> reverse_lookup(kz_term:to_binary(Thing)); reverse_lookup(Thing) -> @@ -42,7 +42,7 @@ reverse_lookup(Thing) -> {'error', 'not_found'} -> io:format("resource not found~n") end. --spec pretty_print_lookup(kz_proplist()) -> 'ok'. +-spec pretty_print_lookup(kz_term:proplist()) -> 'ok'. pretty_print_lookup([]) -> 'ok'; pretty_print_lookup([{Key, Value}|Props]) -> io:format("~-19s: ~s~n", [Key, kz_term:to_binary(Value)]), @@ -54,7 +54,7 @@ pretty_print_lookup([{Key, Value}|Props]) -> %% Displays account tree when given a DID %% @end %%-------------------------------------------------------------------- --spec number_tree(ne_binary()) -> 'ok'. +-spec number_tree(kz_term:ne_binary()) -> 'ok'. number_tree(DID) -> case knm_number:lookup_account(DID) of {'error', _} -> io:format("DID ~s was not found~n", [DID]); @@ -65,13 +65,13 @@ number_tree(DID) -> end end. --spec number_tree(ne_binary(), kz_json:object()) -> 'ok'. +-spec number_tree(kz_term:ne_binary(), kz_json:object()) -> 'ok'. number_tree(DID, AccountDoc) -> io:format("~s tree ", [DID]), print_tree(kz_account:tree(AccountDoc)), io:format(" ~s(~s)~n", [kz_account:name(AccountDoc), kz_doc:id(AccountDoc)]). --spec print_tree(ne_binaries()) -> 'ok'. +-spec print_tree(kz_term:ne_binaries()) -> 'ok'. print_tree([]) -> 'ok'; print_tree([AccountId|Tree]) -> io:format(" ~s(~s) ->", [kz_account:fetch_name(AccountId), AccountId]), @@ -95,7 +95,7 @@ pretty_print_resources([Resource|Resources]) -> io:format("~n"), pretty_print_resources(Resources). --spec pretty_print_resource(kz_proplist()) -> 'ok'. +-spec pretty_print_resource(kz_term:proplist()) -> 'ok'. pretty_print_resource([]) -> 'ok'; pretty_print_resource([{_, []}|Props]) -> pretty_print_resource(Props); @@ -141,7 +141,7 @@ refresh() -> %% Lookup a number in the route db and return the account ID if known %% @end %%-------------------------------------------------------------------- --spec lookup_number(text()) -> 'ok'. +-spec lookup_number(kz_term:text()) -> 'ok'. lookup_number(Number) -> case knm_number:lookup_account(Number) of {'ok', AccountId, Props} -> @@ -154,7 +154,7 @@ lookup_number(Number) -> io:format("number not found~n") end. --spec pretty_print_number_props(kz_proplist()) -> 'ok'. +-spec pretty_print_number_props(kz_term:proplist()) -> 'ok'. pretty_print_number_props([]) -> 'ok'; pretty_print_number_props([{Key, Value}|Props]) -> io:format("~-19s: ~s~n", [kz_term:to_binary(Key), kz_term:to_binary(Value)]), @@ -172,7 +172,7 @@ reload_resources() -> _ = stepswitch_resources:fetch_global_resources(), 'ok'. --spec reload_resources(ne_binary()) -> 'ok'. +-spec reload_resources(kz_term:ne_binary()) -> 'ok'. reload_resources(Account) -> AccountId = kz_util:format_account_id(Account, 'raw'), _ = stepswitch_resources:fetch_local_resources(AccountId), @@ -184,10 +184,10 @@ reload_resources(Account) -> %% %% @end %%-------------------------------------------------------------------- --spec process_number(text()) -> any(). +-spec process_number(kz_term:text()) -> any(). process_number(Number) -> process_number(Number, 'undefined'). --spec process_number(text(), text() | 'undefined') -> any(). +-spec process_number(kz_term:text(), kz_term:text() | 'undefined') -> any(). process_number(Num, 'undefined') -> JObj = kz_json:from_list([{<<"To-DID">>, kz_term:to_binary(Num)}]), Number = stepswitch_util:get_outbound_destination(JObj), @@ -213,7 +213,7 @@ pretty_print_endpoints([Endpoint|Endpoints]) -> io:format("~n"), pretty_print_endpoints(Endpoints). --spec pretty_print_endpoint(kz_proplist()) -> any(). +-spec pretty_print_endpoint(kz_term:proplist()) -> any(). pretty_print_endpoint([]) -> 'ok'; pretty_print_endpoint([{_, []}|Props]) -> pretty_print_endpoint(Props); diff --git a/applications/stepswitch/src/stepswitch_originate.erl b/applications/stepswitch/src/stepswitch_originate.erl index 95a785bd546..0c5f242f44f 100644 --- a/applications/stepswitch/src/stepswitch_originate.erl +++ b/applications/stepswitch/src/stepswitch_originate.erl @@ -26,9 +26,9 @@ ,endpoints = [] :: kz_json:objects() ,resource_req :: kapi_offnet_resource:req() ,request_handler :: pid() - ,response_queue :: api_binary() - ,queue :: api_binary() - ,timeout :: api_reference() + ,response_queue :: kz_term:api_binary() + ,queue :: kz_term:api_binary() + ,timeout :: kz_term:api_reference() }). -type state() :: #state{}. @@ -47,7 +47,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(kz_json:objects(), kapi_offnet_resource:req()) -> startlink_ret(). +-spec start_link(kz_json:objects(), kapi_offnet_resource:req()) -> kz_types:startlink_ret(). start_link(Endpoints, OffnetReq) -> gen_listener:start_link(?SERVER, [{'bindings', ?BINDINGS} ,{'responders', ?RESPONDERS} @@ -95,7 +95,7 @@ init([Endpoints, OffnetReq]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> lager:debug("unhandled call: ~p", [_Request]), {'reply', {'error', 'not_implemented'}, State}. @@ -110,7 +110,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'kz_amqp_channel', _}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'created_queue', Q}}, State) -> @@ -166,7 +166,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info('originate_timeout', #state{timeout='undefined'}=State) -> {'noreply', State}; handle_info('originate_timeout', #state{response_queue=ResponseQ @@ -303,7 +303,7 @@ build_originate(#state{endpoints=Endpoints | kz_api:default_headers(Q, <<"resource">>, <<"originate_req">>, ?APP_NAME, ?APP_VERSION) ]). --spec originate_from_uri(ne_binary(), kz_json:object()) -> api_binary(). +-spec originate_from_uri(kz_term:ne_binary(), kz_json:object()) -> kz_term:api_binary(). originate_from_uri(CIDNum, OffnetReq) -> Realm = kz_json:get_first_defined([<<"From-URI-Realm">> ,<<"Account-Realm">> @@ -321,7 +321,7 @@ originate_from_uri(CIDNum, OffnetReq) -> FromURI end. --spec originate_caller_id(kz_json:object()) -> {api_binary(), api_binary()}. +-spec originate_caller_id(kz_json:object()) -> {kz_term:api_binary(), kz_term:api_binary()}. originate_caller_id(OffnetReq) -> {kz_json:get_first_defined([<<"Outbound-Caller-ID-Number">> ,<<"Emergency-Caller-ID-Number">> @@ -331,7 +331,7 @@ originate_caller_id(OffnetReq) -> ], OffnetReq) }. --spec originate_timeout(kz_json:object()) -> kz_proplist(). +-spec originate_timeout(kz_json:object()) -> kz_term:proplist(). originate_timeout(Request) -> lager:debug("attempt to connect to resources timed out"), [{<<"Call-ID">>, kz_json:get_value(<<"Outbound-Call-ID">>, Request)} @@ -343,7 +343,7 @@ originate_timeout(Request) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]. --spec originate_error(kz_json:object(), kz_json:object()) -> kz_proplist(). +-spec originate_error(kz_json:object(), kz_json:object()) -> kz_term:proplist(). originate_error(JObj, OffnetReq) -> lager:debug("error during originate request: ~s", [kz_term:to_binary(kz_json:encode(JObj))]), [{<<"Call-ID">>, kz_json:get_value(<<"Outbound-Call-ID">>, OffnetReq)} @@ -355,7 +355,7 @@ originate_error(JObj, OffnetReq) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]. --spec originate_success(kz_json:object(), kz_json:object()) -> kz_proplist(). +-spec originate_success(kz_json:object(), kz_json:object()) -> kz_term:proplist(). originate_success(JObj, OffnetReq) -> lager:debug("originate request successfully completed"), [{<<"Call-ID">>, kz_json:get_value(<<"Outbound-Call-ID">>, OffnetReq)} @@ -366,7 +366,7 @@ originate_success(JObj, OffnetReq) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]. --spec originate_failure(kz_json:object(), kz_json:object()) -> kz_proplist(). +-spec originate_failure(kz_json:object(), kz_json:object()) -> kz_term:proplist(). originate_failure(JObj, OffnetReq) -> lager:debug("originate request failed: ~s", [kz_json:get_value(<<"Application-Response">>, JObj)]), [{<<"Call-ID">>, kz_json:get_value(<<"Outbound-Call-ID">>, OffnetReq)} @@ -379,7 +379,7 @@ originate_failure(JObj, OffnetReq) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]. --spec originate_ready(kz_json:object(), kz_json:object()) -> kz_proplist(). +-spec originate_ready(kz_json:object(), kz_json:object()) -> kz_term:proplist(). originate_ready(JObj, OffnetReq) -> lager:debug("originate is ready to execute"), [{<<"Call-ID">>, kz_json:get_value(<<"Outbound-Call-ID">>, JObj)} diff --git a/applications/stepswitch/src/stepswitch_outbound.erl b/applications/stepswitch/src/stepswitch_outbound.erl index 00d83058701..71538f6d74e 100644 --- a/applications/stepswitch/src/stepswitch_outbound.erl +++ b/applications/stepswitch/src/stepswitch_outbound.erl @@ -23,7 +23,7 @@ %% route %% @end %%-------------------------------------------------------------------- --spec handle_req(kz_json:object(), kz_proplist()) -> any(). +-spec handle_req(kz_json:object(), kz_term:proplist()) -> any(). handle_req(OffnetJObj, _Props) -> 'true' = kapi_offnet_resource:req_v(OffnetJObj), OffnetReq = kapi_offnet_resource:jobj_to_req(OffnetJObj), @@ -41,7 +41,7 @@ handle_req(OffnetJObj, _Props) -> %% @end %%-------------------------------------------------------------------- -spec handle_audio_req(kapi_offnet_resource:req()) -> any(). --spec handle_audio_req(ne_binary(), kapi_offnet_resource:req()) -> any(). +-spec handle_audio_req(kz_term:ne_binary(), kapi_offnet_resource:req()) -> any(). handle_audio_req(OffnetReq) -> Number = stepswitch_util:get_outbound_destination(OffnetReq), lager:debug("received outbound audio resource request for ~s: ~p", [Number, OffnetReq]), @@ -67,7 +67,7 @@ handle_originate_req(OffnetReq) -> ), handle_originate_req(Number, maybe_add_call_id(kz_json:get_value(<<"Outbound-Call-ID">>, OffnetReq) , OffnetReq)). --spec handle_originate_req(ne_binary(), kapi_offnet_resource:req()) -> any(). +-spec handle_originate_req(kz_term:ne_binary(), kapi_offnet_resource:req()) -> any(). handle_originate_req(Number, OffnetReq) -> case knm_number:lookup_account(Number) of {'ok', _AccountId, Props} -> @@ -75,7 +75,7 @@ handle_originate_req(Number, OffnetReq) -> _ -> maybe_originate(Number, OffnetReq) end. --spec maybe_add_call_id(api_binary(), kapi_offnet_resource:req()) -> kz_json:object(). +-spec maybe_add_call_id(kz_term:api_binary(), kapi_offnet_resource:req()) -> kz_json:object(). maybe_add_call_id('undefined', OffnetReq) -> kz_json:set_value(<<"Outbound-Call-ID">>, kz_binary:rand_hex(8), OffnetReq); maybe_add_call_id(_, OffnetReq) -> OffnetReq. @@ -144,7 +144,7 @@ maybe_force_outbound_sms(Props, OffnetReq) -> %% %% @end %%-------------------------------------------------------------------- --spec maybe_bridge(ne_binary(), kapi_offnet_resource:req()) -> any(). +-spec maybe_bridge(kz_term:ne_binary(), kapi_offnet_resource:req()) -> any(). maybe_bridge(Number, OffnetReq) -> RouteBy = stepswitch_util:route_by(), case RouteBy:endpoints(Number, OffnetReq) of @@ -152,7 +152,7 @@ maybe_bridge(Number, OffnetReq) -> Endpoints -> stepswitch_request_sup:bridge(Endpoints, OffnetReq) end. --spec maybe_correct_shortdial(ne_binary(), kapi_offnet_resource:req()) -> any(). +-spec maybe_correct_shortdial(kz_term:ne_binary(), kapi_offnet_resource:req()) -> any(). maybe_correct_shortdial(Number, OffnetReq) -> case stepswitch_util:correct_shortdial(Number, OffnetReq) of 'undefined' -> @@ -172,7 +172,7 @@ maybe_correct_shortdial(Number, OffnetReq) -> %% %% @end %%-------------------------------------------------------------------- --spec maybe_sms(ne_binary(), kapi_offnet_resource:req()) -> any(). +-spec maybe_sms(kz_term:ne_binary(), kapi_offnet_resource:req()) -> any(). maybe_sms(Number, OffnetReq) -> RouteBy = stepswitch_util:route_by(), case RouteBy:endpoints(Number, OffnetReq) of @@ -187,7 +187,7 @@ maybe_sms(Number, OffnetReq) -> %% @end %%-------------------------------------------------------------------- -spec local_extension(knm_number_options:extra_options(), kapi_offnet_resource:req()) -> - sup_startchild_ret(). + kz_types:sup_startchild_ret(). local_extension(Props, OffnetReq) -> stepswitch_request_sup:local_extension(Props, OffnetReq). @@ -207,7 +207,7 @@ local_sms(Props, OffnetReq) -> %% %% @end %%-------------------------------------------------------------------- --spec maybe_originate(ne_binary(), kapi_offnet_resource:req()) -> any(). +-spec maybe_originate(kz_term:ne_binary(), kapi_offnet_resource:req()) -> any(). maybe_originate(Number, OffnetReq) -> RouteBy = stepswitch_util:route_by(), case RouteBy:endpoints(Number, OffnetReq) of @@ -224,7 +224,7 @@ local_originate(Props, OffnetReq) -> lager:debug("originate local request"), stepswitch_request_sup:originate(Endpoints, J). --spec local_originate_caller_id(kapi_offnet_resource:req()) -> {api_binary(), api_binary()}. +-spec local_originate_caller_id(kapi_offnet_resource:req()) -> {kz_term:api_binary(), kz_term:api_binary()}. local_originate_caller_id(OffnetReq) -> {kz_json:get_first_defined([<<"Outbound-Caller-ID-Number">> ,<<"Emergency-Caller-ID-Number">> @@ -234,7 +234,7 @@ local_originate_caller_id(OffnetReq) -> ], OffnetReq) }. --spec get_account_realm(ne_binary()) -> ne_binary(). +-spec get_account_realm(kz_term:ne_binary()) -> kz_term:ne_binary(). get_account_realm(AccountId) -> case kz_account:fetch_realm(AccountId) of 'undefined' -> AccountId; @@ -289,7 +289,7 @@ publish_no_resources(OffnetReq) -> kapi_offnet_resource:publish_resp(ResponseQ, no_resources(OffnetReq)) end. --spec no_resources(kapi_offnet_resource:req()) -> kz_proplist(). +-spec no_resources(kapi_offnet_resource:req()) -> kz_term:proplist(). no_resources(OffnetReq) -> ToDID = kapi_offnet_resource:to_did(OffnetReq), lager:info("no available resources for ~s", [ToDID]), diff --git a/applications/stepswitch/src/stepswitch_request_sup.erl b/applications/stepswitch/src/stepswitch_request_sup.erl index a9b74016d7a..ba52a6e72ad 100644 --- a/applications/stepswitch/src/stepswitch_request_sup.erl +++ b/applications/stepswitch/src/stepswitch_request_sup.erl @@ -30,23 +30,23 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec child_name(kapi_offnet_resource:req()) -> ne_binary(). +-spec child_name(kapi_offnet_resource:req()) -> kz_term:ne_binary(). child_name(OffnetReq) -> <<(kapi_offnet_resource:call_id(OffnetReq))/binary ,"-", (kz_binary:rand_hex(3))/binary >>. --spec outbound_child_name(kapi_offnet_resource:req()) -> ne_binary(). +-spec outbound_child_name(kapi_offnet_resource:req()) -> kz_term:ne_binary(). outbound_child_name(OffnetReq) -> <<(kapi_offnet_resource:outbound_call_id(OffnetReq))/binary ,"-", (kz_binary:rand_hex(3))/binary >>. --spec bridge(kz_json:objects(), kapi_offnet_resource:req()) -> sup_startchild_ret(). +-spec bridge(kz_json:objects(), kapi_offnet_resource:req()) -> kz_types:sup_startchild_ret(). bridge(Endpoints, OffnetReq) -> supervisor:start_child(?SERVER ,?WORKER_NAME_ARGS_TYPE(child_name(OffnetReq) @@ -57,7 +57,7 @@ bridge(Endpoints, OffnetReq) -> ). -spec local_extension(knm_number_options:extra_options(), kapi_offnet_resource:req()) -> - sup_startchild_ret(). + kz_types:sup_startchild_ret(). local_extension(Props, OffnetReq) -> supervisor:start_child(?SERVER ,?WORKER_NAME_ARGS_TYPE(child_name(OffnetReq) @@ -67,7 +67,7 @@ local_extension(Props, OffnetReq) -> ) ). --spec originate(kz_json:objects(), kapi_offnet_resource:req()) -> sup_startchild_ret(). +-spec originate(kz_json:objects(), kapi_offnet_resource:req()) -> kz_types:sup_startchild_ret(). originate(Endpoints, OffnetReq) -> supervisor:start_child(?SERVER ,?WORKER_NAME_ARGS_TYPE(outbound_child_name(OffnetReq) @@ -77,7 +77,7 @@ originate(Endpoints, OffnetReq) -> ) ). --spec sms(kz_json:objects(), kapi_offnet_resource:req()) -> sup_startchild_ret(). +-spec sms(kz_json:objects(), kapi_offnet_resource:req()) -> kz_types:sup_startchild_ret(). sms(Endpoints, OffnetReq) -> supervisor:start_child(?SERVER ,?WORKER_NAME_ARGS_TYPE(child_name(OffnetReq) @@ -100,7 +100,7 @@ sms(Endpoints, OffnetReq) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, diff --git a/applications/stepswitch/src/stepswitch_resource_selectors.erl b/applications/stepswitch/src/stepswitch_resource_selectors.erl index 36985d10649..35473ed9a71 100644 --- a/applications/stepswitch/src/stepswitch_resource_selectors.erl +++ b/applications/stepswitch/src/stepswitch_resource_selectors.erl @@ -46,7 +46,7 @@ ] ). --spec endpoints(ne_binary(), kapi_offnet_resource:req()) -> kz_json:objects(). +-spec endpoints(kz_term:ne_binary(), kapi_offnet_resource:req()) -> kz_json:objects(). endpoints(Number, OffnetJObj) -> HuntAccountId = maybe_get_hunt_account(OffnetJObj), SelectorsDb = kz_util:format_resource_selectors_db(HuntAccountId), @@ -57,7 +57,7 @@ endpoints(Number, OffnetJObj) -> {'error', _E} -> [] end. --spec foldl_modules(ne_binary(), kapi_offnet_resource:req(), ne_binary(), kz_json:objects()) -> stepswitch_resources:resources(). +-spec foldl_modules(kz_term:ne_binary(), kapi_offnet_resource:req(), kz_term:ne_binary(), kz_json:objects()) -> stepswitch_resources:resources(). foldl_modules(Number, OffnetJObj, SelectorsDb, SelectorRules) -> lists:foldl(fun(Rule, Resources) -> rule_to_resource(Rule, Resources, Number, OffnetJObj, SelectorsDb) @@ -66,7 +66,7 @@ foldl_modules(Number, OffnetJObj, SelectorsDb, SelectorRules) -> ,SelectorRules ). --spec rule_to_resource(kz_json:object(), stepswitch_resources:resources(), ne_binary(), kapi_offnet_resource:req(), ne_binary()) -> +-spec rule_to_resource(kz_json:object(), stepswitch_resources:resources(), kz_term:ne_binary(), kapi_offnet_resource:req(), kz_term:ne_binary()) -> stepswitch_resources:resources(). rule_to_resource(Rule, Resources, Number, OffnetJObj, SelectorsDb) -> [Module|_] = kz_json:get_keys(Rule), @@ -97,7 +97,7 @@ rule_to_resource(Rule, Resources, Number, OffnetJObj, SelectorsDb) -> [] end. --spec maybe_get_hunt_account(kapi_offnet_resource:req()) -> api_binary(). +-spec maybe_get_hunt_account(kapi_offnet_resource:req()) -> kz_term:api_binary(). maybe_get_hunt_account(OffnetJObj) -> HuntAccountId = kapi_offnet_resource:hunt_account_id(OffnetJObj), AccountId = kapi_offnet_resource:account_id(OffnetJObj), @@ -109,7 +109,7 @@ maybe_get_hunt_account(OffnetJObj) -> 'false' -> MasterAccountId end. --spec get_selector_rules(api_binary()) -> +-spec get_selector_rules(kz_term:api_binary()) -> {'ok', kz_json:objects()} | {'error', any()}. get_selector_rules(HuntAccountId) -> diff --git a/applications/stepswitch/src/stepswitch_resources.erl b/applications/stepswitch/src/stepswitch_resources.erl index 7fee3e8482a..21116fa884b 100644 --- a/applications/stepswitch/src/stepswitch_resources.erl +++ b/applications/stepswitch/src/stepswitch_resources.erl @@ -94,37 +94,37 @@ kapps_config:get_integer(?SS_CONFIG_CAT, <<"default_weight">>, 3)). -define(DEFAULT_RTCP_MUX, kapps_config:get_binary(?SS_CONFIG_CAT, <<"default_rtcp_mux">>)). --record(gateway, {server :: api_binary() - ,port :: api_integer() - ,realm :: api_binary() - ,username :: api_binary() - ,password :: api_binary() - ,route :: api_binary() +-record(gateway, {server :: kz_term:api_binary() + ,port :: kz_term:api_integer() + ,realm :: kz_term:api_binary() + ,username :: kz_term:api_binary() + ,password :: kz_term:api_binary() + ,route :: kz_term:api_binary() ,prefix = <<>> :: binary() ,suffix = <<>> :: binary() - ,codecs = [] :: ne_binaries() + ,codecs = [] :: kz_term:ne_binaries() ,bypass_media = 'false' :: boolean() ,rtcp_mux = <<>> :: binary() - ,caller_id_type = <<"external">> :: ne_binary() - ,fax_option :: ne_binary() | boolean() - ,sip_headers :: api_object() - ,sip_interface :: api_binary() + ,caller_id_type = <<"external">> :: kz_term:ne_binary() + ,fax_option :: kz_term:ne_binary() | boolean() + ,sip_headers :: kz_term:api_object() + ,sip_interface :: kz_term:api_binary() ,progress_timeout = 8 :: 1..100 - ,invite_format = <<"route">> :: ne_binary() - ,endpoint_type = <<"sip">> :: ne_binary() + ,invite_format = <<"route">> :: kz_term:ne_binary() + ,endpoint_type = <<"sip">> :: kz_term:ne_binary() ,endpoint_options = kz_json:new() :: kz_json:object() ,format_from_uri = 'false' :: boolean() ,from_account_realm = 'false' :: boolean() - ,from_uri_realm :: api_binary() + ,from_uri_realm :: kz_term:api_binary() ,is_emergency = 'false' :: boolean() ,force_port = 'false' :: boolean() - ,privacy_mode = 'undefined' :: api_binary() - ,invite_parameters = 'undefined' :: api_object() + ,privacy_mode = 'undefined' :: kz_term:api_binary() + ,invite_parameters = 'undefined' :: kz_term:api_object() }). --record(resrc, {id :: api_binary() - ,rev :: api_binary() - ,name :: api_binary() +-record(resrc, {id :: kz_term:api_binary() + ,rev :: kz_term:api_binary() + ,name :: kz_term:api_binary() ,weight = 1 :: 1..100 ,grace_period = 3 :: non_neg_integer() ,flags = [] :: list() @@ -137,16 +137,16 @@ ,require_flags = 'false' :: boolean() ,global = 'true' :: boolean() ,format_from_uri = 'false' :: boolean() - ,from_uri_realm :: api_binary() + ,from_uri_realm :: kz_term:api_binary() ,from_account_realm = 'false' :: boolean() - ,fax_option :: ne_binary() | boolean() - ,codecs = [] :: ne_binaries() + ,fax_option :: kz_term:ne_binary() | boolean() + ,codecs = [] :: kz_term:ne_binaries() ,bypass_media = 'false' :: boolean() - ,formatters :: api_objects() - ,proxies = [] :: kz_proplist() + ,formatters :: kz_term:api_objects() + ,proxies = [] :: kz_term:proplist() ,selector_marks = [] :: [tuple()] - ,privacy_mode = 'undefined' :: api_binary() - ,classifier = 'undefined' :: api_binary() + ,privacy_mode = 'undefined' :: kz_term:api_binary() + ,classifier = 'undefined' :: kz_term:api_binary() ,classifier_enable = 'true' :: boolean() }). @@ -164,20 +164,20 @@ -compile({'no_auto_import', [get/0, get/1]}). --spec get_props() -> kz_proplists(). +-spec get_props() -> kz_term:proplists(). get_props() -> [resource_to_props(Resource) || Resource <- sort_resources(get()) ]. --spec get_props(ne_binary()) -> kz_proplist() | 'undefined'. +-spec get_props(kz_term:ne_binary()) -> kz_term:proplist() | 'undefined'. get_props(ResourceId) -> case get_resource(ResourceId) of 'undefined' -> 'undefined'; Resource -> resource_to_props(Resource) end. --spec get_props(ne_binary(), api_binary()) -> kz_proplist() | 'undefined'. +-spec get_props(kz_term:ne_binary(), kz_term:api_binary()) -> kz_term:proplist() | 'undefined'. get_props(_ResourceId, 'undefined') -> 'undefined'; get_props(ResourceId, AccountId) -> case get_local_resource(ResourceId, AccountId) of @@ -185,7 +185,7 @@ get_props(ResourceId, AccountId) -> Resource -> resource_to_props(Resource) end. --spec resource_to_props(resource()) -> kz_proplist(). +-spec resource_to_props(resource()) -> kz_term:proplist(). resource_to_props(#resrc{}=Resource) -> props:filter_undefined( [{<<"Name">>, Resource#resrc.name} @@ -221,21 +221,21 @@ sort_resources(Resources) -> %% %% @end %%-------------------------------------------------------------------- --spec endpoints(ne_binary(), kapi_offnet_resource:req()) -> kz_json:objects(). +-spec endpoints(kz_term:ne_binary(), kapi_offnet_resource:req()) -> kz_json:objects(). endpoints(Number, OffnetJObj) -> case maybe_get_endpoints(Number, OffnetJObj) of [] -> []; Endpoints -> sort_endpoints(Endpoints) end. --spec maybe_get_endpoints(ne_binary(), kapi_offnet_resource:req()) -> kz_json:objects(). +-spec maybe_get_endpoints(kz_term:ne_binary(), kapi_offnet_resource:req()) -> kz_json:objects(). maybe_get_endpoints(Number, OffnetJObj) -> case kapi_offnet_resource:hunt_account_id(OffnetJObj) of 'undefined' -> get_global_endpoints(Number, OffnetJObj); HuntAccount -> maybe_get_local_endpoints(HuntAccount, Number, OffnetJObj) end. --spec maybe_get_local_endpoints(ne_binary(), ne_binary(), kapi_offnet_resource:req()) -> kz_json:objects(). +-spec maybe_get_local_endpoints(kz_term:ne_binary(), kz_term:ne_binary(), kapi_offnet_resource:req()) -> kz_json:objects(). maybe_get_local_endpoints(HuntAccount, Number, OffnetJObj) -> AccountId = kapi_offnet_resource:account_id(OffnetJObj), case kz_util:is_in_account_hierarchy(HuntAccount, AccountId, 'true') of @@ -249,14 +249,14 @@ maybe_get_local_endpoints(HuntAccount, Number, OffnetJObj) -> get_local_endpoints(HuntAccount, Number, OffnetJObj) end. --spec get_local_endpoints(ne_binary(), ne_binary(), kapi_offnet_resource:req()) -> kz_json:objects(). +-spec get_local_endpoints(kz_term:ne_binary(), kz_term:ne_binary(), kapi_offnet_resource:req()) -> kz_json:objects(). get_local_endpoints(AccountId, Number, OffnetJObj) -> lager:debug("attempting to find local resources for ~s", [AccountId]), Flags = kapi_offnet_resource:flags(OffnetJObj, []), Resources = filter_resources(Flags, get(AccountId)), resources_to_endpoints(Resources, Number, OffnetJObj). --spec get_global_endpoints(ne_binary(), kapi_offnet_resource:req()) -> kz_json:objects(). +-spec get_global_endpoints(kz_term:ne_binary(), kapi_offnet_resource:req()) -> kz_json:objects(). get_global_endpoints(Number, OffnetJObj) -> lager:debug("attempting to find global resources"), Flags = kapi_offnet_resource:flags(OffnetJObj, []), @@ -279,7 +279,7 @@ endpoint_ordering(P1, P2) -> %% @end %%-------------------------------------------------------------------- -spec reverse_lookup(kz_json:object()) -> - {'ok', kz_proplist()} | + {'ok', kz_term:proplist()} | {'error', 'not_found'}. reverse_lookup(JObj) -> Realm = stepswitch_util:get_realm(JObj), @@ -294,7 +294,7 @@ reverse_lookup(JObj) -> maybe_find_local(IP, Port, Realm, AccountId) end. --spec find_port(kz_json:object()) -> api_integer(). +-spec find_port(kz_json:object()) -> kz_term:api_integer(). find_port(JObj) -> case kz_json:get_first_defined([<<"From-Network-Port">> ,<<"Orig-Port">> @@ -304,7 +304,7 @@ find_port(JObj) -> Port -> kz_term:to_integer(Port) end. --spec find_account_id(api_binary(), kz_json:object()) -> api_binary(). +-spec find_account_id(kz_term:api_binary(), kz_json:object()) -> kz_term:api_binary(). find_account_id(Realm, JObj) -> case kz_json:get_first_defined([<<"Account-ID">> ,?CCV(<<"Account-ID">>) @@ -314,7 +314,7 @@ find_account_id(Realm, JObj) -> AccountId -> AccountId end. --spec find_account_id(api_binary()) -> api_binary(). +-spec find_account_id(kz_term:api_binary()) -> kz_term:api_binary(). find_account_id('undefined') -> 'undefined'; find_account_id(Realm) -> case kapps_util:get_account_by_realm(Realm) of @@ -322,21 +322,21 @@ find_account_id(Realm) -> {'ok', AccountId} -> AccountId end. --spec maybe_find_global(api_binary(), api_integer(), api_binary()) -> - {'ok', kz_proplist()} | +-spec maybe_find_global(kz_term:api_binary(), kz_term:api_integer(), kz_term:api_binary()) -> + {'ok', kz_term:proplist()} | {'error', 'not_found'}. maybe_find_global(IP, Port, Realm) -> search_resources(IP, Port, Realm, get()). --spec maybe_find_local(api_binary(), api_integer(), api_binary(), api_binary()) -> - {'ok', kz_proplist()} | +-spec maybe_find_local(kz_term:api_binary(), kz_term:api_integer(), kz_term:api_binary(), kz_term:api_binary()) -> + {'ok', kz_term:proplist()} | {'error', 'not_found'}. maybe_find_local(_, _, _, 'undefined') -> {'error', 'not_found'}; maybe_find_local(IP, Port, Realm, AccountId) -> search_resources(IP, Port, Realm, get(AccountId)). --spec search_resources(api_binary(), api_integer(), api_binary(), resources()) -> - {'ok', kz_proplist()} | +-spec search_resources(kz_term:api_binary(), kz_term:api_integer(), kz_term:api_binary(), resources()) -> + {'ok', kz_term:proplist()} | {'error', 'not_found'}. search_resources(_IP, _Port, _Realm, []) -> lager:debug("failed to find matching resource for ~s:~p(~s)", [_IP, _Port, _Realm]), @@ -366,7 +366,7 @@ search_resources(IP, Port, Realm, [#resrc{id=Id {'ok', Props} end. --spec search_gateways(api_binary(), api_integer(), api_binary(), gateways()) -> +-spec search_gateways(kz_term:api_binary(), kz_term:api_integer(), kz_term:api_binary(), gateways()) -> gateway() | {'error', 'not_found'}. search_gateways(_, _, _, []) -> {'error', 'not_found'}; @@ -376,7 +376,7 @@ search_gateways(IP, Port, Realm, [Gateway | Gateways]) -> #gateway{}=Gateway -> Gateway end. --spec search_gateway(api_binary(), api_integer(), api_binary(), gateway()) -> +-spec search_gateway(kz_term:api_binary(), kz_term:api_integer(), kz_term:api_binary(), gateway()) -> gateway() | {'error', 'not_found'}. search_gateway(IP, Port, _, #gateway{server=IP @@ -414,7 +414,7 @@ search_gateway(_, _, _, _) -> %% %% @end %%-------------------------------------------------------------------- --spec filter_resources(ne_binaries(), resources()) -> resources(). +-spec filter_resources(kz_term:ne_binaries(), resources()) -> resources(). filter_resources([], Resources) -> lager:debug("no flags provided, filtering resources that require flags"), [Resource @@ -425,7 +425,7 @@ filter_resources(Flags, Resources) -> lager:debug("filtering resources by flags"), filter_resources(Flags, Resources, []). --spec filter_resources(ne_binaries(), resources(), resources()) -> resources(). +-spec filter_resources(kz_term:ne_binaries(), resources(), resources()) -> resources(). filter_resources(_, [], Filtered) -> Filtered; filter_resources(Flags, [Resource|Resources], Filtered) -> case resource_has_flags(Flags, Resource) of @@ -433,12 +433,12 @@ filter_resources(Flags, [Resource|Resources], Filtered) -> 'true' -> filter_resources(Flags, Resources, [Resource | Filtered]) end. --spec resource_has_flags(ne_binaries(), resource()) -> boolean(). +-spec resource_has_flags(kz_term:ne_binaries(), resource()) -> boolean(). resource_has_flags(Flags, Resource) -> HasFlag = fun(Flag) -> resource_has_flag(Flag, Resource) end, lists:all(HasFlag, Flags). --spec resource_has_flag(ne_binary(), resource()) -> boolean(). +-spec resource_has_flag(kz_term:ne_binary(), resource()) -> boolean(). resource_has_flag(Flag, #resrc{flags=ResourceFlags, id=_Id}) -> case kz_term:is_empty(Flag) orelse lists:member(Flag, ResourceFlags) @@ -455,7 +455,7 @@ resource_has_flag(Flag, #resrc{flags=ResourceFlags, id=_Id}) -> %% %% @end %%-------------------------------------------------------------------- --spec resources_to_endpoints(resources(), ne_binary(), kapi_offnet_resource:req()) -> +-spec resources_to_endpoints(resources(), kz_term:ne_binary(), kapi_offnet_resource:req()) -> kz_json:objects(). resources_to_endpoints(Resources, Number, OffnetJObj) -> ResourceMap = lists:foldl(fun resource_classifier_map/2, maps:new(), Resources), @@ -497,8 +497,8 @@ resource_classifier_map(Resource, Map) -> Resources = maps:get(Classification, Map, []), maps:put(Classification, [Resource|Resources], Map). --spec build_endpoints_from_resources(resources(), ne_binary(), kapi_offnet_resource:req()) -> kz_json:objects(). --spec build_endpoints_from_resources(resources(), ne_binary(), kapi_offnet_resource:req(), kz_json:objects()) -> kz_json:objects(). +-spec build_endpoints_from_resources(resources(), kz_term:ne_binary(), kapi_offnet_resource:req()) -> kz_json:objects(). +-spec build_endpoints_from_resources(resources(), kz_term:ne_binary(), kapi_offnet_resource:req(), kz_json:objects()) -> kz_json:objects(). build_endpoints_from_resources(Resources, Number, OffnetJObj) -> build_endpoints_from_resources(Resources, Number, OffnetJObj, []). @@ -510,7 +510,7 @@ build_endpoints_from_resources([Resource|Resources], Number, OffnetJObj, Endpoin MoreEndpoints -> build_endpoints_from_resources(Resources, Number, OffnetJObj, MoreEndpoints) end. --spec maybe_resource_to_endpoints(resource(), ne_binary(), kapi_offnet_resource:req(), kz_json:objects()) -> +-spec maybe_resource_to_endpoints(resource(), kz_term:ne_binary(), kapi_offnet_resource:req(), kz_json:objects()) -> {'error', 'no_match'} | kz_json:objects(). maybe_resource_to_endpoints(#resrc{id=Id @@ -553,7 +553,7 @@ maybe_resource_to_endpoints(#resrc{id=Id maybe_add_proxies(EndpointList, Proxies, Endpoints) end. --spec check_diversion_fields(kapi_offnet_resource:req()) -> ne_binary(). +-spec check_diversion_fields(kapi_offnet_resource:req()) -> kz_term:ne_binary(). check_diversion_fields(OffnetJObj) -> case kapi_offnet_resource:custom_sip_header(OffnetJObj, <<"Diversions">>) of [Diversion|_] -> @@ -563,12 +563,12 @@ check_diversion_fields(OffnetJObj) -> kapi_offnet_resource:outbound_caller_id_number(OffnetJObj) end. --spec update_endpoint(kz_json:object(), kz_proplist(), kz_proplist()) -> +-spec update_endpoint(kz_json:object(), kz_term:proplist(), kz_term:proplist()) -> kz_json:object(). update_endpoint(Endpoint, Updates, CCVUpdates) -> kz_json:set_values(Updates, update_ccvs(Endpoint, CCVUpdates)). --spec maybe_add_proxies(kz_json:objects(), kz_proplist(), kz_json:objects()) -> kz_json:objects(). +-spec maybe_add_proxies(kz_json:objects(), kz_term:proplist(), kz_json:objects()) -> kz_json:objects(). maybe_add_proxies([], _, Acc) -> Acc; maybe_add_proxies(Endpoints, [], Acc) -> Acc ++ Endpoints; maybe_add_proxies([Endpoint | Endpoints], Proxies, Acc) -> @@ -582,8 +582,8 @@ add_proxy(Endpoint, {Zone, IP}) -> ], kz_json:set_values(Updates ,Endpoint). --spec filter_resource_by_rules(ne_binary(), ne_binary(), re:mp(), ne_binary(), re:mp()) -> - {'ok', ne_binary()} | +-spec filter_resource_by_rules(kz_term:ne_binary(), kz_term:ne_binary(), re:mp(), kz_term:ne_binary(), re:mp()) -> + {'ok', kz_term:ne_binary()} | {'error', 'no_match'}. filter_resource_by_rules(Id, Number, Rules, CallerIdNumber, CallerIdRules) -> case evaluate_rules(Rules, Number) of @@ -594,8 +594,8 @@ filter_resource_by_rules(Id, Number, Rules, CallerIdNumber, CallerIdRules) -> filter_resource_by_match(Id, Number, CallerIdNumber, CallerIdRules, Match) end. --spec filter_resource_by_match(ne_binary(), ne_binary(), ne_binary(), re:mp(), ne_binary()) -> - {'ok', ne_binary()} | +-spec filter_resource_by_match(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), re:mp(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | {'error', 'no_match'}. filter_resource_by_match(Id, Number, CallerIdNumber, CallerIdRules, Match) -> case evaluate_cid_rules(CallerIdRules, CallerIdNumber) of @@ -612,13 +612,13 @@ filter_resource_by_match(Id, Number, CallerIdNumber, CallerIdRules, Match) -> {'error','no_match'} end. --spec update_ccvs(kz_json:object(), kz_proplist()) -> kz_json:object(). +-spec update_ccvs(kz_json:object(), kz_term:proplist()) -> kz_json:object(). update_ccvs(Endpoint, Updates) -> CCVs = kz_json:get_value(<<"Custom-Channel-Vars">>, Endpoint, kz_json:new()), kz_json:set_value(<<"Custom-Channel-Vars">>, kz_json:set_values(Updates, CCVs), Endpoint). --spec evaluate_rules(re:mp(), ne_binary()) -> - {'ok', ne_binary()} | +-spec evaluate_rules(re:mp(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | {'error', 'no_match'}. evaluate_rules([], _) -> {'error', 'no_match'}; evaluate_rules([Rule|Rules], Number) -> @@ -634,8 +634,8 @@ evaluate_rules([Rule|Rules], Number) -> evaluate_rules(Rules, Number) end. --spec evaluate_cid_rules(re:mp(), ne_binary()) -> - {'ok', ne_binary()} | +-spec evaluate_cid_rules(re:mp(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | {'ok', 'empty_rules'} | %% empty rules, it`s ok, allow any number {'error', 'no_match'}. evaluate_cid_rules([], _) -> {'ok','empty_rules'}; @@ -647,7 +647,7 @@ evaluate_cid_rules(CIDRules, CIDNumber) -> evaluate_rules(CIDRules, CIDNumber). %% %% @end %%-------------------------------------------------------------------- --spec gateways_to_endpoints(ne_binary(), gateways(), kapi_offnet_resource:req(), kz_json:objects()) -> +-spec gateways_to_endpoints(kz_term:ne_binary(), gateways(), kapi_offnet_resource:req(), kz_json:objects()) -> kz_json:objects(). gateways_to_endpoints(_Number, [], _OffnetJObj, Endpoints) -> Endpoints; gateways_to_endpoints(Number, [Gateway|Gateways], OffnetJObj, Endpoints) -> @@ -657,7 +657,7 @@ gateways_to_endpoints(Number, [Gateway|Gateways], OffnetJObj, Endpoints) -> ,[gateway_to_endpoint(Number, Gateway, OffnetJObj) | Endpoints] ). --spec gateway_to_endpoint(ne_binary(), gateway(), kapi_offnet_resource:req()) -> +-spec gateway_to_endpoint(kz_term:ne_binary(), gateway(), kapi_offnet_resource:req()) -> kz_json:object(). gateway_to_endpoint(DestinationNumber ,#gateway{invite_format=InviteFormat @@ -710,17 +710,17 @@ gateway_to_endpoint(DestinationNumber ])). --spec sip_invite_parameters(gateway(), kz_json:object()) -> ne_binaries(). +-spec sip_invite_parameters(gateway(), kz_json:object()) -> kz_term:ne_binaries(). sip_invite_parameters(Gateway, OffnetJObj) -> static_sip_invite_parameters(Gateway) ++ dynamic_sip_invite_parameters(Gateway, OffnetJObj). --spec static_sip_invite_parameters(gateway()) -> ne_binaries(). +-spec static_sip_invite_parameters(gateway()) -> kz_term:ne_binaries(). static_sip_invite_parameters(#gateway{invite_parameters='undefined'}) -> []; static_sip_invite_parameters(#gateway{invite_parameters=Parameters}) -> kz_json:get_list_value(<<"static">>, Parameters, []). --spec dynamic_sip_invite_parameters(gateway(), kz_json:object()) -> ne_binaries(). +-spec dynamic_sip_invite_parameters(gateway(), kz_json:object()) -> kz_term:ne_binaries(). dynamic_sip_invite_parameters(#gateway{invite_parameters='undefined'}, _) -> []; dynamic_sip_invite_parameters(#gateway{invite_parameters=Parameters}, OffnetJObj) -> CCVs = kz_json:normalize(kapi_offnet_resource:requestor_custom_channel_vars(OffnetJObj, kz_json:new())), @@ -728,11 +728,11 @@ dynamic_sip_invite_parameters(#gateway{invite_parameters=Parameters}, OffnetJObj Keys = kz_json:get_list_value(<<"dynamic">>, Parameters, []), dynamic_sip_invite_parameters(Keys, CCVs, CSHs). --spec dynamic_sip_invite_parameters(api_binaries(), kz_json:object(), kz_json:object()) -> ne_binaries(). +-spec dynamic_sip_invite_parameters(kz_term:api_binaries(), kz_json:object(), kz_json:object()) -> kz_term:ne_binaries(). dynamic_sip_invite_parameters(Keys, CCVs, CSHs) -> dynamic_sip_invite_parameters(Keys, CCVs, CSHs, []). --spec dynamic_sip_invite_parameters(api_binaries(), kz_json:object(), kz_json:object(), ne_binaries()) -> ne_binaries(). +-spec dynamic_sip_invite_parameters(kz_term:api_binaries(), kz_json:object(), kz_json:object(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). dynamic_sip_invite_parameters([], _, _, Parameters) -> Parameters; dynamic_sip_invite_parameters([Key|Keys], CCVs, CSHs, Parameters) when is_binary(Key) -> case dynamic_sip_invite_value(Key, CCVs, CSHs) of @@ -754,7 +754,7 @@ dynamic_sip_invite_parameters([JObj|Keys], CCVs, CSHs, Parameters) -> dynamic_sip_invite_parameters(Keys, CCVs, CSHs, [Parameter|Parameters]) end. --spec dynamic_sip_invite_value(ne_binary(), kz_json:object(), kz_json:object()) -> api_binary(). +-spec dynamic_sip_invite_value(kz_term:ne_binary(), kz_json:object(), kz_json:object()) -> kz_term:api_binary(). dynamic_sip_invite_value(<<"zone">>, _, _) -> kz_term:to_binary(kz_nodes:local_zone()); dynamic_sip_invite_value(<<"custom_sip_headers.", Key/binary>>, _, CSHs) -> @@ -764,7 +764,7 @@ dynamic_sip_invite_value(<<"custom_channel_vars.", Key/binary>>, CCVs, _) -> dynamic_sip_invite_value(_, _, _) -> 'undefined'. --spec gateway_cid(kapi_offnet_resource:req(), api_binary(), api_binary()) -> {ne_binary(), ne_binary()}. +-spec gateway_cid(kapi_offnet_resource:req(), kz_term:api_binary(), kz_term:api_binary()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. gateway_cid(OffnetJObj, IsEmergency, PrivacyMode) -> CCVs = kz_json:get_ne_value(<<"Custom-Channel-Vars">>, OffnetJObj, kz_json:new()), AccountId = kapi_offnet_resource:hunt_account_id(OffnetJObj, kapi_offnet_resource:account_id(OffnetJObj)), @@ -777,7 +777,7 @@ gateway_cid(OffnetJObj, IsEmergency, PrivacyMode) -> , DefaultCID ). --spec default_gateway_cid(kapi_offnet_resource:req(), api_binary()) -> {ne_binary(), ne_binary()}. +-spec default_gateway_cid(kapi_offnet_resource:req(), kz_term:api_binary()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. default_gateway_cid(OffnetJObj, 'undefined') -> {kapi_offnet_resource:outbound_caller_id_name(OffnetJObj) ,kapi_offnet_resource:outbound_caller_id_number(OffnetJObj) @@ -787,7 +787,7 @@ default_gateway_cid(OffnetJObj, <<"true">>) -> ,stepswitch_bridge:bridge_emergency_cid_number(OffnetJObj) }. --spec gateway_from_uri_settings(gateway()) -> kz_proplist(). +-spec gateway_from_uri_settings(gateway()) -> kz_term:proplist(). gateway_from_uri_settings(#gateway{format_from_uri='false'}) -> [{<<"Format-From-URI">>, 'false'}]; gateway_from_uri_settings(#gateway{format_from_uri='true' @@ -820,7 +820,7 @@ gateway_from_uri_settings(#gateway{format_from_uri='true' end end. --spec maybe_get_t38(gateway(), kapi_offnet_resource:req()) -> kz_proplist(). +-spec maybe_get_t38(gateway(), kapi_offnet_resource:req()) -> kz_term:proplist(). maybe_get_t38(#gateway{fax_option=FaxOption}, OffnetJObj) -> Flags = kapi_offnet_resource:flags(OffnetJObj, []), case lists:member(<<"fax">>, Flags) of @@ -831,7 +831,7 @@ maybe_get_t38(#gateway{fax_option=FaxOption}, OffnetJObj) -> ) end. --spec gateway_emergency_resource(gateway()) -> api_binary(). +-spec gateway_emergency_resource(gateway()) -> kz_term:api_binary(). gateway_emergency_resource(#gateway{is_emergency='true'}) -> lager:debug("gateway is part of an emergency resource"), <<"true">>; @@ -846,7 +846,7 @@ gateway_emergency_resource(_) -> 'undefined'. -spec get() -> resources(). get() -> get('undefined'). --spec get(api_binary()) -> resources(). +-spec get(kz_term:api_binary()) -> resources(). get('undefined') -> case kz_cache:fetch_local(?CACHE_NAME, 'global_resources') of {'ok', Resources} -> Resources; @@ -858,7 +858,7 @@ get(AccountId) -> {'error', 'not_found'} -> fetch_local_resources(AccountId) end. --spec get_resource(ne_binary()) -> resource() | 'undefined'. +-spec get_resource(kz_term:ne_binary()) -> resource() | 'undefined'. get_resource(ResourceId) -> case get('undefined') of [] -> 'undefined'; @@ -872,7 +872,7 @@ get_resource(ResourceId, [#resrc{}|Resources]) -> get_resource(_ResourceId, []) -> 'undefined'. --spec get_local_resource(ne_binary(), ne_binary()) -> resource() | 'undefined'. +-spec get_local_resource(kz_term:ne_binary(), kz_term:ne_binary()) -> resource() | 'undefined'. get_local_resource(ResourceId, AccountId) -> case get(AccountId) of [] -> 'undefined'; @@ -913,7 +913,7 @@ fetch_global_resources() -> %% %% @end %%-------------------------------------------------------------------- --spec fetch_local_resources(ne_binary()) -> resources(). +-spec fetch_local_resources(kz_term:ne_binary()) -> resources(). -ifdef(TEST). fetch_local_resources(AccountId) -> {'ok', JObjs} = kz_json:fixture(?APP, <<"fixtures/resources/global.json">>), @@ -935,7 +935,7 @@ fetch_local_resources(AccountId) -> end. -endif. --spec fetch_local_resources(ne_binary(), kz_json:objects()) -> resources(). +-spec fetch_local_resources(kz_term:ne_binary(), kz_json:objects()) -> resources(). fetch_local_resources(AccountId, JObjs) -> Proxies = fetch_account_dedicated_proxies(AccountId), resources_from_jobjs( @@ -947,7 +947,7 @@ fetch_local_resources(AccountId, JObjs) -> || JObj <- JObjs ]). --spec fetch_account_dedicated_proxies(api_binary()) -> kz_proplist(). +-spec fetch_account_dedicated_proxies(kz_term:api_binary()) -> kz_term:proplist(). fetch_account_dedicated_proxies('undefined') -> []; fetch_account_dedicated_proxies(AccountId) -> UseSingle = kapps_config:get_is_true(?SS_CONFIG_CAT, <<"use_first_dedicated_proxy_only">>, 'true'), @@ -957,7 +957,7 @@ fetch_account_dedicated_proxies(AccountId) -> _ -> [] end. --spec build_account_dedicated_proxy(kz_json:object()) -> {api_binary(), api_binary()}. +-spec build_account_dedicated_proxy(kz_json:object()) -> {kz_term:api_binary(), kz_term:api_binary()}. build_account_dedicated_proxy(Proxy) -> Zone = kz_json:get_value(<<"zone">>, Proxy), ProxyIP = kz_json:get_value(<<"ip">>, Proxy), @@ -994,7 +994,7 @@ create_resource(JObj, Resources) -> ) end. --spec create_resource(kz_proplist(), kz_proplist(), kz_json:object(), resources()) -> resources(). +-spec create_resource(kz_term:proplist(), kz_term:proplist(), kz_json:object(), resources()) -> resources(). create_resource([], _ConfigClassifiers, _Resource, Resources) -> Resources; create_resource([{Classifier, ClassifierJObj}|Classifiers], ConfigClassifiers, Resource, Resources) -> case props:get_value(Classifier, ConfigClassifiers) of @@ -1016,7 +1016,7 @@ create_resource([{Classifier, ClassifierJObj}|Classifiers], ConfigClassifiers, R ) end. --spec create_classifier_resource(kz_json:object(), kz_json:object(), ne_binary(), kz_proplist()) -> kz_json:object(). +-spec create_classifier_resource(kz_json:object(), kz_json:object(), kz_term:ne_binary(), kz_term:proplist()) -> kz_json:object(). create_classifier_resource(Resource, ClassifierJObj, Classifier, ConfigClassifier) -> DefaultRegex = kz_json:get_value(<<"regex">>, ConfigClassifier), DefaultEmergency = kz_json:is_true(<<"emergency">>, ConfigClassifier, 'undefined'), @@ -1047,7 +1047,7 @@ create_classifier_gateways(Resource, ClassifierJObj) -> ], kz_json:set_value(<<"gateways">>, Gateways, Resource). --spec classifier_is_emergency(kz_json:object(), ne_binary(), boolean() | 'undefined') -> boolean(). +-spec classifier_is_emergency(kz_json:object(), kz_term:ne_binary(), boolean() | 'undefined') -> boolean(). classifier_is_emergency(ClassifierJObj, <<"emergency">>, _DefaultEmergency) -> kz_json:is_true(<<"emergency">>, ClassifierJObj, 'true'); classifier_is_emergency(ClassifierJObj, _Classifier, DefaultEmergency) -> @@ -1099,12 +1099,12 @@ resource_bypass_media(JObj) -> Default = kapps_config:get_is_true(?SS_CONFIG_CAT, <<"default_bypass_media">>, 'false'), kz_json:is_true([<<"media">>, <<"bypass_media">>], JObj, Default). --spec resource_formatters(kz_json:object()) -> api_objects(). +-spec resource_formatters(kz_json:object()) -> kz_term:api_objects(). resource_formatters(JObj) -> Default = kapps_config:get(?SS_CONFIG_CAT, <<"default_formatters">>), kz_json:get_value(<<"formatters">>, JObj, Default). --spec resource_codecs(kz_json:object()) -> ne_binaries(). +-spec resource_codecs(kz_json:object()) -> kz_term:ne_binaries(). resource_codecs(JObj) -> DefaultAudio = kapps_config:get_ne_binaries(?SS_CONFIG_CAT, <<"default_audio_codecs">>, []), DefaultVideo = kapps_config:get_ne_binaries(?SS_CONFIG_CAT, <<"default_video_codecs">>, []), @@ -1122,7 +1122,7 @@ resource_rules(JObj) -> ,[kz_doc:account_db(JObj, <<"offnet">>), kz_doc:id(JObj), Rules]), resource_rules(Rules, []). --spec resource_rules(ne_binaries(), rules()) -> rules(). +-spec resource_rules(kz_term:ne_binaries(), rules()) -> rules(). resource_rules([], CompiledRules) -> CompiledRules; resource_rules([Rule|Rules], CompiledRules) -> case re:compile(Rule) of @@ -1229,7 +1229,7 @@ gateway_is_emergency(_, 'true') -> 'true'; gateway_is_emergency(JObj, IsEmergency) -> kz_json:is_true(<<"emergency">>, JObj, IsEmergency). --spec endpoint_options(kz_json:object(), api_binary()) -> kz_json:object(). +-spec endpoint_options(kz_json:object(), kz_term:api_binary()) -> kz_json:object(). endpoint_options(JObj, <<"freetdm">>) -> kz_json:from_list( [{<<"Span">>, kz_json:get_value(<<"span">>, JObj)} @@ -1268,7 +1268,7 @@ endpoint_options(_, _) -> %% Build the sip url of a resource gateway %% @end %%-------------------------------------------------------------------- --spec gateway_dialstring(gateway(), ne_binary()) -> ne_binary(). +-spec gateway_dialstring(gateway(), kz_term:ne_binary()) -> kz_term:ne_binary(). gateway_dialstring(#gateway{route='undefined' ,prefix=Prefix ,suffix=Suffix @@ -1290,9 +1290,9 @@ gateway_dialstring(#gateway{route=Route}, _) -> lager:debug("using pre-configured gateway route ~s", [Route]), Route. --spec get_resrc_id(resource()) -> api_binary(). --spec get_resrc_rev(resource()) -> api_binary(). --spec get_resrc_name(resource()) -> api_binary(). +-spec get_resrc_id(resource()) -> kz_term:api_binary(). +-spec get_resrc_rev(resource()) -> kz_term:api_binary(). +-spec get_resrc_name(resource()) -> kz_term:api_binary(). -spec get_resrc_weight(resource()) -> non_neg_integer(). -spec get_resrc_grace_period(resource()) -> non_neg_integer(). -spec get_resrc_flags(resource()) -> list(). @@ -1305,15 +1305,15 @@ gateway_dialstring(#gateway{route=Route}, _) -> -spec get_resrc_require_flags(resource()) -> boolean(). -spec get_resrc_global(resource()) -> boolean(). -spec get_resrc_format_from_uri(resource()) -> boolean(). --spec get_resrc_from_uri_realm(resource()) -> api_binary(). +-spec get_resrc_from_uri_realm(resource()) -> kz_term:api_binary(). -spec get_resrc_from_account_realm(resource()) -> boolean(). --spec get_resrc_fax_option(resource()) -> ne_binary() | boolean(). --spec get_resrc_codecs(resource()) -> ne_binaries(). +-spec get_resrc_fax_option(resource()) -> kz_term:ne_binary() | boolean(). +-spec get_resrc_codecs(resource()) -> kz_term:ne_binaries(). -spec get_resrc_bypass_media(resource()) -> boolean(). --spec get_resrc_formatters(resource()) -> api_objects(). --spec get_resrc_proxies(resource()) -> kz_proplist(). --spec get_resrc_selector_marks(resource()) -> kz_proplist(). --spec get_resrc_classifier(resource()) -> api_binary(). +-spec get_resrc_formatters(resource()) -> kz_term:api_objects(). +-spec get_resrc_proxies(resource()) -> kz_term:proplist(). +-spec get_resrc_selector_marks(resource()) -> kz_term:proplist(). +-spec get_resrc_classifier(resource()) -> kz_term:api_binary(). -spec get_resrc_classifier_enable(resource()) -> boolean(). get_resrc_id(#resrc{id=Id}) -> Id. @@ -1342,9 +1342,9 @@ get_resrc_selector_marks(#resrc{selector_marks=Marks}) -> Marks. get_resrc_classifier(#resrc{classifier=Classifier}) -> Classifier. get_resrc_classifier_enable(#resrc{classifier_enable=Enabled}) -> Enabled. --spec set_resrc_id(resource(), api_binary()) -> resource(). --spec set_resrc_rev(resource(), api_binary()) -> resource(). --spec set_resrc_name(resource(), api_binary()) -> resource(). +-spec set_resrc_id(resource(), kz_term:api_binary()) -> resource(). +-spec set_resrc_rev(resource(), kz_term:api_binary()) -> resource(). +-spec set_resrc_name(resource(), kz_term:api_binary()) -> resource(). -spec set_resrc_weight(resource(), non_neg_integer()) -> resource(). -spec set_resrc_grace_period(resource(), non_neg_integer()) -> resource(). -spec set_resrc_flags(resource(), list()) -> resource(). @@ -1357,14 +1357,14 @@ get_resrc_classifier_enable(#resrc{classifier_enable=Enabled}) -> Enabled. -spec set_resrc_require_flags(resource(), boolean()) -> resource(). -spec set_resrc_global(resource(), boolean()) -> resource(). -spec set_resrc_format_from_uri(resource(), boolean()) -> resource(). --spec set_resrc_from_uri_realm(resource(), api_binary()) -> resource(). +-spec set_resrc_from_uri_realm(resource(), kz_term:api_binary()) -> resource(). -spec set_resrc_from_account_realm(resource(), boolean()) -> resource(). --spec set_resrc_fax_option(resource(), ne_binary() | boolean()) -> resource(). --spec set_resrc_codecs(resource(), ne_binaries()) -> resource(). +-spec set_resrc_fax_option(resource(), kz_term:ne_binary() | boolean()) -> resource(). +-spec set_resrc_codecs(resource(), kz_term:ne_binaries()) -> resource(). -spec set_resrc_bypass_media(resource(), boolean()) -> resource(). --spec set_resrc_formatters(resource(), api_objects()) -> resource(). --spec set_resrc_proxies(resource(), kz_proplist()) -> resource(). --spec set_resrc_selector_marks(resource(), kz_proplist()) -> resource(). +-spec set_resrc_formatters(resource(), kz_term:api_objects()) -> resource(). +-spec set_resrc_proxies(resource(), kz_term:proplist()) -> resource(). +-spec set_resrc_selector_marks(resource(), kz_term:proplist()) -> resource(). set_resrc_id(Resource, Id) -> Resource#resrc{id=Id}. set_resrc_rev(Resource, Rev) -> Resource#resrc{rev=Rev}. diff --git a/applications/stepswitch/src/stepswitch_sms.erl b/applications/stepswitch/src/stepswitch_sms.erl index 76d456eb244..c52b0341978 100644 --- a/applications/stepswitch/src/stepswitch_sms.erl +++ b/applications/stepswitch/src/stepswitch_sms.erl @@ -28,10 +28,10 @@ -record(state, {endpoints = [] :: kz_json:objects() ,resource_req :: kapi_offnet_resource:req() ,request_handler :: pid() - ,control_queue :: api_binary() - ,response_queue :: api_binary() - ,queue :: api_binary() - ,message = [] :: kz_proplist() + ,control_queue :: kz_term:api_binary() + ,response_queue :: kz_term:api_binary() + ,queue :: kz_term:api_binary() + ,message = [] :: kz_term:proplist() ,messages = queue:new() :: queue:queue() }). -type state() :: #state{}. @@ -55,7 +55,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(kz_json:objects(), kapi_offnet_resource:req()) -> startlink_ret(). +-spec start_link(kz_json:objects(), kapi_offnet_resource:req()) -> kz_types:startlink_ret(). start_link(Endpoints, OffnetReq) -> Bindings = [{'self', []}], gen_listener:start_link(?SERVER, [{'bindings', Bindings} @@ -111,7 +111,7 @@ init([Endpoints, OffnetReq]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> lager:debug("unhandled call: ~p", [_Request]), {'reply', {'error', 'not_implemented'}, State}. @@ -126,7 +126,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'kz_amqp_channel', _}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'created_queue', Q}}, State) -> @@ -174,7 +174,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info('sms_timeout', State) -> gen_listener:cast(self(), 'next_message'), {'noreply', State}; @@ -190,7 +190,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. @@ -225,7 +225,7 @@ code_change(_OldVsn, State, _Extra) -> %%% Internal functions %%%=================================================================== --spec handle_message_delivery(kz_json:object(), kz_proplist()) -> no_return(). +-spec handle_message_delivery(kz_json:object(), kz_term:proplist()) -> no_return(). handle_message_delivery(JObj, Props) -> _ = kz_util:put_callid(JObj), Server = props:get_value('server',Props), @@ -235,12 +235,12 @@ handle_message_delivery(JObj, Props) -> 'false' -> gen_listener:cast(Server, {'sms_success', JObj}) end. --spec send(kz_json:object(), kz_proplist()) -> no_return(). +-spec send(kz_json:object(), kz_term:proplist()) -> no_return(). send(Endpoint, API) -> Type = kz_json:get_value(<<"Endpoint-Type">>, Endpoint, <<"sip">>), send(Type, Endpoint, API). --spec send(binary(), kz_json:object(), kz_proplist()) -> no_return(). +-spec send(binary(), kz_json:object(), kz_term:proplist()) -> no_return(). send(<<"sip">>, Endpoint, API) -> Options = kz_json:to_proplist(kz_json:get_value(<<"Endpoint-Options">>, Endpoint, [])), Payload = props:set_values( [{<<"Endpoints">>, [Endpoint]} | Options], API), @@ -275,11 +275,11 @@ send(<<"amqp">>, Endpoint, API) -> send_error(API, CallId, Reason) end. --spec filter_smpp({ne_binary(), any()}) -> boolean(). +-spec filter_smpp({kz_term:ne_binary(), any()}) -> boolean(). filter_smpp({<<"SMPP-", _/binary>>, _}) -> 'true'; filter_smpp(_) -> 'false'. --spec send_success(kz_proplist(), ne_binary()) -> 'ok'. +-spec send_success(kz_term:proplist(), kz_term:ne_binary()) -> 'ok'. send_success(API, CallId) -> DeliveryProps = [{<<"Delivery-Result-Code">>, <<"sip:200">>} ,{<<"Status">>, <<"Success">>} @@ -289,7 +289,7 @@ send_success(API, CallId) -> ], gen_listener:cast(self(), {'sms_success', kz_json:from_list(DeliveryProps)}). --spec send_timeout_error(kz_proplist(), ne_binary()) -> 'ok'. +-spec send_timeout_error(kz_term:proplist(), kz_term:ne_binary()) -> 'ok'. send_timeout_error(API, CallId) -> DeliveryProps = [{<<"Delivery-Result-Code">>, <<"sip:500">>} ,{<<"Delivery-Failure">>, 'true'} @@ -302,7 +302,7 @@ send_timeout_error(API, CallId) -> ], gen_listener:cast(self(), {'sms_error', kz_json:from_list(DeliveryProps)}). --spec send_error(kz_proplist(), ne_binary(), ne_binary()) -> 'ok'. +-spec send_error(kz_term:proplist(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. send_error(API, CallId, Reason) -> DeliveryProps = [{<<"Delivery-Result-Code">>, <<"sip:500">>} ,{<<"Delivery-Failure">>, 'true'} @@ -315,16 +315,16 @@ send_error(API, CallId, Reason) -> ], gen_listener:cast(self(), {'sms_error', kz_json:from_list(DeliveryProps)}). --spec amqp_exchange_options(api_object()) -> kz_proplist(). +-spec amqp_exchange_options(kz_term:api_object()) -> kz_term:proplist(). amqp_exchange_options('undefined') -> []; amqp_exchange_options(JObj) -> [{kz_term:to_atom(K, 'true'), V} || {K, V} <- kz_json:to_proplist(JObj) ]. --spec send_amqp_sms(kz_proplist(), atom()) -> +-spec send_amqp_sms(kz_term:proplist(), atom()) -> 'ok' | - {'error', ne_binary() | 'timeout'}. + {'error', kz_term:ne_binary() | 'timeout'}. send_amqp_sms(Payload, Pool) -> case kz_amqp_worker:cast(Payload, fun kapi_sms:publish_outbound/1, Pool) of {'returned', _JObj, Deliver} -> @@ -332,8 +332,8 @@ send_amqp_sms(Payload, Pool) -> Else -> Else end. --spec maybe_add_broker(api_binary(), api_binary(), api_binary(), ne_binary(), kz_proplist(), api_binary()) -> 'ok'. --spec maybe_add_broker(api_binary(), api_binary(), api_binary(), ne_binary(), kz_proplist(), api_binary(), boolean()) -> 'ok'. +-spec maybe_add_broker(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:ne_binary(), kz_term:proplist(), kz_term:api_binary()) -> 'ok'. +-spec maybe_add_broker(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:ne_binary(), kz_term:proplist(), kz_term:api_binary(), boolean()) -> 'ok'. maybe_add_broker(Broker, Exchange, RouteId, ExchangeType, ExchangeOptions, BrokerName) -> PoolExists = kz_amqp_sup:pool_pid(?SMS_POOL(Exchange, RouteId, BrokerName)) =/= 'undefined', maybe_add_broker(Broker, Exchange, RouteId, ExchangeType, ExchangeOptions, BrokerName, PoolExists). @@ -355,7 +355,7 @@ build_sms(#state{endpoints=Endpoints ,message=build_sms_base({CIDNum, CIDName}, OffnetReq, Q) }. --spec build_sms_base({binary(), binary()}, kapi_offnet_resource:req(), binary()) -> kz_proplist(). +-spec build_sms_base({binary(), binary()}, kapi_offnet_resource:req(), binary()) -> kz_term:proplist(). build_sms_base({CIDNum, CIDName}, OffnetReq, Q) -> AccountId = kapi_offnet_resource:account_id(OffnetReq), AccountRealm = kapi_offnet_resource:account_realm(OffnetReq), @@ -385,7 +385,7 @@ build_sms_base({CIDNum, CIDName}, OffnetReq, Q) -> | kz_api:default_headers(Q, ?APP_NAME, ?APP_VERSION) ]). --spec maybe_endpoints_format_from(kz_json:objects(), api_binary(), kapi_offnet_resource:req()) -> +-spec maybe_endpoints_format_from(kz_json:objects(), kz_term:api_binary(), kapi_offnet_resource:req()) -> kz_json:objects(). maybe_endpoints_format_from([], _ , _) -> []; maybe_endpoints_format_from(Endpoints, 'undefined', _) -> Endpoints; @@ -395,7 +395,7 @@ maybe_endpoints_format_from(Endpoints, CIDNum, OffnetReq) -> || Endpoint <- Endpoints ]. --spec maybe_endpoint_format_from(kz_json:object(), ne_binary(), api_binary()) -> +-spec maybe_endpoint_format_from(kz_json:object(), kz_term:ne_binary(), kz_term:api_binary()) -> kz_json:object(). maybe_endpoint_format_from(Endpoint, CIDNum, DefaultRealm) -> CCVs = kz_json:get_value(<<"Custom-Channel-Vars">>, Endpoint, kz_json:new()), @@ -412,7 +412,7 @@ maybe_endpoint_format_from(Endpoint, CIDNum, DefaultRealm) -> ) end. --spec endpoint_format_from(kz_json:object(), ne_binary(), api_binary()) -> kz_json:object(). +-spec endpoint_format_from(kz_json:object(), kz_term:ne_binary(), kz_term:api_binary()) -> kz_json:object(). endpoint_format_from(Endpoint, CIDNum, DefaultRealm) -> CCVs = kz_json:get_value(<<"Custom-Channel-Vars">>, Endpoint, kz_json:new()), Realm = kz_json:get_value(<<"From-URI-Realm">>, CCVs, DefaultRealm), @@ -444,7 +444,7 @@ endpoint_format_from(Endpoint, CIDNum, DefaultRealm) -> end. -spec bridge_caller_id(kz_json:objects(), kapi_offnet_resource:req()) -> - {api_binary(), api_binary()}. + {kz_term:api_binary(), kz_term:api_binary()}. bridge_caller_id(Endpoints, JObj) -> case contains_emergency_endpoints(Endpoints) of 'true' -> bridge_emergency_caller_id(JObj); @@ -452,7 +452,7 @@ bridge_caller_id(Endpoints, JObj) -> end. -spec bridge_emergency_caller_id(kapi_offnet_resource:req()) -> - {api_binary(), api_binary()}. + {kz_term:api_binary(), kz_term:api_binary()}. bridge_emergency_caller_id(OffnetReq) -> lager:debug("outbound call is using an emergency route, attempting to set CID accordingly"), {maybe_emergency_cid_number(OffnetReq) @@ -460,14 +460,14 @@ bridge_emergency_caller_id(OffnetReq) -> }. -spec bridge_caller_id(kapi_offnet_resource:req()) -> - {ne_binary(), ne_binary()}. + {kz_term:ne_binary(), kz_term:ne_binary()}. bridge_caller_id(OffnetReq) -> {stepswitch_bridge:bridge_outbound_cid_number(OffnetReq) ,stepswitch_bridge:bridge_outbound_cid_name(OffnetReq) }. --spec bridge_from_uri(api_binary(), kapi_offnet_resource:req()) -> - api_binary(). +-spec bridge_from_uri(kz_term:api_binary(), kapi_offnet_resource:req()) -> + kz_term:api_binary(). bridge_from_uri(CIDNum, OffnetReq) -> Realm = stepswitch_util:default_realm(OffnetReq), case (kapps_config:get_is_true(?APP_NAME, <<"format_from_uri">>, 'false') @@ -485,7 +485,7 @@ bridge_from_uri(CIDNum, OffnetReq) -> end. -spec maybe_emergency_cid_number(kapi_offnet_resource:req()) -> - api_binary(). + kz_term:api_binary(). maybe_emergency_cid_number(OffnetReq) -> %% NOTE: if this request had a hunt-account-id then we %% are assuming it was for a local resource (at the @@ -496,7 +496,7 @@ maybe_emergency_cid_number(OffnetReq) -> stepswitch_bridge:bridge_emergency_cid_number(OffnetReq) end. --spec emergency_cid_number(kapi_offnet_resource:req()) -> ne_binary(). +-spec emergency_cid_number(kapi_offnet_resource:req()) -> kz_term:ne_binary(). emergency_cid_number(OffnetReq) -> AccountId = kapi_offnet_resource:account_id(OffnetReq), Candidates = [kapi_offnet_resource:emergency_caller_id_number(OffnetReq) @@ -507,7 +507,7 @@ emergency_cid_number(OffnetReq) -> EnabledNumbers = knm_numbers:emergency_enabled(AccountId), emergency_cid_number(Requested, Candidates, EnabledNumbers). --spec emergency_cid_number(ne_binary(), api_binaries(), ne_binaries()) -> ne_binary(). +-spec emergency_cid_number(kz_term:ne_binary(), kz_term:api_binaries(), kz_term:ne_binaries()) -> kz_term:ne_binary(). %% if there are no emergency enabled numbers then either use the global system default %% or the requested (if there isnt one) emergency_cid_number(Requested, _, []) -> @@ -536,7 +536,7 @@ contains_emergency_endpoints([Endpoint|Endpoints]) -> kz_json:is_true([<<"Custom-Channel-Vars">>, <<"Emergency-Resource">>], Endpoint) orelse contains_emergency_endpoints(Endpoints). --spec sms_timeout(kapi_offnet_resource:req()) -> kz_proplist(). +-spec sms_timeout(kapi_offnet_resource:req()) -> kz_term:proplist(). sms_timeout(OffnetReq) -> lager:debug("attempt to connect to resources timed out"), [{<<"Call-ID">>, kapi_offnet_resource:call_id(OffnetReq)} @@ -548,7 +548,7 @@ sms_timeout(OffnetReq) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]. --spec sms_error(kz_json:object(), kapi_offnet_resource:req()) -> kz_proplist(). +-spec sms_error(kz_json:object(), kapi_offnet_resource:req()) -> kz_term:proplist(). sms_error(JObj, OffnetReq) -> lager:debug("error during outbound request: ~s", [kz_term:to_binary(kz_json:encode(JObj))]), [{<<"Call-ID">>, kapi_offnet_resource:call_id(OffnetReq)} @@ -560,7 +560,7 @@ sms_error(JObj, OffnetReq) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]. --spec sms_success(kz_json:object(), kapi_offnet_resource:req()) -> kz_proplist(). +-spec sms_success(kz_json:object(), kapi_offnet_resource:req()) -> kz_term:proplist(). sms_success(JObj, OffnetReq) -> lager:debug("outbound request successfully completed"), [{<<"Call-ID">>, kapi_offnet_resource:call_id(OffnetReq)} @@ -571,7 +571,7 @@ sms_success(JObj, OffnetReq) -> | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]. --spec sms_failure(kz_json:object(), kapi_offnet_resource:req()) -> kz_proplist(). +-spec sms_failure(kz_json:object(), kapi_offnet_resource:req()) -> kz_term:proplist(). sms_failure(JObj, OffnetReq) -> lager:debug("resources for outbound request failed: ~s" ,[kz_json:get_value(<<"Disposition">>, JObj)] diff --git a/applications/stepswitch/src/stepswitch_sup.erl b/applications/stepswitch/src/stepswitch_sup.erl index d1988d644c4..db0ba243725 100644 --- a/applications/stepswitch/src/stepswitch_sup.erl +++ b/applications/stepswitch/src/stepswitch_sup.erl @@ -38,7 +38,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -55,7 +55,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/stepswitch/src/stepswitch_util.erl b/applications/stepswitch/src/stepswitch_util.erl index 66cccc8ceb4..de98566aabc 100644 --- a/applications/stepswitch/src/stepswitch_util.erl +++ b/applications/stepswitch/src/stepswitch_util.erl @@ -26,7 +26,7 @@ %% %% @end %%-------------------------------------------------------------------- --spec get_realm(api_binary() | kz_json:object()) -> api_binary(). +-spec get_realm(kz_term:api_binary() | kz_json:object()) -> kz_term:api_binary(). get_realm('undefined') -> 'undefined'; get_realm(From) when is_binary(From) -> case binary:split(From, <<"@">>) of @@ -50,7 +50,7 @@ get_realm(JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec get_inbound_destination(kz_json:object()) -> ne_binary(). +-spec get_inbound_destination(kz_json:object()) -> kz_term:ne_binary(). get_inbound_destination(JObj) -> {Number, _} = kapps_util:get_destination(JObj, ?APP_NAME, <<"inbound_user_field">>), case kapps_config:get_is_true(?SS_CONFIG_CAT, <<"assume_inbound_e164">>, 'false') of @@ -58,7 +58,7 @@ get_inbound_destination(JObj) -> 'false' -> knm_converters:normalize(Number) end. --spec assume_e164(ne_binary()) -> ne_binary(). +-spec assume_e164(kz_term:ne_binary()) -> kz_term:ne_binary(). assume_e164(<<$+, _/binary>> = Number) -> Number; assume_e164(Number) -> <<$+, Number/binary>>. @@ -68,7 +68,7 @@ assume_e164(Number) -> <<$+, Number/binary>>. %% %% @end %%-------------------------------------------------------------------- --spec get_outbound_destination(kapi_offnet_resource:req()) -> ne_binary(). +-spec get_outbound_destination(kapi_offnet_resource:req()) -> kz_term:ne_binary(). get_outbound_destination(OffnetReq) -> Number = kapi_offnet_resource:to_did(OffnetReq), case kapi_offnet_resource:bypass_e164(OffnetReq) of @@ -84,7 +84,7 @@ get_outbound_destination(OffnetReq) -> %% callerid. %% @end %%-------------------------------------------------------------------- --spec correct_shortdial(ne_binary(), ne_binary() | kapi_offnet_resource:req()) -> api_binary(). +-spec correct_shortdial(kz_term:ne_binary(), kz_term:ne_binary() | kapi_offnet_resource:req()) -> kz_term:api_binary(). correct_shortdial(<<"+", Number/binary>>, CIDNum) -> correct_shortdial(Number, CIDNum); correct_shortdial(Number, <<"+", CIDNum/binary>>) -> @@ -131,10 +131,10 @@ maybe_remove_diversions(JObj) -> -spec get_diversions(kz_json:object()) -> 'undefined' | - ne_binaries(). --spec get_diversions(api_binary(), ne_binaries()) -> + kz_term:ne_binaries(). +-spec get_diversions(kz_term:api_binary(), kz_term:ne_binaries()) -> 'undefined' | - ne_binaries(). + kz_term:ne_binaries(). get_diversions(JObj) -> Inception = kz_json:get_value(<<"Inception">>, JObj), @@ -155,7 +155,7 @@ get_diversions(Inception, Diversions) -> ) ]. --spec find_diversion_count(ne_binaries()) -> non_neg_integer(). +-spec find_diversion_count(kz_term:ne_binaries()) -> non_neg_integer(). find_diversion_count(Diversions) -> lists:max([kzsip_diversion:counter( kzsip_diversion:from_binary(Diversion) @@ -163,20 +163,20 @@ find_diversion_count(Diversions) -> || Diversion <- Diversions ]). --spec format_endpoints(kz_json:objects(), ne_binary(), ne_binary(), kapi_offnet_resource:req()) -> kz_json:objects(). +-spec format_endpoints(kz_json:objects(), kz_term:ne_binary(), kz_term:ne_binary(), kapi_offnet_resource:req()) -> kz_json:objects(). format_endpoints(Endpoints, Name, Number, OffnetReq) -> EndpointFilter = build_filter_fun(Name, Number), format_endpoints(Endpoints, Name, Number, OffnetReq, EndpointFilter). --type filter_fun() :: fun(({ne_binary(), ne_binary()}) -> boolean()). --spec build_filter_fun(ne_binary(), ne_binary()) -> filter_fun(). +-type filter_fun() :: fun(({kz_term:ne_binary(), kz_term:ne_binary()}) -> boolean()). +-spec build_filter_fun(kz_term:ne_binary(), kz_term:ne_binary()) -> filter_fun(). build_filter_fun(Name, Number) -> fun({?KEY_OUTBOUND_CALLER_ID_NUMBER, N}) when N =:= Number -> 'false'; ({?KEY_OUTBOUND_CALLER_ID_NAME, N}) when N =:= Name -> 'false'; (_Else) -> 'true' end. --spec format_endpoints(kz_json:objects(), api_binary(), api_binary(), kapi_offnet_resource:req(), filter_fun()) -> +-spec format_endpoints(kz_json:objects(), kz_term:api_binary(), kz_term:api_binary(), kapi_offnet_resource:req(), filter_fun()) -> kz_json:objects(). format_endpoints(Endpoints, Name, Number, OffnetReq, FilterFun) -> SIPHeaders = get_sip_headers(OffnetReq), @@ -189,14 +189,14 @@ format_endpoints(Endpoints, Name, Number, OffnetReq, FilterFun) -> || Endpoint <- Endpoints ]. --spec default_realm(kapi_offnet_resource:req()) -> api_binary(). +-spec default_realm(kapi_offnet_resource:req()) -> kz_term:api_binary(). default_realm(OffnetReq) -> case kapi_offnet_resource:from_uri_realm(OffnetReq) of 'undefined' -> kapi_offnet_resource:account_realm(OffnetReq); Realm -> Realm end. --spec set_endpoint_caller_id(kz_json:object(), api_binary(), api_binary()) -> kz_json:object(). +-spec set_endpoint_caller_id(kz_json:object(), kz_term:api_binary(), kz_term:api_binary()) -> kz_json:object(). set_endpoint_caller_id(Endpoint, Name, Number) -> kz_json:insert_values(props:filter_undefined( [{?KEY_OUTBOUND_CALLER_ID_NUMBER, Number} @@ -206,14 +206,14 @@ set_endpoint_caller_id(Endpoint, Name, Number) -> ,Endpoint ). --spec format_endpoint(kz_json:object(), api_binary(), filter_fun(), kapi_offnet_resource:req(), kz_json:object(), ne_binary()) -> +-spec format_endpoint(kz_json:object(), kz_term:api_binary(), filter_fun(), kapi_offnet_resource:req(), kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). format_endpoint(Endpoint, Number, FilterFun, OffnetReq, SIPHeaders, AccountId) -> FormattedEndpoint = apply_formatters(Endpoint, SIPHeaders, AccountId), FilteredEndpoint = kz_json:filter(FilterFun, FormattedEndpoint), maybe_endpoint_format_from(FilteredEndpoint, Number, OffnetReq). --spec apply_formatters(kz_json:object(), kz_json:object(), ne_binary()) -> kz_json:object(). +-spec apply_formatters(kz_json:object(), kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). apply_formatters(Endpoint, SIPHeaders, AccountId) -> kz_formatters:apply(maybe_add_sip_headers(Endpoint, SIPHeaders) ,props:get_value(<<"Formatters">> @@ -223,7 +223,7 @@ apply_formatters(Endpoint, SIPHeaders, AccountId) -> ,'outbound' ). --spec endpoint_props(kz_json:object(), api_binary()) -> kz_proplist(). +-spec endpoint_props(kz_json:object(), kz_term:api_binary()) -> kz_term:proplist(). endpoint_props(Endpoint, AccountId) -> ResourceId = kz_json:get_value(?CCV(<<"Resource-ID">>), Endpoint), case kz_json:is_true(?CCV(<<"Global-Resource">>), Endpoint) of @@ -233,7 +233,7 @@ endpoint_props(Endpoint, AccountId) -> empty_list_on_undefined(stepswitch_resources:get_props(ResourceId, AccountId)) end. --spec empty_list_on_undefined(kz_proplist() | 'undefined') -> kz_proplist(). +-spec empty_list_on_undefined(kz_term:proplist() | 'undefined') -> kz_term:proplist(). empty_list_on_undefined('undefined') -> []; empty_list_on_undefined(L) -> L. @@ -246,7 +246,7 @@ maybe_add_sip_headers(Endpoint, SIPHeaders) -> MergedHeaders -> kz_json:set_value(<<"Custom-SIP-Headers">>, MergedHeaders, Endpoint) end. --spec maybe_endpoint_format_from(kz_json:object(), ne_binary(), kapi_offnet_resource:req()) -> +-spec maybe_endpoint_format_from(kz_json:object(), kz_term:ne_binary(), kapi_offnet_resource:req()) -> kz_json:object(). maybe_endpoint_format_from(Endpoint, Number, OffnetReq) -> CCVs = kz_json:get_value(<<"Custom-Channel-Vars">>, Endpoint, kz_json:new()), @@ -264,7 +264,7 @@ maybe_endpoint_format_from(Endpoint, Number, OffnetReq) -> ) end. --spec endpoint_format_from(kz_json:object(), ne_binary(), kapi_offnet_resource:req(), kz_json:object()) -> +-spec endpoint_format_from(kz_json:object(), kz_term:ne_binary(), kapi_offnet_resource:req(), kz_json:object()) -> kz_json:object(). endpoint_format_from(Endpoint, Number, OffnetReq, CCVs) -> FromNumber = kz_json:get_ne_value(?KEY_OUTBOUND_CALLER_ID_NUMBER, Endpoint, Number), @@ -297,7 +297,7 @@ endpoint_format_from(Endpoint, Number, OffnetReq, CCVs) -> ) end. --spec get_endpoint_format_from(kapi_offnet_resource:req(), kz_json:object()) -> api_binary(). +-spec get_endpoint_format_from(kapi_offnet_resource:req(), kz_json:object()) -> kz_term:api_binary(). get_endpoint_format_from(OffnetReq, CCVs) -> case kz_json:is_true(<<"From-Account-Realm">>, CCVs) of 'true' -> kapi_offnet_resource:account_realm(OffnetReq); @@ -312,9 +312,9 @@ route_by() -> Module -> Module end. --spec resources_to_endpoints(stepswitch_resources:resources(), ne_binary(), kapi_offnet_resource:req()) -> +-spec resources_to_endpoints(stepswitch_resources:resources(), kz_term:ne_binary(), kapi_offnet_resource:req()) -> kz_json:objects(). --spec resources_to_endpoints(stepswitch_resources:resources(), ne_binary(), kapi_offnet_resource:req(), kz_json:objects()) -> +-spec resources_to_endpoints(stepswitch_resources:resources(), kz_term:ne_binary(), kapi_offnet_resource:req(), kz_json:objects()) -> kz_json:objects(). resources_to_endpoints(Resources, Number, OffnetJObj) -> resources_to_endpoints(Resources, Number, OffnetJObj, []). @@ -325,7 +325,7 @@ resources_to_endpoints([Resource|Resources], Number, OffnetJObj, Endpoints) -> MoreEndpoints = maybe_resource_to_endpoints(Resource, Number, OffnetJObj, Endpoints), resources_to_endpoints(Resources, Number, OffnetJObj, MoreEndpoints). --spec maybe_resource_to_endpoints(stepswitch_resources:resource(), ne_binary(), kapi_offnet_resource:req(), kz_json:objects()) -> +-spec maybe_resource_to_endpoints(stepswitch_resources:resource(), kz_term:ne_binary(), kapi_offnet_resource:req(), kz_json:objects()) -> kz_json:objects(). maybe_resource_to_endpoints(Resource ,Number @@ -355,12 +355,12 @@ maybe_resource_to_endpoints(Resource ], stepswitch_resources:maybe_add_proxies(EndpointList, Proxies, Endpoints). --spec update_ccvs(kz_json:object(), kz_proplist()) -> kz_json:object(). +-spec update_ccvs(kz_json:object(), kz_term:proplist()) -> kz_json:object(). update_ccvs(Endpoint, Updates) -> CCVs = kz_json:get_value(<<"Custom-Channel-Vars">>, Endpoint, kz_json:new()), kz_json:set_value(<<"Custom-Channel-Vars">>, kz_json:set_values(Updates, CCVs), Endpoint). -%%-spec maybe_update_number(stepswitch_resources:resource(), ne_binary()) -> stepswitch_resources:resource(). +%%-spec maybe_update_number(stepswitch_resources:resource(), kz_term:ne_binary()) -> stepswitch_resources:resource(). %%maybe_update_number(Resource, Number) -> %% SelectorsResult = stepswitch_resources:get_resrc_selector_marks(Resource), %% props:get_value('regex_number_match', SelectorsResult, Number). diff --git a/applications/sysconf/src/sysconf_acls.erl b/applications/sysconf/src/sysconf_acls.erl index ac78f0e3748..4416723daed 100644 --- a/applications/sysconf/src/sysconf_acls.erl +++ b/applications/sysconf/src/sysconf_acls.erl @@ -18,7 +18,7 @@ -type acls() :: kz_json:object(). --spec build(ne_binary()) -> acls(). +-spec build(kz_term:ne_binary()) -> acls(). build(Node) -> Routines = [fun offnet_resources/1 ,fun local_resources/1 @@ -27,9 +27,9 @@ build(Node) -> PidRefs = [kz_util:spawn_monitor(fun erlang:apply/2, [F, [self()]]) || F <- Routines], collect(system_config_acls(Node), PidRefs). --spec collect(kz_json:object(), pid_refs()) -> +-spec collect(kz_json:object(), kz_term:pid_refs()) -> kz_json:object(). --spec collect(kz_json:object(), pid_refs(), kz_timeout()) -> +-spec collect(kz_json:object(), kz_term:pid_refs(), timeout()) -> kz_json:object(). collect(ACLs, PidRefs) -> collect(ACLs, PidRefs, request_timeout()). @@ -61,7 +61,7 @@ collect(ACLs, PidRefs, Timeout) -> ACLs end. --spec system_config_acls(ne_binary()) -> acls(). +-spec system_config_acls(kz_term:ne_binary()) -> acls(). system_config_acls(Node) -> kapps_config:get_current(<<"ecallmgr">>, <<"acls">>, kz_json:new(), Node). @@ -92,7 +92,7 @@ needs_resolving(JObj, {IPs, ToResolve}) -> 'false' -> {IPs, [{IP, JObj} | ToResolve]} end. --spec wait_for_pid_refs(pid_refs()) -> 'ok'. +-spec wait_for_pid_refs(kz_term:pid_refs()) -> 'ok'. wait_for_pid_refs(PidRefs) -> wait_for_pid_refs(PidRefs, ?REQUEST_TIMEOUT). wait_for_pid_refs([], _Timeout) -> 'ok'; @@ -111,7 +111,7 @@ wait_for_pid_refs(PidRefs, Timeout) -> end. %% @private --spec resolve_hostname(pid(), ne_binary(), kz_json:object(), fun()) -> 'ok'. +-spec resolve_hostname(pid(), kz_term:ne_binary(), kz_json:object(), fun()) -> 'ok'. resolve_hostname(Collector, ResolveMe, JObj, ACLBuilderFun) -> lager:debug("attempting to resolve '~s'", [ResolveMe]), StrippedHost = hd(binary:split(ResolveMe, <<";">>)), @@ -128,7 +128,7 @@ resolve_hostname(Collector, ResolveMe, JObj, ACLBuilderFun) -> lager:debug("resolved '~s' (~s) for ~p: '~s'", [StrippedHost, ResolveMe, Collector, kz_binary:join(IPs, <<"','">>)]) end. --spec maybe_capture_ip(pid(), ne_binary(), kz_json:object(), fun()) -> 'ok'. +-spec maybe_capture_ip(pid(), kz_term:ne_binary(), kz_json:object(), fun()) -> 'ok'. maybe_capture_ip(Collector, CaptureMe, JObj, ACLBuilderFun) -> case re:run(CaptureMe, ?IP_REGEX, [{'capture', 'all', 'binary'}]) of {'match', [_All, IP]} -> @@ -138,7 +138,7 @@ maybe_capture_ip(Collector, CaptureMe, JObj, ACLBuilderFun) -> lager:debug("failed to find IP at start of '~s'", [CaptureMe]) end. --spec handle_sip_auth_result(pid(), kz_json:object(), ne_binaries()) -> 'ok'. +-spec handle_sip_auth_result(pid(), kz_json:object(), kz_term:ne_binaries()) -> 'ok'. handle_sip_auth_result(Collector, JObj, IPs) -> AccountId = kz_json:get_value([<<"value">>, <<"account_id">>], JObj), AuthorizingId = kz_doc:id(JObj), @@ -177,12 +177,12 @@ handle_resource_result(Collector, JObj) -> ServerPidRefs = resource_server_ips(Collector, Doc), wait_for_pid_refs(InboundPidRefs ++ ServerPidRefs). --spec handle_resource_result(pid(), kz_json:object(), ne_binaries()) -> 'ok'. +-spec handle_resource_result(pid(), kz_json:object(), kz_term:ne_binaries()) -> 'ok'. handle_resource_result(Collector, JObj, IPs) -> AuthorizingId = kz_doc:id(JObj), add_trusted_objects(Collector, 'undefined', AuthorizingId, <<"resource">>, IPs). --spec resource_inbound_ips(pid(), kz_json:object()) -> pid_refs(). +-spec resource_inbound_ips(pid(), kz_json:object()) -> kz_term:pid_refs(). resource_inbound_ips(Collector, JObj) -> [kz_util:spawn_monitor(fun resolve_hostname/4, [Collector ,IP @@ -192,7 +192,7 @@ resource_inbound_ips(Collector, JObj) -> || IP <- kz_json:get_value(<<"inbound_ips">>, JObj, []) ]. --spec resource_server_ips(pid(), kz_json:object()) -> pid_refs(). +-spec resource_server_ips(pid(), kz_json:object()) -> kz_term:pid_refs(). resource_server_ips(Collector, JObj) -> [kz_util:spawn_monitor(fun resolve_hostname/4, [Collector ,kz_json:get_value(<<"server">>, Gateway) @@ -203,7 +203,7 @@ resource_server_ips(Collector, JObj) -> kz_json:is_true(<<"enabled">>, Gateway, 'false') ]. --spec add_trusted_objects(pid(), api_binary(), ne_binary(), ne_binary(), ne_binaries()) -> 'ok'. +-spec add_trusted_objects(pid(), kz_term:api_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binaries()) -> 'ok'. add_trusted_objects(_Collector, _AccountId, _AuthorizingId, _AuthorizingType, []) -> 'ok'; add_trusted_objects(Collector, AccountId, AuthorizingId, AuthorizingType, [IP|IPs]) -> Props = kz_json:from_list( diff --git a/applications/sysconf/src/sysconf_app.erl b/applications/sysconf/src/sysconf_app.erl index bf63f02c925..89c2021c71b 100644 --- a/applications/sysconf/src/sysconf_app.erl +++ b/applications/sysconf/src/sysconf_app.erl @@ -23,7 +23,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_StartType, _StartArgs) -> _ = declare_exchanges(), sysconf_sup:start_link(). diff --git a/applications/sysconf/src/sysconf_flush.erl b/applications/sysconf/src/sysconf_flush.erl index 61fac9d9827..cf71efeb54a 100644 --- a/applications/sysconf/src/sysconf_flush.erl +++ b/applications/sysconf/src/sysconf_flush.erl @@ -14,7 +14,7 @@ -spec init() -> 'ok'. init() -> 'ok'. --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(ApiJObj, _Props) -> 'true' = kapi_sysconf:flush_req_v(ApiJObj), kz_util:put_callid(ApiJObj), diff --git a/applications/sysconf/src/sysconf_gateways.erl b/applications/sysconf/src/sysconf_gateways.erl index 5c0ee8d3ef1..1ad37ddd04b 100644 --- a/applications/sysconf/src/sysconf_gateways.erl +++ b/applications/sysconf/src/sysconf_gateways.erl @@ -11,7 +11,7 @@ -include("sysconf.hrl"). --spec build(ne_binary()) -> kz_json:object(). +-spec build(kz_term:ne_binary()) -> kz_json:object(). build(_Node) -> get_gateways(). diff --git a/applications/sysconf/src/sysconf_get.erl b/applications/sysconf/src/sysconf_get.erl index d675535704e..ffe466ca30e 100644 --- a/applications/sysconf/src/sysconf_get.erl +++ b/applications/sysconf/src/sysconf_get.erl @@ -17,7 +17,7 @@ -spec init() -> 'ok'. init() -> 'ok'. --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(ApiJObj, _Props) -> 'true' = kapi_sysconf:get_req_v(ApiJObj), kz_util:put_callid(ApiJObj), @@ -43,14 +43,14 @@ handle_req(ApiJObj, _Props) -> ], kapi_sysconf:publish_get_resp(RespQ, Resp). --spec format_key(ne_binary() | ne_binaries()) -> ne_binary(). +-spec format_key(kz_term:ne_binary() | kz_term:ne_binaries()) -> kz_term:ne_binary(). format_key(Key) when is_binary(Key) -> Key; format_key(Keys) when is_list(Keys) -> kz_binary:join(Keys, <<".">>). --spec get_value(ne_binary(), ne_binary() | ne_binaries(), any(), ne_binary()) -> any(). +-spec get_value(kz_term:ne_binary(), kz_term:ne_binary() | kz_term:ne_binaries(), any(), kz_term:ne_binary()) -> any(). get_value(_, <<"acls">>, _, Node) -> sysconf_acls:build(Node); get_value(_, <<"gateways">>, _, Node) -> diff --git a/applications/sysconf/src/sysconf_listener.erl b/applications/sysconf/src/sysconf_listener.erl index 6715f962d2b..92da452edb2 100644 --- a/applications/sysconf/src/sysconf_listener.erl +++ b/applications/sysconf/src/sysconf_listener.erl @@ -44,7 +44,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'responders', ?RESPONDERS} ,{'bindings', ?BINDINGS} @@ -88,7 +88,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Msg, _From, State) -> {'noreply', State}. @@ -102,7 +102,7 @@ handle_call(_Msg, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _QueueNAme}}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'is_consuming', _IsConsuming}}, State) -> @@ -121,7 +121,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'document_changes', _, _}, State) -> kapps_config:flush(), lager:info("system configuration was updated, flushing kapps config cache"), @@ -142,7 +142,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Props} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/sysconf/src/sysconf_set.erl b/applications/sysconf/src/sysconf_set.erl index 82105907e98..4a56238b8a8 100644 --- a/applications/sysconf/src/sysconf_set.erl +++ b/applications/sysconf/src/sysconf_set.erl @@ -18,7 +18,7 @@ -spec init() -> 'ok'. init() -> 'ok'. --spec handle_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_req(ApiJObj, _Props) -> 'true' = kapi_sysconf:set_req_v(ApiJObj), kz_util:put_callid(ApiJObj), diff --git a/applications/sysconf/src/sysconf_sup.erl b/applications/sysconf/src/sysconf_sup.erl index 8305bb62187..11090e4e4a5 100644 --- a/applications/sysconf/src/sysconf_sup.erl +++ b/applications/sysconf/src/sysconf_sup.erl @@ -30,7 +30,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -47,7 +47,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/tasks/src/knm_number_crawler.erl b/applications/tasks/src/knm_number_crawler.erl index e69f459c8ab..0ea4dcf2e83 100644 --- a/applications/tasks/src/knm_number_crawler.erl +++ b/applications/tasks/src/knm_number_crawler.erl @@ -55,7 +55,7 @@ %% Starts the server %% @end %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_server:start_link(?SERVER, [], []). @@ -93,7 +93,7 @@ init([]) -> %% Handling call messages %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -102,7 +102,7 @@ handle_call(_Request, _From, State) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('stop', State) -> lager:debug("crawler has been stopped"), {'stop', 'normal', State}; @@ -116,7 +116,7 @@ handle_cast(_Msg, State) -> %% Handling all non call/cast messages %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'timeout', Ref, _Msg}, #state{cleanup_ref=Ref}=State) -> _ = kz_util:spawn(fun crawl_numbers/0), {'noreply', State#state{cleanup_ref=cleanup_timer()}}; @@ -155,7 +155,7 @@ code_change(_OldVsn, State, _Extra) -> cleanup_timer() -> erlang:start_timer(?TIME_BETWEEN_CRAWLS, self(), 'ok'). --spec crawl_number_db(ne_binary()) -> ok. +-spec crawl_number_db(kz_term:ne_binary()) -> ok. crawl_number_db(Db) -> case kz_datamgr:all_docs(Db, [include_docs]) of {error, _E} -> diff --git a/applications/tasks/src/knm_port_request_crawler.erl b/applications/tasks/src/knm_port_request_crawler.erl index f79f4a13fa6..43f5975a7fb 100644 --- a/applications/tasks/src/knm_port_request_crawler.erl +++ b/applications/tasks/src/knm_port_request_crawler.erl @@ -41,7 +41,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_server:start_link(?MODULE, [], []). @@ -88,7 +88,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -102,7 +102,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('stop', State) -> lager:debug("crawler has been stopped"), {'stop', 'normal', State}; @@ -120,7 +120,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'timeout', Ref, _Msg}, #state{cleanup_ref=Ref}=State) -> _ = kz_util:spawn(fun crawl_port_requests/0), {'noreply', State#state{cleanup_ref=cleanup_timer()}, 'hibernate'}; diff --git a/applications/tasks/src/kz_account_crawler.erl b/applications/tasks/src/kz_account_crawler.erl index dbda452c8cf..bc305901779 100644 --- a/applications/tasks/src/kz_account_crawler.erl +++ b/applications/tasks/src/kz_account_crawler.erl @@ -25,7 +25,7 @@ -define(SERVER, ?MODULE). -record(state, {cleanup_ref = cleanup_cycle_timer() :: reference() - ,account_ids = [] :: ne_binaries() + ,account_ids = [] :: kz_term:ne_binaries() }). -type state() :: #state{}. @@ -44,7 +44,7 @@ %% Starts the server %% @end %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_server:start_link(?SERVER, [], []). @@ -52,7 +52,7 @@ start_link() -> stop() -> gen_server:cast(?SERVER, stop). --spec check(ne_binary()) -> 'ok'. +-spec check(kz_term:ne_binary()) -> 'ok'. check(Account) when is_binary(Account) -> AccountId = kz_util:format_account_id(Account), @@ -86,7 +86,7 @@ init([]) -> %% Handling call messages %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -96,7 +96,7 @@ handle_call(_Request, _From, State) -> %% Handling cast messages %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(stop, State) -> lager:debug("crawler has been stopped"), {stop, normal, State}; @@ -110,7 +110,7 @@ handle_cast(_Msg, State) -> %% Handling all non call/cast messages %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({timeout, Ref, _Msg}, #state{cleanup_ref = Ref ,account_ids = [] }=State) -> @@ -186,7 +186,7 @@ cleanup_timer() -> cleanup_cycle_timer() -> erlang:start_timer(?TIME_BETWEEN_WHOLE_CRAWLS, self(), 'ok'). --spec crawl_account(ne_binary()) -> ok. +-spec crawl_account(kz_term:ne_binary()) -> ok. crawl_account(AccountId) -> lager:debug("crawling account ~s", [AccountId]), %% do not open the account def in the account db or we will @@ -194,7 +194,7 @@ crawl_account(AccountId) -> OpenResult = kz_datamgr:open_doc(?KZ_ACCOUNTS_DB, AccountId), check_then_process_account(AccountId, OpenResult). --spec check_then_process_account(ne_binary(), {'ok', kz_account:doc()} | {'error',any()}) -> 'ok'. +-spec check_then_process_account(kz_term:ne_binary(), {'ok', kz_account:doc()} | {'error',any()}) -> 'ok'. check_then_process_account(AccountId, {'ok', AccountJObj}) -> case kz_doc:is_soft_deleted(AccountJObj) orelse not kz_account:is_enabled(AccountJObj) of @@ -206,7 +206,7 @@ check_then_process_account(AccountId, {'ok', AccountJObj}) -> check_then_process_account(AccountId, {'error', _R}) -> lager:warning("unable to open account definition for ~s: ~p", [AccountId, _R]). --spec process_account(ne_binary(), kz_account:doc()) -> 'ok'. +-spec process_account(kz_term:ne_binary(), kz_account:doc()) -> 'ok'. process_account(AccountId, AccountJObj) -> lager:debug("account crawler processing account ~s", [AccountId]), _ = tasks_bindings:pmap(<<"tasks.account_crawler">>, [AccountId, AccountJObj]), diff --git a/applications/tasks/src/kz_notify_resend.erl b/applications/tasks/src/kz_notify_resend.erl index b50ebb59fec..15895ac6b91 100644 --- a/applications/tasks/src/kz_notify_resend.erl +++ b/applications/tasks/src/kz_notify_resend.erl @@ -93,7 +93,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> case gen_server:start_link(?SERVER, ?MODULE, [], []) of {'error', {'already_started', Pid}} @@ -118,7 +118,7 @@ start_link() -> %% {stop, Reason} %% @end %%-------------------------------------------------------------------- --spec init([]) -> {'ok', state(), kz_timeout()}. +-spec init([]) -> {'ok', state(), timeout()}. init([]) -> kz_util:put_callid(?NAME), lager:debug("~s has been started", [?NAME]), @@ -135,7 +135,7 @@ running() -> _ -> gen_server:call(?SERVER, 'running') end. --spec send_single(ne_binary()) -> {'ok' | 'failed', kz_json:object()} | {'error', any()}. +-spec send_single(kz_term:ne_binary()) -> {'ok' | 'failed', kz_json:object()} | {'error', any()}. send_single(Id) -> case kz_datamgr:open_doc(?KZ_PENDING_NOTIFY_DB, Id) of {'ok', JObj} -> @@ -163,7 +163,7 @@ next() -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call('running', _From, #state{running=Running}=State) -> {'reply', Running, State}; handle_call(_Request, _From, State) -> @@ -179,7 +179,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('next_cycle', State) -> {'noreply', State#state{running=[]}, ?TIME_BETWEEN_CYCLE}; handle_cast(stop, State) -> @@ -199,7 +199,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info('timeout', State) -> ViewOptions = [{'startkey', 0} ,{'endkey', kz_time:now_s()} @@ -291,7 +291,7 @@ send_notification(JObj, #{ok := OK}=Map) -> 'false' -> maybe_reschedule(NotifyType, JObj, Map) end. --spec call_collect(api_terms(), api_atom()) -> kz_amqp_worker:request_return(). +-spec call_collect(kz_term:api_terms(), kz_term:api_atom()) -> kz_amqp_worker:request_return(). call_collect(_API, undefined) -> 'ok'; call_collect(undefined, _) -> 'ok'; call_collect(API, PublishFun) -> @@ -346,7 +346,7 @@ handle_result({'error', _Reason}) -> 'false'; handle_result({'returned', _, Resp}) -> is_completed(Resp); handle_result({'timeout', Resp}) -> is_completed(Resp). --spec maybe_reschedule(ne_binary(), kz_json:object(), map()) -> map(). +-spec maybe_reschedule(kz_term:ne_binary(), kz_json:object(), map()) -> map(). maybe_reschedule(NotifyType, JObj, #{ko := KO}=Map) -> J = apply_reschedule_logic(NotifyType, JObj), Attempts = kz_json:get_integer_value(<<"attempts">>, J, 0), @@ -361,7 +361,7 @@ maybe_reschedule(NotifyType, JObj, #{ko := KO}=Map) -> Map#{ko := [kz_json:set_value(<<"max_retried">>, 'true', J)|KO]} %% attempts ++ 1 end. --spec apply_reschedule_logic(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec apply_reschedule_logic(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). apply_reschedule_logic(NotifyType, JObj) -> Attempts = kz_json:get_integer_value(<<"attempts">>, JObj, 0), @@ -381,7 +381,7 @@ apply_reschedule_logic(NotifyType, JObj) -> JObj2 end. --spec apply_reschedule_rules(ne_binary(),{kz_json:objects(), kz_json:path()}, kz_json:object()) -> +-spec apply_reschedule_rules(kz_term:ne_binary(),{kz_json:objects(), kz_json:path()}, kz_json:object()) -> {'ok', kz_json:object()} | {'no_rules', kz_json:object()}. apply_reschedule_rules(_NotifyType, {[], _}, JObj) -> {'no_rules', JObj}; @@ -418,7 +418,7 @@ set_default_update_fields(JObj, Attempts) -> fudge_retry_after(0) -> ?DEFAULT_RETRY_PERIOD; fudge_retry_after(Attempts) -> Attempts * ?DEFAULT_RETRY_PERIOD. --spec map_to_publish_fun(api_binary()) -> api_atom(). +-spec map_to_publish_fun(kz_term:api_binary()) -> kz_term:api_atom(). map_to_publish_fun(undefined) -> undefined; map_to_publish_fun(Type) -> kz_term:to_atom(<<"publish_", Type/binary>>, 'true'). diff --git a/applications/tasks/src/kz_service_sync.erl b/applications/tasks/src/kz_service_sync.erl index f176c23b053..790c9dea20f 100644 --- a/applications/tasks/src/kz_service_sync.erl +++ b/applications/tasks/src/kz_service_sync.erl @@ -57,7 +57,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER ,[{'bindings', ?BINDINGS} @@ -70,7 +70,7 @@ start_link() -> ,[] ). --spec maintenance_req(kapi_maintenance:req(), kz_proplist()) -> 'ok'. +-spec maintenance_req(kapi_maintenance:req(), kz_term:proplist()) -> 'ok'. maintenance_req(MaintJObj, _Props) -> 'true' = kapi_maintenance:req_v(MaintJObj), process_maintenance_req(MaintJObj, kapi_maintenance:req_action(MaintJObj)). @@ -164,7 +164,7 @@ start_sync_service_timer() -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -178,7 +178,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> {'noreply', State}. @@ -192,7 +192,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(?SCAN_MSG, State) -> _ = maybe_sync_service(), _ = maybe_clear_process_dictionary(), @@ -211,7 +211,7 @@ maybe_clear_dictionary_entry({{'phone_number_doc', _AccountId}=Key, _Doc}) -> erase(Key); maybe_clear_dictionary_entry(_) -> 'ok'. --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. @@ -250,7 +250,7 @@ code_change(_OldVsn, State, _Extra) -> ,kapps_config:get_non_neg_integer(?CONFIG_CAT, <<"sync_buffer_period">>, 600) ). --spec maybe_sync_service() -> kz_std_return(). +-spec maybe_sync_service() -> kz_term:std_return(). maybe_sync_service() -> ViewOptions = [{'limit', 1} ,'include_docs' @@ -262,7 +262,7 @@ maybe_sync_service() -> {'ok', _} -> {'error', 'no_dirty_services'} end. --spec bump_modified(kz_json:object()) -> kz_std_return(). +-spec bump_modified(kz_json:object()) -> kz_term:std_return(). bump_modified(JObj) -> AccountId = kz_doc:account_id(JObj), Services = kz_services:reconcile_only(AccountId), @@ -287,14 +287,14 @@ bump_modified(JObj) -> maybe_follow_sync_billing_id(AccountId, ServicesJObj) end. --spec maybe_follow_sync_billing_id(ne_binary(), kzd_services:doc()) -> kz_std_return(). +-spec maybe_follow_sync_billing_id(kz_term:ne_binary(), kzd_services:doc()) -> kz_term:std_return(). maybe_follow_sync_billing_id(AccountId, ServicesJObj) -> case kz_services:get_billing_id(AccountId, ServicesJObj) of AccountId -> kz_services:sync(AccountId, ServicesJObj); BillingId -> follow_sync_billing_id(BillingId, AccountId, ServicesJObj) end. --spec follow_sync_billing_id(ne_binary(), ne_binary(), kz_json:object()) -> kz_std_return(). +-spec follow_sync_billing_id(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> kz_term:std_return(). follow_sync_billing_id(BillingId, AccountId, ServicesJObj) -> %% NOTE: First try to make the parent (to be billed) as dirty %% if that is successful then mark the current service doc cleans @@ -309,12 +309,12 @@ follow_sync_billing_id(BillingId, AccountId, ServicesJObj) -> E end. --spec mark_clean(kzd_services:doc()) -> kz_std_return(). +-spec mark_clean(kzd_services:doc()) -> kz_term:std_return(). mark_clean(ServicesJObj) -> kz_datamgr:save_doc(?KZ_SERVICES_DB, kzd_services:set_is_dirty(ServicesJObj, 'false')). --spec maybe_update_billing_id(ne_binary(), ne_binary(), kz_json:object()) -> kz_std_return(). +-spec maybe_update_billing_id(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> kz_term:std_return(). maybe_update_billing_id(BillingId, AccountId, ServicesJObj) -> case kz_datamgr:open_doc(?KZ_ACCOUNTS_DB, BillingId) of {'error', _} -> diff --git a/applications/tasks/src/kz_tasks_help.erl b/applications/tasks/src/kz_tasks_help.erl index 31c1c27557b..6d8ae36de77 100644 --- a/applications/tasks/src/kz_tasks_help.erl +++ b/applications/tasks/src/kz_tasks_help.erl @@ -35,8 +35,8 @@ help() -> %% @doc %% @end %%-------------------------------------------------------------------- --spec help(ne_binary()) -> {'ok', kz_json:object()} | - kz_tasks:help_error(). +-spec help(kz_term:ne_binary()) -> {'ok', kz_json:object()} | + kz_tasks:help_error(). help(Category=?NE_BINARY) -> HelpJObj = tasks_bindings:fold(<<"tasks.help">>, [kz_json:new(), Category]), JObj = parse_apis(HelpJObj), @@ -50,8 +50,8 @@ help(Category=?NE_BINARY) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec help(ne_binary(), ne_binary()) -> {'ok', kz_json:object()} | - kz_tasks:help_error(). +-spec help(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | + kz_tasks:help_error(). help(Category=?NE_BINARY, Action=?NE_BINARY) -> HelpJObj = tasks_bindings:fold(<<"tasks.help">>, [kz_json:new(), Category, Action]), JObj = parse_apis(HelpJObj), @@ -65,7 +65,7 @@ help(Category=?NE_BINARY, Action=?NE_BINARY) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec handle_lookup_req(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_lookup_req(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_lookup_req(JObj, _Props) -> 'true' = kapi_tasks:lookup_req_v(JObj), Help = @@ -108,14 +108,14 @@ lookup_result(Category, Action, {ok, JObj}) -> parse_apis(HelpJObj) -> parse_apis(kz_json:to_proplist(HelpJObj), kz_json:new()). --spec parse_apis(kz_proplist(), kz_json:object()) -> kz_json:object(). +-spec parse_apis(kz_term:proplist(), kz_json:object()) -> kz_json:object(). parse_apis([], Acc) -> Acc; parse_apis([{Category, Actions}|HelpProps], Acc) -> lists:foreach(fun verify_unicity_map/1, kz_json:to_proplist(Actions)), NewAcc = kz_json:set_value(Category, Actions, Acc), parse_apis(HelpProps, NewAcc). --spec verify_unicity_map({ne_binary(), kz_json:object()}) -> 'ok'. +-spec verify_unicity_map({kz_term:ne_binary(), kz_json:object()}) -> 'ok'. verify_unicity_map({_Action, API}) -> Fields0 = kz_tasks:possible_fields(API), Fields = [kz_term:to_lower_binary(Field) || Field <- Fields0], diff --git a/applications/tasks/src/kz_tasks_scheduler.erl b/applications/tasks/src/kz_tasks_scheduler.erl index 26581e5f8f4..0f4dcaf9ea8 100644 --- a/applications/tasks/src/kz_tasks_scheduler.erl +++ b/applications/tasks/src/kz_tasks_scheduler.erl @@ -81,7 +81,7 @@ %% @doc %% @end %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> case gen_server:start_link(?SERVER, ?MODULE, [], []) of {'error', {'already_started', Pid}} -> @@ -317,7 +317,7 @@ init([]) -> kz_datamgr:revise_views_from_folder(?KZ_TASKS_DB, ?APP), {'ok', #state{}}. --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call({'start_task', TaskId}, _From, State) -> lager:debug("attempting to start ~s", [TaskId]), %% Running tasks are stored in server State then promptly removed. @@ -418,7 +418,7 @@ handle_call(_Request, _From, State) -> %% Handling cast messages %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'worker_error', TaskId}, State) -> lager:debug("worker error ~s", [TaskId]), Task = #{total_rows := TotalRows} = task_by_id(TaskId, State), @@ -457,7 +457,7 @@ handle_cast(_Msg, State) -> lager:debug("unhandled cast ~p", [_Msg]), {'noreply', State}. --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'EXIT', Pid, ?STOP_REASON}, State) -> lager:debug("worker ~p was stopped", [Pid]), {'noreply', State}; @@ -605,7 +605,7 @@ set_last_worker_update(TaskId, State = #state{last_worker_update = LWU}) -> State#state{last_worker_update = LWU#{TaskId => ProcessedSoFar}}. --spec task_api(ne_binary(), ne_binary()) -> kz_json:object(). +-spec task_api(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). task_api(Category, Action) -> {'ok', JObj} = kz_tasks_help:help(Category, Action), kz_json:set_values([{<<"category">>, Category} diff --git a/applications/tasks/src/kz_tasks_trigger.erl b/applications/tasks/src/kz_tasks_trigger.erl index 222a4efbc0d..48e883611da 100644 --- a/applications/tasks/src/kz_tasks_trigger.erl +++ b/applications/tasks/src/kz_tasks_trigger.erl @@ -40,7 +40,7 @@ %%% API %%%=================================================================== --spec status() -> kz_proplist(). +-spec status() -> kz_term:proplist(). status() -> gen_server:call(?SERVER, 'status'). @@ -49,7 +49,7 @@ status() -> %% @doc %% @end %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> case gen_server:start_link(?SERVER, ?MODULE, [], []) of {'error', {'already_started', Pid}} -> @@ -82,7 +82,7 @@ init([]) -> %% Handling call messages %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call('status', _From, #state{minute_ref = Minute ,hour_ref = Hour ,day_ref = Day @@ -105,7 +105,7 @@ handle_call(_Request, _From, State) -> %% Handling cast messages %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'cleanup_finished', Ref}, #state{browse_dbs_ref = Ref}=State) -> lager:debug("cleanup finished for ~p, starting timer", [Ref]), {'noreply', State#state{browse_dbs_ref = browse_dbs_timer()}, 'hibernate'}; @@ -120,7 +120,7 @@ handle_cast(_Msg, State) -> %% Handling all non call/cast messages %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'EXIT', _Pid, normal}, State) -> lager:debug("job ~p terminated normally", [_Pid]), {noreply, State}; @@ -195,7 +195,7 @@ browse_dbs_timer() -> erlang:start_timer(Expiry * ?MILLISECONDS_IN_SECOND, self(), ok). --spec spawn_jobs(reference(), ne_binary()) -> ok. +-spec spawn_jobs(reference(), kz_term:ne_binary()) -> ok. spawn_jobs(Ref, Binding) -> CallId = make_callid(Ref, Binding), _Pid = erlang:spawn_link(fun () -> @@ -204,7 +204,7 @@ spawn_jobs(Ref, Binding) -> end), lager:debug("binding ~s triggered ~p via ~p", [Binding, _Pid, Ref]). --spec make_callid(reference(), ne_binary()) -> ne_binary(). +-spec make_callid(reference(), kz_term:ne_binary()) -> kz_term:ne_binary(). make_callid(Ref, Binding) -> Key = lists:last(binary:split(Binding, <<$.>>, [global])), Id = ref_to_id(Ref), @@ -229,12 +229,12 @@ browse_dbs_for_triggers(Ref) -> lager:debug("pass completed for ~p", [Ref]), gen_server:cast(?SERVER, {'cleanup_finished', Ref}). --spec cleanup_pass(ne_binary()) -> boolean(). +-spec cleanup_pass(kz_term:ne_binary()) -> boolean(). cleanup_pass(Db) -> _ = tasks_bindings:map(db_to_trigger(Db), Db), erlang:garbage_collect(self()). --spec db_to_trigger(ne_binary()) -> ne_binary(). +-spec db_to_trigger(kz_term:ne_binary()) -> kz_term:ne_binary(). db_to_trigger(Db) -> Classifiers = [{fun kapps_util:is_account_db/1, ?TRIGGER_ACCOUNT} ,{fun kapps_util:is_account_mod/1, ?TRIGGER_ACCOUNT_MOD} @@ -249,7 +249,7 @@ db_to_trigger(Db, [{Classifier, Trigger} | Classifiers]) -> 'false' -> db_to_trigger(Db, Classifiers) end. --spec is_system_db(ne_binary()) -> boolean(). +-spec is_system_db(kz_term:ne_binary()) -> boolean(). is_system_db(Db) -> lists:member(Db, ?KZ_SYSTEM_DBS). diff --git a/applications/tasks/src/modules/kt_cleanup.erl b/applications/tasks/src/modules/kt_cleanup.erl index f3d1df5a424..dcb256a444c 100644 --- a/applications/tasks/src/modules/kt_cleanup.erl +++ b/applications/tasks/src/modules/kt_cleanup.erl @@ -33,7 +33,7 @@ init() -> %%% Triggerables --spec cleanup_soft_deletes(ne_binary()) -> ok. +-spec cleanup_soft_deletes(kz_term:ne_binary()) -> ok. cleanup_soft_deletes(?KZ_ACCOUNTS_DB) -> do_cleanup(?KZ_ACCOUNTS_DB); cleanup_soft_deletes(Account) -> @@ -50,12 +50,12 @@ cleanup_soft_deletes(Account) -> %%% Internal functions %%%=================================================================== --spec cleanup_account_soft_deletes(ne_binary()) -> 'ok'. +-spec cleanup_account_soft_deletes(kz_term:ne_binary()) -> 'ok'. cleanup_account_soft_deletes(Account) -> AccountDb = kz_util:format_account_id(Account, 'encoded'), do_cleanup(AccountDb). --spec do_cleanup(ne_binary()) -> 'ok'. +-spec do_cleanup(kz_term:ne_binary()) -> 'ok'. do_cleanup(Db) -> View = <<"maintenance/soft_deletes">>, ViewOptions = [{'limit', kz_datamgr:max_bulk_insert()}], diff --git a/applications/tasks/src/modules/kt_compactor.erl b/applications/tasks/src/modules/kt_compactor.erl index 4ffe8dcdf1a..284616ed707 100644 --- a/applications/tasks/src/modules/kt_compactor.erl +++ b/applications/tasks/src/modules/kt_compactor.erl @@ -78,7 +78,7 @@ set_node_defaults(NodeJObj) -> set_node_api_port(Node), set_node_admin_port(Node). --spec set_node_api_port(ne_binary()) -> 'ok'. +-spec set_node_api_port(kz_term:ne_binary()) -> 'ok'. set_node_api_port(Node) -> case kapps_config:get_integer(?SYSCONFIG_COUCH, <<"api_port">>, 'undefined', Node) of 'undefined' -> @@ -88,7 +88,7 @@ set_node_api_port(Node) -> lager:debug("api port for ~s already set: ~p", [Node, _Port]) end. --spec set_node_admin_port(ne_binary()) -> 'ok'. +-spec set_node_admin_port(kz_term:ne_binary()) -> 'ok'. set_node_admin_port(Node) -> case kapps_config:get_integer(?SYSCONFIG_COUCH, <<"admin_port">>, 'undefined', Node) of 'undefined' -> @@ -102,15 +102,15 @@ set_node_admin_port(Node) -> -spec help(kz_json:object()) -> kz_json:object(). help(JObj) -> help(JObj, <>). --spec help(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec help(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). help(JObj, <>=Category) -> lists:foldl(fun(Action, J) -> help(J, Category, Action) end, JObj, ?ACTIONS). --spec help(kz_json:object(), ne_binary(), ne_binary()) -> kz_json:object(). +-spec help(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). help(JObj, <>=Category, Action) -> kz_json:set_value([Category, Action], kz_json:from_list(action(Action)), JObj). --spec action(ne_binary()) -> kz_proplist(). +-spec action(kz_term:ne_binary()) -> kz_term:proplist(). action(<<"compact_all">>) -> [{<<"description">>, <<"Compact all databases">>} ,{<<"doc">>, <<"Walks all the databases and compacts them">>} @@ -131,7 +131,7 @@ action(<<"compact_db">>) -> ,{<<"optional">>, [<<"force">>]} ]. --spec output_header(ne_binary()) -> kz_tasks:output_header(). +-spec output_header(kz_term:ne_binary()) -> kz_tasks:output_header(). output_header(<<"compact_all">>) -> ?OUTPUT_HEADER; output_header(<<"compact_node">>) -> ?OUTPUT_HEADER; output_header(<<"compact_db">>) -> ?OUTPUT_HEADER. @@ -160,11 +160,11 @@ compact_db(_Extra, 'false', _Args) -> compact_db(_Extra, 'true', #{<<"database">> := Database}=Row) -> {do_compact_db(Database, heuristic_from_flag(maps:get(<<"force">>, Row))), 'true'}. --spec compact_db(ne_binary()) -> rows(). +-spec compact_db(kz_term:ne_binary()) -> rows(). compact_db(Database) -> do_compact_db(Database, ?HEUR_NONE). --spec heuristic_from_flag(api_ne_binary()) -> heuristic(). +-spec heuristic_from_flag(kz_term:api_ne_binary()) -> heuristic(). heuristic_from_flag(Force) -> case kz_term:is_true(Force) of 'false' -> ?HEUR_RATIO; @@ -183,11 +183,11 @@ do_compact_all() -> Shuffled = kz_term:shuffle_list(Dbs), lists:foldl(fun do_compact_db_fold/2, [], Shuffled). --spec compact_node(ne_binary()) -> rows(). +-spec compact_node(kz_term:ne_binary()) -> rows(). compact_node(Node) -> do_compact_node(Node, ?HEUR_NONE). --spec do_compact_node(ne_binary(), heuristic()) -> +-spec do_compact_node(kz_term:ne_binary(), heuristic()) -> rows(). do_compact_node(Node, Heuristic) -> #{server := {_App, #server{}=Conn}} = kzs_plan:plan(), @@ -200,7 +200,7 @@ do_compact_node(Node, Heuristic) -> do_compact_node(Node, Heuristic, APIConn, AdminConn) end. --spec do_compact_node(ne_binary(), heuristic(), kz_data:connection(), kz_data:connection()) -> +-spec do_compact_node(kz_term:ne_binary(), heuristic(), kz_data:connection(), kz_data:connection()) -> rows(). do_compact_node(Node, Heuristic, APIConn, AdminConn) -> case kz_datamgr:get_results(kazoo_couch:get_admin_dbs(APIConn) @@ -217,7 +217,7 @@ do_compact_node(Node, Heuristic, APIConn, AdminConn) -> do_compact_node(Node, Heuristic, APIConn, AdminConn, NodeDBs) end. --spec do_compact_node(ne_binary(), heuristic(), kz_data:connection(), kz_data:connection(), ne_binaries()) -> rows(). +-spec do_compact_node(kz_term:ne_binary(), heuristic(), kz_data:connection(), kz_data:connection(), kz_term:ne_binaries()) -> rows(). do_compact_node(Node, Heuristic, APIConn, AdminConn, Databases) -> lists:foldl(fun(Database, Acc) -> do_compact_node_db(Node, Heuristic, APIConn, AdminConn, Database, Acc) @@ -226,7 +226,7 @@ do_compact_node(Node, Heuristic, APIConn, AdminConn, Databases) -> ,Databases ). --spec do_compact_node_db(ne_binary(), heuristic(), kz_data:connection(), kz_data:connection(), ne_binary(), rows()) -> rows(). +-spec do_compact_node_db(kz_term:ne_binary(), heuristic(), kz_data:connection(), kz_data:connection(), kz_term:ne_binary(), rows()) -> rows(). do_compact_node_db(Node, Heuristic, APIConn, AdminConn, Database, Acc) -> Compactor = node_compactor(Node, Heuristic, APIConn, AdminConn, Database), do_compact_node_db(Compactor, Acc). @@ -248,19 +248,19 @@ do_compact_node_db(Compactor) -> | BeforeCols ] ++ AfterCols. --spec do_compact_db(ne_binary()) -> rows(). --spec do_compact_db(ne_binary(), heuristic()) -> rows(). +-spec do_compact_db(kz_term:ne_binary()) -> rows(). +-spec do_compact_db(kz_term:ne_binary(), heuristic()) -> rows(). do_compact_db(Database) -> do_compact_db(Database, ?HEUR_RATIO). do_compact_db(Database, Heuristic) -> do_compact_db_by_nodes(Database, Heuristic). --spec do_compact_db_fold(ne_binary(), rows()) -> rows(). +-spec do_compact_db_fold(kz_term:ne_binary(), rows()) -> rows(). do_compact_db_fold(Database, Rows) -> Rows ++ do_compact_db(Database). --spec do_compact_db_by_nodes(ne_binary(), heuristic()) -> rows(). +-spec do_compact_db_by_nodes(kz_term:ne_binary(), heuristic()) -> rows(). do_compact_db_by_nodes(Database, Heuristic) -> {'ok', DbInfo} = kz_datamgr:open_cache_doc(kazoo_couch:get_admin_dbs(), Database), kz_json:foldl(fun(Node, _, Rows) -> @@ -270,7 +270,7 @@ do_compact_db_by_nodes(Database, Heuristic) -> ,kz_json:get_json_value(<<"by_node">>, DbInfo) ). --spec do_compact_db_by_node(ne_binary(), heuristic(), ne_binary(), rows()) -> rows(). +-spec do_compact_db_by_node(kz_term:ne_binary(), heuristic(), kz_term:ne_binary(), rows()) -> rows(). do_compact_db_by_node(Node, Heuristic, Database, Acc) -> #{server := {_App, #server{}=Conn}} = kzs_plan:plan(), case get_node_connections(Node, Conn) of @@ -281,14 +281,14 @@ do_compact_db_by_node(Node, Heuristic, Database, Acc) -> do_compact_db_by_node(Node, Heuristic, APIConn, AdminConn, Database, Acc) end. --spec do_compact_db_by_node(ne_binary(), heuristic(), kz_data:connection(), kz_data:connection(), ne_binary(), rows()) -> rows(). +-spec do_compact_db_by_node(kz_term:ne_binary(), heuristic(), kz_data:connection(), kz_data:connection(), kz_term:ne_binary(), rows()) -> rows(). do_compact_db_by_node(Node, Heuristic, APIConn, AdminConn, Database, Acc) -> case do_compact_node(Node, Heuristic, APIConn, AdminConn, [Database]) of [] -> Acc; [Row] -> [Row | Acc] end. --spec db_usage_cols(kz_data:connection(), ne_binary()) -> [integer()]. +-spec db_usage_cols(kz_data:connection(), kz_term:ne_binary()) -> [integer()]. db_usage_cols(Conn, Database) -> case kt_compactor_worker:get_db_disk_and_data(Conn, Database) of 'undefined' -> [0, 0]; @@ -296,12 +296,12 @@ db_usage_cols(Conn, Database) -> {Disk, Data} -> [Disk, Data] end. --spec node_compactor(ne_binary(), heuristic(), kz_data:connection(), kz_data:connection(), ne_binary()) -> +-spec node_compactor(kz_term:ne_binary(), heuristic(), kz_data:connection(), kz_data:connection(), kz_term:ne_binary()) -> kt_compactor_worker:compactor(). node_compactor(Node, Heuristic, APIConn, AdminConn, Database) -> kt_compactor_worker:new(Node, Heuristic, APIConn, AdminConn, Database). --spec get_node_connections(ne_binary(), kz_data:connection()) -> +-spec get_node_connections(kz_term:ne_binary(), kz_data:connection()) -> {kz_data:connection(), kz_data:connection()} | {'error', 'no_connection'}. get_node_connections(Node, #server{options=Options}) -> diff --git a/applications/tasks/src/modules/kt_compactor_worker.erl b/applications/tasks/src/modules/kt_compactor_worker.erl index 9ade62dc564..7c15940bc19 100644 --- a/applications/tasks/src/modules/kt_compactor_worker.erl +++ b/applications/tasks/src/modules/kt_compactor_worker.erl @@ -34,12 +34,12 @@ -include("tasks.hrl"). -include("src/modules/kt_compactor.hrl"). --record(compactor, {node :: ne_binary() +-record(compactor, {node :: kz_term:ne_binary() ,conn :: kz_data:connection() ,admin :: kz_data:connection() - ,database :: ne_binary() - ,shards :: ne_binaries() - ,design_docs = [] :: ne_binaries() + ,database :: kz_term:ne_binary() + ,shards :: kz_term:ne_binaries() + ,design_docs = [] :: kz_term:ne_binaries() ,heuristic :: heuristic() }). @@ -57,7 +57,7 @@ run_compactor(Compactor) -> run_compactor_job(Compactor, compactor_shards(Compactor)) end. --spec run_compactor_job(compactor(), ne_binaries()) -> 'ok'. +-spec run_compactor_job(compactor(), kz_term:ne_binaries()) -> 'ok'. run_compactor_job(_Compactor, []) -> 'ok'; run_compactor_job(Compactor, Shards) -> try lists:split(?MAX_COMPACTING_SHARDS, Shards) of @@ -73,8 +73,8 @@ run_compactor_job(Compactor, Shards) -> wait_for_shards(ShardsPidRef) end. --spec wait_for_shards(pid_refs()) -> 'ok'. --spec wait_for_shards(pid_refs(), pid_ref()) -> 'ok'. +-spec wait_for_shards(kz_term:pid_refs()) -> 'ok'. +-spec wait_for_shards(kz_term:pid_refs(), kz_term:pid_ref()) -> 'ok'. wait_for_shards([]) -> 'ok'; wait_for_shards(PidRefs) -> MaxWait = ?MAX_WAIT_FOR_COMPACTION_PIDS, @@ -92,7 +92,7 @@ wait_for_shards(PidRefs, {Pid, Ref}) -> _Ref -> wait_for_shards(PidRefs) end. --spec compact_shards(compactor()) -> pid_refs(). +-spec compact_shards(compactor()) -> kz_term:pid_refs(). compact_shards(Compactor) -> [spawn_monitor(?MODULE, 'compact_shard', [Compactor#compactor{shards=[Shard]}]) || Shard <- compactor_shards(Compactor) @@ -143,7 +143,7 @@ continue_compacting_shard(#compactor{shards=[Shard]}=Compactor) -> lager:debug(" finished compacting shard: ~p disk/~p data", [AfterDisk, AfterData]) end. --spec compact_design_docs(kz_data:connection(), ne_binary(), ne_binaries()) -> 'ok'. +-spec compact_design_docs(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binaries()) -> 'ok'. compact_design_docs(_Conn, _Shard, []) -> 'ok'; compact_design_docs(Conn, Shard, DDs) -> try lists:split(?MAX_COMPACTING_VIEWS, DDs) of @@ -164,9 +164,9 @@ compact_design_docs(Conn, Shard, DDs) -> -type design_info_resp() :: {'ok', kz_json:object()} | {'error', any()}. --spec wait_for_design_compaction(kz_data:connection(), ne_binary(), ne_binaries()) -> +-spec wait_for_design_compaction(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binaries()) -> 'ok'. --spec wait_for_design_compaction(kz_data:connection(), ne_binary(), ne_binaries(), ne_binary(), design_info_resp()) -> +-spec wait_for_design_compaction(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binaries(), kz_term:ne_binary(), design_info_resp()) -> 'ok'. wait_for_design_compaction(_, _, []) -> 'ok'; wait_for_design_compaction(AdminConn, Shard, [DD|DDs]) -> @@ -191,8 +191,8 @@ wait_for_design_compaction(AdminConn, Shard, DDs, DD, {'ok', DesignInfo}) -> wait_for_design_compaction(AdminConn, Shard, DDs, DD, kz_couch_view:design_info(AdminConn, Shard, DD)) end. --spec wait_for_compaction(kz_data:connection(), ne_binary()) -> 'ok'. --spec wait_for_compaction(kz_data:connection(), ne_binary(), db_info_resp()) -> 'ok'. +-spec wait_for_compaction(kz_data:connection(), kz_term:ne_binary()) -> 'ok'. +-spec wait_for_compaction(kz_data:connection(), kz_term:ne_binary(), db_info_resp()) -> 'ok'. wait_for_compaction(AdminConn, Shard) -> wait_for_compaction(AdminConn, Shard, kz_couch_db:db_info(AdminConn, Shard)). @@ -232,10 +232,10 @@ should_compact(Compactor, ?HEUR_RATIO) -> 'false' end. --spec get_db_disk_and_data(kz_data:connection(), ne_binary()) -> +-spec get_db_disk_and_data(kz_data:connection(), kz_term:ne_binary()) -> {pos_integer(), pos_integer()} | 'undefined' | 'not_found'. --spec get_db_disk_and_data(kz_data:connection(), ne_binary(), 0..3) -> +-spec get_db_disk_and_data(kz_data:connection(), kz_term:ne_binary(), 0..3) -> {pos_integer(), pos_integer()} | 'undefined' | 'not_found'. get_db_disk_and_data(Conn, DbName) -> @@ -291,12 +291,12 @@ min_ratio_met(Disk, Data, MinRatio) -> 'false' end. --spec compactor_node(compactor()) -> ne_binary(). +-spec compactor_node(compactor()) -> kz_term:ne_binary(). -spec compactor_conn(compactor()) -> kz_data:connection(). -spec compactor_admin(compactor()) -> kz_data:connection(). --spec compactor_database(compactor()) -> ne_binary(). --spec compactor_shards(compactor()) -> ne_binaries(). --spec compactor_design_docs(compactor()) -> ne_binaries(). +-spec compactor_database(compactor()) -> kz_term:ne_binary(). +-spec compactor_shards(compactor()) -> kz_term:ne_binaries(). +-spec compactor_design_docs(compactor()) -> kz_term:ne_binaries(). -spec compactor_heuristic(compactor()) -> heuristic(). compactor_node(#compactor{node=Node}) -> Node. @@ -307,7 +307,7 @@ compactor_shards(#compactor{shards=Shards}) -> Shards. compactor_design_docs(#compactor{design_docs=DesignDocs}) -> DesignDocs. compactor_heuristic(#compactor{heuristic=Heuristic}) -> Heuristic. --spec new(ne_binary(), heuristic(), kz_data:connection(), kz_data:connection(), ne_binary()) -> +-spec new(kz_term:ne_binary(), heuristic(), kz_data:connection(), kz_data:connection(), kz_term:ne_binary()) -> compactor(). new(Node, Heuristic, APIConn, AdminConn, Database) -> #compactor{node=Node @@ -319,8 +319,8 @@ new(Node, Heuristic, APIConn, AdminConn, Database) -> ,design_docs=db_design_docs(APIConn, Database) }. --spec node_shards(ne_binary(), ne_binary()) -> ne_binaries(). --spec node_shards(ne_binary(), ne_binary(), kz_json:object()) -> ne_binaries(). +-spec node_shards(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binaries(). +-spec node_shards(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> kz_term:ne_binaries(). node_shards(Node, Unencoded) -> {'ok', DbInfo} = kz_datamgr:open_doc(kazoo_couch:get_admin_dbs(), Unencoded), node_shards(Node, Unencoded, DbInfo). @@ -332,7 +332,7 @@ node_shards(Node, Unencoded, DbInfo) -> || Range <- Ranges ]. --spec db_design_docs(kz_data:connection(), ne_binary()) -> ne_binaries(). +-spec db_design_docs(kz_data:connection(), kz_term:ne_binary()) -> kz_term:ne_binaries(). db_design_docs(Conn, D) -> case kz_couch_view:all_design_docs(Conn, kz_http_util:urlencode(D)) of {'ok', Designs} -> @@ -340,6 +340,6 @@ db_design_docs(Conn, D) -> {'error', _} -> [] end. --spec encode_design_doc(ne_binary()) -> ne_binary(). +-spec encode_design_doc(kz_term:ne_binary()) -> kz_term:ne_binary(). encode_design_doc(Design) -> binary:replace(Design, <<"_design/">>, <<>>, []). diff --git a/applications/tasks/src/modules/kt_initial_occurrence.erl b/applications/tasks/src/modules/kt_initial_occurrence.erl index d103bdf96fe..a99428e350e 100644 --- a/applications/tasks/src/modules/kt_initial_occurrence.erl +++ b/applications/tasks/src/modules/kt_initial_occurrence.erl @@ -31,7 +31,7 @@ init() -> 'maybe_test_for_initial_occurrences'). %% Triggerables --spec maybe_test_for_initial_occurrences(ne_binary(), kz_account:doc()) -> 'ok'. +-spec maybe_test_for_initial_occurrences(kz_term:ne_binary(), kz_account:doc()) -> 'ok'. maybe_test_for_initial_occurrences(AccountId, AccountJObj) -> AccountDb = kz_doc:account_db(AccountJObj), case ?SHOULD_CRAWL_FOR_FIRST_OCCURRENCE of @@ -45,7 +45,7 @@ maybe_test_for_initial_occurrences(AccountId, AccountJObj) -> %%% Internal functions %%%============================================================================= %% First Registration --spec maybe_test_for_registrations(ne_binary(), kz_account:doc()) -> 'ok'. +-spec maybe_test_for_registrations(kz_term:ne_binary(), kz_account:doc()) -> 'ok'. maybe_test_for_registrations(AccountId, AccountJObj) -> Realm = kz_account:realm(AccountJObj), case Realm =:= 'undefined' @@ -55,7 +55,7 @@ maybe_test_for_registrations(AccountId, AccountJObj) -> 'false' -> test_for_registrations(AccountId, Realm) end. --spec test_for_registrations(ne_binary(), ne_binary()) -> 'ok'. +-spec test_for_registrations(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. test_for_registrations(AccountId, Realm) -> lager:debug("looking for any registrations in realm ~s", [Realm]), Reg = [{<<"Realm">>, Realm} @@ -77,7 +77,7 @@ test_for_registrations(AccountId, Realm) -> end end. --spec handle_initial_registration(ne_binary()) -> 'ok'. +-spec handle_initial_registration(kz_term:ne_binary()) -> 'ok'. handle_initial_registration(AccountId) -> case kz_account:fetch(AccountId) of {'ok', AccountJObj} -> notify_initial_registration(AccountJObj); @@ -95,7 +95,7 @@ notify_initial_registration(AccountJObj) -> kapps_notify_publisher:cast(Req, fun kapi_notifications:publish_first_occurrence/1). %% First Call --spec maybe_test_for_initial_call(ne_binary(), ne_binary(), kz_account:doc()) -> 'ok'. +-spec maybe_test_for_initial_call(kz_term:ne_binary(), kz_term:ne_binary(), kz_account:doc()) -> 'ok'. maybe_test_for_initial_call(AccountId, AccountDb, AccountJObj) -> case kz_account:sent_initial_call(AccountJObj) of 'true' -> 'ok'; @@ -104,7 +104,7 @@ maybe_test_for_initial_call(AccountId, AccountDb, AccountJObj) -> test_for_initial_call(AccountId, AccountDb) end. --spec test_for_initial_call(ne_binary(), ne_binary()) -> 'ok'. +-spec test_for_initial_call(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. test_for_initial_call(AccountId, AccountDb) -> ViewOptions = [{'key', <<"cdr">>} ,{'limit', 1} @@ -116,7 +116,7 @@ test_for_initial_call(AccountId, AccountDb) -> _Else -> 'ok' end. --spec handle_initial_call(ne_binary()) -> 'ok'. +-spec handle_initial_call(kz_term:ne_binary()) -> 'ok'. handle_initial_call(AccountId) -> case kz_account:fetch(AccountId) of {'ok', AccountJObj} -> notify_initial_call(AccountJObj); diff --git a/applications/tasks/src/modules/kt_low_balance.erl b/applications/tasks/src/modules/kt_low_balance.erl index b0f0c433fc9..07976214c4b 100644 --- a/applications/tasks/src/modules/kt_low_balance.erl +++ b/applications/tasks/src/modules/kt_low_balance.erl @@ -35,7 +35,7 @@ init() -> 'maybe_test_for_low_balance'). %% Triggerables --spec maybe_test_for_low_balance(ne_binary(), kz_account:doc()) -> 'ok'. +-spec maybe_test_for_low_balance(kz_term:ne_binary(), kz_account:doc()) -> 'ok'. maybe_test_for_low_balance(AccountId, AccountJObj) -> case ?SHOULD_CRAWL_FOR_LOW_BALANCE of 'false' -> 'ok'; @@ -45,7 +45,7 @@ maybe_test_for_low_balance(AccountId, AccountJObj) -> %%%============================================================================= %%% Internal functions %%%============================================================================= --spec test_for_low_balance(ne_binary(), kz_account:doc(), 0..3) -> 'ok'. +-spec test_for_low_balance(kz_term:ne_binary(), kz_account:doc(), 0..3) -> 'ok'. test_for_low_balance(_AccountId, _AccountJObj, 0) -> lager:debug("max try to get account ~s current balance", [_AccountId]); test_for_low_balance(AccountId, AccountJObj, Loop) -> diff --git a/applications/tasks/src/modules/kt_modb.erl b/applications/tasks/src/modules/kt_modb.erl index 95702c2238e..202824a2efd 100644 --- a/applications/tasks/src/modules/kt_modb.erl +++ b/applications/tasks/src/modules/kt_modb.erl @@ -36,6 +36,6 @@ init() -> %%% Triggerables --spec clean_modb(ne_binary()) -> 'ok'. +-spec clean_modb(kz_term:ne_binary()) -> 'ok'. clean_modb(AccountMODb) -> kazoo_modb:maybe_archive_modb(AccountMODb). diff --git a/applications/tasks/src/modules/kt_numbers.erl b/applications/tasks/src/modules/kt_numbers.erl index f73c9f01602..e2eae98ddbe 100644 --- a/applications/tasks/src/modules/kt_numbers.erl +++ b/applications/tasks/src/modules/kt_numbers.erl @@ -98,7 +98,7 @@ init() -> _ = tasks_bindings:bind(<<"tasks."?CATEGORY".ported_in">>, ?MODULE, 'ported_in'), tasks_bindings:bind_actions(<<"tasks."?CATEGORY>>, ?MODULE, ?ACTIONS). --spec output_header(ne_binary()) -> kz_tasks:output_header(). +-spec output_header(kz_term:ne_binary()) -> kz_tasks:output_header(). output_header(<<"list">>) -> list_output_header(); output_header(<<"list_all">>) -> @@ -110,7 +110,7 @@ output_header(<<"dump_", _/binary>>) -> output_header(?NE_BINARY) -> result_output_header(). --spec cleanup(ne_binary(), any()) -> any(). +-spec cleanup(kz_term:ne_binary(), any()) -> any(). cleanup(<<"import">>, 'init') -> %% Hit iff no rows at all succeeded. 'ok'; @@ -157,7 +157,7 @@ list_output_header() -> ,<<"failover.sip">> ]. --spec list_doc() -> ne_binary(). +-spec list_doc() -> kz_term:ne_binary(). list_doc() -> <<"For each number found, returns fields:\n" "* `e164`: phone number represented as E164 (with a leading `+` sign).\n" @@ -204,15 +204,15 @@ optional_public_fields() -> -spec help(kz_json:object()) -> kz_json:object(). help(JObj) -> help(JObj, <>). --spec help(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec help(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). help(JObj, <>=Category) -> lists:foldl(fun(Action, J) -> help(J, Category, Action) end, JObj, ?ACTIONS). --spec help(kz_json:object(), ne_binary(), ne_binary()) -> kz_json:object(). +-spec help(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). help(JObj, <>=Category, Action) -> kz_json:set_value([Category, Action], kz_json:from_map(action(Action)), JObj). --spec action(ne_binary()) -> map(). +-spec action(kz_term:ne_binary()) -> map(). action(<<"list">>) -> #{<<"description">> => <<"List all numbers assigned to the account starting the task">> ,<<"doc">> => list_doc() @@ -334,43 +334,43 @@ action(<<"delete">>) -> %%% Verifiers --spec e164(ne_binary()) -> boolean(). +-spec e164(kz_term:ne_binary()) -> boolean(). e164(<<"+", _/binary>>) -> 'true'; e164(_) -> 'false'. --spec account_id(ne_binary()) -> boolean(). +-spec account_id(kz_term:ne_binary()) -> boolean(). account_id(?MATCH_ACCOUNT_RAW(_)) -> 'true'; account_id(_) -> 'false'. --spec carrier_module(ne_binary()) -> boolean(). +-spec carrier_module(kz_term:ne_binary()) -> boolean(). carrier_module(Data) -> lists:member(Data, knm_carriers:all_modules()). --spec state(ne_binary()) -> boolean(). +-spec state(kz_term:ne_binary()) -> boolean(). state(Data) -> knm_phone_number:is_state(Data). --spec ported_in(ne_binary()) -> boolean(). +-spec ported_in(kz_term:ne_binary()) -> boolean(). ported_in(Cell) -> is_cell_boolean(Cell). --spec 'cnam.inbound'(ne_binary()) -> boolean(). +-spec 'cnam.inbound'(kz_term:ne_binary()) -> boolean(). 'cnam.inbound'(Cell) -> is_cell_boolean(Cell). --spec 'prepend.enabled'(ne_binary()) -> boolean(). +-spec 'prepend.enabled'(kz_term:ne_binary()) -> boolean(). 'prepend.enabled'(Cell) -> is_cell_boolean(Cell). --spec force_outbound(ne_binary()) -> boolean(). +-spec force_outbound(kz_term:ne_binary()) -> boolean(). force_outbound(Cell) -> is_cell_boolean(Cell). %% @private --spec is_cell_boolean(ne_binary()) -> boolean(). +-spec is_cell_boolean(kz_term:ne_binary()) -> boolean(). is_cell_boolean(<<"true">>) -> 'true'; is_cell_boolean(<<"false">>) -> 'true'; is_cell_boolean(_) -> 'false'. %% @private --spec is_cell_true(api_ne_binary()) -> boolean(). +-spec is_cell_true(kz_term:api_ne_binary()) -> boolean(). is_cell_true('undefined') -> 'undefined'; is_cell_true(<<"true">>) -> 'true'; is_cell_true(_) -> 'false'. @@ -385,7 +385,7 @@ list(_, []) -> 'stop'; list(#{auth_account_id := AuthBy}, Todo) -> list_assigned_to(AuthBy, Todo). --spec list_numbers(ne_binary(), ne_binaries()) -> [kz_csv:row()]. +-spec list_numbers(kz_term:ne_binary(), kz_term:ne_binaries()) -> [kz_csv:row()]. list_numbers(AuthBy, E164s) -> Options = [{'auth_by', AuthBy} ,{'batch_run', 'true'} @@ -441,14 +441,14 @@ list_number(N) -> ,<<"failover.sip">> => quote(kz_json:get_ne_binary_value(?FAILOVER_SIP, Failover)) }. --spec account_name(api_ne_binary()) -> api_ne_binary(). +-spec account_name(kz_term:api_ne_binary()) -> kz_term:api_ne_binary(). account_name(MaybeAccountId) -> case kz_account:fetch_name(MaybeAccountId) of 'undefined' -> 'undefined'; Name -> quote(Name) end. --spec quote(api_ne_binary()) -> api_ne_binary(). +-spec quote(kz_term:api_ne_binary()) -> kz_term:api_ne_binary(). quote('undefined') -> 'undefined'; quote(Bin) -> <<$\", Bin/binary, $\">>. @@ -622,7 +622,7 @@ ringback(Props) -> maybe_nest(?FEATURE_RINGBACK, Props). failover(Props) -> maybe_nest(?FEATURE_FAILOVER, Props). %% @private --spec maybe_nest(ne_binary(), kz_proplist()) -> kz_proplist(). +-spec maybe_nest(kz_term:ne_binary(), kz_term:proplist()) -> kz_term:proplist(). maybe_nest(_, []) -> []; maybe_nest(Feature, Props) -> [{Feature, kz_json:from_list(Props)}]. @@ -755,15 +755,15 @@ handle_result(Args, {error, KNMError}) -> end, format_result(Args, kz_term:to_binary(Reason)). --spec format_result(kz_tasks:args(), ne_binary() | knm_number:knm_number()) -> kz_csv:mapped_row(). +-spec format_result(kz_tasks:args(), kz_term:ne_binary() | knm_number:knm_number()) -> kz_csv:mapped_row(). format_result(Args, Reason=?NE_BINARY) -> Args#{?OUTPUT_CSV_HEADER_ERROR => Reason}; format_result(_, N) -> Map = list_number(N), Map#{?OUTPUT_CSV_HEADER_ERROR => undefined}. --type accountid_or_startkey_and_numberdbs() :: [{ne_binary() | ne_binaries(), ne_binary()}]. --spec list_assigned_to(ne_binary(), accountid_or_startkey_and_numberdbs()) -> +-type accountid_or_startkey_and_numberdbs() :: [{kz_term:ne_binary() | kz_term:ne_binaries(), kz_term:ne_binary()}]. +-spec list_assigned_to(kz_term:ne_binary(), accountid_or_startkey_and_numberdbs()) -> {ok | error | [kz_csv:row()], accountid_or_startkey_and_numberdbs()}. list_assigned_to(AuthBy, [{Next,NumberDb}|Rest]) -> ViewOptions = [{limit,?DB_DUMP_BULK_SIZE} | view_for_list_assigned(Next)], @@ -777,7 +777,7 @@ list_assigned_to(AuthBy, [{Next,NumberDb}|Rest]) -> {Rows, [{lists:last(Keys),NumberDb}|Rest]} end. --spec view_for_list_assigned(ne_binary() | ne_binaries()) -> kz_datamgr:view_options(). +-spec view_for_list_assigned(kz_term:ne_binary() | kz_term:ne_binaries()) -> kz_datamgr:view_options(). view_for_list_assigned(?MATCH_ACCOUNT_RAW(AccountId)) -> [{startkey, [AccountId]} ,{endkey, [AccountId, kz_json:new()]} @@ -788,8 +788,8 @@ view_for_list_assigned(StartKey=[AccountId,_]) -> ,{skip, 1} ]. --type startkey_or_numberdb() :: ne_binary() | ne_binaries(). --spec dump_next(fun((startkey_or_numberdb()) -> {ne_binary(), kz_datamgr:view_options()}), startkey_or_numberdb()) -> +-type startkey_or_numberdb() :: kz_term:ne_binary() | kz_term:ne_binaries(). +-spec dump_next(fun((startkey_or_numberdb()) -> {kz_term:ne_binary(), kz_datamgr:view_options()}), startkey_or_numberdb()) -> {ok | error | [kz_csv:row()], [startkey_or_numberdb()]}. dump_next(ViewFun, [Next|Rest]) -> {NumberDb, MoreViewOptions} = ViewFun(Next), @@ -804,7 +804,7 @@ dump_next(ViewFun, [Next|Rest]) -> {Rows, [lists:last(Keys)|Rest]} end. --spec db_and_view_for_dump(ne_binary() | ne_binaries()) -> {ne_binary(), kz_datamgr:view_options()}. +-spec db_and_view_for_dump(kz_term:ne_binary() | kz_term:ne_binaries()) -> {kz_term:ne_binary(), kz_datamgr:view_options()}. db_and_view_for_dump(NumberDb=?NE_BINARY) -> {NumberDb, []}; db_and_view_for_dump(StartKey=[_,_,LastNum]) -> ViewOpts = [{startkey, StartKey} @@ -812,7 +812,7 @@ db_and_view_for_dump(StartKey=[_,_,LastNum]) -> ], {knm_converters:to_db(LastNum), ViewOpts}. --spec db_and_view_for_dump_by_state(ne_binary(), ne_binary() | ne_binaries()) -> {ne_binary(), kz_datamgr:view_options()}. +-spec db_and_view_for_dump_by_state(kz_term:ne_binary(), kz_term:ne_binary() | kz_term:ne_binaries()) -> {kz_term:ne_binary(), kz_datamgr:view_options()}. db_and_view_for_dump_by_state(State, NumberDb=?NE_BINARY) -> ViewOptions = [{startkey, [State]} ,{endkey, [State, kz_json:new()]} diff --git a/applications/tasks/src/modules/kt_port_requests.erl b/applications/tasks/src/modules/kt_port_requests.erl index 71460156c17..afcbdbbbd3d 100644 --- a/applications/tasks/src/modules/kt_port_requests.erl +++ b/applications/tasks/src/modules/kt_port_requests.erl @@ -41,7 +41,7 @@ init() -> %% @doc %% Cleanup expired port requests %% @end --spec cleanup(ne_binary()) -> 'ok'. +-spec cleanup(kz_term:ne_binary()) -> 'ok'. cleanup(?KZ_PORT_REQUESTS_DB = Db) -> ModifiedBefore = kz_time:now_s() - ?UNFINISHED_PORT_REQUEST_LIFETIME, ViewOpts = [{'startkey', [0]} @@ -56,7 +56,7 @@ cleanup(?KZ_PORT_REQUESTS_DB = Db) -> end; cleanup(_) -> 'ok'. --spec unconfirmed_port_reminder(ne_binary()) -> 'ok'. +-spec unconfirmed_port_reminder(kz_term:ne_binary()) -> 'ok'. unconfirmed_port_reminder(AccountDb) -> AccountId = kz_util:format_account_id(AccountDb, 'raw'), ViewOpts = [{'startkey', [AccountId, ?PORT_UNCONFIRMED, kz_json:new()]} @@ -73,7 +73,7 @@ unconfirmed_port_reminder(AccountDb) -> %%% Internal functions %%%=================================================================== --spec cleanup(ne_binary(), kz_json:objects()) -> 'ok'. +-spec cleanup(kz_term:ne_binary(), kz_json:objects()) -> 'ok'. cleanup(Db, OldPortRequests) -> lager:debug("checking ~b old port requests", [length(OldPortRequests)]), Deletable = [kz_json:get_value(<<"doc">>, OldPortRequest) @@ -84,18 +84,18 @@ cleanup(Db, OldPortRequests) -> kz_datamgr:del_docs(Db, Deletable), 'ok'. --spec should_delete_port_request([pos_integer() | ne_binary(),...]) -> boolean(). +-spec should_delete_port_request([pos_integer() | kz_term:ne_binary(),...]) -> boolean(). should_delete_port_request([_Modified, ?PORT_SUBMITTED]) -> false; should_delete_port_request([_Modified, ?PORT_SCHEDULED]) -> false; should_delete_port_request(_) -> true. --spec unconfirmed_port_reminder(ne_binary(), kz_json:objects()) -> 'ok'. +-spec unconfirmed_port_reminder(kz_term:ne_binary(), kz_json:objects()) -> 'ok'. unconfirmed_port_reminder(AccountId, UnfinishedPorts) -> lager:debug("found ~p unfinished port requests, sending notifications", [length(UnfinishedPorts)]), F = fun (Port) -> send_port_unconfirmed_notification(AccountId, kz_doc:id(Port)) end, lists:foreach(F, UnfinishedPorts). --spec send_port_unconfirmed_notification(ne_binary(), ne_binary()) -> 'ok'. +-spec send_port_unconfirmed_notification(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. send_port_unconfirmed_notification(?NE_BINARY = AccountId, Id) -> Req = [{<<"Account-ID">>, AccountId} ,{<<"Port-Request-ID">>, Id} diff --git a/applications/tasks/src/modules/kt_rates.erl b/applications/tasks/src/modules/kt_rates.erl index 9202a2c9fe0..b7f08a4b31f 100644 --- a/applications/tasks/src/modules/kt_rates.erl +++ b/applications/tasks/src/modules/kt_rates.erl @@ -48,21 +48,21 @@ init() -> _ = tasks_bindings:bind(<<"tasks."?CATEGORY".cleanup">>, ?MODULE, 'cleanup'), tasks_bindings:bind_actions(<<"tasks."?CATEGORY>>, ?MODULE, ?ACTIONS). --spec output_header(ne_binary()) -> kz_tasks:output_header(). +-spec output_header(kz_term:ne_binary()) -> kz_tasks:output_header(). output_header(<<"export">>) -> ?DOC_FIELDS. -spec help(kz_json:object()) -> kz_json:object(). help(JObj) -> help(JObj, <>). --spec help(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec help(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). help(JObj, <>=Category) -> lists:foldl(fun(Action, J) -> help(J, Category, Action) end, JObj, ?ACTIONS). --spec help(kz_json:object(), ne_binary(), ne_binary()) -> kz_json:object(). +-spec help(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). help(JObj, <>=Category, Action) -> kz_json:set_value([Category, Action], kz_json:from_list(action(Action)), JObj). --spec action(ne_binary()) -> kz_proplist(). +-spec action(kz_term:ne_binary()) -> kz_term:proplist(). action(<<"export">>) -> [{<<"description">>, <<"Export ratedeck">>} ,{<<"doc">>, <<"Export rates from the supplied ratedeck">>} @@ -93,7 +93,7 @@ action(<<"delete">>) -> %%% Verifiers --spec direction(ne_binary()) -> boolean(). +-spec direction(kz_term:ne_binary()) -> boolean(). direction(<<"inbound">>) -> 'true'; direction(<<"outbound">>) -> 'true'; direction(_) -> 'false'. @@ -226,7 +226,7 @@ delete(_ExtraArgs, State, Args) -> } end. --spec cleanup(ne_binary(), any()) -> any(). +-spec cleanup(kz_term:ne_binary(), any()) -> any(). cleanup(<<"import">>, Dict) -> _Size = dict:size(Dict), lager:debug("importing ~p ratedeck~s", [_Size, maybe_plural(_Size)]), @@ -239,7 +239,7 @@ cleanup(<<"delete">>, State) -> kz_datamgr:enable_change_notice(), kzs_publish:publish_db(Db, <<"edited">>). --spec import_rates_into_ratedeck(ne_binary(), {non_neg_integer(), kz_json:objects()}) -> 'ok'. +-spec import_rates_into_ratedeck(kz_term:ne_binary(), {non_neg_integer(), kz_json:objects()}) -> 'ok'. import_rates_into_ratedeck(Ratedeck, {0, []}) -> RatedeckDb = kzd_ratedeck:format_ratedeck_db(Ratedeck), kz_datamgr:enable_change_notice(), @@ -286,7 +286,7 @@ is_allowed(ExtraArgs) -> %% or serve requests from SuperAdmin orelse kz_account:is_superduper_admin(AuthAccountDoc). --spec get_ratedeck_db(kz_tasks:extra_args()) -> ne_binary(). +-spec get_ratedeck_db(kz_tasks:extra_args()) -> kz_term:ne_binary(). get_ratedeck_db(_ExtraArgs) -> %% TODO: per account DB? ?KZ_RATES_DB. @@ -309,7 +309,7 @@ generate_row(Args) -> ]), kz_json:set_values(Update, RateJObj). --spec save_rates(ne_binary(), kzd_rate:docs()) -> 'ok'. +-spec save_rates(kz_term:ne_binary(), kzd_rate:docs()) -> 'ok'. save_rates(Db, Rates) -> case kz_datamgr:save_docs(Db, Rates) of {'ok', _Result} -> @@ -323,7 +323,7 @@ save_rates(Db, Rates) -> {'error', 'timeout'} -> refresh_selectors_index(Db) end. --spec delete_rates(ne_binary(), list(), dict:dict()) -> 'ok'. +-spec delete_rates(kz_term:ne_binary(), list(), dict:dict()) -> 'ok'. delete_rates(Db, Keys, Dict) -> Options = [{'keys', Keys} ,'include_docs' @@ -335,7 +335,7 @@ delete_rates(Db, Keys, Dict) -> do_delete_rates(Db, Docs) end. --spec do_delete_rates(ne_binary(), kz_json:objects()) -> 'ok'. +-spec do_delete_rates(kz_term:ne_binary(), kz_json:objects()) -> 'ok'. do_delete_rates(_Db, []) -> 'ok'; do_delete_rates(Db, Docs) -> {Head, Rest} = case length(Docs) > ?BULK_LIMIT @@ -352,13 +352,13 @@ do_delete_rates(Db, Docs) -> end, do_delete_rates(Db, Rest). --spec refresh_selectors_index(ne_binary()) -> 'ok'. +-spec refresh_selectors_index(kz_term:ne_binary()) -> 'ok'. refresh_selectors_index(Db) -> {'ok', _} = kz_datamgr:all_docs(Db, [{'limit', 1}]), {'ok', _} = kz_datamgr:get_results(Db, <<"rates/lookup">>, [{'limit', 1}]), 'ok'. --spec init_db(ne_binary()) -> 'ok'. +-spec init_db(kz_term:ne_binary()) -> 'ok'. init_db(Db) -> _Created = kz_datamgr:db_create(Db), lager:debug("created ~s: ~s", [Db, _Created]), @@ -389,9 +389,9 @@ maybe_delete_rate(JObj, Dict) -> maybe_default(0, Default) -> Default; maybe_default(Value, _Default) -> Value. --spec maybe_generate_name(kzd_rate:doc()) -> ne_binary(). --spec maybe_generate_name(kzd_rate:doc(), api_ne_binary()) -> ne_binary(). --spec generate_name(ne_binary(), api_ne_binary(), ne_binaries()) -> ne_binary(). +-spec maybe_generate_name(kzd_rate:doc()) -> kz_term:ne_binary(). +-spec maybe_generate_name(kzd_rate:doc(), kz_term:api_ne_binary()) -> kz_term:ne_binary(). +-spec generate_name(kz_term:ne_binary(), kz_term:api_ne_binary(), kz_term:ne_binaries()) -> kz_term:ne_binary(). maybe_generate_name(RateJObj) -> maybe_generate_name(RateJObj, kzd_rate:name(RateJObj)). @@ -414,7 +414,7 @@ generate_name(Prefix, ISO, Directions) -> <>. -spec maybe_generate_weight(kzd_rate:doc()) -> integer(). --spec maybe_generate_weight(kzd_rate:doc(), api_integer()) -> integer(). +-spec maybe_generate_weight(kzd_rate:doc(), kz_term:api_integer()) -> integer(). maybe_generate_weight(RateJObj) -> maybe_generate_weight(RateJObj, kzd_rate:weight(RateJObj, 'undefined')). @@ -425,7 +425,7 @@ maybe_generate_weight(RateJObj, 'undefined') -> ); maybe_generate_weight(_RateJObj, Weight) -> kzd_rate:constrain_weight(Weight). --spec generate_weight(ne_binary(), kz_transaction:units(), kz_transaction:units()) -> +-spec generate_weight(kz_term:ne_binary(), kz_transaction:units(), kz_transaction:units()) -> kzd_rate:weight_range(). generate_weight(?NE_BINARY = Prefix, UnitCost, UnitIntCost) -> UnitCostToUse = maybe_default(UnitIntCost, UnitCost), diff --git a/applications/tasks/src/modules/kt_resource_selectors.erl b/applications/tasks/src/modules/kt_resource_selectors.erl index c0f55713529..786060f9e99 100644 --- a/applications/tasks/src/modules/kt_resource_selectors.erl +++ b/applications/tasks/src/modules/kt_resource_selectors.erl @@ -30,11 +30,11 @@ ,<<"delete">> ]). --record(state, {db :: api_binary() - ,auth_account_id :: api_binary() +-record(state, {db :: kz_term:api_binary() + ,auth_account_id :: kz_term:api_binary() ,bulk_limit = 500 :: non_neg_integer() ,processed_rows = 0 :: non_neg_integer() - ,acc = [] :: ne_binaries() | kz_json:objects() + ,acc = [] :: kz_term:ne_binaries() | kz_json:objects() }). -type state() :: #state{}. @@ -52,15 +52,15 @@ init() -> -spec help(kz_json:object()) -> kz_json:object(). help(JObj) -> help(JObj, <>). --spec help(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec help(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). help(JObj, <>=Category) -> lists:foldl(fun(Action, J) -> help(J, Category, Action) end, JObj, ?ACTIONS). --spec help(kz_json:object(), ne_binary(), ne_binary()) -> kz_json:object(). +-spec help(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). help(JObj, <>=Category, Action) -> kz_json:set_value([Category, Action], kz_json:from_list(action(Action)), JObj). --spec action(ne_binary()) -> kz_proplist(). +-spec action(kz_term:ne_binary()) -> kz_term:proplist(). action(<<"import">>) -> [{<<"description">>, <<"Import stepswitch resource selectors">>} ,{<<"doc">>, <<"Creates stepswitch resource selectors from CSV file.">>} @@ -86,7 +86,7 @@ action(<<"delete">>) -> ]. %%% Verifiers --spec account_id(ne_binary()) -> boolean(). +-spec account_id(kz_term:ne_binary()) -> boolean(). account_id(?MATCH_ACCOUNT_RAW(_)) -> 'true'; account_id(_) -> 'false'. @@ -159,7 +159,7 @@ delete(_ExtraArgs, State, _Args) -> lager:error("wrong state: ~p", [State]), 'stop'. --spec cleanup(ne_binary(), any()) -> any(). +-spec cleanup(kz_term:ne_binary(), any()) -> any(). cleanup(<<"import">>, #state{db=Db, acc=Docs}) -> do_insert(Db, Docs), kz_datamgr:enable_change_notice(); @@ -171,7 +171,7 @@ cleanup(<<"delete">>, #state{db=Db, acc=Keys}) -> %%% Internal functions %%%=================================================================== --spec do_insert(api_binary(), kz_json:objects()) -> 'ok'. +-spec do_insert(kz_term:api_binary(), kz_json:objects()) -> 'ok'. do_insert(_Db, []) -> 'ok'; do_insert(Db, Docs) -> case kz_datamgr:save_docs(Db, Docs) of @@ -182,7 +182,7 @@ do_insert(Db, Docs) -> {'error', E} -> lager:error("error adding selectors: ~p",[E]) end. --spec do_delete(api_binary(), api_list()) -> 'ok'. +-spec do_delete(kz_term:api_binary(), kz_term:api_list()) -> 'ok'. do_delete(_Db, []) -> 'ok'; do_delete(Db, DelKeys) -> BulkLimit = kz_datamgr:max_bulk_insert(), @@ -216,15 +216,15 @@ do_delete_fold(Db, Keys, AccIDs) -> AccIDs end. --spec get_selectors_db(kz_tasks:extra_args()) -> api_binary(). +-spec get_selectors_db(kz_tasks:extra_args()) -> kz_term:api_binary(). get_selectors_db(#{account_id := AccountId ,auth_account_id := AuthAccountId }) -> true = kz_util:is_in_account_hierarchy(AuthAccountId, AccountId, true), kz_util:format_resource_selectors_db(AccountId). --spec split_keys(ne_binaries(), non_neg_integer()) -> [ne_binaries()]. --spec split_keys(ne_binaries(), [ne_binaries()], non_neg_integer()) -> [ne_binaries()]. +-spec split_keys(kz_term:ne_binaries(), non_neg_integer()) -> [kz_term:ne_binaries()]. +-spec split_keys(kz_term:ne_binaries(), [kz_term:ne_binaries()], non_neg_integer()) -> [kz_term:ne_binaries()]. split_keys(Keys, BlockSize) -> split_keys(Keys, [], BlockSize). split_keys([], Acc, _BlockSize) -> Acc; split_keys(Keys, Acc, BlockSize) when length(Keys) =< BlockSize -> [Keys ++ Acc]; @@ -232,14 +232,14 @@ split_keys(Keys, Acc, BlockSize) -> {Block, Rest} = lists:split(BlockSize, Keys), split_keys(Rest, [Block | Acc], BlockSize). --spec refresh_selectors_index(ne_binary()) -> 'ok'. +-spec refresh_selectors_index(kz_term:ne_binary()) -> 'ok'. refresh_selectors_index(Db) -> {'ok', _} = kz_datamgr:all_docs(Db, [{limit, 1}]), {'ok', _} = kz_datamgr:get_results(Db, <<"resource_selectors/resource_name_selector_listing">>, [{'limit', 1}]), 'ok'. --spec generate_selector_doc(ne_binary(), api_binary(), api_binary(), api_binary() - ,api_binary(), api_binary(), api_binary() +-spec generate_selector_doc(kz_term:ne_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary() + ,kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary() ) -> kz_json:object(). generate_selector_doc(AuthAccountId, Resource, Name, Selector, Value, Start, Stop) -> @@ -255,7 +255,7 @@ generate_selector_doc(AuthAccountId, Resource, Name, Selector, Value, Start, Sto ,{<<"pvt_created">>, kz_time:now_s()} ]). --spec init_db(ne_binary()) -> 'ok'. +-spec init_db(kz_term:ne_binary()) -> 'ok'. init_db(Db) when is_binary(Db) -> _ = kz_datamgr:db_create(Db), {'ok', _} = kz_datamgr:revise_doc_from_file(Db, 'crossbar', "views/resource_selectors.json"), diff --git a/applications/tasks/src/modules/kt_services.erl b/applications/tasks/src/modules/kt_services.erl index e926080b60f..fa8b21be511 100644 --- a/applications/tasks/src/modules/kt_services.erl +++ b/applications/tasks/src/modules/kt_services.erl @@ -49,7 +49,7 @@ init() -> tasks_bindings:bind_actions(<<"tasks."?CATEGORY>>, ?MODULE, ?ACTIONS). --spec output_header(ne_binary()) -> kz_tasks:output_header(). +-spec output_header(kz_term:ne_binary()) -> kz_tasks:output_header(). output_header(<<"descendant_quantities">>) -> [<<"account_id">> ,<<"year">> @@ -63,15 +63,15 @@ output_header(<<"descendant_quantities">>) -> -spec help(kz_json:object()) -> kz_json:object(). help(JObj) -> help(JObj, <>). --spec help(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec help(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). help(JObj, <>=Category) -> lists:foldl(fun(Action, J) -> help(J, Category, Action) end, JObj, ?ACTIONS). --spec help(kz_json:object(), ne_binary(), ne_binary()) -> kz_json:object(). +-spec help(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). help(JObj, <>=Category, Action) -> kz_json:set_value([Category, Action], kz_json:from_list(action(Action)), JObj). --spec action(ne_binary()) -> kz_proplist(). +-spec action(kz_term:ne_binary()) -> kz_term:proplist(). action(<<"descendant_quantities">>) -> [{<<"description">>, <<"List per-month descendant accounts quantities">>} ,{<<"doc">>, <<"Attempts to create a month-on-month listing of quantities used by descendant accounts.\n" @@ -118,7 +118,7 @@ descendant_quantities(_, [SubAccountMoDB | DescendantsMoDBs]) -> %%% Triggerables --spec cleanup(ne_binary()) -> ok. +-spec cleanup(kz_term:ne_binary()) -> ok. cleanup(?KZ_SERVICES_DB) -> lager:debug("checking ~s for abandoned accounts", [?KZ_SERVICES_DB]), cleanup_orphaned_services_docs(); @@ -129,7 +129,7 @@ cleanup(_SystemDb) -> ok. %%% Internal functions %%%=================================================================== --spec rows_for_quantities(ne_binary(), ne_binary(), ne_binary(), kz_json:object(), kz_json:object()) -> [kz_csv:mapped_row()]. +-spec rows_for_quantities(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), kz_json:object()) -> [kz_csv:mapped_row()]. rows_for_quantities(AccountId, YYYY, MM, BoM, EoM) -> lists:append( [quantities_for_items(AccountId, YYYY, MM, Category, BoMItem, EoMItem) @@ -138,7 +138,7 @@ rows_for_quantities(AccountId, YYYY, MM, BoM, EoM) -> EoMItem <- [kz_json:get_value(Category, EoM)] ]). --spec quantities_for_items(ne_binary(), ne_binary(), ne_binary(), ne_binary(), api_object(), api_object()) -> [kz_csv:mapped_row()]. +-spec quantities_for_items(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_object(), kz_term:api_object()) -> [kz_csv:mapped_row()]. quantities_for_items(AccountId, YYYY, MM, Category, BoMItem, EoMItem) -> [#{<<"account_id">> => AccountId ,<<"year">> => YYYY @@ -151,7 +151,7 @@ quantities_for_items(AccountId, YYYY, MM, Category, BoMItem, EoMItem) -> || Item <- fields(BoMItem, EoMItem) ]. --spec modb_service_quantities(ne_binary(), ne_binary()) -> kz_json:object(). +-spec modb_service_quantities(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). modb_service_quantities(MoDB, Id) -> case kz_datamgr:open_doc(MoDB, Id) of {'ok', JObj} -> kz_json:get_value(<<"quantities">>, JObj); @@ -160,7 +160,7 @@ modb_service_quantities(MoDB, Id) -> kz_json:new() end. --spec fields(api_object(), api_object()) -> ne_binaries(). +-spec fields(kz_term:api_object(), kz_term:api_object()) -> kz_term:ne_binaries(). fields('undefined', JObjB) -> fields(kz_json:new(), JObjB); fields(JObjA, 'undefined') -> @@ -168,7 +168,7 @@ fields(JObjA, 'undefined') -> fields(JObjA, JObjB) -> lists:usort(kz_json:get_keys(JObjA) ++ kz_json:get_keys(JObjB)). --spec maybe_integer_to_binary(ne_binary(), api_object()) -> api_non_neg_integer(). +-spec maybe_integer_to_binary(kz_term:ne_binary(), kz_term:api_object()) -> kz_term:api_non_neg_integer(). maybe_integer_to_binary(_, 'undefined') -> 'undefined'; maybe_integer_to_binary(Item, JObj) -> case kz_json:get_integer_value(Item, JObj) of @@ -191,7 +191,7 @@ cleanup_orphaned_services_docs([View|Views]) -> cleanup_orphaned_services_doc(View), cleanup_orphaned_services_docs(Views). --spec cleanup_orphaned_services_doc(kz_json:object() | ne_binary()) -> 'ok'. +-spec cleanup_orphaned_services_doc(kz_json:object() | kz_term:ne_binary()) -> 'ok'. cleanup_orphaned_services_doc(<<"_design/", _/binary>>) -> 'ok'; cleanup_orphaned_services_doc(AccountId=?NE_BINARY) -> case kz_datamgr:db_exists(kz_util:format_account_id(AccountId, 'encoded')) of diff --git a/applications/tasks/src/modules/kt_skel.erl b/applications/tasks/src/modules/kt_skel.erl index 348f8cef088..e2d90d68409 100644 --- a/applications/tasks/src/modules/kt_skel.erl +++ b/applications/tasks/src/modules/kt_skel.erl @@ -46,22 +46,22 @@ init() -> _ = tasks_bindings:bind(?TRIGGER_MINUTELY, ?MODULE, 'my_minute_job'), tasks_bindings:bind_actions(<<"tasks."?CATEGORY>>, ?MODULE, ?ACTIONS). --spec output_header(ne_binary()) -> kz_tasks:output_header(). +-spec output_header(kz_term:ne_binary()) -> kz_tasks:output_header(). output_header(<<"id2">>) -> [<<"Col1">>, <<"Col2">>]. -spec help(kz_json:object()) -> kz_json:object(). help(JObj) -> help(JObj, <>). --spec help(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec help(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). help(JObj, <>=Category) -> lists:foldl(fun(Action, J) -> help(J, Category, Action) end, JObj, ?ACTIONS). --spec help(kz_json:object(), ne_binary(), ne_binary()) -> kz_json:object(). +-spec help(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). help(JObj, <>=Category, Action) -> kz_json:set_value([Category, Action], kz_json:from_list(action(Action)), JObj). --spec action(ne_binary()) -> kz_proplist(). +-spec action(kz_term:ne_binary()) -> kz_term:proplist(). action(<<"id1">>) -> [{<<"description">>, <<"The identity task">>} ,{<<"doc">>, <<"Takes 1 column as input and return it as is.">>} @@ -76,7 +76,7 @@ action(<<"id2">>) -> ]. %%% Verifiers --spec col2(ne_binary()) -> boolean(). +-spec col2(kz_term:ne_binary()) -> boolean(). col2(?NE_BINARY) -> 'true'. %%% Appliers diff --git a/applications/tasks/src/modules/kt_token_auth.erl b/applications/tasks/src/modules/kt_token_auth.erl index 5265234faae..d96fde2a2d6 100644 --- a/applications/tasks/src/modules/kt_token_auth.erl +++ b/applications/tasks/src/modules/kt_token_auth.erl @@ -36,7 +36,7 @@ init() -> clean_expired() -> clean_expired(kz_time:now_s() - ?LOOP_TIMEOUT). --spec clean_expired(gregorian_seconds()) -> 'ok'. +-spec clean_expired(kz_time:gregorian_seconds()) -> 'ok'. clean_expired(CreatedBefore) -> ViewOpts = [{'startkey', 0} ,{'endkey', CreatedBefore} diff --git a/applications/tasks/src/modules/kt_user_auth.erl b/applications/tasks/src/modules/kt_user_auth.erl index 5b8c23285ff..562b76ca3ac 100644 --- a/applications/tasks/src/modules/kt_user_auth.erl +++ b/applications/tasks/src/modules/kt_user_auth.erl @@ -32,7 +32,7 @@ init() -> %%% Triggerables %% @public --spec cleanup_reset_ids(ne_binary()) -> 'ok'. +-spec cleanup_reset_ids(kz_term:ne_binary()) -> 'ok'. cleanup_reset_ids(AccountDb) -> ViewOptions = [{'key', ?RESET_PVT_TYPE} ,'include_docs' @@ -49,7 +49,7 @@ cleanup_reset_ids(AccountDb) -> %%% Internal functions %%%=================================================================== --spec maybe_delete_doc(ne_binary(), kz_json:object()) -> 'ok'. +-spec maybe_delete_doc(kz_term:ne_binary(), kz_json:object()) -> 'ok'. maybe_delete_doc(AccountDb, ResetIdDoc) -> TwoDaysAgo = kz_time:now_s() - 2 * ?SECONDS_IN_DAY, Created = kz_doc:created(ResetIdDoc), diff --git a/applications/tasks/src/modules/kt_webhooks.erl b/applications/tasks/src/modules/kt_webhooks.erl index d08eae7a24f..53e7b6286c9 100644 --- a/applications/tasks/src/modules/kt_webhooks.erl +++ b/applications/tasks/src/modules/kt_webhooks.erl @@ -29,7 +29,7 @@ init() -> %%% Triggerables --spec cleanup(ne_binary()) -> 'ok'. +-spec cleanup(kz_term:ne_binary()) -> 'ok'. cleanup(?KZ_WEBHOOKS_DB) -> lager:debug("checking ~s for abandoned accounts", [?KZ_WEBHOOKS_DB]), cleanup_orphaned_hooks(); @@ -68,7 +68,7 @@ cleanup_orphaned_hooks(Accounts) -> andalso lager:debug("removed ~p accounts' webhooks", [length(_Rm)]), 'ok'. --spec delete_account_webhooks(ne_binary()) -> 'ok'. +-spec delete_account_webhooks(kz_term:ne_binary()) -> 'ok'. delete_account_webhooks(AccountId) -> case fetch_account_hooks(AccountId) of {'ok', []} -> 'ok'; @@ -79,7 +79,7 @@ delete_account_webhooks(AccountId) -> lager:debug("deleted ~p hooks from account ~s", [length(ViewJObjs), AccountId]) end. --spec fetch_account_hooks(ne_binary()) -> kazoo_data:get_results_return(). +-spec fetch_account_hooks(kz_term:ne_binary()) -> kazoo_data:get_results_return(). fetch_account_hooks(AccountId) -> kz_datamgr:get_results(?KZ_WEBHOOKS_DB ,<<"webhooks/accounts_listing">> diff --git a/applications/tasks/src/notify_resend_maintenance.erl b/applications/tasks/src/notify_resend_maintenance.erl index 4766511a598..3fd3a74d03d 100644 --- a/applications/tasks/src/notify_resend_maintenance.erl +++ b/applications/tasks/src/notify_resend_maintenance.erl @@ -55,7 +55,7 @@ pending() -> %% Same as pending/2 without showing details %% @end %%-------------------------------------------------------------------- --spec pending(ne_binary()) -> 'no_return'. +-spec pending(kz_term:ne_binary()) -> 'no_return'. pending(ShowCount) -> pending(ShowCount, <<"false">>). @@ -69,7 +69,7 @@ pending(ShowCount) -> %% Details: Whether or not to show notifications details %% @end %%-------------------------------------------------------------------- --spec pending(ne_binary(), ne_binary()) -> 'no_return'. +-spec pending(kz_term:ne_binary(), kz_term:ne_binary()) -> 'no_return'. pending(ShowCount, <<"true">>) -> Total = get_total([{group_level, 0}]), RunningIds = [kz_doc:id(J) || J <- kz_notify_resend:running()], @@ -104,7 +104,7 @@ pending(ShowCount, _Details) -> %% process. %% @end %%-------------------------------------------------------------------- --spec pending_by_type(ne_binary()) -> 'no_return'. +-spec pending_by_type(kz_term:ne_binary()) -> 'no_return'. pending_by_type(Type) -> Total = get_total([{startkey, [Type, 0]} ,{endkey, [Type, kz_time:now_s()]} @@ -136,7 +136,7 @@ failed() -> %% Same as failed/2 without showing details %% @end %%-------------------------------------------------------------------- --spec failed(ne_binary()) -> 'no_return'. +-spec failed(kz_term:ne_binary()) -> 'no_return'. failed(ShowCount) -> failed(ShowCount, <<"false">>). @@ -149,7 +149,7 @@ failed(ShowCount) -> %% Details: Whether or not to show notifications details %% @end %%-------------------------------------------------------------------- --spec failed(ne_binary(), ne_binary()) -> 'no_return'. +-spec failed(kz_term:ne_binary(), kz_term:ne_binary()) -> 'no_return'. failed(ShowCount, <<"true">>) -> Total = get_total([{group_level, 0}], ?FAILED_TYPE_VIEW), ViewOptions = [{'limit', ShowCount} @@ -176,7 +176,7 @@ failed(ShowCount, _Details) -> %% Show failed notification by type, limited to first 100 %% @end %%-------------------------------------------------------------------- --spec failed_by_type(ne_binary()) -> 'no_return'. +-spec failed_by_type(kz_term:ne_binary()) -> 'no_return'. failed_by_type(Type) -> Total = get_total([{startkey, [Type, 0]} ,{endkey, [Type, kz_time:now_s()]} @@ -198,7 +198,7 @@ failed_by_type(Type) -> %% Send the notification by Id %% @end %%-------------------------------------------------------------------- --spec send_notify(ne_binary()) -> 'no_return'. +-spec send_notify(kz_term:ne_binary()) -> 'no_return'. send_notify(Id) -> case kz_notify_resend:send_single(Id) of {'ok', JObj} -> @@ -218,7 +218,7 @@ send_notify(Id) -> %% Show details for the notification by Id %% @end %%-------------------------------------------------------------------- --spec notify_info(ne_binary()) -> 'no_return'. +-spec notify_info(kz_term:ne_binary()) -> 'no_return'. notify_info(Id) -> _ = case kz_datamgr:open_doc(?KZ_PENDING_NOTIFY_DB, Id) of {'ok', JObj} -> @@ -228,7 +228,7 @@ notify_info(Id) -> end, 'no_return'. --spec delete(ne_binary()) -> 'no_return'. +-spec delete(kz_term:ne_binary()) -> 'no_return'. delete(Id) -> case kz_datamgr:del_doc(?KZ_PENDING_NOTIFY_DB, Id) of {'ok', _} -> io:format("notification ~s has been deleted~n", [Id]); @@ -236,7 +236,7 @@ delete(Id) -> end, 'no_return'. --spec delete_older_than(gregorian_seconds()) -> 'no_return'. +-spec delete_older_than(kz_time:gregorian_seconds()) -> 'no_return'. delete_older_than(Timestamp) -> TsTamp = kz_term:to_integer(Timestamp), ViewOptions = [{startkey, [0]} @@ -254,7 +254,7 @@ delete_older_than(Timestamp) -> bulk_delete(ToBeDeleted), 'no_return'. --spec delete_between(gregorian_seconds(), gregorian_seconds()) -> 'no_return'. +-spec delete_between(kz_time:gregorian_seconds(), kz_time:gregorian_seconds()) -> 'no_return'. delete_between(StartTimestamp, EndTimestamp) -> Start = kz_term:to_integer(StartTimestamp), End = kz_term:to_integer(EndTimestamp), @@ -307,11 +307,11 @@ statistics() -> io:format("Total running: ~b~n", [length(kz_notify_resend:running())]), 'no_return'. --spec get_total(kz_proplist()) -> non_neg_integer(). +-spec get_total(kz_term:proplist()) -> non_neg_integer(). get_total(ViewOptions) -> get_total(ViewOptions, <<"pending_notify/pending_by_type">>). --spec get_total(kz_proplist(), ne_binary()) -> non_neg_integer(). +-spec get_total(kz_term:proplist(), kz_term:ne_binary()) -> non_neg_integer(). get_total(ViewOptions, View) -> case kz_datamgr:get_results(?KZ_PENDING_NOTIFY_DB, View, ViewOptions) of {'ok', Rs} -> @@ -345,7 +345,7 @@ print_job_table(ViewOptions, RunningIds, View) -> end, ?JOB_TABLE_EDGE. --spec format_modified_date(kz_json:object()) -> ne_binary(). +-spec format_modified_date(kz_json:object()) -> kz_term:ne_binary(). format_modified_date(JObj) -> Modified = kz_json:get_integer_value(<<"modified">>, JObj, kz_json:get_integer_value(<<"pvt_modified">>, JObj)), RetryAfter = kz_json:get_integer_value(<<"retry_after">>, JObj, 0), diff --git a/applications/tasks/src/tasks_app.erl b/applications/tasks/src/tasks_app.erl index 1c74e580131..19668da661f 100644 --- a/applications/tasks/src/tasks_app.erl +++ b/applications/tasks/src/tasks_app.erl @@ -17,7 +17,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = kapi_self:declare_exchanges(), _ = kapi_tasks:declare_exchanges(), diff --git a/applications/tasks/src/tasks_bindings.erl b/applications/tasks/src/tasks_bindings.erl index d0c907fc240..3f93049e535 100644 --- a/applications/tasks/src/tasks_bindings.erl +++ b/applications/tasks/src/tasks_bindings.erl @@ -44,7 +44,7 @@ -include("tasks.hrl"). --type payload() :: list() | kz_json:object() | ne_binary(). +-type payload() :: list() | kz_json:object() | kz_term:ne_binary(). %%%=================================================================== %%% API @@ -57,7 +57,7 @@ apply(API, Args) -> ?MODULE:apply(API, Action, Args). %% @public --spec apply(kz_json:object(), ne_binary(), list()) -> list(). +-spec apply(kz_json:object(), kz_term:ne_binary(), list()) -> list(). apply(API, Action, Args) -> Category = kz_json:get_value(<<"category">>, API), Route = <<"tasks.", Category/binary, ".", Action/binary>>, @@ -72,13 +72,13 @@ apply(API, Action, Args) -> %% is the payload, possibly modified %% @end %%-------------------------------------------------------------------- --type map_results() :: kz_proplist(). --spec map(ne_binary(), payload()) -> map_results(). +-type map_results() :: kz_term:proplist(). +-spec map(kz_term:ne_binary(), payload()) -> map_results(). map(Routing, Payload) -> kazoo_bindings:map(Routing, Payload). --spec pmap(ne_binary(), payload()) -> map_results(). --spec pmap(ne_binary(), payload(), kazoo_bindings:kz_rt_options()) -> map_results(). +-spec pmap(kz_term:ne_binary(), payload()) -> map_results(). +-spec pmap(kz_term:ne_binary(), payload(), kazoo_bindings:kz_rt_options()) -> map_results(). pmap(Routing, Payload) -> kazoo_bindings:pmap(Routing, Payload). @@ -93,7 +93,7 @@ pmap(Routing, Payload, Options) -> %% @end %%-------------------------------------------------------------------- -type fold_results() :: payload(). --spec fold(ne_binary(), payload()) -> fold_results(). +-spec fold(kz_term:ne_binary(), payload()) -> fold_results(). fold(Routing, Payload) -> kazoo_bindings:fold(Routing, Payload). @@ -159,19 +159,19 @@ filter_out_succeeded(Term) -> kz_term:is_empty(Term). -type bind_result() :: 'ok' | {'error', 'exists'}. -type bind_results() :: [bind_result()]. --spec bind(ne_binary() | ne_binaries(), atom(), atom()) -> +-spec bind(kz_term:ne_binary() | kz_term:ne_binaries(), atom(), atom()) -> bind_result() | bind_results(). bind(Bindings, Module, Fun) -> bind(Bindings, Module, Fun, 'undefined'). --spec bind(ne_binary() | ne_binaries(), atom(), atom(), any()) -> +-spec bind(kz_term:ne_binary() | kz_term:ne_binaries(), atom(), atom(), any()) -> bind_result() | bind_results(). bind([_|_]=Bindings, Module, Fun, Payload) -> [bind(Binding, Module, Fun, Payload) || Binding <- Bindings]; bind(Binding, Module, Fun, Payload) when is_binary(Binding) -> kazoo_bindings:bind(Binding, Module, Fun, Payload). --spec bind_actions(ne_binary(), module(), ne_binaries()) -> 'ok'. +-spec bind_actions(kz_term:ne_binary(), module(), kz_term:ne_binaries()) -> 'ok'. bind_actions(RoutePrefix, Module, Actions) -> lists:foreach(fun (Action) -> bind(<> @@ -182,11 +182,11 @@ bind_actions(RoutePrefix, Module, Actions) -> ,Actions ). --spec unbind(ne_binary() | ne_binaries(), atom(), atom()) -> 'ok'. +-spec unbind(kz_term:ne_binary() | kz_term:ne_binaries(), atom(), atom()) -> 'ok'. unbind(Bindings, Module, Fun) -> unbind(Bindings, Module, Fun, 'undefined'). --spec unbind(ne_binary() | ne_binaries(), atom(), atom(), any()) -> 'ok'. +-spec unbind(kz_term:ne_binary() | kz_term:ne_binaries(), atom(), atom(), any()) -> 'ok'. unbind([_|_]=Bindings, Module, Fun, Payload) -> _ = [unbind(Binding, Module, Fun, Payload) || Binding <- Bindings], 'ok'; @@ -198,21 +198,21 @@ unbind(Binding, Module, Fun, Payload) when is_binary(Binding) -> flush() -> lists:foreach(fun kazoo_bindings:flush_mod/1, modules_loaded()). --spec flush(ne_binary()) -> 'ok'. +-spec flush(kz_term:ne_binary()) -> 'ok'. flush(Binding) -> kazoo_bindings:flush(Binding). -spec filter(kazoo_bindings:filter_fun()) -> 'ok'. filter(Predicate) -> kazoo_bindings:filter(Predicate). --spec modules_loaded() -> atoms(). +-spec modules_loaded() -> kz_term:atoms(). modules_loaded() -> lists:usort( [Mod || Mod <- kazoo_bindings:modules_loaded(), is_task_module(Mod) ]). --spec is_task_module(ne_binary() | atom()) -> boolean(). +-spec is_task_module(kz_term:ne_binary() | atom()) -> boolean(). is_task_module(<<"kt_", _/binary>>) -> 'true'; is_task_module(Mod) when is_atom(Mod) -> diff --git a/applications/tasks/src/tasks_listener.erl b/applications/tasks/src/tasks_listener.erl index dd8d5044c0b..128b42ea332 100644 --- a/applications/tasks/src/tasks_listener.erl +++ b/applications/tasks/src/tasks_listener.erl @@ -56,7 +56,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER ,[{'bindings', ?BINDINGS} @@ -75,7 +75,7 @@ start_link() -> %% @doc %% @end %%-------------------------------------------------------------------- --spec handle_start_req(kz_json:object(), kz_proplist()) -> ok. +-spec handle_start_req(kz_json:object(), kz_term:proplist()) -> ok. handle_start_req(JObj, _Props) -> true = kapi_tasks:start_req_v(JObj), Help = @@ -97,7 +97,7 @@ handle_start_req(JObj, _Props) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec handle_stop_req(kz_json:object(), kz_proplist()) -> ok. +-spec handle_stop_req(kz_json:object(), kz_term:proplist()) -> ok. handle_stop_req(JObj, _Props) -> true = kapi_tasks:stop_req_v(JObj), Help = @@ -118,7 +118,7 @@ handle_stop_req(JObj, _Props) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec handle_remove_req(kz_json:object(), kz_proplist()) -> ok. +-spec handle_remove_req(kz_json:object(), kz_term:proplist()) -> ok. handle_remove_req(JObj, _Props) -> true = kapi_tasks:remove_req_v(JObj), Help = @@ -156,7 +156,7 @@ init([]) -> %% Handling call messages %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -166,7 +166,7 @@ handle_call(_Request, _From, State) -> %% Handling cast messages %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> {'noreply', State}. @@ -176,7 +176,7 @@ handle_cast(_Msg, State) -> %% Handling all non call/cast messages %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -186,7 +186,7 @@ handle_info(_Info, State) -> %% Allows listener to pass options to handlers %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/tasks/src/tasks_maintenance.erl b/applications/tasks/src/tasks_maintenance.erl index 2c70dab08ac..8d65e24406b 100644 --- a/applications/tasks/src/tasks_maintenance.erl +++ b/applications/tasks/src/tasks_maintenance.erl @@ -28,21 +28,21 @@ help() -> print_json(kz_tasks_help:help()). --spec help(text()) -> 'no_return'. +-spec help(kz_term:text()) -> 'no_return'. help(Category) -> case kz_tasks_help:help(Category) of {'ok', JObj} -> print_json(JObj); {'error', Reason} -> print_error(Reason) end. --spec help(text(), text()) -> 'no_return'. +-spec help(kz_term:text(), kz_term:text()) -> 'no_return'. help(Category, Action) -> case kz_tasks_help:help(Category, Action) of {'ok', JObj} -> print_json(JObj); {'error', Reason} -> print_error(Reason) end. --spec add(text(), text(), text(), text(), text()) -> 'no_return'. +-spec add(kz_term:text(), kz_term:text(), kz_term:text(), kz_term:text(), kz_term:text()) -> 'no_return'. add(AuthAccount, Account, Category, Action, CSVFile) -> AuthAccountId = kz_util:format_account_id(AuthAccount), AccountId = kz_util:format_account_id(Account), @@ -58,7 +58,7 @@ add(AuthAccount, Account, Category, Action, CSVFile) -> print_error(Reason) end. --spec add(text(), text(), text(), text()) -> 'no_return'. +-spec add(kz_term:text(), kz_term:text(), kz_term:text(), kz_term:text()) -> 'no_return'. add(AuthAccount, Account, Category, Action) -> AuthAccountId = kz_util:format_account_id(AuthAccount), AccountId = kz_util:format_account_id(Account), @@ -80,42 +80,42 @@ tasks() -> Tasks = kz_tasks:all(), print_json(Tasks). --spec tasks(text()) -> 'no_return'. +-spec tasks(kz_term:text()) -> 'no_return'. tasks(Account) -> AccountId = kz_util:format_account_id(Account), Tasks = kz_tasks:all(AccountId), print_json(Tasks). --spec task(text()) -> 'no_return'. +-spec task(kz_term:text()) -> 'no_return'. task(TaskId) -> case kz_tasks:read(TaskId) of {'ok', JObj} -> print_json(JObj); {'error', Reason} -> print_error(Reason) end. --spec task_input(text()) -> 'no_return'. +-spec task_input(kz_term:text()) -> 'no_return'. task_input(TaskId) -> attachment(TaskId, ?KZ_TASKS_ANAME_IN). --spec task_output(text()) -> 'no_return'. +-spec task_output(kz_term:text()) -> 'no_return'. task_output(TaskId) -> attachment(TaskId, ?KZ_TASKS_ANAME_OUT). --spec start(text()) -> 'no_return'. +-spec start(kz_term:text()) -> 'no_return'. start(TaskId) -> case kz_tasks_scheduler:start(TaskId) of {'ok', StartedTask} -> print_json(StartedTask); {'error', Reason} -> print_error(Reason) end. --spec restart(text()) -> 'no_return'. +-spec restart(kz_term:text()) -> 'no_return'. restart(TaskId) -> case kz_tasks_scheduler:restart(TaskId) of {'ok', RestartedTask} -> print_json(RestartedTask); {'error', Reason} -> print_error(Reason) end. --spec remove(text()) -> 'no_return'. +-spec remove(kz_term:text()) -> 'no_return'. remove(TaskId) -> case kz_tasks_scheduler:remove(TaskId) of {'ok', RemovedTask} -> print_json(RemovedTask); @@ -127,7 +127,7 @@ start_cleanup_pass() -> _ = kz_tasks_trigger:browse_dbs_for_triggers(?MODULE), no_return. --spec cleanup_soft_deletes(text()) -> no_return. +-spec cleanup_soft_deletes(kz_term:text()) -> no_return. cleanup_soft_deletes(Account) -> _ = kt_cleanup:cleanup_soft_deletes(Account), no_return. @@ -148,7 +148,7 @@ print_error(Reason) -> io:format("ERROR: ~p\n", [Reason]), 'no_return'. --spec attachment(kz_tasks:id(), ne_binary()) -> no_return. +-spec attachment(kz_tasks:id(), kz_term:ne_binary()) -> no_return. attachment(TaskId, AName) -> case kz_tasks:read(TaskId) of {'ok', _JObj} -> @@ -161,7 +161,7 @@ attachment(TaskId, AName) -> {'error', Reason} -> print_error(Reason) end. --spec new_task(ne_binary(), ne_binary(), ne_binary(), ne_binary(), pos_integer(), ne_binary(), ne_binary()) -> +-spec new_task(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), pos_integer(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'no_return'. new_task(AuthAccountId, AccountId, Category, Action, TotalRows, CSVBin, CSVName) -> case kz_tasks:new(AuthAccountId, AccountId, Category, Action, TotalRows, CSVBin, CSVName) of @@ -181,7 +181,7 @@ new_task(AuthAccountId, AccountId, Category, Action, TotalRows, CSVBin, CSVName) handle_new_task_error(Reason, Category, Action) end. --spec handle_new_task_error(atom() | kz_json:object(), ne_binary(), ne_binary()) -> 'no_return'. +-spec handle_new_task_error(atom() | kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'no_return'. handle_new_task_error('unknown_category_action', Category, Action) -> print_error(<<"No such category / action: ", Category/binary, " ", Action/binary>>); handle_new_task_error(JObj, _, _) -> diff --git a/applications/tasks/src/tasks_sup.erl b/applications/tasks/src/tasks_sup.erl index 9af1dd20f26..497df2f8fef 100644 --- a/applications/tasks/src/tasks_sup.erl +++ b/applications/tasks/src/tasks_sup.erl @@ -39,7 +39,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -56,7 +56,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/teletype/src/teletype.hrl b/applications/teletype/src/teletype.hrl index 0ebf37220a0..29f5d456dab 100644 --- a/applications/teletype/src/teletype.hrl +++ b/applications/teletype/src/teletype.hrl @@ -20,32 +20,32 @@ -type mime_tuples() :: [mimemail:mimetuple()]. %% {ContentType, Filename, Content} --type attachment() :: {ne_binary(), ne_binary(), ne_binary()}. +-type attachment() :: {kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()}. -type attachments() :: [attachment()]. %% {ContentType, Content} --type rendered_template() :: {ne_binary(), iolist()}. +-type rendered_template() :: {kz_term:ne_binary(), iolist()}. -type rendered_templates() :: [rendered_template()]. %% {"to"/"cc"/etc, [Address,...]} --type email_map() :: [{ne_binary(), api_ne_binaries()}]. +-type email_map() :: [{kz_term:ne_binary(), kz_term:api_ne_binaries()}]. -type init_param() :: {'macros', kz_json:object()} | - {'subject', ne_binary()} | - {'category', ne_binary()} | - {'friendly_name', ne_binary()} | + {'subject', kz_term:ne_binary()} | + {'category', kz_term:ne_binary()} | + {'friendly_name', kz_term:ne_binary()} | {'to', kz_json:object()} | {'cc', kz_json:object()} | {'bcc', kz_json:object()} | - {'from', ne_binary()} | - {'reply_to', api_binary()}. + {'from', kz_term:ne_binary()} | + {'reply_to', kz_term:api_binary()}. -type init_params() :: [init_param(),...]. -type template_response() :: 'ok' | - {'disabled', ne_binary()} | - {'ignored', ne_binary()} | - {'completed', ne_binary()} | - {'failed', ne_binary(), any()}. + {'disabled', kz_term:ne_binary()} | + {'ignored', kz_term:ne_binary()} | + {'completed', kz_term:ne_binary()} | + {'failed', kz_term:ne_binary(), any()}. -type template_responses() :: [template_response()]. -define(TEXT_PLAIN, <<"text/plain">>). @@ -225,10 +225,10 @@ ++ ?SYSTEM_MACROS ). --record(email_receipt, {to :: ne_binaries() | ne_binary() - ,from :: ne_binary() - ,call_id :: ne_binary() - ,timestamp :: gregorian_seconds() +-record(email_receipt, {to :: kz_term:ne_binaries() | kz_term:ne_binary() + ,from :: kz_term:ne_binary() + ,call_id :: kz_term:ne_binary() + ,timestamp :: kz_time:gregorian_seconds() }). -type email_receipt() :: #email_receipt{}. diff --git a/applications/teletype/src/teletype_app.erl b/applications/teletype/src/teletype_app.erl index 62a39e6d253..c574728bd77 100644 --- a/applications/teletype/src/teletype_app.erl +++ b/applications/teletype/src/teletype_app.erl @@ -18,7 +18,7 @@ %% Implement the application start behaviour %% @end %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = declare_exchanges(), _ = kz_datamgr:revise_doc_from_file(?KZ_CONFIG_DB, 'teletype', <<"views/notifications.json">>), diff --git a/applications/teletype/src/teletype_bindings.erl b/applications/teletype/src/teletype_bindings.erl index 7881f14989a..79bafb89378 100644 --- a/applications/teletype/src/teletype_bindings.erl +++ b/applications/teletype/src/teletype_bindings.erl @@ -18,14 +18,14 @@ -define(SERVER, ?MODULE). -define(ROUTING_KEY(Category, Name), <<"teletype.", Category/binary, ".", Name/binary>>). --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> start_modules(), garbage_collect(self()), 'ignore'. --spec bind(ne_binary(), module(), atom()) -> 'ok'. --spec bind(api_binary(), api_binary(), module(), atom()) -> 'ok'. +-spec bind(kz_term:ne_binary(), module(), atom()) -> 'ok'. +-spec bind(kz_term:api_binary(), kz_term:api_binary(), module(), atom()) -> 'ok'. bind(EventName, Module, Fun) -> bind(<<"notification">>, EventName, Module, Fun). bind(EventCategory, EventName, Module, Fun) -> @@ -66,7 +66,7 @@ notification(JObj) -> maybe_send_update(JObj, RoutingKey, Map) end. --spec maybe_send_update(kz_json:object(), ne_binary(), map()) -> 'ok'. +-spec maybe_send_update(kz_json:object(), kz_term:ne_binary(), map()) -> 'ok'. maybe_send_update(JObj, RoutingKey, #{'completed' := _Completed}=Map) -> %% for now we just only care about at least one success print_result(RoutingKey, Map), @@ -82,7 +82,7 @@ maybe_send_update(JObj, RoutingKey, Map) -> Metadata = kz_json:from_list_recursive(maps:to_list(Map)), teletype_util:send_update(JObj, <<"completed">>, 'undefined', Metadata). --spec print_result(ne_binary(), map()) -> 'ok'. +-spec print_result(kz_term:ne_binary(), map()) -> 'ok'. print_result(RoutingKey, Map) -> Completed = erlang:length(maps:get('completed', Map, [])), Disabled = erlang:length(maps:get('disabled', Map, [])), @@ -92,7 +92,7 @@ print_result(RoutingKey, Map) -> ,[RoutingKey, Completed, Failed, Ignored, Disabled, maps:to_list(Map)] ). --spec check_result(any(), {ne_binary(), map()}) -> {ne_binary(), map()}. +-spec check_result(any(), {kz_term:ne_binary(), map()}) -> {kz_term:ne_binary(), map()}. check_result('ok', {RoutingKey, Map}) -> {RoutingKey, maps:update_with('completed', update_with(RoutingKey), [RoutingKey], Map)}; diff --git a/applications/teletype/src/teletype_farms_sup.erl b/applications/teletype/src/teletype_farms_sup.erl index 37ba5d75c28..25bc130a50b 100644 --- a/applications/teletype/src/teletype_farms_sup.erl +++ b/applications/teletype/src/teletype_farms_sup.erl @@ -41,7 +41,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -62,7 +62,7 @@ render_farm_name() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/teletype/src/teletype_fax_util.erl b/applications/teletype/src/teletype_fax_util.erl index 8f789caddc3..8939a1f6028 100644 --- a/applications/teletype/src/teletype_fax_util.erl +++ b/applications/teletype/src/teletype_fax_util.erl @@ -33,7 +33,7 @@ add_data(DataJObj) -> ]), kz_json:set_values(Values, DataJObj). --spec add_attachments(kz_json:object(), kz_proplist(), boolean()) -> {kz_proplist(), attachments()}. +-spec add_attachments(kz_json:object(), kz_term:proplist(), boolean()) -> {kz_term:proplist(), attachments()}. add_attachments(DataJObj, Macros, ShouldTerminate) -> IsPreview = teletype_util:is_preview(DataJObj), FaxDoc = kz_json:get_value(<<"fax_doc">>, DataJObj), @@ -46,7 +46,7 @@ add_attachments(DataJObj, Macros, ShouldTerminate) -> Attachments -> {add_document_data(FaxDoc, Macros, Attachments), Attachments} end. --spec maybe_terminate(kz_proplist(), boolean(), boolean()) -> {kz_proplist(), attachments()}. +-spec maybe_terminate(kz_term:proplist(), boolean(), boolean()) -> {kz_term:proplist(), attachments()}. maybe_terminate(Macros, _, 'true') -> lager:debug("this is a preview, no attachments"), {Macros, []}; @@ -57,7 +57,7 @@ maybe_terminate(Macros, 'false', 'false') -> lager:debug("No attachments were found for this fax"), {Macros, []}. --spec add_document_data(kz_json:object(), kz_proplist(), attachments()) -> kz_proplist(). +-spec add_document_data(kz_json:object(), kz_term:proplist(), attachments()) -> kz_term:proplist(). add_document_data(FaxDoc, Macros, [{ContentType, Filename, Bin}]) -> FaxDocProps = kz_json:to_proplist(kz_doc:public_fields(FaxDoc)), Values = @@ -70,7 +70,7 @@ add_document_data(FaxDoc, Macros, [{ContentType, Filename, Bin}]) -> FaxMacros = props:set_values(Values, props:get_value(<<"fax">>, Macros, [])), props:set_value(<<"fax">>, FaxMacros, Macros). --spec to_email_addresses(kz_json:object(), ne_binary()) -> api_binaries(). +-spec to_email_addresses(kz_json:object(), kz_term:ne_binary()) -> kz_term:api_binaries(). to_email_addresses(DataJObj, TemplateId) -> BoxEmailPath = case TemplateId of <<"fax_inbound", _/binary>> -> @@ -93,7 +93,7 @@ to_email_addresses(DataJObj, TemplateId) -> lager:debug("found emails: ~p", [Found]), Found. --spec to_email_addresses(kz_json:object(), ne_binary(), ne_binary() | api_binaries()) -> api_binaries(). +-spec to_email_addresses(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary() | kz_term:api_binaries()) -> kz_term:api_binaries(). to_email_addresses(_, _, ?NE_BINARY=Email) -> [Email]; to_email_addresses(_, _, Emails) @@ -156,7 +156,7 @@ maybe_get_fax_doc(DataJObj, 'false') -> {'error', _} -> kz_json:new() end. --spec get_fax_doc(ne_binary(), api_binary()) -> {'ok', kz_json:object()} | {'error', any()}. +-spec get_fax_doc(kz_term:ne_binary(), kz_term:api_binary()) -> {'ok', kz_json:object()} | {'error', any()}. get_fax_doc(_, 'undefined') -> lager:debug("undefined fax_id"), {'error', 'not_found'}; @@ -170,7 +170,7 @@ get_fax_doc(Db, Id) -> Error end. --spec find_timezone(api_ne_binary() | kz_json:object(), kz_json:object()) -> ne_binary(). +-spec find_timezone(kz_term:api_ne_binary() | kz_json:object(), kz_json:object()) -> kz_term:ne_binary(). find_timezone('undefined', FaxBoxJObj) -> kzd_fax_box:timezone(FaxBoxJObj); find_timezone(Timezone, _FaxBoxJObj) when is_binary(Timezone) -> @@ -187,7 +187,7 @@ find_timezone(DataJObj, FaxBoxJObj) -> %%% Attachment Utilities %%%=================================================================== --spec fax_db(kz_json:object(), api_ne_binary()) -> ne_binary(). +-spec fax_db(kz_json:object(), kz_term:api_ne_binary()) -> kz_term:ne_binary(). fax_db(DataJObj, FaxId) -> case kapi_notifications:account_db(DataJObj, 'true') of 'undefined' -> @@ -195,13 +195,13 @@ fax_db(DataJObj, FaxId) -> Db -> maybe_get_fax_db_from_id(Db, FaxId) end. --spec maybe_get_fax_db_from_id(api_ne_binary(), api_ne_binary()) -> ne_binary(). +-spec maybe_get_fax_db_from_id(kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> kz_term:ne_binary(). maybe_get_fax_db_from_id('undefined', _) -> ?KZ_FAXES_DB; maybe_get_fax_db_from_id(?MATCH_MODB_SUFFIX_ENCODED(_, _, _)=Db, _) -> Db; maybe_get_fax_db_from_id(Db, ?MATCH_MODB_PREFIX(Year, Month, _)) -> kazoo_modb:get_modb(kz_util:format_account_id(Db), Year, Month); maybe_get_fax_db_from_id(Db, _) -> Db. --spec maybe_fetch_attachments(kz_json:object(), kz_json:object(), kz_proplist(), boolean()) -> attachments(). +-spec maybe_fetch_attachments(kz_json:object(), kz_json:object(), kz_term:proplist(), boolean()) -> attachments(). maybe_fetch_attachments(_, _, _, 'true') -> []; maybe_fetch_attachments(DataJObj, FaxJObj, Macros, 'false') -> @@ -221,7 +221,7 @@ maybe_fetch_attachments(DataJObj, FaxJObj, Macros, 'false') -> [] end. --spec maybe_convert_attachment(kz_json:object(), kz_proplist(), api_binary(), binary()) -> attachments(). +-spec maybe_convert_attachment(kz_json:object(), kz_term:proplist(), kz_term:api_binary(), binary()) -> attachments(). maybe_convert_attachment(DataJObj, Macros, ContentType, Bin) -> ToFormat = kapps_config:get_ne_binary(?FAX_CONFIG_CAT, <<"attachment_format">>, <<"pdf">>), FromFormat = from_format_from_content_type(ContentType), @@ -236,7 +236,7 @@ maybe_convert_attachment(DataJObj, Macros, ContentType, Bin) -> [] end. --spec from_format_from_content_type(ne_binary()) -> ne_binary(). +-spec from_format_from_content_type(kz_term:ne_binary()) -> kz_term:ne_binary(). from_format_from_content_type(<<"application/pdf">>) -> <<"pdf">>; from_format_from_content_type(<<"image/tiff">>) -> <<"tif">>; from_format_from_content_type('undefined') -> <<"tif">>; @@ -244,12 +244,12 @@ from_format_from_content_type(ContentType) -> [_Type, SubType] = binary:split(ContentType, <<"/">>), SubType. --spec content_type_from_extension(ne_binary()) -> ne_binary(). +-spec content_type_from_extension(kz_term:ne_binary()) -> kz_term:ne_binary(). content_type_from_extension(Ext) -> {Type, SubType, _} = cow_mimetypes:all(Ext), <>. --spec get_file_name(kz_proplist(), ne_binary()) -> ne_binary(). +-spec get_file_name(kz_term:proplist(), kz_term:ne_binary()) -> kz_term:ne_binary(). get_file_name(Macros, Ext) -> CallerIdMacros = props:get_value(<<"caller_id">>, Macros), CallerID = @@ -265,7 +265,7 @@ get_file_name(Macros, Ext) -> FName = list_to_binary([CallerID, "_", kz_time:pretty_print_datetime(LocalDateTime), ".", Ext]), re:replace(kz_term:to_lower_binary(FName), <<"\\s+">>, <<"_">>, [{'return', 'binary'}, 'global']). --spec convert(kz_json:object(), ne_binary(), ne_binary(), binary()) -> {ok, binary()} | {error, atom() | string()}. +-spec convert(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), binary()) -> {ok, binary()} | {error, atom() | string()}. convert(_, FromFormat, FromFormat, Bin) -> {'ok', Bin}; convert(DataJObj, FromFormat0, ToFormat0, Bin) -> @@ -289,7 +289,7 @@ convert(DataJObj, FromFormat0, ToFormat0, Bin) -> _ = kz_util:delete_file(ToFile), Response. --spec run_convert_command(string(), ne_binary(), ne_binary()) -> {ok, binary()} | {error, atom() | string()}. +-spec run_convert_command(string(), kz_term:ne_binary(), kz_term:ne_binary()) -> {ok, binary()} | {error, atom() | string()}. run_convert_command(Cmd, FromFile, ToFile) -> lager:debug("running conversion command: ~s", [Cmd]), case os:cmd(Cmd) of @@ -307,6 +307,6 @@ run_convert_command(Cmd, FromFile, ToFile) -> {'error', Else} end. --spec valid_format(ne_binary()) -> ne_binary(). +-spec valid_format(kz_term:ne_binary()) -> kz_term:ne_binary(). valid_format(<<"tiff">>) -> <<"tif">>; valid_format(Format) -> Format. diff --git a/applications/teletype/src/teletype_gen_email_template.erl b/applications/teletype/src/teletype_gen_email_template.erl index 8ef4b98fba7..4fc4589a50a 100644 --- a/applications/teletype/src/teletype_gen_email_template.erl +++ b/applications/teletype/src/teletype_gen_email_template.erl @@ -13,17 +13,17 @@ -include_lib("teletype.hrl"). --callback id() -> ne_binary(). +-callback id() -> kz_term:ne_binary(). -callback init() -> ok. --callback macros(kz_json:object()) -> kz_proplist(). +-callback macros(kz_json:object()) -> kz_term:proplist(). -callback macros() -> kz_json:object(). --callback subject() -> ne_binary(). +-callback subject() -> kz_term:ne_binary(). --callback category() -> ne_binary(). +-callback category() -> kz_term:ne_binary(). --callback friendly_name() -> ne_binary(). +-callback friendly_name() -> kz_term:ne_binary(). diff --git a/applications/teletype/src/teletype_listener.erl b/applications/teletype/src/teletype_listener.erl index f17a00181c7..41d32835781 100644 --- a/applications/teletype/src/teletype_listener.erl +++ b/applications/teletype/src/teletype_listener.erl @@ -41,7 +41,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER ,[{'bindings', ?BINDINGS} @@ -50,7 +50,7 @@ start_link() -> ,[] ). --spec handle_message(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_message(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_message(JObj, _Props) -> lager:debug("recv message ~p", [JObj]). @@ -87,7 +87,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -101,7 +101,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _QueueName}}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'is_consuming', _IsConsuming}}, State) -> @@ -119,7 +119,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -131,7 +131,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/teletype/src/teletype_maintenance.erl b/applications/teletype/src/teletype_maintenance.erl index 683254f2d47..e84f0a8e2d6 100644 --- a/applications/teletype/src/teletype_maintenance.erl +++ b/applications/teletype/src/teletype_maintenance.erl @@ -41,7 +41,7 @@ filter_receipts(_, _) -> 'false'. sort_receipts({_, #email_receipt{timestamp=S1}}, {_, #email_receipt{timestamp=S2}}) -> S1 < S2. --spec print_receipt({{'receipt', ne_binary()}, email_receipt()}, pos_integer()) -> pos_integer(). +-spec print_receipt({{'receipt', kz_term:ne_binary()}, email_receipt()}, pos_integer()) -> pos_integer(). print_receipt({{'receipt', Receipt} ,#email_receipt{to=To ,from=From @@ -59,11 +59,11 @@ print_receipt({{'receipt', Receipt} ]), Count+1. --spec convert_for_printing(ne_binary() | ne_binaries()) -> ne_binary(). +-spec convert_for_printing(kz_term:ne_binary() | kz_term:ne_binaries()) -> kz_term:ne_binary(). convert_for_printing(<<_/binary>>=V) -> V; convert_for_printing([_|_]=Vs) -> kz_binary:join(Vs, <<",">>). --spec receipt_for_printing(ne_binary()) -> ne_binary(). +-spec receipt_for_printing(kz_term:ne_binary()) -> kz_term:ne_binary(). receipt_for_printing(Receipt) -> case re:run(Receipt ,<<"^2.0.0 Ok: queued as ([[:alnum:]]+).*\$">> @@ -82,7 +82,7 @@ default_receipt_printing(Receipt) -> restore_system_templates() -> lists:foreach(fun restore_system_template/1, list_templates_from_db(?KZ_CONFIG_DB)). --spec restore_system_template(ne_binary()) -> ok. +-spec restore_system_template(kz_term:ne_binary()) -> ok. restore_system_template(<<"skel">>) -> 'ok'; restore_system_template(TemplateId) -> DbId = kz_notification:db_id(TemplateId), @@ -107,7 +107,7 @@ restore_system_template(TemplateId) -> end. --spec list_templates_from_db(ne_binary()) -> ne_binaries(). +-spec list_templates_from_db(kz_term:ne_binary()) -> kz_term:ne_binaries(). list_templates_from_db(Db) -> case kz_datamgr:all_docs(Db ,[{'startkey', <<"notification.">>} @@ -132,11 +132,11 @@ list_templates_from_db(Db) -> %% Remove Template Customization from an account %% @end %%-------------------------------------------------------------------- --spec remove_customization(ne_binary()) -> 'no_return'. +-spec remove_customization(kz_term:ne_binary()) -> 'no_return'. remove_customization(Account) -> remove_customization(Account, list_templates_from_db(kz_util:format_account_db(Account))). --spec remove_customization(ne_binary(), ne_binary() | ne_binaries()) -> 'no_return'. +-spec remove_customization(kz_term:ne_binary(), kz_term:ne_binary() | kz_term:ne_binaries()) -> 'no_return'. remove_customization(Account, Id) when is_binary(Id) -> remove_customization(Account, [kz_notification:db_id(Id)]); remove_customization(_Account, []) -> @@ -163,11 +163,11 @@ remove_customization(Account, Ids) -> %% system_config to account's db. %% @end %%-------------------------------------------------------------------- --spec force_system_default(ne_binary()) -> 'no_return'. +-spec force_system_default(kz_term:ne_binary()) -> 'no_return'. force_system_default(Account) -> force_system_default(Account, list_templates_from_db(?KZ_CONFIG_DB)). --spec force_system_default(ne_binary(), ne_binary() | ne_binaries()) -> 'no_return'. +-spec force_system_default(kz_term:ne_binary(), kz_term:ne_binary() | kz_term:ne_binaries()) -> 'no_return'. force_system_default(Account, Id) when is_binary(Id) -> force_system_default(Account, [kz_notification:db_id(Id)]); force_system_default(_Account, []) -> 'no_return'; @@ -178,7 +178,7 @@ force_system_default(Account, Ids) -> _ = [copy_from_system_to_account(AccountDb, Id) || Id <- Ids], 'no_return'. --spec copy_from_system_to_account(ne_binary(), ne_binary()) -> 'ok'. +-spec copy_from_system_to_account(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. copy_from_system_to_account(AccountDb, Id) -> case kz_datamgr:copy_doc(?KZ_CONFIG_DB, Id, AccountDb, Id, []) of {'ok', _} -> io:format(" ~s: done~n", [kz_notification:resp_id(Id)]); @@ -202,7 +202,7 @@ renderer_status() -> ], 'no_return'. --spec start_module(module() | ne_binary()) -> 'ok' | {'error', any()}. +-spec start_module(module() | kz_term:ne_binary()) -> 'ok' | {'error', any()}. start_module(Module) when is_atom(Module) -> lager:info("starting teletype module ~s", [Module]), try Module:init() of @@ -222,7 +222,7 @@ start_module(Module) -> Err -> Err end. --spec stop_module(module() | ne_binary()) -> 'ok' | {'error', any()}. +-spec stop_module(module() | kz_term:ne_binary()) -> 'ok' | {'error', any()}. stop_module(Module) when is_atom(Module) -> teletype_bindings:flush_mod(Module), maybe_remove_module_from_autoload(Module); @@ -232,7 +232,7 @@ stop_module(Module) -> Err -> Err end. --spec module_from_binary(ne_binary()) -> +-spec module_from_binary(kz_term:ne_binary()) -> {'ok', module()} | {'error', 'invalid_mod'}. module_from_binary(<<"teletype_", _/binary>> = Template) -> @@ -243,12 +243,12 @@ module_from_binary(<<"teletype_", _/binary>> = Template) -> module_from_binary(?NE_BINARY=Module) -> module_from_binary(<<"teletype_", Module/binary>>). --spec invalid_module(ne_binary()) -> {'error', 'invalid_mod'}. +-spec invalid_module(kz_term:ne_binary()) -> {'error', 'invalid_mod'}. invalid_module(Module) -> lager:error("~s is not a valid teletype module", [Module]), {'error', 'invalid_mod'}. --spec maybe_add_module_to_autoload(ne_binary() | module()) -> 'ok'. +-spec maybe_add_module_to_autoload(kz_term:ne_binary() | module()) -> 'ok'. maybe_add_module_to_autoload(Module) when is_binary(Module) -> Autoload = ?AUTOLOAD_MODULES, case lists:member(Module, Autoload) of @@ -260,7 +260,7 @@ maybe_add_module_to_autoload(Module) when is_binary(Module) -> maybe_add_module_to_autoload(Module) -> maybe_add_module_to_autoload(kz_term:to_binary(Module)). --spec maybe_remove_module_from_autoload(ne_binary() | module()) -> 'ok'. +-spec maybe_remove_module_from_autoload(kz_term:ne_binary() | module()) -> 'ok'. maybe_remove_module_from_autoload(Module) when is_binary(Module) -> Autoload = ?AUTOLOAD_MODULES, case lists:member(Module, Autoload) of diff --git a/applications/teletype/src/teletype_port_utils.erl b/applications/teletype/src/teletype_port_utils.erl index d49b68c7b81..dc5af2b8f58 100644 --- a/applications/teletype/src/teletype_port_utils.erl +++ b/applications/teletype/src/teletype_port_utils.erl @@ -33,7 +33,7 @@ get_attachments(DataJObj, 'false') -> ,kz_doc:attachment_names(Doc) ). --spec get_attachment_fold(kz_json:path(), attachments(), ne_binary(), kz_json:object()) -> +-spec get_attachment_fold(kz_json:path(), attachments(), kz_term:ne_binary(), kz_json:object()) -> attachments(). get_attachment_fold(Name, Acc, PortReqId, Doc) -> {'ok', Attachment} = kz_datamgr:fetch_attachment(?KZ_PORT_REQUESTS_DB, PortReqId, Name), @@ -51,7 +51,7 @@ fix_email(ReqData, OnlyAdmin) -> Emails = get_emails(ReqData, AccountId, OnlyAdmin), kz_json:set_value(<<"to">>, Emails, ReqData). --spec get_emails(kz_json:object(), api_binary(), boolean()) -> ne_binaries(). +-spec get_emails(kz_json:object(), kz_term:api_binary(), boolean()) -> kz_term:ne_binaries(). get_emails(_ReqData, AccountId, 'true') -> ResellerId = teletype_util:find_reseller_id(AccountId), @@ -76,7 +76,7 @@ get_emails(ReqData, AccountId, 'false') -> {ResellerEmail, _} -> lists:usort([ResellerEmail] ++ PortReqEmail) end. --spec find_reseller_port_email(api_binary()) -> api_binary(). +-spec find_reseller_port_email(kz_term:api_binary()) -> kz_term:api_binary(). find_reseller_port_email(AccountId) -> case kz_whitelabel:fetch(AccountId) of {'error', _R} -> 'undefined'; @@ -84,7 +84,7 @@ find_reseller_port_email(AccountId) -> kz_whitelabel:port_email(JObj) end. --spec get_port_req_email(kz_json:object()) -> binaries(). +-spec get_port_req_email(kz_json:object()) -> kz_term:binaries(). get_port_req_email(ReqData) -> Keys = [[<<"port_request">>, <<"customer_contact">>] ,[<<"port_request">>, <<"notifications">>, <<"email">>, <<"send_to">>] @@ -116,7 +116,7 @@ fix_numbers(JObj, _DataJObj) -> Numbers = kz_json:foldl(fun fix_number_fold/3, [], NumbersJObj), kz_json:set_value(<<"numbers">>, Numbers, JObj). --spec fix_number_fold(kz_json:key(), kz_json:json_term(), ne_binaries()) -> ne_binaries(). +-spec fix_number_fold(kz_json:key(), kz_json:json_term(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). fix_number_fold(Number, _Value, Acc) -> [Number|Acc]. @@ -208,7 +208,7 @@ maybe_add_reason(JObj, DataJObj) -> kz_json:set_value(<<"transition_reason">>, kz_json:from_list(Props), JObj) end. --spec get_commenter_info(api_ne_binary(), api_ne_binary()) -> kz_proplist(). +-spec get_commenter_info(kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> kz_term:proplist(). get_commenter_info(?NE_BINARY=AccountId, ?NE_BINARY=UserId) -> case kzd_user:fetch(AccountId, UserId) of {'ok', UserJObj} -> teletype_util:user_params(UserJObj); diff --git a/applications/teletype/src/teletype_renderer.erl b/applications/teletype/src/teletype_renderer.erl index 00ee78e8fed..455c98dd6f9 100644 --- a/applications/teletype/src/teletype_renderer.erl +++ b/applications/teletype/src/teletype_renderer.erl @@ -27,18 +27,18 @@ -type state() :: module(). --spec start_link(any()) -> startlink_ret(). +-spec start_link(any()) -> kz_types:startlink_ret(). start_link(Args) -> gen_server:start_link(?SERVER, [], [Args]). --spec render(ne_binary(), binary(), kz_proplist()) -> +-spec render(kz_term:ne_binary(), binary(), kz_term:proplist()) -> {'ok', iolist()} | {'error', any()}. render(TemplateId, Template, TemplateData) -> Renderer = next_renderer(), render(Renderer, TemplateId, Template, TemplateData, 3). --spec render(pid(), ne_binary(), binary(), kz_proplist(), integer()) -> +-spec render(pid(), kz_term:ne_binary(), binary(), kz_term:proplist(), integer()) -> {'ok', iolist()} | {'error', any()}. @@ -63,7 +63,7 @@ render(Renderer, TemplateId, Template, TemplateData, Tries) -> GoodReturn end. --spec do_render(pid(), ne_binary(), binary(), kz_proplist()) -> +-spec do_render(pid(), kz_term:ne_binary(), binary(), kz_term:proplist()) -> {'ok', iolist()} | {'error', any()}. do_render(Renderer, TemplateId, Template, TemplateData) -> @@ -120,7 +120,7 @@ init(_) -> lager:debug("starting template renderer, using ~s as compiled module name", [Module]), {'ok', Module}. --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call({'render', _TemplateId, Template, TemplateData}, _From, TemplateModule) -> %% l?LOG_DEBUG("trying to compile template ~s as ~s for ~w", [_TemplateId, TemplateModule, _From]), lager:debug("trying to compile template ~s as ~s for ~w", [_TemplateId, TemplateModule, _From]), @@ -132,11 +132,11 @@ handle_call({'render', _TemplateId, Template, TemplateData}, _From, TemplateModu handle_call(_Req, _From, TemplateModule) -> {'noreply', TemplateModule}. --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Req, TemplateModule) -> {'noreply', TemplateModule}. --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Msg, TemplateModule) -> {'noreply', TemplateModule}. diff --git a/applications/teletype/src/teletype_shared_listener.erl b/applications/teletype/src/teletype_shared_listener.erl index ddc2b33ff9e..21ff5b5b115 100644 --- a/applications/teletype/src/teletype_shared_listener.erl +++ b/applications/teletype/src/teletype_shared_listener.erl @@ -46,7 +46,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link({'local', ?SERVER} ,?SERVER @@ -92,7 +92,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'noreply', State}. @@ -106,7 +106,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _QueueName}}, State) -> kz_util:put_callid(?MODULE), {'noreply', State}; @@ -126,7 +126,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'EXIT', _Pid, 'normal'}, State) -> {'noreply', State}; handle_info(_Info, State) -> @@ -141,14 +141,14 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(JObj, _State) -> case teletype_util:should_handle_notification(JObj) of 'false' -> 'ignore'; 'true' -> {'reply', []} end. --spec handle_message(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_message(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_message(JObj, _Props) -> teletype_bindings:notification(JObj). diff --git a/applications/teletype/src/teletype_sup.erl b/applications/teletype/src/teletype_sup.erl index 8cdc360b7df..d5e5c76f152 100644 --- a/applications/teletype/src/teletype_sup.erl +++ b/applications/teletype/src/teletype_sup.erl @@ -31,7 +31,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -48,7 +48,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/teletype/src/teletype_templates.erl b/applications/teletype/src/teletype_templates.erl index fab42516759..2753f40bb06 100644 --- a/applications/teletype/src/teletype_templates.erl +++ b/applications/teletype/src/teletype_templates.erl @@ -24,7 +24,7 @@ -export([master_content_types/1]). -endif. --type macro() :: {ne_binary(), ne_binary() | number() | macros()}. +-type macro() :: {kz_term:ne_binary(), kz_term:ne_binary() | number() | macros()}. -type macros() :: [macro()]. -define(TEMPLATE_FAILURE_KEY(TemplateId, AccountId) @@ -41,7 +41,7 @@ init(Module) when is_atom(Module) -> init(Module:id(), params(Module)). --spec params(module() | ne_binary()) -> kz_proplist(). +-spec params(module() | kz_term:ne_binary()) -> kz_term:proplist(). params(TemplateId=?NE_BINARY) -> Module = kz_term:to_atom(<<(?APP_NAME)/binary, "_", TemplateId/binary>>, true), params(Module); @@ -61,7 +61,7 @@ params(Module) ,{text, TemplateId} ]. --spec init(ne_binary(), init_params()) -> 'ok'. +-spec init(kz_term:ne_binary(), init_params()) -> 'ok'. init(TemplateId, Params) -> UpdatedParams = props:set_values([{'html', TemplateId} ,{'text', TemplateId} @@ -80,7 +80,7 @@ init(TemplateId, Params) -> end, compile_master_renderers(TemplateId). --spec compile_master_renderers(ne_binary()) -> 'ok'. +-spec compile_master_renderers(kz_term:ne_binary()) -> 'ok'. compile_master_renderers(TemplateId) -> _ = [build_renderer(TemplateId, ContentType, Template) || {ContentType, Template} <- fetch_master_attachments(TemplateId) @@ -88,7 +88,7 @@ compile_master_renderers(TemplateId) -> %% ?LOG_DEBUG("built master renderer modules for ~s", [TemplateId]). lager:debug("built master renderer modules for ~s", [TemplateId]). --spec build_renderer(ne_binary(), ne_binary(), binary()) -> 'ok'. +-spec build_renderer(kz_term:ne_binary(), kz_term:ne_binary(), binary()) -> 'ok'. build_renderer(TemplateId, ContentType, Template) -> ModuleName = renderer_name(TemplateId, ContentType), case kz_template:compile(Template, ModuleName,[{'auto_escape', 'false'}]) of @@ -98,14 +98,14 @@ build_renderer(TemplateId, ContentType, Template) -> throw({'error', 'failed_template', ModuleName}) end. --type template_attachment() :: {ne_binary(), binary()}. +-type template_attachment() :: {kz_term:ne_binary(), binary()}. -type template_attachments() :: [template_attachment()]. --spec fetch_master_attachments(ne_binary()) -> template_attachments(). +-spec fetch_master_attachments(kz_term:ne_binary()) -> template_attachments(). fetch_master_attachments(TemplateId) -> fetch_attachments(TemplateId, ?KZ_CONFIG_DB). --spec fetch_attachments(ne_binary(), ne_binary()) -> template_attachments(). +-spec fetch_attachments(kz_term:ne_binary(), kz_term:ne_binary()) -> template_attachments(). fetch_attachments(TemplateId, Account) -> AccountDb = case ?KZ_CONFIG_DB =:= Account of true -> ?KZ_CONFIG_DB; @@ -125,7 +125,7 @@ fetch_attachments(TemplateId, Account) -> [] end. --spec fetch_attachment(ne_binary(), kz_json:object(), template_attachments(), ne_binary(), ne_binary()) -> +-spec fetch_attachment(kz_term:ne_binary(), kz_json:object(), template_attachments(), kz_term:ne_binary(), kz_term:ne_binary()) -> template_attachments(). fetch_attachment(AttachmentName, AttachmentProps, Acc, AccountDb, DocId) -> ContentType = kz_json:get_value(<<"content_type">>, AttachmentProps), @@ -139,16 +139,16 @@ fetch_attachment(AttachmentName, AttachmentProps, Acc, AccountDb, DocId) -> Acc end. --spec preview(ne_binary(), macros(), kz_json:object()) -> kz_proplist(). +-spec preview(kz_term:ne_binary(), macros(), kz_json:object()) -> kz_term:proplist(). preview(TemplateId, Macros, DataJObj) -> render_farm(TemplateId ,Macros ,load_preview_templates(DataJObj) ). --spec render(ne_binary(), macros()) -> kz_proplist(). --spec render(ne_binary(), macros(), kz_json:object()) -> kz_proplist(). --spec render(ne_binary(), macros(), kz_json:object(), boolean()) -> kz_proplist(). +-spec render(kz_term:ne_binary(), macros()) -> kz_term:proplist(). +-spec render(kz_term:ne_binary(), macros(), kz_json:object()) -> kz_term:proplist(). +-spec render(kz_term:ne_binary(), macros(), kz_json:object(), boolean()) -> kz_term:proplist(). render(TemplateId, Macros) -> render(TemplateId, Macros, kz_json:new()). @@ -174,8 +174,8 @@ render(TemplateId, Macros, DataJObj, 'false') -> render(TemplateId, Macros, DataJObj, 'true') -> preview(TemplateId, Macros, DataJObj). --spec templates_source(ne_binary(), api_binary() | kz_json:object()) -> api_binary(). --spec templates_source(ne_binary(), api_binary(), ne_binary()) -> api_binary(). +-spec templates_source(kz_term:ne_binary(), kz_term:api_binary() | kz_json:object()) -> kz_term:api_binary(). +-spec templates_source(kz_term:ne_binary(), kz_term:api_binary(), kz_term:ne_binary()) -> kz_term:api_binary(). templates_source(_TemplateId, 'undefined') -> lager:warning("no account id for template ~s, no template to process", [_TemplateId]), 'undefined'; @@ -211,23 +211,23 @@ templates_source(TemplateId, AccountId, ResellerId) -> {'error', _E} -> 'undefined' end. --spec templates_source_has_attachments(ne_binary(), ne_binary(), ne_binary(), kz_json:object()) -> - api_binary(). +-spec templates_source_has_attachments(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> + kz_term:api_binary(). templates_source_has_attachments(TemplateId, AccountId, ResellerId, Template) -> case kz_doc:attachments(Template) of 'undefined' -> parent_templates_source(TemplateId, AccountId, ResellerId); _ -> kz_doc:account_id(Template) end. --spec parent_templates_source(ne_binary(), ne_binary(), ne_binary()) -> - api_binary(). +-spec parent_templates_source(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> + kz_term:api_binary(). parent_templates_source(_TemplateId, AccountId, AccountId) -> ?KZ_CONFIG_DB; parent_templates_source(TemplateId, AccountId, ResellerId) -> lager:debug("failed to find template ~s in account ~s", [TemplateId, AccountId]), ParentId = teletype_util:get_parent_account_id(AccountId), templates_source(TemplateId, ParentId, ResellerId). --spec fetch_notification(ne_binary(), ne_binary()) -> +-spec fetch_notification(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. fetch_notification(TemplateId, ?KZ_CONFIG_DB) -> @@ -256,7 +256,7 @@ fetch_notification(TemplateId, AccountId, ResellerId) -> fetch_notification(TemplateId, teletype_util:get_parent_account_id(AccountId), ResellerId) end. --spec render_masters(ne_binary(), macros()) -> kz_proplist(). +-spec render_masters(kz_term:ne_binary(), macros()) -> kz_term:proplist(). render_masters(TemplateId, Macros) -> [{ContentType, render_master(TemplateId, ContentType, Macros)} || ContentType <- master_content_types(TemplateId) @@ -273,7 +273,7 @@ master_content_types(TemplateId) -> [] end. --spec render_master(ne_binary(), ne_binary(), macros()) -> ne_binary(). +-spec render_master(kz_term:ne_binary(), kz_term:ne_binary(), macros()) -> kz_term:ne_binary(). render_master(?NE_BINARY=TemplateId, ?NE_BINARY=ContentType, Macros) -> ModuleName = renderer_name(TemplateId, ContentType), case kz_template:render(ModuleName, Macros) of @@ -284,17 +284,17 @@ render_master(?NE_BINARY=TemplateId, ?NE_BINARY=ContentType, Macros) -> throw({'error', 'template_error', <<"failed to render template ", TemplateId/binary>>}) end. --spec render_accounts(ne_binary(), ne_binary(), macros()) -> kz_proplist(). +-spec render_accounts(kz_term:ne_binary(), kz_term:ne_binary(), macros()) -> kz_term:proplist(). render_accounts(TemplateId, AccountDb, Macros) -> render_farm(TemplateId, Macros, fetch_attachments(TemplateId, AccountDb)). --spec render_farm(ne_binary(), macros(), kz_proplist()) -> kz_proplist(). +-spec render_farm(kz_term:ne_binary(), macros(), kz_term:proplist()) -> kz_term:proplist(). render_farm(TemplateId, Macros, Templates) -> [{ContentType, teletype_util:render(TemplateId, Template, Macros)} || {ContentType, Template} <- Templates ]. --spec renderer_name(ne_binary(), ne_binary()) -> atom(). +-spec renderer_name(kz_term:ne_binary(), kz_term:ne_binary()) -> atom(). renderer_name(TemplateId, ContentType) -> kz_term:to_atom(<<(TemplateId)/binary, ".", ContentType/binary>>, 'true'). @@ -303,18 +303,18 @@ renderer_name(TemplateId, ContentType) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec doc_id(ne_binary()) -> ne_binary(). +-spec doc_id(kz_term:ne_binary()) -> kz_term:ne_binary(). doc_id(Id) -> kz_notification:db_id(Id). --spec load_preview_templates(kz_json:object()) -> kz_proplist(). +-spec load_preview_templates(kz_json:object()) -> kz_term:proplist(). load_preview_templates(DataJObj) -> props:filter_undefined( [{?TEXT_HTML, maybe_decode_html(kz_json:get_value(<<"html">>, DataJObj))} ,{?TEXT_PLAIN, kz_json:get_value(<<"text">>, DataJObj)} ]). --spec maybe_decode_html(api_binary()) -> api_binary(). +-spec maybe_decode_html(kz_term:api_binary()) -> kz_term:api_binary(). maybe_decode_html('undefined') -> 'undefined'; maybe_decode_html(HTML) -> try base64:decode(HTML) @@ -331,7 +331,7 @@ maybe_decode_html(HTML) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec create(ne_binary(), init_params()) -> 'ok'. +-spec create(kz_term:ne_binary(), init_params()) -> 'ok'. create(DocId, Params) -> lager:debug("attempting to create template ~s", [DocId]), TemplateJObj = @@ -430,7 +430,7 @@ update_from_params(TemplateJObj, Params) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec update_from_param(init_param() | {'pvt_type', ne_binary()}, update_acc()) -> update_acc(). +-spec update_from_param(init_param() | {'pvt_type', kz_term:ne_binary()}, update_acc()) -> update_acc(). update_from_param({'macros', Macros}, Acc) -> update_macros(Macros, Acc); update_from_param({'text', Basename}, Acc) -> @@ -465,7 +465,7 @@ update_from_param({'pvt_type', PvtType}, Acc) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec update_category(ne_binary(), update_acc()) -> +-spec update_category(kz_term:ne_binary(), update_acc()) -> update_acc(). update_category(Category, Acc) -> update_field(Category @@ -474,7 +474,7 @@ update_category(Category, Acc) -> ,fun kz_notification:set_category/2 ). --spec update_name(ne_binary(), update_acc()) -> +-spec update_name(kz_term:ne_binary(), update_acc()) -> update_acc(). update_name(Name, Acc) -> update_field(Name @@ -483,7 +483,7 @@ update_name(Name, Acc) -> ,fun kz_notification:set_name/2 ). --spec update_from(ne_binary(), update_acc()) -> +-spec update_from(kz_term:ne_binary(), update_acc()) -> update_acc(). update_from(From, Acc) -> update_field(From @@ -492,7 +492,7 @@ update_from(From, Acc) -> ,fun kz_notification:set_from/2 ). --spec update_reply_to(ne_binary(), update_acc()) -> +-spec update_reply_to(kz_term:ne_binary(), update_acc()) -> update_acc(). update_reply_to(ReplyTo, Acc) -> update_field(ReplyTo @@ -528,7 +528,7 @@ update_bcc(Bcc, Acc) -> ,fun kz_notification:set_bcc/2 ). --spec update_field(api_object() | ne_binary(), update_acc(), fun(), fun()) -> +-spec update_field(kz_term:api_object() | kz_term:ne_binary(), update_acc(), fun(), fun()) -> update_acc(). update_field('undefined', Acc, _GetFun, _SetFun) -> Acc; update_field(Value, {_IsUpdated, TemplateJObj}=Acc, GetFun, SetFun) -> @@ -542,7 +542,7 @@ update_field(Value, {_IsUpdated, TemplateJObj}=Acc, GetFun, SetFun) -> _V -> {'true', SetFun(TemplateJObj, Value)} end. --spec update_subject(ne_binary(), update_acc()) -> +-spec update_subject(kz_term:ne_binary(), update_acc()) -> update_acc(). update_subject(Subject, Acc) -> update_field(Subject @@ -576,9 +576,9 @@ update_text_attachment(Basename, Acc) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec update_attachment(binary(), update_acc(), ne_binary()) -> +-spec update_attachment(binary(), update_acc(), kz_term:ne_binary()) -> update_acc(). --spec update_attachment(binary(), update_acc(), ne_binary(), ne_binary(), ne_binary()) -> +-spec update_attachment(binary(), update_acc(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> update_acc(). update_attachment(Contents, {_IsUpdated, TemplateJObj}=Acc, ContentType) -> AttachmentName = attachment_name(ContentType), @@ -627,7 +627,7 @@ update_macro(MacroKey, MacroValue, {_IsUpdated, TemplateJObj}=Acc) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec attachment_name(ne_binary()) -> ne_binary(). +-spec attachment_name(kz_term:ne_binary()) -> kz_term:ne_binary(). attachment_name(ContentType) -> kz_binary:clean(<<"template.", ContentType/binary>>). @@ -636,7 +636,7 @@ attachment_name(ContentType) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec does_attachment_exist(ne_binary(), ne_binary()) -> boolean(). +-spec does_attachment_exist(kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). does_attachment_exist(DocId, AName) -> case kz_datamgr:open_doc(?KZ_CONFIG_DB, DocId) of {'ok', JObj} -> @@ -650,7 +650,7 @@ does_attachment_exist(DocId, AName) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec save_attachment(ne_binary(), ne_binary(), ne_binary(), binary()) -> +-spec save_attachment(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), binary()) -> {'ok', kz_json:object()} | {'error', any()}. save_attachment(DocId, AName, ContentType, Contents) -> @@ -673,7 +673,7 @@ save_attachment(DocId, AName, ContentType, Contents) -> E end. --spec write_templates_to_disk(ne_binary(), kz_proplist()) -> 'ok'. +-spec write_templates_to_disk(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. write_templates_to_disk(TemplateId, Params) -> lists:foreach(fun(Template) -> write_template_to_disk(TemplateId, Template) @@ -685,19 +685,19 @@ write_templates_to_disk(TemplateId, Params) -> ) ). --spec read_template_from_disk(ne_binary(), 'html' | 'text') -> +-spec read_template_from_disk(kz_term:ne_binary(), 'html' | 'text') -> {'ok', binary()} | {'error', file:posix() | 'badarg' | 'terminated' | 'system_limit'}. read_template_from_disk(TemplateId, Type) -> file:read_file( template_filename(TemplateId, Type)). --spec write_template_to_disk(ne_binary(), {'html' | 'text', binary()}) -> 'ok'. +-spec write_template_to_disk(kz_term:ne_binary(), {'html' | 'text', binary()}) -> 'ok'. write_template_to_disk(TemplateId, {Type, Template}) -> File = template_filename(TemplateId, Type), 'ok' = file:write_file(File, Template). --spec template_filename(ne_binary(), 'html' | 'text') -> file:filename_all(). +-spec template_filename(kz_term:ne_binary(), 'html' | 'text') -> file:filename_all(). template_filename(TemplateId, Type) -> Basename = iolist_to_binary([TemplateId, ".", kz_term:to_list(Type)]), filename:join([code:priv_dir(?APP), "templates", Basename]). diff --git a/applications/teletype/src/teletype_tests.erl b/applications/teletype/src/teletype_tests.erl index 15da4b0b0a3..86e08b0e57b 100644 --- a/applications/teletype/src/teletype_tests.erl +++ b/applications/teletype/src/teletype_tests.erl @@ -16,16 +16,16 @@ -include("teletype.hrl"). --spec voicemail_to_email(ne_binary()) -> 'ok' | - {'ok', kz_json:objects()} | - {'error', any()}. +-spec voicemail_to_email(kz_term:ne_binary()) -> 'ok' | + {'ok', kz_json:objects()} | + {'error', any()}. voicemail_to_email(?NE_BINARY=AccountId) -> case find_vmboxes(AccountId) of [] -> lager:debug("no voicemail boxes in account ~s", [AccountId]); VMBoxes -> find_vmbox_messages(AccountId, VMBoxes) end. --spec find_vmboxes(ne_binary()) -> kz_json:objects(). +-spec find_vmboxes(kz_term:ne_binary()) -> kz_json:objects(). find_vmboxes(?NE_BINARY=AccountId) -> AccountDb = kz_util:format_account_db(AccountId), case kz_datamgr:get_results(AccountDb, <<"vmboxes/crossbar_listing">>, ['include_docs']) of @@ -35,7 +35,7 @@ find_vmboxes(?NE_BINARY=AccountId) -> [] end. --spec find_vmbox_messages(ne_binary(), kz_json:objects()) -> +-spec find_vmbox_messages(kz_term:ne_binary(), kz_json:objects()) -> 'ok' | {'ok', kz_json:objects()} | {'error', any()}. @@ -48,7 +48,7 @@ find_vmbox_messages(AccountId, [Box|Boxes]) -> Ms -> voicemail_to_email(AccountId, BoxJObj, Ms) end. --spec voicemail_to_email(ne_binary(), ne_binary()) -> +-spec voicemail_to_email(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | {'ok', kz_json:objects()} | {'error', any()}. @@ -57,7 +57,7 @@ voicemail_to_email(AccountId, ?NE_BINARY=VoicemailBoxId) -> {'ok', VMBox} = kz_datamgr:open_cache_doc(AccountDb, VoicemailBoxId), find_vmbox_messages(AccountId, [VMBox]). --spec voicemail_to_email(ne_binary(), kz_json:object(), kz_json:objects()) -> +-spec voicemail_to_email(kz_term:ne_binary(), kz_json:object(), kz_json:objects()) -> {'ok', kz_json:objects()} | {'error', any()}. voicemail_to_email(AccountId, VMBox, [Message|_]) -> @@ -84,7 +84,7 @@ voicemail_to_email(AccountId, VMBox, [Message|_]) -> ,5 * ?MILLISECONDS_IN_SECOND ). --spec skel(ne_binary()) -> ok. +-spec skel(kz_term:ne_binary()) -> ok. skel(AccountId) -> AccountDb = kz_util:format_account_id(AccountId, 'encoded'), case kz_datamgr:get_results(AccountDb, <<"users/crossbar_listing">>, ['include_docs']) of @@ -109,7 +109,7 @@ find_user_for_skel(AccountId, User, Users, PotentialEmail) -> _ -> find_user_for_skel(AccountId, Users) end. --spec skel(ne_binary(), ne_binary()) -> ok. +-spec skel(kz_term:ne_binary(), kz_term:ne_binary()) -> ok. skel(AccountId, ?NE_BINARY=UserId) -> Req = [{<<"Account-ID">>, AccountId} ,{<<"User-ID">>, UserId} @@ -118,14 +118,14 @@ skel(AccountId, ?NE_BINARY=UserId) -> ], kz_amqp_worker:cast(Req, fun kapi_notifications:publish_skel/1). --spec voicemail_full(ne_binary()) -> ok. +-spec voicemail_full(kz_term:ne_binary()) -> ok. voicemail_full(AccountId) -> case find_vmboxes(AccountId) of [] -> lager:debug("there are no voicemail boxes in ~s", [AccountId]); [Box|_] -> voicemail_full(AccountId, kz_json:get_value(<<"doc">>, Box)) end. --spec voicemail_full(ne_binary(), ne_binary()) -> kz_amqp_worker:request_return(). +-spec voicemail_full(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_amqp_worker:request_return(). voicemail_full(AccountId, ?NE_BINARY=BoxId) -> AccountDb = kz_util:format_account_id(AccountId, 'encoded'), {'ok', Box} = kz_datamgr:open_cache_doc(AccountDb, BoxId), @@ -143,7 +143,7 @@ voicemail_full(AccountId, Box) -> Publisher = fun kapi_notifications:publish_voicemail_full/1, kz_amqp_worker:call_collect(Props, Publisher, 5 * ?MILLISECONDS_IN_SECOND). --spec fax_inbound_to_email(ne_binary()) -> ok. +-spec fax_inbound_to_email(kz_term:ne_binary()) -> ok. fax_inbound_to_email(AccountId) -> AccountDb = kz_util:format_account_id(AccountId, 'encoded'), case kz_datamgr:get_results(AccountDb, <<"faxes/crossbar_listing">>, ['include_docs']) of @@ -160,7 +160,7 @@ find_fax_with_attachment(AccountId, [Fax|Faxes]) -> _As -> fax_inbound_to_email(AccountId, kz_json:get_value(<<"doc">>, Fax)) end. --spec fax_inbound_to_email(ne_binary(), ne_binary()) -> kz_amqp_worker:request_return(). +-spec fax_inbound_to_email(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_amqp_worker:request_return(). fax_inbound_to_email(AccountId, ?NE_BINARY=FaxId) -> AccountDb = kz_util:format_account_id(AccountId, 'encoded'), {'ok', Fax} = kz_datamgr:open_cache_doc(AccountDb, FaxId), @@ -177,7 +177,7 @@ fax_inbound_to_email(AccountId, Fax) -> Publisher = fun kapi_notifications:publish_fax_inbound/1, kz_amqp_worker:call_collect(Message, Publisher, 2 * ?MILLISECONDS_IN_SECOND). --spec notify_fields(kz_json:object()) -> kz_proplist(). +-spec notify_fields(kz_json:object()) -> kz_term:proplist(). notify_fields(JObj) -> props:filter_empty( [{<<"From-User">>, <<"FromUser">>} diff --git a/applications/teletype/src/teletype_util.erl b/applications/teletype/src/teletype_util.erl index c9abf371894..dd9d9bc41cf 100644 --- a/applications/teletype/src/teletype_util.erl +++ b/applications/teletype/src/teletype_util.erl @@ -59,9 +59,9 @@ kapps_config:get_is_true(?APP_NAME, <<"notice_enabled_by_default">>, 'true') ). --spec send_email(email_map(), ne_binary(), rendered_templates()) -> +-spec send_email(email_map(), kz_term:ne_binary(), rendered_templates()) -> 'ok' | {'error', any()}. --spec send_email(email_map(), ne_binary(), rendered_templates(), attachments()) -> +-spec send_email(email_map(), kz_term:ne_binary(), rendered_templates(), attachments()) -> 'ok' | {'error', any()}. send_email(Emails, Subject, RenderedTemplates) -> send_email(Emails, Subject, RenderedTemplates, []). @@ -97,8 +97,8 @@ send_email(Emails, Subject, RenderedTemplates, Attachments) -> E end. --spec maybe_log_smtp(email_map(), ne_binary(), list(), api_binary(), api_binary()) -> 'ok'. --spec maybe_log_smtp(email_map(), ne_binary(), list(), api_binary(), api_binary(), boolean()) -> 'ok'. +-spec maybe_log_smtp(email_map(), kz_term:ne_binary(), list(), kz_term:api_binary(), kz_term:api_binary()) -> 'ok'. +-spec maybe_log_smtp(email_map(), kz_term:ne_binary(), list(), kz_term:api_binary(), kz_term:api_binary(), boolean()) -> 'ok'. maybe_log_smtp(Emails, Subject, RenderedTemplates, Receipt, Error) -> Skip = kz_term:is_true(get('skip_smtp_log')), maybe_log_smtp(Emails, Subject, RenderedTemplates, Receipt, Error, Skip). @@ -113,7 +113,7 @@ maybe_log_smtp(Emails, Subject, RenderedTemplates, Receipt, Error, 'false') -> log_smtp(Emails, Subject, RenderedTemplates, Receipt, Error, AccountId) end. --spec log_smtp(email_map(), ne_binary(), list(), api_binary(), api_binary(), ne_binary()) -> 'ok'. +-spec log_smtp(email_map(), kz_term:ne_binary(), list(), kz_term:api_binary(), kz_term:api_binary(), kz_term:ne_binary()) -> 'ok'. log_smtp(Emails, Subject, RenderedTemplates, Receipt, Error, AccountId) -> AccountDb = kazoo_modb:get_modb(AccountId), Id = make_smtplog_id(AccountDb), @@ -139,7 +139,7 @@ log_smtp(Emails, Subject, RenderedTemplates, Receipt, Error, AccountId) -> _ = kazoo_modb:save_doc(AccountDb, Doc), 'ok'. --spec make_smtplog_id(ne_binary()) -> ne_binary(). +-spec make_smtplog_id(kz_term:ne_binary()) -> kz_term:ne_binary(). make_smtplog_id(?MATCH_MODB_SUFFIX_ENCODED(_Account, Year, Month)) -> ?MATCH_MODB_PREFIX(Year, Month, kz_binary:rand_hex(16)). @@ -152,7 +152,7 @@ email_body(RenderedTemplates) -> ,add_rendered_templates_to_email(RenderedTemplates) }. --spec email_parameters(kz_proplist(), kz_proplist()) -> kz_proplist(). +-spec email_parameters(kz_term:proplist(), kz_term:proplist()) -> kz_term:proplist(). email_parameters([], Params) -> lists:reverse(props:filter_empty(Params)); email_parameters([{_Key, 'undefined'}|T], Params) -> @@ -162,7 +162,7 @@ email_parameters([{Key, Vs}|T], Params) when is_list(Vs) -> email_parameters([{Key, V}|T], Params) -> email_parameters(T, [{Key, V} | Params]). --spec relay_email(api_binaries(), ne_binary(), mimemail:mimetuple()) -> +-spec relay_email(kz_term:api_binaries(), kz_term:ne_binary(), mimemail:mimetuple()) -> 'ok' | {'error', any()}. relay_email(To, From, {_Type ,_SubType @@ -186,7 +186,7 @@ relay_email(To, From, {_Type {'error', 'email_encoding_failed'} end. --spec maybe_relay_to_bcc(ne_binary(), ne_binary(), api_binaries()) -> 'ok'. +-spec maybe_relay_to_bcc(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binaries()) -> 'ok'. maybe_relay_to_bcc(_From, _Encoded, 'undefined') -> 'ok'; maybe_relay_to_bcc(_From, _Encoded, []) -> 'ok'; maybe_relay_to_bcc(From, Encoded, Bcc) -> @@ -195,15 +195,15 @@ maybe_relay_to_bcc(From, Encoded, Bcc) -> 'false' -> 'ok' end. --spec relay_to_bcc(ne_binary(), ne_binary(), ne_binaries() | ne_binary()) -> - {'ok', ne_binary()} | {'error', any()}. +-spec relay_to_bcc(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binaries() | kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | {'error', any()}. relay_to_bcc(From, Encoded, Bcc) when is_binary(Bcc) -> relay_encoded_email([Bcc], From, Encoded); relay_to_bcc(From, Encoded, Bcc) -> relay_encoded_email(Bcc, From, Encoded). --spec relay_encoded_email(api_binaries(), ne_binary(), ne_binary()) -> - {'ok', ne_binary()} | {'error', any()}. +-spec relay_encoded_email(kz_term:api_binaries(), kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | {'error', any()}. relay_encoded_email('undefined', _From, _Encoded) -> lager:debug("failed to send email as the TO address(es) are missing"), {'error', 'invalid_to_addresses'}; @@ -251,7 +251,7 @@ log_email_send_error({'function_clause', Stacktrace}) -> log_email_send_error(Reason) -> lager:debug("exit relaying message: ~p", [Reason]). --spec smtp_options() -> kz_proplist(). +-spec smtp_options() -> kz_term:proplist(). smtp_options() -> Relay = kapps_config:get_string(<<"smtp_client">>, <<"relay">>, "localhost"), Username = kapps_config:get_string(<<"smtp_client">>, <<"username">>, ""), @@ -277,12 +277,12 @@ smtp_options() -> ,{'ssl', SSL} ]). --spec smtp_auth_option(ne_binary()) -> atom(). +-spec smtp_auth_option(kz_term:ne_binary()) -> atom(). smtp_auth_option(<<"if_available">>) -> 'if_available'; smtp_auth_option(<<"always">>) -> 'always'; smtp_auth_option(_) -> 'never'. --spec smtp_tls_option(ne_binary()) -> atom(). +-spec smtp_tls_option(kz_term:ne_binary()) -> atom(). smtp_tls_option(<<"if_available">>) -> 'if_available'; smtp_tls_option(<<"always">>) -> 'always'; smtp_tls_option(_) -> 'never'. @@ -338,7 +338,7 @@ add_rendered_templates_to_email([{ContentType, Content}|Rs], Acc) -> default_content_transfer_encoding(<<"text/html">>) -> <<"base64">>; default_content_transfer_encoding(_) -> <<"7BIT">>. --spec system_params() -> kz_proplist(). +-spec system_params() -> kz_term:proplist(). system_params() -> [{<<"hostname">>, kz_term:to_binary(net_adm:localhost())} ,{<<"encoded_hostname">>, kz_base64url:encode(crypto:hash('md5', kz_term:to_binary(net_adm:localhost())))} @@ -346,7 +346,7 @@ system_params() -> ,{<<"encoded_node">>, kz_nodes:node_encoded()} ]. --spec user_params(kzd_user:doc()) -> kz_proplist(). +-spec user_params(kzd_user:doc()) -> kz_term:proplist(). user_params(UserJObj) -> Ks = [{<<"first_name">>, fun kzd_user:first_name/1} ,{<<"last_name">>, fun kzd_user:last_name/1} @@ -357,7 +357,7 @@ user_params(UserJObj) -> [{Key, Fun(UserJObj)} || {Key, Fun} <- Ks] ). --spec account_params(kz_json:object()) -> kz_proplist(). +-spec account_params(kz_json:object()) -> kz_term:proplist(). account_params(DataJObj) -> case kapi_notifications:account_id(DataJObj) of 'undefined' -> @@ -368,7 +368,7 @@ account_params(DataJObj) -> find_account_params(AccountId) end. --spec find_account_params(api_binary()) -> kz_proplist(). +-spec find_account_params(kz_term:api_binary()) -> kz_term:proplist(). find_account_params('undefined') -> []; find_account_params(AccountId) -> case kz_account:fetch(AccountId) of @@ -386,7 +386,7 @@ find_account_params(AccountId) -> [] end. --spec maybe_add_parent_params(ne_binary(), kz_json:object()) -> kz_proplist(). +-spec maybe_add_parent_params(kz_term:ne_binary(), kz_json:object()) -> kz_term:proplist(). maybe_add_parent_params(AccountId, AccountJObj) -> case kz_account:parent_account_id(AccountJObj) of 'undefined' -> []; @@ -399,18 +399,18 @@ maybe_add_parent_params(AccountId, AccountJObj) -> ] end. --spec default_from_address() -> ne_binary(). +-spec default_from_address() -> kz_term:ne_binary(). default_from_address() -> list_to_binary([<<"no_reply@">>, net_adm:localhost()]). --spec default_reply_to() -> api_ne_binary(). +-spec default_reply_to() -> kz_term:api_ne_binary(). default_reply_to() -> 'undefined'. --spec render_subject(ne_binary(), kz_proplist()) -> binary(). +-spec render_subject(kz_term:ne_binary(), kz_term:proplist()) -> binary(). render_subject(Template, Macros) -> render(<<"subject">>, Template, Macros). --spec render(ne_binary(), ne_binary(), kz_proplist()) -> binary(). +-spec render(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> binary(). render(TemplateId, Template, Macros) -> case teletype_renderer:render(TemplateId, Template, Macros) of {'ok', IOData} -> iolist_to_binary(IOData); @@ -423,12 +423,12 @@ render(TemplateId, Template, Macros) -> sort_templates(RenderedTemplates) -> lists:sort(fun sort_templates/2, RenderedTemplates). --spec sort_templates({ne_binary(), any()}, {ne_binary(), any()}) -> boolean(). +-spec sort_templates({kz_term:ne_binary(), any()}, {kz_term:ne_binary(), any()}) -> boolean(). sort_templates({K1, _}, {K2, _}) -> props:get_value(K1, ?TEMPLATE_RENDERING_ORDER, 1) =< props:get_value(K2, ?TEMPLATE_RENDERING_ORDER, 1). --spec find_account_db(ne_binary(), kz_json:object()) -> api_binary(). +-spec find_account_db(kz_term:ne_binary(), kz_json:object()) -> kz_term:api_binary(). find_account_db(<<"account">>, JObj) -> kapi_notifications:account_db(JObj, 'false'); find_account_db(<<"user">>, JObj) -> kapi_notifications:account_db(JObj, 'false'); find_account_db(<<"faxbox">>, JObj) -> kapi_notifications:account_db(JObj, 'false'); @@ -437,15 +437,15 @@ find_account_db(<<"port_request">>, _JObj) -> ?KZ_PORT_REQUESTS_DB; find_account_db(<<"webhook">>, _JObj) -> ?KZ_WEBHOOKS_DB; find_account_db(_, JObj) -> kapi_notifications:account_db(JObj, 'false'). --spec send_update(kz_json:object(), ne_binary()) -> 'ok'. +-spec send_update(kz_json:object(), kz_term:ne_binary()) -> 'ok'. send_update(DataJObj, Status) -> send_update(DataJObj, Status, 'undefined'). --spec send_update(kz_json:object(), ne_binary(), api_binary()) -> 'ok'. +-spec send_update(kz_json:object(), kz_term:ne_binary(), kz_term:api_binary()) -> 'ok'. send_update(DataJObj, Status, Message) -> send_update(DataJObj, Status, Message, 'undefined'). --spec send_update(kz_json:object(), ne_binary(), api_binary(), api_object()) -> 'ok'. +-spec send_update(kz_json:object(), kz_term:ne_binary(), kz_term:api_binary(), kz_term:api_object()) -> 'ok'. send_update(DataJObj, Status, Message, Metadata) -> send_update(kz_json:get_first_defined([<<"server_id">>, <<"Server-ID">>], DataJObj) ,kz_json:get_first_defined([<<"msg_id">>, <<"Msg-ID">>], DataJObj) @@ -454,7 +454,7 @@ send_update(DataJObj, Status, Message, Metadata) -> ,Metadata ). --spec send_update(api_binary(), ne_binary(), ne_binary(), api_binary(), api_object()) -> 'ok'. +-spec send_update(kz_term:api_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary(), kz_term:api_object()) -> 'ok'. send_update('undefined', _, _, _, _) -> ?LOG_DEBUG("no response queue available, not publishing update"); send_update(RespQ, MsgId, Status, Msg, Metadata) -> @@ -469,7 +469,7 @@ send_update(RespQ, MsgId, Status, Msg, Metadata) -> lager:debug("notification update (~s) sending to ~s", [Status, RespQ]), kz_amqp_worker:cast(Prop, fun(P) -> kapi_notifications:publish_notify_update(RespQ, P) end). --spec find_account_rep_email(api_object() | ne_binary()) -> api_binaries(). +-spec find_account_rep_email(kz_term:api_object() | kz_term:ne_binary()) -> kz_term:api_binaries(). find_account_rep_email('undefined') -> 'undefined'; find_account_rep_email(?NE_BINARY=AccountId) -> case kz_services:is_reseller(AccountId) of @@ -483,8 +483,8 @@ find_account_rep_email(?NE_BINARY=AccountId) -> find_account_rep_email(AccountJObj) -> find_account_rep_email(kapi_notifications:account_id(AccountJObj)). --spec find_account_admin_email(api_binary()) -> api_binaries(). --spec find_account_admin_email(api_binary(), api_binary()) -> api_binaries(). +-spec find_account_admin_email(kz_term:api_binary()) -> kz_term:api_binaries(). +-spec find_account_admin_email(kz_term:api_binary(), kz_term:api_binary()) -> kz_term:api_binaries(). find_account_admin_email('undefined') -> 'undefined'; find_account_admin_email(AccountId) -> find_account_admin_email(AccountId, find_reseller_id(AccountId)). @@ -502,7 +502,7 @@ find_account_admin_email(AccountId, ResellerId) -> Emails -> Emails end. --spec query_account_for_admin_emails(ne_binary()) -> ne_binaries(). +-spec query_account_for_admin_emails(kz_term:ne_binary()) -> kz_term:ne_binaries(). query_account_for_admin_emails(<<_/binary>> = AccountId) -> AccountDb = kz_util:format_account_db(AccountId), ViewOptions = [{'key', <<"user">>} @@ -516,18 +516,18 @@ query_account_for_admin_emails(<<_/binary>> = AccountId) -> [] end. --spec extract_admin_emails(kzd_user:docs()) -> ne_binaries(). +-spec extract_admin_emails(kzd_user:docs()) -> kz_term:ne_binaries(). extract_admin_emails(Users) -> [Email || Admin <- filter_for_admins(Users), (Email = kzd_user:email(Admin)) =/= 'undefined' ]. --spec find_reseller_id(ne_binary()) -> ne_binary(). +-spec find_reseller_id(kz_term:ne_binary()) -> kz_term:ne_binary(). find_reseller_id(AccountId) -> kz_services:find_reseller_id(AccountId). --spec find_account_admin(api_binary()) -> api_object(). --spec find_account_admin(ne_binary(), ne_binary()) -> 'undefined' | kzd_user:doc(). +-spec find_account_admin(kz_term:api_binary()) -> kz_term:api_object(). +-spec find_account_admin(kz_term:ne_binary(), kz_term:ne_binary()) -> 'undefined' | kzd_user:doc(). find_account_admin('undefined') -> 'undefined'; find_account_admin(?MATCH_ACCOUNT_RAW(AccountId)) -> find_account_admin(AccountId, find_reseller_id(AccountId)). @@ -540,7 +540,7 @@ find_account_admin(AccountId, ResellerId) -> Admin -> Admin end. --spec query_for_account_admin(ne_binary()) -> 'undefined' | kzd_user:doc(). +-spec query_for_account_admin(kz_term:ne_binary()) -> 'undefined' | kzd_user:doc(). query_for_account_admin(AccountId) -> AccountDb = kz_util:format_account_db(AccountId), ViewOptions = [{'key', <<"user">>} @@ -587,7 +587,7 @@ should_handle_notification(JObj, 'false') -> lager:debug("notification configuration is: ~p", [Config]), Config =:= ?APP_NAME. --spec is_notice_enabled(api_binary(), kz_json:object(), ne_binary()) -> boolean(). +-spec is_notice_enabled(kz_term:api_binary(), kz_json:object(), kz_term:ne_binary()) -> boolean(). is_notice_enabled('undefined', _ApiJObj, TemplateKey) -> is_notice_enabled_default(TemplateKey); is_notice_enabled(AccountId, ApiJObj, TemplateKey) -> @@ -598,7 +598,7 @@ is_notice_enabled(AccountId, ApiJObj, TemplateKey) -> is_account_notice_enabled(AccountId, TemplateKey, ResellerAccountId) end. --spec is_account_notice_enabled(api_binary(), ne_binary(), ne_binary()) -> boolean(). +-spec is_account_notice_enabled(kz_term:api_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_account_notice_enabled('undefined', TemplateKey, _ResellerAccountId) -> lager:debug("no account id to check, checking system config for ~s", [TemplateKey]), is_notice_enabled_default(TemplateKey); @@ -620,7 +620,7 @@ is_account_notice_enabled(AccountId, TemplateKey, ResellerAccountId) -> is_notice_enabled_default(TemplateKey) end. --spec is_notice_enabled_default(ne_binary()) -> boolean(). +-spec is_notice_enabled_default(kz_term:ne_binary()) -> boolean(). is_notice_enabled_default(TemplateKey) -> TemplateId = teletype_templates:doc_id(TemplateKey), case kz_datamgr:open_cache_doc(?KZ_CONFIG_DB, TemplateId) of @@ -632,7 +632,7 @@ is_notice_enabled_default(TemplateKey) -> 'false' end. --spec get_parent_account_id(ne_binary()) -> api_binary(). +-spec get_parent_account_id(kz_term:ne_binary()) -> kz_term:api_binary(). get_parent_account_id(AccountId) -> case kz_account:fetch(AccountId) of {'ok', JObj} -> kz_account:parent_account_id(JObj); @@ -641,9 +641,9 @@ get_parent_account_id(AccountId) -> 'undefined' end. --spec find_addresses(kz_json:object(), kz_json:object(), ne_binary()) -> +-spec find_addresses(kz_json:object(), kz_json:object(), kz_term:ne_binary()) -> email_map(). --spec find_addresses(kz_json:object(), kz_json:object(), ne_binary(), ne_binaries(), email_map()) -> +-spec find_addresses(kz_json:object(), kz_json:object(), kz_term:ne_binary(), kz_term:ne_binaries(), email_map()) -> email_map(). find_addresses(DataJObj, TemplateMetaJObj, ConfigCat) -> AddressKeys = [<<"to">>, <<"cc">>, <<"bcc">>, <<"from">>, <<"reply_to">>], @@ -658,10 +658,10 @@ find_addresses(DataJObj, TemplateMetaJObj, ConfigCat, [Key|Keys], Acc) -> ,[find_address(DataJObj, TemplateMetaJObj, ConfigCat, Key)|Acc] ). --spec find_address(kz_json:object(), kz_json:object(), ne_binary(), ne_binary()) -> - {ne_binary(), api_ne_binaries()}. --spec find_address(kz_json:object(), kz_json:object(), ne_binary(), ne_binary(), api_binary()) -> - {ne_binary(), api_ne_binaries()}. +-spec find_address(kz_json:object(), kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> + {kz_term:ne_binary(), kz_term:api_ne_binaries()}. +-spec find_address(kz_json:object(), kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary()) -> + {kz_term:ne_binary(), kz_term:api_ne_binaries()}. find_address(DataJObj, TemplateMetaJObj, ConfigCat, Key) -> find_address(DataJObj ,TemplateMetaJObj @@ -689,7 +689,7 @@ find_address(DataJObj, _TemplateMetaJObj, ConfigCat, Key, ?EMAIL_ADMINS) -> lager:debug("looking for admin emails for '~s'", [Key]), {Key, find_admin_emails(DataJObj, ConfigCat, Key)}. --spec find_first_defined_address(ne_binary(), kz_json:paths(), kz_json:objects()) -> api_ne_binaries(). +-spec find_first_defined_address(kz_term:ne_binary(), kz_json:paths(), kz_json:objects()) -> kz_term:api_ne_binaries(). find_first_defined_address(_Key, [], _JObjs) -> 'undefined'; find_first_defined_address(Key, [Path|Paths], JObjs) -> case get_address_value(Key, Path, JObjs) of @@ -697,7 +697,7 @@ find_first_defined_address(Key, [Path|Paths], JObjs) -> Emails -> Emails end. --spec get_address_value(ne_binary(), kz_json:path(), kz_json:objects()) -> api_ne_binaries(). +-spec get_address_value(kz_term:ne_binary(), kz_json:path(), kz_json:objects()) -> kz_term:api_ne_binaries(). get_address_value(_Key, _Path, []) -> 'undefined'; get_address_value(Key, Path, [JObj|JObjs]) -> Email0 = kz_json:get_value(Key, JObj), @@ -706,7 +706,7 @@ get_address_value(Key, Path, [JObj|JObjs]) -> Emails -> Emails end. --spec check_address_value(binary() | binaries() | kz_json:object() | 'undefined') -> api_ne_binaries(). +-spec check_address_value(binary() | kz_term:binaries() | kz_json:object() | 'undefined') -> kz_term:api_ne_binaries(). check_address_value('undefined') -> 'undefined'; check_address_value(<<>>) -> 'undefined'; check_address_value(<<_/binary>> = Email) -> [Email]; @@ -718,8 +718,8 @@ check_address_value(Emails) when is_list(Emails) -> check_address_value(JObj) -> check_address_value(kz_json:get_value(<<"email_addresses">>, JObj)). --spec find_admin_emails(kz_json:object(), ne_binary(), kz_json:path()) -> - api_ne_binaries(). +-spec find_admin_emails(kz_json:object(), kz_term:ne_binary(), kz_json:path()) -> + kz_term:api_ne_binaries(). find_admin_emails(DataJObj, ConfigCat, Key) -> case find_account_rep_email(kapi_notifications:account_id(DataJObj)) of 'undefined' -> @@ -728,14 +728,14 @@ find_admin_emails(DataJObj, ConfigCat, Key) -> Emails -> Emails end. --spec admin_emails_from_system_template(ne_binary(), kz_json:path()) -> api_ne_binaries(). +-spec admin_emails_from_system_template(kz_term:ne_binary(), kz_json:path()) -> kz_term:api_ne_binaries(). admin_emails_from_system_template(ConfigCat, Key) -> case kz_datamgr:open_cache_doc(?KZ_CONFIG_DB, ConfigCat) of {'ok', JObj} -> admin_emails_from_system_template(ConfigCat, Key, JObj); {'error', _} -> 'undefined' end. --spec admin_emails_from_system_template(ne_binary(), kz_json:path(), kz_json:object()) -> api_ne_binaries(). +-spec admin_emails_from_system_template(kz_term:ne_binary(), kz_json:path(), kz_json:object()) -> kz_term:api_ne_binaries(). admin_emails_from_system_template(ConfigCat, Key, JObj) -> case check_address_value(kz_json:get_ne_value([<<"default">>, <<"default_", Key/binary>>], JObj)) of 'undefined' -> @@ -748,7 +748,7 @@ admin_emails_from_system_template(ConfigCat, Key, JObj) -> Emails -> Emails end. --spec template_system_value(ne_binary()) -> kz_json:object(). +-spec template_system_value(kz_term:ne_binary()) -> kz_json:object(). template_system_value(TemplateId) -> ConfigCat = teletype_templates:doc_id(TemplateId), case kz_datamgr:open_cache_doc(?KZ_CONFIG_DB, ConfigCat) of @@ -756,15 +756,15 @@ template_system_value(TemplateId) -> {'error', _} -> kz_json:new() end. --spec template_system_value(ne_binary(), kz_json:path()) -> any(). +-spec template_system_value(kz_term:ne_binary(), kz_json:path()) -> any(). template_system_value(TemplateId, Key) -> template_system_value(TemplateId, Key, 'undefined'). --spec template_system_value(ne_binary(), kz_json:path(), any()) -> any(). +-spec template_system_value(kz_term:ne_binary(), kz_json:path(), any()) -> any(). template_system_value(TemplateId, Key, Default) -> kz_json:get_first_defined([Key, lists:flatten([<<"default">>, Key])], template_system_value(TemplateId), Default). --spec open_doc(ne_binary(), api_binary(), kz_json:object()) -> +-spec open_doc(kz_term:ne_binary(), kz_term:api_binary(), kz_json:object()) -> {'ok', kz_json:object()} | {'error', any()}. open_doc(Type, 'undefined', DataJObj) -> @@ -779,7 +779,7 @@ open_doc(Type, DocId, DataJObj) -> -type read_file_error() :: file:posix() | 'badarg' | 'terminated' | 'system_limit'. --spec maybe_load_preview(ne_binary(), E, boolean()) -> +-spec maybe_load_preview(kz_term:ne_binary(), E, boolean()) -> {'ok', kz_json:object()} | {'error', read_file_error()} | E. maybe_load_preview(_Type, Error, 'false') -> @@ -787,7 +787,7 @@ maybe_load_preview(_Type, Error, 'false') -> maybe_load_preview(Type, _Error, 'true') -> read_preview_doc(Type). --spec read_preview_doc(ne_binary()) -> +-spec read_preview_doc(kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', read_file_error()}. read_preview_doc(File) -> @@ -809,11 +809,11 @@ is_preview(DataJObj) -> %% make timestamp ready to process by "date" filter in ErlyDTL %% returns a prop list with local, UTC time and timezone --spec fix_timestamp(gregorian_seconds() | api_ne_binary()) -> kz_proplist(). +-spec fix_timestamp(kz_time:gregorian_seconds() | kz_term:api_ne_binary()) -> kz_term:proplist(). fix_timestamp(Timestamp) -> fix_timestamp(Timestamp, <<"UTC">>). --spec fix_timestamp(gregorian_seconds() | api_ne_binary(), api_binary() | kz_json:object()) -> kz_proplist(). +-spec fix_timestamp(kz_time:gregorian_seconds() | kz_term:api_ne_binary(), kz_term:api_binary() | kz_json:object()) -> kz_term:proplist(). fix_timestamp('undefined', Thing) -> fix_timestamp(kz_time:now_s(), Thing); fix_timestamp(?NE_BINARY=Timestamp, Thing) -> @@ -836,13 +836,13 @@ fix_timestamp(Timestamp, DataJObj) -> TZ = props:get_ne_binary_value(<<"timezone">>, Params), fix_timestamp(Timestamp, TZ). --spec fix_timestamp(gregorian_seconds() | api_ne_binary(), kz_json:object(), api_ne_binary()) -> kz_proplist(). +-spec fix_timestamp(kz_time:gregorian_seconds() | kz_term:api_ne_binary(), kz_json:object(), kz_term:api_ne_binary()) -> kz_term:proplist(). fix_timestamp(Timestamp, DataJObj, 'undefined') -> fix_timestamp(Timestamp, DataJObj); fix_timestamp(Timestamp, _DataJObj, TZ) -> fix_timestamp(Timestamp, TZ). --spec build_call_data(kz_json:object(), api_ne_binary()) -> kz_proplist(). +-spec build_call_data(kz_json:object(), kz_term:api_ne_binary()) -> kz_term:proplist(). build_call_data(DataJObj, Timezone) -> props:filter_empty( [{<<"caller_id">>, build_caller_id_data(DataJObj)} @@ -853,27 +853,27 @@ build_call_data(DataJObj, Timezone) -> ,{<<"call_id">>, kz_json:get_value(<<"call_id">>, DataJObj)} ]). --spec build_caller_id_data(kz_json:object()) -> kz_proplist(). +-spec build_caller_id_data(kz_json:object()) -> kz_term:proplist(). build_caller_id_data(DataJObj) -> props:filter_undefined( [{<<"name">>, knm_util:pretty_print(kz_json:get_ne_binary_value(<<"caller_id_name">>, DataJObj))} ,{<<"number">>, knm_util:pretty_print(kz_json:get_ne_binary_value(<<"caller_id_number">>, DataJObj))} ]). --spec build_callee_id_data(kz_json:object()) -> kz_proplist(). +-spec build_callee_id_data(kz_json:object()) -> kz_term:proplist(). build_callee_id_data(DataJObj) -> props:filter_undefined( [{<<"name">>, knm_util:pretty_print(kz_json:get_ne_binary_value(<<"callee_id_name">>, DataJObj))} ,{<<"number">>, knm_util:pretty_print(kz_json:get_ne_binary_value(<<"callee_id_number">>, DataJObj))} ]). --spec build_date_called_data(kz_json:object(), api_ne_binary()) -> kz_proplist(). +-spec build_date_called_data(kz_json:object(), kz_term:api_ne_binary()) -> kz_term:proplist(). build_date_called_data(DataJObj, Timezone) -> DateCalled = find_date_called(DataJObj), Timezone = kz_json:get_ne_binary_value(<<"timezone">>, DataJObj, Timezone), fix_timestamp(DateCalled, DataJObj, Timezone). --spec find_date_called(kz_json:object()) -> gregorian_seconds(). +-spec find_date_called(kz_json:object()) -> kz_time:gregorian_seconds(). find_date_called(DataJObj) -> Paths = [<<"voicemail_timestamp">> ,<<"fax_timestamp">> @@ -884,7 +884,7 @@ find_date_called(DataJObj) -> catch _:_ -> kz_time:now_s() end. --spec build_from_data(kz_json:object()) -> kz_proplist(). +-spec build_from_data(kz_json:object()) -> kz_term:proplist(). build_from_data(DataJObj) -> FromE164 = kz_json:get_first_defined([<<"from_user">>, <<"caller_id_number">>], DataJObj), props:filter_undefined( @@ -892,7 +892,7 @@ build_from_data(DataJObj) -> ,{<<"realm">>, kz_json:get_ne_binary_value(<<"from_realm">>, DataJObj)} ]). --spec build_to_data(kz_json:object()) -> kz_proplist(). +-spec build_to_data(kz_json:object()) -> kz_term:proplist(). build_to_data(DataJObj) -> ToE164 = kz_json:get_first_defined([<<"to_user">>, <<"callee_id_number">>], DataJObj), props:filter_undefined( @@ -900,7 +900,7 @@ build_to_data(DataJObj) -> ,{<<"realm">>, kz_json:get_ne_binary_value(<<"to_realm">>, DataJObj)} ]). --spec public_proplist(kz_json:path(), kz_json:object()) -> kz_proplist(). +-spec public_proplist(kz_json:path(), kz_json:object()) -> kz_term:proplist(). public_proplist(Key, JObj) -> kz_json:recursive_to_proplist( kz_doc:public_fields( @@ -908,22 +908,22 @@ public_proplist(Key, JObj) -> ) ). --spec notification_completed(ne_binary()) -> template_response(). +-spec notification_completed(kz_term:ne_binary()) -> template_response(). notification_completed(TemplateId) -> {'completed', TemplateId}. --spec notification_ignored(ne_binary()) -> template_response(). +-spec notification_ignored(kz_term:ne_binary()) -> template_response(). notification_ignored(TemplateId) -> {'ignored', TemplateId}. --spec notification_failed(ne_binary(), any()) -> template_response(). +-spec notification_failed(kz_term:ne_binary(), any()) -> template_response(). notification_failed(TemplateId, Reason) -> {'failed', Reason, TemplateId}. --spec notification_disabled(ne_binary(), kz_json:object()) -> template_response(). +-spec notification_disabled(kz_term:ne_binary(), kz_json:object()) -> template_response(). notification_disabled(DataJObj, TemplateId) -> AccountId = kapi_notifications:account_id(DataJObj), lager:debug("notification ~s is disabled for account ~s", [TemplateId, AccountId]), {'disabled', TemplateId}. --spec maybe_get_attachments(kz_json:object() | api_binary()) -> attachments(). +-spec maybe_get_attachments(kz_json:object() | kz_term:api_binary()) -> attachments(). maybe_get_attachments('undefined') -> []; maybe_get_attachments(URL) when is_binary(URL) -> @@ -934,7 +934,7 @@ maybe_get_attachments(URL) maybe_get_attachments(DataObj) -> maybe_get_attachments(kz_json:get_value(<<"attachment_url">>, DataObj)). --spec fetch_attachment_from_url(ne_binary()) -> {'ok', attachment()} | {'error', any()}. +-spec fetch_attachment_from_url(kz_term:ne_binary()) -> {'ok', attachment()} | {'error', any()}. fetch_attachment_from_url(URL) -> case kz_http:get(kz_term:to_list(URL)) of {'ok', _2xx, Headers, Body} @@ -948,7 +948,7 @@ fetch_attachment_from_url(URL) -> Error end. --spec attachment_from_url_result(kz_proplist(), binary()) -> attachment(). +-spec attachment_from_url_result(kz_term:proplist(), binary()) -> attachment(). attachment_from_url_result(Headers, Body) -> CT = kz_term:to_binary(props:get_value("content-type", Headers, <<"text/plain">>)), Disposition = kz_term:to_binary(props:get_value("content-disposition", Headers, <<>>)), diff --git a/applications/teletype/src/templates/teletype_account_zone_change.erl b/applications/teletype/src/templates/teletype_account_zone_change.erl index 8ef34d3a462..4a091f110f7 100644 --- a/applications/teletype/src/templates/teletype_account_zone_change.erl +++ b/applications/teletype/src/templates/teletype_account_zone_change.erl @@ -93,7 +93,7 @@ process_req(DataJObj) -> {'error', Reason} -> teletype_util:notification_failed(?TEMPLATE_ID, Reason) end. --spec zones_data(kz_json:object()) -> kz_proplist(). +-spec zones_data(kz_json:object()) -> kz_term:proplist(). zones_data(DataJObj) -> case teletype_util:is_preview(DataJObj) of 'false' -> diff --git a/applications/teletype/src/templates/teletype_cnam_request.erl b/applications/teletype/src/templates/teletype_cnam_request.erl index 0e5936cf723..afe678be8f7 100644 --- a/applications/teletype/src/templates/teletype_cnam_request.erl +++ b/applications/teletype/src/templates/teletype_cnam_request.erl @@ -84,7 +84,7 @@ handle_req(JObj, 'true') -> 'true' -> process_req(CNAMJObj) end. --spec cnam_data(kz_json:object()) -> api_object(). +-spec cnam_data(kz_json:object()) -> kz_term:api_object(). cnam_data(DataJObj) -> case teletype_util:is_preview(DataJObj) of 'false' -> diff --git a/applications/teletype/src/templates/teletype_customer_update.erl b/applications/teletype/src/templates/teletype_customer_update.erl index 3d267c7f96f..a90abffde9d 100644 --- a/applications/teletype/src/templates/teletype_customer_update.erl +++ b/applications/teletype/src/templates/teletype_customer_update.erl @@ -100,7 +100,7 @@ process_accounts(DataJObj) -> [{'error', kz_term:to_binary(Msg), ?TEMPLATE_ID}] end. --spec process_account(ne_binary(), kz_json:object()) -> template_responses(). +-spec process_account(kz_term:ne_binary(), kz_json:object()) -> template_responses(). process_account(AccountId, DataJObj) -> case kz_json:get_value(<<"user_type">>, DataJObj) of ?MATCH_ACCOUNT_RAW(UserId) -> @@ -142,11 +142,11 @@ send_update_to_user(UserJObj, DataJObj) -> {'error', Reason} -> teletype_util:notification_failed(?TEMPLATE_ID, Reason) end. --spec maybe_replace_to_field(email_map(), api_binary()) -> email_map(). +-spec maybe_replace_to_field(email_map(), kz_term:api_binary()) -> email_map(). maybe_replace_to_field(Emails, 'undefined') -> Emails; maybe_replace_to_field(Emails, To) -> props:set_value(<<"to">>, [To], Emails). --spec build_macro_data(kz_json:object(), kz_json:object()) -> kz_proplist(). +-spec build_macro_data(kz_json:object(), kz_json:object()) -> kz_term:proplist(). build_macro_data(UserJObj, DataJObj) -> case teletype_util:is_preview(DataJObj) of 'true' -> []; @@ -159,14 +159,14 @@ build_macro_data(UserJObj, DataJObj) -> ) end. --spec maybe_add_macro_key(kz_json:path(), kz_proplist(), kz_json:object()) -> kz_proplist(). +-spec maybe_add_macro_key(kz_json:path(), kz_term:proplist(), kz_json:object()) -> kz_term:proplist(). maybe_add_macro_key(<<"user.", UserKey/binary>>, Acc, UserJObj) -> maybe_add_user_data(UserKey, Acc, UserJObj); maybe_add_macro_key(_Key, Acc, _UserJObj) -> lager:debug("unprocessed macro key ~s: ~p", [_Key, _UserJObj]), Acc. --spec maybe_add_user_data(kz_json:path(), kz_proplist(), kz_json:object()) -> kz_proplist(). +-spec maybe_add_user_data(kz_json:path(), kz_term:proplist(), kz_json:object()) -> kz_term:proplist(). maybe_add_user_data(Key, Acc, UserJObj) -> UserMacros = props:get_value(<<"user">>, Acc, []), case kz_json:get_value(Key, UserJObj) of @@ -176,7 +176,7 @@ maybe_add_user_data(Key, Acc, UserJObj) -> V -> props:set_value(<<"user">>, [{Key, V} | UserMacros], Acc) end. --spec maybe_expand_template_id(kz_json:object()) -> ne_binary(). +-spec maybe_expand_template_id(kz_json:object()) -> kz_term:ne_binary(). maybe_expand_template_id(DataJObj) -> case kz_json:get_value(<<"template_id">>, DataJObj) of <<"customer_update_", _/binary>> = TemplateId -> @@ -185,7 +185,7 @@ maybe_expand_template_id(DataJObj) -> ?TEMPLATE_ID end. --spec maybe_expanded_config_id(kz_json:object()) -> ne_binary(). +-spec maybe_expanded_config_id(kz_json:object()) -> kz_term:ne_binary(). maybe_expanded_config_id(DataJObj) -> case kz_json:get_value(<<"template_id">>, DataJObj) of <<"customer_update_", _/binary>> = TemplateId -> TemplateId; diff --git a/applications/teletype/src/templates/teletype_deregister.erl b/applications/teletype/src/templates/teletype_deregister.erl index 8904b4c80f0..e1d355bd5f7 100644 --- a/applications/teletype/src/templates/teletype_deregister.erl +++ b/applications/teletype/src/templates/teletype_deregister.erl @@ -21,7 +21,7 @@ -include("teletype.hrl"). --spec id() -> ne_binary(). +-spec id() -> kz_term:ne_binary(). id() -> <<"deregister">>. -spec macros() -> kz_json:object(). @@ -46,19 +46,19 @@ macros() -> | ?COMMON_TEMPLATE_MACROS ]). --spec subject() -> ne_binary(). +-spec subject() -> kz_term:ne_binary(). subject() -> <<"Loss of Registration for '{{last_registration.username}}'">>. --spec category() -> ne_binary(). +-spec category() -> kz_term:ne_binary(). category() -> <<"registration">>. --spec friendly_name() -> ne_binary(). +-spec friendly_name() -> kz_term:ne_binary(). friendly_name() -> <<"Deregister Notice">>. -spec to() -> kz_json:object(). to() -> ?CONFIGURED_EMAILS(?EMAIL_ADMINS). --spec from() -> api_ne_binary(). +-spec from() -> kz_term:api_ne_binary(). from() -> teletype_util:default_from_address(). -spec cc() -> kz_json:object(). @@ -67,7 +67,7 @@ cc() -> ?CONFIGURED_EMAILS(?EMAIL_SPECIFIED, []). -spec bcc() -> kz_json:object(). bcc() -> ?CONFIGURED_EMAILS(?EMAIL_SPECIFIED, []). --spec reply_to() -> api_ne_binary(). +-spec reply_to() -> kz_term:api_ne_binary(). reply_to() -> teletype_util:default_reply_to(). -spec init() -> 'ok'. @@ -114,11 +114,11 @@ process_req(DataJObj) -> {'error', Reason} -> teletype_util:notification_failed(id(), Reason) end. --spec macros(kz_json:object()) -> kz_proplist(). +-spec macros(kz_json:object()) -> kz_term:proplist(). macros(DataJObj) -> macros(DataJObj, teletype_util:account_params(DataJObj)). --spec macros(kz_json:object(), kz_proplist()) -> kz_proplist(). +-spec macros(kz_json:object(), kz_term:proplist()) -> kz_term:proplist(). macros(DataJObj, []) -> lager:info("no account data available for deregister, not sending notification"), teletype_util:send_update(DataJObj, <<"failed">>, <<"missing account">>), diff --git a/applications/teletype/src/templates/teletype_fax_inbound_error_to_email.erl b/applications/teletype/src/templates/teletype_fax_inbound_error_to_email.erl index 447a9a97a96..95cac6d857f 100644 --- a/applications/teletype/src/templates/teletype_fax_inbound_error_to_email.erl +++ b/applications/teletype/src/templates/teletype_fax_inbound_error_to_email.erl @@ -76,7 +76,7 @@ handle_req(JObj, 'true') -> process_req(teletype_fax_util:add_data(DataJObj), ?TEMPLATE_ID, TemplateMetaJObj) end. --spec process_req(kz_json:object(), ne_binary(), kz_json:object()) -> template_response(). +-spec process_req(kz_json:object(), kz_term:ne_binary(), kz_json:object()) -> template_response(). process_req(DataJObj, TemplateId, TemplateMetaJObj) -> TemplateData = build_template_data(DataJObj), {Macros, EmailAttachements} = teletype_fax_util:add_attachments(DataJObj, TemplateData, 'false'), @@ -105,7 +105,7 @@ process_req(DataJObj, TemplateId, TemplateMetaJObj) -> {'error', Reason} -> teletype_util:notification_failed(TemplateId, Reason) end. --spec build_template_data(kz_json:object()) -> kz_proplist(). +-spec build_template_data(kz_json:object()) -> kz_term:proplist(). build_template_data(DataJObj) -> Timezone = kz_json:get_value(<<"timezone">>, DataJObj), props:filter_undefined( @@ -117,7 +117,7 @@ build_template_data(DataJObj) -> | teletype_util:build_call_data(DataJObj, Timezone) ]). --spec build_fax_template_data(kz_json:object()) -> kz_proplist(). +-spec build_fax_template_data(kz_json:object()) -> kz_term:proplist(). build_fax_template_data(DataJObj) -> FaxJObj = kz_json:get_value(<<"fax_doc">>, DataJObj), FaxBoxJObj = kz_json:get_value(<<"faxbox">>, DataJObj), diff --git a/applications/teletype/src/templates/teletype_fax_inbound_error_to_email_filtered.erl b/applications/teletype/src/templates/teletype_fax_inbound_error_to_email_filtered.erl index a0f70762b72..0f63bc233e3 100644 --- a/applications/teletype/src/templates/teletype_fax_inbound_error_to_email_filtered.erl +++ b/applications/teletype/src/templates/teletype_fax_inbound_error_to_email_filtered.erl @@ -74,7 +74,7 @@ handle_req(JObj, 'true') -> teletype_fax_inbound_error_to_email:process_req(teletype_fax_util:add_data(DataJObj), ?TEMPLATE_ID, TemplateMetaJObj) end. --spec is_notice_enabled(ne_binary(), kz_json:object()) -> kz_json:object() | 'disabled' | 'ignored'. +-spec is_notice_enabled(kz_term:ne_binary(), kz_json:object()) -> kz_json:object() | 'disabled' | 'ignored'. is_notice_enabled(AccountId, JObj) -> {'ok', TemplateMetaJObj} = teletype_templates:fetch_notification(?TEMPLATE_ID, AccountId), case teletype_util:is_notice_enabled(AccountId, JObj, ?TEMPLATE_ID) of diff --git a/applications/teletype/src/templates/teletype_fax_inbound_to_email.erl b/applications/teletype/src/templates/teletype_fax_inbound_to_email.erl index d63e4709149..8948e93b04c 100644 --- a/applications/teletype/src/templates/teletype_fax_inbound_to_email.erl +++ b/applications/teletype/src/templates/teletype_fax_inbound_to_email.erl @@ -102,7 +102,7 @@ process_req(DataJObj) -> {'error', Reason} -> teletype_util:notification_failed(?TEMPLATE_ID, Reason) end. --spec build_template_data(kz_json:object()) -> kz_proplist(). +-spec build_template_data(kz_json:object()) -> kz_term:proplist(). build_template_data(DataJObj) -> Timezone = kz_json:get_value(<<"timezone">>, DataJObj), props:filter_undefined( @@ -113,7 +113,7 @@ build_template_data(DataJObj) -> | teletype_util:build_call_data(DataJObj, Timezone) ]). --spec build_fax_template_data(kz_json:object()) -> kz_proplist(). +-spec build_fax_template_data(kz_json:object()) -> kz_term:proplist(). build_fax_template_data(DataJObj) -> FaxJObj = kz_json:get_value(<<"fax_doc">>, DataJObj), FaxBoxJObj = kz_json:get_value(<<"faxbox">>, DataJObj), diff --git a/applications/teletype/src/templates/teletype_fax_outbound_error_to_email.erl b/applications/teletype/src/templates/teletype_fax_outbound_error_to_email.erl index 06a0816e87d..62547458af2 100644 --- a/applications/teletype/src/templates/teletype_fax_outbound_error_to_email.erl +++ b/applications/teletype/src/templates/teletype_fax_outbound_error_to_email.erl @@ -106,7 +106,7 @@ process_req(DataJObj) -> {'error', Reason} -> teletype_util:notification_failed(?TEMPLATE_ID, Reason) end. --spec build_template_data(kz_json:object()) -> kz_proplist(). +-spec build_template_data(kz_json:object()) -> kz_term:proplist(). build_template_data(DataJObj) -> Timezone = kz_json:get_value(<<"timezone">>, DataJObj), props:filter_undefined( @@ -118,7 +118,7 @@ build_template_data(DataJObj) -> | teletype_util:build_call_data(DataJObj, Timezone) ]). --spec build_fax_template_data(kz_json:object()) -> kz_proplist(). +-spec build_fax_template_data(kz_json:object()) -> kz_term:proplist(). build_fax_template_data(DataJObj) -> FaxJObj = kz_json:get_value(<<"fax_doc">>, DataJObj), FaxBoxJObj = kz_json:get_value(<<"faxbox">>, DataJObj), diff --git a/applications/teletype/src/templates/teletype_fax_outbound_smtp_error_to_email.erl b/applications/teletype/src/templates/teletype_fax_outbound_smtp_error_to_email.erl index ea344fa2402..40ed1cb2190 100644 --- a/applications/teletype/src/templates/teletype_fax_outbound_smtp_error_to_email.erl +++ b/applications/teletype/src/templates/teletype_fax_outbound_smtp_error_to_email.erl @@ -88,7 +88,7 @@ process_req(DataJObj) -> {'error', Reason} -> teletype_util:notification_failed(?TEMPLATE_ID, Reason) end. --spec build_macros(kz_json:object()) -> kz_proplist(). +-spec build_macros(kz_json:object()) -> kz_term:proplist(). build_macros(DataJObj) -> [Error | _]=Errors = kz_json:get_list_value(<<"errors">>, DataJObj), diff --git a/applications/teletype/src/templates/teletype_fax_outbound_to_email.erl b/applications/teletype/src/templates/teletype_fax_outbound_to_email.erl index 885033bfba9..3075bdf3362 100644 --- a/applications/teletype/src/templates/teletype_fax_outbound_to_email.erl +++ b/applications/teletype/src/templates/teletype_fax_outbound_to_email.erl @@ -102,7 +102,7 @@ process_req(DataJObj) -> {'error', Reason} -> teletype_util:notification_failed(?TEMPLATE_ID, Reason) end. --spec build_template_data(kz_json:object()) -> kz_proplist(). +-spec build_template_data(kz_json:object()) -> kz_term:proplist(). build_template_data(DataJObj) -> Timezone = kz_json:get_value(<<"timezone">>, DataJObj), props:filter_undefined( @@ -113,7 +113,7 @@ build_template_data(DataJObj) -> | teletype_util:build_call_data(DataJObj, Timezone) ]). --spec build_fax_template_data(kz_json:object()) -> kz_proplist(). +-spec build_fax_template_data(kz_json:object()) -> kz_term:proplist(). build_fax_template_data(DataJObj) -> FaxJObj = kz_json:get_value(<<"fax_doc">>, DataJObj), FaxBoxJObj = kz_json:get_value(<<"faxbox">>, DataJObj), diff --git a/applications/teletype/src/templates/teletype_first_occurrence.erl b/applications/teletype/src/templates/teletype_first_occurrence.erl index 9e69fb79272..ba045612fbb 100644 --- a/applications/teletype/src/templates/teletype_first_occurrence.erl +++ b/applications/teletype/src/templates/teletype_first_occurrence.erl @@ -70,7 +70,7 @@ handle_req(JObj, 'true') -> 'true' -> process_req(DataJObj) end. --spec build_macro_data(kz_json:object()) -> kz_proplist(). +-spec build_macro_data(kz_json:object()) -> kz_term:proplist(). build_macro_data(DataJObj) -> AccountId = kz_json:get_value(<<"account_id">>, DataJObj), [{<<"system">>, teletype_util:system_params()} diff --git a/applications/teletype/src/templates/teletype_low_balance.erl b/applications/teletype/src/templates/teletype_low_balance.erl index 9edac225ab7..2c6650fb2bc 100644 --- a/applications/teletype/src/templates/teletype_low_balance.erl +++ b/applications/teletype/src/templates/teletype_low_balance.erl @@ -21,7 +21,7 @@ -include("teletype.hrl"). --spec id() -> ne_binary(). +-spec id() -> kz_term:ne_binary(). id() -> <<"low_balance">>. -spec macros() -> kz_json:object(). @@ -32,19 +32,19 @@ macros() -> | ?COMMON_TEMPLATE_MACROS ]). --spec subject() -> ne_binary(). +-spec subject() -> kz_term:ne_binary(). subject() -> <<"Account '{{account.name}}' is running out of credit">>. --spec category() -> ne_binary(). +-spec category() -> kz_term:ne_binary(). category() -> <<"account">>. --spec friendly_name() -> ne_binary(). +-spec friendly_name() -> kz_term:ne_binary(). friendly_name() -> <<"Low Balance">>. -spec to() -> kz_json:object(). to() -> ?CONFIGURED_EMAILS(?EMAIL_ADMINS). --spec from() -> api_ne_binary(). +-spec from() -> kz_term:api_ne_binary(). from() -> teletype_util:default_from_address(). -spec cc() -> kz_json:object(). @@ -53,7 +53,7 @@ cc() -> ?CONFIGURED_EMAILS(?EMAIL_SPECIFIED, []). -spec bcc() -> kz_json:object(). bcc() -> ?CONFIGURED_EMAILS(?EMAIL_SPECIFIED, []). --spec reply_to() -> api_ne_binary(). +-spec reply_to() -> kz_term:api_ne_binary(). reply_to() -> teletype_util:default_reply_to(). -spec init() -> 'ok'. @@ -100,7 +100,7 @@ process_req(DataJObj) -> {'error', Reason} -> teletype_util:notification_failed(id(), Reason) end. --spec macros(kz_json:object()) -> kz_proplist(). +-spec macros(kz_json:object()) -> kz_term:proplist(). macros(DataJObj) -> [{<<"system">>, teletype_util:system_params()} ,{<<"account">>, teletype_util:account_params(DataJObj)} @@ -109,7 +109,7 @@ macros(DataJObj) -> | build_macro_data(DataJObj) ]. --spec get_current_balance(kz_json:object()) -> ne_binary(). +-spec get_current_balance(kz_json:object()) -> kz_term:ne_binary(). get_current_balance(DataJObj) -> AccountId = kz_json:get_value(<<"account_id">>, DataJObj), case current_account_dollars(AccountId) of @@ -117,12 +117,12 @@ get_current_balance(DataJObj) -> {'error', _R} -> <<"not known at the moment">> end. --spec get_balance_threshold(kz_json:object()) -> ne_binary(). +-spec get_balance_threshold(kz_json:object()) -> kz_term:ne_binary(). get_balance_threshold(DataJObj) -> AccountId = kz_json:get_value(<<"account_id">>, DataJObj), wht_util:pretty_print_dollars(kz_account:low_balance_threshold(AccountId)). --spec build_macro_data(kz_json:object()) -> kz_proplist(). +-spec build_macro_data(kz_json:object()) -> kz_term:proplist(). build_macro_data(DataJObj) -> kz_json:foldl(fun(MacroKey, _V, Acc) -> maybe_add_macro_key(MacroKey, Acc, DataJObj) @@ -131,13 +131,13 @@ build_macro_data(DataJObj) -> ,macros() ). --spec maybe_add_macro_key(kz_json:path(), kz_proplist(), kz_json:object()) -> kz_proplist(). +-spec maybe_add_macro_key(kz_json:path(), kz_term:proplist(), kz_json:object()) -> kz_term:proplist(). maybe_add_macro_key(<<"user.", UserKey/binary>>, Acc, DataJObj) -> maybe_add_user_data(UserKey, Acc, DataJObj); maybe_add_macro_key(_Key, Acc, _DataJObj) -> Acc. --spec maybe_add_user_data(kz_json:path(), kz_proplist(), kz_json:object()) -> kz_proplist(). +-spec maybe_add_user_data(kz_json:path(), kz_term:proplist(), kz_json:object()) -> kz_term:proplist(). maybe_add_user_data(Key, Acc, DataJObj) -> User = get_user(DataJObj), case kz_json:get_value(Key, User) of diff --git a/applications/teletype/src/templates/teletype_missed_call.erl b/applications/teletype/src/templates/teletype_missed_call.erl index c625d29993d..cea95752cc1 100644 --- a/applications/teletype/src/templates/teletype_missed_call.erl +++ b/applications/teletype/src/templates/teletype_missed_call.erl @@ -99,18 +99,18 @@ process_req(DataJObj) -> {'error', Reason} -> teletype_util:notification_failed(?TEMPLATE_ID, Reason) end. --spec build_missed_call_data(kz_json:object()) -> kz_proplist(). +-spec build_missed_call_data(kz_json:object()) -> kz_term:proplist(). build_missed_call_data(DataJObj) -> [{<<"reason">>, missed_call_reason(DataJObj)} ,{<<"is_bridged">>, kz_term:is_true(kz_json:get_value(<<"call_bridged">>, DataJObj))} ,{<<"is_message_left">>, kz_term:is_true(kz_json:get_value(<<"message_left">>, DataJObj))} ]. --spec missed_call_reason(kz_json:object()) -> ne_binary(). +-spec missed_call_reason(kz_json:object()) -> kz_term:ne_binary(). missed_call_reason(DataJObj) -> missed_call_reason(DataJObj, kz_json:get_ne_binary_value([<<"notify">>, <<"hangup_cause">>], DataJObj)). --spec missed_call_reason(kz_json:object(), api_ne_binary()) -> ne_binary(). +-spec missed_call_reason(kz_json:object(), kz_term:api_ne_binary()) -> kz_term:ne_binary(). missed_call_reason(_DataJObj, 'undefined') -> <<"no voicemail message was left">>; missed_call_reason(_DataJObj, HangupCause) -> <<"No voicemail message was left (", HangupCause/binary, ")">>. diff --git a/applications/teletype/src/templates/teletype_new_account.erl b/applications/teletype/src/templates/teletype_new_account.erl index a4d88b490b6..e52874bdf13 100644 --- a/applications/teletype/src/templates/teletype_new_account.erl +++ b/applications/teletype/src/templates/teletype_new_account.erl @@ -21,7 +21,7 @@ -include("teletype.hrl"). --spec id() -> ne_binary(). +-spec id() -> kz_term:ne_binary(). id() -> <<"new_account">>. -spec macros() -> kz_json:object(). @@ -34,19 +34,19 @@ macros() -> | ?COMMON_TEMPLATE_MACROS ]). --spec subject() -> ne_binary(). +-spec subject() -> kz_term:ne_binary(). subject() -> <<"Your new VoIP services account '{{account.name}}' has been created">>. --spec category() -> ne_binary(). +-spec category() -> kz_term:ne_binary(). category() -> <<"account">>. --spec friendly_name() -> ne_binary(). +-spec friendly_name() -> kz_term:ne_binary(). friendly_name() -> <<"New Account">>. -spec to() -> kz_json:object(). to() -> ?CONFIGURED_EMAILS(?EMAIL_ADMINS). --spec from() -> api_ne_binary(). +-spec from() -> kz_term:api_ne_binary(). from() -> teletype_util:default_from_address(). -spec cc() -> kz_json:object(). @@ -55,7 +55,7 @@ cc() -> ?CONFIGURED_EMAILS(?EMAIL_SPECIFIED, []). -spec bcc() -> kz_json:object(). bcc() -> ?CONFIGURED_EMAILS(?EMAIL_SPECIFIED, []). --spec reply_to() -> api_ne_binary(). +-spec reply_to() -> kz_term:api_ne_binary(). reply_to() -> teletype_util:default_reply_to(). -spec init() -> 'ok'. @@ -102,14 +102,14 @@ process_req(DataJObj) -> {'error', Reason} -> teletype_util:notification_failed(id(), Reason) end. --spec macros(kz_json:object()) -> kz_proplist(). +-spec macros(kz_json:object()) -> kz_term:proplist(). macros(DataJObj) -> [{<<"system">>, teletype_util:system_params()} ,{<<"account">>, teletype_util:account_params(DataJObj)} ,{<<"admin">>, admin_user_properties(DataJObj)} ]. --spec admin_user_properties(kz_json:object()) -> kz_proplist(). +-spec admin_user_properties(kz_json:object()) -> kz_term:proplist(). admin_user_properties(DataJObj) -> AccountId = kz_json:get_value(<<"account_id">>, DataJObj), case kz_account:fetch(AccountId) of @@ -117,7 +117,7 @@ admin_user_properties(DataJObj) -> {'error', _} -> [] end. --spec account_admin_user_properties(kz_json:object()) -> kz_proplist(). +-spec account_admin_user_properties(kz_json:object()) -> kz_term:proplist(). account_admin_user_properties(AccountJObj) -> AccountDb = kz_doc:account_db(AccountJObj), case kz_datamgr:get_results(AccountDb, <<"users/crossbar_listing">>, ['include_docs']) of @@ -128,7 +128,7 @@ account_admin_user_properties(AccountJObj) -> find_admin(Users) end. --spec find_admin(kz_json:objects()) -> kz_proplist(). +-spec find_admin(kz_json:objects()) -> kz_term:proplist(). find_admin([]) -> ?LOG_DEBUG("account has no admin users"), []; diff --git a/applications/teletype/src/templates/teletype_new_user.erl b/applications/teletype/src/templates/teletype_new_user.erl index 59470f7df1f..63ee0b55d80 100644 --- a/applications/teletype/src/templates/teletype_new_user.erl +++ b/applications/teletype/src/templates/teletype_new_user.erl @@ -21,7 +21,7 @@ -include("teletype.hrl"). --spec id() -> ne_binary(). +-spec id() -> kz_term:ne_binary(). id() -> <<"new_user">>. -spec macros() -> kz_json:object(). @@ -32,19 +32,19 @@ macros() -> ++ ?COMMON_TEMPLATE_MACROS ]). --spec subject() -> ne_binary(). +-spec subject() -> kz_term:ne_binary(). subject() -> <<"Your new VoIP services user profile has been created">>. --spec category() -> ne_binary(). +-spec category() -> kz_term:ne_binary(). category() -> <<"user">>. --spec friendly_name() -> ne_binary(). +-spec friendly_name() -> kz_term:ne_binary(). friendly_name() -> <<"New User">>. -spec to() -> kz_json:object(). to() -> ?CONFIGURED_EMAILS(?EMAIL_ORIGINAL). --spec from() -> api_ne_binary(). +-spec from() -> kz_term:api_ne_binary(). from() -> teletype_util:default_from_address(). -spec cc() -> kz_json:object(). @@ -53,7 +53,7 @@ cc() -> ?CONFIGURED_EMAILS(?EMAIL_SPECIFIED, []). -spec bcc() -> kz_json:object(). bcc() -> ?CONFIGURED_EMAILS(?EMAIL_SPECIFIED, []). --spec reply_to() -> api_ne_binary(). +-spec reply_to() -> kz_term:api_ne_binary(). reply_to() -> teletype_util:default_reply_to(). -spec init() -> 'ok'. @@ -100,11 +100,11 @@ process_req(DataJObj) -> {'error', Reason} -> teletype_util:notification_failed(id(), Reason) end. --spec macros(kz_json:object()) -> kz_proplist(). +-spec macros(kz_json:object()) -> kz_term:proplist(). macros(DataJObj) -> macros(DataJObj, 'false'). --spec macros(kz_json:object(), boolean()) -> {kz_json:object(), kz_proplist()} | kz_proplist(). +-spec macros(kz_json:object(), boolean()) -> {kz_json:object(), kz_term:proplist()} | kz_term:proplist(). macros(DataJObj, 'true') -> ReqData = get_user_doc(DataJObj), {ReqData, create_macros(ReqData)}; @@ -112,7 +112,7 @@ macros(DataJObj, 'false') -> ReqData = get_user_doc(DataJObj), create_macros(ReqData). --spec create_macros(kz_json:object()) -> kz_proplist(). +-spec create_macros(kz_json:object()) -> kz_term:proplist(). create_macros(DataJObj) -> UserDoc = kz_json:get_value(<<"user">>, DataJObj, kz_json:new()), UserParams = case kz_json:get_value(<<"password">>, UserDoc) of diff --git a/applications/teletype/src/templates/teletype_password_recovery.erl b/applications/teletype/src/templates/teletype_password_recovery.erl index 2f801b4594d..22c40808ea7 100644 --- a/applications/teletype/src/templates/teletype_password_recovery.erl +++ b/applications/teletype/src/templates/teletype_password_recovery.erl @@ -70,7 +70,7 @@ handle_req(JObj, 'true') -> 'true' -> process_req(DataJObj) end. --spec build_macro_data(kz_json:object()) -> kz_proplist(). +-spec build_macro_data(kz_json:object()) -> kz_term:proplist(). build_macro_data(DataJObj) -> [{<<"system">>, teletype_util:system_params()} ,{<<"account">>, teletype_util:account_params(DataJObj)} @@ -102,7 +102,7 @@ process_req(DataJObj) -> {'error', Reason} -> teletype_util:notification_failed(?TEMPLATE_ID, Reason) end. --spec get_email_address(kz_json:object(), kz_proplist()) -> api_ne_binaries(). +-spec get_email_address(kz_json:object(), kz_term:proplist()) -> kz_term:api_ne_binaries(). get_email_address(DataJObj, Emails0) -> ToEmails = props:get_value(<<"to">>, Emails0), case kz_json:get_value(<<"email">>, DataJObj) of diff --git a/applications/teletype/src/templates/teletype_port_comment.erl b/applications/teletype/src/templates/teletype_port_comment.erl index 8850381df43..0ed50db6fdb 100644 --- a/applications/teletype/src/templates/teletype_port_comment.erl +++ b/applications/teletype/src/templates/teletype_port_comment.erl @@ -114,11 +114,11 @@ handle_port_request(DataJObj) -> {'error', Reason} -> teletype_util:notification_failed(?TEMPLATE_ID, Reason) end. --spec user_data(kz_json:object()) -> kz_proplist(). +-spec user_data(kz_json:object()) -> kz_term:proplist(). user_data(DataJObj) -> user_data(DataJObj, teletype_util:is_preview(DataJObj)). --spec user_data(kz_json:object(), boolean()) -> kz_proplist(). +-spec user_data(kz_json:object(), boolean()) -> kz_term:proplist(). user_data(DataJObj, 'true') -> AccountId = kz_json:get_value(<<"account_id">>, DataJObj), teletype_util:user_params(teletype_util:find_account_admin(AccountId)); diff --git a/applications/teletype/src/templates/teletype_port_request_admin.erl b/applications/teletype/src/templates/teletype_port_request_admin.erl index a4cb9562481..d47f6c23cb4 100644 --- a/applications/teletype/src/templates/teletype_port_request_admin.erl +++ b/applications/teletype/src/templates/teletype_port_request_admin.erl @@ -106,7 +106,7 @@ handle_port_request(DataJObj) -> {'error', Reason} -> teletype_util:notification_failed(?TEMPLATE_ID, Reason) end. --spec account_tree(ne_binary()) -> kz_proplist(). +-spec account_tree(kz_term:ne_binary()) -> kz_term:proplist(). account_tree(AccountId) -> {'ok', AccountJObj} = kz_account:fetch(AccountId), [{AncestorId, kz_account:fetch_name(AncestorId)} @@ -144,7 +144,7 @@ maybe_set_to(DataJObj) -> DataJObj end. --spec find_port_authority(ne_binary(), ne_binary()) -> api_binary() | ne_binaries(). +-spec find_port_authority(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_binary() | kz_term:ne_binaries(). find_port_authority(MasterAccountId, MasterAccountId) -> case kz_whitelabel:fetch(MasterAccountId) of {'error', _R} -> diff --git a/applications/teletype/src/templates/teletype_service_added.erl b/applications/teletype/src/templates/teletype_service_added.erl index 3873bad68cc..f056cbf0246 100644 --- a/applications/teletype/src/templates/teletype_service_added.erl +++ b/applications/teletype/src/templates/teletype_service_added.erl @@ -21,7 +21,7 @@ -include("teletype.hrl"). --spec id() -> ne_binary(). +-spec id() -> kz_term:ne_binary(). id() -> <<"service_added">>. -spec macros() -> kz_json:object(). @@ -37,19 +37,19 @@ macros() -> ++ ?COMMON_TEMPLATE_MACROS ]). --spec subject() -> ne_binary(). +-spec subject() -> kz_term:ne_binary(). subject() -> <<"New VoIP services were added to sub-account '{{sub_account.name}}'">>. --spec category() -> ne_binary(). +-spec category() -> kz_term:ne_binary(). category() -> <<"account">>. --spec friendly_name() -> ne_binary(). +-spec friendly_name() -> kz_term:ne_binary(). friendly_name() -> <<"New Service Addition">>. -spec to() -> kz_json:object(). to() -> ?CONFIGURED_EMAILS(?EMAIL_ADMINS). --spec from() -> api_ne_binary(). +-spec from() -> kz_term:api_ne_binary(). from() -> teletype_util:default_from_address(). -spec cc() -> kz_json:object(). @@ -58,7 +58,7 @@ cc() -> ?CONFIGURED_EMAILS(?EMAIL_SPECIFIED, []). -spec bcc() -> kz_json:object(). bcc() -> ?CONFIGURED_EMAILS(?EMAIL_SPECIFIED, []). --spec reply_to() -> api_ne_binary(). +-spec reply_to() -> kz_term:api_ne_binary(). reply_to() -> teletype_util:default_reply_to(). -spec init() -> 'ok'. @@ -105,7 +105,7 @@ process_req(DataJObj) -> {'error', Reason} -> teletype_util:notification_failed(id(), Reason) end. --spec macros(kz_json:object()) -> kz_proplist(). +-spec macros(kz_json:object()) -> kz_term:proplist(). macros(DataJObj) -> [{<<"system">>, teletype_util:system_params()} ,{<<"account">>, reseller_info_data(DataJObj)} @@ -116,12 +116,12 @@ macros(DataJObj) -> ,{<<"time_stamp">>, timestamp(DataJObj)} %% backward compatibility ]. --spec timestamp(kz_json:object()) -> kz_proplist(). +-spec timestamp(kz_json:object()) -> kz_term:proplist(). timestamp(DataJObj) -> TS = kz_json:get_integer_value(<<"timestamp">>, DataJObj), teletype_util:fix_timestamp(TS, DataJObj). --spec reseller_info_data(kz_json:object()) -> kz_proplist(). +-spec reseller_info_data(kz_json:object()) -> kz_term:proplist(). reseller_info_data(DataJObj) -> Audit = kz_json:get_value(<<"audit_log">>, DataJObj), case teletype_util:is_preview(DataJObj) of @@ -132,7 +132,7 @@ reseller_info_data(DataJObj) -> teletype_util:find_account_params(ResellerId) end. --spec sub_account_data(kz_json:object()) -> kz_proplist(). +-spec sub_account_data(kz_json:object()) -> kz_term:proplist(). sub_account_data(DataJObj) -> Audit = kz_json:get_value(<<"audit_log">>, DataJObj), case teletype_util:is_preview(DataJObj) of @@ -142,7 +142,7 @@ sub_account_data(DataJObj) -> teletype_util:find_account_params(AccountId) end. --spec service_added_data(kz_json:object()) -> kz_proplist(). +-spec service_added_data(kz_json:object()) -> kz_term:proplist(). service_added_data(DataJObj) -> Audit = kz_json:get_value(<<"audit_log">>, DataJObj), case teletype_util:is_preview(DataJObj) of @@ -153,7 +153,7 @@ service_added_data(DataJObj) -> kz_json:recursive_to_proplist(Diff) end. --spec auth_user_data(kz_json:object()) -> kz_proplist(). +-spec auth_user_data(kz_json:object()) -> kz_term:proplist(). auth_user_data(DataJObj) -> Audit = kz_json:get_value(<<"audit_log">>, DataJObj), case teletype_util:is_preview(DataJObj) of diff --git a/applications/teletype/src/templates/teletype_system_alert.erl b/applications/teletype/src/templates/teletype_system_alert.erl index a0e7ca88b4e..9e9e8993420 100644 --- a/applications/teletype/src/templates/teletype_system_alert.erl +++ b/applications/teletype/src/templates/teletype_system_alert.erl @@ -22,7 +22,7 @@ -include("teletype.hrl"). --spec id() -> ne_binary(). +-spec id() -> kz_term:ne_binary(). id() -> <<"system_alert">>. -spec macros() -> kz_json:object(). @@ -33,19 +33,19 @@ macros() -> ++ ?COMMON_TEMPLATE_MACROS ]). --spec subject() -> ne_binary(). +-spec subject() -> kz_term:ne_binary(). subject() -> <<"System Alert: '{{request.level}}' from '{{request.node}}'">>. --spec category() -> ne_binary(). +-spec category() -> kz_term:ne_binary(). category() -> <<"system">>. --spec friendly_name() -> ne_binary(). +-spec friendly_name() -> kz_term:ne_binary(). friendly_name() -> <<"System Notifications">>. -spec to() -> kz_json:object(). to() -> ?CONFIGURED_EMAILS(?EMAIL_ADMINS). --spec from() -> api_ne_binary(). +-spec from() -> kz_term:api_ne_binary(). from() -> teletype_util:default_from_address(). -spec cc() -> kz_json:object(). @@ -54,7 +54,7 @@ cc() -> ?CONFIGURED_EMAILS(?EMAIL_SPECIFIED, []). -spec bcc() -> kz_json:object(). bcc() -> ?CONFIGURED_EMAILS(?EMAIL_SPECIFIED, []). --spec reply_to() -> api_ne_binary(). +-spec reply_to() -> kz_term:api_ne_binary(). reply_to() -> teletype_util:default_reply_to(). -spec init() -> 'ok'. @@ -86,7 +86,7 @@ handle_req(JObj, 'true') -> ] end. --spec process_req_as_http(kz_json:object(), api_binary()) -> template_response(). +-spec process_req_as_http(kz_json:object(), kz_term:api_binary()) -> template_response(). process_req_as_http(_JObj, 'undefined') -> teletype_util:notification_ignored(<<(id())/binary, "_http">>); process_req_as_http(JObj, Url) -> @@ -145,7 +145,7 @@ process_req_as_email(DataJObj) -> {'error', Reason} -> teletype_util:notification_failed(<<(id())/binary, "_email">>, Reason) end. --spec macros(kz_json:object()) -> kz_proplist(). +-spec macros(kz_json:object()) -> kz_term:proplist(). macros(DataJObj) -> [{<<"system">>, teletype_util:system_params()} ,{<<"account">>, teletype_util:account_params(DataJObj)} @@ -155,7 +155,7 @@ macros(DataJObj) -> | details_macros(DataJObj) ]. --spec details_macros(kz_json:object()) -> kz_proplist(). +-spec details_macros(kz_json:object()) -> kz_term:proplist(). details_macros(DataJObj) -> case kz_json:get_value(<<"details">>, DataJObj) of 'undefined' -> []; @@ -164,12 +164,12 @@ details_macros(DataJObj) -> Details -> details_groups(kz_json:recursive_to_proplist(Details)) end. --spec details_groups(kz_proplist()) -> kz_proplist(). +-spec details_groups(kz_term:proplist()) -> kz_term:proplist(). details_groups(Details) -> details_groups(Details, {<<"details">>, []}). --spec details_groups(kz_proplist(), {ne_binary(), kz_proplist()}) -> - kz_proplist(). +-spec details_groups(kz_term:proplist(), {kz_term:ne_binary(), kz_term:proplist()}) -> + kz_term:proplist(). details_groups([], {_, Acc}) -> Acc; details_groups([{<<"key_value_store">>, V} | KS], {Group, Acc}) -> @@ -189,15 +189,15 @@ details_groups([{<<"cf_", _/binary>>,_}=KV | KS], {Group, Acc}) -> details_groups([KV | KS], {Group, Acc}) -> details_groups(KS, {Group, add_to_group(Group, KV, Acc)}). --spec add_to_group(ne_binary(), {kz_json:path(), kz_json:json_term()}, kz_proplist()) -> - kz_proplist(). +-spec add_to_group(kz_term:ne_binary(), {kz_json:path(), kz_json:json_term()}, kz_term:proplist()) -> + kz_term:proplist(). add_to_group(Group, KV, Acc) -> case props:get_value(Group, Acc) of 'undefined' -> props:set_value(Group,[KV], Acc); Props -> props:set_value(Group, props:insert_value(KV, Props), Acc) end. --spec request_macros(kz_json:object()) -> kz_proplist(). +-spec request_macros(kz_json:object()) -> kz_term:proplist(). request_macros(DataJObj) -> kz_json:recursive_to_proplist( kz_json:delete_keys([<<"details">> @@ -224,7 +224,7 @@ request_macros(DataJObj) -> ) ). --spec admin_user_data(kz_json:object()) -> kz_proplist(). +-spec admin_user_data(kz_json:object()) -> kz_term:proplist(). admin_user_data(DataJObj) -> AccountId = kapi_notifications:account_id(DataJObj), case teletype_util:find_account_admin(AccountId) of diff --git a/applications/teletype/src/templates/teletype_template_skel.erl b/applications/teletype/src/templates/teletype_template_skel.erl index a11b13270f3..93eaaaa7954 100644 --- a/applications/teletype/src/templates/teletype_template_skel.erl +++ b/applications/teletype/src/templates/teletype_template_skel.erl @@ -91,7 +91,7 @@ process_req(DataJObj) -> {'error', Reason} -> teletype_util:notification_failed(?TEMPLATE_ID, Reason) end. --spec build_macro_data(kz_json:object()) -> kz_proplist(). +-spec build_macro_data(kz_json:object()) -> kz_term:proplist(). build_macro_data(DataJObj) -> kz_json:foldl(fun(MacroKey, _V, Acc) -> maybe_add_macro_key(MacroKey, Acc, DataJObj) @@ -100,14 +100,14 @@ build_macro_data(DataJObj) -> ,?TEMPLATE_MACROS ). --spec maybe_add_macro_key(kz_json:path(), kz_proplist(), kz_json:object()) -> kz_proplist(). +-spec maybe_add_macro_key(kz_json:path(), kz_term:proplist(), kz_json:object()) -> kz_term:proplist(). maybe_add_macro_key(<<"user.", UserKey/binary>>, Acc, DataJObj) -> maybe_add_user_data(UserKey, Acc, DataJObj); maybe_add_macro_key(_Key, Acc, _DataJObj) -> lager:debug("unprocessed macro key ~s: ~p", [_Key, _DataJObj]), Acc. --spec maybe_add_user_data(kz_json:path(), kz_proplist(), kz_json:object()) -> kz_proplist(). +-spec maybe_add_user_data(kz_json:path(), kz_term:proplist(), kz_json:object()) -> kz_term:proplist(). maybe_add_user_data(Key, Acc, DataJObj) -> User = get_user(DataJObj), diff --git a/applications/teletype/src/templates/teletype_topup.erl b/applications/teletype/src/templates/teletype_topup.erl index 057f1c4743b..963ca21183d 100644 --- a/applications/teletype/src/templates/teletype_topup.erl +++ b/applications/teletype/src/templates/teletype_topup.erl @@ -74,7 +74,7 @@ handle_req(JObj, 'true') -> 'true' -> process_req(kz_json:merge_jobjs(DataJObj, ReqData)) end. --spec macros(kz_json:object()) -> kz_proplist(). +-spec macros(kz_json:object()) -> kz_term:proplist(). macros(DataJObj) -> TransactionProps = transaction_data(DataJObj), [{<<"account">>, teletype_util:account_params(DataJObj)} @@ -102,11 +102,11 @@ process_req(DataJObj) -> {'error', Reason} -> teletype_util:notification_failed(?TEMPLATE_ID, Reason) end. --spec transaction_data(kz_json:object()) -> kz_proplist(). +-spec transaction_data(kz_json:object()) -> kz_term:proplist(). transaction_data(DataJObj) -> transaction_data(DataJObj, teletype_util:is_preview(DataJObj)). --spec transaction_data(kz_json:object(), boolean()) -> kz_proplist(). +-spec transaction_data(kz_json:object(), boolean()) -> kz_term:proplist(). transaction_data(DataJObj, 'true') -> {'ok', JObj} = teletype_util:read_preview_doc(<<"transaction">>), Props = kz_json:recursive_to_proplist(JObj), @@ -140,7 +140,7 @@ transaction_data(DataJObj, 'false') -> ] ). --spec get_balance(kz_json:object()) -> ne_binary(). +-spec get_balance(kz_json:object()) -> kz_term:ne_binary(). get_balance(DataJObj) -> AccountId = kz_json:get_value(<<"account_id">>, DataJObj), case wht_util:current_account_dollars(AccountId) of diff --git a/applications/teletype/src/templates/teletype_transaction.erl b/applications/teletype/src/templates/teletype_transaction.erl index 182e10f0407..b55ed59b8de 100644 --- a/applications/teletype/src/templates/teletype_transaction.erl +++ b/applications/teletype/src/templates/teletype_transaction.erl @@ -83,7 +83,7 @@ handle_req(JObj, 'true') -> 'true' -> process_req(kz_json:merge_jobjs(DataJObj, ReqData), ?TEMPLATE_ID) end. --spec process_req(kz_json:object(), ne_binary()) -> template_response(). +-spec process_req(kz_json:object(), kz_term:ne_binary()) -> template_response(). process_req(DataJObj, TemplateId) -> Macros = [{<<"system">>, teletype_util:system_params()} ,{<<"account">>, teletype_util:account_params(DataJObj)} @@ -107,18 +107,18 @@ process_req(DataJObj, TemplateId) -> {'error', Reason} -> teletype_util:notification_failed(TemplateId, Reason) end. --spec service_plan_data(kz_json:object()) -> kz_proplist(). +-spec service_plan_data(kz_json:object()) -> kz_term:proplist(). service_plan_data(DataJObj) -> case teletype_util:is_preview(DataJObj) of 'true' -> []; 'false' ->teletype_util:public_proplist(<<"service_plan">>, DataJObj) end. --spec transaction_data(kz_json:object()) -> kz_proplist(). +-spec transaction_data(kz_json:object()) -> kz_term:proplist(). transaction_data(DataJObj) -> transaction_data(DataJObj, teletype_util:is_preview(DataJObj)). --spec transaction_data(kz_json:object(), boolean()) -> kz_proplist(). +-spec transaction_data(kz_json:object(), boolean()) -> kz_term:proplist(). transaction_data(DataJObj, 'true') -> {'ok', JObj} = teletype_util:read_preview_doc(<<"transaction">>), Props = kz_json:recursive_to_proplist(JObj), @@ -174,7 +174,7 @@ purchase_order(DataJObj) -> ,[global] ). --spec calculate_total(api_objects() | binary()) -> non_neg_integer(). +-spec calculate_total(kz_term:api_objects() | binary()) -> non_neg_integer(). calculate_total(JObjs) when is_list(JObjs) -> lists:sum( [kz_json:get_integer_value(<<"quantity">>, J, 0) * kz_json:get_integer_value(<<"amount">>, J, 0) diff --git a/applications/teletype/src/templates/teletype_voicemail_full.erl b/applications/teletype/src/templates/teletype_voicemail_full.erl index 80119450522..ee95ed16199 100644 --- a/applications/teletype/src/templates/teletype_voicemail_full.erl +++ b/applications/teletype/src/templates/teletype_voicemail_full.erl @@ -74,7 +74,7 @@ handle_req(JObj, 'true') -> 'true' -> process_req(DataJObj, AccountId) end. --spec process_req(kz_json:object(), ne_binary()) -> template_response(). +-spec process_req(kz_json:object(), kz_term:ne_binary()) -> template_response(). process_req(DataJObj, AccountId) -> VMBox = get_vm_box(AccountId, DataJObj), User = get_vm_box_owner(VMBox, DataJObj), @@ -91,11 +91,11 @@ process_req(DataJObj, AccountId) -> ), process_req(kz_json:merge_jobjs(DataJObj, ReqData)). --spec maybe_add_user_email(ne_binaries(), api_binary()) -> ne_binaries(). +-spec maybe_add_user_email(kz_term:ne_binaries(), kz_term:api_binary()) -> kz_term:ne_binaries(). maybe_add_user_email(BoxEmails, 'undefined') -> BoxEmails; maybe_add_user_email(BoxEmails, UserEmail) -> [UserEmail | BoxEmails]. --spec get_vm_box(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec get_vm_box(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). get_vm_box(AccountId, JObj) -> VMBoxId = kz_json:get_value(<<"voicemail_box">>, JObj), case teletype_util:open_doc(<<"vmbox">>, VMBoxId, JObj) of @@ -144,13 +144,13 @@ process_req(DataJObj) -> {'error', Reason} -> teletype_util:notification_failed(?TEMPLATE_ID, Reason) end. --spec build_template_data(kz_json:object()) -> kz_proplist(). +-spec build_template_data(kz_json:object()) -> kz_term:proplist(). build_template_data(DataJObj) -> [{<<"voicemail">>, build_voicemail_data(DataJObj)} ,{<<"owner">>, teletype_util:user_params(kz_json:get_value(<<"user">>, DataJObj))} %% backward compatibility ]. --spec build_voicemail_data(kz_json:object()) -> kz_proplist(). +-spec build_voicemail_data(kz_json:object()) -> kz_term:proplist(). build_voicemail_data(DataJObj) -> props:filter_undefined( [{<<"id">>, kz_json:get_value(<<"voicemail_box">>, DataJObj)} diff --git a/applications/teletype/src/templates/teletype_voicemail_to_email.erl b/applications/teletype/src/templates/teletype_voicemail_to_email.erl index 4f1f955378d..78af1d59c6d 100644 --- a/applications/teletype/src/templates/teletype_voicemail_to_email.erl +++ b/applications/teletype/src/templates/teletype_voicemail_to_email.erl @@ -21,7 +21,7 @@ -include("teletype.hrl"). --spec id() -> ne_binary(). +-spec id() -> kz_term:ne_binary(). id() -> <<"voicemail_to_email">>. @@ -40,19 +40,19 @@ macros() -> ++ ?COMMON_TEMPLATE_MACROS ]). --spec subject() -> ne_binary(). +-spec subject() -> kz_term:ne_binary(). subject() -> <<"New voicemail from {{caller_id.name}} ({{caller_id.number}})">>. --spec category() -> ne_binary(). +-spec category() -> kz_term:ne_binary(). category() -> <<"voicemail">>. --spec friendly_name() -> ne_binary(). +-spec friendly_name() -> kz_term:ne_binary(). friendly_name() -> <<"Voicemail To Email">>. -spec to() -> kz_json:object(). to() -> ?CONFIGURED_EMAILS(?EMAIL_ORIGINAL). --spec from() -> api_ne_binary(). +-spec from() -> kz_term:api_ne_binary(). from() -> teletype_util:default_from_address(). -spec cc() -> kz_json:object(). @@ -61,7 +61,7 @@ cc() -> ?CONFIGURED_EMAILS(?EMAIL_SPECIFIED, []). -spec bcc() -> kz_json:object(). bcc() -> ?CONFIGURED_EMAILS(?EMAIL_SPECIFIED, []). --spec reply_to() -> api_ne_binary(). +-spec reply_to() -> kz_term:api_ne_binary(). reply_to() -> teletype_util:default_reply_to(). -spec init() -> 'ok'. @@ -128,7 +128,7 @@ get_owner(VMBoxJObj, DataJObj) -> kz_json:new() end. --spec maybe_add_user_email(ne_binaries(), api_binary(), boolean()) -> ne_binaries(). +-spec maybe_add_user_email(kz_term:ne_binaries(), kz_term:api_binary(), boolean()) -> kz_term:ne_binaries(). maybe_add_user_email(BoxEmails, 'undefined', _) -> BoxEmails; maybe_add_user_email(BoxEmails, UserEmail, 'false') -> lists:delete(UserEmail, BoxEmails); maybe_add_user_email(BoxEmails, UserEmail, 'true') -> [UserEmail | BoxEmails]. @@ -169,24 +169,24 @@ do_process_req(DataJObj) -> {'error', Reason} -> teletype_util:notification_failed(id(), Reason) end. --spec macros(kz_json:object()) -> kz_proplist(). +-spec macros(kz_json:object()) -> kz_term:proplist(). macros(DataJObj) -> TemplateData = template_data(DataJObj), EmailAttachements = email_attachments(DataJObj, TemplateData), Macros = maybe_add_file_data(TemplateData, EmailAttachements), props:set_value(<<"attachments">>, EmailAttachements, Macros). --spec template_data(kz_json:object()) -> kz_proplist(). +-spec template_data(kz_json:object()) -> kz_term:proplist(). template_data(DataJObj) -> [{<<"system">>, teletype_util:system_params()} | build_template_data(DataJObj) ]. --spec email_attachments(kz_json:object(), kz_proplist()) -> attachments(). +-spec email_attachments(kz_json:object(), kz_term:proplist()) -> attachments(). email_attachments(DataJObj, Macros) -> email_attachments(DataJObj, Macros, teletype_util:is_preview(DataJObj)). --spec email_attachments(kz_json:object(), kz_proplist(), boolean()) -> attachments(). +-spec email_attachments(kz_json:object(), kz_term:proplist(), boolean()) -> attachments(). email_attachments(_DataJObj, _Macros, 'true') -> []; email_attachments(DataJObj, Macros, 'false') -> VMId = kz_json:get_value(<<"voicemail_id">>, DataJObj), @@ -200,7 +200,7 @@ email_attachments(DataJObj, Macros, 'false') -> maybe_fetch_attachments(DataJObj, Db, VMId, get_file_name(VMJObj, Macros), kz_doc:attachments(VMJObj)). --spec maybe_fetch_attachments(kz_json:object(), ne_binary(), ne_binary(), ne_binary(), api_object()) -> attachments(). +-spec maybe_fetch_attachments(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_object()) -> attachments(). maybe_fetch_attachments(_, _, _, _, 'undefined') -> throw({'error', 'no_attachment'}); maybe_fetch_attachments(DataJObj, Db, VMId, FileName, Attachments) -> @@ -211,7 +211,7 @@ maybe_fetch_attachments(DataJObj, Db, VMId, FileName, Attachments) -> fetch_attachments(Db, VMId, FileName, Attachments) end. --spec fetch_attachments(ne_binary(), ne_binary(), ne_binary(), kz_json:object()) -> attachments(). +-spec fetch_attachments(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> attachments(). fetch_attachments(Db, VMId, FileName, Attachments) -> {[AttachmentMeta], [AttachmentId]} = kz_json:get_values(Attachments), ContentType = kz_json:get_value(<<"content_type">>, AttachmentMeta), @@ -225,7 +225,7 @@ fetch_attachments(Db, VMId, FileName, Attachments) -> throw({'error', 'no_attachment'}) end. --spec get_file_name(kz_json:object(), kz_proplist()) -> ne_binary(). +-spec get_file_name(kz_json:object(), kz_term:proplist()) -> kz_term:ne_binary(). get_file_name(MediaJObj, Macros) -> %% CallerID_Date_Time.mp3 CallerID = @@ -247,11 +247,11 @@ get_file_name(MediaJObj, Macros) -> binary:replace(kz_term:to_lower_binary(FileName), <<$\s>>, <<$_>>) ). --spec get_extension(kz_json:object()) -> ne_binary(). +-spec get_extension(kz_json:object()) -> kz_term:ne_binary(). get_extension(MediaJObj) -> kz_mime:to_extension(kz_doc:attachment_content_type(MediaJObj)). --spec build_template_data(kz_json:object()) -> kz_proplist(). +-spec build_template_data(kz_json:object()) -> kz_term:proplist(). build_template_data(DataJObj) -> Timezone = kzd_voicemail_box:timezone(kz_json:get_value(<<"vmbox_doc">>, DataJObj)), [{<<"voicemail">>, build_voicemail_data(DataJObj)} @@ -261,7 +261,7 @@ build_template_data(DataJObj) -> | teletype_util:build_call_data(DataJObj, Timezone) ]. --spec build_voicemail_data(kz_json:object()) -> kz_proplist(). +-spec build_voicemail_data(kz_json:object()) -> kz_term:proplist(). build_voicemail_data(DataJObj) -> props:filter_undefined( [{<<"vmbox_id">>, kz_json:get_value(<<"voicemail_box">>, DataJObj)} @@ -274,7 +274,7 @@ build_voicemail_data(DataJObj) -> ,{<<"length">>, pretty_print_length(DataJObj)} ]). --spec get_transcription(kz_json:object()) -> api_ne_binary(). +-spec get_transcription(kz_json:object()) -> kz_term:api_ne_binary(). get_transcription(DataJObj) -> case kz_json:get_value(<<"voicemail_transcription">>, DataJObj) of 'undefined' -> 'undefined'; @@ -282,7 +282,7 @@ get_transcription(DataJObj) -> JObj -> kz_json:get_ne_binary_value(<<"text">>, JObj) end. --spec pretty_print_length(api_object() | pos_integer()) -> ne_binary(). +-spec pretty_print_length(kz_term:api_object() | pos_integer()) -> kz_term:ne_binary(). pretty_print_length('undefined') -> <<"00:00:00">>; pretty_print_length(Ms) when is_integer(Ms) -> MilliSeconds = kz_time:milliseconds_to_seconds(Ms), @@ -292,7 +292,7 @@ pretty_print_length(Ms) when is_integer(Ms) -> pretty_print_length(JObj) -> pretty_print_length(kz_json:get_integer_value(<<"voicemail_length">>, JObj)). --spec maybe_add_file_data(kz_proplist(), attachments()) -> kz_proplist(). +-spec maybe_add_file_data(kz_term:proplist(), attachments()) -> kz_term:proplist(). maybe_add_file_data(Macros, []) -> Macros; maybe_add_file_data(Macros, [{ContentType, FileName, Bin}]) -> Props = props:filter_undefined( diff --git a/applications/teletype/src/templates/teletype_webhook_disabled.erl b/applications/teletype/src/templates/teletype_webhook_disabled.erl index 7913475f25b..babc10c7f43 100644 --- a/applications/teletype/src/templates/teletype_webhook_disabled.erl +++ b/applications/teletype/src/templates/teletype_webhook_disabled.erl @@ -73,7 +73,7 @@ handle_req(JObj, 'true') -> 'true' -> process_req(DataJObj, AccountId) end. --spec process_req(kz_json:object(), ne_binary()) -> template_response(). +-spec process_req(kz_json:object(), kz_term:ne_binary()) -> template_response(). process_req(DataJObj, AccountId) -> HookId = kz_json:get_value(<<"hook_id">>, DataJObj), @@ -112,7 +112,7 @@ process_req(DataJObj) -> {'error', Reason} -> teletype_util:notification_failed(?TEMPLATE_ID, Reason) end. --spec hook_data(kzd_webhook:doc()) -> kz_proplist(). +-spec hook_data(kzd_webhook:doc()) -> kz_term:proplist(). hook_data(HookJObj) -> props:filter_undefined( [{<<"id">>, kz_doc:id(HookJObj)} diff --git a/applications/trunkstore/src/trunkstore_app.erl b/applications/trunkstore/src/trunkstore_app.erl index 3bfb99890b4..863a119f15a 100644 --- a/applications/trunkstore/src/trunkstore_app.erl +++ b/applications/trunkstore/src/trunkstore_app.erl @@ -19,7 +19,7 @@ %% Application callbacks %% =================================================================== --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_StartType, _StartArgs) -> _ = declare_exchanges(), trunkstore_sup:start_link(). diff --git a/applications/trunkstore/src/trunkstore_listener.erl b/applications/trunkstore/src/trunkstore_listener.erl index 134789895d9..c30063ded60 100644 --- a/applications/trunkstore/src/trunkstore_listener.erl +++ b/applications/trunkstore/src/trunkstore_listener.erl @@ -42,7 +42,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'bindings', ?BINDINGS} ,{'responders', ?RESPONDERS} @@ -79,7 +79,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -93,7 +93,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _QueueNAme}}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'is_consuming', _IsConsuming}}, State) -> @@ -111,7 +111,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -123,7 +123,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/trunkstore/src/trunkstore_maintenance.erl b/applications/trunkstore/src/trunkstore_maintenance.erl index 97398f05c75..83aa6a23c07 100644 --- a/applications/trunkstore/src/trunkstore_maintenance.erl +++ b/applications/trunkstore/src/trunkstore_maintenance.erl @@ -19,7 +19,7 @@ -include("ts.hrl"). -spec flush() -> 'ok'. --spec flush(ne_binary()) -> 'ok'. +-spec flush(kz_term:ne_binary()) -> 'ok'. flush() -> kz_cache:flush_local(?CACHE_NAME). @@ -186,7 +186,7 @@ clear_old_calls(Super) -> %% @doc %% Usage example: sup trunkstore_maintenance classifier_inherit international pbx_username@realm.domain.tld %% @end --spec classifier_inherit(kz_json:object(), ne_binary()) -> 'ok'. +-spec classifier_inherit(kz_json:object(), kz_term:ne_binary()) -> 'ok'. classifier_inherit(Classifier, UserR) -> set_classifier_action(<<"inherit">>, Classifier, UserR). @@ -194,7 +194,7 @@ classifier_inherit(Classifier, UserR) -> %% @doc %% Usage example: sup trunkstore_maintenance classifier_deny international pbx_username@realm.domain.tld %% @end --spec classifier_deny(kz_json:object(), ne_binary()) -> 'ok'. +-spec classifier_deny(kz_json:object(), kz_term:ne_binary()) -> 'ok'. classifier_deny(Classifier, UserR) -> set_classifier_action(<<"deny">>, Classifier, UserR). @@ -219,7 +219,7 @@ set_classifier_action(Action, Classifier, UserR) -> io:format("Failed: account with realm ~p does not exist\n", [Realm]) end. --spec is_ts_cache_object(tuple(), ne_binary()) -> boolean(). +-spec is_ts_cache_object(tuple(), kz_term:ne_binary()) -> boolean(). is_ts_cache_object({'lookup_user_flags', _Realm, _User, AccountId}, AccountId) -> 'true'; is_ts_cache_object({'lookup_did', _DID, AccountId}, AccountId) -> diff --git a/applications/trunkstore/src/trunkstore_sup.erl b/applications/trunkstore/src/trunkstore_sup.erl index 3a8aed0475a..df93f353f15 100644 --- a/applications/trunkstore/src/trunkstore_sup.erl +++ b/applications/trunkstore/src/trunkstore_sup.erl @@ -39,14 +39,14 @@ %% =================================================================== %% API functions %% =================================================================== --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). %% =================================================================== %% Supervisor callbacks %% =================================================================== --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), diff --git a/applications/trunkstore/src/ts.hrl b/applications/trunkstore/src/ts.hrl index f7b76a8801e..b97f56e296a 100644 --- a/applications/trunkstore/src/ts.hrl +++ b/applications/trunkstore/src/ts.hrl @@ -38,16 +38,16 @@ %% just want to deal with binary K/V pairs -type active_calls() :: [{binary(), 'flat_rate' | 'per_min'}]. --record(ts_callflow_state, {aleg_callid :: api_ne_binary() - ,bleg_callid :: api_ne_binary() +-record(ts_callflow_state, {aleg_callid :: kz_term:api_ne_binary() + ,bleg_callid :: kz_term:api_ne_binary() ,acctid = <<>> :: binary() ,acctdb = <<>> :: binary() ,route_req_jobj = kz_json:new() :: kz_json:object() ,ep_data = kz_json:new() :: kz_json:object() %% data for the endpoint, either an actual endpoint or an offnet request - ,amqp_worker :: api_pid() - ,callctl_q :: api_ne_binary() + ,amqp_worker :: kz_term:api_pid() + ,callctl_q :: kz_term:api_ne_binary() ,call_cost = 0.0 :: float() - ,failover :: api_object() + ,failover :: kz_term:api_object() ,kapps_call :: kapps_call:call() }). @@ -56,8 +56,8 @@ ,to_domain = <<>> :: binary() ,from_user = <<>> :: binary() ,from_domain = <<>> :: binary() - ,auth_user = <<>> :: api_binary() % what username did we authenticate with - ,auth_realm = <<>> :: api_binary() % what realm did we auth with + ,auth_user = <<>> :: kz_term:api_binary() % what username did we authenticate with + ,auth_realm = <<>> :: kz_term:api_binary() % what realm did we auth with ,direction = <<>> :: binary() % what direction is the call (relative to client) ,server_id = <<>> :: binary() % Server of the DID ,failover = {} :: tuple() % Failover information {type, value}. Type=(sip|e164), Value=("sip:user@domain"|"+1234567890") diff --git a/applications/trunkstore/src/ts_callflow.erl b/applications/trunkstore/src/ts_callflow.erl index f31c7a23d01..5494d557bff 100644 --- a/applications/trunkstore/src/ts_callflow.erl +++ b/applications/trunkstore/src/ts_callflow.erl @@ -40,11 +40,11 @@ -define(WAIT_FOR_WIN_TIMEOUT, 5 * ?MILLISECONDS_IN_SECOND). -type state() :: #ts_callflow_state{}. --type event_type() :: {api_binary(), api_binary(), api_binary()}. +-type event_type() :: {kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary()}. -export_type([state/0]). --spec init(kz_json:object(), api_binary() | api_binaries()) -> +-spec init(kz_json:object(), kz_term:api_binary() | kz_term:api_binaries()) -> state() | {'error', 'not_ts_account'}. init(RouteReqJObj, Type) -> @@ -130,9 +130,9 @@ route_won(#ts_callflow_state{amqp_worker=Worker, kapps_call=Call}=State, RouteWi } }. --spec wait_for_bridge(state(), api_integer()) -> +-spec wait_for_bridge(state(), kz_term:api_integer()) -> {'hangup' | 'error' | 'bridged', state()}. --spec wait_for_bridge(state(), api_integer(), kapps_call_command:request_return()) -> +-spec wait_for_bridge(state(), kz_term:api_integer(), kapps_call_command:request_return()) -> {'hangup' | 'error' | 'bridged', state()}. wait_for_bridge(State, 'undefined') -> wait_for_bridge(State, 20); @@ -280,7 +280,7 @@ send_hangup(#ts_callflow_state{callctl_q=CtlQ ,Worker ). --spec send_hangup(state(), api_binary()) -> 'ok'. +-spec send_hangup(state(), kz_term:api_binary()) -> 'ok'. send_hangup(#ts_callflow_state{callctl_q = <<>>}, _) -> 'ok'; send_hangup(#ts_callflow_state{callctl_q = 'undefined'}, _) -> 'ok'; send_hangup(#ts_callflow_state{callctl_q=CtlQ @@ -292,7 +292,7 @@ send_hangup(#ts_callflow_state{callctl_q=CtlQ {'ok', _} = kz_call_response:send(CallId, CtlQ, Code), 'ok'. --spec send_command(state(), api_terms(), kz_amqp_worker:publish_fun()) -> 'ok'. +-spec send_command(state(), kz_term:api_terms(), kz_amqp_worker:publish_fun()) -> 'ok'. send_command(#ts_callflow_state{amqp_worker=Worker}, Command, PubFun) -> 'ok' = kz_amqp_worker:cast(Command, PubFun, Worker). @@ -306,7 +306,7 @@ get_request_data(#ts_callflow_state{route_req_jobj=JObj}) -> JObj. get_custom_channel_vars(#ts_callflow_state{route_req_jobj=JObj}) -> kz_json:get_value(<<"Custom-Channel-Vars">>, JObj, kz_json:new()). --spec get_custom_sip_headers(state()) -> api_object(). +-spec get_custom_sip_headers(state()) -> kz_term:api_object(). get_custom_sip_headers(#ts_callflow_state{route_req_jobj=JObj}) -> kz_json:get_value(<<"Custom-SIP-Headers">>, JObj). @@ -316,21 +316,21 @@ set_endpoint_data(State, Data) -> State#ts_callflow_state{ep_data=Data}. -spec get_endpoint_data(state()) -> kz_json:object(). get_endpoint_data(#ts_callflow_state{ep_data=EP}) -> EP. --spec set_account_id(state(), ne_binary()) -> state(). +-spec set_account_id(state(), kz_term:ne_binary()) -> state(). set_account_id(State, ID) -> State#ts_callflow_state{acctid=ID}. --spec get_account_id(state()) -> ne_binary(). +-spec get_account_id(state()) -> kz_term:ne_binary(). get_account_id(#ts_callflow_state{acctid=ID}) -> ID. --spec get_control_queue(state()) -> api_binary(). +-spec get_control_queue(state()) -> kz_term:api_binary(). get_control_queue(#ts_callflow_state{callctl_q=CtlQ}) -> CtlQ. --spec get_worker_queue(state()) -> ne_binary(). +-spec get_worker_queue(state()) -> kz_term:ne_binary(). get_worker_queue(#ts_callflow_state{amqp_worker=Worker}) -> gen_listener:queue_name(Worker). --spec get_aleg_id(state()) -> api_binary(). --spec get_bleg_id(state()) -> api_binary(). +-spec get_aleg_id(state()) -> kz_term:api_binary(). +-spec get_bleg_id(state()) -> kz_term:api_binary(). get_aleg_id(#ts_callflow_state{aleg_callid=ALeg}) -> ALeg. get_bleg_id(#ts_callflow_state{bleg_callid=ALeg}) -> ALeg. @@ -340,16 +340,16 @@ get_call_cost(#ts_callflow_state{call_cost=Cost}) -> Cost. -spec set_failover(state(), kz_json:object()) -> state(). set_failover(State, Failover) -> State#ts_callflow_state{failover=Failover}. --spec get_failover(state()) -> api_object(). +-spec get_failover(state()) -> kz_term:api_object(). get_failover(#ts_callflow_state{failover=Fail}) -> Fail. --spec is_trunkstore_acct(kz_json:object(), api_binary() | api_binaries()) -> boolean(). +-spec is_trunkstore_acct(kz_json:object(), kz_term:api_binary() | kz_term:api_binaries()) -> boolean(). is_trunkstore_acct(RouteReqJObj, Type) -> CCVs = kz_json:get_json_value(<<"Custom-Channel-Vars">>, RouteReqJObj, kz_json:new()), lager:info("checking type(s) ~p against CCVs ~s", [Type, kz_json:encode(CCVs)]), check_ccvs_for_type(CCVs, Type). --spec check_ccvs_for_type(kz_json:object(), api_binary() | api_binaries()) -> boolean(). +-spec check_ccvs_for_type(kz_json:object(), kz_term:api_binary() | kz_term:api_binaries()) -> boolean(). check_ccvs_for_type(CCVs, [Type|Types]) -> check_ccvs_for_type(CCVs, Type) orelse check_ccvs_for_type(CCVs, Types); @@ -363,7 +363,7 @@ check_ccvs_for_type(CCVs, <<"sys_info">> = Type) -> check_ccvs_for_type(CCVs, Type) -> is_authorized(CCVs, Type). --spec is_authorized(kz_json:object(), api_ne_binary()) -> boolean(). +-spec is_authorized(kz_json:object(), kz_term:api_ne_binary()) -> boolean(). is_authorized(CCVs, Type) -> Type =:= kz_json:get_ne_binary_value([<<"Authorizing-Type">>], CCVs). @@ -376,15 +376,15 @@ is_not_redirected(CCVs) -> 'undefined' =/= kz_json:get_ne_binary_value([<<"Referred-By">>], CCVs) orelse 'undefined' =/= kz_json:get_ne_binary_value([<<"Redirected-By">>], CCVs). --spec pre_park_action() -> ne_binary(). +-spec pre_park_action() -> kz_term:ne_binary(). pre_park_action() -> case kapps_config:get_is_true(?CONFIG_CAT, <<"ring_ready_offnet">>, 'true') of 'false' -> <<"none">>; 'true' -> <<"ring_ready">> end. --spec is_success(ne_binary(), kz_json:object()) -> boolean(). --spec is_success(ne_binaries(), kz_json:object(), ne_binary()) -> boolean(). +-spec is_success(kz_term:ne_binary(), kz_json:object()) -> boolean(). +-spec is_success(kz_term:ne_binaries(), kz_json:object(), kz_term:ne_binary()) -> boolean(). is_success(Key, JObj) -> kz_json:get_value(Key, JObj) =:= <<"SUCCESS">>. is_success(Key, JObj, Default) -> diff --git a/applications/trunkstore/src/ts_from_offnet.erl b/applications/trunkstore/src/ts_from_offnet.erl index 958d6660c93..0436e3e1eed 100644 --- a/applications/trunkstore/src/ts_from_offnet.erl +++ b/applications/trunkstore/src/ts_from_offnet.erl @@ -16,7 +16,7 @@ -define(SERVER, ?MODULE). --spec start_link(kz_json:object()) -> startlink_ret(). +-spec start_link(kz_json:object()) -> kz_types:startlink_ret(). start_link(RouteReqJObj) -> proc_lib:start_link(?SERVER, 'init', [self(), RouteReqJObj]). @@ -78,14 +78,14 @@ proceed_with_endpoint(State, Endpoint, JObj) -> State2 = ts_callflow:set_endpoint_data(State1, Endpoint), send_park(State2, Command). --spec send_park(ts_callflow:state(), kz_proplist()) -> 'ok'. +-spec send_park(ts_callflow:state(), kz_term:proplist()) -> 'ok'. send_park(State, Command) -> case ts_callflow:send_park(State) of {'lost', _} -> 'ok'; {'won', State1} -> route_call(State1, Command) end. --spec route_call(ts_callflow:state(), kz_proplist()) -> 'ok'. +-spec route_call(ts_callflow:state(), kz_term:proplist()) -> 'ok'. route_call(State, Command) -> lager:info("route won, sending command"), send_onnet(State, Command), @@ -94,20 +94,20 @@ route_call(State, Command) -> wait_for_bridge(State, Timeout). --spec endpoint_timeout(kz_proplist()) -> api_integer(). +-spec endpoint_timeout(kz_term:proplist()) -> kz_term:api_integer(). endpoint_timeout(Command) when is_list(Command) -> kz_json:get_integer_value([<<"Endpoints">>, 1, <<"Endpoint-Timeout">>] ,kz_json:from_list(Command) ). --spec send_onnet(ts_callflow:state(), kz_proplist()) -> 'ok'. +-spec send_onnet(ts_callflow:state(), kz_term:proplist()) -> 'ok'. send_onnet(State, Command) -> lager:info("sending onnet command: ~p", [Command]), 'ok' = maybe_send_privacy(State), send_bridge(State, Command). --spec send_bridge(ts_callflow:state(), kz_proplist()) -> 'ok'. +-spec send_bridge(ts_callflow:state(), kz_term:proplist()) -> 'ok'. send_bridge(State, Command) -> CtlQ = ts_callflow:get_control_queue(State), ts_callflow:send_command(State @@ -139,7 +139,7 @@ send_privacy(State) -> ,fun(API) -> kapi_dialplan:publish_command(CtlQ, API) end ). --spec wait_for_bridge(ts_callflow:state(), api_integer()) -> 'ok'. +-spec wait_for_bridge(ts_callflow:state(), kz_term:api_integer()) -> 'ok'. wait_for_bridge(State, Timeout) -> case ts_callflow:wait_for_bridge(State, Timeout) of {'bridged', _} -> lager:info("channel bridged, we're done"); @@ -178,7 +178,7 @@ failover(State, Failover) -> try_failover_e164(State, DID) end. --spec try_failover_sip(ts_callflow:state(), api_ne_binary()) -> 'ok'. +-spec try_failover_sip(ts_callflow:state(), kz_term:api_ne_binary()) -> 'ok'. try_failover_sip(_, 'undefined') -> lager:info("SIP failover undefined"); try_failover_sip(State, SIPUri) -> @@ -204,7 +204,7 @@ try_failover_sip(State, SIPUri) -> ), wait_for_bridge(ts_callflow:set_failover(State, kz_json:new()), 20). --spec try_failover_e164(ts_callflow:state(), ne_binary()) -> 'ok'. +-spec try_failover_e164(ts_callflow:state(), kz_term:ne_binary()) -> 'ok'. try_failover_e164(State, ToDID) -> RouteReq = ts_callflow:get_request_data(State), OriginalCIdNumber = kz_json:get_ne_binary_value(<<"Caller-ID-Number">>, RouteReq), @@ -263,7 +263,7 @@ get_endpoint_data(State) -> throw('unknown_account') end. --spec get_endpoint_data(ts_callflow:state(), kz_json:object(), ne_binary(), ne_binary(), knm_number_options:extra_options()) -> +-spec get_endpoint_data(ts_callflow:state(), kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), knm_number_options:extra_options()) -> {'endpoint', kz_json:object()}. get_endpoint_data(State, JObj, ToDID, AccountId, NumberProps) -> ForceOut = knm_number_options:should_force_outbound(NumberProps), @@ -288,7 +288,7 @@ get_endpoint_data(State, JObj, ToDID, AccountId, NumberProps) -> Endpoint = lists:foldl(fun(F, E) -> F(E) end, Invite, Routines), {'endpoint', kz_json:from_list(Endpoint)}. --spec get_endpoint_ccvs(kz_proplist(), api_binary(), api_binary(), ne_binary(), ne_binary()) -> kz_proplist(). +-spec get_endpoint_ccvs(kz_term:proplist(), kz_term:api_binary(), kz_term:api_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:proplist(). get_endpoint_ccvs(Endpoint, AuthUser, AuthRealm, AccountId, AuthzId) -> Props = props:filter_undefined([{<<"Auth-User">>, AuthUser} ,{<<"Auth-Realm">>, AuthRealm} @@ -299,15 +299,15 @@ get_endpoint_ccvs(Endpoint, AuthUser, AuthRealm, AccountId, AuthzId) -> ]), [{<<"Custom-Channel-Vars">>, kz_json:from_list(Props)} | Endpoint]. --spec get_endpoint_sip_headers(kz_proplist(), api_binary(), api_binary()) -> kz_proplist(). +-spec get_endpoint_sip_headers(kz_term:proplist(), kz_term:api_binary(), kz_term:api_binary()) -> kz_term:proplist(). get_endpoint_sip_headers(Endpoint, 'undefined', _) -> Endpoint; get_endpoint_sip_headers(Endpoint, _, 'undefined') -> Endpoint; get_endpoint_sip_headers(Endpoint, AuthUser, AuthRealm) -> Props = [{<<"X-KAZOO-AOR">>, <<"sip:", AuthUser/binary, "@", AuthRealm/binary>>}], [{<<"Custom-SIP-Headers">>, kz_json:from_list(Props)} | Endpoint]. --spec routing_data(ne_binary(), ne_binary()) -> [{<<_:48,_:_*8>>, any()}]. --spec routing_data(ne_binary(), ne_binary(), kz_json:object()) -> [{<<_:48,_:_*8>>, any()}]. +-spec routing_data(kz_term:ne_binary(), kz_term:ne_binary()) -> [{<<_:48,_:_*8>>, any()}]. +-spec routing_data(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> [{<<_:48,_:_*8>>, any()}]. routing_data(ToDID, AccountId) -> case ts_util:lookup_did(ToDID, AccountId) of {'ok', Settings} -> @@ -420,7 +420,7 @@ routing_data(ToDID, AccountId, Settings) -> V =/= <<>> ]. --spec build_ip(api_binary(), api_binary() | integer()) -> api_binary(). +-spec build_ip(kz_term:api_binary(), kz_term:api_binary() | integer()) -> kz_term:api_binary(). build_ip('undefined', _) -> 'undefined'; build_ip(IP, 'undefined') -> IP; build_ip(IP, <<_/binary>> = PortBin) -> build_ip(IP, kz_term:to_integer(PortBin)); @@ -445,8 +445,8 @@ callee_id([JObj | T]) -> end end. --spec maybe_anonymize_caller_id(ts_callflow:state(), {ne_binary(), ne_binary()}, api_object()) -> - kz_proplist(). +-spec maybe_anonymize_caller_id(ts_callflow:state(), {kz_term:ne_binary(), kz_term:ne_binary()}, kz_term:api_object()) -> + kz_term:proplist(). maybe_anonymize_caller_id(State, DefaultCID, CidFormat) -> AccountId = ts_callflow:get_account_id(State), CCVs = ts_callflow:get_custom_channel_vars(State), diff --git a/applications/trunkstore/src/ts_from_onnet.erl b/applications/trunkstore/src/ts_from_onnet.erl index 827d2d1ea5a..4eb2cc16c10 100644 --- a/applications/trunkstore/src/ts_from_onnet.erl +++ b/applications/trunkstore/src/ts_from_onnet.erl @@ -19,7 +19,7 @@ -define(SERVER, ?MODULE). --spec start_link(kz_json:object()) -> startlink_ret(). +-spec start_link(kz_json:object()) -> kz_types:startlink_ret(). start_link(RouteReqJObj) -> proc_lib:start_link(?SERVER, 'init', [self(), RouteReqJObj]). @@ -167,7 +167,7 @@ onnet_data(CallID, AccountId, FromUser, ToDID, Options, State) -> ts_callflow:cleanup_amqp(State) end. --spec get_flags(kz_json:object(), kz_json:object(), kz_json:object(), ts_callflow:state()) -> ne_binaries(). +-spec get_flags(kz_json:object(), kz_json:object(), kz_json:object(), ts_callflow:state()) -> kz_term:ne_binaries(). get_flags(DIDOptions, ServerOptions, AccountOptions, State) -> Call = ts_callflow:get_kapps_call(State), Flags = kz_attributes:get_flags(?APP_NAME, Call), @@ -176,7 +176,7 @@ get_flags(DIDOptions, ServerOptions, AccountOptions, State) -> ], lists:foldl(fun(F, A) -> F(DIDOptions, ServerOptions, AccountOptions, Call, A) end, Flags, Routines). --spec get_offnet_flags(kz_json:object(), kz_json:object(), kz_json:object(), kapps_call:call(), ne_binaries()) -> ne_binaries(). +-spec get_offnet_flags(kz_json:object(), kz_json:object(), kz_json:object(), kapps_call:call(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). get_offnet_flags(DIDOptions, ServerOptions, AccountOptions, _, Flags) -> case ts_util:offnet_flags([kz_json:get_value(<<"DID_Opts">>, DIDOptions) ,kz_json:get_value(<<"flags">>, ServerOptions) @@ -187,7 +187,7 @@ get_offnet_flags(DIDOptions, ServerOptions, AccountOptions, _, Flags) -> DIDFlags -> Flags ++ DIDFlags end. --spec get_offnet_dynamic_flags(kz_json:object(), kz_json:object(), kz_json:object(), kapps_call:call(), ne_binaries()) -> ne_binaries(). +-spec get_offnet_dynamic_flags(kz_json:object(), kz_json:object(), kz_json:object(), kapps_call:call(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). get_offnet_dynamic_flags(_, ServerOptions, AccountOptions, Call, Flags) -> case ts_util:offnet_flags([kz_json:get_value(<<"dynamic_flags">>, ServerOptions) ,kz_json:get_value(<<"dynamic_flags">>, AccountOptions) @@ -249,24 +249,24 @@ maybe_fix_request({Username, Realm}, JObj) -> _ -> JObj end. --spec fix_request_values(binary(), binary()) -> [{kz_json:path(), ne_binary()}]. +-spec fix_request_values(binary(), binary()) -> [{kz_json:path(), kz_term:ne_binary()}]. fix_request_values(Username, Realm) -> [{[<<"Custom-Channel-Vars">>, <<"Username">>], Username} ,{[<<"Custom-Channel-Vars">>, <<"Realm">>], Realm} ,{[<<"Custom-Channel-Vars">>, <<"Authorizing-Type">>], <<"sys_info">>} ]. --spec get_referred_by(kz_json:object()) -> api_binary(). +-spec get_referred_by(kz_json:object()) -> kz_term:api_binary(). get_referred_by(JObj) -> ReferredBy = kz_json:get_value([<<"Custom-Channel-Vars">>, <<"Referred-By">>], JObj), extract_sip_username(ReferredBy). --spec get_redirected_by(kz_json:object()) -> api_binary(). +-spec get_redirected_by(kz_json:object()) -> kz_term:api_binary(). get_redirected_by(JObj) -> RedirectedBy = kz_json:get_value([<<"Custom-Channel-Vars">>, <<"Redirected-By">>], JObj), extract_sip_username(RedirectedBy). --spec extract_sip_username(api_binary()) -> api_binary(). +-spec extract_sip_username(kz_term:api_binary()) -> kz_term:api_binary(). extract_sip_username('undefined') -> 'undefined'; extract_sip_username(Contact) -> ReOptions = [{'capture', 'all_but_first', 'binary'}], diff --git a/applications/trunkstore/src/ts_offnet_sup.erl b/applications/trunkstore/src/ts_offnet_sup.erl index 6cb11ac5022..ed8357ea187 100644 --- a/applications/trunkstore/src/ts_offnet_sup.erl +++ b/applications/trunkstore/src/ts_offnet_sup.erl @@ -27,11 +27,11 @@ %%-------------------------------------------------------------------- %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec start_handler(ne_binary(), kz_json:object()) -> sup_startchild_ret(). +-spec start_handler(kz_term:ne_binary(), kz_json:object()) -> kz_types:sup_startchild_ret(). start_handler(CallID, RouteReqJObj) -> supervisor:start_child(?SERVER, ?WORKER_NAME_ARGS_TYPE(<<"offnet-", CallID/binary>> ,'ts_from_offnet' @@ -39,7 +39,7 @@ start_handler(CallID, RouteReqJObj) -> ,'temporary' )). --spec stop_handler(ne_binary()) -> 'ok'. +-spec stop_handler(kz_term:ne_binary()) -> 'ok'. stop_handler(CallID) -> 'ok' = supervisor:terminate_child(?SERVER, <<"offnet-", CallID/binary>>), _ = supervisor:delete_child(?SERVER, <<"offnet-", CallID/binary>>), @@ -58,7 +58,7 @@ stop_handler(CallID) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 1, diff --git a/applications/trunkstore/src/ts_onnet_sup.erl b/applications/trunkstore/src/ts_onnet_sup.erl index c126aaa19bb..de83aafb2e1 100644 --- a/applications/trunkstore/src/ts_onnet_sup.erl +++ b/applications/trunkstore/src/ts_onnet_sup.erl @@ -26,11 +26,11 @@ %%-------------------------------------------------------------------- %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec start_handler(ne_binary(), kz_json:object()) -> sup_startchild_ret(). +-spec start_handler(kz_term:ne_binary(), kz_json:object()) -> kz_types:sup_startchild_ret(). start_handler(CallID, RouteReqJObj) -> supervisor:start_child(?SERVER, ?WORKER_NAME_ARGS_TYPE(<<"onnet-", CallID/binary>> ,'ts_from_onnet' @@ -38,7 +38,7 @@ start_handler(CallID, RouteReqJObj) -> ,'temporary' )). --spec stop_handler(ne_binary()) -> 'ok'. +-spec stop_handler(kz_term:ne_binary()) -> 'ok'. stop_handler(CallID) -> 'ok' = supervisor:terminate_child(?SERVER, <<"onnet-", CallID/binary>>), _ = supervisor:delete_child(?SERVER, <<"onnet-", CallID/binary>>), @@ -57,7 +57,7 @@ stop_handler(CallID) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 1, diff --git a/applications/trunkstore/src/ts_responder.erl b/applications/trunkstore/src/ts_responder.erl index b8ff568e827..c6d793b1f81 100644 --- a/applications/trunkstore/src/ts_responder.erl +++ b/applications/trunkstore/src/ts_responder.erl @@ -49,7 +49,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER, [{'responders', ?RESPONDERS} ,{'bindings', ?BINDINGS} @@ -87,7 +87,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', 'ignored', State}. @@ -101,7 +101,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> {'noreply', State}. @@ -115,7 +115,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Unhandled, State) -> lager:info("unknown message: ~p", [_Unhandled]), {'noreply', State}. @@ -128,7 +128,7 @@ handle_info(_Unhandled, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/trunkstore/src/ts_route_req.erl b/applications/trunkstore/src/ts_route_req.erl index 35f257f4387..d99e69b1357 100644 --- a/applications/trunkstore/src/ts_route_req.erl +++ b/applications/trunkstore/src/ts_route_req.erl @@ -17,7 +17,7 @@ -spec init() -> 'ok'. init() -> 'ok'. --spec handle_req(kz_json:object(), kz_proplist()) -> any(). +-spec handle_req(kz_json:object(), kz_term:proplist()) -> any(). handle_req(ApiJObj, _Options) -> 'true' = kapi_route:req_v(ApiJObj), kz_util:put_callid(ApiJObj), diff --git a/applications/trunkstore/src/ts_util.erl b/applications/trunkstore/src/ts_util.erl index 83129ec9981..0a0c313853c 100644 --- a/applications/trunkstore/src/ts_util.erl +++ b/applications/trunkstore/src/ts_util.erl @@ -47,7 +47,7 @@ -define(VALIDATE_CALLER_ID, kapps_config:get_is_true(?CONFIG_CAT, <<"ensure_valid_caller_id">>, 'false')). -define(HONOR_DIVERSION, kapps_config:get_is_true(?CONFIG_CAT, <<"honor_diversions_by_cid_validation">>, 'false')). --spec find_ip(ne_binary() | nonempty_string()) -> nonempty_string(). +-spec find_ip(kz_term:ne_binary() | nonempty_string()) -> nonempty_string(). find_ip(Domain) when is_binary(Domain) -> find_ip(binary_to_list(Domain)); find_ip(Domain) when is_list(Domain) -> @@ -65,7 +65,7 @@ find_ip(Domain) when is_list(Domain) -> %% FilterOn: CallID | flat_rate | per_min %% Remove active call entries based on what Filter criteria is passed in --spec filter_active_calls(ne_binary() | 'flat_rate' | 'per_min', active_calls()) -> active_calls(). +-spec filter_active_calls(kz_term:ne_binary() | 'flat_rate' | 'per_min', active_calls()) -> active_calls(). filter_active_calls('flat_rate', ActiveCalls) -> lists:filter(fun({_,'flat_rate'}) -> 'false'; (_) -> 'true' @@ -80,21 +80,21 @@ filter_active_calls(CallID, ActiveCalls) -> (_) -> 'true' end, ActiveCalls). --spec get_media_handling(kz_json:objects() | api_binaries()) -> ne_binary(). +-spec get_media_handling(kz_json:objects() | kz_term:api_binaries()) -> kz_term:ne_binary(). get_media_handling(L) -> case simple_extract(L) of <<"process">> -> <<"process">>; _ -> <<"bypass">> end. --spec constrain_weight(ne_binary() | integer()) -> integer(). +-spec constrain_weight(kz_term:ne_binary() | integer()) -> integer(). constrain_weight(W) when not is_integer(W) -> constrain_weight(kz_term:to_integer(W)); constrain_weight(W) when W > 100 -> 100; constrain_weight(W) when W < 1 -> 1; constrain_weight(W) -> W. --spec lookup_did(ne_binary(), ne_binary()) -> +-spec lookup_did(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', 'no_did_found' | atom()}. lookup_did(DID, AccountId) -> @@ -140,13 +140,13 @@ lookup_did(DID, AccountId) -> end end. --spec lookup_user_flags(ne_binary(), ne_binary(), ne_binary()) -> +-spec lookup_user_flags(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', atom()}. lookup_user_flags(Name, Realm, AccountId) -> lookup_user_flags(Name, Realm, AccountId, 'undefined'). --spec lookup_user_flags(ne_binary(), ne_binary(), ne_binary(), api_binary()) -> +-spec lookup_user_flags(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary()) -> {'ok', kz_json:object()} | {'error', atom()}. lookup_user_flags('undefined', _, _, 'undefined') -> @@ -216,7 +216,7 @@ lookup_user_flags(Name, Realm, AccountId, _) -> end end. --spec merge_account_attributes(ne_binary() | kz_json:object(), kz_json:object()) -> kz_json:object(). +-spec merge_account_attributes(kz_term:ne_binary() | kz_json:object(), kz_json:object()) -> kz_json:object(). merge_account_attributes(?NE_BINARY=AccountId, JObj) -> case kz_account:fetch(AccountId) of {'ok', Account} -> merge_account_attributes(Account, JObj); @@ -234,7 +234,7 @@ merge_account_attributes(Account, JObj) -> get_call_duration(JObj) -> kz_term:to_integer(kz_json:get_value(<<"Billing-Seconds">>, JObj)). --spec invite_format(ne_binary(), ne_binary()) -> kz_proplist(). +-spec invite_format(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:proplist(). invite_format(<<"e.164">>, To) -> [{<<"Invite-Format">>, <<"e164">>} ,{<<"To-DID">>, knm_converters:normalize(To)} @@ -274,7 +274,7 @@ invite_format(<<"npan">>, To) -> invite_format(_, _) -> [{<<"Invite-Format">>, <<"username">>}]. --spec caller_id(api_objects()) -> {api_binary(), api_binary()}. +-spec caller_id(kz_term:api_objects()) -> {kz_term:api_binary(), kz_term:api_binary()}. caller_id([]) -> {'undefined', 'undefined'}; caller_id(['undefined'|T]) -> caller_id(T); caller_id([CID|T]) -> @@ -286,7 +286,7 @@ caller_id([CID|T]) -> CallerID -> CallerID end. --spec sip_headers(api_objects()) -> api_object(). +-spec sip_headers(kz_term:api_objects()) -> kz_term:api_object(). sip_headers([]) -> 'undefined'; sip_headers(L) when is_list(L) -> case [Headers || Headers <- L, @@ -298,8 +298,8 @@ sip_headers(L) when is_list(L) -> _ -> 'undefined' end. --spec failover(kz_json:objects() | api_binaries()) -> - api_object(). +-spec failover(kz_json:objects() | kz_term:api_binaries()) -> + kz_term:api_object(). %% cascade from DID to Srv to Account failover(L) -> case simple_extract(L) of @@ -307,27 +307,27 @@ failover(L) -> Other -> Other end. --spec progress_timeout(kz_json:objects() | api_binaries()) -> - kz_json:object() | api_binary(). +-spec progress_timeout(kz_json:objects() | kz_term:api_binaries()) -> + kz_json:object() | kz_term:api_binary(). progress_timeout(L) -> simple_extract(L). --spec bypass_media(kz_json:objects() | api_binaries()) -> ne_binary(). +-spec bypass_media(kz_json:objects() | kz_term:api_binaries()) -> kz_term:ne_binary(). bypass_media(L) -> case simple_extract(L) of <<"process">> -> <<"false">>; _ -> <<"true">> end. --spec delay(kz_json:objects() | api_binaries()) -> - kz_json:object() | api_binary(). +-spec delay(kz_json:objects() | kz_term:api_binaries()) -> + kz_json:object() | kz_term:api_binary(). delay(L) -> simple_extract(L). --spec ignore_early_media(kz_json:objects() | api_binaries()) -> - kz_json:object() | api_binary(). +-spec ignore_early_media(kz_json:objects() | kz_term:api_binaries()) -> + kz_json:object() | kz_term:api_binary(). ignore_early_media(L) -> simple_extract(L). --spec ep_timeout(kz_json:objects() | api_binaries()) -> - kz_json:object() | api_binary(). +-spec ep_timeout(kz_json:objects() | kz_term:api_binaries()) -> + kz_json:object() | kz_term:api_binary(). ep_timeout(L) -> simple_extract(L). -spec offnet_flags(list()) -> 'undefined' | list(). @@ -335,8 +335,8 @@ offnet_flags([]) -> 'undefined'; offnet_flags([H|_]) when is_list(H) -> H; offnet_flags([_|T]) -> offnet_flags(T). --spec simple_extract(kz_json:objects() | api_binaries()) -> - kz_json:object() | api_binary(). +-spec simple_extract(kz_json:objects() | kz_term:api_binaries()) -> + kz_json:object() | kz_term:api_binary(). simple_extract([]) -> 'undefined'; simple_extract(['undefined'|T]) -> simple_extract(T); simple_extract([<<>> | T]) -> simple_extract(T); @@ -351,8 +351,8 @@ simple_extract([JObj | T]) -> -type cid_type() :: 'external' | 'emergency'. --spec maybe_ensure_cid_valid(cid_type(), api_binary(), ne_binary(), ne_binary(), kz_json:object()) -> - ne_binary(). +-spec maybe_ensure_cid_valid(cid_type(), kz_term:api_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> + kz_term:ne_binary(). maybe_ensure_cid_valid('external', CIDNum, FromUser, AccountId, CustomSIPHeaders) -> case ?VALIDATE_CALLER_ID of 'true' -> maybe_honor_diversion(CIDNum, FromUser, AccountId, CustomSIPHeaders); @@ -382,7 +382,7 @@ honor_diversion(CIDNum, FromUser, AccountId, CustomSIPHeaders) -> validate_external_cid(CIDNum, FromUser, AccountId) end. --spec validate_external_cid(api_binary(), ne_binary(), ne_binary()) -> ne_binary(). +-spec validate_external_cid(kz_term:api_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). validate_external_cid(CIDNum, FromUser, AccountId) -> lager:info("ensure_valid_caller_id flag detected, will check whether CID is legal..."), case knm_number:lookup_account(CIDNum) of @@ -390,7 +390,7 @@ validate_external_cid(CIDNum, FromUser, AccountId) -> _Else -> validate_from_user(FromUser, AccountId) end. --spec validate_from_user(ne_binary(), ne_binary()) -> ne_binary(). +-spec validate_from_user(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). validate_from_user(FromUser, AccountId) -> NormalizedFromUser = knm_converters:normalize(FromUser), case knm_number:lookup_account(NormalizedFromUser) of @@ -403,7 +403,7 @@ validate_from_user(FromUser, AccountId) -> DefaultCID end. --spec maybe_restrict_call(ts_callflow:state(), kz_proplist()) -> boolean(). +-spec maybe_restrict_call(ts_callflow:state(), kz_term:proplist()) -> boolean(). maybe_restrict_call(#ts_callflow_state{acctid=AccountId ,route_req_jobj=RRObj } diff --git a/applications/webhooks/src/modules/webhooks_notifications.erl b/applications/webhooks/src/modules/webhooks_notifications.erl index d27b3109678..2b75c84a7ed 100644 --- a/applications/webhooks/src/modules/webhooks_notifications.erl +++ b/applications/webhooks/src/modules/webhooks_notifications.erl @@ -51,7 +51,7 @@ init() -> init(get_notifications_definition(), []). --spec init(kapi_definition:apis(), [{ne_binary(), kz_json:object()}]) -> 'ok'. +-spec init(kapi_definition:apis(), [{kz_term:ne_binary(), kz_json:object()}]) -> 'ok'. init([], Acc) -> _ = webhooks_util:init_metadata(?ID, ?METADATA(Acc)), 'ok'; @@ -92,7 +92,7 @@ bindings() -> %% @doc %% @end %%-------------------------------------------------------------------- --spec account_bindings(ne_binary()) -> gen_listener:bindings(). +-spec account_bindings(kz_term:ne_binary()) -> gen_listener:bindings(). account_bindings(_AccountId) -> []. %%-------------------------------------------------------------------- @@ -100,7 +100,7 @@ account_bindings(_AccountId) -> []. %% @doc %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_event(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_event(JObj, _Props) -> kz_util:put_callid(JObj), @@ -122,7 +122,7 @@ handle_event(JObj, _Props) -> webhooks_util:fire_hooks(Event, Filtered) end. --spec match_action_type(webhook(), api_binary()) -> boolean(). +-spec match_action_type(webhook(), kz_term:api_binary()) -> boolean(). match_action_type(#webhook{hook_event = ?HOOK_NAME ,custom_data='undefined' }, _Type) -> diff --git a/applications/webhooks/src/modules/webhooks_object.erl b/applications/webhooks/src/modules/webhooks_object.erl index 0cc66a8c670..fac2a48e19b 100644 --- a/applications/webhooks/src/modules/webhooks_object.erl +++ b/applications/webhooks/src/modules/webhooks_object.erl @@ -77,7 +77,7 @@ bindings_and_responders() -> %% @doc %% @end %%-------------------------------------------------------------------- --spec account_bindings(ne_binary()) -> gen_listener:bindings(). +-spec account_bindings(kz_term:ne_binary()) -> gen_listener:bindings(). account_bindings(_AccountId) -> []. %%-------------------------------------------------------------------- @@ -85,7 +85,7 @@ account_bindings(_AccountId) -> []. %% @doc %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> any(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> any(). handle_event(JObj, _Props) -> kz_util:put_callid(JObj), 'true' = kapi_conf:doc_update_v(JObj), @@ -104,7 +104,7 @@ handle_event(JObj, _Props) -> webhooks_util:fire_hooks(Event, Filtered) end. --spec match_action_type(webhook(), api_binary(), api_binary()) -> boolean(). +-spec match_action_type(webhook(), kz_term:api_binary(), kz_term:api_binary()) -> boolean(). match_action_type(#webhook{hook_event = ?HOOK_NAME ,custom_data='undefined' }, _Action, _Type) -> @@ -136,7 +136,7 @@ bindings() -> %% @doc %% @end %%-------------------------------------------------------------------- --spec format_event(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec format_event(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). format_event(JObj, AccountId) -> kz_json:from_list( [{<<"id">>, kapi_conf:get_id(JObj)} @@ -150,12 +150,12 @@ format_event(JObj, AccountId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec find_account_id(kz_json:object()) -> ne_binary(). +-spec find_account_id(kz_json:object()) -> kz_term:ne_binary(). find_account_id(JObj) -> DB = kapi_conf:get_database(JObj), find_account_id(kzs_util:db_classification(DB), DB, kapi_conf:get_id(JObj)). --spec find_account_id(atom(), ne_binary(), ne_binary()) -> ne_binary(). +-spec find_account_id(atom(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). find_account_id(Classification, DB, _Id) when Classification =:= 'account'; Classification =:= 'modb' -> diff --git a/applications/webhooks/src/modules/webhooks_parking.erl b/applications/webhooks/src/modules/webhooks_parking.erl index 8ef40d6adf3..0a8c232512b 100644 --- a/applications/webhooks/src/modules/webhooks_parking.erl +++ b/applications/webhooks/src/modules/webhooks_parking.erl @@ -58,7 +58,7 @@ bindings_and_responders() -> %% @doc %% @end %%-------------------------------------------------------------------- --spec handle(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle(kz_json:object(), kz_term:proplist()) -> 'ok'. handle(JObj, _Props) -> 'true' = kapi_call:event_v(JObj), AccountId = kz_json:get_value([<<"Custom-Channel-Vars">>, <<"Account-ID">>], JObj), @@ -69,7 +69,7 @@ handle(JObj, _Props) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec maybe_send_event(api_binary(), kz_json:object()) -> 'ok'. +-spec maybe_send_event(kz_term:api_binary(), kz_json:object()) -> 'ok'. maybe_send_event('undefined', _JObj) -> 'ok'; maybe_send_event(AccountId, JObj) -> case webhooks_util:find_webhooks(?HOOK_NAME, AccountId) of diff --git a/applications/webhooks/src/modules/webhooks_skel.erl b/applications/webhooks/src/modules/webhooks_skel.erl index 860127c1ff7..b53655679b3 100644 --- a/applications/webhooks/src/modules/webhooks_skel.erl +++ b/applications/webhooks/src/modules/webhooks_skel.erl @@ -37,7 +37,7 @@ bindings_and_responders() -> ] }. --spec handle_event(kz_json:object(), kz_proplist()) -> any(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> any(). handle_event(JObj, _Props) -> kz_util:put_callid(JObj), lager:debug("event handled"). diff --git a/applications/webhooks/src/webhooks.hrl b/applications/webhooks/src/webhooks.hrl index cd9a6db8773..65f59235393 100644 --- a/applications/webhooks/src/webhooks.hrl +++ b/applications/webhooks/src/webhooks.hrl @@ -10,17 +10,17 @@ -type http_verb() :: 'get' | 'post'. -type hook_retries() :: 1..5. --record(webhook, {id :: api_ne_binary() | '_' - ,uri :: api_ne_binary() | '_' +-record(webhook, {id :: kz_term:api_ne_binary() | '_' + ,uri :: kz_term:api_ne_binary() | '_' ,http_verb = 'get' :: http_verb() | '_' - ,hook_event :: api_ne_binary() | '_' | '$1' | '$2' - ,hook_id :: api_ne_binary() | '_' + ,hook_event :: kz_term:api_ne_binary() | '_' | '$1' | '$2' + ,hook_id :: kz_term:api_ne_binary() | '_' ,retries = 3 :: hook_retries() | '_' - ,account_id :: api_ne_binary() | '_' | '$1' + ,account_id :: kz_term:api_ne_binary() | '_' | '$1' ,include_subaccounts = 'false' :: boolean() | '_' | '$3' ,include_loopback = 'true' :: boolean() | '_' - ,custom_data :: api_object() | '_' - ,modifiers :: api_object() | '_' + ,custom_data :: kz_term:api_object() | '_' + ,modifiers :: kz_term:api_object() | '_' }). -type webhook() :: #webhook{}. -type webhooks() :: [webhook()]. diff --git a/applications/webhooks/src/webhooks_app.erl b/applications/webhooks/src/webhooks_app.erl index 6059c9ce77d..7286753c29b 100644 --- a/applications/webhooks/src/webhooks_app.erl +++ b/applications/webhooks/src/webhooks_app.erl @@ -18,7 +18,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = declare_exchanges(), webhooks_sup:start_link(). diff --git a/applications/webhooks/src/webhooks_channel_util.erl b/applications/webhooks/src/webhooks_channel_util.erl index d34bd5ce696..437f18d1887 100644 --- a/applications/webhooks/src/webhooks_channel_util.erl +++ b/applications/webhooks/src/webhooks_channel_util.erl @@ -14,7 +14,7 @@ -include("webhooks.hrl"). --spec handle_event(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_event(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_event(JObj, _Props) -> HookEvent = hook_event_name(kz_json:get_value(<<"Event-Name">>, JObj)), case kz_hooks_util:lookup_account_id(JObj) of @@ -28,7 +28,7 @@ handle_event(JObj, _Props) -> end. %% @public --spec maybe_handle_channel_event(ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec maybe_handle_channel_event(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. maybe_handle_channel_event(AccountId, HookEvent, JObj) -> lager:debug("evt ~s for ~s", [HookEvent, AccountId]), case webhooks_util:find_webhooks(HookEvent, AccountId) of @@ -37,7 +37,7 @@ maybe_handle_channel_event(AccountId, HookEvent, JObj) -> maybe_fire_event(AccountId, HookEvent, JObj, Hooks) end. --spec maybe_fire_event(ne_binary(), ne_binary(), kz_json:object(), webhooks()) -> 'ok'. +-spec maybe_fire_event(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), webhooks()) -> 'ok'. maybe_fire_event(AccountId, HookEvent, JObj, Hooks) -> FireAbleHooks = fireable_hooks(JObj, Hooks), webhooks_util:fire_hooks(format_event(JObj, AccountId, HookEvent), FireAbleHooks). @@ -62,15 +62,15 @@ is_fireable_hook(JObj, #webhook{include_loopback='false' 'false' end. --spec is_loopback_channel_name(api_ne_binary()) -> boolean(). +-spec is_loopback_channel_name(kz_term:api_ne_binary()) -> boolean(). is_loopback_channel_name(<<"loopback/", _/binary>>=_N) -> 'true'; is_loopback_channel_name(_N) -> 'false'. --spec hook_event_name(ne_binary()) -> ne_binary(). +-spec hook_event_name(kz_term:ne_binary()) -> kz_term:ne_binary(). hook_event_name(<<"CHANNEL_DISCONNECTED">>) -> <<"CHANNEL_DESTROY">>; hook_event_name(Event) -> Event. --spec format_event(kz_json:object(), api_binary(), ne_binary()) -> +-spec format_event(kz_json:object(), kz_term:api_binary(), kz_term:ne_binary()) -> kz_json:object(). format_event(JObj, AccountId, <<"CHANNEL_CREATE">>) -> kz_json:set_value(<<"hook_event">>, <<"channel_create">> @@ -100,8 +100,8 @@ format_event(JObj, AccountId, <<"CHANNEL_DESTROY">>) -> ] ). --spec base_hook_event(kz_json:object(), api_binary()) -> kz_json:object(). --spec base_hook_event(kz_json:object(), api_binary(), kz_proplist()) -> kz_json:object(). +-spec base_hook_event(kz_json:object(), kz_term:api_binary()) -> kz_json:object(). +-spec base_hook_event(kz_json:object(), kz_term:api_binary(), kz_term:proplist()) -> kz_json:object(). base_hook_event(JObj, AccountId) -> base_hook_event(JObj, AccountId, []). base_hook_event(JObj, AccountId, Acc) -> @@ -135,21 +135,21 @@ base_hook_event(JObj, AccountId, Acc) -> | Acc ]). --spec resource_used(boolean(), kz_json:object()) -> api_binary(). +-spec resource_used(boolean(), kz_json:object()) -> kz_term:api_binary(). resource_used('true', _JObj) -> 'undefined'; resource_used('false', JObj) -> ccv(JObj, <<"Resource-ID">>). -spec ccv(kz_json:object(), kz_json:path()) -> - api_binary(). + kz_term:api_binary(). -spec ccv(kz_json:object(), kz_json:path(), Default) -> - ne_binary() | Default. + kz_term:ne_binary() | Default. ccv(JObj, Key) -> ccv(JObj, Key, 'undefined'). ccv(JObj, Key, Default) -> kz_call_event:custom_channel_var(JObj, Key, Default). --spec non_reserved_ccvs(kz_call_event:doc()) -> api_object(). --spec non_reserved_ccvs(kz_json:object(), api_ne_binaries()) -> api_object(). +-spec non_reserved_ccvs(kz_call_event:doc()) -> kz_term:api_object(). +-spec non_reserved_ccvs(kz_json:object(), kz_term:api_ne_binaries()) -> kz_term:api_object(). non_reserved_ccvs(JObj) -> CCVs = kz_call_event:custom_channel_vars(JObj, kz_json:new()), non_reserved_ccvs(CCVs, kapps_config:get_ne_binaries(<<"call_command">>, <<"reserved_ccv_keys">>)). @@ -159,6 +159,6 @@ non_reserved_ccvs(CCVs, Keys) -> kz_json:filter(fun({K, _}) -> not lists:member(K, Keys) end, CCVs). -spec cavs(kz_json:object()) -> - api_object(). + kz_term:api_object(). cavs(JObj) -> kz_call_event:custom_application_vars(JObj). diff --git a/applications/webhooks/src/webhooks_disabler.erl b/applications/webhooks/src/webhooks_disabler.erl index 328e3e69f87..c7f67ffe7fd 100644 --- a/applications/webhooks/src/webhooks_disabler.erl +++ b/applications/webhooks/src/webhooks_disabler.erl @@ -30,7 +30,7 @@ -define(EXPIRY_MSG, 'failure_check'). --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_server:start_link(?SERVER, [], []). @@ -39,15 +39,15 @@ init(_) -> kz_util:put_callid(?MODULE), {'ok', start_check_timer()}. --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'noreply', State}. --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> {'noreply', State}. --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'timeout', Ref, ?EXPIRY_MSG}, Ref) -> _ = kz_util:spawn(fun check_failed_attempts/0), {'noreply', start_check_timer()}; @@ -77,7 +77,7 @@ check_failed_attempts() -> Failures = find_failures(), check_failures(Failures). --type failure() :: {{ne_binary(), ne_binary()}, integer()}. +-type failure() :: {{kz_term:ne_binary(), kz_term:ne_binary()}, integer()}. -type failures() :: [failure()]. -spec find_failures() -> failures(). @@ -97,8 +97,8 @@ flush_hooks(HookJObjs) -> ] ). --spec flush_failures(ne_binary()) -> non_neg_integer(). --spec flush_failures(ne_binary(), api_binary()) -> non_neg_integer(). +-spec flush_failures(kz_term:ne_binary()) -> non_neg_integer(). +-spec flush_failures(kz_term:ne_binary(), kz_term:api_binary()) -> non_neg_integer(). flush_failures(AccountId) -> flush_failures(AccountId, 'undefined'). flush_failures(AccountId, HookId) -> @@ -109,7 +109,7 @@ flush_failures(AccountId, HookId) -> ,FilterFun ). --spec maybe_remove_failure(tuple(), ne_binary(), api_binary()) -> boolean(). +-spec maybe_remove_failure(tuple(), kz_term:ne_binary(), kz_term:api_binary()) -> boolean(). maybe_remove_failure(?FAILURE_CACHE_KEY(AccountId, HookId, _Timestamp) ,AccountId ,HookId @@ -141,7 +141,7 @@ check_failures(Failures) -> ], 'ok'. --spec check_failure(ne_binary(), ne_binary(), pos_integer()) -> 'ok'. +-spec check_failure(kz_term:ne_binary(), kz_term:ne_binary(), pos_integer()) -> 'ok'. check_failure(AccountId, HookId, Count) -> try kz_term:to_integer(kapps_account_config:get_global(AccountId, ?APP_NAME, ?FAILURE_COUNT_KEY, 6)) of N when N =< Count -> @@ -157,7 +157,7 @@ check_failure(AccountId, HookId, Count) -> end end. --spec disable_hook(ne_binary(), ne_binary()) -> 'ok'. +-spec disable_hook(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. disable_hook(AccountId, HookId) -> case kz_datamgr:open_cache_doc(?KZ_WEBHOOKS_DB, HookId) of {'ok', HookJObj} -> @@ -170,7 +170,7 @@ disable_hook(AccountId, HookId) -> lager:debug("failed to find ~s/~s to disable: ~p", [AccountId, HookId, _E]) end. --spec filter_cache(ne_binary(), ne_binary()) -> non_neg_integer(). +-spec filter_cache(kz_term:ne_binary(), kz_term:ne_binary()) -> non_neg_integer(). filter_cache(AccountId, HookId) -> kz_cache:filter_erase_local(?CACHE_NAME ,fun(?FAILURE_CACHE_KEY(A, H, _), _) -> @@ -181,7 +181,7 @@ filter_cache(AccountId, HookId) -> end ). --spec send_notification(ne_binary(), ne_binary()) -> 'ok'. +-spec send_notification(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. send_notification(AccountId, HookId) -> API = [{<<"Account-ID">>, AccountId} ,{<<"Hook-ID">>, HookId} diff --git a/applications/webhooks/src/webhooks_init.erl b/applications/webhooks/src/webhooks_init.erl index 836456e6fad..6a7df9937cc 100644 --- a/applications/webhooks/src/webhooks_init.erl +++ b/applications/webhooks/src/webhooks_init.erl @@ -22,7 +22,7 @@ start_link() -> 'ignore'. -spec do_init() -> 'ok'. --spec do_init(ne_binary()) -> 'ok'. +-spec do_init(kz_term:ne_binary()) -> 'ok'. do_init() -> init_dbs(), init_modules(). @@ -36,14 +36,14 @@ init_dbs() -> _ = init_master_account_db(), webhooks_util:init_webhook_db(). --spec maybe_init_account(kz_json:object(), kz_proplist()) -> 'ok' | 'false'. +-spec maybe_init_account(kz_json:object(), kz_term:proplist()) -> 'ok' | 'false'. maybe_init_account(JObj, _Props) -> Database = kapi_conf:get_database(JObj), kz_datamgr:db_classification(Database) =:= 'account' andalso do_init(Database). -spec init_master_account_db() -> 'ok'. --spec init_master_account_db(ne_binary()) -> 'ok'. +-spec init_master_account_db(kz_term:ne_binary()) -> 'ok'. init_master_account_db() -> case kapps_util:get_master_account_db() of {'ok', MasterAccountDb} -> @@ -58,7 +58,7 @@ init_master_account_db(MasterAccountDb) -> _ = kz_datamgr:revise_doc_from_file(MasterAccountDb, 'webhooks', <<"webhooks.json">>), lager:debug("loaded view into master db ~s", [MasterAccountDb]). --spec remove_old_notifications_webhooks(ne_binary()) -> 'ok'. +-spec remove_old_notifications_webhooks(kz_term:ne_binary()) -> 'ok'. remove_old_notifications_webhooks(MasterAccountDb) -> ToRemove = [<<"webhooks_callflow">> ,<<"webhooks_inbound_fax">> @@ -88,11 +88,11 @@ init_module(Module) -> lager:debug("~s failed: ~s: ~p", [Module, _E, _R]) end. --spec existing_modules() -> atoms(). +-spec existing_modules() -> kz_term:atoms(). existing_modules() -> existing_modules(code:lib_dir(kz_term:to_atom(?APP_NAME))). --spec existing_modules(string()) -> atoms(). +-spec existing_modules(string()) -> kz_term:atoms(). existing_modules(WebhooksRoot) -> ModulesDirectory = filename:join(WebhooksRoot, "ebin"), Extension = ".beam", diff --git a/applications/webhooks/src/webhooks_listener.erl b/applications/webhooks/src/webhooks_listener.erl index de4e67eeb7e..13d595e0b5b 100644 --- a/applications/webhooks/src/webhooks_listener.erl +++ b/applications/webhooks/src/webhooks_listener.erl @@ -50,7 +50,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER ,[{'bindings', ?BINDINGS} @@ -59,8 +59,8 @@ start_link() -> ,[] ). --spec handle_config(kz_json:object(), kz_proplist()) -> 'ok'. --spec handle_config(kz_json:object(), pid(), ne_binary()) -> 'ok'. +-spec handle_config(kz_json:object(), kz_term:proplist()) -> 'ok'. +-spec handle_config(kz_json:object(), pid(), kz_term:ne_binary()) -> 'ok'. handle_config(JObj, Props) -> 'true' = kapi_conf:doc_update_v(JObj), handle_config(JObj @@ -163,7 +163,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -177,7 +177,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'add_hook', #webhook{id=_Id}=Hook}, State) -> lager:debug("adding hook ~s", [_Id]), ets:insert_new(webhooks_util:table_id(), Hook), @@ -211,7 +211,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'ETS-TRANSFER', _TblId, _From, _Data}, State) -> lager:info("write access to table '~p' available", [_TblId]), Self = self(), @@ -234,7 +234,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/webhooks/src/webhooks_maintenance.erl b/applications/webhooks/src/webhooks_maintenance.erl index 5661677a309..e5ec8ffd5ba 100644 --- a/applications/webhooks/src/webhooks_maintenance.erl +++ b/applications/webhooks/src/webhooks_maintenance.erl @@ -22,7 +22,7 @@ -include("webhooks.hrl"). -spec hooks_configured() -> 'ok'. --spec hooks_configured(ne_binary()) -> 'ok'. +-spec hooks_configured(kz_term:ne_binary()) -> 'ok'. hooks_configured() -> webhooks_shared_listener:hooks_configured(), 'ok'. @@ -31,8 +31,8 @@ hooks_configured(AccountId) -> webhooks_shared_listener:hooks_configured(AccountId), 'ok'. --spec set_failure_expiry(ne_binary()) -> 'ok'. --spec set_failure_expiry(ne_binary(), ne_binary()) -> 'ok'. +-spec set_failure_expiry(kz_term:ne_binary()) -> 'ok'. +-spec set_failure_expiry(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. set_failure_expiry(Expires) -> try kz_term:to_integer(Expires) of I -> @@ -54,8 +54,8 @@ set_failure_expiry(Account, Expires) -> io:format("error in expiry time, must be an integer (milliseconds)~n") end. --spec set_disable_threshold(ne_binary()) -> 'ok'. --spec set_disable_threshold(ne_binary(), ne_binary()) -> 'ok'. +-spec set_disable_threshold(kz_term:ne_binary()) -> 'ok'. +-spec set_disable_threshold(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. set_disable_threshold(Count) -> try kz_term:to_integer(Count) of I -> @@ -78,7 +78,7 @@ set_disable_threshold(Account, Count) -> end. -spec failure_status() -> 'ok'. --spec failure_status(ne_binary()) -> 'ok'. +-spec failure_status(kz_term:ne_binary()) -> 'ok'. failure_status() -> Failed = webhooks_disabler:find_failures(), Sorted = lists:keysort(1, Failed), @@ -108,11 +108,11 @@ print_failure_footer() -> print_failure_count(AccountId, HookId, Count) -> io:format(?FORMAT_FAILURE_STRING, [AccountId, HookId, kz_term:to_binary(Count)]). --spec enable_account_hooks(ne_binary()) -> 'ok'. +-spec enable_account_hooks(kz_term:ne_binary()) -> 'ok'. enable_account_hooks(AccountId) -> webhooks_util:reenable(AccountId, <<"account">>). --spec enable_descendant_hooks(ne_binary()) -> 'ok'. +-spec enable_descendant_hooks(kz_term:ne_binary()) -> 'ok'. enable_descendant_hooks(AccountId) -> webhooks_util:reenable(AccountId, <<"descendants">>). @@ -121,13 +121,13 @@ reset_webhooks_list() -> _ = kapi_maintenance:refresh_database(?KZ_WEBHOOKS_DB), _ = kapi_maintenance:refresh_views(?KZ_WEBHOOKS_DB). --spec flush_account_failures(ne_binary()) -> 'ok'. +-spec flush_account_failures(kz_term:ne_binary()) -> 'ok'. flush_account_failures(AccountId) -> io:format("flushed ~p failure entries~n" ,[webhooks_disabler:flush_failures(AccountId)] ). --spec flush_hook_failures(ne_binary(), ne_binary()) -> 'ok'. +-spec flush_hook_failures(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. flush_hook_failures(AccountId, HookId) -> io:format("flushed ~p failure entries for ~s~n" ,[webhooks_disabler:flush_failures(AccountId, HookId), HookId] diff --git a/applications/webhooks/src/webhooks_shared_listener.erl b/applications/webhooks/src/webhooks_shared_listener.erl index 94f04e14cd3..70ebd0cff47 100644 --- a/applications/webhooks/src/webhooks_shared_listener.erl +++ b/applications/webhooks/src/webhooks_shared_listener.erl @@ -57,7 +57,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> {Bindings, Responders} = load_module_bindings_and_responders(), lager:debug("bindings: ~p", [Bindings]), @@ -102,7 +102,7 @@ load_module_fold(Module, {Bindings, Responders}=Acc) -> Acc end. --spec handle_doc_type_update(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_doc_type_update(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_doc_type_update(JObj, _Props) -> 'true' = kapi_conf:doc_type_update_v(JObj), kz_util:put_callid(JObj), @@ -127,7 +127,7 @@ handle_doc_type_update(JObj, _Props) -> ). -spec hooks_configured() -> 'ok'. --spec hooks_configured(ne_binary()) -> 'ok'. +-spec hooks_configured(kz_term:ne_binary()) -> 'ok'. hooks_configured() -> MatchSpec = [{#webhook{_ = '_'} ,[] @@ -227,7 +227,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -241,7 +241,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _Q}}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'is_consuming', _IsConsuming}}, State) -> @@ -261,7 +261,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> lager:debug("unhandled msg: ~p", [_Info]), {'noreply', State}. @@ -274,7 +274,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/applications/webhooks/src/webhooks_sup.erl b/applications/webhooks/src/webhooks_sup.erl index 6c2a1d3b495..1384448f49a 100644 --- a/applications/webhooks/src/webhooks_sup.erl +++ b/applications/webhooks/src/webhooks_sup.erl @@ -44,25 +44,25 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec listener() -> api_pid(). +-spec listener() -> kz_term:api_pid(). listener() -> case child_of_type(?SERVER, 'webhooks_listener') of [] -> 'undefined'; [P] -> P end. --spec shared_listener() -> api_pid(). +-spec shared_listener() -> kz_term:api_pid(). shared_listener() -> case child_of_type(?SERVER, 'webhooks_shared_listener') of [] -> 'undefined'; [P] -> P end. --spec child_of_type(pid() | atom(), atom()) -> pids(). +-spec child_of_type(pid() | atom(), atom()) -> kz_term:pids(). child_of_type(S, T) -> [P || {Ty, P, 'worker', _} <- supervisor:which_children(S), T =:= Ty @@ -81,7 +81,7 @@ child_of_type(S, T) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/applications/webhooks/src/webhooks_util.erl b/applications/webhooks/src/webhooks_util.erl index 17335a1478f..940392fe11e 100644 --- a/applications/webhooks/src/webhooks_util.erl +++ b/applications/webhooks/src/webhooks_util.erl @@ -92,7 +92,7 @@ to_json(#webhook{}=Hook) -> ,{<<"modifiers">>, Hook#webhook.modifiers} ]). --spec find_webhooks(ne_binary(), api_binary()) -> webhooks(). +-spec find_webhooks(kz_term:ne_binary(), kz_term:api_binary()) -> webhooks(). find_webhooks(_HookEvent, 'undefined') -> []; find_webhooks(HookEvent, AccountId) -> case kz_account:fetch(AccountId, 'accounts') of @@ -157,7 +157,7 @@ maybe_fire_hook(JObj, #webhook{modifiers=Modifiers}=Hook) -> end. -type maybe_fire_acc() :: {boolean(), kz_json:object()}. --spec maybe_fire_foldl(ne_binary(), any(), maybe_fire_acc()) -> maybe_fire_acc(). +-spec maybe_fire_foldl(kz_term:ne_binary(), any(), maybe_fire_acc()) -> maybe_fire_acc(). maybe_fire_foldl(_Key, _Value, {'false', _}=Acc) -> Acc; @@ -185,7 +185,7 @@ fire_hook(JObj, #webhook{custom_data = CustomData EventId = kz_binary:rand_hex(5), do_fire(Hook, EventId, kz_json:merge_jobjs(CustomData, JObj)). --spec do_fire(webhook(), ne_binary(), kz_json:object()) -> 'ok'. +-spec do_fire(webhook(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. do_fire(#webhook{uri = ?NE_BINARY = URI ,http_verb = 'get' ,retries = Retries @@ -218,7 +218,7 @@ do_fire(#webhook{uri = ?NE_BINARY = URI handle_resp(Hook, EventId, JObj, Debug, Fired). --spec handle_resp(webhook(), ne_binary(), kz_json:object(), kz_proplist(), kz_http:ret()) -> 'ok'. +-spec handle_resp(webhook(), kz_term:ne_binary(), kz_json:object(), kz_term:proplist(), kz_http:ret()) -> 'ok'. handle_resp(#webhook{hook_event = _HookEvent ,hook_id = _HookId } = Hook, _EventId, _JObj, Debug, {'ok', 200, _, _} = Resp) -> @@ -238,7 +238,7 @@ handle_resp(#webhook{hook_event = _HookEvent _ = failed_hook(Hook, Debug, Resp), retry_hook(Hook, EventId, JObj). --spec retry_hook(webhook(), ne_binary(), kz_json:object()) -> 'ok'. +-spec retry_hook(webhook(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. retry_hook(#webhook{uri = _URI ,retries = 1 ,hook_id = _HookId @@ -249,8 +249,8 @@ retry_hook(#webhook{retries = Retries} = Hook, EventId, JObj) -> timer:sleep(2000), do_fire(Hook#webhook{retries = Retries - 1}, EventId, JObj). --spec successful_hook(webhook(), kz_proplist(), kz_http:ret()) -> 'ok'. --spec successful_hook(webhook(), kz_proplist(), kz_http:ret(), boolean()) -> 'ok'. +-spec successful_hook(webhook(), kz_term:proplist(), kz_http:ret()) -> 'ok'. +-spec successful_hook(webhook(), kz_term:proplist(), kz_http:ret(), boolean()) -> 'ok'. successful_hook(Hook, Debug, Resp) -> successful_hook(Hook, Debug, Resp, ?SHOULD_LOG_SUCCESS). @@ -259,7 +259,7 @@ successful_hook(#webhook{account_id = AccountId}, Debug, Resp, 'true') -> DebugJObj = debug_resp(Resp, Debug, 'undefined'), save_attempt(AccountId, DebugJObj). --spec failed_hook(webhook(), kz_proplist(), kz_http:ret()) -> 'ok'. +-spec failed_hook(webhook(), kz_term:proplist(), kz_http:ret()) -> 'ok'. failed_hook(#webhook{hook_id = HookId ,account_id = AccountId ,retries = Retries @@ -272,7 +272,7 @@ failed_hook(#webhook{hook_id = HookId %%% Internal functions %%%=================================================================== --spec save_attempt(api_binary(), kz_json:object()) -> 'ok'. +-spec save_attempt(kz_term:api_binary(), kz_json:object()) -> 'ok'. save_attempt(AccountId, Attempt) -> Now = kz_time:now_s(), ModDb = kz_util:format_account_mod_id(AccountId, Now), @@ -288,8 +288,8 @@ save_attempt(AccountId, Attempt) -> _ = kazoo_modb:save_doc(ModDb, Doc, [{'publish_change_notice', 'false'}]), 'ok'. --spec debug_req(webhook(), ne_binary(), ne_binary(), kz_proplist(), iodata()) -> - kz_proplist(). +-spec debug_req(webhook(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist(), iodata()) -> + kz_term:proplist(). debug_req(#webhook{hook_id=HookId ,hook_event = HookEvent ,http_verb = Method @@ -309,7 +309,7 @@ debug_req(#webhook{hook_id=HookId ,{<<"req_body">>, ReqBody} ]. --spec debug_resp(kz_http:ret(), kz_proplist(), hook_retries() | 'undefined') -> +-spec debug_resp(kz_http:ret(), kz_term:proplist(), hook_retries() | 'undefined') -> kz_json:object(). debug_resp({'ok', RespCode, RespHeaders, RespBody}, Debug, Retries) -> Headers = kz_json:from_list( @@ -358,11 +358,11 @@ debug_resp({'error', E}, Debug, Retries) -> | Debug ]). --spec fix_value(number() | list()) -> number() | ne_binary(). +-spec fix_value(number() | list()) -> number() | kz_term:ne_binary(). fix_value(N) when is_number(N) -> N; fix_value(O) -> kz_term:to_lower_binary(O). --spec fix_error_value(atom() | {atom(), atom()}) -> ne_binary(). +-spec fix_error_value(atom() | {atom(), atom()}) -> kz_term:ne_binary(). fix_error_value({E, R}) -> <<(kz_term:to_binary(E))/binary ,": " @@ -371,8 +371,8 @@ fix_error_value({E, R}) -> fix_error_value(E) -> kz_term:to_binary(E). --spec hook_id(kz_json:object()) -> ne_binary(). --spec hook_id(ne_binary(), ne_binary()) -> ne_binary(). +-spec hook_id(kz_json:object()) -> kz_term:ne_binary(). +-spec hook_id(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). hook_id(JObj) -> hook_id(kz_json:get_first_defined([<<"pvt_account_id">> ,<<"Account-ID">> @@ -385,10 +385,10 @@ hook_id(JObj) -> hook_id(AccountId, Id) -> <>. --spec hook_event(ne_binary()) -> ne_binary(). +-spec hook_event(kz_term:ne_binary()) -> kz_term:ne_binary(). hook_event(Bin) -> hook_event_lowered(kz_term:to_lower_binary(Bin)). --spec hook_event_lowered(ne_binary()) -> ne_binary(). +-spec hook_event_lowered(kz_term:ne_binary()) -> kz_term:ne_binary(). hook_event_lowered(<<"channel_create">>) -> <<"CHANNEL_CREATE">>; hook_event_lowered(<<"channel_answer">>) -> <<"CHANNEL_ANSWER">>; hook_event_lowered(<<"channel_destroy">>) -> <<"CHANNEL_DESTROY">>; @@ -451,7 +451,7 @@ update_hook_docs([JObj|JObjs], Acc) -> Hook = kz_json:get_value(<<"doc">>, JObj), update_hook_docs(JObjs, update_hook_doc(Hook, kzd_webhook:event(Hook), Acc)). --spec update_hook_doc(kz_json:object(), ne_binary(), map()) -> map(). +-spec update_hook_doc(kz_json:object(), kz_term:ne_binary(), map()) -> map(). update_hook_doc(WebHook, <<"callflow">>, #{update := Update}=Acc) -> Acc#{update => [set_as_notifications_webhook(WebHook, <<"callflow">>, kz_doc:id(WebHook), 'undefined', kz_doc:revision(WebHook)) | Update @@ -476,7 +476,7 @@ update_hook_doc(WebHook, <<"outbound_fax">>, #{update := Update, extra := Extra} ] }. --spec set_as_notifications_webhook(kz_json:object(), ne_binary(), ne_binary(), api_ne_binary(), api_ne_binary()) -> kz_json:object(). +-spec set_as_notifications_webhook(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> kz_json:object(). set_as_notifications_webhook(WebHook, Type, Id, OtherId, Rev) -> kz_json:set_values([{<<"_id">>, Id} ,{<<"_rev">>, Rev} @@ -577,7 +577,7 @@ jobj_to_rec(Hook) -> -spec init_webhooks() -> 'ok'. -spec init_webhooks(kz_json:objects()) -> 'ok'. --spec init_webhooks(kz_json:objects(), kz_year(), kz_month()) -> 'ok'. +-spec init_webhooks(kz_json:objects(), kz_time:year(), kz_time:month()) -> 'ok'. init_webhooks() -> case kz_datamgr:get_results(?KZ_WEBHOOKS_DB ,<<"webhooks/accounts_listing">> @@ -597,13 +597,13 @@ init_webhooks(WebHooks, Year, Month) -> _ = [init_webhook(WebHook, Year, Month) || WebHook <- WebHooks], 'ok'. --spec init_webhook(kz_json:object(), kz_year(), kz_month()) -> 'ok'. +-spec init_webhook(kz_json:object(), kz_time:year(), kz_time:month()) -> 'ok'. init_webhook(WebHook, Year, Month) -> Db = kz_util:format_account_id(kz_json:get_value(<<"key">>, WebHook), Year, Month), kazoo_modb:maybe_create(Db), lager:debug("updated account_modb ~s", [Db]). --spec note_failed_attempt(ne_binary(), ne_binary()) -> 'ok'. +-spec note_failed_attempt(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. note_failed_attempt(AccountId, HookId) -> kz_cache:store_local(?CACHE_NAME ,?FAILURE_CACHE_KEY(AccountId, HookId, kz_time:now_s()) @@ -611,7 +611,7 @@ note_failed_attempt(AccountId, HookId) -> ,[{'expires', account_expires_time(AccountId)}] ). --spec account_expires_time(ne_binary()) -> pos_integer(). +-spec account_expires_time(kz_term:ne_binary()) -> pos_integer(). account_expires_time(AccountId) -> Expiry = kapps_account_config:get_global(AccountId ,?APP_NAME @@ -628,13 +628,13 @@ account_expires_time(AccountId) -> system_expires_time() -> kapps_config:get_integer(?APP_NAME, ?ATTEMPT_EXPIRY_KEY, ?MILLISECONDS_IN_MINUTE). --spec reenable(ne_binary(), ne_binary()) -> 'ok'. +-spec reenable(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. reenable(AccountId, <<"account">>) -> enable_account_hooks(AccountId); reenable(AccountId, <<"descendants">>) -> enable_descendant_hooks(AccountId). --spec enable_account_hooks(ne_binary()) -> 'ok'. +-spec enable_account_hooks(kz_term:ne_binary()) -> 'ok'. enable_account_hooks(Account) -> AccountId = kz_util:format_account_id(Account, 'raw'), @@ -670,7 +670,7 @@ hooks_to_reenable(Hooks) -> kzd_webhook:is_auto_disabled(Hook = kz_json:get_value(<<"doc">>, View)) ]. --spec enable_descendant_hooks(ne_binary()) -> 'ok'. +-spec enable_descendant_hooks(kz_term:ne_binary()) -> 'ok'. enable_descendant_hooks(Account) -> AccountId = kz_util:format_account_id(Account, 'raw'), case kz_datamgr:get_results(?KZ_ACCOUNTS_DB @@ -691,20 +691,20 @@ enable_descendant_hooks(Account) -> io:format("failed to find descendants for account ~s: ~p~n", [AccountId, _E]) end. --spec maybe_enable_descendants_hooks(ne_binaries()) -> 'ok'. +-spec maybe_enable_descendants_hooks(kz_term:ne_binaries()) -> 'ok'. maybe_enable_descendants_hooks(Accounts) -> lists:foreach(fun maybe_enable_descendant_hooks/1, Accounts). --spec maybe_enable_descendant_hooks(ne_binary()) -> 'ok'. +-spec maybe_enable_descendant_hooks(kz_term:ne_binary()) -> 'ok'. maybe_enable_descendant_hooks(Account) -> io:format("## checking account ~s for hooks to enable ##~n", [Account]), enable_account_hooks(Account). --spec init_metadata(ne_binary(), kz_json:object()) -> 'ok'. +-spec init_metadata(kz_term:ne_binary(), kz_json:object()) -> 'ok'. init_metadata(Id, JObj) -> init_metadata(Id, JObj, kapps_util:get_master_account_db()). --spec init_metadata(ne_binary(), kz_json:object(), {'ok', ne_binary()} | {'error', any()}) -> 'ok'. +-spec init_metadata(kz_term:ne_binary(), kz_json:object(), {'ok', kz_term:ne_binary()} | {'error', any()}) -> 'ok'. init_metadata(_, _, {'error', _}) -> lager:warning("master account not available"), 'ok'; @@ -721,7 +721,7 @@ init_metadata(Id, JObj, {'ok', MasterAccountDb}) -> end end. --spec save_metadata(ne_binary(), kz_json:object()) -> 'ok'. +-spec save_metadata(kz_term:ne_binary(), kz_json:object()) -> 'ok'. save_metadata(MasterAccountDb, JObj) -> Metadata = kz_doc:update_pvt_parameters(JObj, MasterAccountDb, [{'type', <<"webhook_meta">>}]), case kz_datamgr:save_doc(MasterAccountDb, Metadata) of @@ -733,7 +733,7 @@ save_metadata(MasterAccountDb, JObj) -> lager:warning("failed to load metadata for ~s: ~p", [kz_doc:id(JObj), _E]) end. --spec available_events() -> ne_binaries(). +-spec available_events() -> kz_term:ne_binaries(). available_events() -> case kz_cache:fetch_local(?CACHE_NAME, ?AVAILABLE_EVENT_KEY) of {'error', 'not_found'} -> @@ -742,7 +742,7 @@ available_events() -> Events end. --spec fetch_available_events() -> ne_binaries(). +-spec fetch_available_events() -> kz_term:ne_binaries(). fetch_available_events() -> {'ok', MasterAccountDb} = kapps_util:get_master_account_db(), case kz_datamgr:get_results(MasterAccountDb, ?WEBHOOK_META_LIST) of diff --git a/core/amqp_cron/src/amqp_cron.erl b/core/amqp_cron/src/amqp_cron.erl index 63b5e70c3b5..903171fde1f 100644 --- a/core/amqp_cron/src/amqp_cron.erl +++ b/core/amqp_cron/src/amqp_cron.erl @@ -100,7 +100,7 @@ %% %% @end %%-------------------------------------------------------------------- --spec start_link([node()]) -> startlink_ret(). +-spec start_link([node()]) -> kz_types:startlink_ret(). start_link(Nodes) -> Opts = [], amqp_leader:start_link(?SERVER, Nodes, Opts, ?MODULE, [], []). @@ -223,7 +223,7 @@ surrendered(State, Sync, _Election) -> State3 = State2#state{is_leader = 'false'}, {'ok', State3}. --spec handle_leader_call(any(), pid_ref(), state(), any()) -> handle_call_ret_state(state()). +-spec handle_leader_call(any(), kz_term:pid_ref(), state(), any()) -> kz_types:handle_call_ret_state(state()). handle_leader_call({'cancel', Name}, From, State, Election) when is_binary(Name); is_atom(Name) -> case pid_for_name(Name, State#state.tasks) of @@ -283,7 +283,7 @@ handle_leader_call('remove_done_tasks', _From, State, Election) -> 'ok' = send_tasks(Tasks1, Election), {'reply', 'ok', State1}. --spec handle_leader_cast(any(), state(), any()) -> handle_cast_ret_state(state()). +-spec handle_leader_cast(any(), state(), any()) -> kz_types:handle_cast_ret_state(state()). handle_leader_cast(_Request, State, _Election) -> {'noreply', State}. @@ -296,7 +296,7 @@ from_leader({'tasks', Tasks}, State, _Election) -> handle_DOWN(_Node, State, _Election) -> {'ok', State}. --spec handle_call(any(), pid_ref(), state(), any()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state(), any()) -> kz_types:handle_call_ret_state(state()). handle_call('status', _From, State, Election) -> Reply = [{'leader', amqp_leader_proc:leader_node(Election)} ,{'alive', amqp_leader_proc:alive(Election)} @@ -309,11 +309,11 @@ handle_call('status', _From, State, Election) -> handle_call(_Request, _From, State, _Election) -> {'reply', 'ok', State}. --spec handle_cast(any(), state(), any()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state(), any()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State, _Election) -> {'noreply', State}. --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. diff --git a/core/amqp_cron/src/amqp_cron_app.erl b/core/amqp_cron/src/amqp_cron_app.erl index 4a4a191aee6..06f030959af 100644 --- a/core/amqp_cron/src/amqp_cron_app.erl +++ b/core/amqp_cron/src/amqp_cron_app.erl @@ -42,7 +42,7 @@ %%% Application callbacks %%%=================================================================== --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_StartType, _StartArgs) -> amqp_cron_sup:start_link([node()|nodes()]). diff --git a/core/amqp_cron/src/amqp_cron_sup.erl b/core/amqp_cron/src/amqp_cron_sup.erl index b8deca1d41a..f1585527cf7 100644 --- a/core/amqp_cron/src/amqp_cron_sup.erl +++ b/core/amqp_cron/src/amqp_cron_sup.erl @@ -51,7 +51,7 @@ %% @end %%-------------------------------------------------------------------- --spec start_link([node()]) -> startlink_ret(). +-spec start_link([node()]) -> kz_types:startlink_ret(). start_link(Nodes) -> supervisor:start_link({'local', ?SERVER}, ?MODULE, [Nodes]). @@ -67,7 +67,7 @@ start_link(Nodes) -> %% @end %%-------------------------------------------------------------------- --spec init([node()]) -> sup_init_ret(). +-spec init([node()]) -> kz_types:sup_init_ret(). init([]) -> {error, no_node_list}; diff --git a/core/amqp_cron/src/amqp_cron_task.erl b/core/amqp_cron/src/amqp_cron_task.erl index 5e5c651a260..916ba3382f0 100644 --- a/core/amqp_cron/src/amqp_cron_task.erl +++ b/core/amqp_cron/src/amqp_cron_task.erl @@ -89,7 +89,7 @@ -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). --export_type([sleeper/0, cron/0, execargs/0, datetime/0, status/0, schedule/0]). +-export_type([sleeper/0, cron/0, execargs/0, status/0, schedule/0]). -include_lib("kazoo_stdlib/include/kz_types.hrl"). @@ -110,7 +110,7 @@ -type schedule() :: oneshot() | sleeper() | cron(). %% A cron schedule. --type oneshot() :: {'oneshot', Millis::pos_integer() | datetime()}. +-type oneshot() :: {'oneshot', Millis::pos_integer() | kz_time:datetime()}. %% Schedule a task once after a delay or on a particular date. -type sleeper() :: {'sleeper', Millis::pos_integer()}. @@ -148,7 +148,6 @@ -type funcargs() :: {Function :: fun(), Args :: [term()]}. %% Anonymous function execution definition. --type datetime() :: calendar:datetime(). %% Date and time. %%%=================================================================== @@ -163,7 +162,7 @@ %% %% @end %%-------------------------------------------------------------------- --spec start_link(Schedule, Exec) -> startlink_ret() when +-spec start_link(Schedule, Exec) -> kz_types:startlink_ret() when Schedule :: schedule(), Exec :: execargs(). @@ -181,7 +180,7 @@ start_link(Schedule, Exec) -> %%-------------------------------------------------------------------- -spec status(pid()) -> {Status, ScheduleTime, TaskPid} when Status :: status(), - ScheduleTime :: datetime() | pos_integer() | {'error', Reason}, + ScheduleTime :: kz_time:datetime() | pos_integer() | {'error', Reason}, Reason :: any(), TaskPid :: pid(). @@ -232,7 +231,7 @@ init([{Schedule, Exec}]) -> %% %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call('status', _From, State) -> Status = State#state.status, Next = State#state.next, @@ -246,7 +245,7 @@ handle_call('status', _From, State) -> %% %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'error', Message}, State) -> {'noreply', State#state{status = 'error', next = Message}}; handle_cast({'done', Schedule}, State) -> @@ -265,7 +264,7 @@ handle_cast('stop', State) -> %% %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -355,21 +354,21 @@ apply_task(Exec) -> error_logger:error_report(Message) end. --spec time_to_wait_millis(datetime(), datetime()) -> integer(). +-spec time_to_wait_millis(kz_time:datetime(), kz_time:datetime()) -> integer(). time_to_wait_millis(CurrentDateTime, NextDateTime) -> CurrentSeconds = calendar:datetime_to_gregorian_seconds(CurrentDateTime), NextSeconds = calendar:datetime_to_gregorian_seconds(NextDateTime), SecondsToSleep = NextSeconds - CurrentSeconds, SecondsToSleep * 1000. --spec next_valid_datetime(cron(), datetime()) -> datetime(). +-spec next_valid_datetime(cron(), kz_time:datetime()) -> kz_time:datetime(). next_valid_datetime({'cron', _Schedule} = Cron, DateTime) -> DateTime1 = advance_seconds(DateTime, ?MINUTE_IN_SECONDS), {{Y, Mo, D}, {H, M, _}} = DateTime1, DateTime2 = {{Y, Mo, D}, {H, M, 0}}, next_valid_datetime('not_done', Cron, DateTime2). --spec next_valid_datetime('done' | 'not_done', cron(), datetime()) -> datetime(). +-spec next_valid_datetime('done' | 'not_done', cron(), kz_time:datetime()) -> kz_time:datetime(). next_valid_datetime('done', _, DateTime) -> DateTime; next_valid_datetime('not_done', {'cron', Schedule} = Cron, DateTime) -> @@ -435,7 +434,7 @@ value_valid(Spec, Min, Max, Value) when Value >= Min, Value =< Max-> end, ValidValues) end. --spec advance_seconds(datetime(), integer()) -> datetime(). +-spec advance_seconds(kz_time:datetime(), integer()) -> kz_time:datetime(). advance_seconds(DateTime, Seconds) -> Seconds1 = calendar:datetime_to_gregorian_seconds(DateTime) + Seconds, calendar:gregorian_seconds_to_datetime(Seconds1). diff --git a/core/amqp_leader/src/amqp_leader.erl b/core/amqp_leader/src/amqp_leader.erl index 7f744bcbc46..5f1971ad40d 100644 --- a/core/amqp_leader/src/amqp_leader.erl +++ b/core/amqp_leader/src/amqp_leader.erl @@ -12,6 +12,6 @@ -export([start_link/6]). --spec start_link(atom(), atoms(), list(), atom(), list(), list()) -> startlink_ret(). +-spec start_link(atom(), kz_term:atoms(), list(), atom(), list(), list()) -> kz_types:startlink_ret(). start_link(Name, Nodes, Opts, Module, [], []) -> amqp_leader_sup:start_leader(Name, Nodes, Opts, Module, [], []). diff --git a/core/amqp_leader/src/amqp_leader_app.erl b/core/amqp_leader/src/amqp_leader_app.erl index e5ff5f41dc3..5bcf931ce25 100644 --- a/core/amqp_leader/src/amqp_leader_app.erl +++ b/core/amqp_leader/src/amqp_leader_app.erl @@ -17,7 +17,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = declare_exchanges(), amqp_leader_sup:start_link(). diff --git a/core/amqp_leader/src/amqp_leader_listener.erl b/core/amqp_leader/src/amqp_leader_listener.erl index 51ee57c51ef..66605d1f037 100644 --- a/core/amqp_leader/src/amqp_leader_listener.erl +++ b/core/amqp_leader/src/amqp_leader_listener.erl @@ -55,7 +55,7 @@ is_ready() -> %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(atom() | pid()) -> startlink_ret(). +-spec start_link(atom() | pid()) -> kz_types:startlink_ret(). start_link(Name) -> gen_listener:start_link(?SERVER, [{'bindings', ?BINDINGS(Name)} ,{'responders', ?RESPONDERS} @@ -100,7 +100,7 @@ init([Name]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), {pid(), any()}, state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), {pid(), any()}, state()) -> kz_types:handle_call_ret_state(state()). handle_call('is_ready', From, #state{pending = Pids} = State) -> NewState = maybe_ready(State#state{pending = [From | Pids]}), {'noreply', NewState}; @@ -118,7 +118,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'is_ready', Pid, Ref}, #state{pending = Pending} = State) -> NewState = maybe_ready(State#state{pending = [{Pid, Ref} | Pending]}), {'noreply', NewState}; @@ -147,7 +147,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> lager:warning("~s unhandled info ~p", [node(), _Info]), {'noreply', State}. diff --git a/core/amqp_leader/src/amqp_leader_proc.erl b/core/amqp_leader/src/amqp_leader_proc.erl index c0e3392092d..3d07691cd3f 100644 --- a/core/amqp_leader/src/amqp_leader_proc.erl +++ b/core/amqp_leader/src/amqp_leader_proc.erl @@ -38,8 +38,8 @@ ,restarted = 0 :: integer() ,callback_module :: atom() ,callback_state :: any() - ,down = [] :: atoms() - ,candidates = [node()] :: atoms() + ,down = [] :: kz_term:atoms() + ,candidates = [node()] :: kz_term:atoms() }). -record(sign, {elected :: integer() @@ -65,7 +65,7 @@ | {state(), atom()} | {atom(), sign()} | sign() - | ne_binary(). + | kz_term:ne_binary(). -type from() :: any(). -include("amqp_leader.hrl"). @@ -81,15 +81,15 @@ %%%=================================================================== %%% API functions %%%=================================================================== --spec start(atom(), atoms(), list(), atom(), list(), list()) -> startlink_ret(). +-spec start(atom(), kz_term:atoms(), list(), atom(), list(), list()) -> kz_types:startlink_ret(). start(Name, CandidateNodes, OptArgs, Mod, Arg, Options) -> start_it('start', Name, CandidateNodes, OptArgs, Mod, Arg, Options). --spec start_link(atom(), atoms(), list(), atom(), list(), list()) -> startlink_ret(). +-spec start_link(atom(), kz_term:atoms(), list(), atom(), list(), list()) -> kz_types:startlink_ret(). start_link(Name, CandidateNodes, OptArgs, Mod, Arg, Options) -> start_it('start_link', Name, CandidateNodes, OptArgs, Mod, Arg, Options). --spec start_it(atom(), atom(), atoms(), list(), atom(), list(), list()) -> startlink_ret(). +-spec start_it(atom(), atom(), kz_term:atoms(), list(), atom(), list(), list()) -> kz_types:startlink_ret(). start_it(StartFun, Name, CandidateNodes, OptArgs, Mod, Arg, Options) -> gen_server:StartFun({'local', Name}, ?MODULE, [Name, CandidateNodes, OptArgs, Mod, Arg, Options], []). @@ -124,23 +124,23 @@ reply({Pid, _} = From, Reply) when is_pid(Pid) reply({From, Tag}, Reply) -> send(From, {Tag, Reply}). --spec alive(sign()) -> atoms(). +-spec alive(sign()) -> kz_term:atoms(). alive(_) -> [node()]. %alive(#sign{candidates = Candidates}) -> % Candidates. --spec down(sign()) -> atoms(). +-spec down(sign()) -> kz_term:atoms(). down(_) -> []. --spec workers(sign()) -> atoms(). +-spec workers(sign()) -> kz_term:atoms(). workers(_) -> []. --spec candidates(sign()) -> atoms(). +-spec candidates(sign()) -> kz_term:atoms(). candidates(_) -> [node()]. -type msg() :: {'from_leader', any()}. --spec broadcast(msg(), atoms(), sign()) -> sign(). +-spec broadcast(msg(), kz_term:atoms(), sign()) -> sign(). broadcast(Msg, _Nodes, #sign{name = Name} = Sign) -> send({Name, 'broadcast'}, Msg), Sign. @@ -190,7 +190,7 @@ init([Name, _CandidateNodes, _OptArgs, Mod, Arg, _Options]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), {pid(), any()}, state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), {pid(), any()}, state()) -> kz_types:handle_call_ret_state(state()). handle_call(s, _, State) -> {reply, {self(), State}, State}; handle_call({'leader_call', Msg}, From, State) when ?is_leader -> @@ -215,7 +215,7 @@ handle_call(Call, From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'init', Arg}, State) -> init(State, Arg); handle_cast({'leader_cast', Msg}, State) when ?is_leader -> @@ -240,7 +240,7 @@ handle_cast(Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(#?MODULE{from = From, msg = 'join'} = Msg, State) when ?is_leader -> lager:debug("message ~p", [Msg]), Routines = [{fun announce_leader/2, {From, 'me'}} @@ -554,7 +554,7 @@ noreply(#state{} = State, [{Fun, Data} | Rest]) when is_function(Fun, 2) -> increase_elected(#state{elected = Elected} = State, []) -> State#state{elected = Elected + 1}. --spec add_candidates(state(), sign() | atoms()) -> state(). +-spec add_candidates(state(), sign() | kz_term:atoms()) -> state(). add_candidates(#state{} = State, #sign{node = Node}) -> add_candidates(State, [Node]); add_candidates(#state{candidates = MyCandidates} = State, Candidates) -> diff --git a/core/amqp_leader/src/amqp_leader_proc_sup.erl b/core/amqp_leader/src/amqp_leader_proc_sup.erl index ba11b74aa34..a396952105f 100644 --- a/core/amqp_leader/src/amqp_leader_proc_sup.erl +++ b/core/amqp_leader/src/amqp_leader_proc_sup.erl @@ -30,7 +30,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link(atom(), atoms(), list(), atom(), [], []) -> startlink_ret(). +-spec start_link(atom(), kz_term:atoms(), list(), atom(), [], []) -> kz_types:startlink_ret(). start_link(Name, Nodes, Opts, Module, [], []) -> supervisor:start_link(?SERVER, {Name, Nodes, Opts, Module, [], []}). @@ -47,7 +47,7 @@ start_link(Name, Nodes, Opts, Module, [], []) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init({atom(), atoms(), list(), atom(), [], []}) -> sup_init_ret(). +-spec init({atom(), kz_term:atoms(), list(), atom(), [], []}) -> kz_types:sup_init_ret(). init({Name, Nodes, Opts, Module, [], []}) -> RestartStrategy = 'rest_for_one', MaxRestarts = 5, diff --git a/core/amqp_leader/src/amqp_leader_sup.erl b/core/amqp_leader/src/amqp_leader_sup.erl index aaca119c55e..c2ebbd3df38 100644 --- a/core/amqp_leader/src/amqp_leader_sup.erl +++ b/core/amqp_leader/src/amqp_leader_sup.erl @@ -28,11 +28,11 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec start_leader(atom(), atoms(), list(), atom(), list(), list()) -> startlink_ret(). +-spec start_leader(atom(), kz_term:atoms(), list(), atom(), list(), list()) -> kz_types:startlink_ret(). start_leader(Name, Nodes, Opts, Module, [], []) -> supervisor:start_child(?SERVER ,?SUPER_NAME_ARGS_TYPE(Name @@ -53,7 +53,7 @@ start_leader(Name, Nodes, Opts, Module, [], []) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/core/braintree/include/braintree.hrl b/core/braintree/include/braintree.hrl index 80e0a4e831a..65eefa96638 100644 --- a/core/braintree/include/braintree.hrl +++ b/core/braintree/include/braintree.hrl @@ -69,132 +69,132 @@ -define(BT_ACTIVE_STATUSES, [?BT_ACTIVE, ?BT_PENDING, ?BT_PAST_DUE]). --record(bt_address, {id :: api_binary() - ,customer_id :: api_binary() - ,first_name :: api_binary() - ,last_name :: api_binary() - ,company :: api_binary() - ,street_address :: api_binary() - ,extended_address :: api_binary() - ,locality :: api_binary() - ,region :: api_binary() - ,postal_code :: api_binary() - ,country_code_two :: api_binary() - ,country_code_three :: api_binary() - ,country_code :: api_binary() - ,country_name :: api_binary() +-record(bt_address, {id :: kz_term:api_binary() + ,customer_id :: kz_term:api_binary() + ,first_name :: kz_term:api_binary() + ,last_name :: kz_term:api_binary() + ,company :: kz_term:api_binary() + ,street_address :: kz_term:api_binary() + ,extended_address :: kz_term:api_binary() + ,locality :: kz_term:api_binary() + ,region :: kz_term:api_binary() + ,postal_code :: kz_term:api_binary() + ,country_code_two :: kz_term:api_binary() + ,country_code_three :: kz_term:api_binary() + ,country_code :: kz_term:api_binary() + ,country_name :: kz_term:api_binary() ,update_existing = 'false' :: boolean() - ,created_at :: api_binary() - ,updated_at :: api_binary() + ,created_at :: kz_term:api_binary() + ,updated_at :: kz_term:api_binary() }). -type bt_address() :: #bt_address{}. -type bt_addresses() :: [bt_address()]. --record(bt_card, {token :: api_binary() - ,bin :: api_binary() - ,cardholder_name :: api_binary() - ,card_type :: api_binary() - ,created_at :: api_binary() - ,updated_at :: api_binary() +-record(bt_card, {token :: kz_term:api_binary() + ,bin :: kz_term:api_binary() + ,cardholder_name :: kz_term:api_binary() + ,card_type :: kz_term:api_binary() + ,created_at :: kz_term:api_binary() + ,updated_at :: kz_term:api_binary() ,default = 'false' :: boolean() - ,expiration_date :: api_binary() - ,expiration_month :: api_binary() - ,expiration_year :: api_binary() + ,expiration_date :: kz_term:api_binary() + ,expiration_month :: kz_term:api_binary() + ,expiration_year :: kz_term:api_binary() ,expired = 'false' :: boolean() - ,customer_location :: api_binary() - ,last_four :: api_binary() - ,number :: api_binary() - ,cvv :: api_binary() - ,customer_id :: api_binary() + ,customer_location :: kz_term:api_binary() + ,last_four :: kz_term:api_binary() + ,number :: kz_term:api_binary() + ,cvv :: kz_term:api_binary() + ,customer_id :: kz_term:api_binary() ,make_default = 'true' :: boolean() ,verify = 'true' :: boolean() - ,payment_method_nonce :: api_binary() - ,update_existing = 'false' :: boolean() | ne_binary() - ,billing_address_id :: api_binary() + ,payment_method_nonce :: kz_term:api_binary() + ,update_existing = 'false' :: boolean() | kz_term:ne_binary() + ,billing_address_id :: kz_term:api_binary() ,billing_address :: bt_address() | 'undefined' }). -type bt_card() :: #bt_card{}. -type bt_cards() :: [bt_card()]. --record(bt_addon, {id :: api_binary() - ,amount :: api_binary() +-record(bt_addon, {id :: kz_term:api_binary() + ,amount :: kz_term:api_binary() ,never_expires = true :: boolean() - ,billing_cycle :: api_binary() - ,number_of_cycles :: api_binary() + ,billing_cycle :: kz_term:api_binary() + ,number_of_cycles :: kz_term:api_binary() ,quantity = 0 :: integer() - ,inherited_from :: api_binary() - ,existing_id :: api_binary() + ,inherited_from :: kz_term:api_binary() + ,existing_id :: kz_term:api_binary() }). -type bt_addon() :: #bt_addon{}. -type bt_addons() :: [bt_addon()]. --record(bt_discount, {id :: api_binary() - ,amount :: api_binary() +-record(bt_discount, {id :: kz_term:api_binary() + ,amount :: kz_term:api_binary() ,never_expires = true :: boolean() - ,billing_cycle :: api_binary() - ,number_of_cycles :: api_binary() + ,billing_cycle :: kz_term:api_binary() + ,number_of_cycles :: kz_term:api_binary() ,quantity = 0 :: integer() - ,inherited_from :: api_binary() - ,existing_id :: api_binary() + ,inherited_from :: kz_term:api_binary() + ,existing_id :: kz_term:api_binary() }). -type bt_discount() :: #bt_discount{}. -type bt_discounts() :: [bt_discount()]. --record(bt_descriptor, {name :: api_binary() - ,phone :: api_binary() - ,url :: api_binary() +-record(bt_descriptor, {name :: kz_term:api_binary() + ,phone :: kz_term:api_binary() + ,url :: kz_term:api_binary() }). -type bt_descriptor() :: #bt_descriptor{}. --record(bt_subscription, {id :: api_ne_binary() - ,balance :: api_binary() - ,billing_dom :: api_binary() - ,billing_first_date :: api_binary() %% Read only - ,billing_end_date :: api_binary() - ,billing_start_date :: api_binary() - ,billing_cycle :: api_binary() - ,number_of_cycles :: api_binary() - ,days_past_due :: api_binary() - ,failure_count :: api_binary() - ,merchant_account_id :: api_binary() - ,never_expires = 'true' :: api_boolean() - ,next_bill_amount :: api_binary() - ,next_cycle_amount :: api_binary() - ,next_bill_date :: api_binary() %% Read only - ,paid_through_date :: api_binary() - ,payment_token :: api_ne_binary() - ,plan_id :: api_binary() - ,price :: api_binary() - ,status :: api_binary() - ,trial_duration :: api_binary() - ,trial_duration_unit :: api_binary() - ,trial_period :: api_ne_binary() +-record(bt_subscription, {id :: kz_term:api_ne_binary() + ,balance :: kz_term:api_binary() + ,billing_dom :: kz_term:api_binary() + ,billing_first_date :: kz_term:api_binary() %% Read only + ,billing_end_date :: kz_term:api_binary() + ,billing_start_date :: kz_term:api_binary() + ,billing_cycle :: kz_term:api_binary() + ,number_of_cycles :: kz_term:api_binary() + ,days_past_due :: kz_term:api_binary() + ,failure_count :: kz_term:api_binary() + ,merchant_account_id :: kz_term:api_binary() + ,never_expires = 'true' :: kz_term:api_boolean() + ,next_bill_amount :: kz_term:api_binary() + ,next_cycle_amount :: kz_term:api_binary() + ,next_bill_date :: kz_term:api_binary() %% Read only + ,paid_through_date :: kz_term:api_binary() + ,payment_token :: kz_term:api_ne_binary() + ,plan_id :: kz_term:api_binary() + ,price :: kz_term:api_binary() + ,status :: kz_term:api_binary() + ,trial_duration :: kz_term:api_binary() + ,trial_duration_unit :: kz_term:api_binary() + ,trial_period :: kz_term:api_ne_binary() ,add_ons = [] :: bt_addons() ,discounts = [] :: bt_discounts() ,descriptor :: bt_descriptor() | 'undefined' - ,transactions :: api_binary() - ,do_not_inherit = 'true' :: api_boolean() - ,start_immediately = 'true' :: api_boolean() - ,prorate_charges = 'true' :: api_boolean() - ,revert_on_prorate_fail = 'true' :: api_boolean() - ,replace_add_ons = 'false' :: api_boolean() + ,transactions :: kz_term:api_binary() + ,do_not_inherit = 'true' :: kz_term:api_boolean() + ,start_immediately = 'true' :: kz_term:api_boolean() + ,prorate_charges = 'true' :: kz_term:api_boolean() + ,revert_on_prorate_fail = 'true' :: kz_term:api_boolean() + ,replace_add_ons = 'false' :: kz_term:api_boolean() ,create = 'false' :: boolean() }). -type bt_subscription() :: #bt_subscription{}. -type bt_subscriptions() :: [bt_subscription()]. --record(bt_customer, {id :: api_binary() - ,first_name :: api_binary() - ,last_name :: api_binary() - ,company :: api_binary() - ,email :: api_binary() - ,phone :: api_binary() - ,fax :: api_binary() - ,website :: api_binary() - ,created_at :: api_binary() - ,updated_at :: api_binary() - ,payment_method_nonce :: api_binary() +-record(bt_customer, {id :: kz_term:api_binary() + ,first_name :: kz_term:api_binary() + ,last_name :: kz_term:api_binary() + ,company :: kz_term:api_binary() + ,email :: kz_term:api_binary() + ,phone :: kz_term:api_binary() + ,fax :: kz_term:api_binary() + ,website :: kz_term:api_binary() + ,created_at :: kz_term:api_binary() + ,updated_at :: kz_term:api_binary() + ,payment_method_nonce :: kz_term:api_binary() ,credit_cards = [] :: bt_cards() ,addresses = [] :: bt_addresses() ,subscriptions = [] :: bt_subscriptions() @@ -202,37 +202,37 @@ -type bt_customer() :: #bt_customer{}. -type bt_customers() :: [bt_customer()]. --record(bt_transaction, {id :: api_ne_binary() - ,status :: api_ne_binary() - ,type :: api_ne_binary() - ,currency_code :: api_ne_binary() - ,amount :: api_ne_binary() - ,merchant_account_id :: api_ne_binary() - ,order_id :: api_ne_binary() - ,purchase_order :: api_ne_binary() - ,created_at :: api_ne_binary() - ,update_at :: api_ne_binary() - ,refund_ids :: api_ne_binary() - ,refunded_transaction :: api_ne_binary() - ,settlement_batch :: api_ne_binary() - ,avs_error_code :: api_ne_binary() - ,avs_postal_response :: api_ne_binary() - ,avs_street_response :: api_ne_binary() - ,ccv_response_code :: api_ne_binary() - ,gateway_rejection :: api_ne_binary() - ,processor_authorization_code :: api_ne_binary() - ,processor_response_code :: api_ne_binary() - ,processor_response_text :: api_ne_binary() - ,tax_amount :: api_binary() +-record(bt_transaction, {id :: kz_term:api_ne_binary() + ,status :: kz_term:api_ne_binary() + ,type :: kz_term:api_ne_binary() + ,currency_code :: kz_term:api_ne_binary() + ,amount :: kz_term:api_ne_binary() + ,merchant_account_id :: kz_term:api_ne_binary() + ,order_id :: kz_term:api_ne_binary() + ,purchase_order :: kz_term:api_ne_binary() + ,created_at :: kz_term:api_ne_binary() + ,update_at :: kz_term:api_ne_binary() + ,refund_ids :: kz_term:api_ne_binary() + ,refunded_transaction :: kz_term:api_ne_binary() + ,settlement_batch :: kz_term:api_ne_binary() + ,avs_error_code :: kz_term:api_ne_binary() + ,avs_postal_response :: kz_term:api_ne_binary() + ,avs_street_response :: kz_term:api_ne_binary() + ,ccv_response_code :: kz_term:api_ne_binary() + ,gateway_rejection :: kz_term:api_ne_binary() + ,processor_authorization_code :: kz_term:api_ne_binary() + ,processor_response_code :: kz_term:api_ne_binary() + ,processor_response_text :: kz_term:api_ne_binary() + ,tax_amount :: kz_term:api_binary() ,tax_exempt = 'false' :: boolean() ,billing_address :: bt_address() | 'undefined' - ,shipping_address_id :: api_binary() + ,shipping_address_id :: kz_term:api_binary() ,shipping_address :: bt_address() | 'undefined' - ,customer_id :: api_binary() + ,customer_id :: kz_term:api_binary() ,customer :: bt_customer() | 'undefined' - ,payment_token :: api_binary() + ,payment_token :: kz_term:api_binary() ,card :: bt_card() | 'undefined' - ,subscription_id :: api_binary() + ,subscription_id :: kz_term:api_binary() ,add_ons = [] :: bt_addons() | 'undefined' ,discounts = [] :: bt_discounts() | 'undefined' ,descriptor :: bt_descriptor() | 'undefined' @@ -249,27 +249,27 @@ -type bt_transactions() :: [bt_transaction()]. -type api_bt_transaction() :: undefined | bt_transaction(). --record(bt_error, {code :: api_binary() - ,message :: api_binary() - ,attribute :: api_binary() +-record(bt_error, {code :: kz_term:api_binary() + ,message :: kz_term:api_binary() + ,attribute :: kz_term:api_binary() }). -type bt_error() :: #bt_error{}. -type bt_errors() :: [#bt_error{}]. --record(bt_verification, {verification_status :: api_binary() - ,processor_response_code :: api_binary() - ,processor_response_text :: api_binary() - ,cvv_response_code :: api_binary() - ,avs_response_code :: api_binary() - ,postal_response_code :: api_binary() - ,street_response_code :: api_binary() - ,gateway_rejection_reason :: api_binary() +-record(bt_verification, {verification_status :: kz_term:api_binary() + ,processor_response_code :: kz_term:api_binary() + ,processor_response_text :: kz_term:api_binary() + ,cvv_response_code :: kz_term:api_binary() + ,avs_response_code :: kz_term:api_binary() + ,postal_response_code :: kz_term:api_binary() + ,street_response_code :: kz_term:api_binary() + ,gateway_rejection_reason :: kz_term:api_binary() }). -type bt_verification() :: #bt_verification{}. -record(bt_api_error, {errors = [] :: bt_errors() ,verification :: bt_verification() - ,message:: api_binary() + ,message:: kz_term:api_binary() }). -type bt_api_error() :: #bt_api_error{}. diff --git a/core/braintree/src/braintree_addon.erl b/core/braintree/src/braintree_addon.erl index 24ebb9d3726..f8d06c8e21c 100644 --- a/core/braintree/src/braintree_addon.erl +++ b/core/braintree/src/braintree_addon.erl @@ -33,7 +33,7 @@ get_quantity(#bt_addon{quantity=Quantity}) -> %% @end %%-------------------------------------------------------------------- -spec xml_to_record(bt_xml()) -> bt_addon(). --spec xml_to_record(bt_xml(), kz_deeplist()) -> bt_addon(). +-spec xml_to_record(bt_xml(), kz_term:deeplist()) -> bt_addon(). xml_to_record(Xml) -> xml_to_record(Xml, "/add-on"). @@ -53,8 +53,8 @@ xml_to_record(Xml, Base) -> %% Contert the given XML to a customer record %% @end %%-------------------------------------------------------------------- --spec record_to_xml(bt_addon()) -> kz_proplist() | bt_xml(). --spec record_to_xml(bt_addon(), boolean()) -> kz_proplist() | bt_xml(). +-spec record_to_xml(bt_addon()) -> kz_term:proplist() | bt_xml(). +-spec record_to_xml(bt_addon(), boolean()) -> kz_term:proplist() | bt_xml(). record_to_xml(Addon) -> record_to_xml(Addon, false). @@ -93,7 +93,7 @@ record_to_json(#bt_addon{id=Id, amount=Amount, quantity=Q}) -> %% Convert a given json obj into a record %% @end %%-------------------------------------------------------------------- --spec json_to_record(api_object()) -> bt_addon() | 'undefined'. +-spec json_to_record(kz_term:api_object()) -> bt_addon() | 'undefined'. json_to_record('undefined') -> 'undefined'; json_to_record(JObj) -> #bt_addon{id = kz_doc:id(JObj) diff --git a/core/braintree/src/braintree_address.erl b/core/braintree/src/braintree_address.erl index f4829a38894..7eb18bfe57d 100644 --- a/core/braintree/src/braintree_address.erl +++ b/core/braintree/src/braintree_address.erl @@ -26,8 +26,8 @@ %% Create the partial url for this module %% @end %%-------------------------------------------------------------------- --spec url(ne_binary()) -> string(). --spec url(ne_binary(), ne_binary()) -> string(). +-spec url(kz_term:ne_binary()) -> string(). +-spec url(kz_term:ne_binary(), kz_term:ne_binary()) -> string(). url(CustomerId) -> lists:append(["/customers/", kz_term:to_list(CustomerId), "/addresses"]). @@ -41,7 +41,7 @@ url(CustomerId, AddressId) -> %% Find a customer by id %% @end %%-------------------------------------------------------------------- --spec find(ne_binary() | nonempty_string(), ne_binary() | nonempty_string()) -> bt_address(). +-spec find(kz_term:ne_binary() | nonempty_string(), kz_term:ne_binary() | nonempty_string()) -> bt_address(). find(CustomerId, AddressId) -> Url = url(CustomerId, AddressId), Xml = braintree_request:get(Url), @@ -54,7 +54,7 @@ find(CustomerId, AddressId) -> %% @end %%-------------------------------------------------------------------- -spec create(bt_address()) -> bt_address(). --spec create(nonempty_string() | ne_binary(), bt_address()) -> bt_address(). +-spec create(nonempty_string() | kz_term:ne_binary(), bt_address()) -> bt_address(). create(#bt_address{customer_id=CustomerId}=Address) -> Url = url(CustomerId), @@ -87,7 +87,7 @@ update(#bt_address{id=AddressId %% @end %%-------------------------------------------------------------------- -spec delete(bt_address()) -> bt_address(). --spec delete(ne_binary() | nonempty_string(), ne_binary() | nonempty_string()) -> bt_address(). +-spec delete(kz_term:ne_binary() | nonempty_string(), kz_term:ne_binary() | nonempty_string()) -> bt_address(). delete(#bt_address{customer_id=CustomerId ,id=AddressId @@ -106,7 +106,7 @@ delete(CustomerId, AddressId) -> %% @end %%-------------------------------------------------------------------- -spec xml_to_record(bt_xml()) -> bt_address(). --spec xml_to_record(bt_xml(), kz_deeplist()) -> bt_address(). +-spec xml_to_record(bt_xml(), kz_term:deeplist()) -> bt_address(). xml_to_record(Xml) -> xml_to_record(Xml, "/address"). @@ -136,8 +136,8 @@ xml_to_record(Xml, Base) -> %% Contert the given XML to a customer record %% @end %%-------------------------------------------------------------------- --spec record_to_xml(bt_address()) -> kz_proplist() | bt_xml() | 'undefined'. --spec record_to_xml(bt_address(), boolean()) -> kz_proplist() | bt_xml() | 'undefined'. +-spec record_to_xml(bt_address()) -> kz_term:proplist() | bt_xml() | 'undefined'. +-spec record_to_xml(bt_address(), boolean()) -> kz_term:proplist() | bt_xml() | 'undefined'. record_to_xml(Address) -> record_to_xml(Address, 'false'). @@ -172,7 +172,7 @@ record_to_xml(Address, ToString) -> %% Convert a given json object into a record %% @end %%-------------------------------------------------------------------- --spec json_to_record(api_object()) -> bt_address() | 'undefined'. +-spec json_to_record(kz_term:api_object()) -> bt_address() | 'undefined'. json_to_record('undefined') -> 'undefined'; json_to_record(JObj) -> #bt_address{id = create_or_get_json_id(JObj) @@ -197,7 +197,7 @@ json_to_record(JObj) -> %% Convert a given record into a json object %% @end %%-------------------------------------------------------------------- --spec record_to_json(bt_address() | 'undefined') -> api_object(). +-spec record_to_json(bt_address() | 'undefined') -> kz_term:api_object(). record_to_json('undefined') -> 'undefined'; record_to_json(#bt_address{}=Address) -> kz_json:from_list( @@ -226,7 +226,7 @@ record_to_json(#bt_address{}=Address) -> %% a uuid to use during creation. %% @end %%-------------------------------------------------------------------- --spec create_or_get_json_id(kz_json:object()) -> api_binary(). +-spec create_or_get_json_id(kz_json:object()) -> kz_term:api_binary(). create_or_get_json_id(JObj) -> case kz_json:get_value(<<"street_address">>, JObj) of 'undefined' -> kz_doc:id(JObj); diff --git a/core/braintree/src/braintree_card.erl b/core/braintree/src/braintree_card.erl index b98001cba10..6432f1d33f4 100644 --- a/core/braintree/src/braintree_card.erl +++ b/core/braintree/src/braintree_card.erl @@ -36,8 +36,8 @@ %% @end %%-------------------------------------------------------------------- -spec url() -> string(). --spec url(ne_binary()) -> string(). --spec url(ne_binary(), _) -> string(). +-spec url(kz_term:ne_binary()) -> string(). +-spec url(kz_term:ne_binary(), _) -> string(). url() -> "/payment_methods/". @@ -54,7 +54,7 @@ url(Token, _) -> %% Given a list of #bt_cards{} find the current default payment token. %% @end %%-------------------------------------------------------------------- --spec default_payment_token(bt_cards()) -> api_binary(). +-spec default_payment_token(bt_cards()) -> kz_term:api_binary(). default_payment_token(Cards) -> case lists:keyfind('true', #bt_card.default, Cards) of 'false' -> braintree_util:error_no_payment_token(); @@ -68,10 +68,10 @@ default_payment_card(Cards) -> Card -> Card end. --spec payment_token(bt_card()) -> api_ne_binary(). +-spec payment_token(bt_card()) -> kz_term:api_ne_binary(). payment_token(#bt_card{token = Value}) -> Value. --spec payment_tokens(bt_cards()) -> api_ne_binaries(). +-spec payment_tokens(bt_cards()) -> kz_term:api_ne_binaries(). payment_tokens(Cards) -> [payment_token(Card) || Card <- Cards]. @@ -81,7 +81,7 @@ payment_tokens(Cards) -> %% Find a credit card by id %% @end %%-------------------------------------------------------------------- --spec find(ne_binary() | bt_card()) -> bt_card(). +-spec find(kz_term:ne_binary() | bt_card()) -> bt_card(). find(#bt_card{token = CardId}) -> find(CardId); find(Token) -> %% github.com/braintree/braintree_php/blob/master/lib/Braintree/CreditCardGateway.php#L149 @@ -100,7 +100,7 @@ find(Token) -> %% @end %%-------------------------------------------------------------------- -spec create(bt_card()) -> bt_card(). --spec create(string() | ne_binary(), bt_card()) -> bt_card(). +-spec create(string() | kz_term:ne_binary(), bt_card()) -> bt_card(). create(#bt_card{}=Card) -> Url = url(), @@ -159,7 +159,7 @@ expired(#bt_card{expired=Expired}) -> Expired. %% start and end dates. Dates are given as MMYYYY %% @end %%-------------------------------------------------------------------- --spec expiring(text(), text()) -> [bt_xml()]. +-spec expiring(kz_term:text(), kz_term:text()) -> [bt_xml()]. expiring(Start, End) -> Url = lists:append(["/payment_methods/all/expiring?start=" ,kz_term:to_list(Start) @@ -177,7 +177,7 @@ expiring(Start, End) -> %% Accessors for field 'make_default'. %% @end %%-------------------------------------------------------------------- --spec make_default(bt_card()) -> api_boolean(). +-spec make_default(bt_card()) -> kz_term:api_boolean(). -spec make_default(bt_card(), boolean()) -> bt_card(). make_default(#bt_card{make_default = Value}) -> Value. @@ -192,7 +192,7 @@ make_default(#bt_card{}=Card, Value) -> %% @end %%-------------------------------------------------------------------- -spec xml_to_record(bt_xml()) -> bt_card(). --spec xml_to_record(bt_xml(), kz_deeplist()) -> bt_card(). +-spec xml_to_record(bt_xml(), kz_term:deeplist()) -> bt_card(). xml_to_record(Xml) -> xml_to_record(Xml, "/credit-card"). @@ -222,8 +222,8 @@ xml_to_record(Xml, Base) -> %% Convert the given record to XML %% @end %%-------------------------------------------------------------------- --spec record_to_xml(bt_card()) -> kz_proplist() | bt_xml(). --spec record_to_xml(bt_card(), boolean()) -> kz_proplist() | bt_xml(). +-spec record_to_xml(bt_card()) -> kz_term:proplist() | bt_xml(). +-spec record_to_xml(bt_card(), boolean()) -> kz_term:proplist() | bt_xml(). record_to_xml(Card) -> record_to_xml(Card, 'false'). @@ -300,7 +300,7 @@ record_to_xml(#bt_card{}=Card, ToString) -> %% Convert a given json object into a record %% @end %%-------------------------------------------------------------------- --spec json_to_record(api_object()) -> bt_card(). +-spec json_to_record(kz_term:api_object()) -> bt_card(). json_to_record('undefined') -> 'undefined'; json_to_record(JObj) -> #bt_card{token = create_or_get_json_id(JObj) @@ -355,7 +355,7 @@ record_to_json(#bt_card{}=Card) -> %% a uuid to use during creation. %% @end %%-------------------------------------------------------------------- --spec create_or_get_json_id(kz_json:object()) -> api_binary(). +-spec create_or_get_json_id(kz_json:object()) -> kz_term:api_binary(). create_or_get_json_id(JObj) -> case kz_json:get_value(<<"number">>, JObj) of 'undefined' -> kz_doc:id(JObj); diff --git a/core/braintree/src/braintree_client_token.erl b/core/braintree/src/braintree_client_token.erl index bb7e605828e..d64f35bb080 100644 --- a/core/braintree/src/braintree_client_token.erl +++ b/core/braintree/src/braintree_client_token.erl @@ -30,7 +30,7 @@ url() -> %% Create client Token %% @end %%-------------------------------------------------------------------- --spec get_client_token(ne_binary()) -> api_ne_binary(). +-spec get_client_token(kz_term:ne_binary()) -> kz_term:api_ne_binary(). get_client_token(<<_/binary>> = CustomerId) -> Url = url(), Props = [{'customer-id', CustomerId} diff --git a/core/braintree/src/braintree_customer.erl b/core/braintree/src/braintree_customer.erl index afd36250963..71bb447fe97 100644 --- a/core/braintree/src/braintree_customer.erl +++ b/core/braintree/src/braintree_customer.erl @@ -41,7 +41,7 @@ %% @end %%-------------------------------------------------------------------- -spec url() -> string(). --spec url(ne_binary()) -> string(). +-spec url(kz_term:ne_binary()) -> string(). url() -> "/customers/". @@ -55,7 +55,7 @@ url(CustomerId) -> %% Creates a new customer record %% @end %%-------------------------------------------------------------------- --spec new(ne_binary()) -> customer(). +-spec new(kz_term:ne_binary()) -> customer(). new(CustomerId) -> #bt_customer{id=CustomerId}. @@ -65,7 +65,7 @@ new(CustomerId) -> %% Creates a new subscription record %% @end %%-------------------------------------------------------------------- --spec new_subscription(ne_binary(), customer()) -> braintree_subscription:subscription(). +-spec new_subscription(kz_term:ne_binary(), customer()) -> braintree_subscription:subscription(). new_subscription(PlanId, Customer) -> PaymentToken = default_payment_token(Customer), braintree_subscription:new(PlanId, PaymentToken). @@ -76,13 +76,13 @@ new_subscription(PlanId, Customer) -> %% Given a customer record find (if any) the default payment token %% @end %%-------------------------------------------------------------------- --spec default_payment_token(ne_binary() | customer()) -> api_binary(). +-spec default_payment_token(kz_term:ne_binary() | customer()) -> kz_term:api_binary(). default_payment_token(#bt_customer{}=Customer) -> braintree_card:default_payment_token(get_cards(Customer)); default_payment_token(CustomerId) -> default_payment_token(find(CustomerId)). --spec default_payment_card(ne_binary() | customer()) -> bt_card(). +-spec default_payment_card(kz_term:ne_binary() | customer()) -> bt_card(). default_payment_card(#bt_customer{}=Customer) -> braintree_card:default_payment_card(get_cards(Customer)); default_payment_card(CustomerId) -> @@ -94,7 +94,7 @@ default_payment_card(CustomerId) -> %% Get the customer id %% @end %%-------------------------------------------------------------------- --spec get_id(customer()) -> api_binary(). +-spec get_id(customer()) -> kz_term:api_binary(). get_id(#bt_customer{id=CustomerId}) -> CustomerId. @@ -124,7 +124,7 @@ get_subscriptions(#bt_customer{subscriptions=Subscriptions}) -> %% Get a subscription %% @end %%-------------------------------------------------------------------- --spec get_subscription(ne_binary(), customer() | bt_subscriptions()) -> +-spec get_subscription(kz_term:ne_binary(), customer() | bt_subscriptions()) -> bt_subscription(). get_subscription(PlanId, #bt_customer{subscriptions=Subscriptions}) -> get_subscription(PlanId, Subscriptions); @@ -160,7 +160,7 @@ all() -> %% Find a customer by id %% @end %%-------------------------------------------------------------------- --spec find(ne_binary() | customer()) -> customer(). +-spec find(kz_term:ne_binary() | customer()) -> customer(). find(#bt_customer{id = CustomerId}) -> find(CustomerId); find(CustomerId) -> Url = url(CustomerId), @@ -173,7 +173,7 @@ find(CustomerId) -> %% Creates a new customer using the given record %% @end %%-------------------------------------------------------------------- --spec create(customer() | ne_binary()) -> customer(). +-spec create(customer() | kz_term:ne_binary()) -> customer(). create(#bt_customer{}=Customer) -> Url = url(), Request = record_to_xml(Customer, 'true'), @@ -226,7 +226,7 @@ update_card(Customer, Card) -> NewPaymentToken = braintree_card:payment_token(Card), update_subsciption(NewPaymentToken, UpdatedCustomer). --spec update_subsciption(ne_binary(), bt_customer()) -> bt_customer(). +-spec update_subsciption(kz_term:ne_binary(), bt_customer()) -> bt_customer(). update_subsciption(NewPaymentToken, UpdatedCustomer) -> %% NewCard = Card with updated fields {[NewCard], OldCards} = @@ -249,8 +249,8 @@ update_subsciption(NewPaymentToken, UpdatedCustomer) -> %%get all the new user info find(UpdatedCustomer). --spec update_subsciption_with_token(bt_subscription(), ne_binary()) -> 'ok'. --spec update_subsciption_with_token(bt_subscription(), ne_binary(), boolean()) -> 'ok'. +-spec update_subsciption_with_token(bt_subscription(), kz_term:ne_binary()) -> 'ok'. +-spec update_subsciption_with_token(bt_subscription(), kz_term:ne_binary(), boolean()) -> 'ok'. update_subsciption_with_token(Sub, NewPaymentToken) -> ShouldUpdate = not braintree_subscription:is_cancelled(Sub) andalso not braintree_subscription:is_expired(Sub), @@ -268,7 +268,7 @@ delete_old_cards_and_addresses(OldCards, #bt_card{billing_address_id=NewAddressI ,OldCards ). --spec delete_old_stuff(bt_card(), ne_binary()) -> bt_card(). +-spec delete_old_stuff(bt_card(), kz_term:ne_binary()) -> bt_card(). delete_old_stuff(#bt_card{billing_address_id='undefined'}=OldCard, _NewAddressId) -> braintree_card:delete(OldCard); delete_old_stuff(#bt_card{billing_address_id=NewAddressId}=OldCard, NewAddressId) -> @@ -290,7 +290,7 @@ do_update(#bt_customer{id=CustomerId}=Customer) -> %% Deletes a customer id from braintree's system %% @end %%-------------------------------------------------------------------- --spec delete(customer() | ne_binary()) -> customer(). +-spec delete(customer() | kz_term:ne_binary()) -> customer(). delete(#bt_customer{id=CustomerId}) -> delete(CustomerId); delete(CustomerId) -> @@ -305,7 +305,7 @@ delete(CustomerId) -> %% @end %%-------------------------------------------------------------------- -spec xml_to_record(bt_xml()) -> customer(). --spec xml_to_record(bt_xml(), kz_deeplist()) -> customer(). +-spec xml_to_record(bt_xml(), kz_term:deeplist()) -> customer(). xml_to_record(Xml) -> xml_to_record(Xml, "/customer"). @@ -341,8 +341,8 @@ xml_to_record(Xml, Base) -> %% Convert the given record to XML %% @end %%-------------------------------------------------------------------- --spec record_to_xml(customer()) -> kz_proplist() | bt_xml(). --spec record_to_xml(customer(), boolean()) -> kz_proplist() | bt_xml(). +-spec record_to_xml(customer()) -> kz_term:proplist() | bt_xml(). +-spec record_to_xml(customer(), boolean()) -> kz_term:proplist() | bt_xml(). record_to_xml(Customer) -> record_to_xml(Customer, 'false'). @@ -373,7 +373,7 @@ record_to_xml(Customer, ToString) -> %% Convert a given json object into a record %% @end %%-------------------------------------------------------------------- --spec json_to_record(api_object()) -> customer(). +-spec json_to_record(kz_term:api_object()) -> customer(). json_to_record('undefined') -> #bt_customer{}; json_to_record(JObj) -> #bt_customer{id = kz_doc:id(JObj) @@ -388,7 +388,7 @@ json_to_record(JObj) -> ,credit_cards = maybe_add_credit_card(JObj) }. --spec maybe_add_credit_card(api_object()) -> bt_cards(). +-spec maybe_add_credit_card(kz_term:api_object()) -> bt_cards(). maybe_add_credit_card(JObj) -> case kz_json:get_value(<<"credit_card">>, JObj) of 'undefined' -> []; diff --git a/core/braintree/src/braintree_descriptor.erl b/core/braintree/src/braintree_descriptor.erl index 085dbd8e4d5..419c708ff72 100644 --- a/core/braintree/src/braintree_descriptor.erl +++ b/core/braintree/src/braintree_descriptor.erl @@ -20,21 +20,21 @@ %% %% @end %%-------------------------------------------------------------------- --spec get_name(bt_descriptor()) -> api_ne_binary(). +-spec get_name(bt_descriptor()) -> kz_term:api_ne_binary(). get_name(#bt_descriptor{name=Name}) -> Name. %%-------------------------------------------------------------------- %% @public %% @doc -%% Contert the given XML to a descriptor record +%% Convert the given XML to a descriptor record %% @end %%-------------------------------------------------------------------- -spec xml_to_record(bt_xml()) -> bt_descriptor(). xml_to_record(Xml) -> xml_to_record(Xml, "/descriptor"). --spec xml_to_record(bt_xml(), kz_deeplist()) -> bt_descriptor(). +-spec xml_to_record(bt_xml(), kz_term:deeplist()) -> bt_descriptor(). xml_to_record(Xml, Base) -> #bt_descriptor{name = kz_xml:get_value([Base, "/name/text()"], Xml) ,phone = kz_xml:get_value([Base, "/phone/text()"], Xml) @@ -44,14 +44,14 @@ xml_to_record(Xml, Base) -> %%-------------------------------------------------------------------- %% @public %% @doc -%% Contert the given XML to a descriptor record +%% Convert the given XML to a descriptor record %% @end %%-------------------------------------------------------------------- --spec record_to_xml(bt_descriptor()) -> kz_proplist() | bt_xml() | 'undefined'. --spec record_to_xml(bt_descriptor(), boolean()) -> kz_proplist() | bt_xml() | 'undefined'. +-spec record_to_xml(bt_descriptor()) -> kz_term:proplist() | bt_xml() | 'undefined'. record_to_xml(Descriptor) -> record_to_xml(Descriptor, 'false'). +-spec record_to_xml(bt_descriptor(), boolean()) -> kz_term:proplist() | bt_xml() | 'undefined'. record_to_xml('undefined', _ToString) -> 'undefined'; record_to_xml(Descriptor, ToString) -> Props = [{'name', Descriptor#bt_descriptor.name} @@ -82,7 +82,7 @@ record_to_json(#bt_descriptor{name=Name, phone=Phone, url=Url}) -> %% Convert a given json obj into a record %% @end %%-------------------------------------------------------------------- --spec json_to_record(api_object()) -> bt_descriptor() | 'undefined'. +-spec json_to_record(kz_term:api_object()) -> bt_descriptor() | 'undefined'. json_to_record('undefined') -> 'undefined'; json_to_record(JObj) -> #bt_descriptor{name = kz_json:get_binary_value(<<"name">>, JObj) diff --git a/core/braintree/src/braintree_discount.erl b/core/braintree/src/braintree_discount.erl index 39694dd8cba..37ad9044595 100644 --- a/core/braintree/src/braintree_discount.erl +++ b/core/braintree/src/braintree_discount.erl @@ -29,7 +29,7 @@ %% @end %%-------------------------------------------------------------------- -spec xml_to_record(bt_xml()) -> bt_discount(). --spec xml_to_record(bt_xml(), kz_deeplist()) -> bt_discount(). +-spec xml_to_record(bt_xml(), kz_term:deeplist()) -> bt_discount(). xml_to_record(Xml) -> xml_to_record(Xml, "/discount"). @@ -49,8 +49,8 @@ xml_to_record(Xml, Base) -> %% Contert the given XML to a customer record %% @end %%-------------------------------------------------------------------- --spec record_to_xml(bt_discount()) -> kz_proplist() | bt_xml(). --spec record_to_xml(bt_discount(), boolean()) -> kz_proplist() | bt_xml(). +-spec record_to_xml(bt_discount()) -> kz_term:proplist() | bt_xml(). +-spec record_to_xml(bt_discount(), boolean()) -> kz_term:proplist() | bt_xml(). record_to_xml(Discount) -> record_to_xml(Discount, false). @@ -89,7 +89,7 @@ record_to_json(#bt_discount{id=Id, amount=Amount, quantity=Q}) -> %% Convert a given json obj into a record %% @end %%-------------------------------------------------------------------- --spec json_to_record(api_object()) -> bt_discount() | 'undefined'. +-spec json_to_record(kz_term:api_object()) -> bt_discount() | 'undefined'. json_to_record('undefined') -> 'undefined'; json_to_record(JObj) -> #bt_discount{id = kz_doc:id(JObj) diff --git a/core/braintree/src/braintree_request.erl b/core/braintree/src/braintree_request.erl index 1341e4459ba..1f77cc966e6 100644 --- a/core/braintree/src/braintree_request.erl +++ b/core/braintree/src/braintree_request.erl @@ -134,7 +134,7 @@ request(Method, Path, Body) -> braintree_util:error_io_fault() end. --spec build_url(text()) -> text(). +-spec build_url(kz_term:text()) -> kz_term:text(). build_url(Path) -> lists:flatten(["https://" ,braintree_server_url(?BT_DEFAULT_ENVIRONMENT) @@ -150,7 +150,7 @@ request_headers() -> ,{"Content-Type", "application/xml"} ]. --type ssl_option() :: {'ssl', kz_proplist()}. +-type ssl_option() :: {'ssl', kz_term:proplist()}. -type basic_auth_option() :: {'basic_auth', {string(), string()}}. -spec http_options() -> [ssl_option() | basic_auth_option()]. diff --git a/core/braintree/src/braintree_subscription.erl b/core/braintree/src/braintree_subscription.erl index c2bc6625bcb..006b421bc62 100644 --- a/core/braintree/src/braintree_subscription.erl +++ b/core/braintree/src/braintree_subscription.erl @@ -37,7 +37,7 @@ -include("bt.hrl"). --type changes() :: [{atom(), kz_proplist(), [kz_proplist()]}]. +-type changes() :: [{atom(), kz_term:proplist(), [kz_term:proplist()]}]. -type subscription() :: bt_subscription(). -type subscriptions() :: bt_subscriptions(). @@ -52,8 +52,8 @@ %% @end %%-------------------------------------------------------------------- -spec url() -> string(). --spec url(ne_binary()) -> string(). --spec url(ne_binary(), ne_binary()) -> string(). +-spec url(kz_term:ne_binary()) -> string(). +-spec url(kz_term:ne_binary(), kz_term:ne_binary()) -> string(). url() -> "/subscriptions/". @@ -74,8 +74,8 @@ url(SubscriptionId, Options) -> %% Creates a new subscription record %% @end %%-------------------------------------------------------------------- --spec new(ne_binary(), ne_binary()) -> subscription(). --spec new(ne_binary(), ne_binary(), ne_binary()) -> subscription(). +-spec new(kz_term:ne_binary(), kz_term:ne_binary()) -> subscription(). +-spec new(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> subscription(). new(PlanId, PaymentToken) -> new(new_subscription_id(), PlanId, PaymentToken). @@ -88,7 +88,7 @@ new(SubscriptionId, PlanId, PaymentToken) -> }. %% @private --spec new_subscription_id() -> ne_binary(). +-spec new_subscription_id() -> kz_term:ne_binary(). new_subscription_id() -> kz_binary:rand_hex(16). @@ -98,7 +98,7 @@ new_subscription_id() -> %% Get the subscription id %% @end %%-------------------------------------------------------------------- --spec get_id(subscription()) -> api_binary(). +-spec get_id(subscription()) -> kz_term:api_binary(). get_id(#bt_subscription{id=SubscriptionId}) -> SubscriptionId. @@ -108,7 +108,7 @@ get_id(#bt_subscription{id=SubscriptionId}) -> %% Get the subscription id %% @end %%-------------------------------------------------------------------- --spec get_addon(subscription(), ne_binary()) -> #bt_addon{}. +-spec get_addon(subscription(), kz_term:ne_binary()) -> #bt_addon{}. get_addon(#bt_subscription{add_ons=AddOns}, AddOnId) -> case lists:keyfind(AddOnId, #bt_addon.id, AddOns) of 'false' -> @@ -125,7 +125,7 @@ get_addon(#bt_subscription{add_ons=AddOns}, AddOnId) -> %% Get the quantity of addons %% @end %%-------------------------------------------------------------------- --spec get_addon_quantity(subscription(), ne_binary()) -> integer(). +-spec get_addon_quantity(subscription(), kz_term:ne_binary()) -> integer(). get_addon_quantity(#bt_subscription{add_ons=AddOns}, AddOnId) -> case lists:keyfind(AddOnId, #bt_addon.id, AddOns) of 'false' -> @@ -142,7 +142,7 @@ get_addon_quantity(#bt_subscription{add_ons=AddOns}, AddOnId) -> %% Get the subscription id %% @end %%-------------------------------------------------------------------- --spec update_addon_amount(subscription(), ne_binary(), api_binary() | number()) -> subscription(). +-spec update_addon_amount(subscription(), kz_term:ne_binary(), kz_term:api_binary() | number()) -> subscription(). update_addon_amount(#bt_subscription{add_ons=AddOns}=Subscription, AddOnId, Amount) -> case lists:keyfind(AddOnId, #bt_addon.id, AddOns) of 'false' -> @@ -165,7 +165,7 @@ update_addon_amount(#bt_subscription{add_ons=AddOns}=Subscription, AddOnId, Amou %% Find a specific discount %% @end %%-------------------------------------------------------------------- --spec get_discount(subscription(), ne_binary()) -> #bt_discount{}. +-spec get_discount(subscription(), kz_term:ne_binary()) -> #bt_discount{}. get_discount(#bt_subscription{discounts=Discounts}, DiscountId) -> case lists:keyfind(DiscountId, #bt_discount.id, Discounts) of 'false' -> @@ -182,7 +182,7 @@ get_discount(#bt_subscription{discounts=Discounts}, DiscountId) -> %% Update the amount of a specific discount %% @end %%-------------------------------------------------------------------- --spec update_discount_amount(subscription(), ne_binary(), ne_binary() | number()) -> subscription(). +-spec update_discount_amount(subscription(), kz_term:ne_binary(), kz_term:ne_binary() | number()) -> subscription(). update_discount_amount(#bt_subscription{discounts=Discounts}=Subscription, DiscountId, Amount) -> case lists:keyfind(DiscountId, #bt_discount.id, Discounts) of 'false' -> @@ -200,7 +200,7 @@ update_discount_amount(#bt_subscription{discounts=Discounts}=Subscription, Disco end. %% @public --spec get_payment_token(subscription()) -> api_binary(). +-spec get_payment_token(subscription()) -> kz_term:api_binary(). get_payment_token(#bt_subscription{payment_token = PT}) -> PT. %%-------------------------------------------------------------------- @@ -209,7 +209,7 @@ get_payment_token(#bt_subscription{payment_token = PT}) -> PT. %% Find a subscription by id %% @end %%-------------------------------------------------------------------- --spec find(ne_binary()) -> subscription(). +-spec find(kz_term:ne_binary()) -> subscription(). find(SubscriptionId) -> XML = braintree_request:get(url(SubscriptionId)), xml_to_record(XML). @@ -254,7 +254,7 @@ update(#bt_subscription{id=SubscriptionId}=Subscription) -> %% Deletes a subscription id from braintree's system %% @end %%-------------------------------------------------------------------- --spec cancel(subscription() | ne_binary()) -> subscription(). +-spec cancel(subscription() | kz_term:ne_binary()) -> subscription(). cancel(#bt_subscription{id=SubscriptionId}) -> cancel(SubscriptionId); cancel(SubscriptionId) -> @@ -301,7 +301,7 @@ reset_discounts(#bt_subscription{discounts=Discounts}=Subscription) -> %% or subscription id %% @end %%-------------------------------------------------------------------- --spec update_addon_quantity(subscription() | ne_binary(), ne_binary(), integer() | api_binary()) -> +-spec update_addon_quantity(subscription() | kz_term:ne_binary(), kz_term:ne_binary(), integer() | kz_term:api_binary()) -> subscription(). update_addon_quantity(Subscription, AddOnId, Quantity) when not is_integer(Quantity) -> update_addon_quantity(Subscription, AddOnId, kz_term:to_integer(Quantity)); @@ -335,7 +335,7 @@ update_addon_quantity(#bt_subscription{add_ons=AddOns}=Subscription, AddOnId, Qu %% or subscription id %% @end %%-------------------------------------------------------------------- --spec increment_addon_quantity(subscription() | ne_binary(), ne_binary()) -> subscription(). +-spec increment_addon_quantity(subscription() | kz_term:ne_binary(), kz_term:ne_binary()) -> subscription(). increment_addon_quantity(#bt_subscription{add_ons=AddOns}=Subscription, AddOnId) -> case lists:keyfind(AddOnId, #bt_addon.id, AddOns) of 'false' -> @@ -361,7 +361,7 @@ increment_addon_quantity(SubscriptionId, AddOnId) -> %% Really ugly function to update a discount for a given subscription %% @end %%-------------------------------------------------------------------- --spec update_discount_quantity(subscription() | ne_binary(), ne_binary(), api_integer()) -> subscription(). +-spec update_discount_quantity(subscription() | kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_integer()) -> subscription(). update_discount_quantity(Subscription, DiscountId, Quantity) when not is_integer(Quantity) -> update_discount_quantity(Subscription, DiscountId, kz_term:to_integer(Quantity)); update_discount_quantity(#bt_subscription{discounts=Discounts}=Subscription, DiscountId, Quantity) -> @@ -389,7 +389,7 @@ update_discount_quantity(SubscriptionId, DiscountId, Quantity) -> %% Really ugly function to increment a discount for a given subscription %% @end %%-------------------------------------------------------------------- --spec increment_discount_quantity(subscription() | ne_binary(), ne_binary()) -> subscription(). +-spec increment_discount_quantity(subscription() | kz_term:ne_binary(), kz_term:ne_binary()) -> subscription(). increment_discount_quantity(#bt_subscription{discounts=Discounts}=Subscription, DiscountId) -> case lists:keyfind(DiscountId, #bt_discount.id, Discounts) of 'false' -> @@ -415,7 +415,7 @@ increment_discount_quantity(SubscriptionId, DiscountId) -> %% Update payment token and reset fields to be able to push update back %% @end %%-------------------------------------------------------------------- --spec update_payment_token(subscription(), ne_binary()) -> subscription(). +-spec update_payment_token(subscription(), kz_term:ne_binary()) -> subscription(). update_payment_token(#bt_subscription{id=Id}, PaymentToken) -> %% Fixes: 91920: Cannot edit price changing fields on past due subscription. %% For reference: @@ -459,7 +459,7 @@ is_expired(#bt_subscription{}) -> 'false'. %% @end %%-------------------------------------------------------------------- -spec xml_to_record(bt_xml()) -> subscription(). --spec xml_to_record(bt_xml(), kz_deeplist()) -> subscription(). +-spec xml_to_record(bt_xml(), kz_term:deeplist()) -> subscription(). xml_to_record(Xml) -> xml_to_record(Xml, "/subscription"). @@ -506,8 +506,8 @@ xml_to_record(Xml, Base) -> %% Contert the given XML to a subscription record %% @end %%-------------------------------------------------------------------- --spec record_to_xml(subscription()) -> kz_proplist() | bt_xml(). --spec record_to_xml(subscription(), boolean()) -> kz_proplist() | bt_xml(). +-spec record_to_xml(subscription()) -> kz_term:proplist() | bt_xml(). +-spec record_to_xml(subscription(), boolean()) -> kz_term:proplist() | bt_xml(). record_to_xml(Subscription) -> record_to_xml(Subscription, 'false'). @@ -605,7 +605,7 @@ record_to_json(Subscription) -> %% %% @end %%-------------------------------------------------------------------- --spec should_prorate(subscription(), kz_proplist()) -> kz_proplist(). +-spec should_prorate(subscription(), kz_term:proplist()) -> kz_term:proplist(). should_prorate(#bt_subscription{prorate_charges=Value}, Props) -> case kapps_config:get_is_true(?CONFIG_CAT, <<"should_prorate">>, 'true') of 'true' -> update_options('prorate-charges', Value, Props); @@ -618,7 +618,7 @@ should_prorate(#bt_subscription{prorate_charges=Value}, Props) -> %% Determine the necessary steps to change the add ons %% @end %%-------------------------------------------------------------------- --spec update_options(any(), any(), kz_proplist()) -> kz_proplist(). +-spec update_options(any(), any(), kz_term:proplist()) -> kz_term:proplist(). update_options(_, 'undefined', Props) -> Props; update_options(Key, Value, Props) -> case props:get_value('options', Props) of @@ -722,7 +722,7 @@ create_discount_fold(#bt_discount{existing_id=Id %% Determine the necessary steps to change the add ons %% @end %%-------------------------------------------------------------------- --spec append_items(atom(), ne_binary() | kz_proplist(), changes()) -> changes(). +-spec append_items(atom(), kz_term:ne_binary() | kz_term:proplist(), changes()) -> changes(). append_items(Change, Item, Changes) -> case lists:keyfind(Change, 1, Changes) of 'false' -> diff --git a/core/braintree/src/braintree_transaction.erl b/core/braintree/src/braintree_transaction.erl index 451e524075b..6abe963385e 100644 --- a/core/braintree/src/braintree_transaction.erl +++ b/core/braintree/src/braintree_transaction.erl @@ -36,8 +36,8 @@ %% @end %%-------------------------------------------------------------------- -spec url() -> string(). --spec url(ne_binary()) -> string(). --spec url(ne_binary(), ne_binary()) -> string(). +-spec url(kz_term:ne_binary()) -> string(). +-spec url(kz_term:ne_binary(), kz_term:ne_binary()) -> string(). url() -> "/transactions/". @@ -58,7 +58,7 @@ url(TransactionId, Options) -> %% Find a transaction by id %% @end %%-------------------------------------------------------------------- --spec find(ne_binary()) -> bt_transaction(). +-spec find(kz_term:ne_binary()) -> bt_transaction(). find(TransactionId) -> Url = url(TransactionId), Xml = braintree_request:get(Url), @@ -70,7 +70,7 @@ find(TransactionId) -> %% Find transactions by customer id %% @end %%-------------------------------------------------------------------- --spec find_by_customer(ne_binary()) -> bt_transactions(). +-spec find_by_customer(kz_term:ne_binary()) -> bt_transactions(). find_by_customer(CustomerId) -> Url = url(<<"advanced_search">>), Props = [{'customer_id', [{'is', CustomerId}]}], @@ -80,7 +80,7 @@ find_by_customer(CustomerId) -> || Transaction <- xmerl_xpath:string("/credit-card-transactions/transaction", Xml) ]. --spec find_by_customer(ne_binary(), ne_binary(), ne_binary()) -> bt_transactions(). +-spec find_by_customer(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> bt_transactions(). find_by_customer(CustomerId, Min, Max) -> Url = url(<<"advanced_search">>), Props = [{'customer_id', [{'is', CustomerId}]} @@ -108,7 +108,7 @@ find_by_customer(CustomerId, Min, Max) -> %% @end %%-------------------------------------------------------------------- -spec create(bt_transaction()) -> bt_transaction(). --spec create(ne_binary(), bt_transaction()) -> bt_transaction(). +-spec create(kz_term:ne_binary(), bt_transaction()) -> bt_transaction(). create(#bt_transaction{amount=Amount}=Transaction) -> MaxAmount = kapps_config:get_float(?CONFIG_CAT, <<"max_amount">>, 200.00), @@ -131,7 +131,7 @@ create(CustomerId, Transaction) -> %% @end %%-------------------------------------------------------------------- -spec sale(bt_transaction()) -> bt_transaction(). --spec sale(ne_binary(), bt_transaction()) -> bt_transaction(). +-spec sale(kz_term:ne_binary(), bt_transaction()) -> bt_transaction(). sale(Transaction) -> create(Transaction#bt_transaction{type=?BT_TRANS_SALE}). @@ -140,8 +140,8 @@ sale(CustomerId, Transaction) -> ,customer_id=CustomerId }). --spec quick_sale(ne_binary(), number() | ne_binary()) -> bt_transaction(). --spec quick_sale(ne_binary(), number() | ne_binary(), kz_proplist()) -> bt_transaction(). +-spec quick_sale(kz_term:ne_binary(), number() | kz_term:ne_binary()) -> bt_transaction(). +-spec quick_sale(kz_term:ne_binary(), number() | kz_term:ne_binary(), kz_term:proplist()) -> bt_transaction(). quick_sale(CustomerId, Amount) -> case kz_term:to_float(Amount) < ?MIN_AMOUNT of 'true' -> braintree_util:error_min_amount(?MIN_AMOUNT); @@ -163,7 +163,7 @@ quick_sale(CustomerId, Amount, Props) -> %% @end %%-------------------------------------------------------------------- -spec credit(bt_transaction()) -> bt_transaction(). --spec credit(ne_binary(), bt_transaction()) -> bt_transaction(). +-spec credit(kz_term:ne_binary(), bt_transaction()) -> bt_transaction(). credit(Transaction) -> create(Transaction#bt_transaction{type=?BT_TRANS_CREDIT}). @@ -172,7 +172,7 @@ credit(CustomerId, Transaction) -> ,customer_id=CustomerId }). --spec quick_credit(ne_binary(), ne_binary()) -> bt_transaction(). +-spec quick_credit(kz_term:ne_binary(), kz_term:ne_binary()) -> bt_transaction(). quick_credit(CustomerId, Amount) -> credit(CustomerId, #bt_transaction{amount=kz_term:to_binary(Amount) ,settle='false' @@ -185,7 +185,7 @@ quick_credit(CustomerId, Amount) -> %% Void transactions that have a status:authorized or submitted_for_settlement %% @end %%-------------------------------------------------------------------- --spec void(bt_transaction() | ne_binary()) -> bt_transaction(). +-spec void(bt_transaction() | kz_term:ne_binary()) -> bt_transaction(). void(#bt_transaction{id=TransactionId}) -> void(TransactionId); void(TransactionId) -> @@ -199,8 +199,8 @@ void(TransactionId) -> %% Refund a transaction with status: settled or settling %% @end %%-------------------------------------------------------------------- --spec refund(bt_transaction() | ne_binary()) -> bt_transaction(). --spec refund(bt_transaction() | ne_binary(), api_binary()) -> bt_transaction(). +-spec refund(bt_transaction() | kz_term:ne_binary()) -> bt_transaction(). +-spec refund(bt_transaction() | kz_term:ne_binary(), kz_term:api_binary()) -> bt_transaction(). refund(TransactionId) -> refund(TransactionId, 'undefined'). @@ -220,7 +220,7 @@ refund(TransactionId, Amount) -> %% @end %%-------------------------------------------------------------------- -spec xml_to_record(bt_xml()) -> bt_transaction(). --spec xml_to_record(bt_xml(), kz_deeplist()) -> bt_transaction(). +-spec xml_to_record(bt_xml(), kz_term:deeplist()) -> bt_transaction(). xml_to_record(Xml) -> xml_to_record(Xml, "/transaction"). @@ -272,7 +272,7 @@ xml_to_record(Xml, Base) -> ,is_recurring = props:get_value('is_recurring', StatusHistory) }. --spec get_status_history(bt_xml(), kz_deeplist()) -> kz_proplist(). +-spec get_status_history(bt_xml(), kz_term:deeplist()) -> kz_term:proplist(). get_status_history(Xml, Base) -> HistoryPath = lists:flatten([Base, "/status-history/status-event"]), History = xmerl_xpath:string(HistoryPath, Xml), @@ -290,13 +290,13 @@ get_status_history(Xml, Base) -> end, Sources)} ]. --spec get_users(bt_xml(), api_binaries()) -> api_binaries(). +-spec get_users(bt_xml(), kz_term:api_binaries()) -> kz_term:api_binaries(). get_users([], Users) -> Users; get_users([Element|Elements], Users) -> User = kz_xml:get_value("user/text()", Element), get_users(Elements, [User|Users]). --spec get_transaction_sources(bt_xml(), api_binaries()) -> api_binaries(). +-spec get_transaction_sources(bt_xml(), kz_term:api_binaries()) -> kz_term:api_binaries(). get_transaction_sources([], Sources) -> Sources; get_transaction_sources([Element|Elements], Sources) -> Source = kz_xml:get_value("transaction-source/text()", Element), @@ -308,8 +308,8 @@ get_transaction_sources([Element|Elements], Sources) -> %% Contert the given XML to a transaction record %% @end %%-------------------------------------------------------------------- --spec record_to_xml(bt_transaction()) -> kz_proplist() | bt_xml(). --spec record_to_xml(bt_transaction(), boolean()) -> kz_proplist() | bt_xml(). +-spec record_to_xml(bt_transaction()) -> kz_term:proplist() | bt_xml(). +-spec record_to_xml(bt_transaction(), boolean()) -> kz_term:proplist() | bt_xml(). record_to_xml(Transaction) -> record_to_xml(Transaction, 'false'). @@ -447,7 +447,7 @@ record_to_json(#bt_transaction{}=Transaction) -> ,{<<"is_recurring">>, Transaction#bt_transaction.is_recurring} ]). --spec json_to_record(api_object()) -> bt_transaction() | 'undefined'. +-spec json_to_record(kz_term:api_object()) -> bt_transaction() | 'undefined'. json_to_record('undefined') -> 'undefined'; json_to_record(JObj) -> #bt_transaction{id = kz_doc:id(JObj) @@ -497,7 +497,7 @@ json_to_record(JObj) -> ,is_recurring = kz_json:is_true(<<"is_recurring">>, JObj) }. --spec record_to_notification_props(bt_transaction()) -> kz_proplist(). +-spec record_to_notification_props(bt_transaction()) -> kz_term:proplist(). record_to_notification_props(#bt_transaction{}=BraintreeTransaction) -> Transaction = record_to_json(BraintreeTransaction), RespCode = kz_json:get_value(<<"processor_response_code">>, Transaction, ?CODE_UNKNOWN), @@ -516,7 +516,7 @@ record_to_notification_props(#bt_transaction{}=BraintreeTransaction) -> ,{<<"Currency-Code">>, kz_json:get_value(<<"currency_code">>, Transaction)} ]). --spec purchase_order_reason(kz_json:object()) -> api_ne_binary(). +-spec purchase_order_reason(kz_json:object()) -> kz_term:api_ne_binary(). purchase_order_reason(Transaction) -> case kz_json:get_integer_value(<<"purchase_order">>, Transaction) of 'undefined' -> 'undefined'; diff --git a/core/braintree/src/braintree_util.erl b/core/braintree/src/braintree_util.erl index c1c0a0c5499..6cff7910ed5 100644 --- a/core/braintree/src/braintree_util.erl +++ b/core/braintree/src/braintree_util.erl @@ -39,7 +39,7 @@ %% %% @end %%-------------------------------------------------------------------- --spec make_doc_xml(kz_proplist(), atom()) -> char_to_bin_res(). +-spec make_doc_xml(kz_term:proplist(), atom()) -> char_to_bin_res(). make_doc_xml(Props, Root) -> Xml = xmerl:export_simple([doc_xml_simple(Props, Root)] ,'xmerl_xml' @@ -166,7 +166,7 @@ error_authorization() -> %% %% @end %%-------------------------------------------------------------------- --spec error_not_found(ne_binary()) -> no_return(). +-spec error_not_found(kz_term:ne_binary()) -> no_return(). error_not_found(Object) -> Error = <>, lager:debug("~s", [Error]), @@ -238,7 +238,7 @@ error_io_fault() -> %% %% @end %%-------------------------------------------------------------------- --spec error_min_amount(number() | ne_binary()) -> no_return(). +-spec error_min_amount(number() | kz_term:ne_binary()) -> no_return(). error_min_amount(Amount) -> Error = <<"Unable to process a transaction for less than $", (kz_term:to_binary(Amount))/binary>>, lager:debug("~s", [Error]), @@ -250,7 +250,7 @@ error_min_amount(Amount) -> %% %% @end %%-------------------------------------------------------------------- --spec error_max_amount(number() | ne_binary()) -> no_return(). +-spec error_max_amount(number() | kz_term:ne_binary()) -> no_return(). error_max_amount(Amount) -> Error = <<"Unable to process a transaction for more than $", (kz_term:to_binary(Amount))/binary>>, lager:debug("~s", [Error]), diff --git a/core/gcm/src/gcm.erl b/core/gcm/src/gcm.erl index cb6a7be01c5..f418470a05e 100644 --- a/core/gcm/src/gcm.erl +++ b/core/gcm/src/gcm.erl @@ -35,11 +35,11 @@ start(Name, Key) -> stop(Name) -> gen_server:call(Name, stop). --spec push(server_ref(), list(), any()) -> ok. +-spec push(kz_types:server_ref(), list(), any()) -> ok. push(Name, RegIds, Message) -> push(Name, RegIds, Message, ?RETRY). --spec push(server_ref(), list(), any(), non_neg_integer()) -> ok. +-spec push(kz_types:server_ref(), list(), any(), non_neg_integer()) -> ok. push(Name, RegIds, Message, Retry) -> gen_server:cast(Name, {send, RegIds, Message, Retry}). diff --git a/core/gcm/src/gcm_sup.erl b/core/gcm/src/gcm_sup.erl index bed4e77529d..353d86654b6 100644 --- a/core/gcm/src/gcm_sup.erl +++ b/core/gcm/src/gcm_sup.erl @@ -11,15 +11,15 @@ -define(CHILDREN, [?WORKER_TYPE('gcm', 'transient')]). --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec start_child(atom(),string()) -> sup_startchild_ret(). +-spec start_child(atom(),string()) -> kz_types:sup_startchild_ret(). start_child(Name, ApiKey) -> supervisor:start_child(?SERVER, [Name, ApiKey]). --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 5, diff --git a/core/kazoo/src/kazoo_maintenance.erl b/core/kazoo/src/kazoo_maintenance.erl index 1dcd64fc1e9..2b3cf8543ef 100644 --- a/core/kazoo/src/kazoo_maintenance.erl +++ b/core/kazoo/src/kazoo_maintenance.erl @@ -122,19 +122,19 @@ start_debug_file(File) -> Timestamp = kz_time:current_unix_tstamp(), file:write_file(File, io_lib:format("Created: ~p~n~n", [Timestamp])). --spec syslog_level(text()) -> 'ok'. +-spec syslog_level(kz_term:text()) -> 'ok'. syslog_level(Level) -> kz_util:change_syslog_log_level(kz_term:to_atom(Level)). --spec error_level(text()) -> 'ok'. +-spec error_level(kz_term:text()) -> 'ok'. error_level(Level) -> kz_util:change_error_log_level(kz_term:to_atom(Level)). --spec console_level(text()) -> 'ok'. +-spec console_level(kz_term:text()) -> 'ok'. console_level(Level) -> kz_util:change_console_log_level(kz_term:to_atom(Level)). --spec hotload(text() | atom()) -> 'ok' | 'no_return'. +-spec hotload(kz_term:text() | atom()) -> 'ok' | 'no_return'. hotload(Module) when is_atom(Module) -> _ = code:soft_purge(Module), case code:load_file(Module) of @@ -146,7 +146,7 @@ hotload(Module) when is_atom(Module) -> hotload(Module) -> hotload(kz_term:to_atom(Module, 'true')). --spec hotload_app(text() | atom()) -> 'ok'. +-spec hotload_app(kz_term:text() | atom()) -> 'ok'. hotload_app(App) when is_atom(App) -> case application:get_key(App, 'modules') of {'ok', Modules} -> @@ -174,7 +174,7 @@ gc_top_mem_consumers(N) -> {Top, _} = top_mem_consumers(N), gc_pids([P || {P,_} <- Top]). --type consumers() :: {kz_proplist_kv(pid(), integer()), kz_proplist_kv(pid(), integer())}. +-type consumers() :: {kz_term:proplist_kv(pid(), integer()), kz_term:proplist_kv(pid(), integer())}. -spec top_mem_consumers() -> consumers(). -spec top_mem_consumers(pos_integer()) -> consumers(). top_mem_consumers() -> diff --git a/core/kazoo/src/kz_doc.erl b/core/kazoo/src/kz_doc.erl index c3c086306a8..d30c27d7111 100644 --- a/core/kazoo/src/kz_doc.erl +++ b/core/kazoo/src/kz_doc.erl @@ -96,9 +96,9 @@ %% parameters on all crossbar documents %% @end %%-------------------------------------------------------------------- --spec update_pvt_parameters(kz_json:object(), api_binary()) -> +-spec update_pvt_parameters(kz_json:object(), kz_term:api_binary()) -> kz_json:object(). --spec update_pvt_parameters(kz_json:object(), api_binary(), kz_proplist()) -> +-spec update_pvt_parameters(kz_json:object(), kz_term:api_binary(), kz_term:proplist()) -> kz_json:object(). update_pvt_parameters(JObj0, DBName) -> update_pvt_parameters(JObj0, DBName, []). @@ -106,14 +106,14 @@ update_pvt_parameters(JObj0, DBName, Options) -> Opts = props:insert_value('now', kz_time:now_s(), Options), lists:foldl(fun(Fun, JObj) -> Fun(JObj, DBName, Opts) end, JObj0, ?PVT_FUNS). --spec add_pvt_vsn(kz_json:object(), api_binary(), kz_proplist()) -> kz_json:object(). +-spec add_pvt_vsn(kz_json:object(), kz_term:api_binary(), kz_term:proplist()) -> kz_json:object(). add_pvt_vsn(JObj, _, Options) -> case props:get_value('crossbar_doc_vsn', Options) of 'undefined' -> JObj; Vsn -> kz_json:set_value(?KEY_VSN, Vsn, JObj) end. --spec add_pvt_account_db(kz_json:object(), api_binary(), kz_proplist()) -> kz_json:object(). +-spec add_pvt_account_db(kz_json:object(), kz_term:api_binary(), kz_term:proplist()) -> kz_json:object(). add_pvt_account_db(JObj, 'undefined', Opts) -> case props:get_value('account_db', Opts) of 'undefined' -> JObj; @@ -125,7 +125,7 @@ add_pvt_account_db(JObj, DBName, Opts) -> Db -> kz_json:set_value(?KEY_ACCOUNT_DB, Db, JObj) end. --spec add_pvt_account_id(kz_json:object(), api_binary(), kz_proplist()) -> kz_json:object(). +-spec add_pvt_account_id(kz_json:object(), kz_term:api_binary(), kz_term:proplist()) -> kz_json:object(). add_pvt_account_id(JObj, 'undefined', Opts) -> case props:get_value('account_id', Opts) of 'undefined' -> JObj; @@ -137,21 +137,21 @@ add_pvt_account_id(JObj, DBName, Opts) -> Id -> kz_json:set_value(?KEY_ACCOUNT_ID, Id, JObj) end. --spec add_pvt_type(kz_json:object(), api_binary(), kz_proplist()) -> kz_json:object(). +-spec add_pvt_type(kz_json:object(), kz_term:api_binary(), kz_term:proplist()) -> kz_json:object(). add_pvt_type(JObj, _, Options) -> case props:get_value('type', Options) of 'undefined' -> JObj; Type -> kz_json:set_value(?KEY_PVT_TYPE, Type, JObj) end. --spec add_pvt_node(kz_json:object(), api_binary(), kz_proplist()) -> kz_json:object(). +-spec add_pvt_node(kz_json:object(), kz_term:api_binary(), kz_term:proplist()) -> kz_json:object(). add_pvt_node(JObj, _, Options) -> case props:get_value('node', Options) of 'undefined' -> kz_json:set_value(?KEY_NODE, kz_term:to_binary(node()), JObj); Node -> kz_json:set_value(?KEY_NODE, kz_term:to_binary(Node), JObj) end. --spec add_pvt_created(kz_json:object(), api_binary(), kz_proplist()) -> kz_json:object(). +-spec add_pvt_created(kz_json:object(), kz_term:api_binary(), kz_term:proplist()) -> kz_json:object(). add_pvt_created(JObj, _, Opts) -> case kz_json:get_ne_binary_value(?KEY_REV, JObj) of 'undefined' -> @@ -166,29 +166,29 @@ add_pvt_created(JObj, _, Opts) -> update_pvt_modified(JObj) -> add_pvt_modified(JObj, 'undefined', [{'now', kz_time:now_s()}]). --spec set_modified(kz_json:object(), gregorian_seconds()) -> kz_json:object(). +-spec set_modified(kz_json:object(), kz_time:gregorian_seconds()) -> kz_json:object(). set_modified(JObj, Now) -> kz_json:set_value(?KEY_MODIFIED, Now, JObj). --spec add_pvt_modified(kz_json:object(), api_binary(), kz_proplist()) -> kz_json:object(). +-spec add_pvt_modified(kz_json:object(), kz_term:api_binary(), kz_term:proplist()) -> kz_json:object(). add_pvt_modified(JObj, _, Opts) -> kz_json:set_value(?KEY_MODIFIED, props:get_value('now', Opts), JObj). --spec modified(kz_json:object()) -> api_integer(). +-spec modified(kz_json:object()) -> kz_term:api_integer(). -spec modified(kz_json:object(), Default) -> integer() | Default. modified(JObj) -> modified(JObj, 'undefined'). modified(JObj, Default) -> kz_json:get_integer_value(?KEY_MODIFIED, JObj, Default). --spec add_id(kz_json:object(), any(), kz_proplist()) -> kz_json:object(). +-spec add_id(kz_json:object(), any(), kz_term:proplist()) -> kz_json:object(). add_id(JObj, _, Opts) -> case props:get_value('id', Opts) of 'undefined' -> JObj; Id -> set_id(JObj, Id) end. --spec add_pvt_document_hash(kz_json:object(), any(), kz_proplist()) -> kz_json:object(). +-spec add_pvt_document_hash(kz_json:object(), any(), kz_term:proplist()) -> kz_json:object(). add_pvt_document_hash(JObj, _, _) -> Hash = calculate_document_hash(JObj), set_document_hash(JObj, Hash). @@ -269,7 +269,7 @@ remove_pvt(<<"_", Key/binary>>) -> Key; remove_pvt(<<"pvt_", Key/binary>>) -> Key; remove_pvt(Key) -> Key. --spec attachments(kz_json:object()) -> api_object(). +-spec attachments(kz_json:object()) -> kz_term:api_object(). -spec attachments(kz_json:object(), Default) -> kz_json:object() | Default. attachments(JObj) -> attachments(JObj, 'undefined'). @@ -281,7 +281,7 @@ attachments(JObj, Default) -> A3 -> A3 end. --spec stub_attachments(kz_json:object()) -> api_object(). +-spec stub_attachments(kz_json:object()) -> kz_term:api_object(). -spec stub_attachments(kz_json:object(), Default) -> kz_json:object() | Default. stub_attachments(JObj) -> stub_attachments(JObj, 'undefined'). @@ -291,7 +291,7 @@ stub_attachments(JObj, Default) -> A3 -> A3 end. --spec external_attachments(kz_json:object()) -> api_object(). +-spec external_attachments(kz_json:object()) -> kz_term:api_object(). -spec external_attachments(kz_json:object(), Default) -> kz_json:object() | Default. external_attachments(JObj) -> external_attachments(JObj, 'undefined'). @@ -301,7 +301,7 @@ external_attachments(JObj, Default) -> A3 -> A3 end. --spec attachment_names(kz_json:object()) -> ne_binaries() | []. +-spec attachment_names(kz_json:object()) -> kz_term:ne_binaries() | []. attachment_names(JObj) -> kz_json:get_keys(attachments(JObj, kz_json:new())). @@ -314,7 +314,7 @@ attachment_revision(AttachmentJObj) -> compare_attachments(AttachmentJObjA, AttachmentJObjB) -> attachment_revision(AttachmentJObjA) =< attachment_revision(AttachmentJObjB). --spec latest_attachment_id(kz_json:object()) -> ne_binary() | 'undefined'. +-spec latest_attachment_id(kz_json:object()) -> kz_term:ne_binary() | 'undefined'. latest_attachment_id(Doc) -> case attachments(Doc) of 'undefined' -> 'undefined'; @@ -325,8 +325,8 @@ latest_attachment_id(Doc) -> Name end. --spec attachment(kz_json:object()) -> api_object(). --spec attachment(kz_json:object(), kz_json:path()) -> api_object(). +-spec attachment(kz_json:object()) -> kz_term:api_object(). +-spec attachment(kz_json:object(), kz_json:path()) -> kz_term:api_object(). -spec attachment(kz_json:object(), kz_json:path(), Default) -> kz_json:object() | Default. %% @public %% @doc Gets a random attachment from JObj (no order is imposed!) @@ -342,16 +342,16 @@ attachment(JObj, AName) -> attachment(JObj, AName, Default) -> kz_json:get_json_value(AName, attachments(JObj, kz_json:new()), Default). --spec attachment_length(kz_json:object(), ne_binary()) -> api_integer(). --spec attachment_length(kz_json:object(), ne_binary(), Default) -> non_neg_integer() | Default. +-spec attachment_length(kz_json:object(), kz_term:ne_binary()) -> kz_term:api_integer(). +-spec attachment_length(kz_json:object(), kz_term:ne_binary(), Default) -> non_neg_integer() | Default. attachment_length(JObj, AName) -> attachment_length(JObj, AName, 'undefined'). attachment_length(JObj, AName, Default) -> attachment_property(JObj, AName, <<"length">>, Default, fun kz_json:get_integer_value/3). --spec attachment_content_type(kz_json:object()) -> api_ne_binary(). --spec attachment_content_type(kz_json:object(), ne_binary()) -> api_ne_binary(). --spec attachment_content_type(kz_json:object(), ne_binary(), Default) -> Default | ne_binary(). +-spec attachment_content_type(kz_json:object()) -> kz_term:api_ne_binary(). +-spec attachment_content_type(kz_json:object(), kz_term:ne_binary()) -> kz_term:api_ne_binary(). +-spec attachment_content_type(kz_json:object(), kz_term:ne_binary(), Default) -> Default | kz_term:ne_binary(). attachment_content_type(JObj) -> case kz_json:get_values(attachments(JObj, kz_json:new())) of {[], []} -> 'undefined'; @@ -363,11 +363,11 @@ attachment_content_type(JObj, AName) -> attachment_content_type(JObj, AName, Default) -> attachment_property(JObj, AName, <<"content_type">>, Default, fun kz_json:get_ne_binary_value/3). --spec attachment_property(kz_json:object(), ne_binary(), kz_json:path()) -> +-spec attachment_property(kz_json:object(), kz_term:ne_binary(), kz_json:path()) -> kz_json:api_json_term(). --spec attachment_property(kz_json:object(), ne_binary(), kz_json:path(), Default) -> +-spec attachment_property(kz_json:object(), kz_term:ne_binary(), kz_json:path(), Default) -> Default | kz_json:json_term(). --spec attachment_property(kz_json:object(), ne_binary(), kz_json:path(), Default, fun((kz_json:path(), kz_json:object(), Default) -> Default | kz_json:json_term())) -> +-spec attachment_property(kz_json:object(), kz_term:ne_binary(), kz_json:path(), Default, fun((kz_json:path(), kz_json:object(), Default) -> Default | kz_json:json_term())) -> Default | kz_json:json_term(). attachment_property(JObj, AName, Key) -> attachment_property(JObj, AName, Key, 'undefined'). @@ -380,7 +380,7 @@ attachment_property(JObj, AName, Key, Default, Get) when is_function(Get, 3) -> delete_attachments(JObj) -> maybe_remove_attachments(JObj, attachments(JObj)). --spec delete_attachment(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec delete_attachment(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). delete_attachment(JObj, AName) -> maybe_remove_attachment(JObj, AName, attachment(JObj, AName)). @@ -391,21 +391,21 @@ maybe_remove_attachments(JObj) -> _Attachments -> {'true', kz_json:delete_keys(?KEYS_ATTACHMENTS, JObj)} end. --spec maybe_remove_attachments(kz_json:object(), api_object()) -> kz_json:object(). +-spec maybe_remove_attachments(kz_json:object(), kz_term:api_object()) -> kz_json:object(). maybe_remove_attachments(JObj, 'undefined') -> JObj; maybe_remove_attachments(JObj, _Attachments) -> kz_json:delete_keys(?KEYS_ATTACHMENTS, JObj). --spec maybe_remove_attachment(kz_json:object(), ne_binary(), api_object()) -> kz_json:object(). +-spec maybe_remove_attachment(kz_json:object(), kz_term:ne_binary(), kz_term:api_object()) -> kz_json:object(). maybe_remove_attachment(JObj, _AName, 'undefined') -> JObj; maybe_remove_attachment(JObj, AName, _AMeta) -> kz_json:delete_keys(?KEYS_ATTACHMENTS(AName), JObj). --spec revision(kz_json:object()) -> api_binary(). +-spec revision(kz_json:object()) -> kz_term:api_binary(). revision(JObj) -> kz_json:get_first_defined([?KEY_REV, <<"rev">>], JObj). --spec set_revision(kz_json:object(), api_binary()) -> kz_json:object(). +-spec set_revision(kz_json:object(), kz_term:api_binary()) -> kz_json:object(). set_revision(JObj, Rev) -> kz_json:set_value(?KEY_REV, Rev, JObj). @@ -413,8 +413,8 @@ set_revision(JObj, Rev) -> delete_revision(JObj) -> kz_json:delete_key(?KEY_REV, JObj). --spec id(kz_json:object()) -> api_binary(). --spec id(kz_json:object(), Default) -> ne_binary() | Default. +-spec id(kz_json:object()) -> kz_term:api_binary(). +-spec id(kz_json:object(), Default) -> kz_term:ne_binary() | Default. id(JObj) -> id(JObj, 'undefined'). @@ -433,12 +433,12 @@ id(JObj, Default) -> 'false' -> Id end. --spec set_id(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec set_id(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). set_id(JObj, Id) -> kz_json:set_value(?KEY_ID, Id, JObj). --spec type(kz_json:object()) -> api_ne_binary(). --spec type(kz_json:object(), Default) -> ne_binary() | Default. +-spec type(kz_json:object()) -> kz_term:api_ne_binary(). +-spec type(kz_json:object(), Default) -> kz_term:ne_binary() | Default. type(JObj) -> type(JObj, 'undefined'). type(JObj, Default) -> @@ -448,7 +448,7 @@ type(JObj, Default) -> Default end. --spec set_type(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec set_type(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). set_type(JObj, Type) -> kz_json:set_value(?KEY_PVT_TYPE, Type, JObj). @@ -471,7 +471,7 @@ set_deleted(JObj, Bool) when is_boolean(Bool) -> is_deleted(JObj) -> kz_json:is_true(?KEY_DELETED, JObj, 'false'). --spec created(kz_json:object()) -> api_integer(). +-spec created(kz_json:object()) -> kz_term:api_integer(). -spec created(kz_json:object(), Default) -> integer() | Default. created(JObj) -> created(JObj, 'undefined'). @@ -482,51 +482,51 @@ created(JObj, Default) -> set_created(JObj, Timestamp) -> kz_json:set_value(?KEY_CREATED, Timestamp, JObj). --spec account_id(kz_json:object()) -> api_ne_binary(). --spec account_id(kz_json:object(), Default) -> ne_binary() | Default. +-spec account_id(kz_json:object()) -> kz_term:api_ne_binary(). +-spec account_id(kz_json:object(), Default) -> kz_term:ne_binary() | Default. account_id(JObj) -> account_id(JObj, 'undefined'). account_id(JObj, Default) -> kz_json:get_ne_binary_value(?KEY_ACCOUNT_ID, JObj, Default). --spec set_account_id(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec set_account_id(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). set_account_id(JObj, AccountId) -> kz_json:set_value(?KEY_ACCOUNT_ID, AccountId, JObj). --spec account_db(kz_json:object()) -> api_ne_binary(). --spec account_db(kz_json:object(), Default) -> ne_binary() | Default. +-spec account_db(kz_json:object()) -> kz_term:api_ne_binary(). +-spec account_db(kz_json:object(), Default) -> kz_term:ne_binary() | Default. account_db(JObj) -> account_db(JObj, 'undefined'). account_db(JObj, Default) -> kz_json:get_ne_binary_value(?KEY_ACCOUNT_DB, JObj, Default). --spec set_account_db(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec set_account_db(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). set_account_db(JObj, AccountDb) -> kz_json:set_value(?KEY_ACCOUNT_DB, AccountDb, JObj). --spec vsn(kz_json:object()) -> api_ne_binary(). --spec vsn(kz_json:object(), Default) -> ne_binary() | Default. +-spec vsn(kz_json:object()) -> kz_term:api_ne_binary(). +-spec vsn(kz_json:object(), Default) -> kz_term:ne_binary() | Default. vsn(JObj) -> vsn(JObj, 'undefined'). vsn(JObj, Default) -> kz_json:get_ne_binary_value(?KEY_VSN, JObj, Default). --spec set_vsn(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec set_vsn(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). set_vsn(JObj, VSN) -> kz_json:set_value(?KEY_VSN, VSN, JObj). --spec document_hash(kz_json:object()) -> ne_binary(). +-spec document_hash(kz_json:object()) -> kz_term:ne_binary(). document_hash(JObj) -> case kz_json:get_ne_binary_value(?KEY_DOCUMENT_HASH, JObj) of 'undefined' -> calculate_document_hash(JObj); Hash -> Hash end. --spec set_document_hash(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec set_document_hash(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). set_document_hash(JObj, Hash) -> kz_json:set_value(?KEY_DOCUMENT_HASH, Hash, JObj). --spec calculate_document_hash(kz_json:object()) -> ne_binary(). +-spec calculate_document_hash(kz_json:object()) -> kz_term:ne_binary(). calculate_document_hash(JObj) -> PublicJObj = public_fields(JObj), Attachments = kz_json:get_json_value(?KEY_ATTACHMENTS, JObj), diff --git a/core/kazoo/src/kz_network_utils.erl b/core/kazoo/src/kz_network_utils.erl index 80b6e83112b..82ab57870a2 100644 --- a/core/kazoo/src/kz_network_utils.erl +++ b/core/kazoo/src/kz_network_utils.erl @@ -98,7 +98,7 @@ get_hostname() -> %% %% @end %%-------------------------------------------------------------------- --spec is_ipv4(text()) -> boolean(). +-spec is_ipv4(kz_term:text()) -> boolean(). is_ipv4(Address) when is_binary(Address) -> is_ipv4(kz_term:to_list(Address)); is_ipv4(Address) when is_list(Address) -> @@ -107,7 +107,7 @@ is_ipv4(Address) when is_list(Address) -> {'error', _} -> 'false' end. --spec is_ipv6(text()) -> boolean(). +-spec is_ipv6(kz_term:text()) -> boolean(). is_ipv6(Address) when is_binary(Address) -> is_ipv6(kz_term:to_list(Address)); is_ipv6(Address) when is_list(Address) -> @@ -116,7 +116,7 @@ is_ipv6(Address) when is_list(Address) -> {'error', _} -> 'false' end. --spec is_ip(text()) -> boolean(). +-spec is_ip(kz_term:text()) -> boolean(). is_ip(Address) -> is_ipv4(Address) orelse is_ipv6(Address). @@ -202,10 +202,10 @@ prefered_inet('system') -> %% %% @end %%-------------------------------------------------------------------- --spec to_cidr(ne_binary()) -> ne_binary(). +-spec to_cidr(kz_term:ne_binary()) -> kz_term:ne_binary(). to_cidr(IP) -> to_cidr(IP, <<"32">>). --spec to_cidr(ne_binary(), ne_binary()) -> ne_binary(). +-spec to_cidr(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). to_cidr(IP, Prefix) when not is_binary(IP) -> to_cidr(kz_term:to_binary(IP), Prefix); to_cidr(IP, Prefix) when not is_binary(Prefix) -> @@ -221,7 +221,7 @@ to_cidr(IP, Prefix) -> IP end. --spec verify_cidr(text(), text()) -> boolean(). +-spec verify_cidr(kz_term:text(), kz_term:text()) -> boolean(). verify_cidr(IP, CIDR) when is_binary(IP) -> verify_cidr(kz_term:to_list(IP), CIDR); verify_cidr(IP, CIDR) when is_binary(CIDR) -> @@ -243,7 +243,7 @@ verify_cidr(IP, CIDR) -> %% {'error', _} -> 'false' %% end. -%% -spec expand_cidr(text()) -> ne_binaries(). +%% -spec expand_cidr(kz_term:text()) -> kz_term:ne_binaries(). %% expand_cidr(CIDR) when is_binary(CIDR) -> %% expand_cidr(kz_term:to_list(CIDR)); %% expand_cidr(CIDR) -> @@ -269,7 +269,7 @@ verify_cidr(IP, CIDR) -> %% %% @end %%-------------------------------------------------------------------- --spec is_rfc1918_ip(text()) -> boolean(). +-spec is_rfc1918_ip(kz_term:text()) -> boolean(). is_rfc1918_ip(IP) -> verify_cidr(IP, "192.168.0.0/16") orelse verify_cidr(IP, "10.0.0.0/8") @@ -281,11 +281,11 @@ is_rfc1918_ip(IP) -> %% %% @end %%-------------------------------------------------------------------- --spec find_nameservers(ne_binary()) -> [string()]. +-spec find_nameservers(kz_term:ne_binary()) -> [string()]. find_nameservers(Domain) -> find_nameservers(Domain, default_options()). --spec find_nameservers(ne_binary(), options()) -> [string()]. +-spec find_nameservers(kz_term:ne_binary(), options()) -> [string()]. find_nameservers(Domain, Options) -> case inet_res:lookup(kz_term:to_list(Domain), 'in', 'ns', Options) of [] -> @@ -296,7 +296,7 @@ find_nameservers(Domain, Options) -> Nameservers -> Nameservers end. --spec find_nameservers_parent(ne_binaries(), options()) -> [string()]. +-spec find_nameservers_parent(kz_term:ne_binaries(), options()) -> [string()]. find_nameservers_parent([], _) -> []; find_nameservers_parent([_, _]=Parts, Options) -> Domain = @@ -320,25 +320,25 @@ find_nameservers_parent([_|Parts], Options) -> %% %% @end %%-------------------------------------------------------------------- --spec resolve(ne_binary()) -> kz_ip_list(). +-spec resolve(kz_term:ne_binary()) -> kz_types:ip_list(). resolve(Address) -> resolve(Address, default_options()). --spec resolve(ne_binary(), options()) -> kz_ip_list(). +-spec resolve(kz_term:ne_binary(), options()) -> kz_types:ip_list(). resolve(Address, Options) -> case binary:split(Address, <<":">>) of [Addr|_Port] -> maybe_is_ip(Addr, Options); _ -> maybe_is_ip(Address, Options) end. --spec maybe_is_ip(ne_binary(), options()) -> ne_binaries(). +-spec maybe_is_ip(kz_term:ne_binary(), options()) -> kz_term:ne_binaries(). maybe_is_ip(Address, Options) -> case is_ip(Address) of 'true' -> [Address]; 'false' -> maybe_resolve_srv_records(Address, Options) end. --spec maybe_resolve_srv_records(ne_binary(), options()) -> ne_binaries(). +-spec maybe_resolve_srv_records(kz_term:ne_binary(), options()) -> kz_term:ne_binaries(). maybe_resolve_srv_records(Address, Options) -> Domain = <<"_sip._udp.", Address/binary>>, case inet_res:lookup(kz_term:to_list(Domain), 'in', 'srv', Options) of @@ -346,20 +346,20 @@ maybe_resolve_srv_records(Address, Options) -> SRVs -> maybe_resolve_a_records([D || {_, _, _, D} <- SRVs], Options) end. --spec maybe_resolve_a_records(ne_binaries(), options()) -> ne_binaries(). +-spec maybe_resolve_a_records(kz_term:ne_binaries(), options()) -> kz_term:ne_binaries(). maybe_resolve_a_records(Domains, Options) -> lists:foldr(fun(Domain, IPs) -> maybe_resolve_fold(Domain, IPs, Options) end, [], Domains). --spec maybe_resolve_fold(ne_binary(), ne_binaries(), options()) -> ne_binaries(). +-spec maybe_resolve_fold(kz_term:ne_binary(), kz_term:ne_binaries(), options()) -> kz_term:ne_binaries(). maybe_resolve_fold(Domain, IPs, Options) -> case is_ip(Domain) of 'true' -> [Domain]; 'false' -> resolve_a_record(kz_term:to_list(Domain), IPs, Options) end. --spec resolve_a_record(string(), ne_binaries(), options()) -> ne_binaries(). +-spec resolve_a_record(string(), kz_term:ne_binaries(), options()) -> kz_term:ne_binaries(). resolve_a_record(Domain, IPs, Options) -> case inet_res:lookup(Domain, 'in', 'a', Options) of [] -> @@ -369,7 +369,7 @@ resolve_a_record(Domain, IPs, Options) -> lists:foldr(fun resolve_a_record_fold/2, IPs, Addresses) end. --spec resolve_a_record_fold(inet:ip4_address(), ne_binaries()) -> ne_binaries(). +-spec resolve_a_record_fold(inet:ip4_address(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). resolve_a_record_fold(IPTuple, I) -> [iptuple_to_binary(IPTuple) | I]. @@ -379,7 +379,7 @@ resolve_a_record_fold(IPTuple, I) -> %% %% @end %%-------------------------------------------------------------------- --spec iptuple_to_binary(inet:ip4_address() | inet:ipv6_address()) -> ne_binary(). +-spec iptuple_to_binary(inet:ip4_address() | inet:ipv6_address()) -> kz_term:ne_binary(). iptuple_to_binary({A,B,C,D}) -> <<(kz_term:to_binary(A))/binary, "." ,(kz_term:to_binary(B))/binary, "." @@ -400,7 +400,7 @@ iptuple_to_binary({_I1, _I2, _I3, _I4, _I5, _I6, _I7, _I8}=T) -> to_hex(I) -> kz_term:to_lower_binary(integer_to_binary(I, 16)). --spec srvtuple_to_binary(srvtuple()) -> ne_binary(). +-spec srvtuple_to_binary(srvtuple()) -> kz_term:ne_binary(). srvtuple_to_binary({Priority, Weight, Port, Domain}) -> <<(kz_term:to_binary(Priority))/binary, " " ,(kz_term:to_binary(Weight))/binary, " " @@ -408,7 +408,7 @@ srvtuple_to_binary({Priority, Weight, Port, Domain}) -> ,(kz_binary:strip_right(kz_term:to_binary(Domain), $.))/binary >>. --spec naptrtuple_to_binary(naptrtuple()) -> ne_binary(). +-spec naptrtuple_to_binary(naptrtuple()) -> kz_term:ne_binary(). naptrtuple_to_binary({Order, Preference, Flags, Services, Regexp, Domain}) -> <<(kz_term:to_binary(Order))/binary, " " ,(kz_term:to_binary(Preference))/binary, " " @@ -418,7 +418,7 @@ naptrtuple_to_binary({Order, Preference, Flags, Services, Regexp, Domain}) -> ,(kz_binary:strip_right(kz_term:to_binary(Domain), $.))/binary >>. --spec mxtuple_to_binary(mxtuple()) -> ne_binary(). +-spec mxtuple_to_binary(mxtuple()) -> kz_term:ne_binary(). mxtuple_to_binary({_Priority, Domain}) -> <<(kz_binary:strip_right(kz_term:to_binary(Domain), $.))/binary>>. @@ -447,13 +447,13 @@ pretty_print_bytes(Bytes) -> %% %% @end %%-------------------------------------------------------------------- --spec lookup_dns(ne_binary(), atom()) -> +-spec lookup_dns(kz_term:ne_binary(), atom()) -> {'ok', [inet_res:dns_data()]}. %% See kernel/src/inet_dns.hrl, the S_* macros for values for Type lookup_dns(Hostname, Type) -> lookup_dns(Hostname, Type, default_options()). --spec lookup_dns(ne_binary(), atom(), options()) -> +-spec lookup_dns(kz_term:ne_binary(), atom(), options()) -> {'ok', [inet_res:dns_data()]}. lookup_dns(Hostname, Type, Options) -> {'ok', inet_res:lookup(kz_term:to_list(Hostname), 'in', Type, Options)}. diff --git a/core/kazoo/src/kz_util.erl b/core/kazoo/src/kz_util.erl index ca75e120fc7..c8d2ae90f3b 100644 --- a/core/kazoo/src/kz_util.erl +++ b/core/kazoo/src/kz_util.erl @@ -144,7 +144,7 @@ log_stacktrace_mfa(M, F, Args, Info) -> | 'notice' | 'info' | 'debug' - | ne_binary(). + | kz_term:ne_binary(). -spec change_console_log_level(log_level()) -> 'ok'. change_console_log_level(L) when is_atom(L) -> @@ -178,9 +178,9 @@ change_syslog_log_level(L) -> %% @end %%-------------------------------------------------------------------- -type account_format() :: 'unencoded' | 'encoded' | 'raw'. --spec format_account_id(api_binary()) -> api_binary(). --spec format_account_id(api_binary(), account_format()) -> api_binary(); - (api_binary(), gregorian_seconds()) -> api_binary(). %% MODb! +-spec format_account_id(kz_term:api_binary()) -> kz_term:api_binary(). +-spec format_account_id(kz_term:api_binary(), account_format()) -> kz_term:api_binary(); + (kz_term:api_binary(), kz_time:gregorian_seconds()) -> kz_term:api_binary(). %% MODb! format_account_id(Account) -> format_account_id(Account, 'raw'). @@ -212,7 +212,7 @@ format_account_id(AccountId, 'encoded') -> %% @private %% Returns account_id() | any() %% Passes input along if not account_id() | account_db() | account_db_unencoded(). --spec raw_account_id(ne_binary()) -> ne_binary(). +-spec raw_account_id(kz_term:ne_binary()) -> kz_term:ne_binary(). raw_account_id(?MATCH_ACCOUNT_RAW(AccountId)) -> AccountId; raw_account_id(?MATCH_ACCOUNT_UNENCODED(A, B, Rest)) -> @@ -244,7 +244,7 @@ raw_account_id(Other) -> %% @private %% (modb()) -> modb_id() when modb() :: modb_id() | modb_db() | modb_db_unencoded() %% Crashes if given anything else. --spec raw_account_modb(ne_binary()) -> ne_binary(). +-spec raw_account_modb(kz_term:ne_binary()) -> kz_term:ne_binary(). raw_account_modb(?MATCH_MODB_SUFFIX_RAW(_, _, _) = AccountId) -> AccountId; raw_account_modb(?MATCH_MODB_SUFFIX_ENCODED(A, B, Rest, Year, Month)) -> @@ -259,9 +259,9 @@ raw_account_modb(?MATCH_MODB_SUFFIX_UNENCODED(A, B, Rest, Year, Month)) -> %% unencoded or 'raw' format. %% @end %%-------------------------------------------------------------------- --spec format_resource_selectors_id(api_binary()) -> api_binary(). --spec format_resource_selectors_id(api_binary(), account_format()) -> api_binary(); - (api_binary(), gregorian_seconds()) -> api_binary(). %% MODb! +-spec format_resource_selectors_id(kz_term:api_binary()) -> kz_term:api_binary(). +-spec format_resource_selectors_id(kz_term:api_binary(), account_format()) -> kz_term:api_binary(); + (kz_term:api_binary(), kz_time:gregorian_seconds()) -> kz_term:api_binary(). %% MODb! format_resource_selectors_id(Account) -> format_resource_selectors_id(Account, 'raw'). @@ -293,7 +293,7 @@ format_resource_selectors_id(AccountId, 'encoded') -> %% @private %% Returns account_id() | any() %% Passes input along if not account_id() | account_db() | account_db_unencoded(). --spec raw_resource_selectors_id(ne_binary()) -> ne_binary(). +-spec raw_resource_selectors_id(kz_term:ne_binary()) -> kz_term:ne_binary(). raw_resource_selectors_id(?MATCH_RESOURCE_SELECTORS_RAW(AccountId)) -> AccountId; raw_resource_selectors_id(?MATCH_RESOURCE_SELECTORS_UNENCODED(A, B, Rest)) -> @@ -314,7 +314,7 @@ raw_resource_selectors_id(Other) -> %% Given a representation of an account resource_selectors return it in a 'encoded', %% @end %%-------------------------------------------------------------------- --spec format_resource_selectors_db(api_binary()) -> api_binary(). +-spec format_resource_selectors_db(kz_term:api_binary()) -> kz_term:api_binary(). format_resource_selectors_db(AccountId) -> format_resource_selectors_id(AccountId, 'encoded'). @@ -325,8 +325,8 @@ format_resource_selectors_db(AccountId) -> %% Note: accepts MODbs as well as account IDs/DBs %% @end %%-------------------------------------------------------------------- --spec format_account_id(api_binary(), kz_year() | ne_binary(), kz_month() | ne_binary()) -> - api_binary(). +-spec format_account_id(kz_term:api_binary(), kz_time:year() | kz_term:ne_binary(), kz_time:month() | kz_term:ne_binary()) -> + kz_term:api_binary(). format_account_id('undefined', _Year, _Month) -> 'undefined'; format_account_id(AccountId, Year, Month) when not is_integer(Year) -> format_account_id(AccountId, kz_term:to_integer(Year), Month); @@ -344,10 +344,10 @@ format_account_id(Account, Year, Month) when is_integer(Year), %% Note: accepts MODbs as well as account IDs/DBs %% @end %%-------------------------------------------------------------------- --spec format_account_mod_id(api_binary()) -> api_binary(). --spec format_account_mod_id(api_binary(), gregorian_seconds() | kz_now()) -> api_binary(). --spec format_account_mod_id(api_binary(), kz_year() | ne_binary(), kz_month() | ne_binary()) -> - api_binary(). +-spec format_account_mod_id(kz_term:api_binary()) -> kz_term:api_binary(). +-spec format_account_mod_id(kz_term:api_binary(), kz_time:gregorian_seconds() | kz_time:now()) -> kz_term:api_binary(). +-spec format_account_mod_id(kz_term:api_binary(), kz_time:year() | kz_term:ne_binary(), kz_time:month() | kz_term:ne_binary()) -> + kz_term:api_binary(). format_account_mod_id(Account) -> format_account_mod_id(Account, os:timestamp()). @@ -369,7 +369,7 @@ format_account_mod_id(AccountId, Year, Month) -> %% Note: accepts MODbs as well as account IDs/DBs %% @end %%-------------------------------------------------------------------- --spec format_account_db(api_binary()) -> api_binary(). +-spec format_account_db(kz_term:api_binary()) -> kz_term:api_binary(). format_account_db(AccountId) -> format_account_id(AccountId, 'encoded'). @@ -380,8 +380,8 @@ format_account_db(AccountId) -> %% Note: crashes if given anything but an MODb (in any format). %% @end %%-------------------------------------------------------------------- --spec format_account_modb(ne_binary()) -> ne_binary(). --spec format_account_modb(ne_binary(), account_format()) -> ne_binary(). +-spec format_account_modb(kz_term:ne_binary()) -> kz_term:ne_binary(). +-spec format_account_modb(kz_term:ne_binary(), account_format()) -> kz_term:ne_binary(). format_account_modb(AccountId) -> format_account_modb(AccountId, 'raw'). format_account_modb(AccountId, 'raw') -> @@ -402,7 +402,7 @@ format_account_modb(AccountId, 'encoded') -> %% This can possibly return an empty binary. %% @end %%-------------------------------------------------------------------- --spec normalize_account_name(api_binary()) -> api_binary(). +-spec normalize_account_name(kz_term:api_binary()) -> kz_term:api_binary(). normalize_account_name('undefined') -> 'undefined'; normalize_account_name(AccountName) -> << <> @@ -429,8 +429,8 @@ is_alphanumeric(_) -> %% its own hierarchy. %% @end %%-------------------------------------------------------------------- --spec is_in_account_hierarchy(api_binary(), api_binary()) -> boolean(). --spec is_in_account_hierarchy(api_binary(), api_binary(), boolean()) -> boolean(). +-spec is_in_account_hierarchy(kz_term:api_binary(), kz_term:api_binary()) -> boolean(). +-spec is_in_account_hierarchy(kz_term:api_binary(), kz_term:api_binary(), boolean()) -> boolean(). is_in_account_hierarchy(CheckFor, InAccount) -> is_in_account_hierarchy(CheckFor, InAccount, 'false'). @@ -469,7 +469,7 @@ is_in_account_hierarchy(CheckFor, InAccount, IncludeSelf) -> %% %% @end %%-------------------------------------------------------------------- --spec is_system_admin(api_binary()) -> boolean(). +-spec is_system_admin(kz_term:api_binary()) -> boolean(). is_system_admin('undefined') -> 'false'; is_system_admin(Account) -> case kz_account:fetch(Account) of @@ -488,7 +488,7 @@ is_system_admin(Account) -> %% 'false'. %% @end %%-------------------------------------------------------------------- --spec is_account_enabled(api_binary()) -> boolean(). +-spec is_account_enabled(kz_term:api_binary()) -> boolean(). is_account_enabled('undefined') -> 'false'; is_account_enabled(Account) -> case kz_account:fetch(Account) of @@ -499,7 +499,7 @@ is_account_enabled(Account) -> kz_account:is_enabled(JObj) end. --spec is_account_expired(api_binary()) -> 'false' | {'true', gregorian_seconds()}. +-spec is_account_expired(kz_term:api_binary()) -> 'false' | {'true', kz_time:gregorian_seconds()}. is_account_expired('undefined') -> 'false'; is_account_expired(Account) -> case kz_account:fetch(Account) of @@ -515,7 +515,7 @@ is_account_expired(Account) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec maybe_disable_account(ne_binary()) -> +-spec maybe_disable_account(kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. maybe_disable_account(Account) -> @@ -530,7 +530,7 @@ maybe_disable_account(Account) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec disable_account(ne_binary()) -> +-spec disable_account(kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. disable_account(Account) -> @@ -541,7 +541,7 @@ disable_account(Account) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec enable_account(ne_binary()) -> +-spec enable_account(kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. enable_account(Account) -> @@ -552,7 +552,7 @@ enable_account(Account) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec set_superduper_admin(ne_binary(), boolean()) -> +-spec set_superduper_admin(kz_term:ne_binary(), boolean()) -> {'ok', kz_json:object()} | {'error', any()}. set_superduper_admin(Account, IsAdmin) -> @@ -563,7 +563,7 @@ set_superduper_admin(Account, IsAdmin) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec set_allow_number_additions(ne_binary(), boolean()) -> +-spec set_allow_number_additions(kz_term:ne_binary(), boolean()) -> {'ok', kz_json:object()} | {'error', any()}. set_allow_number_additions(Account, IsAllowed) -> @@ -577,7 +577,7 @@ set_allow_number_additions(Account, IsAllowed) -> -spec account_update(kz_account:doc()) -> {'ok', kz_json:object()} | {'error', any()}. --spec account_update(ne_binary(), function()) -> 'ok' | {'error', any()}. +-spec account_update(kz_term:ne_binary(), function()) -> 'ok' | {'error', any()}. account_update(AccountJObj) -> AccountDb = kz_doc:account_db(AccountJObj), case kz_datamgr:ensure_saved(AccountDb, AccountJObj) of @@ -623,7 +623,7 @@ try_load_module(Name) -> %% dictionary, failing that the Msg-ID and finally a generic %% @end %%-------------------------------------------------------------------- --spec put_callid(kz_json:object() | kz_proplist() | ne_binary() | atom()) -> 'ok'. +-spec put_callid(kz_json:object() | kz_term:proplist() | kz_term:ne_binary() | atom()) -> 'ok'. put_callid(?NE_BINARY = CallId) -> _ = kz_log_md_put('callid', CallId), _ = erlang:put('callid', CallId), @@ -635,16 +635,16 @@ put_callid(Atom) when is_atom(Atom) -> put_callid(APITerm) -> put_callid(find_callid(APITerm)). --spec get_callid() -> ne_binary(). +-spec get_callid() -> kz_term:ne_binary(). get_callid() -> erlang:get('callid'). --spec find_callid(api_terms()) -> api_binary(). +-spec find_callid(kz_term:api_terms()) -> kz_term:api_binary(). find_callid(APITerm) when is_list(APITerm) -> find_callid(APITerm, fun props:get_first_defined/3); find_callid(APITerm) -> find_callid(APITerm, fun kz_json:get_first_defined/3). --spec find_callid(api_terms(), fun()) -> api_binary(). +-spec find_callid(kz_term:api_terms(), fun()) -> kz_term:api_binary(). find_callid(APITerm, GetFun) -> GetFun([?KEY_LOG_ID, ?KEY_API_CALL_ID, ?KEY_MSG_ID] ,APITerm @@ -711,7 +711,7 @@ spawn_link(Fun) -> Fun() end). --spec spawn_monitor(fun(), list()) -> pid_ref(). +-spec spawn_monitor(fun(), list()) -> kz_term:pid_ref(). spawn_monitor(Fun, Arguments) -> CallId = get_callid(), erlang:spawn_monitor(fun () -> @@ -720,11 +720,11 @@ spawn_monitor(Fun, Arguments) -> end). --spec set_startup() -> api_seconds(). +-spec set_startup() -> kz_time:api_seconds(). set_startup() -> put('$startup', kz_time:now_s()). --spec startup() -> api_seconds(). +-spec startup() -> kz_time:api_seconds(). startup() -> get('$startup'). @@ -734,7 +734,7 @@ startup() -> %% Given an object, extract the category and name into a tuple %% @end %%-------------------------------------------------------------------- --spec get_event_type(api_terms()) -> {api_binary(), api_binary()}. +-spec get_event_type(kz_term:api_terms()) -> {kz_term:api_binary(), kz_term:api_binary()}. get_event_type(Props) when is_list(Props) -> {props:get_value(<<"Event-Category">>, Props) ,props:get_value(<<"Event-Name">>, Props) @@ -744,7 +744,7 @@ get_event_type(JObj) -> ,kz_json:get_value(<<"Event-Name">>, JObj) }. --spec uri_decode(text()) -> text(). +-spec uri_decode(kz_term:text()) -> kz_term:text(). uri_decode(Binary) when is_binary(Binary) -> kz_term:to_binary(http_uri:decode(kz_term:to_list(Binary))); uri_decode(String) when is_list(String) -> @@ -752,7 +752,7 @@ uri_decode(String) when is_list(String) -> uri_decode(Atom) when is_atom(Atom) -> kz_term:to_atom(http_uri:decode(kz_term:to_list(Atom)), 'true'). --spec uri_encode(text()) -> text(). +-spec uri_encode(kz_term:text()) -> kz_term:text(). uri_encode(Binary) when is_binary(Binary) -> kz_term:to_binary(http_uri:encode(kz_term:to_list(Binary))); uri_encode(String) when is_list(String) -> @@ -760,7 +760,7 @@ uri_encode(String) when is_list(String) -> uri_encode(Atom) when is_atom(Atom) -> kz_term:to_atom(http_uri:encode(kz_term:to_list(Atom)), 'true'). --spec resolve_uri(nonempty_string() | ne_binary(), nonempty_string() | api_ne_binary()) -> ne_binary(). +-spec resolve_uri(nonempty_string() | kz_term:ne_binary(), nonempty_string() | kz_term:api_ne_binary()) -> kz_term:ne_binary(). resolve_uri(Raw, 'undefined') -> kz_term:to_binary(Raw); resolve_uri(_Raw, <<"http", _/binary>> = Abs) -> Abs; resolve_uri(<<_/binary>> = RawPath, <<_/binary>> = Relative) -> @@ -769,7 +769,7 @@ resolve_uri(<<_/binary>> = RawPath, <<_/binary>> = Relative) -> resolve_uri(RawPath, Relative) -> resolve_uri(kz_term:to_binary(RawPath), kz_term:to_binary(Relative)). --spec resolve_uri_path(ne_binary(), ne_binary()) -> ne_binaries(). +-spec resolve_uri_path(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binaries(). resolve_uri_path(RawPath, Relative) -> PathTokensRev = lists:reverse(binary:split(RawPath, <<"/">>, ['global'])), UrlTokens = binary:split(Relative, <<"/">>, ['global']), @@ -777,7 +777,7 @@ resolve_uri_path(RawPath, Relative) -> lists:foldl(fun resolve_uri_fold/2, PathTokensRev, UrlTokens) ). --spec resolve_uri_fold(ne_binary(), ne_binaries()) -> ne_binaries(). +-spec resolve_uri_fold(kz_term:ne_binary(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). resolve_uri_fold(<<"..">>, []) -> []; resolve_uri_fold(<<"..">>, [_ | PathTokens]) -> PathTokens; resolve_uri_fold(<<".">>, PathTokens) -> PathTokens; @@ -793,14 +793,14 @@ resolve_uri_fold(Segment, [LastToken|DirTokens]=PathTokens) -> [Segment|DirTokens] end. --spec uri(ne_binary(), ne_binaries()) -> ne_binary(). +-spec uri(kz_term:ne_binary(), kz_term:ne_binaries()) -> kz_term:ne_binary(). uri(BaseUrl, Tokens) -> [Pro, Url] = binary:split(BaseUrl, <<"://">>), Uri = filename:join([Url | Tokens]), <>. %% fetch and cache the kazoo version from the VERSION file in kazoo's root folder --spec kazoo_version() -> ne_binary(). +-spec kazoo_version() -> kz_term:ne_binary(). kazoo_version() -> {_, _, Version} = get_app('kazoo'), kz_term:to_binary(Version). @@ -810,8 +810,8 @@ write_pid(FileName) -> file:write_file(FileName, io_lib:format("~s", [os:getpid()]), ['write', 'binary']). --spec pretty_print_bytes(non_neg_integer()) -> ne_binary(). --spec pretty_print_bytes(non_neg_integer(), 'full' | 'truncated') -> ne_binary(). +-spec pretty_print_bytes(non_neg_integer()) -> kz_term:ne_binary(). +-spec pretty_print_bytes(non_neg_integer(), 'full' | 'truncated') -> kz_term:ne_binary(). pretty_print_bytes(Bytes) -> pretty_print_bytes(Bytes, 'full'). @@ -898,7 +898,7 @@ delete_dir(Dir) -> F = fun(D) -> 'ok' = file:del_dir(D) end, lists:foreach(F, del_all_files([Dir], [])). --spec del_all_files(strings(), strings()) -> strings(). +-spec del_all_files(kz_term:strings(), kz_term:strings()) -> kz_term:strings(). del_all_files([], EmptyDirs) -> EmptyDirs; del_all_files([Dir | T], EmptyDirs) -> {'ok', FilesInDir} = file:list_dir(Dir), @@ -940,7 +940,7 @@ process_fold(App, _, M, _) -> {App, M}. %% @doc %% For core apps that want to know which app is calling. %% @end --spec calling_app() -> ne_binary(). +-spec calling_app() -> kz_term:ne_binary(). calling_app() -> Modules = erlang:process_info(self(),current_stacktrace), {'current_stacktrace', [_Me, {Module, _, _, _} | Start]} = Modules, @@ -950,7 +950,7 @@ calling_app() -> {Parent, _MFA} -> kz_term:to_binary(Parent) end. --spec calling_app_version() -> {ne_binary(), ne_binary()}. +-spec calling_app_version() -> {kz_term:ne_binary(), kz_term:ne_binary()}. calling_app_version() -> Modules = erlang:process_info(self(),current_stacktrace), {'current_stacktrace', [_Me, {Module, _, _, _} | Start]} = Modules, @@ -983,7 +983,7 @@ calling_process() -> ,line => Line }. --spec get_app(atom() | ne_binary()) -> {atom(), string(), string()} | 'undefined'. +-spec get_app(atom() | kz_term:ne_binary()) -> {atom(), string(), string()} | 'undefined'. get_app(<<_/binary>> = AppName) -> get_app(kz_term:to_atom(AppName)); get_app(AppName) -> @@ -992,7 +992,7 @@ get_app(AppName) -> [Ret | _] -> Ret end. --spec application_version(atom()) -> ne_binary(). +-spec application_version(atom()) -> kz_term:ne_binary(). application_version(Application) -> {'ok', Vsn} = application:get_key(Application, 'vsn'), kz_term:to_binary(Vsn). @@ -1001,7 +1001,7 @@ application_version(Application) -> %% Like lists:usort/1 but preserves original ordering. %% Time: O(nlog(n)). %% @end --spec uniq([kz_proplist()]) -> kz_proplist(). +-spec uniq([kz_term:proplist()]) -> kz_term:proplist(). uniq(KVs) when is_list(KVs) -> uniq(KVs, sets:new(), []). uniq([], _, L) -> lists:reverse(L); uniq([{K,_}=KV|Rest], S, L) -> diff --git a/core/kazoo_amqp/include/kz_amqp.hrl b/core/kazoo_amqp/include/kz_amqp.hrl index 7cba58824e6..69f97503e10 100644 --- a/core/kazoo_amqp/include/kz_amqp.hrl +++ b/core/kazoo_amqp/include/kz_amqp.hrl @@ -171,24 +171,24 @@ #'confirm.select_ok'{} | #'basic.cancel_ok'{}. -type command_ret() :: 'ok' | - {'ok', ne_binary() | kz_command_ret_ok()} | + {'ok', kz_term:ne_binary() | kz_command_ret_ok()} | {'error', any()}. -define(KZ_AMQP_ETS, 'kz_amqp_ets'). -type kz_amqp_type() :: 'sticky' | 'float'. --record(kz_amqp_assignment, {timestamp = os:timestamp() :: kz_now() | '_' - ,consumer :: api_pid() | '$2' | '_' - ,consumer_ref :: api_reference() | '_' +-record(kz_amqp_assignment, {timestamp = os:timestamp() :: kz_time:now() | '_' + ,consumer :: kz_term:api_pid() | '$2' | '_' + ,consumer_ref :: kz_term:api_reference() | '_' ,type = 'float' :: kz_amqp_type() | 'undefined' | '_' - ,channel :: api_pid() | '$1' | '_' - ,channel_ref :: api_reference() | '_' - ,connection :: api_pid() | '$1' | '_' - ,broker :: api_binary() | '$1' | '_' - ,assigned :: kz_timeout() | 'undefined' | '_' + ,channel :: kz_term:api_pid() | '$1' | '_' + ,channel_ref :: kz_term:api_reference() | '_' + ,connection :: kz_term:api_pid() | '$1' | '_' + ,broker :: kz_term:api_binary() | '$1' | '_' + ,assigned :: timeout() | 'undefined' | '_' ,reconnect = 'false' :: boolean() | '_' - ,watchers = sets:new() :: sets:set() | pids() | '_' + ,watchers = sets:new() :: sets:set() | kz_term:pids() | '_' }). -type kz_amqp_assignment() :: #kz_amqp_assignment{}. @@ -196,28 +196,28 @@ -type kz_exchanges() :: [#'exchange.declare'{}]. --record(kz_amqp_connection, {broker :: ne_binary() | '_' +-record(kz_amqp_connection, {broker :: kz_term:ne_binary() | '_' ,params :: #'amqp_params_direct'{} | #'amqp_params_network'{} | '_' - ,manager :: api_pid() | '_' - ,connection :: api_pid() | '_' - ,connection_ref :: api_reference() | '_' - ,channel :: api_pid() | '$1' | '_' - ,channel_ref :: api_reference() | '$1' | '_' - ,reconnect_ref :: api_reference() | '_' + ,manager :: kz_term:api_pid() | '_' + ,connection :: kz_term:api_pid() | '_' + ,connection_ref :: kz_term:api_reference() | '_' + ,channel :: kz_term:api_pid() | '$1' | '_' + ,channel_ref :: kz_term:api_reference() | '$1' | '_' + ,reconnect_ref :: kz_term:api_reference() | '_' ,available = 'false' :: boolean() | '_' ,exchanges_initialized = 'false' :: boolean() | '_' ,prechannels_initialized = 'false' :: boolean() | '_' - ,started = os:timestamp() :: kz_now() | '_' + ,started = os:timestamp() :: kz_time:now() | '_' ,tags = [] :: list() | '_' ,hidden = 'false' :: boolean() | '_' }). -type kz_amqp_connection() :: #kz_amqp_connection{}. --record(kz_amqp_connections, {connection :: api_pid() | '$1' | '_' - ,connection_ref :: api_reference() | '_' - ,broker :: ne_binary() | '$1' | '$2' | '_' +-record(kz_amqp_connections, {connection :: kz_term:api_pid() | '$1' | '_' + ,connection_ref :: kz_term:api_reference() | '_' + ,broker :: kz_term:ne_binary() | '$1' | '$2' | '_' ,available='false' :: boolean() | '$1' | '$2' | '_' - ,timestamp=os:timestamp() :: kz_now() | '_' + ,timestamp=os:timestamp() :: kz_time:now() | '_' ,zone='local' :: atom() | '$1' | '_' ,manager=self() :: pid() | '_' ,tags = [] :: list() | '_' diff --git a/core/kazoo_amqp/include/kz_api.hrl b/core/kazoo_amqp/include/kz_api.hrl index cf4ea75920d..0014e6b8756 100644 --- a/core/kazoo_amqp/include/kz_api.hrl +++ b/core/kazoo_amqp/include/kz_api.hrl @@ -3,20 +3,20 @@ -include_lib("kazoo/include/kz_api_literals.hrl"). -type api_formatter_return() :: {'ok', iolist()} | {'error', string()}. --type api_headers() :: ne_binaries() | [ne_binary() | ne_binaries()]. +-type api_headers() :: kz_term:ne_binaries() | [kz_term:ne_binary() | kz_term:ne_binaries()]. --type api_types() :: [{ne_binary(), fun()}]. --type valid_value() :: ne_binary() | integer(). --type api_valid_values() :: [{ne_binary(), valid_value() | [valid_value()]}]. +-type api_types() :: [{kz_term:ne_binary(), fun()}]. +-type valid_value() :: kz_term:ne_binary() | integer(). +-type api_valid_values() :: [{kz_term:ne_binary(), valid_value() | [valid_value()]}]. --record(kapi_definition, {name :: ne_binary() - ,friendly_name :: ne_binary() - ,description :: ne_binary() - ,build_fun :: fun((api_terms()) -> api_formatter_return()) - ,validate_fun :: fun((api_terms()) -> boolean()) +-record(kapi_definition, {name :: kz_term:ne_binary() + ,friendly_name :: kz_term:ne_binary() + ,description :: kz_term:ne_binary() + ,build_fun :: fun((kz_term:api_terms()) -> api_formatter_return()) + ,validate_fun :: fun((kz_term:api_terms()) -> boolean()) ,publish_fun :: fun((...) -> 'ok') - ,binding = 'undefined' :: api_ne_binary() - ,restrict_to = 'undefined' :: api_atom() + ,binding = 'undefined' :: kz_term:api_ne_binary() + ,restrict_to = 'undefined' :: kz_term:api_atom() ,required_headers :: api_headers() ,optional_headers :: api_headers() ,values :: api_valid_values() diff --git a/core/kazoo_amqp/src/amqp_util.erl b/core/kazoo_amqp/src/amqp_util.erl index d8998015562..96288126e53 100644 --- a/core/kazoo_amqp/src/amqp_util.erl +++ b/core/kazoo_amqp/src/amqp_util.erl @@ -169,9 +169,9 @@ -define(P_GET(K, Prop), props:get_value(K, Prop)). -define(P_GET(K, Prop, D), props:get_value(K, Prop, D)). --type amqp_payload() :: iolist() | ne_binary(). +-type amqp_payload() :: iolist() | kz_term:ne_binary(). --type amqp_property() :: {ne_binary(), atom(), any()}. +-type amqp_property() :: {kz_term:ne_binary(), atom(), any()}. -type amqp_properties() :: [amqp_property()]. %%------------------------------------------------------------------------------ @@ -180,9 +180,9 @@ %% Publish AMQP messages %% @end %%------------------------------------------------------------------------------ --spec targeted_publish(ne_binary(), amqp_payload()) -> 'ok'. --spec targeted_publish(ne_binary(), amqp_payload(), ne_binary()) -> 'ok'. --spec targeted_publish(ne_binary(), amqp_payload(), ne_binary(), kz_proplist()) -> 'ok'. +-spec targeted_publish(kz_term:ne_binary(), amqp_payload()) -> 'ok'. +-spec targeted_publish(kz_term:ne_binary(), amqp_payload(), kz_term:ne_binary()) -> 'ok'. +-spec targeted_publish(kz_term:ne_binary(), amqp_payload(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. targeted_publish(Queue, Payload) -> targeted_publish(Queue, Payload, ?DEFAULT_CONTENT_TYPE). targeted_publish(?NE_BINARY = Queue, Payload, ContentType) -> @@ -191,15 +191,15 @@ targeted_publish(?NE_BINARY = Queue, Payload, ContentType, Options) -> basic_publish(?EXCHANGE_TARGETED, Queue, Payload, ContentType, Options). -spec nodes_publish(amqp_payload()) -> 'ok'. --spec nodes_publish(amqp_payload(), ne_binary()) -> 'ok'. +-spec nodes_publish(amqp_payload(), kz_term:ne_binary()) -> 'ok'. nodes_publish(Payload) -> nodes_publish(Payload, ?DEFAULT_CONTENT_TYPE). nodes_publish(Payload, ContentType) -> basic_publish(?EXCHANGE_NODES, <<>>, Payload, ContentType, ['maybe_publish']). --spec kapps_publish(ne_binary(), amqp_payload()) -> 'ok'. --spec kapps_publish(ne_binary(), amqp_payload(), ne_binary()) -> 'ok'. --spec kapps_publish(ne_binary(), amqp_payload(), ne_binary(), kz_proplist()) -> 'ok'. +-spec kapps_publish(kz_term:ne_binary(), amqp_payload()) -> 'ok'. +-spec kapps_publish(kz_term:ne_binary(), amqp_payload(), kz_term:ne_binary()) -> 'ok'. +-spec kapps_publish(kz_term:ne_binary(), amqp_payload(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. kapps_publish(Routing, Payload) -> kapps_publish(Routing, Payload, ?DEFAULT_CONTENT_TYPE). kapps_publish(Routing, Payload, ContentType) -> @@ -207,9 +207,9 @@ kapps_publish(Routing, Payload, ContentType) -> kapps_publish(Routing, Payload, ContentType, Opts) -> basic_publish(?EXCHANGE_KAPPS, Routing, Payload, ContentType, Opts). --spec presence_publish(ne_binary(), amqp_payload()) -> 'ok'. --spec presence_publish(ne_binary(), amqp_payload(), ne_binary()) -> 'ok'. --spec presence_publish(ne_binary(), amqp_payload(), ne_binary(), kz_proplist()) -> 'ok'. +-spec presence_publish(kz_term:ne_binary(), amqp_payload()) -> 'ok'. +-spec presence_publish(kz_term:ne_binary(), amqp_payload(), kz_term:ne_binary()) -> 'ok'. +-spec presence_publish(kz_term:ne_binary(), amqp_payload(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. presence_publish(Routing, Payload) -> presence_publish(Routing, Payload, ?DEFAULT_CONTENT_TYPE). presence_publish(Routing, Payload, ContentType) -> @@ -217,9 +217,9 @@ presence_publish(Routing, Payload, ContentType) -> presence_publish(Routing, Payload, ContentType, Opts) -> basic_publish(?EXCHANGE_PRESENCE, Routing, Payload, ContentType, Opts). --spec notifications_publish(ne_binary(), amqp_payload()) -> 'ok'. --spec notifications_publish(ne_binary(), amqp_payload(), ne_binary()) -> 'ok'. --spec notifications_publish(ne_binary(), amqp_payload(), ne_binary(), kz_proplist()) -> 'ok'. +-spec notifications_publish(kz_term:ne_binary(), amqp_payload()) -> 'ok'. +-spec notifications_publish(kz_term:ne_binary(), amqp_payload(), kz_term:ne_binary()) -> 'ok'. +-spec notifications_publish(kz_term:ne_binary(), amqp_payload(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. notifications_publish(Routing, Payload) -> notifications_publish(Routing, Payload, ?DEFAULT_CONTENT_TYPE). notifications_publish(Routing, Payload, ContentType) -> @@ -227,9 +227,9 @@ notifications_publish(Routing, Payload, ContentType) -> notifications_publish(Routing, Payload, ContentType, Opts) -> basic_publish(?EXCHANGE_NOTIFICATIONS, Routing, Payload, ContentType, Opts). --spec sysconf_publish(ne_binary(), amqp_payload()) -> 'ok'. --spec sysconf_publish(ne_binary(), amqp_payload(), ne_binary()) -> 'ok'. --spec sysconf_publish(ne_binary(), amqp_payload(), ne_binary(), kz_proplist()) -> 'ok'. +-spec sysconf_publish(kz_term:ne_binary(), amqp_payload()) -> 'ok'. +-spec sysconf_publish(kz_term:ne_binary(), amqp_payload(), kz_term:ne_binary()) -> 'ok'. +-spec sysconf_publish(kz_term:ne_binary(), amqp_payload(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. sysconf_publish(Routing, Payload) -> sysconf_publish(Routing, Payload, ?DEFAULT_CONTENT_TYPE). sysconf_publish(Routing, Payload, ContentType) -> @@ -237,17 +237,17 @@ sysconf_publish(Routing, Payload, ContentType) -> sysconf_publish(Routing, Payload, ContentType, Opts) -> basic_publish(?EXCHANGE_SYSCONF, Routing, Payload, ContentType, Opts). --spec callmgr_publish(amqp_payload(), ne_binary(), ne_binary()) -> 'ok'. --spec callmgr_publish(amqp_payload(), ne_binary(), ne_binary(), kz_proplist()) -> 'ok'. +-spec callmgr_publish(amqp_payload(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. +-spec callmgr_publish(amqp_payload(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. %% TODO: The routing key on this function should be the first argument for consistency callmgr_publish(Payload, ContentType, RoutingKey) -> basic_publish(?EXCHANGE_CALLMGR, RoutingKey, Payload, ContentType). callmgr_publish(Payload, ContentType, RoutingKey, Opts) -> basic_publish(?EXCHANGE_CALLMGR, RoutingKey, Payload, ContentType, Opts). --spec configuration_publish(ne_binary(), amqp_payload()) -> 'ok'. --spec configuration_publish(ne_binary(), amqp_payload(), ne_binary()) -> 'ok'. --spec configuration_publish(ne_binary(), amqp_payload(), ne_binary(), kz_proplist()) -> 'ok'. +-spec configuration_publish(kz_term:ne_binary(), amqp_payload()) -> 'ok'. +-spec configuration_publish(kz_term:ne_binary(), amqp_payload(), kz_term:ne_binary()) -> 'ok'. +-spec configuration_publish(kz_term:ne_binary(), amqp_payload(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. configuration_publish(RoutingKey, Payload) -> configuration_publish(RoutingKey, Payload, ?DEFAULT_CONTENT_TYPE). configuration_publish(RoutingKey, Payload, ContentType) -> @@ -257,22 +257,22 @@ configuration_publish(RoutingKey, Payload, ContentType, Props) -> -spec document_change_publish(Action, Db, Type, Id, Payload) -> 'ok' when Action :: atom(), %% edited | created | deleted - Db :: ne_binary(), - Type :: ne_binary(), - Id :: ne_binary(), + Db :: kz_term:ne_binary(), + Type :: kz_term:ne_binary(), + Id :: kz_term:ne_binary(), Payload :: amqp_payload(). --spec document_change_publish(atom(), ne_binary(), ne_binary(), ne_binary(), amqp_payload(), ne_binary()) -> 'ok'. +-spec document_change_publish(atom(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), amqp_payload(), kz_term:ne_binary()) -> 'ok'. document_change_publish(Action, Db, Type, Id, JSON) -> document_change_publish(Action, Db, Type, Id, JSON, ?DEFAULT_CONTENT_TYPE). document_change_publish(Action, Db, Type, Id, Payload, ContentType) -> RoutingKey = document_routing_key(Action, Db, Type, Id), configuration_publish(RoutingKey, Payload, ContentType). --spec document_routing_key() -> ne_binary(). --spec document_routing_key(atom() | ne_binary()) -> ne_binary(). --spec document_routing_key(atom() | ne_binary(), ne_binary()) -> ne_binary(). --spec document_routing_key(atom() | ne_binary(), ne_binary(), ne_binary()) -> ne_binary(). --spec document_routing_key(atom() | ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> ne_binary(). +-spec document_routing_key() -> kz_term:ne_binary(). +-spec document_routing_key(atom() | kz_term:ne_binary()) -> kz_term:ne_binary(). +-spec document_routing_key(atom() | kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). +-spec document_routing_key(atom() | kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). +-spec document_routing_key(atom() | kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). document_routing_key() -> document_routing_key(<<"*">>). document_routing_key(Action) -> @@ -312,9 +312,9 @@ document_routing_key(Action, Db, Type, Id) -> ,".", encode(kz_term:to_binary(Id)) ]). --spec callctl_publish(ne_binary(), amqp_payload()) -> 'ok'. --spec callctl_publish(ne_binary(), amqp_payload(), ne_binary()) -> 'ok'. --spec callctl_publish(ne_binary(), amqp_payload(), ne_binary(), kz_proplist()) -> 'ok'. +-spec callctl_publish(kz_term:ne_binary(), amqp_payload()) -> 'ok'. +-spec callctl_publish(kz_term:ne_binary(), amqp_payload(), kz_term:ne_binary()) -> 'ok'. +-spec callctl_publish(kz_term:ne_binary(), amqp_payload(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. callctl_publish(CtrlQ, Payload) -> callctl_publish(CtrlQ, Payload, ?DEFAULT_CONTENT_TYPE). callctl_publish(CtrlQ, Payload, ContentType) -> @@ -322,9 +322,9 @@ callctl_publish(CtrlQ, Payload, ContentType) -> callctl_publish(CtrlQ, Payload, ContentType, Props) -> basic_publish(?EXCHANGE_CALLCTL, CtrlQ, Payload, ContentType, Props). --spec callevt_publish(ne_binary(), amqp_payload()) -> 'ok'. --spec callevt_publish(ne_binary(), amqp_payload(), ne_binary()) -> 'ok'. --spec callevt_publish(ne_binary(), amqp_payload(), ne_binary(), kz_proplist()) -> 'ok'. +-spec callevt_publish(kz_term:ne_binary(), amqp_payload()) -> 'ok'. +-spec callevt_publish(kz_term:ne_binary(), amqp_payload(), kz_term:ne_binary()) -> 'ok'. +-spec callevt_publish(kz_term:ne_binary(), amqp_payload(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. callevt_publish(RoutingKey, Payload) -> callevt_publish(RoutingKey, Payload, ?DEFAULT_CONTENT_TYPE). callevt_publish(RoutingKey, Payload, ContentType) -> @@ -333,29 +333,29 @@ callevt_publish(RoutingKey, Payload, ContentType, Prop) -> basic_publish(?EXCHANGE_CALLEVT, RoutingKey, Payload, ContentType, Prop). -spec originate_resource_publish(amqp_payload()) -> 'ok'. --spec originate_resource_publish(amqp_payload(), ne_binary()) -> 'ok'. +-spec originate_resource_publish(amqp_payload(), kz_term:ne_binary()) -> 'ok'. originate_resource_publish(Payload) -> originate_resource_publish(Payload, ?DEFAULT_CONTENT_TYPE). originate_resource_publish(Payload, ContentType) -> basic_publish(?EXCHANGE_RESOURCE, ?KEY_ORGN_RESOURCE_REQ, Payload, ContentType). -spec offnet_resource_publish(amqp_payload()) -> 'ok'. --spec offnet_resource_publish(amqp_payload(), ne_binary()) -> 'ok'. +-spec offnet_resource_publish(amqp_payload(), kz_term:ne_binary()) -> 'ok'. offnet_resource_publish(Payload) -> offnet_resource_publish(Payload, ?DEFAULT_CONTENT_TYPE). offnet_resource_publish(Payload, ContentType) -> basic_publish(?EXCHANGE_RESOURCE, ?KEY_OFFNET_RESOURCE_REQ, Payload, ContentType). %% monitor --spec monitor_publish(amqp_payload(), ne_binary(), ne_binary()) -> 'ok'. +-spec monitor_publish(amqp_payload(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. monitor_publish(Payload, ContentType, RoutingKey) -> basic_publish(?EXCHANGE_MONITOR, RoutingKey, Payload, ContentType). -type conf_routing_type() :: 'discovery' | 'event' | 'command' | 'config'. -spec conference_publish(amqp_payload(), conf_routing_type()) -> 'ok'. --spec conference_publish(amqp_payload(), conf_routing_type(), api_binary()) -> 'ok'. --spec conference_publish(amqp_payload(), conf_routing_type(), api_binary(), kz_proplist()) -> 'ok'. --spec conference_publish(amqp_payload(), conf_routing_type(), api_binary(), kz_proplist(), ne_binary()) -> 'ok'. +-spec conference_publish(amqp_payload(), conf_routing_type(), kz_term:api_binary()) -> 'ok'. +-spec conference_publish(amqp_payload(), conf_routing_type(), kz_term:api_binary(), kz_term:proplist()) -> 'ok'. +-spec conference_publish(amqp_payload(), conf_routing_type(), kz_term:api_binary(), kz_term:proplist(), kz_term:ne_binary()) -> 'ok'. conference_publish(Payload, 'discovery') -> conference_publish(Payload, 'discovery', <<"*">>); @@ -393,14 +393,14 @@ conference_publish(Payload, 'event', ConfId, Options, ContentType) -> conference_publish(Payload, 'command', ConfId, Options, ContentType) -> basic_publish(?EXCHANGE_CONFERENCE, conference_command_binding(ConfId), Payload, ContentType, Options). --spec conference_publish(amqp_payload(), 'event', ne_binary(), ne_binary(), kz_proplist(), ne_binary()) -> 'ok'. +-spec conference_publish(amqp_payload(), 'event', kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist(), kz_term:ne_binary()) -> 'ok'. conference_publish(Payload, 'event', ConfId, CallId, Options, ContentType) -> RoutingKey = <>, basic_publish(?EXCHANGE_CONFERENCE, RoutingKey, Payload, ContentType, Options). --spec registrar_publish(ne_binary(), amqp_payload()) -> 'ok'. --spec registrar_publish(ne_binary(), amqp_payload(), ne_binary()) -> 'ok'. --spec registrar_publish(ne_binary(), amqp_payload(), ne_binary(), kz_proplist()) -> 'ok'. +-spec registrar_publish(kz_term:ne_binary(), amqp_payload()) -> 'ok'. +-spec registrar_publish(kz_term:ne_binary(), amqp_payload(), kz_term:ne_binary()) -> 'ok'. +-spec registrar_publish(kz_term:ne_binary(), amqp_payload(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. registrar_publish(Routing, Payload) -> registrar_publish(Routing, Payload, ?DEFAULT_CONTENT_TYPE). registrar_publish(Routing, Payload, ContentType) -> @@ -408,9 +408,9 @@ registrar_publish(Routing, Payload, ContentType) -> registrar_publish(Routing, Payload, ContentType, Opts) -> basic_publish(?EXCHANGE_REGISTRAR, Routing, Payload, ContentType, Opts). --spec leader_publish(ne_binary(), amqp_payload()) -> 'ok'. --spec leader_publish(ne_binary(), amqp_payload(), ne_binary()) -> 'ok'. --spec leader_publish(ne_binary(), amqp_payload(), ne_binary(), kz_proplist()) -> 'ok'. +-spec leader_publish(kz_term:ne_binary(), amqp_payload()) -> 'ok'. +-spec leader_publish(kz_term:ne_binary(), amqp_payload(), kz_term:ne_binary()) -> 'ok'. +-spec leader_publish(kz_term:ne_binary(), amqp_payload(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. leader_publish(Routing, Payload) -> leader_publish(Routing, Payload, ?DEFAULT_CONTENT_TYPE). leader_publish(Routing, Payload, ContentType) -> @@ -418,9 +418,9 @@ leader_publish(Routing, Payload, ContentType) -> leader_publish(Routing, Payload, ContentType, Opts) -> basic_publish(?EXCHANGE_LEADER, Routing, Payload, ContentType, Opts). --spec tasks_publish(ne_binary(), amqp_payload()) -> 'ok'. --spec tasks_publish(ne_binary(), amqp_payload(), ne_binary()) -> 'ok'. --spec tasks_publish(ne_binary(), amqp_payload(), ne_binary(), kz_proplist()) -> 'ok'. +-spec tasks_publish(kz_term:ne_binary(), amqp_payload()) -> 'ok'. +-spec tasks_publish(kz_term:ne_binary(), amqp_payload(), kz_term:ne_binary()) -> 'ok'. +-spec tasks_publish(kz_term:ne_binary(), amqp_payload(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. tasks_publish(Routing, Payload) -> tasks_publish(Routing, Payload, ?DEFAULT_CONTENT_TYPE). tasks_publish(Routing, Payload, ContentType) -> @@ -431,9 +431,9 @@ tasks_publish(Routing, Payload, ContentType, Opts) -> %% generic publisher for an Exchange.Queue %% Use <<"#">> for a default Queue --spec basic_publish(ne_binary(), binary(), amqp_payload()) -> 'ok'. --spec basic_publish(ne_binary(), binary(), amqp_payload(), ne_binary()) -> 'ok'. --spec basic_publish(ne_binary(), binary(), amqp_payload(), ne_binary(), kz_proplist()) -> 'ok'. +-spec basic_publish(kz_term:ne_binary(), binary(), amqp_payload()) -> 'ok'. +-spec basic_publish(kz_term:ne_binary(), binary(), amqp_payload(), kz_term:ne_binary()) -> 'ok'. +-spec basic_publish(kz_term:ne_binary(), binary(), amqp_payload(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. basic_publish(Exchange, RoutingKey, Payload) -> basic_publish(Exchange, RoutingKey, Payload, ?DEFAULT_CONTENT_TYPE). @@ -557,8 +557,8 @@ tasks_exchange() -> %% A generic Exchange maker --spec new_exchange(ne_binary(), ne_binary()) -> 'ok'. --spec new_exchange(ne_binary(), ne_binary(), kz_proplist()) -> 'ok'. +-spec new_exchange(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. +-spec new_exchange(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. new_exchange(Exchange, Type) -> new_exchange(Exchange, Type, []). new_exchange(Exchange, Type, Options) -> @@ -573,8 +573,8 @@ new_exchange(Exchange, Type, Options) -> }, kz_amqp_channel:command(ED). --spec declare_exchange(ne_binary(), ne_binary()) -> kz_amqp_exchange(). --spec declare_exchange(ne_binary(), ne_binary(), kz_proplist()) -> kz_amqp_exchange(). +-spec declare_exchange(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_amqp_exchange(). +-spec declare_exchange(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> kz_amqp_exchange(). declare_exchange(Exchange, Type) -> declare_exchange(Exchange, Type, []). declare_exchange(Exchange, Type, Options) -> @@ -594,42 +594,42 @@ declare_exchange(Exchange, Type, Options) -> %% Create AMQP queues %% @end %%------------------------------------------------------------------------------ --spec new_targeted_queue() -> ne_binary() | {'error', any()}. --spec new_targeted_queue(binary()) -> ne_binary() | {'error', any()}. +-spec new_targeted_queue() -> kz_term:ne_binary() | {'error', any()}. +-spec new_targeted_queue(binary()) -> kz_term:ne_binary() | {'error', any()}. new_targeted_queue() -> new_targeted_queue(<<>>). new_targeted_queue(Queue) -> new_queue(Queue, [{'nowait', 'false'}]). --spec new_nodes_queue() -> ne_binary() | {'error', any()}. --spec new_nodes_queue(binary()) -> ne_binary() | {'error', any()}. +-spec new_nodes_queue() -> kz_term:ne_binary() | {'error', any()}. +-spec new_nodes_queue(binary()) -> kz_term:ne_binary() | {'error', any()}. new_nodes_queue() -> new_nodes_queue(<<>>). new_nodes_queue(Queue) -> new_queue(Queue, [{'nowait', 'false'}]). --spec new_kapps_queue() -> ne_binary() | {'error', any()}. --spec new_kapps_queue(binary()) -> ne_binary() | {'error', any()}. +-spec new_kapps_queue() -> kz_term:ne_binary() | {'error', any()}. +-spec new_kapps_queue(binary()) -> kz_term:ne_binary() | {'error', any()}. new_kapps_queue() -> new_kapps_queue(<<>>). new_kapps_queue(Queue) -> new_queue(Queue, [{'nowait', 'false'}]). --spec new_presence_queue() -> ne_binary() | {'error', any()}. --spec new_presence_queue(binary()) -> ne_binary() | {'error', any()}. +-spec new_presence_queue() -> kz_term:ne_binary() | {'error', any()}. +-spec new_presence_queue(binary()) -> kz_term:ne_binary() | {'error', any()}. new_presence_queue() -> new_presence_queue(<<>>). new_presence_queue(Queue) -> new_queue(Queue, [{'nowait', 'false'}]). --spec new_registrar_queue() -> ne_binary() | {'error', any()}. --spec new_registrar_queue(binary()) -> ne_binary() | {'error', any()}. +-spec new_registrar_queue() -> kz_term:ne_binary() | {'error', any()}. +-spec new_registrar_queue(binary()) -> kz_term:ne_binary() | {'error', any()}. new_registrar_queue() -> new_registrar_queue(<<>>). new_registrar_queue(Queue) -> new_queue(Queue, [{'nowait', 'false'}]). --spec new_notifications_queue() -> ne_binary() | {'error', any()}. --spec new_notifications_queue(binary()) -> ne_binary() | {'error', any()}. +-spec new_notifications_queue() -> kz_term:ne_binary() | {'error', any()}. +-spec new_notifications_queue(binary()) -> kz_term:ne_binary() | {'error', any()}. new_notifications_queue() -> new_notifications_queue(<<>>). new_notifications_queue(Queue) -> new_queue(Queue, [{'nowait', 'false'}]). --spec new_sysconf_queue() -> ne_binary() | {'error', any()}. --spec new_sysconf_queue(binary()) -> ne_binary() | {'error', any()}. +-spec new_sysconf_queue() -> kz_term:ne_binary() | {'error', any()}. +-spec new_sysconf_queue(binary()) -> kz_term:ne_binary() | {'error', any()}. new_sysconf_queue() -> new_sysconf_queue(<<>>). new_sysconf_queue(Queue) -> new_queue(Queue, [{'nowait', 'false'}]). --spec new_callevt_queue(binary()) -> ne_binary() | {'error', any()}. +-spec new_callevt_queue(binary()) -> kz_term:ne_binary() | {'error', any()}. new_callevt_queue(<<>>) -> new_queue(<<>>, [{'exclusive', 'false'} ,{'auto_delete', 'true'} @@ -642,7 +642,7 @@ new_callevt_queue(CallID) -> ,{'nowait', 'false'} ]). --spec new_callctl_queue(binary()) -> ne_binary() | {'error', any()}. +-spec new_callctl_queue(binary()) -> kz_term:ne_binary() | {'error', any()}. new_callctl_queue(<<>>) -> new_queue(<<>>, [{'exclusive', 'false'} ,{'auto_delete', 'true'} @@ -655,8 +655,8 @@ new_callctl_queue(CallID) -> ,{'nowait', 'false'} ]). --spec new_resource_queue() -> ne_binary() | {'error', any()}. --spec new_resource_queue(binary()) -> ne_binary() | {'error', any()}. +-spec new_resource_queue() -> kz_term:ne_binary() | {'error', any()}. +-spec new_resource_queue(binary()) -> kz_term:ne_binary() | {'error', any()}. new_resource_queue() -> new_resource_queue(?RESOURCE_QUEUE_NAME). new_resource_queue(Queue) -> new_queue(Queue, [{'exclusive', 'false'} @@ -664,26 +664,26 @@ new_resource_queue(Queue) -> ,{'nowait', 'false'} ]). --spec new_callmgr_queue(binary()) -> ne_binary() | {'error', any()}. --spec new_callmgr_queue(binary(), kz_proplist()) -> ne_binary() | {'error', any()}. +-spec new_callmgr_queue(binary()) -> kz_term:ne_binary() | {'error', any()}. +-spec new_callmgr_queue(binary(), kz_term:proplist()) -> kz_term:ne_binary() | {'error', any()}. new_callmgr_queue(Queue) -> new_callmgr_queue(Queue, []). new_callmgr_queue(Queue, Opts) -> new_queue(Queue, Opts). --spec new_configuration_queue(ne_binary()) -> ne_binary() | {'error', any()}. --spec new_configuration_queue(ne_binary(), kz_proplist()) -> ne_binary() | {'error', any()}. +-spec new_configuration_queue(kz_term:ne_binary()) -> kz_term:ne_binary() | {'error', any()}. +-spec new_configuration_queue(kz_term:ne_binary(), kz_term:proplist()) -> kz_term:ne_binary() | {'error', any()}. new_configuration_queue(Queue) -> new_configuration_queue(Queue, []). new_configuration_queue(Queue, Options) -> new_queue(Queue, Options). --spec new_monitor_queue() -> ne_binary() | {'error', any()}. --spec new_monitor_queue(binary()) -> ne_binary() | {'error', any()}. +-spec new_monitor_queue() -> kz_term:ne_binary() | {'error', any()}. +-spec new_monitor_queue(binary()) -> kz_term:ne_binary() | {'error', any()}. new_monitor_queue() -> new_monitor_queue(<<>>). new_monitor_queue(Queue) -> new_queue(Queue, [{'exclusive', 'false'} ,{'auto_delete', 'true'} ]). --spec new_conference_queue() -> ne_binary() | {'error', any()}. --spec new_conference_queue(binary()) -> ne_binary() | {'error', any()}. +-spec new_conference_queue() -> kz_term:ne_binary() | {'error', any()}. +-spec new_conference_queue(binary()) -> kz_term:ne_binary() | {'error', any()}. new_conference_queue() -> new_conference_queue(<<>>). new_conference_queue(Queue) -> new_queue(Queue, [{'exclusive', 'false'} @@ -691,19 +691,19 @@ new_conference_queue(Queue) -> ,{'nowait', 'false'} ]). --spec new_tasks_queue() -> ne_binary() | {'error', any()}. --spec new_tasks_queue(binary()) -> ne_binary() | {'error', any()}. +-spec new_tasks_queue() -> kz_term:ne_binary() | {'error', any()}. +-spec new_tasks_queue(binary()) -> kz_term:ne_binary() | {'error', any()}. new_tasks_queue() -> new_tasks_queue(<<>>). new_tasks_queue(Queue) -> new_queue(Queue, [{'nowait', 'false'}]). %% Declare a queue and returns the queue Name --type new_queue_ret() :: api_binary() | integer() | - {ne_binary(), integer(), integer()} | +-type new_queue_ret() :: kz_term:api_binary() | integer() | + {kz_term:ne_binary(), integer(), integer()} | {'error', any()}. -spec new_queue() -> new_queue_ret(). -spec new_queue(binary()) -> new_queue_ret(). --spec new_queue(binary(), kz_proplist()) -> new_queue_ret(). +-spec new_queue(binary(), kz_term:proplist()) -> new_queue_ret(). new_queue() -> new_queue(new_queue_name()). % lets the client lib create a random queue name new_queue(Queue) -> new_queue(Queue, []). @@ -738,11 +738,11 @@ new_queue(Queue, Options) when is_binary(Queue) -> {'EXIT',{'noproc', _}} -> {'error', 'no_channel'} end. --spec new_queue_name() -> ne_binary(). +-spec new_queue_name() -> kz_term:ne_binary(). new_queue_name() -> list_to_binary(io_lib:format("~s-~p-~s", [node(), self(), kz_binary:rand_hex(4)])). --spec queue_arguments(kz_proplist()) -> amqp_properties(). +-spec queue_arguments(kz_term:proplist()) -> amqp_properties(). queue_arguments(Arguments) -> Routines = [fun max_length/2 ,fun message_ttl/2 @@ -750,7 +750,7 @@ queue_arguments(Arguments) -> ], lists:foldl(fun(F, Acc) -> F(Arguments, Acc) end, Arguments, Routines). --spec max_priority(kz_proplist(), amqp_properties()) -> amqp_properties(). +-spec max_priority(kz_term:proplist(), amqp_properties()) -> amqp_properties(). max_priority(Args, Acc) -> Property = props:get_value(<<"x-max-priority">>, Args), Acc1 = props:delete(<<"x-max-priority">>, Acc), @@ -766,7 +766,7 @@ trim(Min, _ , Val) when Val < Min -> Min; trim(_ , Max, Val) when Val > Max -> Max; trim(_ , _ , Val) -> Val. --spec max_length(kz_proplist(), amqp_properties()) -> amqp_properties(). +-spec max_length(kz_term:proplist(), amqp_properties()) -> amqp_properties(). max_length(Args, Acc) -> case props:get_value(<<"x-max-length">>, Args) of 'undefined' -> [{<<"x-max-length">>, 'short', 100}|Acc]; @@ -776,7 +776,7 @@ max_length(Args, Acc) -> [{<<"x-max-length">>, 'short', Value}|Acc1] end. --spec message_ttl(kz_proplist(), amqp_properties()) -> amqp_properties(). +-spec message_ttl(kz_term:proplist(), amqp_properties()) -> amqp_properties(). message_ttl(Args, Acc) -> case props:get_value(<<"x-message-ttl">>, Args) of 'undefined' -> [{<<"x-message-ttl">>, 'signedint', 60 * ?MILLISECONDS_IN_SECOND}|Acc]; @@ -792,19 +792,19 @@ message_ttl(Args, Acc) -> %% Delete AMQP queue %% @end %%------------------------------------------------------------------------------ --spec delete_targeted_queue(ne_binary()) -> command_ret(). --spec delete_nodes_queue(ne_binary()) -> command_ret(). --spec delete_kapps_queue(ne_binary()) -> command_ret(). --spec delete_presence_queue(ne_binary()) -> command_ret(). --spec delete_notifications_queue(ne_binary()) -> command_ret(). --spec delete_sysconf_queue(ne_binary()) -> command_ret(). --spec delete_callmgr_queue(ne_binary()) -> command_ret(). --spec delete_resource_queue(ne_binary()) -> command_ret(). --spec delete_configuration_queue(ne_binary()) -> command_ret(). --spec delete_conference_queue(ne_binary()) -> command_ret(). --spec delete_monitor_queue(ne_binary()) -> command_ret(). --spec delete_registrar_queue(ne_binary()) -> command_ret(). --spec delete_tasks_queue(ne_binary()) -> command_ret(). +-spec delete_targeted_queue(kz_term:ne_binary()) -> command_ret(). +-spec delete_nodes_queue(kz_term:ne_binary()) -> command_ret(). +-spec delete_kapps_queue(kz_term:ne_binary()) -> command_ret(). +-spec delete_presence_queue(kz_term:ne_binary()) -> command_ret(). +-spec delete_notifications_queue(kz_term:ne_binary()) -> command_ret(). +-spec delete_sysconf_queue(kz_term:ne_binary()) -> command_ret(). +-spec delete_callmgr_queue(kz_term:ne_binary()) -> command_ret(). +-spec delete_resource_queue(kz_term:ne_binary()) -> command_ret(). +-spec delete_configuration_queue(kz_term:ne_binary()) -> command_ret(). +-spec delete_conference_queue(kz_term:ne_binary()) -> command_ret(). +-spec delete_monitor_queue(kz_term:ne_binary()) -> command_ret(). +-spec delete_registrar_queue(kz_term:ne_binary()) -> command_ret(). +-spec delete_tasks_queue(kz_term:ne_binary()) -> command_ret(). delete_targeted_queue(Queue) -> queue_delete(Queue). delete_nodes_queue(Queue) -> queue_delete(Queue). delete_kapps_queue(Queue) -> queue_delete(Queue). @@ -819,18 +819,18 @@ delete_monitor_queue(Queue) -> queue_delete(Queue). delete_registrar_queue(Queue) -> queue_delete(Queue). delete_tasks_queue(Queue) -> queue_delete(Queue). --spec delete_callevt_queue(ne_binary()) -> command_ret(). +-spec delete_callevt_queue(kz_term:ne_binary()) -> command_ret(). delete_callevt_queue(CallID) -> delete_callevt_queue(CallID, []). delete_callevt_queue(CallID, Prop) -> queue_delete(list_to_binary([?EXCHANGE_CALLEVT, ".", encode(CallID)]), Prop). --spec delete_callctl_queue(ne_binary()) -> command_ret(). +-spec delete_callctl_queue(kz_term:ne_binary()) -> command_ret(). delete_callctl_queue(CallID) -> delete_callctl_queue(CallID, []). delete_callctl_queue(CallID, Prop) -> queue_delete(list_to_binary([?EXCHANGE_CALLCTL, ".", encode(CallID)]), Prop). --spec queue_delete(ne_binary()) -> command_ret(). --spec queue_delete(ne_binary(), kz_proplist()) -> command_ret(). +-spec queue_delete(kz_term:ne_binary()) -> command_ret(). +-spec queue_delete(kz_term:ne_binary(), kz_term:proplist()) -> command_ret(). queue_delete(Queue) -> queue_delete(Queue, []). queue_delete(Queue, _Prop) when not is_binary(Queue) -> {'error', 'invalid_queue_name'}; @@ -848,92 +848,92 @@ queue_delete(Queue, Prop) -> %% Bind a Queue to an Exchange (with optional Routing Key) %% @end %%------------------------------------------------------------------------------ --spec bind_q_to_targeted(ne_binary()) -> 'ok'. --spec bind_q_to_targeted(ne_binary(), ne_binary()) -> 'ok'. +-spec bind_q_to_targeted(kz_term:ne_binary()) -> 'ok'. +-spec bind_q_to_targeted(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. bind_q_to_targeted(Queue) -> bind_q_to_exchange(Queue, Queue, ?EXCHANGE_TARGETED). bind_q_to_targeted(Queue, Routing) -> bind_q_to_exchange(Queue, Routing, ?EXCHANGE_TARGETED). --spec bind_q_to_nodes(ne_binary()) -> 'ok'. --spec bind_q_to_nodes(ne_binary(), ne_binary()) -> 'ok'. +-spec bind_q_to_nodes(kz_term:ne_binary()) -> 'ok'. +-spec bind_q_to_nodes(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. bind_q_to_nodes(Queue) -> bind_q_to_exchange(Queue, Queue, ?EXCHANGE_NODES). bind_q_to_nodes(Queue, Routing) -> bind_q_to_exchange(Queue, Routing, ?EXCHANGE_NODES). --spec bind_q_to_kapps(ne_binary(), ne_binary()) -> 'ok'. --spec bind_q_to_kapps(ne_binary(), ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q_to_kapps(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. +-spec bind_q_to_kapps(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q_to_kapps(Queue, Routing) -> bind_q_to_kapps(Queue, Routing, []). bind_q_to_kapps(Queue, Routing, Options) -> bind_q_to_exchange(Queue, Routing, ?EXCHANGE_KAPPS, Options). --spec bind_q_to_presence(ne_binary(), ne_binary()) -> 'ok'. --spec bind_q_to_presence(ne_binary(), ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q_to_presence(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. +-spec bind_q_to_presence(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q_to_presence(Queue, Routing) -> bind_q_to_presence(Queue, Routing, []). bind_q_to_presence(Queue, Routing, Options) -> bind_q_to_exchange(Queue, Routing, ?EXCHANGE_PRESENCE, Options). --spec bind_q_to_registrar(ne_binary(), ne_binary()) -> 'ok'. --spec bind_q_to_registrar(ne_binary(), ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q_to_registrar(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. +-spec bind_q_to_registrar(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q_to_registrar(Queue, Routing) -> bind_q_to_registrar(Queue, Routing, []). bind_q_to_registrar(Queue, Routing, Options) -> bind_q_to_exchange(Queue, Routing, ?EXCHANGE_REGISTRAR, Options). --spec bind_q_to_notifications(ne_binary(), ne_binary()) -> 'ok'. --spec bind_q_to_notifications(ne_binary(), ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q_to_notifications(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. +-spec bind_q_to_notifications(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q_to_notifications(Queue, Routing) -> bind_q_to_notifications(Queue, Routing, []). bind_q_to_notifications(Queue, Routing, Options) -> bind_q_to_exchange(Queue, Routing, ?EXCHANGE_NOTIFICATIONS, Options). --spec bind_q_to_sysconf(ne_binary(), ne_binary()) -> 'ok'. --spec bind_q_to_sysconf(ne_binary(), ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q_to_sysconf(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. +-spec bind_q_to_sysconf(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q_to_sysconf(Queue, Routing) -> bind_q_to_sysconf(Queue, Routing, []). bind_q_to_sysconf(Queue, Routing, Options) -> bind_q_to_exchange(Queue, Routing, ?EXCHANGE_SYSCONF, Options). --spec bind_q_to_callctl(ne_binary()) -> 'ok'. --spec bind_q_to_callctl(ne_binary(), ne_binary()) -> 'ok'. +-spec bind_q_to_callctl(kz_term:ne_binary()) -> 'ok'. +-spec bind_q_to_callctl(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. bind_q_to_callctl(Queue) -> bind_q_to_callctl(Queue, Queue). bind_q_to_callctl(Queue, Routing) -> bind_q_to_exchange(Queue, Routing, ?EXCHANGE_CALLCTL). --spec bind_q_to_callevt(ne_binary()) -> 'ok'. --spec bind_q_to_callevt(ne_binary(), ne_binary()) -> 'ok'. +-spec bind_q_to_callevt(kz_term:ne_binary()) -> 'ok'. +-spec bind_q_to_callevt(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. bind_q_to_callevt(Queue) -> bind_q_to_callevt(Queue, Queue). bind_q_to_callevt(Queue, Routing) -> bind_q_to_exchange(Queue, Routing, ?EXCHANGE_CALLEVT). --spec bind_q_to_resource(ne_binary()) -> 'ok'. --spec bind_q_to_resource(ne_binary(), ne_binary()) -> 'ok'. +-spec bind_q_to_resource(kz_term:ne_binary()) -> 'ok'. +-spec bind_q_to_resource(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. bind_q_to_resource(Queue) -> bind_q_to_resource(Queue, <<"#">>). bind_q_to_resource(Queue, Routing) -> bind_q_to_exchange(Queue, Routing, ?EXCHANGE_RESOURCE). --spec bind_q_to_callmgr(ne_binary(), ne_binary()) -> 'ok'. +-spec bind_q_to_callmgr(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. bind_q_to_callmgr(Queue, Routing) -> bind_q_to_exchange(Queue, Routing, ?EXCHANGE_CALLMGR). --spec bind_q_to_configuration(ne_binary(), ne_binary()) -> 'ok'. +-spec bind_q_to_configuration(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. bind_q_to_configuration(Queue, Routing) -> bind_q_to_exchange(Queue, Routing, ?EXCHANGE_CONFIGURATION). --spec bind_q_to_monitor(ne_binary(), ne_binary()) -> 'ok'. +-spec bind_q_to_monitor(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. bind_q_to_monitor(Queue, Routing) -> bind_q_to_exchange(Queue, Routing, ?EXCHANGE_MONITOR). --spec unbind_q_from_monitor(ne_binary(), ne_binary()) -> 'ok'. +-spec unbind_q_from_monitor(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. unbind_q_from_monitor(Queue, Routing) -> unbind_q_from_exchange(Queue, Routing, ?EXCHANGE_MONITOR). --spec bind_q_to_conference(ne_binary(), conf_routing_type()) -> 'ok'. --spec bind_q_to_conference(ne_binary(), conf_routing_type(), api_binary()) -> 'ok'. +-spec bind_q_to_conference(kz_term:ne_binary(), conf_routing_type()) -> 'ok'. +-spec bind_q_to_conference(kz_term:ne_binary(), conf_routing_type(), kz_term:api_binary()) -> 'ok'. bind_q_to_conference(Queue, 'discovery') -> bind_q_to_conference(Queue, 'discovery', 'undefined'); @@ -953,27 +953,27 @@ bind_q_to_conference(Queue, 'command', ConfId) -> bind_q_to_conference(Queue, 'config', ConfProfile) -> bind_q_to_exchange(Queue, <>, ?EXCHANGE_CONFERENCE). --spec conference_command_binding(ne_binary()) -> ne_binary(). +-spec conference_command_binding(kz_term:ne_binary()) -> kz_term:ne_binary(). conference_command_binding(ConferenceId) -> <>. --spec bind_q_to_leader(ne_binary(), ne_binary()) -> 'ok'. +-spec bind_q_to_leader(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. bind_q_to_leader(Queue, Bind) -> bind_q_to_exchange(Queue, Bind, ?EXCHANGE_LEADER). --spec unbind_q_from_leader(ne_binary(), ne_binary()) -> 'ok'. +-spec unbind_q_from_leader(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. unbind_q_from_leader(Queue, Bind) -> unbind_q_from_exchange(Queue, Bind, ?EXCHANGE_LEADER). --spec bind_q_to_tasks(ne_binary(), ne_binary()) -> 'ok'. --spec bind_q_to_tasks(ne_binary(), ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q_to_tasks(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. +-spec bind_q_to_tasks(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q_to_tasks(Queue, Routing) -> bind_q_to_tasks(Queue, Routing, []). bind_q_to_tasks(Queue, Routing, Options) -> bind_q_to_exchange(Queue, Routing, ?EXCHANGE_TASKS, Options). --spec bind_q_to_exchange(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. --spec bind_q_to_exchange(ne_binary(), ne_binary(), ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q_to_exchange(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. +-spec bind_q_to_exchange(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q_to_exchange(Queue, _Routing, _Exchange) when not is_binary(Queue) -> {'error', 'invalid_queue_name'}; bind_q_to_exchange(Queue, Routing, Exchange) -> @@ -993,9 +993,9 @@ bind_q_to_exchange(Queue, Routing, Exchange, Options) -> %% Unbind a Queue from an Exchange %% @end %%------------------------------------------------------------------------------ --spec unbind_q_from_conference(ne_binary(), conf_routing_type()) -> +-spec unbind_q_from_conference(kz_term:ne_binary(), conf_routing_type()) -> 'ok' | {'error', any()}. --spec unbind_q_from_conference(ne_binary(), conf_routing_type(), api_binary()) -> +-spec unbind_q_from_conference(kz_term:ne_binary(), conf_routing_type(), kz_term:api_binary()) -> 'ok' | {'error', any()}. unbind_q_from_conference(Queue, 'discovery') -> unbind_q_from_conference(Queue, 'discovery', 'undefined'); @@ -1015,78 +1015,78 @@ unbind_q_from_conference(Queue, 'config', ConfProfile) -> unbind_q_from_conference(Queue, 'command', ConfId) -> unbind_q_from_exchange(Queue, conference_command_binding(ConfId), ?EXCHANGE_CONFERENCE). --spec unbind_q_from_conference(ne_binary(), 'event', ne_binary(), ne_binary()) -> +-spec unbind_q_from_conference(kz_term:ne_binary(), 'event', kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | {'error', any()}. unbind_q_from_conference(Queue, 'event', ConfId, CallId) -> unbind_q_from_exchange(Queue, <>, ?EXCHANGE_CONFERENCE). --spec unbind_q_from_callctl(ne_binary()) -> +-spec unbind_q_from_callctl(kz_term:ne_binary()) -> 'ok' | {'error', any()}. unbind_q_from_callctl(Queue) -> unbind_q_from_exchange(Queue, Queue, ?EXCHANGE_CALLCTL). --spec unbind_q_from_notifications(ne_binary(), ne_binary()) -> +-spec unbind_q_from_notifications(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | {'error', any()}. unbind_q_from_notifications(Queue, Routing) -> unbind_q_from_exchange(Queue, Routing, ?EXCHANGE_NOTIFICATIONS). --spec unbind_q_from_sysconf(ne_binary(), ne_binary()) -> +-spec unbind_q_from_sysconf(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | {'error', any()}. unbind_q_from_sysconf(Queue, Routing) -> unbind_q_from_exchange(Queue, Routing, ?EXCHANGE_SYSCONF). --spec unbind_q_from_resource(ne_binary(), ne_binary()) -> +-spec unbind_q_from_resource(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | {'error', any()}. unbind_q_from_resource(Queue, Routing) -> unbind_q_from_exchange(Queue, Routing, ?EXCHANGE_RESOURCE). --spec unbind_q_from_callevt(ne_binary(), ne_binary()) -> +-spec unbind_q_from_callevt(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | {'error', any()}. unbind_q_from_callevt(Queue, Routing) -> unbind_q_from_exchange(Queue, Routing, ?EXCHANGE_CALLEVT). --spec unbind_q_from_callmgr(ne_binary(), ne_binary()) -> +-spec unbind_q_from_callmgr(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | {'error', any()}. unbind_q_from_callmgr(Queue, Routing) -> unbind_q_from_exchange(Queue, Routing, ?EXCHANGE_CALLMGR). --spec unbind_q_from_configuration(ne_binary(), ne_binary()) -> +-spec unbind_q_from_configuration(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | {'error', any()}. unbind_q_from_configuration(Queue, Routing) -> unbind_q_from_exchange(Queue, Routing, ?EXCHANGE_CONFIGURATION). --spec unbind_q_from_targeted(ne_binary()) -> +-spec unbind_q_from_targeted(kz_term:ne_binary()) -> 'ok' | {'error', any()}. unbind_q_from_targeted(Queue) -> unbind_q_from_exchange(Queue, Queue, ?EXCHANGE_TARGETED). --spec unbind_q_from_nodes(ne_binary()) -> +-spec unbind_q_from_nodes(kz_term:ne_binary()) -> 'ok' | {'error', any()}. unbind_q_from_nodes(Queue) -> unbind_q_from_exchange(Queue, Queue, ?EXCHANGE_NODES). --spec unbind_q_from_kapps(ne_binary(), ne_binary()) -> +-spec unbind_q_from_kapps(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | {'error', any()}. unbind_q_from_kapps(Queue, Routing) -> unbind_q_from_exchange(Queue, Routing, ?EXCHANGE_KAPPS). --spec unbind_q_from_presence(ne_binary(), ne_binary()) -> +-spec unbind_q_from_presence(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | {'error', any()}. unbind_q_from_presence(Queue, Routing) -> unbind_q_from_exchange(Queue, Routing, ?EXCHANGE_PRESENCE). --spec unbind_q_from_registrar(ne_binary(), ne_binary()) -> +-spec unbind_q_from_registrar(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | {'error', any()}. unbind_q_from_registrar(Queue, Routing) -> unbind_q_from_exchange(Queue, Routing, ?EXCHANGE_REGISTRAR). --spec unbind_q_from_tasks(ne_binary(), ne_binary()) -> +-spec unbind_q_from_tasks(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | {'error', any()}. unbind_q_from_tasks(Queue, Routing) -> unbind_q_from_exchange(Queue, Routing, ?EXCHANGE_TASKS). --spec unbind_q_from_exchange(ne_binary(), ne_binary(), ne_binary()) -> +-spec unbind_q_from_exchange(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | {'error', any()}. unbind_q_from_exchange(Queue, Routing, Exchange) -> UB = #'queue.unbind'{queue = Queue @@ -1103,8 +1103,8 @@ unbind_q_from_exchange(Queue, Routing, Exchange) -> %% @end %%------------------------------------------------------------------------------ %% create a consumer for a Queue --spec basic_consume(ne_binary()) -> 'ok' | {'error', any()}. --spec basic_consume(ne_binary(), kz_proplist()) -> 'ok' | {'error', any()}. +-spec basic_consume(kz_term:ne_binary()) -> 'ok' | {'error', any()}. +-spec basic_consume(kz_term:ne_binary(), kz_term:proplist()) -> 'ok' | {'error', any()}. basic_consume(Queue) -> basic_consume(Queue, []). basic_consume(Queue, Options) -> BC = #'basic.consume'{queue = Queue @@ -1124,7 +1124,7 @@ basic_consume(Queue, Options) -> %% @end %%------------------------------------------------------------------------------ -spec basic_cancel() -> 'ok'. --spec basic_cancel(ne_binary()) -> 'ok'. +-spec basic_cancel(kz_term:ne_binary()) -> 'ok'. basic_cancel() -> kz_amqp_channel:command(#'basic.cancel'{}). basic_cancel(ConsumerTag) -> kz_amqp_channel:command(#'basic.cancel'{consumer_tag=ConsumerTag}). @@ -1160,7 +1160,7 @@ flow_control_reply(Active) -> %% @end %%------------------------------------------------------------------------------ -spec access_request() -> #'access.request'{}. --spec access_request(kz_proplist()) -> #'access.request'{}. +-spec access_request(kz_term:proplist()) -> #'access.request'{}. access_request() -> access_request([]). access_request(Options) -> #'access.request'{realm = ?P_GET('realm', Options, <<"/data">>) diff --git a/core/kazoo_amqp/src/api/kapi_asr.erl b/core/kazoo_amqp/src/api/kapi_asr.erl index 8bd6f930396..da30ca9935f 100644 --- a/core/kazoo_amqp/src/api/kapi_asr.erl +++ b/core/kazoo_amqp/src/api/kapi_asr.erl @@ -52,10 +52,10 @@ %%-------------------------------------------------------------------- %% @doc Request asr - see wiki -%% Takes kz_proplist(), creates JSON string or error +%% Takes kz_term:proplist(), creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. req(Prop) when is_list(Prop) -> case req_v(Prop) of true -> kz_api:build_message(Prop, ?ASR_REQ_HEADERS, ?OPTIONAL_ASR_REQ_HEADERS); @@ -64,7 +64,7 @@ req(Prop) when is_list(Prop) -> req(JObj) -> req(kz_json:to_proplist(JObj)). --spec req_v(api_terms()) -> boolean(). +-spec req_v(kz_term:api_terms()) -> boolean(). req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?ASR_REQ_HEADERS, ?ASR_REQ_VALUES, ?ASR_REQ_TYPES); req_v(JObj) -> @@ -72,10 +72,10 @@ req_v(JObj) -> %%-------------------------------------------------------------------- %% @doc Response with asr - see wiki -%% Takes kz_proplist(), creates JSON string or error +%% Takes kz_term:proplist(), creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. resp(Prop) when is_list(Prop) -> case resp_v(Prop) of true -> kz_api:build_message(Prop, ?ASR_RESP_HEADERS, ?OPTIONAL_ASR_RESP_HEADERS); @@ -84,7 +84,7 @@ resp(Prop) when is_list(Prop) -> resp(JObj) -> resp(kz_json:to_proplist(JObj)). --spec resp_v(api_terms()) -> boolean(). +-spec resp_v(kz_term:api_terms()) -> boolean(). resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?ASR_RESP_HEADERS, ?ASR_RESP_VALUES, ?ASR_RESP_TYPES); resp_v(JObj) -> @@ -92,10 +92,10 @@ resp_v(JObj) -> %%-------------------------------------------------------------------- %% @doc Asr error - see wiki -%% Takes kz_proplist(), creates JSON string or error +%% Takes kz_term:proplist(), creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec error(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec error(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. error(Prop) when is_list(Prop) -> case error_v(Prop) of true -> kz_api:build_message(Prop, ?ASR_ERROR_HEADERS, ?OPTIONAL_ASR_ERROR_HEADERS); @@ -104,7 +104,7 @@ error(Prop) when is_list(Prop) -> error(JObj) -> error(kz_json:to_proplist(JObj)). --spec error_v(api_terms()) -> boolean(). +-spec error_v(kz_term:api_terms()) -> boolean(). error_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?ASR_ERROR_HEADERS, ?ASR_ERROR_VALUES, ?ASR_ERROR_TYPES); error_v(JObj) -> @@ -115,7 +115,7 @@ error_v(JObj) -> %% bind to a queue to the asr exchange and events %% @end %%-------------------------------------------------------------------- --spec bind_q(binary(), kz_proplist()) -> 'ok'. +-spec bind_q(binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, _Props) -> amqp_util:bind_q_to_callctl(Queue, ?KEY_ASR_REQ). @@ -142,8 +142,8 @@ declare_exchanges() -> %% prepare and publish an asr request %% @end %%-------------------------------------------------------------------- --spec publish_req(api_terms()) -> 'ok'. --spec publish_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_req(kz_term:api_terms()) -> 'ok'. +-spec publish_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_req(JObj) -> publish_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_req(Req, ContentType) -> @@ -155,8 +155,8 @@ publish_req(Req, ContentType) -> %% prepare and publish an asr response %% @end %%-------------------------------------------------------------------- --spec publish_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_resp(Queue, JObj) -> publish_resp(Queue, JObj, ?DEFAULT_CONTENT_TYPE). publish_resp(Queue, Resp, ContentType) -> @@ -168,8 +168,8 @@ publish_resp(Queue, Resp, ContentType) -> %% prepare and publish an asr error %% @end %%-------------------------------------------------------------------- --spec publish_error(ne_binary(), api_terms()) -> 'ok'. --spec publish_error(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_error(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_error(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_error(Queue, JObj) -> publish_error(Queue, JObj, ?DEFAULT_CONTENT_TYPE). publish_error(Queue, Error, ContentType) -> diff --git a/core/kazoo_amqp/src/api/kapi_authn.erl b/core/kazoo_amqp/src/api/kapi_authn.erl index a8967e62508..babd4b23622 100644 --- a/core/kazoo_amqp/src/api/kapi_authn.erl +++ b/core/kazoo_amqp/src/api/kapi_authn.erl @@ -87,7 +87,7 @@ %% Takes proplist, creates JSON iolist or error %% @end %%-------------------------------------------------------------------- --spec req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. req(Prop) when is_list(Prop) -> case req_v(Prop) of true -> kz_api:build_message(Prop, ?AUTHN_REQ_HEADERS, ?OPTIONAL_AUTHN_REQ_HEADERS); @@ -96,13 +96,13 @@ req(Prop) when is_list(Prop) -> req(JObj) -> req(kz_json:to_proplist(JObj)). --spec req_v(api_terms()) -> boolean(). +-spec req_v(kz_term:api_terms()) -> boolean(). req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?AUTHN_REQ_HEADERS, ?AUTHN_REQ_VALUES, ?AUTHN_REQ_TYPES); req_v(JObj) -> req_v(kz_json:to_proplist(JObj)). --spec req_event_type() -> {ne_binary(), ne_binary()}. +-spec req_event_type() -> {kz_term:ne_binary(), kz_term:ne_binary()}. req_event_type() -> {?EVENT_CATEGORY, ?AUTHN_REQ_EVENT_NAME}. @@ -111,7 +111,7 @@ req_event_type() -> %% Takes proplist, creates JSON iolist or error %% @end %%-------------------------------------------------------------------- --spec resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. resp(Prop) when is_list(Prop) -> case resp_v(Prop) of true -> kz_api:build_message(Prop, ?AUTHN_RESP_HEADERS, ?OPTIONAL_AUTHN_RESP_HEADERS); @@ -120,7 +120,7 @@ resp(Prop) when is_list(Prop) -> resp(JObj) -> resp(kz_json:to_proplist(JObj)). --spec resp_v(api_terms()) -> boolean(). +-spec resp_v(kz_term:api_terms()) -> boolean(). resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?AUTHN_RESP_HEADERS, ?AUTHN_RESP_VALUES, ?AUTHN_RESP_TYPES); resp_v(JObj) -> @@ -131,7 +131,7 @@ resp_v(JObj) -> %% Takes proplist, creates JSON iolist or error %% @end %%-------------------------------------------------------------------- --spec error(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec error(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. error(Prop) when is_list(Prop) -> case error_v(Prop) of 'true' -> kz_api:build_message(Prop, ?AUTHN_ERR_HEADERS, ?OPTIONAL_AUTHN_ERR_HEADERS); @@ -139,7 +139,7 @@ error(Prop) when is_list(Prop) -> end; error(JObj) -> error(kz_json:to_proplist(JObj)). --spec error_v(api_terms()) -> boolean(). +-spec error_v(kz_term:api_terms()) -> boolean(). error_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?AUTHN_ERR_HEADERS, ?AUTHN_ERR_VALUES, ?AUTHN_ERR_TYPES); error_v(JObj) -> error_v(kz_json:to_proplist(JObj)). @@ -148,12 +148,12 @@ error_v(JObj) -> error_v(kz_json:to_proplist(JObj)). %% @doc Setup and tear down bindings for authn gen_listeners %% @end %%-------------------------------------------------------------------- --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Q, Props) -> Realm = props:get_value('realm', Props, <<"*">>), amqp_util:bind_q_to_callmgr(Q, get_authn_req_routing(Realm)). --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Q, Props) -> Realm = props:get_value('realm', Props, <<"*">>), amqp_util:unbind_q_from_callmgr(Q, get_authn_req_routing(Realm)). @@ -171,24 +171,24 @@ declare_exchanges() -> %% @doc Publish the JSON iolist() to the proper Exchange %% @end %%-------------------------------------------------------------------- --spec publish_req(api_terms()) -> 'ok'. --spec publish_req(api_terms(), binary()) -> 'ok'. +-spec publish_req(kz_term:api_terms()) -> 'ok'. +-spec publish_req(kz_term:api_terms(), binary()) -> 'ok'. publish_req(JObj) -> publish_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_req(Req, ContentType) -> {ok, Payload} = kz_api:prepare_api_payload(Req, ?AUTHN_REQ_VALUES, fun req/1), amqp_util:callmgr_publish(Payload, ContentType, get_authn_req_routing(Req)). --spec publish_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_resp(ne_binary(), api_terms(), binary()) -> 'ok'. +-spec publish_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_resp(kz_term:ne_binary(), kz_term:api_terms(), binary()) -> 'ok'. publish_resp(Queue, JObj) -> publish_resp(Queue, JObj, ?DEFAULT_CONTENT_TYPE). publish_resp(Queue, Resp, ContentType) -> {ok, Payload} = kz_api:prepare_api_payload(Resp, ?AUTHN_RESP_VALUES, fun resp/1), amqp_util:targeted_publish(Queue, Payload, ContentType). --spec publish_error(ne_binary(), api_terms()) -> 'ok'. --spec publish_error(ne_binary(), api_terms(), binary()) -> 'ok'. +-spec publish_error(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_error(kz_term:ne_binary(), kz_term:api_terms(), binary()) -> 'ok'. publish_error(Queue, JObj) -> publish_error(Queue, JObj, ?DEFAULT_CONTENT_TYPE). publish_error(Queue, Resp, ContentType) -> @@ -201,7 +201,7 @@ publish_error(Queue, Resp, ContentType) -> %% creating the routing key for either binding queues or publishing messages %% @end %%----------------------------------------------------------------------------- --spec get_authn_req_routing(ne_binary() | api_terms()) -> ne_binary(). +-spec get_authn_req_routing(kz_term:ne_binary() | kz_term:api_terms()) -> kz_term:ne_binary(). get_authn_req_routing(Realm) when is_binary(Realm) -> list_to_binary([?KEY_AUTHN_REQ, ".", amqp_util:encode(Realm)]); get_authn_req_routing(Req) -> @@ -216,7 +216,7 @@ get_authn_req_routing(Req) -> %% extract the auth user from the API request %% @end %%----------------------------------------------------------------------------- --spec get_auth_user(kz_json:object()) -> api_binary(). +-spec get_auth_user(kz_json:object()) -> kz_term:api_binary(). get_auth_user(ApiJObj) -> AuthUser = case kz_json:get_value(<<"Auth-User">>, ApiJObj, <<"unknown">>) of <<"unknown">> -> @@ -234,7 +234,7 @@ get_auth_user(ApiJObj) -> %% when provided with an IP %% @end %%----------------------------------------------------------------------------- --spec get_auth_realm(kz_json:object() | kz_proplist()) -> ne_binary(). +-spec get_auth_realm(kz_json:object() | kz_term:proplist()) -> kz_term:ne_binary(). get_auth_realm(ApiProp) when is_list(ApiProp) -> AuthRealm = props:get_value(<<"Auth-Realm">>, ApiProp, <<"missing.realm">>), Realm = case kz_network_utils:is_ipv4(AuthRealm) diff --git a/core/kazoo_amqp/src/api/kapi_authz.erl b/core/kazoo_amqp/src/api/kapi_authz.erl index 40b968fab47..faa772e6bba 100644 --- a/core/kazoo_amqp/src/api/kapi_authz.erl +++ b/core/kazoo_amqp/src/api/kapi_authz.erl @@ -65,7 +65,7 @@ ,{<<"Custom-Channel-Vars">>, fun kz_json:is_json_object/1} ,{<<"Usage">>, fun kz_json:is_json_object/1} ]). -%% TODO: allow only ne_binaries() +%% TODO: allow only kz_term:ne_binaries() -define(BALANCE_CHECK_REQ_TYPES, [{<<"Accounts">>, fun is_list/1}]). %% Authorization Responses @@ -93,7 +93,7 @@ %% Takes proplist, creates JSON iolist or error %% @end %%-------------------------------------------------------------------- --spec authz_req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec authz_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. authz_req(Prop) when is_list(Prop) -> case authz_req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?AUTHZ_REQ_HEADERS, ?OPTIONAL_AUTHZ_REQ_HEADERS); @@ -102,13 +102,13 @@ authz_req(Prop) when is_list(Prop) -> authz_req(JObj) -> authz_req(kz_json:to_proplist(JObj)). --spec authz_req_v(api_terms()) -> boolean(). +-spec authz_req_v(kz_term:api_terms()) -> boolean(). authz_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?AUTHZ_REQ_HEADERS, ?AUTHZ_REQ_VALUES, ?AUTHZ_REQ_TYPES); authz_req_v(JObj) -> authz_req_v(kz_json:to_proplist(JObj)). --spec balance_check_req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec balance_check_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. balance_check_req(Prop) when is_list(Prop) -> case balance_check_req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?BALANCE_CHECK_REQ_HEADERS, ?OPTIONAL_BALANCE_CHECK_REQ_HEADERS); @@ -117,7 +117,7 @@ balance_check_req(Prop) when is_list(Prop) -> balance_check_req(JObj) -> balance_check_req(kz_json:to_proplist(JObj)). --spec balance_check_req_v(api_terms()) -> boolean(). +-spec balance_check_req_v(kz_term:api_terms()) -> boolean(). balance_check_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?BALANCE_CHECK_REQ_HEADERS, ?BALANCE_CHECK_REQ_VALUES, ?BALANCE_CHECK_REQ_TYPES); balance_check_req_v(JObj) -> @@ -128,7 +128,7 @@ balance_check_req_v(JObj) -> %% Takes proplist, creates JSON iolist or error %% @end %%-------------------------------------------------------------------- --spec authz_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec authz_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. authz_resp(Prop) when is_list(Prop) -> case authz_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?AUTHZ_RESP_HEADERS, ?OPTIONAL_AUTHZ_RESP_HEADERS); @@ -137,13 +137,13 @@ authz_resp(Prop) when is_list(Prop) -> authz_resp(JObj) -> authz_resp(kz_json:to_proplist(JObj)). --spec authz_resp_v(api_terms()) -> boolean(). +-spec authz_resp_v(kz_term:api_terms()) -> boolean(). authz_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?AUTHZ_RESP_HEADERS, ?AUTHZ_RESP_VALUES, ?AUTHZ_RESP_TYPES); authz_resp_v(JObj) -> authz_resp_v(kz_json:to_proplist(JObj)). --spec balance_check_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec balance_check_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. balance_check_resp(Prop) when is_list(Prop) -> case balance_check_resp_v(Prop) of 'true' -> @@ -153,7 +153,7 @@ balance_check_resp(Prop) when is_list(Prop) -> balance_check_resp(JObj) -> balance_check_resp(kz_json:to_proplist(JObj)). --spec balance_check_resp_v(api_terms()) -> boolean(). +-spec balance_check_resp_v(kz_term:api_terms()) -> boolean(). balance_check_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?BALANCE_CHECK_RESP_HEADERS, ?BALANCE_CHECK_RESP_VALUES, ?BALANCE_CHECK_RESP_TYPES); balance_check_resp_v(JObj) -> @@ -163,7 +163,7 @@ balance_check_resp_v(JObj) -> %% @doc Setup and tear down bindings for authz gen_listeners %% @end %%-------------------------------------------------------------------- --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, Props) -> bind_to_q(Queue, props:get_value('restrict_to', Props)). @@ -180,7 +180,7 @@ bind_to_q(Q, ['balance_check'|T]) -> bind_to_q(Q, T); bind_to_q(_Q, []) -> 'ok'. --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Q, Props) -> unbind_q_from(Q, props:get_value('restrict_to', Props)). @@ -210,40 +210,40 @@ declare_exchanges() -> %% @doc Publish the JSON iolist() to the proper Exchange %% @end %%-------------------------------------------------------------------- --spec publish_authz_req(api_terms()) -> 'ok'. --spec publish_authz_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_authz_req(kz_term:api_terms()) -> 'ok'. +-spec publish_authz_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_authz_req(JObj) -> publish_authz_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_authz_req(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?AUTHZ_REQ_VALUES, fun authz_req/1), amqp_util:callmgr_publish(Payload, ContentType, ?KEY_AUTHZ_REQ). --spec publish_authz_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_authz_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_authz_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_authz_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_authz_resp(Queue, JObj) -> publish_authz_resp(Queue, JObj, ?DEFAULT_CONTENT_TYPE). publish_authz_resp(Queue, Resp, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Resp, ?AUTHZ_RESP_VALUES, fun authz_resp/1), amqp_util:targeted_publish(Queue, Payload, ContentType). --spec publish_balance_check_req(api_terms()) -> 'ok'. --spec publish_balance_check_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_balance_check_req(kz_term:api_terms()) -> 'ok'. +-spec publish_balance_check_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_balance_check_req(JObj) -> publish_balance_check_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_balance_check_req(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?BALANCE_CHECK_REQ_VALUES, fun balance_check_req/1), amqp_util:callmgr_publish(Payload, ContentType, ?KEY_BALANCE_CHECK_REQ). --spec publish_balance_check_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_balance_check_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_balance_check_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_balance_check_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_balance_check_resp(Queue, JObj) -> publish_balance_check_resp(Queue, JObj, ?DEFAULT_CONTENT_TYPE). publish_balance_check_resp(Queue, Resp, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Resp, ?BALANCE_CHECK_RESP_VALUES, fun balance_check_resp/1), amqp_util:targeted_publish(Queue, Payload, ContentType). --spec broadcast_authz_resp(api_terms()) -> 'ok'. --spec broadcast_authz_resp(api_terms(), ne_binary()) -> 'ok'. +-spec broadcast_authz_resp(kz_term:api_terms()) -> 'ok'. +-spec broadcast_authz_resp(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. broadcast_authz_resp(JObj) -> broadcast_authz_resp(JObj, ?DEFAULT_CONTENT_TYPE). broadcast_authz_resp(Resp, ContentType) -> diff --git a/core/kazoo_amqp/src/api/kapi_call.erl b/core/kazoo_amqp/src/api/kapi_call.erl index 4fb4a8f7966..d62d789f6fe 100644 --- a/core/kazoo_amqp/src/api/kapi_call.erl +++ b/core/kazoo_amqp/src/api/kapi_call.erl @@ -60,7 +60,7 @@ -include_lib("kazoo_amqp/src/amqp_util.hrl"). -include("kapi_call.hrl"). --spec optional_call_event_headers() -> ne_binaries(). +-spec optional_call_event_headers() -> kz_term:ne_binaries(). optional_call_event_headers() -> ?OPTIONAL_CALL_EVENT_HEADERS. @@ -69,7 +69,7 @@ optional_call_event_headers() -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec event(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec event(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. event(Prop) when is_list(Prop) -> case event_v(Prop) of 'true' -> kz_api:build_message(Prop, ?CALL_EVENT_HEADERS, ?OPTIONAL_CALL_EVENT_HEADERS); @@ -77,7 +77,7 @@ event(Prop) when is_list(Prop) -> end; event(JObj) -> event(kz_json:to_proplist(JObj)). --spec event_v(api_terms()) -> boolean(). +-spec event_v(kz_term:api_terms()) -> boolean(). event_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CALL_EVENT_HEADERS, ?CALL_EVENT_VALUES, ?CALL_EVENT_TYPES); event_v(JObj) -> event_v(kz_json:to_proplist(JObj)). @@ -87,7 +87,7 @@ event_v(JObj) -> event_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec channel_status_req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec channel_status_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. channel_status_req(Prop) when is_list(Prop) -> case channel_status_req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?CHANNEL_STATUS_REQ_HEADERS, ?OPTIONAL_CHANNEL_STATUS_REQ_HEADERS); @@ -95,7 +95,7 @@ channel_status_req(Prop) when is_list(Prop) -> end; channel_status_req(JObj) -> channel_status_req(kz_json:to_proplist(JObj)). --spec channel_status_req_v(api_terms()) -> boolean(). +-spec channel_status_req_v(kz_term:api_terms()) -> boolean(). channel_status_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CHANNEL_STATUS_REQ_HEADERS, ?CHANNEL_STATUS_REQ_VALUES, ?CHANNEL_STATUS_REQ_TYPES); channel_status_req_v(JObj) -> channel_status_req_v(kz_json:to_proplist(JObj)). @@ -105,7 +105,7 @@ channel_status_req_v(JObj) -> channel_status_req_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec channel_status_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec channel_status_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. channel_status_resp(Prop) when is_list(Prop) -> case channel_status_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?CHANNEL_STATUS_RESP_HEADERS, ?OPTIONAL_CHANNEL_STATUS_RESP_HEADERS); @@ -113,7 +113,7 @@ channel_status_resp(Prop) when is_list(Prop) -> end; channel_status_resp(JObj) -> channel_status_resp(kz_json:to_proplist(JObj)). --spec channel_status_resp_v(api_terms()) -> boolean(). +-spec channel_status_resp_v(kz_term:api_terms()) -> boolean(). channel_status_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CHANNEL_STATUS_RESP_HEADERS, ?CHANNEL_STATUS_RESP_VALUES, ?CHANNEL_STATUS_RESP_TYPES); channel_status_resp_v(JObj) -> channel_status_resp_v(kz_json:to_proplist(JObj)). @@ -123,7 +123,7 @@ channel_status_resp_v(JObj) -> channel_status_resp_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec query_auth_id_req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec query_auth_id_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. query_auth_id_req(Prop) when is_list(Prop) -> case query_auth_id_req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?QUERY_AUTH_ID_REQ_HEADERS, ?OPTIONAL_QUERY_AUTH_ID_REQ_HEADERS); @@ -131,7 +131,7 @@ query_auth_id_req(Prop) when is_list(Prop) -> end; query_auth_id_req(JObj) -> query_auth_id_req(kz_json:to_proplist(JObj)). --spec query_auth_id_req_v(api_terms()) -> boolean(). +-spec query_auth_id_req_v(kz_term:api_terms()) -> boolean(). query_auth_id_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?QUERY_AUTH_ID_REQ_HEADERS, ?QUERY_AUTH_ID_REQ_VALUES, ?QUERY_AUTH_ID_REQ_TYPES); query_auth_id_req_v(JObj) -> query_auth_id_req_v(kz_json:to_proplist(JObj)). @@ -141,7 +141,7 @@ query_auth_id_req_v(JObj) -> query_auth_id_req_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec query_auth_id_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec query_auth_id_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. query_auth_id_resp(Prop) when is_list(Prop) -> case query_auth_id_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?QUERY_AUTH_ID_RESP_HEADERS, ?OPTIONAL_QUERY_AUTH_ID_RESP_HEADERS); @@ -149,7 +149,7 @@ query_auth_id_resp(Prop) when is_list(Prop) -> end; query_auth_id_resp(JObj) -> query_auth_id_resp(kz_json:to_proplist(JObj)). --spec query_auth_id_resp_v(api_terms()) -> boolean(). +-spec query_auth_id_resp_v(kz_term:api_terms()) -> boolean(). query_auth_id_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?QUERY_AUTH_ID_RESP_HEADERS, ?QUERY_AUTH_ID_RESP_VALUES, ?QUERY_AUTH_ID_RESP_TYPES); query_auth_id_resp_v(JObj) -> query_auth_id_resp_v(kz_json:to_proplist(JObj)). @@ -159,7 +159,7 @@ query_auth_id_resp_v(JObj) -> query_auth_id_resp_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec query_user_channels_req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec query_user_channels_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. query_user_channels_req(Prop) when is_list(Prop) -> case query_user_channels_req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?QUERY_USER_CHANNELS_REQ_HEADERS, ?OPTIONAL_QUERY_USER_CHANNELS_REQ_HEADERS); @@ -167,7 +167,7 @@ query_user_channels_req(Prop) when is_list(Prop) -> end; query_user_channels_req(JObj) -> query_user_channels_req(kz_json:to_proplist(JObj)). --spec query_user_channels_req_v(api_terms()) -> boolean(). +-spec query_user_channels_req_v(kz_term:api_terms()) -> boolean(). query_user_channels_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?QUERY_USER_CHANNELS_REQ_HEADERS, ?QUERY_USER_CHANNELS_REQ_VALUES, ?QUERY_USER_CHANNELS_REQ_TYPES); query_user_channels_req_v(JObj) -> query_user_channels_req_v(kz_json:to_proplist(JObj)). @@ -177,7 +177,7 @@ query_user_channels_req_v(JObj) -> query_user_channels_req_v(kz_json:to_proplist %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec query_user_channels_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec query_user_channels_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. query_user_channels_resp(Prop) when is_list(Prop) -> case query_user_channels_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?QUERY_USER_CHANNELS_RESP_HEADERS, ?OPTIONAL_QUERY_USER_CHANNELS_RESP_HEADERS); @@ -185,7 +185,7 @@ query_user_channels_resp(Prop) when is_list(Prop) -> end; query_user_channels_resp(JObj) -> query_user_channels_resp(kz_json:to_proplist(JObj)). --spec query_user_channels_resp_v(api_terms()) -> boolean(). +-spec query_user_channels_resp_v(kz_term:api_terms()) -> boolean(). query_user_channels_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?QUERY_USER_CHANNELS_RESP_HEADERS, ?QUERY_USER_CHANNELS_RESP_VALUES, ?QUERY_USER_CHANNELS_RESP_TYPES); query_user_channels_resp_v(JObj) -> query_user_channels_resp_v(kz_json:to_proplist(JObj)). @@ -195,7 +195,7 @@ query_user_channels_resp_v(JObj) -> query_user_channels_resp_v(kz_json:to_propli %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec query_account_channels_req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec query_account_channels_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. query_account_channels_req(Prop) when is_list(Prop) -> case query_account_channels_req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?QUERY_ACCOUNT_CHANNELS_REQ_HEADERS, ?OPTIONAL_QUERY_ACCOUNT_CHANNELS_REQ_HEADERS); @@ -203,7 +203,7 @@ query_account_channels_req(Prop) when is_list(Prop) -> end; query_account_channels_req(JObj) -> query_account_channels_req(kz_json:to_proplist(JObj)). --spec query_account_channels_req_v(api_terms()) -> boolean(). +-spec query_account_channels_req_v(kz_term:api_terms()) -> boolean(). query_account_channels_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?QUERY_ACCOUNT_CHANNELS_REQ_HEADERS, ?QUERY_ACCOUNT_CHANNELS_REQ_VALUES, ?QUERY_ACCOUNT_CHANNELS_REQ_TYPES); query_account_channels_req_v(JObj) -> query_account_channels_req_v(kz_json:to_proplist(JObj)). @@ -213,7 +213,7 @@ query_account_channels_req_v(JObj) -> query_account_channels_req_v(kz_json:to_pr %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec query_account_channels_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec query_account_channels_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. query_account_channels_resp(Prop) when is_list(Prop) -> case query_account_channels_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?QUERY_ACCOUNT_CHANNELS_RESP_HEADERS, ?OPTIONAL_QUERY_ACCOUNT_CHANNELS_RESP_HEADERS); @@ -221,7 +221,7 @@ query_account_channels_resp(Prop) when is_list(Prop) -> end; query_account_channels_resp(JObj) -> query_account_channels_resp(kz_json:to_proplist(JObj)). --spec query_account_channels_resp_v(api_terms()) -> boolean(). +-spec query_account_channels_resp_v(kz_term:api_terms()) -> boolean(). query_account_channels_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?QUERY_ACCOUNT_CHANNELS_RESP_HEADERS, ?QUERY_ACCOUNT_CHANNELS_RESP_VALUES, ?QUERY_ACCOUNT_CHANNELS_RESP_TYPES); query_account_channels_resp_v(JObj) -> query_account_channels_resp_v(kz_json:to_proplist(JObj)). @@ -231,7 +231,7 @@ query_account_channels_resp_v(JObj) -> query_account_channels_resp_v(kz_json:to_ %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec query_channels_req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec query_channels_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. query_channels_req(Prop) when is_list(Prop) -> case query_channels_req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?QUERY_CHANNELS_REQ_HEADERS, ?OPTIONAL_QUERY_CHANNELS_REQ_HEADERS); @@ -239,7 +239,7 @@ query_channels_req(Prop) when is_list(Prop) -> end; query_channels_req(JObj) -> query_channels_req(kz_json:to_proplist(JObj)). --spec query_channels_req_v(api_terms()) -> boolean(). +-spec query_channels_req_v(kz_term:api_terms()) -> boolean(). query_channels_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?QUERY_CHANNELS_REQ_HEADERS, ?QUERY_CHANNELS_REQ_VALUES, ?QUERY_CHANNELS_REQ_TYPES); query_channels_req_v(JObj) -> query_channels_req_v(kz_json:to_proplist(JObj)). @@ -249,7 +249,7 @@ query_channels_req_v(JObj) -> query_channels_req_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec query_channels_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec query_channels_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. query_channels_resp(Prop) when is_list(Prop) -> case query_channels_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?QUERY_CHANNELS_RESP_HEADERS, ?OPTIONAL_QUERY_CHANNELS_RESP_HEADERS); @@ -257,7 +257,7 @@ query_channels_resp(Prop) when is_list(Prop) -> end; query_channels_resp(JObj) -> query_channels_resp(kz_json:to_proplist(JObj)). --spec query_channels_resp_v(api_terms()) -> boolean(). +-spec query_channels_resp_v(kz_term:api_terms()) -> boolean(). query_channels_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?QUERY_CHANNELS_RESP_HEADERS, ?QUERY_CHANNELS_RESP_VALUES, ?QUERY_CHANNELS_RESP_TYPES); query_channels_resp_v(JObj) -> query_channels_resp_v(kz_json:to_proplist(JObj)). @@ -267,7 +267,7 @@ query_channels_resp_v(JObj) -> query_channels_resp_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec usurp_control(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec usurp_control(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. usurp_control(Prop) when is_list(Prop) -> case usurp_control_v(Prop) of 'true' -> kz_api:build_message(Prop, ?CALL_USURP_CONTROL_HEADERS, ?OPTIONAL_CALL_USURP_CONTROL_HEADERS); @@ -275,7 +275,7 @@ usurp_control(Prop) when is_list(Prop) -> end; usurp_control(JObj) -> usurp_control(kz_json:to_proplist(JObj)). --spec usurp_control_v(api_terms()) -> boolean(). +-spec usurp_control_v(kz_term:api_terms()) -> boolean(). usurp_control_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CALL_USURP_CONTROL_HEADERS, ?CALL_USURP_CONTROL_VALUES, ?CALL_USURP_CONTROL_TYPES); usurp_control_v(JObj) -> usurp_control_v(kz_json:to_proplist(JObj)). @@ -285,7 +285,7 @@ usurp_control_v(JObj) -> usurp_control_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec usurp_publisher(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec usurp_publisher(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. usurp_publisher(Prop) when is_list(Prop) -> case usurp_publisher_v(Prop) of 'true' -> kz_api:build_message(Prop, ?PUBLISHER_USURP_CONTROL_HEADERS, ?OPTIONAL_PUBLISHER_USURP_CONTROL_HEADERS); @@ -293,12 +293,12 @@ usurp_publisher(Prop) when is_list(Prop) -> end; usurp_publisher(JObj) -> usurp_publisher(kz_json:to_proplist(JObj)). --spec usurp_publisher_v(api_terms()) -> boolean(). +-spec usurp_publisher_v(kz_term:api_terms()) -> boolean(). usurp_publisher_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?PUBLISHER_USURP_CONTROL_HEADERS, ?PUBLISHER_USURP_CONTROL_VALUES, ?PUBLISHER_USURP_CONTROL_TYPES); usurp_publisher_v(JObj) -> usurp_publisher_v(kz_json:to_proplist(JObj)). --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, Props) -> CallId = props:get_value('callid', Props, <<"*">>), Events = props:get_value('restrict_to', Props, [<<"*">>]), @@ -309,7 +309,7 @@ bind_q(Q, [Event|T], CallId) -> bind_q(Q, T, CallId); bind_q(_Q, [], _CallId) -> 'ok'. --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Queue, Props) -> CallId = props:get_value('callid', Props, <<"*">>), Events = props:get_value('restrict_to', Props, [<<"*">>]), @@ -330,8 +330,8 @@ declare_exchanges() -> amqp_util:callevt_exchange(), amqp_util:callmgr_exchange(). --spec publish_event(api_terms()) -> 'ok'. --spec publish_event(api_terms(), ne_binary()) -> 'ok'. +-spec publish_event(kz_term:api_terms()) -> 'ok'. +-spec publish_event(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_event(Event) -> publish_event(Event, ?DEFAULT_CONTENT_TYPE). publish_event(Event, ContentType) when is_list(Event) -> CallId = props:get_first_defined([<<"Origination-Call-ID">>, <<"Call-ID">>, <<"Unique-ID">>], Event), @@ -341,9 +341,9 @@ publish_event(Event, ContentType) when is_list(Event) -> publish_event(Event, ContentType) -> publish_event(kz_json:to_proplist(Event), ContentType). --spec publish_channel_status_req(api_terms()) -> 'ok'. --spec publish_channel_status_req(ne_binary(), api_terms()) -> 'ok'. --spec publish_channel_status_req(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_channel_status_req(kz_term:api_terms()) -> 'ok'. +-spec publish_channel_status_req(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_channel_status_req(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_channel_status_req(API) -> case is_list(API) of 'true' -> publish_channel_status_req(props:get_value(<<"Call-ID">>, API), API); @@ -355,17 +355,17 @@ publish_channel_status_req(CallId, Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?CHANNEL_STATUS_REQ_VALUES, fun channel_status_req/1), amqp_util:callevt_publish(?CALL_EVENT_ROUTING_KEY('status_req', CallId), Payload, ContentType). --spec publish_channel_status_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_channel_status_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_channel_status_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_channel_status_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_channel_status_resp(RespQ, JObj) -> publish_channel_status_resp(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_channel_status_resp(RespQ, Resp, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Resp, ?CHANNEL_STATUS_RESP_VALUES, fun channel_status_resp/1), amqp_util:targeted_publish(RespQ, Payload, ContentType). --spec publish_query_auth_id_req(api_terms()) -> 'ok'. --spec publish_query_auth_id_req(ne_binary(), api_terms()) -> 'ok'. --spec publish_query_auth_id_req(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_query_auth_id_req(kz_term:api_terms()) -> 'ok'. +-spec publish_query_auth_id_req(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_query_auth_id_req(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_query_auth_id_req(API) -> case is_list(API) of 'true' -> publish_query_auth_id_req(props:get_value(<<"Auth-ID">>, API), API); @@ -377,15 +377,15 @@ publish_query_auth_id_req(AuthId, Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?QUERY_AUTH_ID_REQ_VALUES, fun query_auth_id_req/1), amqp_util:callevt_publish(?CALL_EVENT_ROUTING_KEY('status_req', AuthId), Payload, ContentType). --spec publish_query_auth_id_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_query_auth_id_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_query_auth_id_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_query_auth_id_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_query_auth_id_resp(RespQ, JObj) -> publish_query_auth_id_resp(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_query_auth_id_resp(RespQ, Resp, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Resp, ?QUERY_AUTH_ID_RESP_VALUES, fun query_auth_id_resp/1), amqp_util:targeted_publish(RespQ, Payload, ContentType). --spec publish_query_user_channels_req(api_terms()) -> 'ok'. +-spec publish_query_user_channels_req(kz_term:api_terms()) -> 'ok'. publish_query_user_channels_req(Props) when is_list(Props) -> publish_query_user_channels_req(Props ,props:get_value(<<"Username">>, Props) @@ -399,7 +399,7 @@ publish_query_user_channels_req(JObj) -> ,?DEFAULT_CONTENT_TYPE ). --spec publish_query_user_channels_req(api_terms(), api_binary(), api_binary(), ne_binary()) -> 'ok'. +-spec publish_query_user_channels_req(kz_term:api_terms(), kz_term:api_binary(), kz_term:api_binary(), kz_term:ne_binary()) -> 'ok'. publish_query_user_channels_req(Req, 'undefined', 'undefined', ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?QUERY_USER_CHANNELS_REQ_VALUES, fun query_user_channels_req/1), amqp_util:callevt_publish(?CALL_EVENT_ROUTING_KEY('status_req', <<>>), Payload, ContentType); @@ -411,16 +411,16 @@ publish_query_user_channels_req(Req, Username, Realm, ContentType) -> User = <>, amqp_util:callevt_publish(?CALL_EVENT_ROUTING_KEY('status_req', User), Payload, ContentType). --spec publish_query_user_channels_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_query_user_channels_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_query_user_channels_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_query_user_channels_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_query_user_channels_resp(RespQ, JObj) -> publish_query_user_channels_resp(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_query_user_channels_resp(RespQ, Resp, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Resp, ?QUERY_USER_CHANNELS_RESP_VALUES, fun query_user_channels_resp/1), amqp_util:targeted_publish(RespQ, Payload, ContentType). --spec publish_query_account_channels_req(api_terms()) -> 'ok'. --spec publish_query_account_channels_req(api_terms(), ne_binary(), ne_binary()) -> 'ok'. +-spec publish_query_account_channels_req(kz_term:api_terms()) -> 'ok'. +-spec publish_query_account_channels_req(kz_term:api_terms(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. publish_query_account_channels_req(Props) when is_list(Props) -> publish_query_account_channels_req(Props ,props:get_value(<<"Account-ID">>, Props) @@ -436,16 +436,16 @@ publish_query_account_channels_req(Req, AccountId, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?QUERY_ACCOUNT_CHANNELS_REQ_VALUES, fun query_account_channels_req/1), amqp_util:callevt_publish(?CALL_EVENT_ROUTING_KEY('status_req', AccountId), Payload, ContentType). --spec publish_query_account_channels_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_query_account_channels_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_query_account_channels_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_query_account_channels_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_query_account_channels_resp(RespQ, JObj) -> publish_query_account_channels_resp(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_query_account_channels_resp(RespQ, Resp, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Resp, ?QUERY_ACCOUNT_CHANNELS_RESP_VALUES, fun query_account_channels_resp/1), amqp_util:targeted_publish(RespQ, Payload, ContentType). --spec publish_query_channels_req(api_terms()) -> 'ok'. --spec publish_query_channels_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_query_channels_req(kz_term:api_terms()) -> 'ok'. +-spec publish_query_channels_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_query_channels_req(ApiProps) -> publish_query_channels_req(ApiProps, ?DEFAULT_CONTENT_TYPE). publish_query_channels_req(ApiProps, ContentType) when is_list(ApiProps) -> {'ok', Payload} = kz_api:prepare_api_payload(ApiProps, ?QUERY_CHANNELS_REQ_VALUES, fun query_channels_req/1), @@ -453,8 +453,8 @@ publish_query_channels_req(ApiProps, ContentType) when is_list(ApiProps) -> publish_query_channels_req(JObj, ContentType) -> publish_query_channels_req(kz_json:to_proplist(JObj), ContentType). --spec publish_query_channels_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_query_channels_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_query_channels_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_query_channels_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_query_channels_resp(RespQ, ApiProps) -> publish_query_channels_resp(RespQ, ApiProps, ?DEFAULT_CONTENT_TYPE). publish_query_channels_resp(RespQ, ApiProps, ContentType) when is_list(ApiProps) -> {'ok', Payload} = kz_api:prepare_api_payload(ApiProps, ?QUERY_CHANNELS_RESP_VALUES, fun query_channels_resp/1), @@ -462,27 +462,27 @@ publish_query_channels_resp(RespQ, ApiProps, ContentType) when is_list(ApiProps) publish_query_channels_resp(RespQ, JObj, ContentType) -> publish_query_channels_resp(RespQ, kz_json:to_proplist(JObj), ContentType). --spec publish_usurp_control(ne_binary(), api_terms()) -> 'ok'. --spec publish_usurp_control(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_usurp_control(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_usurp_control(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_usurp_control(CallId, JObj) -> publish_usurp_control(CallId, JObj, ?DEFAULT_CONTENT_TYPE). publish_usurp_control(CallId, JObj, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(JObj, ?CALL_USURP_CONTROL_VALUES, fun usurp_control/1), amqp_util:callevt_publish(?CALL_EVENT_ROUTING_KEY('usurp_control', CallId), Payload, ContentType). --spec publish_usurp_publisher(ne_binary(), api_terms()) -> 'ok'. --spec publish_usurp_publisher(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_usurp_publisher(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_usurp_publisher(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_usurp_publisher(CallId, JObj) -> publish_usurp_publisher(CallId, JObj, ?DEFAULT_CONTENT_TYPE). publish_usurp_publisher(CallId, JObj, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(JObj, ?PUBLISHER_USURP_CONTROL_VALUES, fun usurp_publisher/1), amqp_util:callevt_publish(?CALL_EVENT_ROUTING_KEY('publisher_usurp', CallId), Payload, ContentType). --spec get_status(api_terms()) -> ne_binary(). +-spec get_status(kz_term:api_terms()) -> kz_term:ne_binary(). get_status(API) when is_list(API) -> props:get_value(<<"Status">>, API); get_status(API) -> kz_json:get_value(<<"Status">>, API). --spec first_username(api_terms()) -> ne_binary(). +-spec first_username(kz_term:api_terms()) -> kz_term:ne_binary(). first_username(Props) when is_list(Props) -> [U|_] = props:get_value(<<"Usernames">>, Props), U; @@ -490,6 +490,6 @@ first_username(JObj) -> [U|_] = kz_json:get_value(<<"Usernames">>, JObj), U. --spec event_routing_key(ne_binary(), ne_binary()) -> ne_binary(). +-spec event_routing_key(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). event_routing_key(EventName, CallId) -> ?CALL_EVENT_ROUTING_KEY(EventName, CallId). diff --git a/core/kazoo_amqp/src/api/kapi_callflow.erl b/core/kazoo_amqp/src/api/kapi_callflow.erl index 5cd9843fe27..a9b10c04bff 100644 --- a/core/kazoo_amqp/src/api/kapi_callflow.erl +++ b/core/kazoo_amqp/src/api/kapi_callflow.erl @@ -31,7 +31,7 @@ %% Takes proplist, creates JSON iolist or error %% @end %%-------------------------------------------------------------------- --spec resume(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec resume(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. resume(Prop) when is_list(Prop) -> case resume_v(Prop) of 'true' -> kz_api:build_message(Prop, ?RESUME_HEADERS, ?OPTIONAL_RESUME_HEADERS); @@ -39,16 +39,16 @@ resume(Prop) when is_list(Prop) -> end; resume(JObj) -> resume(kz_json:to_proplist(JObj)). --spec resume_v(api_terms()) -> boolean(). +-spec resume_v(kz_term:api_terms()) -> boolean(). resume_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?RESUME_HEADERS, ?RESUME_VALUES, ?RESUME_TYPES); resume_v(JObj) -> resume_v(kz_json:to_proplist(JObj)). --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Q, _Props) -> amqp_util:bind_q_to_kapps(Q, ?RESUME_ROUTING_KEY). --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Q, _Props) -> amqp_util:unbind_q_from_kapps(Q, ?RESUME_ROUTING_KEY). @@ -65,7 +65,7 @@ declare_exchanges() -> %% @doc Publish the JSON iolist() to the proper Exchange %% @end %%-------------------------------------------------------------------- --spec publish_resume(api_terms()) -> 'ok'. +-spec publish_resume(kz_term:api_terms()) -> 'ok'. publish_resume(JObj) -> {'ok', Payload} = kz_api:prepare_api_payload(JObj, ?RESUME_VALUES, fun resume/1), amqp_util:kapps_publish(?RESUME_ROUTING_KEY, Payload). diff --git a/core/kazoo_amqp/src/api/kapi_camping.erl b/core/kazoo_amqp/src/api/kapi_camping.erl index 9fa27071d5c..08b451ed6b8 100644 --- a/core/kazoo_amqp/src/api/kapi_camping.erl +++ b/core/kazoo_amqp/src/api/kapi_camping.erl @@ -17,7 +17,7 @@ -include_lib("amqp_util.hrl"). --type req() :: api_terms(). +-type req() :: kz_term:api_terms(). -export_type([req/0]). @@ -29,7 +29,7 @@ ]). -define(REQ_TYPES, [{<<"Camping-Request">>, fun kz_json:is_json_object/1}]). --spec req(api_terms()) -> +-spec req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. req(Prop) when is_list(Prop) -> @@ -39,18 +39,18 @@ req(Prop) when is_list(Prop) -> end; req(JObj) -> req(kz_json:to_proplist(JObj)). --spec req_v(api_terms()) -> boolean(). +-spec req_v(kz_term:api_terms()) -> boolean(). req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?REQ_HEADERS, ?REQ_VALUES, ?REQ_TYPES); req_v(JObj) -> req_v(kz_json:to_proplist(JObj)). --spec bind_q(ne_binary(), kz_proplist() | ne_binary()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist() | kz_term:ne_binary()) -> 'ok'. bind_q(Queue, Props) when is_list(Props) -> bind_q(Queue, props:get_value('account_id', Props, <<"*">>)); bind_q(Queue, ?NE_BINARY=AccountId) -> amqp_util:bind_q_to_callmgr(Queue, ?REQ_ROUTING_KEY(AccountId)). --spec unbind_q(ne_binary(), kz_proplist() | ne_binary()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist() | kz_term:ne_binary()) -> 'ok'. unbind_q(Queue, Props) when is_list(Props) -> bind_q(Queue, props:get_value('account_id', Props, <<"*">>)); unbind_q(Queue, ?NE_BINARY=AccountId) -> @@ -60,15 +60,15 @@ unbind_q(Queue, ?NE_BINARY=AccountId) -> declare_exchanges() -> amqp_util:callmgr_exchange(). --spec publish_req(api_terms()) -> 'ok'. --spec publish_req(api_terms(), binary()) -> 'ok'. +-spec publish_req(kz_term:api_terms()) -> 'ok'. +-spec publish_req(kz_term:api_terms(), binary()) -> 'ok'. publish_req(JObj) -> publish_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_req(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?REQ_VALUES, fun req/1), amqp_util:callmgr_publish(Payload, ContentType, ?REQ_ROUTING_KEY(get_account_id(Req))). --spec get_account_id(api_terms()) -> ne_binary(). +-spec get_account_id(kz_term:api_terms()) -> kz_term:ne_binary(). get_account_id(Props) when is_list(Props) -> props:get_value(<<"Account-ID">>, Props); get_account_id(JObj) -> diff --git a/core/kazoo_amqp/src/api/kapi_conf.erl b/core/kazoo_amqp/src/api/kapi_conf.erl index 817182f3476..105eceffb42 100644 --- a/core/kazoo_amqp/src/api/kapi_conf.erl +++ b/core/kazoo_amqp/src/api/kapi_conf.erl @@ -69,41 +69,41 @@ ]). -define(DOC_TYPE_UPDATE_TYPES, []). --spec get_account_id(api_terms()) -> api_binary(). +-spec get_account_id(kz_term:api_terms()) -> kz_term:api_binary(). get_account_id(API) -> get_value(API, <<"Account-ID">>). --spec get_action(api_terms()) -> api_binary(). +-spec get_action(kz_term:api_terms()) -> kz_term:api_binary(). get_action(API) -> get_value(API, <<"Action">>). --spec get_account_db(api_terms()) -> api_binary(). +-spec get_account_db(kz_term:api_terms()) -> kz_term:api_binary(). get_account_db(API) -> get_value(API, <<"Account-DB">>). --spec get_database(api_terms()) -> ne_binary(). +-spec get_database(kz_term:api_terms()) -> kz_term:ne_binary(). get_database(API) -> get_value(API, <<"Database">>). %% returns the public fields of the document --spec get_doc(api_terms()) -> api_object(). +-spec get_doc(kz_term:api_terms()) -> kz_term:api_object(). get_doc(API) -> get_value(API, <<"Doc">>). --spec get_id(api_terms()) -> api_binary(). +-spec get_id(kz_term:api_terms()) -> kz_term:api_binary(). get_id(API) -> get_value(API, <<"ID">>). %% returns the pvt_type field --spec get_type(api_terms()) -> api_binary(). +-spec get_type(kz_term:api_terms()) -> kz_term:api_binary(). get_type(API) -> get_value(API, <<"Type">>). --spec get_is_soft_deleted(api_terms()) -> boolean(). +-spec get_is_soft_deleted(kz_term:api_terms()) -> boolean(). get_is_soft_deleted(API) -> kz_term:is_true(get_value(API, <<"Is-Soft-Deleted">>)). --spec get_value(api_terms(), ne_binary()) -> any(). +-spec get_value(kz_term:api_terms(), kz_term:ne_binary()) -> any(). get_value(Prop, Key) when is_list(Prop) -> props:get_value(Key, Prop); get_value(JObj, Key) -> @@ -115,7 +115,7 @@ get_value(JObj, Key) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec doc_update(api_terms()) -> +-spec doc_update(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. doc_update(Prop) when is_list(Prop) -> @@ -126,7 +126,7 @@ doc_update(Prop) when is_list(Prop) -> doc_update(JObj) -> doc_update(kz_json:to_proplist(JObj)). --spec doc_update_v(api_terms()) -> boolean(). +-spec doc_update_v(kz_term:api_terms()) -> boolean(). doc_update_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CONF_DOC_UPDATE_HEADERS, ?CONF_DOC_UPDATE_VALUES, ?CONF_DOC_UPDATE_TYPES); doc_update_v(JObj) -> @@ -137,7 +137,7 @@ doc_update_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec doc_type_update(api_terms()) -> +-spec doc_type_update(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. doc_type_update(Prop) when is_list(Prop) -> @@ -148,14 +148,14 @@ doc_type_update(Prop) when is_list(Prop) -> doc_type_update(JObj) -> doc_type_update(kz_json:to_proplist(JObj)). --spec doc_type_update_v(api_terms()) -> boolean(). +-spec doc_type_update_v(kz_term:api_terms()) -> boolean(). doc_type_update_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?DOC_TYPE_UPDATE_HEADERS, ?DOC_TYPE_UPDATE_VALUES, ?DOC_TYPE_UPDATE_TYPES); doc_type_update_v(JObj) -> doc_type_update_v(kz_json:to_proplist(JObj)). --spec bind_q(binary(), kz_proplist()) -> 'ok'. --spec bind_q(binary(), kz_proplist(), api_atoms()) -> 'ok'. +-spec bind_q(binary(), kz_term:proplist()) -> 'ok'. +-spec bind_q(binary(), kz_term:proplist(), kz_term:api_atoms()) -> 'ok'. bind_q(Q, Props) -> bind_q(Q, Props, props:get_value('restrict_to', Props)). @@ -171,7 +171,7 @@ bind_q(Q, Props, [_|Restrict]) -> bind_q(Q, Props, Restrict); bind_q(_Q, _Props, []) -> 'ok'. --spec bind_for_doc_changes(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_for_doc_changes(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_for_doc_changes(Q, Props) -> case props:get_value('keys', Props) of 'undefined' -> @@ -183,7 +183,7 @@ bind_for_doc_changes(Q, Props) -> 'ok' end. --spec bind_for_doc_type_changes(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_for_doc_type_changes(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_for_doc_type_changes(Q, Props) -> case props:get_value('type', Props) of 'undefined' -> bind_for_doc_types(Q, Props); @@ -191,7 +191,7 @@ bind_for_doc_type_changes(Q, Props) -> amqp_util:bind_q_to_configuration(Q, doc_type_update_routing_key(Type)) end. --spec bind_for_doc_types(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_for_doc_types(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_for_doc_types(Q, Props) -> case props:get_value('types', Props) of 'undefined' -> @@ -203,8 +203,8 @@ bind_for_doc_types(Q, Props) -> 'ok' end. --spec unbind_q(binary(), kz_proplist()) -> 'ok'. --spec unbind_q(binary(), kz_proplist(), api_atoms()) -> 'ok'. +-spec unbind_q(binary(), kz_term:proplist()) -> 'ok'. +-spec unbind_q(binary(), kz_term:proplist(), kz_term:api_atoms()) -> 'ok'. unbind_q(Q, Props) -> unbind_q(Q, Props, props:get_value('restrict_to', Props)). @@ -220,7 +220,7 @@ unbind_q(Q, Props, [_|Restrict]) -> unbind_q(Q, Props, Restrict); unbind_q(_Q, _Props, []) -> 'ok'. --spec unbind_for_doc_changes(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_for_doc_changes(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_for_doc_changes(Q, Props) -> case props:get_value('keys', Props) of 'undefined' -> @@ -232,7 +232,7 @@ unbind_for_doc_changes(Q, Props) -> 'ok' end. --spec unbind_for_doc_type_changes(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_for_doc_type_changes(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_for_doc_type_changes(Q, Props) -> case props:get_value('type', Props) of 'undefined' -> unbind_for_doc_types(Q, Props); @@ -240,7 +240,7 @@ unbind_for_doc_type_changes(Q, Props) -> amqp_util:unbind_q_from_configuration(Q, doc_type_update_routing_key(Type)) end. --spec unbind_for_doc_types(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_for_doc_types(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_for_doc_types(Q, Props) -> case props:get_value('types', Props) of 'undefined' -> 'ok'; @@ -259,7 +259,7 @@ unbind_for_doc_types(Q, Props) -> declare_exchanges() -> amqp_util:configuration_exchange(). --spec get_routing_key(kz_proplist()) -> binary(). +-spec get_routing_key(kz_term:proplist()) -> binary(). get_routing_key(Props) -> Action = props:get_binary_value('action', Props, <<"*">>), Db = props:get_binary_value('db', Props, <<"*">>), @@ -271,31 +271,31 @@ get_routing_key(Props) -> ), amqp_util:document_routing_key(Action, Db, Type, Id). --spec publish_doc_update(action(), ne_binary(), ne_binary(), ne_binary(), api_terms()) -> 'ok'. --spec publish_doc_update(action(), ne_binary(), ne_binary(), ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_doc_update(action(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_doc_update(action(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_doc_update(Action, Db, Type, Id, JObj) -> publish_doc_update(Action, Db, Type, Id, JObj, ?DEFAULT_CONTENT_TYPE). publish_doc_update(Action, Db, Type, Id, Change, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Change, ?CONF_DOC_UPDATE_VALUES, fun doc_update/1), amqp_util:document_change_publish(Action, Db, Type, Id, Payload, ContentType). --spec publish_db_update(action(), ne_binary(), api_terms()) -> 'ok'. --spec publish_db_update(action(), ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_db_update(action(), kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_db_update(action(), kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_db_update(Action, Db, JObj) -> publish_db_update(Action, Db, JObj, ?DEFAULT_CONTENT_TYPE). publish_db_update(Action, Db, Change, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Change, ?CONF_DOC_UPDATE_VALUES, fun doc_update/1), amqp_util:document_change_publish(Action, Db, <<"database">>, Db, Payload, ContentType). --spec publish_doc_type_update(api_terms()) -> 'ok'. --spec publish_doc_type_update(api_terms(), ne_binary()) -> 'ok'. +-spec publish_doc_type_update(kz_term:api_terms()) -> 'ok'. +-spec publish_doc_type_update(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_doc_type_update(JObj) -> publish_doc_type_update(JObj, ?DEFAULT_CONTENT_TYPE). publish_doc_type_update(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?DOC_TYPE_UPDATE_VALUES, fun doc_type_update/1), amqp_util:configuration_publish(doc_type_update_routing_key(API), Payload, ContentType, [{'mandatory', 'true'}]). --spec doc_type_update_routing_key(api_terms() | ne_binary()) -> ne_binary(). +-spec doc_type_update_routing_key(kz_term:api_terms() | kz_term:ne_binary()) -> kz_term:ne_binary(). doc_type_update_routing_key(<<_/binary>> = Type) -> <<"configuration.doc_type_update.", Type/binary>>; doc_type_update_routing_key(API) -> diff --git a/core/kazoo_amqp/src/api/kapi_conference.erl b/core/kazoo_amqp/src/api/kapi_conference.erl index 510c3ca944b..2cc988d37cb 100644 --- a/core/kazoo_amqp/src/api/kapi_conference.erl +++ b/core/kazoo_amqp/src/api/kapi_conference.erl @@ -521,7 +521,7 @@ -define(CONF_PLAY_MACRO_REQ_VALUES, []). -define(CONF_PLAY_MACRO_REQ_TYPES, [{<<"Conference-ID">>, fun is_binary/1}]). --spec focus_queue_name(atom()) -> ne_binary(). +-spec focus_queue_name(atom()) -> kz_term:ne_binary(). focus_queue_name(Focus) -> <<(kz_term:to_binary(Focus))/binary, "_conference">>. %%-------------------------------------------------------------------- @@ -537,7 +537,7 @@ focus_queue_name(Focus) -> <<(kz_term:to_binary(Focus))/binary, "_conference">>. ,?TONES_REQ_VALUES ) ]). --spec say(api_terms()) -> api_formatter_return() . +-spec say(kz_term:api_terms()) -> api_formatter_return() . say(Prop) when is_list(Prop) -> case say_v(Prop) of 'true' -> kz_api:build_message(Prop, ?TTS_REQ_HEADERS, ?OPTIONAL_TTS_REQ_HEADERS); @@ -545,15 +545,15 @@ say(Prop) when is_list(Prop) -> end; say(JObj) -> say(kz_json:to_proplist(JObj)). --spec tts(api_terms()) -> api_formatter_return(). +-spec tts(kz_term:api_terms()) -> api_formatter_return(). tts(API) -> say(API). --spec say_v(api_terms()) -> boolean(). +-spec say_v(kz_term:api_terms()) -> boolean(). say_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?TTS_REQ_HEADERS, ?CONF_SAY_REQ_VALUES, ?TTS_REQ_TYPES); say_v(JObj) -> say_v(kz_json:to_proplist(JObj)). --spec tts_v(api_terms()) -> boolean(). +-spec tts_v(kz_term:api_terms()) -> boolean(). tts_v(API) -> say_v(API). %%-------------------------------------------------------------------- @@ -565,7 +565,7 @@ tts_v(API) -> say_v(API). -define(CONF_TONES_REQ_VALUES, [{<<"Event-Category">>, <<"conference">>} | props:delete(<<"Event-Category">>, ?TONES_REQ_VALUES) ]). --spec tones(api_terms()) -> api_formatter_return() . +-spec tones(kz_term:api_terms()) -> api_formatter_return() . tones(Prop) when is_list(Prop) -> Tones = [begin {'ok', TonesProp} = kapi_dialplan:tones_req_tone_headers(Tone), @@ -581,7 +581,7 @@ tones(Prop) when is_list(Prop) -> end; tones(JObj) -> tones(kz_json:to_proplist(JObj)). --spec tones_v(api_terms()) -> boolean(). +-spec tones_v(kz_term:api_terms()) -> boolean(). tones_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?TONES_REQ_HEADERS, ?CONF_TONES_REQ_VALUES, ?TONES_REQ_TYPES); tones_v(JObj) -> tones_v(kz_json:to_proplist(JObj)). @@ -591,7 +591,7 @@ tones_v(JObj) -> tones_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec search_req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec search_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. search_req(Prop) when is_list(Prop) -> case search_req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?SEARCH_REQ_HEADERS, ?OPTIONAL_SEARCH_REQ_HEADERS); @@ -599,7 +599,7 @@ search_req(Prop) when is_list(Prop) -> end; search_req(JObj) -> search_req(kz_json:to_proplist(JObj)). --spec search_req_v(api_terms()) -> boolean(). +-spec search_req_v(kz_term:api_terms()) -> boolean(). search_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SEARCH_REQ_HEADERS, ?SEARCH_REQ_VALUES, ?SEARCH_REQ_TYPES); search_req_v(JObj) -> search_req_v(kz_json:to_proplist(JObj)). @@ -609,7 +609,7 @@ search_req_v(JObj) -> search_req_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec search_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec search_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. search_resp(Prop) when is_list(Prop) -> case search_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?SEARCH_RESP_HEADERS, ?OPTIONAL_SEARCH_RESP_HEADERS); @@ -617,7 +617,7 @@ search_resp(Prop) when is_list(Prop) -> end; search_resp(JObj) -> search_resp(kz_json:to_proplist(JObj)). --spec search_resp_v(api_terms()) -> boolean(). +-spec search_resp_v(kz_term:api_terms()) -> boolean(). search_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SEARCH_RESP_HEADERS, ?SEARCH_RESP_VALUES, ?SEARCH_RESP_TYPES); search_resp_v(JObj) -> search_resp_v(kz_json:to_proplist(JObj)). @@ -627,7 +627,7 @@ search_resp_v(JObj) -> search_resp_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec discovery_req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec discovery_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. discovery_req(Prop) when is_list(Prop) -> case discovery_req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?DISCOVERY_REQ_HEADERS, ?OPTIONAL_DISCOVERY_REQ_HEADERS); @@ -635,7 +635,7 @@ discovery_req(Prop) when is_list(Prop) -> end; discovery_req(JObj) -> discovery_req(kz_json:to_proplist(JObj)). --spec discovery_req_v(api_terms()) -> boolean(). +-spec discovery_req_v(kz_term:api_terms()) -> boolean(). discovery_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?DISCOVERY_REQ_HEADERS, ?DISCOVERY_REQ_VALUES, ?DISCOVERY_REQ_TYPES); discovery_req_v(JObj) -> discovery_req_v(kz_json:to_proplist(JObj)). @@ -645,7 +645,7 @@ discovery_req_v(JObj) -> discovery_req_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec discovery_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec discovery_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. discovery_resp(Prop) when is_list(Prop) -> case discovery_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?DISCOVERY_RESP_HEADERS, ?OPTIONAL_DISCOVERY_RESP_HEADERS); @@ -653,7 +653,7 @@ discovery_resp(Prop) when is_list(Prop) -> end; discovery_resp(JObj) -> discovery_resp(kz_json:to_proplist(JObj)). --spec discovery_resp_v(api_terms()) -> boolean(). +-spec discovery_resp_v(kz_term:api_terms()) -> boolean(). discovery_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?DISCOVERY_RESP_HEADERS, ?DISCOVERY_RESP_VALUES, ?DISCOVERY_RESP_TYPES); discovery_resp_v(JObj) -> discovery_resp_v(kz_json:to_proplist(JObj)). @@ -663,7 +663,7 @@ discovery_resp_v(JObj) -> discovery_resp_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec add_participant(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec add_participant(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. add_participant(Prop) when is_list(Prop) -> case add_participant_v(Prop) of 'true' -> kz_api:build_message(Prop, ?ADD_PARTICIPANT_HEADERS, ?OPTIONAL_ADD_PARTICIPANT_HEADERS); @@ -671,7 +671,7 @@ add_participant(Prop) when is_list(Prop) -> end; add_participant(JObj) -> add_participant(kz_json:to_proplist(JObj)). --spec add_participant_v(api_terms()) -> boolean(). +-spec add_participant_v(kz_term:api_terms()) -> boolean(). add_participant_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?ADD_PARTICIPANT_HEADERS, ?ADD_PARTICIPANT_VALUES, ?ADD_PARTICIPANT_TYPES); add_participant_v(JObj) -> add_participant_v(kz_json:to_proplist(JObj)). @@ -681,7 +681,7 @@ add_participant_v(JObj) -> add_participant_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec deaf_participant(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec deaf_participant(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. deaf_participant(Prop) when is_list(Prop) -> case deaf_participant_v(Prop) of 'true' -> kz_api:build_message(Prop, ?DEAF_PARTICIPANT_HEADERS, ?OPTIONAL_DEAF_PARTICIPANT_HEADERS); @@ -689,7 +689,7 @@ deaf_participant(Prop) when is_list(Prop) -> end; deaf_participant(JObj) -> deaf_participant(kz_json:to_proplist(JObj)). --spec deaf_participant_v(api_terms()) -> boolean(). +-spec deaf_participant_v(kz_term:api_terms()) -> boolean(). deaf_participant_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?DEAF_PARTICIPANT_HEADERS, ?DEAF_PARTICIPANT_VALUES, ?DEAF_PARTICIPANT_TYPES); deaf_participant_v(JObj) -> deaf_participant_v(kz_json:to_proplist(JObj)). @@ -699,7 +699,7 @@ deaf_participant_v(JObj) -> deaf_participant_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec participant_energy(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec participant_energy(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. participant_energy(Prop) when is_list(Prop) -> case participant_energy_v(Prop) of 'true' -> kz_api:build_message(Prop, ?PARTICIPANT_ENERGY_HEADERS, ?OPTIONAL_PARTICIPANT_ENERGY_HEADERS); @@ -707,7 +707,7 @@ participant_energy(Prop) when is_list(Prop) -> end; participant_energy(JObj) -> participant_energy(kz_json:to_proplist(JObj)). --spec participant_energy_v(api_terms()) -> boolean(). +-spec participant_energy_v(kz_term:api_terms()) -> boolean(). participant_energy_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?PARTICIPANT_ENERGY_HEADERS, ?PARTICIPANT_ENERGY_VALUES, ?PARTICIPANT_ENERGY_TYPES); participant_energy_v(JObj) -> participant_energy_v(kz_json:to_proplist(JObj)). @@ -717,7 +717,7 @@ participant_energy_v(JObj) -> participant_energy_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec kick(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec kick(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. kick(Prop) when is_list(Prop) -> case kick_v(Prop) of 'true' -> kz_api:build_message(Prop, ?KICK_HEADERS, ?OPTIONAL_KICK_HEADERS); @@ -725,7 +725,7 @@ kick(Prop) when is_list(Prop) -> end; kick(JObj) -> kick(kz_json:to_proplist(JObj)). --spec kick_v(api_terms()) -> boolean(). +-spec kick_v(kz_term:api_terms()) -> boolean(). kick_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?KICK_HEADERS, ?KICK_VALUES, ?KICK_TYPES); kick_v(JObj) -> kick_v(kz_json:to_proplist(JObj)). @@ -735,7 +735,7 @@ kick_v(JObj) -> kick_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec participants_req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec participants_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. participants_req(Prop) when is_list(Prop) -> case participants_req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?PARTICIPANTS_REQ_HEADERS, ?OPTIONAL_PARTICIPANTS_REQ_HEADERS); @@ -743,7 +743,7 @@ participants_req(Prop) when is_list(Prop) -> end; participants_req(JObj) -> participants_req(kz_json:to_proplist(JObj)). --spec participants_req_v(api_terms()) -> boolean(). +-spec participants_req_v(kz_term:api_terms()) -> boolean(). participants_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?PARTICIPANTS_REQ_HEADERS, ?PARTICIPANTS_REQ_VALUES, ?PARTICIPANTS_REQ_TYPES); participants_req_v(JObj) -> participants_req_v(kz_json:to_proplist(JObj)). @@ -753,7 +753,7 @@ participants_req_v(JObj) -> participants_req_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec participants_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec participants_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. participants_resp(Prop) when is_list(Prop) -> case participants_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?PARTICIPANTS_RESP_HEADERS, ?OPTIONAL_PARTICIPANTS_RESP_HEADERS); @@ -761,7 +761,7 @@ participants_resp(Prop) when is_list(Prop) -> end; participants_resp(JObj) -> participants_resp(kz_json:to_proplist(JObj)). --spec participants_resp_v(api_terms()) -> boolean(). +-spec participants_resp_v(kz_term:api_terms()) -> boolean(). participants_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?PARTICIPANTS_RESP_HEADERS, ?PARTICIPANTS_RESP_VALUES, ?PARTICIPANTS_RESP_TYPES); participants_resp_v(JObj) -> participants_resp_v(kz_json:to_proplist(JObj)). @@ -771,7 +771,7 @@ participants_resp_v(JObj) -> participants_resp_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec lock(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec lock(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. lock(Prop) when is_list(Prop) -> case lock_v(Prop) of 'true' -> kz_api:build_message(Prop, ?LOCK_HEADERS, ?OPTIONAL_LOCK_HEADERS); @@ -779,7 +779,7 @@ lock(Prop) when is_list(Prop) -> end; lock(JObj) -> lock(kz_json:to_proplist(JObj)). --spec lock_v(api_terms()) -> boolean(). +-spec lock_v(kz_term:api_terms()) -> boolean(). lock_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?LOCK_HEADERS, ?LOCK_VALUES, ?LOCK_TYPES); lock_v(JObj) -> lock_v(kz_json:to_proplist(JObj)). @@ -789,7 +789,7 @@ lock_v(JObj) -> lock_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec mute_participant(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec mute_participant(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. mute_participant(Prop) when is_list(Prop) -> case mute_participant_v(Prop) of 'true' -> kz_api:build_message(Prop, ?MUTE_PARTICIPANT_HEADERS, ?OPTIONAL_MUTE_PARTICIPANT_HEADERS); @@ -797,7 +797,7 @@ mute_participant(Prop) when is_list(Prop) -> end; mute_participant(JObj) -> mute_participant(kz_json:to_proplist(JObj)). --spec mute_participant_v(api_terms()) -> boolean(). +-spec mute_participant_v(kz_term:api_terms()) -> boolean(). mute_participant_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?MUTE_PARTICIPANT_HEADERS, ?MUTE_PARTICIPANT_VALUES, ?MUTE_PARTICIPANT_TYPES); mute_participant_v(JObj) -> mute_participant_v(kz_json:to_proplist(JObj)). @@ -807,7 +807,7 @@ mute_participant_v(JObj) -> mute_participant_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec play(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec play(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. play(Prop) when is_list(Prop) -> case play_v(Prop) of 'true' -> kz_api:build_message(Prop, ?PLAY_HEADERS, ?OPTIONAL_PLAY_HEADERS); @@ -815,7 +815,7 @@ play(Prop) when is_list(Prop) -> end; play(JObj) -> play(kz_json:to_proplist(JObj)). --spec play_v(api_terms()) -> boolean(). +-spec play_v(kz_term:api_terms()) -> boolean(). play_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?PLAY_HEADERS, ?PLAY_VALUES, ?PLAY_TYPES); play_v(JObj) -> play_v(kz_json:to_proplist(JObj)). @@ -825,7 +825,7 @@ play_v(JObj) -> play_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec play_macro_req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec play_macro_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. play_macro_req(Prop) when is_list(Prop) -> case play_macro_req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?CONF_PLAY_MACRO_REQ_HEADERS, ?OPTIONAL_CONF_PLAY_MACRO_REQ_HEADERS); @@ -833,7 +833,7 @@ play_macro_req(Prop) when is_list(Prop) -> end; play_macro_req(JObj) -> play_macro_req(kz_json:to_proplist(JObj)). --spec play_macro_req_v(api_terms()) -> boolean(). +-spec play_macro_req_v(kz_term:api_terms()) -> boolean(). play_macro_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CONF_PLAY_MACRO_REQ_HEADERS, ?CONF_PLAY_MACRO_REQ_VALUES, ?CONF_PLAY_MACRO_REQ_TYPES); play_macro_req_v(JObj) -> play_macro_req_v(kz_json:to_proplist(JObj)). @@ -843,7 +843,7 @@ play_macro_req_v(JObj) -> play_macro_req_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec record(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec record(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. record(Prop) when is_list(Prop) -> case record_v(Prop) of 'true' -> kz_api:build_message(Prop, ?RECORD_HEADERS, ?OPTIONAL_RECORD_HEADERS); @@ -851,7 +851,7 @@ record(Prop) when is_list(Prop) -> end; record(JObj) -> record(kz_json:to_proplist(JObj)). --spec record_v(api_terms()) -> boolean(). +-spec record_v(kz_term:api_terms()) -> boolean(). record_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?RECORD_HEADERS, ?RECORD_VALUES, ?RECORD_TYPES); record_v(JObj) -> record_v(kz_json:to_proplist(JObj)). @@ -861,7 +861,7 @@ record_v(JObj) -> record_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec recordstop(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec recordstop(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. recordstop(Prop) when is_list(Prop) -> case recordstop_v(Prop) of 'true' -> kz_api:build_message(Prop, ?RECORDSTOP_HEADERS, ?OPTIONAL_RECORDSTOP_HEADERS); @@ -869,7 +869,7 @@ recordstop(Prop) when is_list(Prop) -> end; recordstop(JObj) -> recordstop(kz_json:to_proplist(JObj)). --spec recordstop_v(api_terms()) -> boolean(). +-spec recordstop_v(kz_term:api_terms()) -> boolean(). recordstop_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?RECORDSTOP_HEADERS, ?RECORDSTOP_VALUES, ?RECORDSTOP_TYPES); recordstop_v(JObj) -> recordstop_v(kz_json:to_proplist(JObj)). @@ -879,7 +879,7 @@ recordstop_v(JObj) -> recordstop_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec relate_participants(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec relate_participants(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. relate_participants(Prop) when is_list(Prop) -> case relate_participants_v(Prop) of 'true' -> kz_api:build_message(Prop, ?RELATE_PARTICIPANTS_HEADERS, ?OPTIONAL_RELATE_PARTICIPANTS_HEADERS); @@ -887,7 +887,7 @@ relate_participants(Prop) when is_list(Prop) -> end; relate_participants(JObj) -> relate_participants(kz_json:to_proplist(JObj)). --spec relate_participants_v(api_terms()) -> boolean(). +-spec relate_participants_v(kz_term:api_terms()) -> boolean(). relate_participants_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?RELATE_PARTICIPANTS_HEADERS, ?RELATE_PARTICIPANTS_VALUES, ?RELATE_PARTICIPANTS_TYPES); relate_participants_v(JObj) -> relate_participants_v(kz_json:to_proplist(JObj)). @@ -897,7 +897,7 @@ relate_participants_v(JObj) -> relate_participants_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec set(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec set(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. set(Prop) when is_list(Prop) -> case set_v(Prop) of 'true' -> kz_api:build_message(Prop, ?SET_HEADERS, ?OPTIONAL_SET_HEADERS); @@ -905,7 +905,7 @@ set(Prop) when is_list(Prop) -> end; set(JObj) -> set(kz_json:to_proplist(JObj)). --spec set_v(api_terms()) -> boolean(). +-spec set_v(kz_term:api_terms()) -> boolean(). set_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SET_HEADERS, ?SET_VALUES, ?SET_TYPES); set_v(JObj) -> set_v(kz_json:to_proplist(JObj)). @@ -915,7 +915,7 @@ set_v(JObj) -> set_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec stop_play(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec stop_play(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. stop_play(Prop) when is_list(Prop) -> case stop_play_v(Prop) of 'true' -> kz_api:build_message(Prop, ?STOP_PLAY_HEADERS, ?OPTIONAL_STOP_PLAY_HEADERS); @@ -923,7 +923,7 @@ stop_play(Prop) when is_list(Prop) -> end; stop_play(JObj) -> stop_play(kz_json:to_proplist(JObj)). --spec stop_play_v(api_terms()) -> boolean(). +-spec stop_play_v(kz_term:api_terms()) -> boolean(). stop_play_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?STOP_PLAY_HEADERS, ?STOP_PLAY_VALUES, ?STOP_PLAY_TYPES); stop_play_v(JObj) -> stop_play_v(kz_json:to_proplist(JObj)). @@ -933,7 +933,7 @@ stop_play_v(JObj) -> stop_play_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec undeaf_participant(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec undeaf_participant(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. undeaf_participant(Prop) when is_list(Prop) -> case undeaf_participant_v(Prop) of 'true' -> kz_api:build_message(Prop, ?UNDEAF_PARTICIPANT_HEADERS, ?OPTIONAL_UNDEAF_PARTICIPANT_HEADERS); @@ -941,7 +941,7 @@ undeaf_participant(Prop) when is_list(Prop) -> end; undeaf_participant(JObj) -> undeaf_participant(kz_json:to_proplist(JObj)). --spec undeaf_participant_v(api_terms()) -> boolean(). +-spec undeaf_participant_v(kz_term:api_terms()) -> boolean(). undeaf_participant_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?UNDEAF_PARTICIPANT_HEADERS, ?UNDEAF_PARTICIPANT_VALUES, ?UNDEAF_PARTICIPANT_TYPES); undeaf_participant_v(JObj) -> undeaf_participant_v(kz_json:to_proplist(JObj)). @@ -951,7 +951,7 @@ undeaf_participant_v(JObj) -> undeaf_participant_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec unlock(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec unlock(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. unlock(Prop) when is_list(Prop) -> case unlock_v(Prop) of 'true' -> kz_api:build_message(Prop, ?UNLOCK_HEADERS, ?OPTIONAL_UNLOCK_HEADERS); @@ -959,7 +959,7 @@ unlock(Prop) when is_list(Prop) -> end; unlock(JObj) -> unlock(kz_json:to_proplist(JObj)). --spec unlock_v(api_terms()) -> boolean(). +-spec unlock_v(kz_term:api_terms()) -> boolean(). unlock_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?UNLOCK_HEADERS, ?UNLOCK_VALUES, ?UNLOCK_TYPES); unlock_v(JObj) -> unlock_v(kz_json:to_proplist(JObj)). @@ -969,7 +969,7 @@ unlock_v(JObj) -> unlock_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec unmute_participant(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec unmute_participant(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. unmute_participant(Prop) when is_list(Prop) -> case unmute_participant_v(Prop) of 'true' -> kz_api:build_message(Prop, ?UNMUTE_PARTICIPANT_HEADERS, ?OPTIONAL_UNMUTE_PARTICIPANT_HEADERS); @@ -977,7 +977,7 @@ unmute_participant(Prop) when is_list(Prop) -> end; unmute_participant(JObj) -> unmute_participant(kz_json:to_proplist(JObj)). --spec unmute_participant_v(api_terms()) -> boolean(). +-spec unmute_participant_v(kz_term:api_terms()) -> boolean(). unmute_participant_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?UNMUTE_PARTICIPANT_HEADERS, ?UNMUTE_PARTICIPANT_VALUES, ?UNMUTE_PARTICIPANT_TYPES); unmute_participant_v(JObj) -> unmute_participant_v(kz_json:to_proplist(JObj)). @@ -987,7 +987,7 @@ unmute_participant_v(JObj) -> unmute_participant_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec participant_volume_in(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec participant_volume_in(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. participant_volume_in(Prop) when is_list(Prop) -> case participant_volume_in_v(Prop) of 'true' -> kz_api:build_message(Prop, ?PARTICIPANT_VOLUME_IN_HEADERS, ?OPTIONAL_PARTICIPANT_VOLUME_IN_HEADERS); @@ -995,7 +995,7 @@ participant_volume_in(Prop) when is_list(Prop) -> end; participant_volume_in(JObj) -> participant_volume_in(kz_json:to_proplist(JObj)). --spec participant_volume_in_v(api_terms()) -> boolean(). +-spec participant_volume_in_v(kz_term:api_terms()) -> boolean(). participant_volume_in_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?PARTICIPANT_VOLUME_IN_HEADERS, ?PARTICIPANT_VOLUME_IN_VALUES, ?PARTICIPANT_VOLUME_IN_TYPES); participant_volume_in_v(JObj) -> participant_volume_in_v(kz_json:to_proplist(JObj)). @@ -1005,7 +1005,7 @@ participant_volume_in_v(JObj) -> participant_volume_in_v(kz_json:to_proplist(JOb %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec participant_volume_out(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec participant_volume_out(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. participant_volume_out(Prop) when is_list(Prop) -> case participant_volume_out_v(Prop) of 'true' -> kz_api:build_message(Prop, ?PARTICIPANT_VOLUME_OUT_HEADERS, ?OPTIONAL_PARTICIPANT_VOLUME_OUT_HEADERS); @@ -1013,7 +1013,7 @@ participant_volume_out(Prop) when is_list(Prop) -> end; participant_volume_out(JObj) -> participant_volume_out(kz_json:to_proplist(JObj)). --spec participant_volume_out_v(api_terms()) -> boolean(). +-spec participant_volume_out_v(kz_term:api_terms()) -> boolean(). participant_volume_out_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?PARTICIPANT_VOLUME_OUT_HEADERS, ?PARTICIPANT_VOLUME_OUT_VALUES, ?PARTICIPANT_VOLUME_OUT_TYPES); participant_volume_out_v(JObj) -> participant_volume_out_v(kz_json:to_proplist(JObj)). @@ -1023,7 +1023,7 @@ participant_volume_out_v(JObj) -> participant_volume_out_v(kz_json:to_proplist(J %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec participant_event(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec participant_event(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. participant_event(Prop) when is_list(Prop) -> case participant_event_v(Prop) of 'true' -> kz_api:build_message(Prop, ?PARTICIPANT_EVENT_HEADERS, ?OPTIONAL_PARTICIPANT_EVENT_HEADERS); @@ -1031,7 +1031,7 @@ participant_event(Prop) when is_list(Prop) -> end; participant_event(JObj) -> participant_event(kz_json:to_proplist(JObj)). --spec participant_event_v(api_terms()) -> boolean(). +-spec participant_event_v(kz_term:api_terms()) -> boolean(). participant_event_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?PARTICIPANT_EVENT_HEADERS, ?PARTICIPANT_EVENT_VALUES, ?PARTICIPANT_EVENT_TYPES); participant_event_v(JObj) -> participant_event_v(kz_json:to_proplist(JObj)). @@ -1041,7 +1041,7 @@ participant_event_v(JObj) -> participant_event_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec event(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec event(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. event(Prop) when is_list(Prop) -> case event_v(Prop) of 'true' -> kz_api:build_message(Prop, ?CONFERENCE_EVENT_HEADERS, ?OPTIONAL_CONFERENCE_EVENT_HEADERS); @@ -1049,7 +1049,7 @@ event(Prop) when is_list(Prop) -> end; event(JObj) -> event(kz_json:to_proplist(JObj)). --spec event_v(api_terms()) -> boolean(). +-spec event_v(kz_term:api_terms()) -> boolean(). event_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CONFERENCE_EVENT_HEADERS, ?CONFERENCE_EVENT_VALUES, ?CONFERENCE_EVENT_TYPES); event_v(JObj) -> event_v(kz_json:to_proplist(JObj)). @@ -1059,7 +1059,7 @@ event_v(JObj) -> event_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec conference_error(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec conference_error(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. conference_error(Prop) when is_list(Prop) -> case conference_error_v(Prop) of 'true' -> kz_api:build_message(Prop, ?CONFERENCE_ERROR_HEADERS, ?OPTIONAL_CONFERENCE_ERROR_HEADERS); @@ -1067,7 +1067,7 @@ conference_error(Prop) when is_list(Prop) -> end; conference_error(JObj) -> conference_error(kz_json:to_proplist(JObj)). --spec conference_error_v(api_terms()) -> boolean(). +-spec conference_error_v(kz_term:api_terms()) -> boolean(). conference_error_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CONFERENCE_ERROR_HEADERS, ?CONFERENCE_ERROR_VALUES, ?CONFERENCE_ERROR_TYPES); conference_error_v(JObj) -> conference_error_v(kz_json:to_proplist(JObj)). @@ -1077,7 +1077,7 @@ conference_error_v(JObj) -> conference_error_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec config_req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec config_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. config_req(Prop) when is_list(Prop) -> case config_req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?CONFIG_REQ_HEADERS, ?OPTIONAL_CONFIG_REQ_HEADERS); @@ -1085,7 +1085,7 @@ config_req(Prop) when is_list(Prop) -> end; config_req(JObj) -> config_req(kz_json:to_proplist(JObj)). --spec config_req_v(api_terms()) -> boolean(). +-spec config_req_v(kz_term:api_terms()) -> boolean(). config_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CONFIG_REQ_HEADERS, ?CONFIG_REQ_VALUES, ?CONFIG_REQ_TYPES); config_req_v(JObj) -> config_req_v(kz_json:to_proplist(JObj)). @@ -1095,7 +1095,7 @@ config_req_v(JObj) -> config_req_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec config_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec config_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. config_resp(Prop) when is_list(Prop) -> case config_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?CONFIG_RESP_HEADERS, ?OPTIONAL_CONFIG_RESP_HEADERS); @@ -1103,12 +1103,12 @@ config_resp(Prop) when is_list(Prop) -> end; config_resp(JObj) -> config_resp(kz_json:to_proplist(JObj)). --spec config_resp_v(api_terms()) -> boolean(). +-spec config_resp_v(kz_term:api_terms()) -> boolean(). config_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CONFIG_RESP_HEADERS, ?CONFIG_RESP_VALUES, ?CONFIG_RESP_TYPES); config_resp_v(JObj) -> config_resp_v(kz_json:to_proplist(JObj)). --spec dial(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec dial(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. dial(Prop) when is_list(Prop) -> case dial_v(Prop) of 'true' -> kz_api:build_message(Prop, ?DIAL_HEADERS, ?OPTIONAL_DIAL_HEADERS); @@ -1116,12 +1116,12 @@ dial(Prop) when is_list(Prop) -> end; dial(JObj) -> dial(kz_json:to_proplist(JObj)). --spec dial_v(api_terms()) -> boolean(). +-spec dial_v(kz_term:api_terms()) -> boolean(). dial_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?DIAL_HEADERS, ?DIAL_VALUES, ?DIAL_TYPES); dial_v(JObj) -> dial_v(kz_json:to_proplist(JObj)). --spec dial_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec dial_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. dial_resp(Prop) when is_list(Prop) -> case dial_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?DIAL_RESP_HEADERS, ?OPTIONAL_DIAL_RESP_HEADERS); @@ -1129,7 +1129,7 @@ dial_resp(Prop) when is_list(Prop) -> end; dial_resp(JObj) -> dial_resp(kz_json:to_proplist(JObj)). --spec dial_resp_v(api_terms()) -> boolean(). +-spec dial_resp_v(kz_term:api_terms()) -> boolean(). dial_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?DIAL_RESP_HEADERS, ?DIAL_RESP_VALUES, ?DIAL_RESP_TYPES); dial_resp_v(JObj) -> dial_resp_v(kz_json:to_proplist(JObj)). @@ -1139,7 +1139,7 @@ dial_resp_v(JObj) -> dial_resp_v(kz_json:to_proplist(JObj)). %% Bind a queue to the conference exchange %% @end %%-------------------------------------------------------------------- --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, Props) -> bind_to_q(Queue, props:get_value('restrict_to', Props), Props). @@ -1179,7 +1179,7 @@ bind_to_q(_Q, [], _) -> %% Unbind a queue from the conference exhange %% @end %%-------------------------------------------------------------------- --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Queue, Props) -> unbind_from_q(Queue, props:get_value('restrict_to', Props), Props). @@ -1227,8 +1227,8 @@ declare_exchanges() -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_search_req(api_terms()) -> 'ok'. --spec publish_search_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_search_req(kz_term:api_terms()) -> 'ok'. +-spec publish_search_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_search_req(JObj) -> publish_search_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_search_req(Req, ContentType) -> @@ -1240,8 +1240,8 @@ publish_search_req(Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_search_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_search_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_search_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_search_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_search_resp(Queue, Resp) -> publish_search_resp(Queue, Resp, ?DEFAULT_CONTENT_TYPE). publish_search_resp(Queue, Resp, ContentType) -> @@ -1253,8 +1253,8 @@ publish_search_resp(Queue, Resp, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_discovery_req(api_terms()) -> 'ok'. --spec publish_discovery_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_discovery_req(kz_term:api_terms()) -> 'ok'. +-spec publish_discovery_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_discovery_req(JObj) -> publish_discovery_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_discovery_req(Req, ContentType) -> @@ -1266,8 +1266,8 @@ publish_discovery_req(Req, ContentType) -> %% Publish the response to requestor %% @end %%-------------------------------------------------------------------- --spec publish_discovery_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_discovery_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_discovery_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_discovery_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_discovery_resp(Q, JObj) -> publish_discovery_resp(Q, JObj, ?DEFAULT_CONTENT_TYPE). publish_discovery_resp(Q, Req, ContentType) -> @@ -1279,8 +1279,8 @@ publish_discovery_resp(Q, Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_add_participant(ne_binary(), api_terms()) -> 'ok'. --spec publish_add_participant(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_add_participant(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_add_participant(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_add_participant(Zone, JObj) -> publish_add_participant(Zone, JObj, ?DEFAULT_CONTENT_TYPE). publish_add_participant(Zone, Req, ContentType) -> @@ -1292,8 +1292,8 @@ publish_add_participant(Zone, Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_deaf_participant(ne_binary(), api_terms()) -> 'ok'. --spec publish_deaf_participant(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_deaf_participant(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_deaf_participant(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_deaf_participant(ConferenceId, JObj) -> publish_deaf_participant(ConferenceId, JObj, ?DEFAULT_CONTENT_TYPE). publish_deaf_participant(ConferenceId, Req, ContentType) -> @@ -1305,8 +1305,8 @@ publish_deaf_participant(ConferenceId, Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_participant_energy(ne_binary(), api_terms()) -> 'ok'. --spec publish_participant_energy(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_participant_energy(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_participant_energy(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_participant_energy(ConferenceId, JObj) -> publish_participant_energy(ConferenceId, JObj, ?DEFAULT_CONTENT_TYPE). publish_participant_energy(ConferenceId, Req, ContentType) -> @@ -1318,8 +1318,8 @@ publish_participant_energy(ConferenceId, Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_kick(ne_binary(), api_terms()) -> 'ok'. --spec publish_kick(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_kick(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_kick(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_kick(ConferenceId, JObj) -> publish_kick(ConferenceId, JObj, ?DEFAULT_CONTENT_TYPE). publish_kick(ConferenceId, Req, ContentType) -> @@ -1331,8 +1331,8 @@ publish_kick(ConferenceId, Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_participants_req(ne_binary(), api_terms()) -> 'ok'. --spec publish_participants_req(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_participants_req(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_participants_req(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_participants_req(ConferenceId, JObj) -> publish_participants_req(ConferenceId, JObj, ?DEFAULT_CONTENT_TYPE). publish_participants_req(ConferenceId, Req, ContentType) -> @@ -1344,8 +1344,8 @@ publish_participants_req(ConferenceId, Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_participants_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_participants_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_participants_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_participants_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_participants_resp(Queue, Resp) -> publish_participants_resp(Queue, Resp, ?DEFAULT_CONTENT_TYPE). publish_participants_resp(Queue, Resp, ContentType) -> @@ -1357,8 +1357,8 @@ publish_participants_resp(Queue, Resp, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_lock(ne_binary(), api_terms()) -> 'ok'. --spec publish_lock(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_lock(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_lock(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_lock(ConferenceId, JObj) -> publish_lock(ConferenceId, JObj, ?DEFAULT_CONTENT_TYPE). publish_lock(ConferenceId, Req, ContentType) -> @@ -1370,8 +1370,8 @@ publish_lock(ConferenceId, Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_mute_participant(ne_binary(), api_terms()) -> 'ok'. --spec publish_mute_participant(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_mute_participant(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_mute_participant(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_mute_participant(ConferenceId, JObj) -> publish_mute_participant(ConferenceId, JObj, ?DEFAULT_CONTENT_TYPE). publish_mute_participant(ConferenceId, Req, ContentType) -> @@ -1383,8 +1383,8 @@ publish_mute_participant(ConferenceId, Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_play(ne_binary(), api_terms()) -> 'ok'. --spec publish_play(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_play(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_play(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_play(ConferenceId, JObj) -> publish_play(ConferenceId, JObj, ?DEFAULT_CONTENT_TYPE). publish_play(ConferenceId, Req, ContentType) -> @@ -1396,8 +1396,8 @@ publish_play(ConferenceId, Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_record(ne_binary(), api_terms()) -> 'ok'. --spec publish_record(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_record(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_record(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_record(ConferenceId, JObj) -> publish_record(ConferenceId, JObj, ?DEFAULT_CONTENT_TYPE). publish_record(ConferenceId, Req, ContentType) -> @@ -1409,8 +1409,8 @@ publish_record(ConferenceId, Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_recordstop(ne_binary(), api_terms()) -> 'ok'. --spec publish_recordstop(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_recordstop(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_recordstop(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_recordstop(ConferenceId, JObj) -> publish_recordstop(ConferenceId, JObj, ?DEFAULT_CONTENT_TYPE). publish_recordstop(ConferenceId, Req, ContentType) -> @@ -1422,8 +1422,8 @@ publish_recordstop(ConferenceId, Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_relate_participants(ne_binary(), api_terms()) -> 'ok'. --spec publish_relate_participants(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_relate_participants(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_relate_participants(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_relate_participants(ConferenceId, JObj) -> publish_relate_participants(ConferenceId, JObj, ?DEFAULT_CONTENT_TYPE). publish_relate_participants(ConferenceId, Req, ContentType) -> @@ -1435,8 +1435,8 @@ publish_relate_participants(ConferenceId, Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_set(ne_binary(), api_terms()) -> 'ok'. --spec publish_set(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_set(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_set(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_set(ConferenceId, JObj) -> publish_set(ConferenceId, JObj, ?DEFAULT_CONTENT_TYPE). publish_set(ConferenceId, Req, ContentType) -> @@ -1448,8 +1448,8 @@ publish_set(ConferenceId, Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_stop_play(ne_binary(), api_terms()) -> 'ok'. --spec publish_stop_play(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_stop_play(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_stop_play(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_stop_play(ConferenceId, JObj) -> publish_stop_play(ConferenceId, JObj, ?DEFAULT_CONTENT_TYPE). publish_stop_play(ConferenceId, Req, ContentType) -> @@ -1461,8 +1461,8 @@ publish_stop_play(ConferenceId, Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_undeaf_participant(ne_binary(), api_terms()) -> 'ok'. --spec publish_undeaf_participant(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_undeaf_participant(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_undeaf_participant(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_undeaf_participant(ConferenceId, JObj) -> publish_undeaf_participant(ConferenceId, JObj, ?DEFAULT_CONTENT_TYPE). publish_undeaf_participant(ConferenceId, Req, ContentType) -> @@ -1474,8 +1474,8 @@ publish_undeaf_participant(ConferenceId, Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_unlock(ne_binary(), api_terms()) -> 'ok'. --spec publish_unlock(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_unlock(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_unlock(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_unlock(ConferenceId, JObj) -> publish_unlock(ConferenceId, JObj, ?DEFAULT_CONTENT_TYPE). publish_unlock(ConferenceId, Req, ContentType) -> @@ -1487,8 +1487,8 @@ publish_unlock(ConferenceId, Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_unmute_participant(ne_binary(), api_terms()) -> 'ok'. --spec publish_unmute_participant(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_unmute_participant(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_unmute_participant(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_unmute_participant(ConferenceId, JObj) -> publish_unmute_participant(ConferenceId, JObj, ?DEFAULT_CONTENT_TYPE). publish_unmute_participant(ConferenceId, Req, ContentType) -> @@ -1500,8 +1500,8 @@ publish_unmute_participant(ConferenceId, Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_participant_volume_in(ne_binary(), api_terms()) -> 'ok'. --spec publish_participant_volume_in(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_participant_volume_in(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_participant_volume_in(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_participant_volume_in(ConferenceId, JObj) -> publish_participant_volume_in(ConferenceId, JObj, ?DEFAULT_CONTENT_TYPE). publish_participant_volume_in(ConferenceId, Req, ContentType) -> @@ -1513,8 +1513,8 @@ publish_participant_volume_in(ConferenceId, Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_participant_volume_out(ne_binary(), api_terms()) -> 'ok'. --spec publish_participant_volume_out(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_participant_volume_out(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_participant_volume_out(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_participant_volume_out(ConferenceId, JObj) -> publish_participant_volume_out(ConferenceId, JObj, ?DEFAULT_CONTENT_TYPE). publish_participant_volume_out(ConferenceId, Req, ContentType) -> @@ -1526,8 +1526,8 @@ publish_participant_volume_out(ConferenceId, Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_participant_event(ne_binary(), ne_binary(), api_terms()) -> 'ok'. --spec publish_participant_event(ne_binary(), ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_participant_event(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_participant_event(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_participant_event(ConferenceId, CallId, JObj) -> publish_participant_event(ConferenceId, CallId, JObj, ?DEFAULT_CONTENT_TYPE). publish_participant_event(ConferenceId, CallId, Event, ContentType) -> @@ -1539,8 +1539,8 @@ publish_participant_event(ConferenceId, CallId, Event, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_event(api_terms()) -> 'ok'. --spec publish_event(api_terms(), ne_binary()) -> 'ok'. +-spec publish_event(kz_term:api_terms()) -> 'ok'. +-spec publish_event(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_event(API) -> publish_event(API, ?DEFAULT_CONTENT_TYPE). publish_event(API, ContentType) -> @@ -1576,8 +1576,8 @@ event_key(API) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_error(ne_binary(), api_terms()) -> 'ok'. --spec publish_error(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_error(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_error(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_error(Queue, JObj) -> publish_error(Queue, JObj, ?DEFAULT_CONTENT_TYPE). publish_error(Queue, Req, ContentType) -> @@ -1589,8 +1589,8 @@ publish_error(Queue, Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_command(ne_binary(), api_terms()) -> 'ok'. --spec publish_command(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_command(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_command(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_command(ConferenceId, JObj) -> publish_command(ConferenceId, JObj, ?DEFAULT_CONTENT_TYPE). publish_command(ConferenceId, Req, ContentType) -> @@ -1607,8 +1607,8 @@ publish_command(ConferenceId, Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_targeted_command(atom(), api_terms()) -> 'ok'. --spec publish_targeted_command(atom(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_targeted_command(atom(), kz_term:api_terms()) -> 'ok'. +-spec publish_targeted_command(atom(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_targeted_command(Focus, JObj) -> publish_targeted_command(Focus, JObj, ?DEFAULT_CONTENT_TYPE). publish_targeted_command(Focus, Req, ContentType) -> @@ -1626,8 +1626,8 @@ publish_targeted_command(Focus, Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_config_req(api_terms()) -> 'ok'. --spec publish_config_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_config_req(kz_term:api_terms()) -> 'ok'. +-spec publish_config_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_config_req(JObj) -> publish_config_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_config_req(Req, ContentType) -> @@ -1643,8 +1643,8 @@ profile(JObj) -> kz_json:get_value(<<"Profile">>, JObj). %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_config_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_config_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_config_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_config_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_config_resp(Queue, JObj) -> publish_config_resp(Queue, JObj, ?DEFAULT_CONTENT_TYPE). publish_config_resp(Queue, Req, ContentType) -> @@ -1656,16 +1656,16 @@ publish_config_resp(Queue, Req, ContentType) -> %% Publish to the conference exchange %% @end %%-------------------------------------------------------------------- --spec publish_dial(ne_binary(), api_terms()) -> 'ok'. --spec publish_dial(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_dial(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_dial(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_dial(Zone, JObj) -> publish_dial(Zone, JObj, ?DEFAULT_CONTENT_TYPE). publish_dial(Zone, Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?DIAL_VALUES, fun dial/1), amqp_util:conference_publish(Payload, 'command', Zone, [], ContentType). --spec publish_dial_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_dial_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_dial_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_dial_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_dial_resp(Queue, JObj) -> publish_dial_resp(Queue, JObj, ?DEFAULT_CONTENT_TYPE). publish_dial_resp(Queue, Req, ContentType) -> diff --git a/core/kazoo_amqp/src/api/kapi_delegate.erl b/core/kazoo_amqp/src/api/kapi_delegate.erl index f8f8866568f..cd2b8d23c14 100644 --- a/core/kazoo_amqp/src/api/kapi_delegate.erl +++ b/core/kazoo_amqp/src/api/kapi_delegate.erl @@ -24,7 +24,7 @@ -define(APIKEY, <<"delegate">>). --type maybe_key() :: ne_binary() | 'undefined'. +-type maybe_key() :: kz_term:ne_binary() | 'undefined'. -define(DELEGATE_ROUTING_KEY(App, Key), < {'ok', iolist()} | {'error', string()}. +-spec delegate(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. delegate(Prop) when is_list(Prop) -> case delegate_v(Prop) of 'true' -> kz_api:build_message(Prop, ?DELEGATE_HEADERS, ?OPTIONAL_DELEGATE_HEADERS); @@ -54,13 +54,13 @@ delegate(Prop) when is_list(Prop) -> end; delegate(JObj) -> delegate(kz_json:to_proplist(JObj)). --spec delegate_v(api_terms()) -> boolean(). +-spec delegate_v(kz_term:api_terms()) -> boolean(). delegate_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?DELEGATE_HEADERS, ?DELEGATE_VALUES, ?DELEGATE_TYPES); delegate_v(JObj) -> delegate_v(kz_json:to_proplist(JObj)). --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. --spec bind_q(ne_binary(), ne_binary(), maybe_key()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:ne_binary(), maybe_key()) -> 'ok'. bind_q(Q, Props) -> App = props:get_binary_value('app_name', Props), Key = props:get_value('route_key', Props), @@ -70,8 +70,8 @@ bind_q(Q, <<_/binary>> = App, 'undefined') -> bind_q(Q, <<_/binary>> = App, <<_/binary>> = Key) -> amqp_util:bind_q_to_kapps(Q, ?DELEGATE_ROUTING_KEY(App, Key)). --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. --spec unbind_q(ne_binary(), ne_binary(), maybe_key()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:ne_binary(), maybe_key()) -> 'ok'. unbind_q(Q, Props) -> App = props:get_binary_value('app_name', Props), Key = props:get_value('route_key', Props), @@ -94,9 +94,9 @@ declare_exchanges() -> %% @doc Publish the JSON iolist() to the proper Exchange %% @end %%-------------------------------------------------------------------- --spec publish_delegate(ne_binary(), api_terms()) -> 'ok'. --spec publish_delegate(ne_binary(), api_terms(), maybe_key()) -> 'ok'. --spec publish_delegate(ne_binary(), api_terms(), maybe_key(), binary()) -> 'ok'. +-spec publish_delegate(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_delegate(kz_term:ne_binary(), kz_term:api_terms(), maybe_key()) -> 'ok'. +-spec publish_delegate(kz_term:ne_binary(), kz_term:api_terms(), maybe_key(), binary()) -> 'ok'. publish_delegate(TargetApp, API) -> publish_delegate(TargetApp, API, 'undefined'). diff --git a/core/kazoo_amqp/src/api/kapi_dialplan.erl b/core/kazoo_amqp/src/api/kapi_dialplan.erl index e05c4e04fe8..af7f169b43f 100644 --- a/core/kazoo_amqp/src/api/kapi_dialplan.erl +++ b/core/kazoo_amqp/src/api/kapi_dialplan.erl @@ -97,28 +97,28 @@ -include("amqp_util.hrl"). -include("kapi_dialplan.hrl"). --spec optional_bridge_req_headers() -> ne_binaries(). +-spec optional_bridge_req_headers() -> kz_term:ne_binaries(). optional_bridge_req_headers() -> ?OPTIONAL_BRIDGE_REQ_HEADERS. --spec optional_bridge_req_endpoint_headers() -> ne_binaries(). +-spec optional_bridge_req_endpoint_headers() -> kz_term:ne_binaries(). optional_bridge_req_endpoint_headers() -> ?OPTIONAL_BRIDGE_REQ_ENDPOINT_HEADERS. --spec b_leg_events_v(ne_binaries()) -> boolean(). +-spec b_leg_events_v(kz_term:ne_binaries()) -> boolean(). b_leg_events_v(Events) -> lists:all(fun(ApiEvent) -> lists:member(ApiEvent, ?CALL_EVENTS) end, Events). %% Takes a generic API JObj, determines what type it is, and calls the appropriate validator --spec v(api_terms()) -> boolean(). +-spec v(kz_term:api_terms()) -> boolean(). v(Prop) when is_list(Prop) -> v(Prop, props:get_value(<<"Application-Name">>, Prop)); v(JObj) -> v(kz_json:to_proplist(JObj)). --spec v(api_terms(), binary()) -> boolean(). +-spec v(kz_term:api_terms(), binary()) -> boolean(). v(Prop, DPApp) -> try VFun = kz_term:to_atom(<>), @@ -136,7 +136,7 @@ v(Prop, DPApp) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec bridge(api_terms()) -> api_formatter_return(). +-spec bridge(kz_term:api_terms()) -> api_formatter_return(). bridge(Prop) when is_list(Prop) -> EPs = [begin {'ok', EPProps} = bridge_endpoint_headers(EP), @@ -153,7 +153,7 @@ bridge(Prop) when is_list(Prop) -> bridge(JObj) -> bridge(kz_json:to_proplist(JObj)). --spec bridge_v(api_terms()) -> boolean(). +-spec bridge_v(kz_term:api_terms()) -> boolean(). bridge_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?BRIDGE_REQ_HEADERS, ?BRIDGE_REQ_VALUES, ?BRIDGE_REQ_TYPES); bridge_v(JObj) -> @@ -164,7 +164,7 @@ bridge_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec unbridge(api_terms()) -> api_formatter_return(). +-spec unbridge(kz_term:api_terms()) -> api_formatter_return(). unbridge(Prop) when is_list(Prop) -> case unbridge_v(Prop) of 'true' -> kz_api:build_message(Prop, ?UNBRIDGE_REQ_HEADERS, ?OPTIONAL_UNBRIDGE_REQ_HEADERS); @@ -173,7 +173,7 @@ unbridge(Prop) when is_list(Prop) -> unbridge(JObj) -> unbridge(kz_json:to_proplist(JObj)). --spec unbridge_v(api_terms()) -> boolean(). +-spec unbridge_v(kz_term:api_terms()) -> boolean(). unbridge_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?UNBRIDGE_REQ_HEADERS, ?UNBRIDGE_REQ_VALUES, ?UNBRIDGE_REQ_TYPES); unbridge_v(JObj) -> @@ -184,8 +184,8 @@ unbridge_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec bridge_endpoint(api_terms()) -> - {'ok', kz_proplist()} | +-spec bridge_endpoint(kz_term:api_terms()) -> + {'ok', kz_term:proplist()} | {'error', string()}. bridge_endpoint(Prop) when is_list(Prop) -> case bridge_endpoint_v(Prop) of @@ -195,15 +195,15 @@ bridge_endpoint(Prop) when is_list(Prop) -> bridge_endpoint(JObj) -> bridge_endpoint(kz_json:to_proplist(JObj)). --spec bridge_endpoint_headers(api_terms()) -> - {'ok', kz_proplist()} | +-spec bridge_endpoint_headers(kz_term:api_terms()) -> + {'ok', kz_term:proplist()} | {'error', string()}. bridge_endpoint_headers(Prop) when is_list(Prop) -> kz_api:build_message_specific_headers(Prop, ?BRIDGE_REQ_ENDPOINT_HEADERS, ?OPTIONAL_BRIDGE_REQ_ENDPOINT_HEADERS); bridge_endpoint_headers(JObj) -> bridge_endpoint_headers(kz_json:to_proplist(JObj)). --spec bridge_endpoint_v(api_terms()) -> boolean(). +-spec bridge_endpoint_v(kz_term:api_terms()) -> boolean(). bridge_endpoint_v(Prop) when is_list(Prop) -> kz_api:validate_message(Prop, ?BRIDGE_REQ_ENDPOINT_HEADERS, ?BRIDGE_REQ_ENDPOINT_VALUES, ?BRIDGE_REQ_ENDPOINT_TYPES); bridge_endpoint_v(JObj) -> @@ -214,7 +214,7 @@ bridge_endpoint_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec page(api_terms()) -> api_formatter_return(). +-spec page(kz_term:api_terms()) -> api_formatter_return(). page(Prop) when is_list(Prop) -> EPs = [begin {'ok', EPProps} = bridge_endpoint_headers(EP), @@ -230,13 +230,13 @@ page(Prop) when is_list(Prop) -> end; page(JObj) -> page(kz_json:to_proplist(JObj)). --spec page_v(api_terms()) -> boolean(). +-spec page_v(kz_term:api_terms()) -> boolean(). page_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?PAGE_REQ_HEADERS, ?PAGE_REQ_VALUES, ?PAGE_REQ_TYPES); page_v(JObj) -> page_v(kz_json:to_proplist(JObj)). --spec store(api_terms()) -> - {'ok', kz_proplist()} | +-spec store(kz_term:api_terms()) -> + {'ok', kz_term:proplist()} | {'error', string()}. store(Prop) when is_list(Prop) -> case store_v(Prop) of @@ -245,12 +245,12 @@ store(Prop) when is_list(Prop) -> end; store(JObj) -> store(kz_json:to_proplist(JObj)). --spec store_v(api_terms()) -> boolean(). +-spec store_v(kz_term:api_terms()) -> boolean(). store_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?STORE_REQ_HEADERS, ?STORE_REQ_VALUES, ?STORE_REQ_TYPES); store_v(JObj) -> store_v(kz_json:to_proplist(JObj)). --spec store_amqp_resp(api_terms()) -> api_formatter_return(). +-spec store_amqp_resp(kz_term:api_terms()) -> api_formatter_return(). store_amqp_resp(Prop) when is_list(Prop) -> case store_amqp_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?STORE_AMQP_RESP_HEADERS, ?OPTIONAL_STORE_AMQP_RESP_HEADERS); @@ -258,12 +258,12 @@ store_amqp_resp(Prop) when is_list(Prop) -> end; store_amqp_resp(JObj) -> store_amqp_resp(kz_json:to_proplist(JObj)). --spec store_amqp_resp_v(api_terms()) -> boolean(). +-spec store_amqp_resp_v(kz_term:api_terms()) -> boolean(). store_amqp_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?STORE_AMQP_RESP_HEADERS, ?STORE_AMQP_RESP_VALUES, ?STORE_AMQP_RESP_TYPES); store_amqp_resp_v(JObj) -> store_amqp_resp_v(kz_json:to_proplist(JObj)). --spec store_http_resp(api_terms()) -> api_formatter_return(). +-spec store_http_resp(kz_term:api_terms()) -> api_formatter_return(). store_http_resp(Prop) when is_list(Prop) -> case store_http_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?STORE_HTTP_RESP_HEADERS, ?OPTIONAL_STORE_HTTP_RESP_HEADERS); @@ -271,7 +271,7 @@ store_http_resp(Prop) when is_list(Prop) -> end; store_http_resp(JObj) -> store_http_resp(kz_json:to_proplist(JObj)). --spec store_http_resp_v(api_terms()) -> boolean(). +-spec store_http_resp_v(kz_term:api_terms()) -> boolean(). store_http_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?STORE_HTTP_RESP_HEADERS, ?STORE_HTTP_RESP_VALUES, ?STORE_HTTP_RESP_TYPES); store_http_resp_v(JObj) -> store_http_resp_v(kz_json:to_proplist(JObj)). @@ -286,7 +286,7 @@ store_media_content_v(V) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec send_dtmf(api_terms()) -> api_formatter_return() . +-spec send_dtmf(kz_term:api_terms()) -> api_formatter_return() . send_dtmf(Prop) when is_list(Prop) -> case send_dtmf_v(Prop) of 'true' -> kz_api:build_message(Prop, ?SEND_DTMF_HEADERS, ?OPTIONAL_SEND_DTMF_HEADERS); @@ -294,12 +294,12 @@ send_dtmf(Prop) when is_list(Prop) -> end; send_dtmf(JObj) -> send_dtmf(kz_json:to_proplist(JObj)). --spec send_dtmf_v(api_terms()) -> boolean(). +-spec send_dtmf_v(kz_term:api_terms()) -> boolean(). send_dtmf_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SEND_DTMF_HEADERS, ?SEND_DTMF_VALUES, ?SEND_DTMF_TYPES); send_dtmf_v(JObj) -> send_dtmf_v(kz_json:to_proplist(JObj)). --spec recv_dtmf(api_terms()) -> api_formatter_return() . +-spec recv_dtmf(kz_term:api_terms()) -> api_formatter_return() . recv_dtmf(Prop) when is_list(Prop) -> case recv_dtmf_v(Prop) of 'true' -> kz_api:build_message(Prop, ?RECV_DTMF_HEADERS, ?OPTIONAL_RECV_DTMF_HEADERS); @@ -307,7 +307,7 @@ recv_dtmf(Prop) when is_list(Prop) -> end; recv_dtmf(JObj) -> recv_dtmf(kz_json:to_proplist(JObj)). --spec recv_dtmf_v(api_terms()) -> boolean(). +-spec recv_dtmf_v(kz_term:api_terms()) -> boolean(). recv_dtmf_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?RECV_DTMF_HEADERS, ?RECV_DTMF_VALUES, ?RECV_DTMF_TYPES); recv_dtmf_v(JObj) -> recv_dtmf_v(kz_json:to_proplist(JObj)). @@ -317,7 +317,7 @@ recv_dtmf_v(JObj) -> recv_dtmf_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec tones(api_terms()) -> api_formatter_return() . +-spec tones(kz_term:api_terms()) -> api_formatter_return() . tones(Prop) when is_list(Prop) -> Tones = [begin {'ok', TonesProp} = tones_req_tone_headers(Tone), @@ -332,7 +332,7 @@ tones(Prop) when is_list(Prop) -> end; tones(JObj) -> tones(kz_json:to_proplist(JObj)). --spec tones_v(api_terms()) -> boolean(). +-spec tones_v(kz_term:api_terms()) -> boolean(). tones_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?TONES_REQ_HEADERS, ?TONES_REQ_VALUES, ?TONES_REQ_TYPES); tones_v(JObj) -> tones_v(kz_json:to_proplist(JObj)). @@ -352,7 +352,7 @@ tone_timeout_v(Timeout) -> %% Takes proplist and returns a proplist %% @end %%-------------------------------------------------------------------- --spec tones_req_tone(api_terms()) -> api_formatter_return(). +-spec tones_req_tone(kz_term:api_terms()) -> api_formatter_return(). tones_req_tone(Prop) when is_list(Prop) -> case tones_req_tone_v(Prop) of 'true' -> kz_api:build_message_specific(Prop, ?TONES_REQ_TONE_HEADERS, ?OPTIONAL_TONES_REQ_TONE_HEADERS); @@ -360,13 +360,13 @@ tones_req_tone(Prop) when is_list(Prop) -> end; tones_req_tone(JObj) -> tones_req_tone(kz_json:to_proplist(JObj)). --spec tones_req_tone_v(api_terms()) -> boolean(). +-spec tones_req_tone_v(kz_term:api_terms()) -> boolean(). tones_req_tone_v(Prop) when is_list(Prop) -> kz_api:validate_message(Prop, ?TONES_REQ_TONE_HEADERS, ?TONES_REQ_TONE_VALUES, ?TONES_REQ_TONE_TYPES); tones_req_tone_v(JObj) -> tones_req_tone_v(kz_json:to_proplist(JObj)). --spec tones_req_tone_headers(api_terms()) -> - {'ok', kz_proplist()} | +-spec tones_req_tone_headers(kz_term:api_terms()) -> + {'ok', kz_term:proplist()} | {'error', string()}. tones_req_tone_headers(Prop) when is_list(Prop) -> kz_api:build_message_specific_headers(Prop, ?TONES_REQ_TONE_HEADERS, ?OPTIONAL_TONES_REQ_TONE_HEADERS); @@ -377,7 +377,7 @@ tones_req_tone_headers(JObj) -> tones_req_tone_headers(kz_json:to_proplist(JObj) %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec tone_detect(api_terms()) -> api_formatter_return(). +-spec tone_detect(kz_term:api_terms()) -> api_formatter_return(). tone_detect(Prop) when is_list(Prop) -> case tone_detect_v(Prop) of 'true' -> kz_api:build_message(Prop, ?TONE_DETECT_REQ_HEADERS, ?OPTIONAL_TONE_DETECT_REQ_HEADERS); @@ -385,7 +385,7 @@ tone_detect(Prop) when is_list(Prop) -> end; tone_detect(JObj) -> tone_detect(kz_json:to_proplist(JObj)). --spec tone_detect_v(api_terms()) -> boolean(). +-spec tone_detect_v(kz_term:api_terms()) -> boolean(). tone_detect_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?TONE_DETECT_REQ_HEADERS, ?TONE_DETECT_REQ_VALUES, ?TONE_DETECT_REQ_TYPES); tone_detect_v(JObj) -> tone_detect_v(kz_json:to_proplist(JObj)). @@ -395,7 +395,7 @@ tone_detect_v(JObj) -> tone_detect_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec queue(api_terms()) -> api_formatter_return(). +-spec queue(kz_term:api_terms()) -> api_formatter_return(). queue(Prop) when is_list(Prop) -> case queue_v(Prop) of 'true' -> kz_api:build_message(Prop, ?QUEUE_REQ_HEADERS, ?OPTIONAL_QUEUE_REQ_HEADERS); @@ -403,7 +403,7 @@ queue(Prop) when is_list(Prop) -> end; queue(JObj) -> queue(kz_json:to_proplist(JObj)). --spec queue_v(api_terms()) -> boolean(). +-spec queue_v(kz_term:api_terms()) -> boolean(). queue_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?QUEUE_REQ_HEADERS, ?QUEUE_REQ_VALUES, ?QUEUE_REQ_TYPES); queue_v(JObj) -> queue_v(kz_json:to_proplist(JObj)). @@ -413,7 +413,7 @@ queue_v(JObj) -> queue_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec play(api_terms()) -> api_formatter_return(). +-spec play(kz_term:api_terms()) -> api_formatter_return(). play(Prop) when is_list(Prop) -> case play_v(Prop) of 'true' -> kz_api:build_message(Prop, ?PLAY_REQ_HEADERS, ?OPTIONAL_PLAY_REQ_HEADERS); @@ -421,7 +421,7 @@ play(Prop) when is_list(Prop) -> end; play(JObj) -> play(kz_json:to_proplist(JObj)). --spec play_v(api_terms()) -> boolean(). +-spec play_v(kz_term:api_terms()) -> boolean(). play_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?PLAY_REQ_HEADERS, ?PLAY_REQ_VALUES, ?PLAY_REQ_TYPES); play_v(JObj) -> play_v(kz_json:to_proplist(JObj)). @@ -431,7 +431,7 @@ play_v(JObj) -> play_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec break(api_terms()) -> api_formatter_return(). +-spec break(kz_term:api_terms()) -> api_formatter_return(). break(Prop) when is_list(Prop) -> case break_v(Prop) of 'true' -> kz_api:build_message(Prop, ?BREAK_REQ_HEADERS, ?OPTIONAL_BREAK_REQ_HEADERS); @@ -439,7 +439,7 @@ break(Prop) when is_list(Prop) -> end; break(JObj) -> break(kz_json:to_proplist(JObj)). --spec break_v(api_terms()) -> boolean(). +-spec break_v(kz_term:api_terms()) -> boolean(). break_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?BREAK_REQ_HEADERS, ?BREAK_REQ_VALUES, ?BREAK_REQ_TYPES); break_v(JObj) -> break_v(kz_json:to_proplist(JObj)). @@ -450,7 +450,7 @@ break_v(JObj) -> break_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec playstop(api_terms()) -> api_formatter_return(). +-spec playstop(kz_term:api_terms()) -> api_formatter_return(). playstop(Prop) when is_list(Prop) -> case playstop_v(Prop) of 'true' -> kz_api:build_message(Prop, ?PLAY_STOP_REQ_HEADERS, ?OPTIONAL_PLAY_STOP_REQ_HEADERS); @@ -458,7 +458,7 @@ playstop(Prop) when is_list(Prop) -> end; playstop(JObj) -> playstop(kz_json:to_proplist(JObj)). --spec playstop_v(api_terms()) -> boolean(). +-spec playstop_v(kz_term:api_terms()) -> boolean(). playstop_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?PLAY_STOP_REQ_HEADERS, ?PLAY_STOP_REQ_VALUES, ?PLAY_STOP_REQ_TYPES); playstop_v(JObj) -> playstop_v(kz_json:to_proplist(JObj)). @@ -468,7 +468,7 @@ playstop_v(JObj) -> playstop_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec tts(api_terms()) -> api_formatter_return(). +-spec tts(kz_term:api_terms()) -> api_formatter_return(). tts(Prop) when is_list(Prop) -> case tts_v(Prop) of 'true' -> kz_api:build_message(Prop, ?TTS_REQ_HEADERS, ?OPTIONAL_TTS_REQ_HEADERS); @@ -476,7 +476,7 @@ tts(Prop) when is_list(Prop) -> end; tts(JObj) -> tts(kz_json:to_proplist(JObj)). --spec tts_v(api_terms()) -> boolean(). +-spec tts_v(kz_term:api_terms()) -> boolean(). tts_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?TTS_REQ_HEADERS, ?TTS_REQ_VALUES, ?TTS_REQ_TYPES); tts_v(JObj) -> tts_v(kz_json:to_proplist(JObj)). @@ -486,7 +486,7 @@ tts_v(JObj) -> tts_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec record(api_terms()) -> api_formatter_return(). +-spec record(kz_term:api_terms()) -> api_formatter_return(). record(Prop) when is_list(Prop) -> case record_v(Prop) of 'true' -> kz_api:build_message(Prop, ?RECORD_REQ_HEADERS, ?OPTIONAL_RECORD_REQ_HEADERS); @@ -494,7 +494,7 @@ record(Prop) when is_list(Prop) -> end; record(JObj) -> record(kz_json:to_proplist(JObj)). --spec record_v(api_terms()) -> boolean(). +-spec record_v(kz_term:api_terms()) -> boolean(). record_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?RECORD_REQ_HEADERS, ?RECORD_REQ_VALUES, ?RECORD_REQ_TYPES); record_v(JObj) -> record_v(kz_json:to_proplist(JObj)). @@ -504,7 +504,7 @@ record_v(JObj) -> record_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec record_call(api_terms()) -> api_formatter_return(). +-spec record_call(kz_term:api_terms()) -> api_formatter_return(). record_call(Prop) when is_list(Prop) -> case record_call_v(Prop) of 'true' -> kz_api:build_message(Prop, ?RECORD_CALL_REQ_HEADERS, ?OPTIONAL_RECORD_CALL_REQ_HEADERS); @@ -512,7 +512,7 @@ record_call(Prop) when is_list(Prop) -> end; record_call(JObj) -> record_call(kz_json:to_proplist(JObj)). --spec record_call_v(api_terms()) -> boolean(). +-spec record_call_v(kz_term:api_terms()) -> boolean(). record_call_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?RECORD_CALL_REQ_HEADERS, ?RECORD_CALL_REQ_VALUES, ?RECORD_CALL_REQ_TYPES); record_call_v(JObj) -> record_call_v(kz_json:to_proplist(JObj)). @@ -522,7 +522,7 @@ record_call_v(JObj) -> record_call_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec answer(api_terms()) -> api_formatter_return(). +-spec answer(kz_term:api_terms()) -> api_formatter_return(). answer(Prop) when is_list(Prop) -> case answer_v(Prop) of 'true' -> kz_api:build_message(Prop, ?ANSWER_REQ_HEADERS, ?OPTIONAL_ANSWER_REQ_HEADERS); @@ -530,7 +530,7 @@ answer(Prop) when is_list(Prop) -> end; answer(JObj) -> answer(kz_json:to_proplist(JObj)). --spec answer_v(api_terms()) -> boolean(). +-spec answer_v(kz_term:api_terms()) -> boolean(). answer_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?ANSWER_REQ_HEADERS, ?ANSWER_REQ_VALUES, ?ANSWER_REQ_TYPES); answer_v(JObj) -> answer_v(kz_json:to_proplist(JObj)). @@ -540,7 +540,7 @@ answer_v(JObj) -> answer_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec echo(api_terms()) -> api_formatter_return(). +-spec echo(kz_term:api_terms()) -> api_formatter_return(). echo(Prop) when is_list(Prop) -> case echo_v(Prop) of 'true' -> kz_api:build_message(Prop, ?ECHO_REQ_HEADERS, ?OPTIONAL_ECHO_REQ_HEADERS); @@ -548,7 +548,7 @@ echo(Prop) when is_list(Prop) -> end; echo(JObj) -> echo(kz_json:to_proplist(JObj)). --spec echo_v(api_terms()) -> boolean(). +-spec echo_v(kz_term:api_terms()) -> boolean(). echo_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?ECHO_REQ_HEADERS, ?ECHO_REQ_VALUES, ?ECHO_REQ_TYPES); echo_v(JObj) -> echo_v(kz_json:to_proplist(JObj)). @@ -558,7 +558,7 @@ echo_v(JObj) -> echo_v(kz_json:to_proplist(JObj)). %% %% @end %%-------------------------------------------------------------------- --spec privacy(api_terms()) -> api_formatter_return(). +-spec privacy(kz_term:api_terms()) -> api_formatter_return(). privacy(Prop) when is_list(Prop) -> case privacy_v(Prop) of 'true' -> kz_api:build_message(Prop, ?PRIVACY_REQ_HEADERS, ?OPTIONAL_PRIVACY_REQ_HEADERS); @@ -566,7 +566,7 @@ privacy(Prop) when is_list(Prop) -> end; privacy(JObj) -> privacy(kz_json:to_proplist(JObj)). --spec privacy_v(api_terms()) -> boolean(). +-spec privacy_v(kz_term:api_terms()) -> boolean(). privacy_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?PRIVACY_REQ_HEADERS, ?PRIVACY_REQ_VALUES, ?PRIVACY_REQ_TYPES); privacy_v(JObj) -> privacy_v(kz_json:to_proplist(JObj)). @@ -576,7 +576,7 @@ privacy_v(JObj) -> privacy_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec progress(api_terms()) -> api_formatter_return(). +-spec progress(kz_term:api_terms()) -> api_formatter_return(). progress(Prop) when is_list(Prop) -> case progress_v(Prop) of 'true' -> kz_api:build_message(Prop, ?PROGRESS_REQ_HEADERS, ?OPTIONAL_PROGRESS_REQ_HEADERS); @@ -584,7 +584,7 @@ progress(Prop) when is_list(Prop) -> end; progress(JObj) -> progress(kz_json:to_proplist(JObj)). --spec progress_v(api_terms()) -> boolean(). +-spec progress_v(kz_term:api_terms()) -> boolean(). progress_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?PROGRESS_REQ_HEADERS, ?PROGRESS_REQ_VALUES, ?PROGRESS_REQ_TYPES); progress_v(JObj) -> progress_v(kz_json:to_proplist(JObj)). @@ -594,7 +594,7 @@ progress_v(JObj) -> progress_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec ring(api_terms()) -> api_formatter_return(). +-spec ring(kz_term:api_terms()) -> api_formatter_return(). ring(Prop) when is_list(Prop) -> case ring_v(Prop) of 'true' -> kz_api:build_message(Prop, ?RING_REQ_HEADERS, ?OPTIONAL_RING_REQ_HEADERS); @@ -602,7 +602,7 @@ ring(Prop) when is_list(Prop) -> end; ring(JObj) -> ring(kz_json:to_proplist(JObj)). --spec ring_v(api_terms()) -> boolean(). +-spec ring_v(kz_term:api_terms()) -> boolean(). ring_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?RING_REQ_HEADERS, ?RING_REQ_VALUES, ?RING_REQ_TYPES); ring_v(JObj) -> ring_v(kz_json:to_proplist(JObj)). @@ -612,7 +612,7 @@ ring_v(JObj) -> ring_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec receive_fax(api_terms()) -> api_formatter_return(). +-spec receive_fax(kz_term:api_terms()) -> api_formatter_return(). receive_fax(Prop) when is_list(Prop) -> case receive_fax_v(Prop) of 'true' -> kz_api:build_message(Prop, ?RECV_FAX_HEADERS, ?OPTIONAL_RECV_FAX_HEADERS); @@ -620,7 +620,7 @@ receive_fax(Prop) when is_list(Prop) -> end; receive_fax(JObj) -> receive_fax(kz_json:to_proplist(JObj)). --spec receive_fax_v(api_terms()) -> boolean(). +-spec receive_fax_v(kz_term:api_terms()) -> boolean(). receive_fax_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?RECV_FAX_HEADERS, ?RECV_FAX_VALUES, ?RECV_FAX_TYPES); receive_fax_v(JObj) -> receive_fax_v(kz_json:to_proplist(JObj)). @@ -630,7 +630,7 @@ receive_fax_v(JObj) -> receive_fax_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec store_fax(api_terms()) -> api_formatter_return(). +-spec store_fax(kz_term:api_terms()) -> api_formatter_return(). store_fax(Prop) when is_list(Prop) -> case store_fax_v(Prop) of 'true' -> kz_api:build_message(Prop, ?STORE_FAX_HEADERS, ?OPTIONAL_STORE_FAX_HEADERS); @@ -639,7 +639,7 @@ store_fax(Prop) when is_list(Prop) -> store_fax(JObj) -> store_fax(kz_json:to_proplist(JObj)). --spec store_fax_v(api_terms()) -> boolean(). +-spec store_fax_v(kz_term:api_terms()) -> boolean(). store_fax_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?STORE_FAX_HEADERS, ?STORE_FAX_VALUES, ?STORE_FAX_TYPES); store_fax_v(JObj) -> @@ -650,7 +650,7 @@ store_fax_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec hangup(api_terms()) -> api_formatter_return(). +-spec hangup(kz_term:api_terms()) -> api_formatter_return(). hangup(Prop) when is_list(Prop) -> case hangup_v(Prop) of 'true' -> kz_api:build_message(Prop, ?HANGUP_REQ_HEADERS, ?OPTIONAL_HANGUP_REQ_HEADERS); @@ -659,13 +659,13 @@ hangup(Prop) when is_list(Prop) -> hangup(JObj) -> hangup(kz_json:to_proplist(JObj)). --spec hangup_v(api_terms()) -> boolean(). +-spec hangup_v(kz_term:api_terms()) -> boolean(). hangup_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?HANGUP_REQ_HEADERS, ?HANGUP_REQ_VALUES, ?HANGUP_REQ_TYPES); hangup_v(JObj) -> hangup_v(kz_json:to_proplist(JObj)). --spec soft_hold(api_terms()) -> api_formatter_return(). +-spec soft_hold(kz_term:api_terms()) -> api_formatter_return(). soft_hold(Prop) when is_list(Prop) -> case soft_hold_v(Prop) of 'true' -> kz_api:build_message(Prop, ?SOFT_HOLD_REQ_HEADERS, ?OPTIONAL_SOFT_HOLD_REQ_HEADERS); @@ -674,7 +674,7 @@ soft_hold(Prop) when is_list(Prop) -> soft_hold(JObj) -> soft_hold(kz_json:to_proplist(JObj)). --spec soft_hold_v(api_terms()) -> boolean(). +-spec soft_hold_v(kz_term:api_terms()) -> boolean(). soft_hold_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SOFT_HOLD_REQ_HEADERS, ?SOFT_HOLD_REQ_VALUES, ?SOFT_HOLD_REQ_TYPES); soft_hold_v(JObj) -> @@ -685,7 +685,7 @@ soft_hold_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec hold(api_terms()) -> api_formatter_return(). +-spec hold(kz_term:api_terms()) -> api_formatter_return(). hold(Prop) when is_list(Prop) -> case hold_v(Prop) of 'true' -> kz_api:build_message(Prop, ?HOLD_REQ_HEADERS, ?OPTIONAL_HOLD_REQ_HEADERS); @@ -694,13 +694,13 @@ hold(Prop) when is_list(Prop) -> hold(JObj) -> hold(kz_json:to_proplist(JObj)). --spec hold_v(api_terms()) -> boolean(). +-spec hold_v(kz_term:api_terms()) -> boolean(). hold_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?HOLD_REQ_HEADERS, ?HOLD_REQ_VALUES, ?HOLD_REQ_TYPES); hold_v(JObj) -> hold_v(kz_json:to_proplist(JObj)). --spec hold_control(api_terms()) -> api_formatter_return(). +-spec hold_control(kz_term:api_terms()) -> api_formatter_return(). hold_control(Prop) when is_list(Prop) -> case hold_control_v(Prop) of 'true' -> kz_api:build_message(Prop, ?HOLD_CTL_REQ_HEADERS, ?OPTIONAL_HOLD_CTL_REQ_HEADERS); @@ -709,7 +709,7 @@ hold_control(Prop) when is_list(Prop) -> hold_control(JObj) -> hold_control(kz_json:to_proplist(JObj)). --spec hold_control_v(api_terms()) -> boolean(). +-spec hold_control_v(kz_term:api_terms()) -> boolean(). hold_control_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?HOLD_CTL_REQ_HEADERS, ?HOLD_CTL_REQ_VALUES, ?HOLD_CTL_REQ_TYPES); hold_control_v(JObj) -> @@ -720,7 +720,7 @@ hold_control_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec park(api_terms()) -> api_formatter_return(). +-spec park(kz_term:api_terms()) -> api_formatter_return(). park(Prop) when is_list(Prop) -> case park_v(Prop) of 'true' -> kz_api:build_message(Prop, ?PARK_REQ_HEADERS, ?OPTIONAL_PARK_REQ_HEADERS); @@ -729,13 +729,13 @@ park(Prop) when is_list(Prop) -> park(JObj) -> park(kz_json:to_proplist(JObj)). --spec park_v(api_terms()) -> boolean(). +-spec park_v(kz_term:api_terms()) -> boolean(). park_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?PARK_REQ_HEADERS, ?PARK_REQ_VALUES, ?PARK_REQ_TYPES); park_v(JObj) -> park_v(kz_json:to_proplist(JObj)). --spec audio_level(api_terms()) -> api_formatter_return(). +-spec audio_level(kz_term:api_terms()) -> api_formatter_return(). audio_level(Prop) when is_list(Prop) -> case audio_level_v(Prop) of 'true' -> kz_api:build_message(Prop, ?AUDIO_REQ_HEADERS, ?OPTIONAL_AUDIO_REQ_HEADERS); @@ -744,7 +744,7 @@ audio_level(Prop) when is_list(Prop) -> audio_level(JObj) -> audio_level(kz_json:to_proplist(JObj)). --spec audio_level_v(api_terms()) -> boolean(). +-spec audio_level_v(kz_term:api_terms()) -> boolean(). audio_level_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?AUDIO_REQ_HEADERS, ?AUDIO_REQ_VALUES, ?AUDIO_REQ_TYPES); audio_level_v(JObj) -> @@ -754,7 +754,7 @@ audio_level_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec set(api_terms()) -> api_formatter_return(). +-spec set(kz_term:api_terms()) -> api_formatter_return(). set(Prop) when is_list(Prop) -> case set_v(Prop) of 'true' -> kz_api:build_message(Prop, ?SET_REQ_HEADERS, ?OPTIONAL_SET_REQ_HEADERS); @@ -763,7 +763,7 @@ set(Prop) when is_list(Prop) -> set(JObj) -> set(kz_json:to_proplist(JObj)). --spec set_v(api_terms()) -> boolean() . +-spec set_v(kz_term:api_terms()) -> boolean() . set_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SET_REQ_HEADERS, ?SET_REQ_VALUES, ?SET_REQ_TYPES); set_v(JObj) -> @@ -774,7 +774,7 @@ set_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec set_terminators(api_terms()) -> api_formatter_return(). +-spec set_terminators(kz_term:api_terms()) -> api_formatter_return(). set_terminators(Prop) when is_list(Prop) -> case set_terminators_v(Prop) of 'true' -> kz_api:build_message(Prop, ?SET_TERM_HEADERS, ?OPTIONAL_SET_TERM_HEADERS); @@ -783,7 +783,7 @@ set_terminators(Prop) when is_list(Prop) -> set_terminators(JObj) -> set_terminators(kz_json:to_proplist(JObj)). --spec set_terminators_v(api_terms()) -> boolean() . +-spec set_terminators_v(kz_term:api_terms()) -> boolean() . set_terminators_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SET_TERM_HEADERS, ?SET_TERM_VALUES, ?SET_TERM_TYPES); set_terminators_v(JObj) -> @@ -794,7 +794,7 @@ set_terminators_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec fetch(api_terms()) -> api_formatter_return(). +-spec fetch(kz_term:api_terms()) -> api_formatter_return(). fetch(Prop) when is_list(Prop) -> case fetch_v(Prop) of 'true' -> kz_api:build_message(Prop, ?FETCH_REQ_HEADERS, ?OPTIONAL_FETCH_REQ_HEADERS); @@ -803,7 +803,7 @@ fetch(Prop) when is_list(Prop) -> fetch(JObj) -> fetch(kz_json:to_proplist(JObj)). --spec fetch_v(api_terms()) -> boolean(). +-spec fetch_v(kz_term:api_terms()) -> boolean(). fetch_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?FETCH_REQ_HEADERS, ?FETCH_REQ_VALUES, ?FETCH_REQ_TYPES); fetch_v(JObj) -> @@ -814,7 +814,7 @@ fetch_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec play_and_collect_digits(api_terms()) -> api_formatter_return(). +-spec play_and_collect_digits(kz_term:api_terms()) -> api_formatter_return(). play_and_collect_digits(Prop) when is_list(Prop) -> case play_and_collect_digits_v(Prop) of 'true' -> kz_api:build_message(Prop, ?PLAY_COLLECT_DIGITS_REQ_HEADERS, ?OPTIONAL_PLAY_COLLECT_DIGITS_REQ_HEADERS); @@ -823,7 +823,7 @@ play_and_collect_digits(Prop) when is_list(Prop) -> play_and_collect_digits(JObj) -> play_and_collect_digits(kz_json:to_proplist(JObj)). --spec play_and_collect_digits_v(api_terms()) -> boolean(). +-spec play_and_collect_digits_v(kz_term:api_terms()) -> boolean(). play_and_collect_digits_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?PLAY_COLLECT_DIGITS_REQ_HEADERS, ?PLAY_COLLECT_DIGITS_REQ_VALUES, ?PLAY_COLLECT_DIGITS_REQ_TYPES); play_and_collect_digits_v(JObj) -> @@ -834,7 +834,7 @@ play_and_collect_digits_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec call_pickup(api_terms()) -> api_formatter_return(). +-spec call_pickup(kz_term:api_terms()) -> api_formatter_return(). call_pickup(Prop) when is_list(Prop) -> case call_pickup_v(Prop) of 'true' -> kz_api:build_message(Prop, ?CALL_PICKUP_REQ_HEADERS, ?OPTIONAL_CALL_PICKUP_REQ_HEADERS); @@ -843,7 +843,7 @@ call_pickup(Prop) when is_list(Prop) -> call_pickup(JObj) -> call_pickup(kz_json:to_proplist(JObj)). --spec call_pickup_v(api_terms()) -> boolean(). +-spec call_pickup_v(kz_term:api_terms()) -> boolean(). call_pickup_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CALL_PICKUP_REQ_HEADERS, ?CALL_PICKUP_REQ_VALUES, ?CALL_PICKUP_REQ_TYPES); call_pickup_v(JObj) -> @@ -854,7 +854,7 @@ call_pickup_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec connect_leg(api_terms()) -> api_formatter_return(). +-spec connect_leg(kz_term:api_terms()) -> api_formatter_return(). connect_leg(Prop) when is_list(Prop) -> case connect_leg_v(Prop) of 'true' -> kz_api:build_message(Prop, ?CONNECT_LEG_REQ_HEADERS, ?OPTIONAL_CONNECT_LEG_REQ_HEADERS); @@ -863,7 +863,7 @@ connect_leg(Prop) when is_list(Prop) -> connect_leg(JObj) -> connect_leg(kz_json:to_proplist(JObj)). --spec connect_leg_v(api_terms()) -> boolean(). +-spec connect_leg_v(kz_term:api_terms()) -> boolean(). connect_leg_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CONNECT_LEG_REQ_HEADERS, ?CONNECT_LEG_REQ_VALUES, ?CONNECT_LEG_REQ_TYPES); connect_leg_v(JObj) -> @@ -874,7 +874,7 @@ connect_leg_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec eavesdrop(api_terms()) -> api_formatter_return(). +-spec eavesdrop(kz_term:api_terms()) -> api_formatter_return(). eavesdrop(Prop) when is_list(Prop) -> case eavesdrop_v(Prop) of 'true' -> kz_api:build_message(Prop, ?EAVESDROP_REQ_HEADERS, ?OPTIONAL_EAVESDROP_REQ_HEADERS); @@ -883,7 +883,7 @@ eavesdrop(Prop) when is_list(Prop) -> eavesdrop(JObj) -> eavesdrop(kz_json:to_proplist(JObj)). --spec eavesdrop_v(api_terms()) -> boolean(). +-spec eavesdrop_v(kz_term:api_terms()) -> boolean(). eavesdrop_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?EAVESDROP_REQ_HEADERS, ?EAVESDROP_REQ_VALUES, ?EAVESDROP_REQ_TYPES); eavesdrop_v(JObj) -> @@ -894,7 +894,7 @@ eavesdrop_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec say(api_terms()) -> api_formatter_return(). +-spec say(kz_term:api_terms()) -> api_formatter_return(). say(Prop) when is_list(Prop) -> case say_v(Prop) of 'true' -> kz_api:build_message(Prop, ?SAY_REQ_HEADERS, ?OPTIONAL_SAY_REQ_HEADERS); @@ -903,7 +903,7 @@ say(Prop) when is_list(Prop) -> say(JObj) -> say(kz_json:to_proplist(JObj)). --spec say_v(api_terms()) -> boolean(). +-spec say_v(kz_term:api_terms()) -> boolean(). say_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SAY_REQ_HEADERS, ?SAY_REQ_VALUES, ?SAY_REQ_TYPES); say_v(JObj) -> @@ -914,7 +914,7 @@ say_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec respond(api_terms()) -> api_formatter_return(). +-spec respond(kz_term:api_terms()) -> api_formatter_return(). respond(Prop) when is_list(Prop) -> case respond_v(Prop) of 'true' -> kz_api:build_message(Prop, ?RESPOND_REQ_HEADERS, ?OPTIONAL_RESPOND_REQ_HEADERS); @@ -923,7 +923,7 @@ respond(Prop) when is_list(Prop) -> respond(JObj) -> respond(kz_json:to_proplist(JObj)). --spec respond_v(api_terms()) -> boolean(). +-spec respond_v(kz_term:api_terms()) -> boolean(). respond_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?RESPOND_REQ_HEADERS, ?RESPOND_REQ_VALUES, ?RESPOND_REQ_TYPES); respond_v(JObj) -> @@ -934,7 +934,7 @@ respond_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec redirect(api_terms()) -> api_formatter_return(). +-spec redirect(kz_term:api_terms()) -> api_formatter_return(). redirect(Prop) when is_list(Prop) -> case redirect_v(Prop) of 'true' -> kz_api:build_message(Prop, ?REDIRECT_REQ_HEADERS, ?OPTIONAL_REDIRECT_REQ_HEADERS); @@ -943,7 +943,7 @@ redirect(Prop) when is_list(Prop) -> redirect(JObj) -> redirect(kz_json:to_proplist(JObj)). --spec redirect_v(api_terms()) -> boolean(). +-spec redirect_v(kz_term:api_terms()) -> boolean(). redirect_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?REDIRECT_REQ_HEADERS, ?REDIRECT_REQ_VALUES, ?REDIRECT_REQ_TYPES); redirect_v(JObj) -> @@ -954,7 +954,7 @@ redirect_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec execute_extension(api_terms()) -> api_formatter_return(). +-spec execute_extension(kz_term:api_terms()) -> api_formatter_return(). execute_extension(Prop) when is_list(Prop) -> case execute_extension_v(Prop) of 'true' -> kz_api:build_message(Prop, ?EXECUTE_EXTENSION_REQ_HEADERS, ?OPTIONAL_EXECUTE_EXTENSION_REQ_HEADERS); @@ -963,7 +963,7 @@ execute_extension(Prop) when is_list(Prop) -> execute_extension(JObj) -> execute_extension(kz_json:to_proplist(JObj)). --spec execute_extension_v(api_terms()) -> boolean(). +-spec execute_extension_v(kz_term:api_terms()) -> boolean(). execute_extension_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?EXECUTE_EXTENSION_REQ_HEADERS, ?EXECUTE_EXTENSION_REQ_VALUES, ?EXECUTE_EXTENSION_REQ_TYPES); execute_extension_v(JObj) -> @@ -974,7 +974,7 @@ execute_extension_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec sleep(api_terms()) -> api_formatter_return(). +-spec sleep(kz_term:api_terms()) -> api_formatter_return(). sleep(Prop) when is_list(Prop) -> case sleep_v(Prop) of 'true' -> kz_api:build_message(Prop, ?SLEEP_REQ_HEADERS, ?OPTIONAL_SLEEP_REQ_HEADERS); @@ -983,7 +983,7 @@ sleep(Prop) when is_list(Prop) -> sleep(JObj) -> sleep(kz_json:to_proplist(JObj)). --spec sleep_v(api_terms()) -> boolean(). +-spec sleep_v(kz_term:api_terms()) -> boolean(). sleep_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SLEEP_REQ_HEADERS, ?SLEEP_REQ_VALUES, ?SLEEP_REQ_TYPES); sleep_v(JObj) -> @@ -994,7 +994,7 @@ sleep_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec noop(api_terms()) -> api_formatter_return(). +-spec noop(kz_term:api_terms()) -> api_formatter_return(). noop(Prop) when is_list(Prop) -> case noop_v(Prop) of 'true' -> kz_api:build_message(Prop, ?NOOP_REQ_HEADERS, ?OPTIONAL_NOOP_REQ_HEADERS); @@ -1003,7 +1003,7 @@ noop(Prop) when is_list(Prop) -> noop(JObj) -> noop(kz_json:to_proplist(JObj)). --spec noop_v(api_terms()) -> boolean(). +-spec noop_v(kz_term:api_terms()) -> boolean(). noop_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?NOOP_REQ_HEADERS, ?NOOP_REQ_VALUES, ?NOOP_REQ_TYPES); noop_v(JObj) -> @@ -1014,7 +1014,7 @@ noop_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec conference(api_terms()) -> api_formatter_return(). +-spec conference(kz_term:api_terms()) -> api_formatter_return(). conference(Prop) when is_list(Prop) -> case conference_v(Prop) of 'true' -> kz_api:build_message(Prop, ?CONFERENCE_REQ_HEADERS, ?OPTIONAL_CONFERENCE_REQ_HEADERS); @@ -1022,7 +1022,7 @@ conference(Prop) when is_list(Prop) -> end; conference(JObj) -> conference(kz_json:to_proplist(JObj)). --spec conference_v(api_terms()) -> boolean(). +-spec conference_v(kz_term:api_terms()) -> boolean(). conference_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CONFERENCE_REQ_HEADERS, ?CONFERENCE_REQ_VALUES, ?CONFERENCE_REQ_TYPES); conference_v(JObj) -> conference_v(kz_json:to_proplist(JObj)). @@ -1033,7 +1033,7 @@ conference_v(JObj) -> conference_v(kz_json:to_proplist(JObj)). %% wait for the Requestor to respond to execute the origination %% @end %%-------------------------------------------------------------------- --spec originate_ready(api_terms()) -> api_formatter_return(). +-spec originate_ready(kz_term:api_terms()) -> api_formatter_return(). originate_ready(Prop) when is_list(Prop) -> case originate_ready_v(Prop) of 'true' -> kz_api:build_message(Prop, ?ORIGINATE_READY_HEADERS, ?OPTIONAL_ORIGINATE_READY_HEADERS); @@ -1042,13 +1042,13 @@ originate_ready(Prop) when is_list(Prop) -> originate_ready(JObj) -> originate_ready(kz_json:to_proplist(JObj)). --spec originate_ready_v(api_terms()) -> boolean(). +-spec originate_ready_v(kz_term:api_terms()) -> boolean(). originate_ready_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?ORIGINATE_READY_HEADERS, ?ORIGINATE_READY_VALUES, ?ORIGINATE_READY_TYPES); originate_ready_v(JObj) -> originate_ready_v(kz_json:to_proplist(JObj)). --spec originate_execute(api_terms()) -> api_formatter_return(). +-spec originate_execute(kz_term:api_terms()) -> api_formatter_return(). originate_execute(Prop) when is_list(Prop) -> case originate_execute_v(Prop) of 'true' -> kz_api:build_message(Prop, ?ORIGINATE_EXECUTE_HEADERS, ?OPTIONAL_ORIGINATE_EXECUTE_HEADERS); @@ -1057,7 +1057,7 @@ originate_execute(Prop) when is_list(Prop) -> originate_execute(JObj) -> originate_execute(kz_json:to_proplist(JObj)). --spec originate_execute_v(api_terms()) -> boolean(). +-spec originate_execute_v(kz_term:api_terms()) -> boolean(). originate_execute_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?ORIGINATE_EXECUTE_HEADERS, ?ORIGINATE_EXECUTE_VALUES, ?ORIGINATE_EXECUTE_TYPES); originate_execute_v(JObj) -> @@ -1068,7 +1068,7 @@ originate_execute_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec error(api_terms()) -> api_formatter_return(). +-spec error(kz_term:api_terms()) -> api_formatter_return(). error(Prop) when is_list(Prop) -> case error_v(Prop) of 'true' -> kz_api:build_message(Prop, ?ERROR_RESP_HEADERS, ?OPTIONAL_ERROR_RESP_HEADERS); @@ -1076,7 +1076,7 @@ error(Prop) when is_list(Prop) -> end; error(JObj) -> error(kz_json:to_proplist(JObj)). --spec error_v(api_terms()) -> boolean(). +-spec error_v(kz_term:api_terms()) -> boolean(). error_v(Prop) when is_list(Prop) -> kz_api:validate(Prop ,?ERROR_RESP_HEADERS @@ -1088,8 +1088,8 @@ error_v(Prop) when is_list(Prop) -> error_v(JObj) -> error_v(kz_json:to_proplist(JObj)). %% Takes a generic API JObj, determines what type it is, and calls the appropriate validator --spec publish_command(ne_binary(), api_terms()) -> 'ok'. --spec publish_command(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_command(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_command(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_command(CtrlQ, Prop) when is_list(Prop) -> publish_command(CtrlQ, Prop, props:get_value(<<"Application-Name">>, Prop)); @@ -1100,13 +1100,13 @@ publish_command(CtrlQ, Prop, DPApp) -> {'ok', Payload} = build_command(Prop, DPApp), amqp_util:callctl_publish(CtrlQ, Payload, ?DEFAULT_CONTENT_TYPE). --spec build_command(api_terms()) -> {'ok', api_terms()}. +-spec build_command(kz_term:api_terms()) -> {'ok', kz_term:api_terms()}. build_command(Prop) when is_list(Prop) -> build_command(Prop, props:get_value(<<"Application-Name">>, Prop)); build_command(JObj) -> build_command(kz_json:to_proplist(JObj)). --spec build_command(api_terms(), ne_binary()) -> {'ok', api_terms()}. +-spec build_command(kz_term:api_terms(), kz_term:ne_binary()) -> {'ok', kz_term:api_terms()}. build_command(Prop, DPApp) when is_list(Prop) -> try kz_term:to_atom(<>) of BuildMsgFun -> @@ -1124,15 +1124,15 @@ build_command(JObj, DPApp) -> build_command(kz_json:to_proplist(JObj), DPApp). %% sending DP actions to CallControl Queue --spec publish_action(ne_binary(), iodata()) -> 'ok'. --spec publish_action(ne_binary(), iodata(), ne_binary()) -> 'ok'. +-spec publish_action(kz_term:ne_binary(), iodata()) -> 'ok'. +-spec publish_action(kz_term:ne_binary(), iodata(), kz_term:ne_binary()) -> 'ok'. publish_action(Queue, JSON) -> publish_action(Queue, JSON, ?DEFAULT_CONTENT_TYPE). publish_action(Queue, Payload, ContentType) -> amqp_util:callctl_publish(Queue, Payload, ContentType). --spec publish_error(ne_binary(), api_terms()) -> 'ok'. --spec publish_error(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_error(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_error(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_error(CallID, JObj) -> publish_error(CallID, JObj, ?DEFAULT_CONTENT_TYPE). publish_error(CallID, API, ContentType) -> @@ -1141,33 +1141,33 @@ publish_error(CallID, API, ContentType) -> ], fun error/1), amqp_util:callevt_publish(kapi_call:event_routing_key(<<"diaplan">>, CallID), Payload, ContentType). --spec publish_originate_ready(ne_binary(), api_terms()) -> 'ok'. --spec publish_originate_ready(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_originate_ready(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_originate_ready(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_originate_ready(ServerId, JObj) -> publish_originate_ready(ServerId, JObj, ?DEFAULT_CONTENT_TYPE). publish_originate_ready(ServerId, API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?ORIGINATE_READY_VALUES, fun originate_ready/1), amqp_util:targeted_publish(ServerId, Payload, ContentType). --spec publish_originate_execute(ne_binary(), api_terms()) -> 'ok'. --spec publish_originate_execute(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_originate_execute(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_originate_execute(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_originate_execute(ServerId, JObj) -> publish_originate_execute(ServerId, JObj, ?DEFAULT_CONTENT_TYPE). publish_originate_execute(ServerId, API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?ORIGINATE_EXECUTE_VALUES, fun originate_execute/1), amqp_util:targeted_publish(ServerId, Payload, ContentType). --spec dial_method_single() -> ne_binary(). +-spec dial_method_single() -> kz_term:ne_binary(). dial_method_single() -> ?DIAL_METHOD_SINGLE. --spec dial_method_simultaneous() -> ne_binary(). +-spec dial_method_simultaneous() -> kz_term:ne_binary(). dial_method_simultaneous() -> ?DIAL_METHOD_SIMUL. --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, _Props) -> amqp_util:bind_q_to_callctl(Queue). --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Queue, _Props) -> amqp_util:unbind_q_from_callctl(Queue). @@ -1180,13 +1180,13 @@ unbind_q(Queue, _Props) -> declare_exchanges() -> amqp_util:callctl_exchange(). --spec terminators(api_binary()) -> ne_binaries(). +-spec terminators(kz_term:api_binary()) -> kz_term:ne_binaries(). terminators(Bin) when is_binary(Bin) -> [<> || <> <= Bin, lists:member(<>, ?ANY_DIGIT)]; terminators('undefined') -> ?ANY_DIGIT. --spec terminators_v(api_binaries() | binary()) -> boolean(). --spec terminator_v(ne_binary()) -> boolean(). +-spec terminators_v(kz_term:api_binaries() | binary()) -> boolean(). +-spec terminator_v(kz_term:ne_binary()) -> boolean(). terminators_v(Ts) when is_list(Ts) -> lists:all(fun terminator_v/1, Ts); terminators_v(<<>>) -> 'true'; @@ -1195,7 +1195,7 @@ terminators_v(_) -> 'false'. terminator_v(T) -> lists:member(T, ?ANY_DIGIT). --spec offsite_store_url(api_binary(), ne_binary()) -> ne_binary(). +-spec offsite_store_url(kz_term:api_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). offsite_store_url('undefined', _) -> throw({'error', <<"URL not defined">>}); offsite_store_url(Url, MediaName) -> iolist_to_binary([kz_binary:strip_right(Url, $/), "/", MediaName]). @@ -1205,7 +1205,7 @@ offsite_store_url(Url, MediaName) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec fax_detection(api_terms()) -> api_formatter_return(). +-spec fax_detection(kz_term:api_terms()) -> api_formatter_return(). fax_detection(Prop) when is_list(Prop) -> case fax_detection_v(Prop) of 'true' -> kz_api:build_message(Prop, ?FAX_DETECTION_REQ_HEADERS, ?OPTIONAL_FAX_DETECTION_REQ_HEADERS); @@ -1213,13 +1213,13 @@ fax_detection(Prop) when is_list(Prop) -> end; fax_detection(JObj) -> fax_detection(kz_json:to_proplist(JObj)). --spec fax_detection_v(api_terms()) -> boolean(). +-spec fax_detection_v(kz_term:api_terms()) -> boolean(). fax_detection_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?FAX_DETECTION_REQ_HEADERS, ?FAX_DETECTION_REQ_VALUES, ?FAX_DETECTION_REQ_TYPES); fax_detection_v(JObj) -> fax_detection_v(kz_json:to_proplist(JObj)). --spec store_vm(api_terms()) -> - {'ok', kz_proplist()} | +-spec store_vm(kz_term:api_terms()) -> + {'ok', kz_term:proplist()} | {'error', string()}. store_vm(Prop) when is_list(Prop) -> case store_vm_v(Prop) of @@ -1228,12 +1228,12 @@ store_vm(Prop) when is_list(Prop) -> end; store_vm(JObj) -> store_vm(kz_json:to_proplist(JObj)). --spec store_vm_v(api_terms()) -> boolean(). +-spec store_vm_v(kz_term:api_terms()) -> boolean(). store_vm_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?STORE_VM_REQ_HEADERS, ?STORE_VM_REQ_VALUES, ?STORE_VM_REQ_TYPES); store_vm_v(JObj) -> store_vm_v(kz_json:to_proplist(JObj)). --spec transfer(api_terms()) -> api_formatter_return(). +-spec transfer(kz_term:api_terms()) -> api_formatter_return(). transfer(Prop) when is_list(Prop) -> case transfer_v(Prop) of 'true' -> kz_api:build_message(Prop, ?TRANSFER_HEADERS, ?OPTIONAL_TRANSFER_HEADERS); @@ -1241,12 +1241,12 @@ transfer(Prop) when is_list(Prop) -> end; transfer(JObj) -> transfer(kz_json:to_proplist(JObj)). --spec transfer_v(api_terms()) -> boolean(). +-spec transfer_v(kz_term:api_terms()) -> boolean(). transfer_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?TRANSFER_HEADERS, ?TRANSFER_VALUES, ?TRANSFER_TYPES); transfer_v(JObj) -> transfer_v(kz_json:to_proplist(JObj)). --spec media_macro(api_terms()) -> api_formatter_return(). +-spec media_macro(kz_term:api_terms()) -> api_formatter_return(). media_macro(Prop) when is_list(Prop) -> case media_macro_v(Prop) of 'true' -> kz_api:build_message(Prop, ?MEDIA_MACRO_HEADERS, ?OPTIONAL_MEDIA_MACRO_HEADERS); @@ -1254,12 +1254,12 @@ media_macro(Prop) when is_list(Prop) -> end; media_macro(JObj) -> media_macro(kz_json:to_proplist(JObj)). --spec media_macro_v(api_terms()) -> boolean(). +-spec media_macro_v(kz_term:api_terms()) -> boolean(). media_macro_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?MEDIA_MACRO_HEADERS, ?MEDIA_MACRO_VALUES, ?MEDIA_MACRO_TYPES); media_macro_v(JObj) -> media_macro_v(kz_json:to_proplist(JObj)). --spec play_macro(api_terms()) -> api_formatter_return(). +-spec play_macro(kz_term:api_terms()) -> api_formatter_return(). play_macro(Prop) when is_list(Prop) -> case play_macro_v(Prop) of 'true' -> kz_api:build_message(Prop, ?PLAY_MACRO_HEADERS, ?OPTIONAL_PLAY_MACRO_HEADERS); @@ -1267,12 +1267,12 @@ play_macro(Prop) when is_list(Prop) -> end; play_macro(JObj) -> play_macro(kz_json:to_proplist(JObj)). --spec play_macro_v(api_terms()) -> boolean(). +-spec play_macro_v(kz_term:api_terms()) -> boolean(). play_macro_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?PLAY_MACRO_HEADERS, ?PLAY_MACRO_VALUES, ?PLAY_MACRO_TYPES); play_macro_v(JObj) -> play_macro_v(kz_json:to_proplist(JObj)). --spec sound_touch(api_terms()) -> api_formatter_return(). +-spec sound_touch(kz_term:api_terms()) -> api_formatter_return(). sound_touch(Prop) when is_list(Prop) -> case sound_touch_v(Prop) of 'true' -> kz_api:build_message(Prop, ?SOUNDTOUCH_HEADERS, ?OPTIONAL_SOUNDTOUCH_HEADERS); @@ -1280,7 +1280,7 @@ sound_touch(Prop) when is_list(Prop) -> end; sound_touch(JObj) -> sound_touch(kz_json:to_proplist(JObj)). --spec sound_touch_v(api_terms()) -> boolean(). +-spec sound_touch_v(kz_term:api_terms()) -> boolean(). sound_touch_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SOUNDTOUCH_HEADERS, ?SOUNDTOUCH_VALUES, ?SOUNDTOUCH_TYPES); sound_touch_v(JObj) -> sound_touch_v(kz_json:to_proplist(JObj)). diff --git a/core/kazoo_amqp/src/api/kapi_fax.erl b/core/kazoo_amqp/src/api/kapi_fax.erl index f60e39199d4..5f02efff490 100644 --- a/core/kazoo_amqp/src/api/kapi_fax.erl +++ b/core/kazoo_amqp/src/api/kapi_fax.erl @@ -92,7 +92,7 @@ ]). -define(FAX_START_JOB_TYPES, []). --spec req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. req(Prop) when is_list(Prop) -> case req_v(Prop) of 'false' -> {'error', "Proplist failed validation for fax_req"}; @@ -101,13 +101,13 @@ req(Prop) when is_list(Prop) -> req(JObj) -> req(kz_json:to_proplist(JObj)). --spec req_v(api_terms()) -> boolean(). +-spec req_v(kz_term:api_terms()) -> boolean(). req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?FAX_REQ_HEADERS, ?FAX_REQ_VALUES, ?FAX_REQ_TYPES); req_v(JObj) -> req_v(kz_json:to_proplist(JObj)). --spec query_status(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec query_status(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. query_status(Prop) when is_list(Prop) -> case query_status_v(Prop) of 'false' -> {'error', "Proplist failed validation for fax_query_status"}; @@ -116,13 +116,13 @@ query_status(Prop) when is_list(Prop) -> query_status(JObj) -> query_status(kz_json:to_proplist(JObj)). --spec query_status_v(api_terms()) -> boolean(). +-spec query_status_v(kz_term:api_terms()) -> boolean(). query_status_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?FAX_QUERY_HEADERS, ?FAX_QUERY_VALUES, ?FAX_QUERY_TYPES); query_status_v(JObj) -> query_status_v(kz_json:to_proplist(JObj)). --spec status(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec status(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. status(Prop) when is_list(Prop) -> case status_v(Prop) of 'false' -> {'error', "Proplist failed validation for fax_query_status"}; @@ -131,13 +131,13 @@ status(Prop) when is_list(Prop) -> status(JObj) -> status(kz_json:to_proplist(JObj)). --spec status_v(api_terms()) -> boolean(). +-spec status_v(kz_term:api_terms()) -> boolean(). status_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?FAX_STATUS_HEADERS, ?FAX_STATUS_VALUES, ?FAX_STATUS_TYPES); status_v(JObj) -> status_v(kz_json:to_proplist(JObj)). --spec start_account(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec start_account(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. start_account(Prop) when is_list(Prop) -> case start_account_v(Prop) of 'false' -> {'error', "Proplist failed validation for fax_start account"}; @@ -146,13 +146,13 @@ start_account(Prop) when is_list(Prop) -> start_account(JObj) -> start_account(kz_json:to_proplist(JObj)). --spec start_account_v(api_terms()) -> boolean(). +-spec start_account_v(kz_term:api_terms()) -> boolean(). start_account_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?FAX_START_ACCOUNT_HEADERS, ?FAX_START_ACCOUNT_VALUES, ?FAX_START_ACCOUNT_TYPES); start_account_v(JObj) -> start_account_v(kz_json:to_proplist(JObj)). --spec start_job(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec start_job(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. start_job(Prop) when is_list(Prop) -> case start_job_v(Prop) of 'false' -> {'error', "Proplist failed validation for fax_start account"}; @@ -161,20 +161,20 @@ start_job(Prop) when is_list(Prop) -> start_job(JObj) -> start_job(kz_json:to_proplist(JObj)). --spec start_job_v(api_terms()) -> boolean(). +-spec start_job_v(kz_term:api_terms()) -> boolean(). start_job_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?FAX_START_JOB_HEADERS, ?FAX_START_JOB_VALUES, ?FAX_START_JOB_TYPES); start_job_v(JObj) -> start_job_v(kz_json:to_proplist(JObj)). --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, Props) -> FaxId = props:get_value('fax_id', Props, <<"*">>), StartId = props:get_value('start_id', Props, <<"*">>), AccountId = props:get_value('account_id', Props, <<"*">>), bind_q(Queue, AccountId, FaxId, StartId, props:get_value('restrict_to', Props)). --spec bind_q(ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, AccountId, FaxId, StartId, 'undefined') -> amqp_util:bind_q_to_callmgr(Queue, fax_routing_key()), amqp_util:bind_q_to_exchange(Queue, fax_start_key(StartId), ?FAX_EXCHANGE), @@ -193,14 +193,14 @@ bind_q(Queue, AccountId, FaxId, StartId, ['start'|Restrict]) -> bind_q(Queue, AccountId, FaxId, StartId, Restrict); bind_q(_, _, _, _, []) -> 'ok'. --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Queue, Props) -> FaxId = props:get_value('fax_id', Props, <<"*">>), StartId = props:get_value('start_id', Props, <<"*">>), AccountId = props:get_value('account_id', Props, <<"*">>), unbind_q(Queue, AccountId, FaxId, StartId, props:get_value('restrict_to', Props)). --spec unbind_q(ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Queue, AccountId, FaxId, StartId, 'undefined') -> 'ok' = amqp_util:unbind_q_from_callmgr(Queue, fax_routing_key()), 'ok' = amqp_util:unbind_q_from_exchange(Queue, fax_start_key(StartId), ?FAX_EXCHANGE), @@ -230,8 +230,8 @@ declare_exchanges() -> amqp_util:targeted_exchange(), amqp_util:callmgr_exchange(). --spec publish_req(api_terms()) -> 'ok'. --spec publish_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_req(kz_term:api_terms()) -> 'ok'. +-spec publish_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_req(JObj) -> publish_req(JObj, ?DEFAULT_CONTENT_TYPE). @@ -239,8 +239,8 @@ publish_req(Api, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Api, ?FAX_REQ_VALUES, fun req/1), amqp_util:callmgr_publish(Payload, ContentType, fax_routing_key()). --spec publish_query_status(ne_binary(), api_terms()) -> 'ok'. --spec publish_query_status(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_query_status(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_query_status(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_query_status(Q, JObj) -> publish_query_status(Q, JObj, ?DEFAULT_CONTENT_TYPE). @@ -248,8 +248,8 @@ publish_query_status(Q, API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?FAX_QUERY_VALUES, fun query_status/1), amqp_util:targeted_publish(Q, Payload, ContentType). --spec publish_status(api_terms()) -> 'ok'. --spec publish_status(api_terms(), ne_binary()) -> 'ok'. +-spec publish_status(kz_term:api_terms()) -> 'ok'. +-spec publish_status(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_status(API) -> publish_status(API, ?DEFAULT_CONTENT_TYPE). @@ -259,8 +259,8 @@ publish_status(API, ContentType) -> AccountId = props:get_value(<<"Account-ID">>, API, <<"*">>), amqp_util:basic_publish(?FAX_EXCHANGE, status_routing_key(AccountId, FaxId), Payload, ContentType). --spec publish_targeted_status(ne_binary(), api_terms()) -> 'ok'. --spec publish_targeted_status(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_targeted_status(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_targeted_status(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_targeted_status(Q, JObj) -> publish_targeted_status(Q, JObj, ?DEFAULT_CONTENT_TYPE). @@ -268,8 +268,8 @@ publish_targeted_status(Q, Api, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Api, ?FAX_STATUS_VALUES, fun status/1), amqp_util:targeted_publish(Q, Payload, ContentType). --spec publish_start_account(api_terms()) -> 'ok'. --spec publish_start_account(api_terms(), ne_binary()) -> 'ok'. +-spec publish_start_account(kz_term:api_terms()) -> 'ok'. +-spec publish_start_account(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_start_account(API) -> publish_start_account(API, ?DEFAULT_CONTENT_TYPE). @@ -278,8 +278,8 @@ publish_start_account(API, ContentType) -> AccountId = props:get_value(<<"Account-ID">>, API,<<"*">>), amqp_util:basic_publish(?FAX_EXCHANGE, fax_start_key(<<"account">>, AccountId), Payload, ContentType). --spec publish_start_job(api_terms()) -> 'ok'. --spec publish_start_job(api_terms(), ne_binary()) -> 'ok'. +-spec publish_start_job(kz_term:api_terms()) -> 'ok'. +-spec publish_start_job(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_start_job(API) -> publish_start_job(API, ?DEFAULT_CONTENT_TYPE). @@ -300,18 +300,18 @@ fax_start_key(Type, Id) -> status_routing_key(AccountId, FaxId) -> list_to_binary(["fax.status.", AccountId, ".", amqp_util:encode(FaxId)]). --spec account_id(kz_json:object()) -> ne_binary(). +-spec account_id(kz_json:object()) -> kz_term:ne_binary(). account_id(JObj) -> kz_json:get_ne_binary_value(<<"Account-ID">>, JObj). --spec job_id(kz_json:object()) -> ne_binary(). +-spec job_id(kz_json:object()) -> kz_term:ne_binary(). job_id(JObj) -> kz_json:get_ne_binary_value(<<"Job-ID">>, JObj). --spec to_number(kz_json:object()) -> ne_binary(). +-spec to_number(kz_json:object()) -> kz_term:ne_binary(). to_number(JObj) -> kz_json:get_ne_binary_value(<<"To-Number">>, JObj). --spec state(kz_json:object()) -> ne_binary(). +-spec state(kz_json:object()) -> kz_term:ne_binary(). state(JObj) -> kz_json:get_ne_binary_value(<<"Fax-State">>, JObj). diff --git a/core/kazoo_amqp/src/api/kapi_fs.erl b/core/kazoo_amqp/src/api/kapi_fs.erl index 9d9aa8834b7..ffa03e85e1c 100644 --- a/core/kazoo_amqp/src/api/kapi_fs.erl +++ b/core/kazoo_amqp/src/api/kapi_fs.erl @@ -30,7 +30,7 @@ %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. req(Prop) when is_list(Prop) -> case req_v(Prop) of true -> kz_api:build_message(Prop, ?FS_REQ_HEADERS, ?OPTIONAL_FS_REQ_HEADERS); @@ -39,7 +39,7 @@ req(Prop) when is_list(Prop) -> req(JObj) -> req(kz_json:to_proplist(JObj)). --spec req_v(api_terms()) -> boolean(). +-spec req_v(kz_term:api_terms()) -> boolean(). req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?FS_REQ_HEADERS, ?FS_REQ_VALUES, ?FS_REQ_TYPES); req_v(JObj) -> @@ -54,8 +54,8 @@ req_v(JObj) -> declare_exchanges() -> amqp_util:callctl_exchange(). --spec publish_req(ne_binary(), api_terms()) -> 'ok'. --spec publish_req(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_req(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_req(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_req(Queue, JObj) -> publish_req(Queue, JObj, ?DEFAULT_CONTENT_TYPE). publish_req(Queue, Req, ContentType) -> diff --git a/core/kazoo_amqp/src/api/kapi_globals.erl b/core/kazoo_amqp/src/api/kapi_globals.erl index e9c01d8d7df..00ba004df9b 100644 --- a/core/kazoo_amqp/src/api/kapi_globals.erl +++ b/core/kazoo_amqp/src/api/kapi_globals.erl @@ -47,11 +47,11 @@ -type state() :: 'none' | 'local' | 'pending' | 'remote' | 'registered'. -export_type([state/0]). --spec encode(any()) -> ne_binary(). +-spec encode(any()) -> kz_term:ne_binary(). encode(Term) -> base64:encode(term_to_binary(Term)). --spec decode(api_binary()) -> any(). +-spec decode(kz_term:api_binary()) -> any(). decode('undefined') -> 'undefined'; decode(Bin) -> binary_to_term(base64:decode(Bin)). @@ -75,18 +75,18 @@ maybe_decode(MaybeEncoded) -> 'error':{'badarg', _} -> MaybeEncoded end. --spec encode_req(kz_json:object() | kz_proplist()) -> any(). +-spec encode_req(kz_json:object() | kz_term:proplist()) -> any(). encode_req(Req) -> set_name(Req, name(Req)). --spec name(kz_json:object() | kz_proplist()) -> any(). +-spec name(kz_json:object() | kz_term:proplist()) -> any(). name(Props) when is_list(Props) -> maybe_decode(props:get_value(<<"Name">>, Props)); name(JObj) -> maybe_decode(kz_json:get_value(<<"Name">>, JObj)). --spec set_name(api_terms(), any()) -> api_terms(). +-spec set_name(kz_term:api_terms(), any()) -> kz_term:api_terms(). set_name(Req, 'undefined') -> Req; set_name(Props, Name) when is_list(Props) -> @@ -94,11 +94,11 @@ set_name(Props, Name) set_name(JObj, Name) -> kz_json:set_value(<<"Name">>, maybe_encode(Name), JObj). --spec message(kz_json:object()) -> ne_binary(). +-spec message(kz_json:object()) -> kz_term:ne_binary(). message(JObj) -> maybe_decode(kz_json:get_value(<<"Message">>, JObj)). --spec reply(kz_json:object()) -> ne_binary(). +-spec reply(kz_json:object()) -> kz_term:ne_binary(). reply(JObj) -> maybe_decode(kz_json:get_value(<<"Reply">>, JObj)). @@ -203,7 +203,7 @@ routing_key(Event, Name) -> ]). -define(REPLY_REQ_TYPES, []). --spec register(api_terms()) -> api_formatter_return(). +-spec register(kz_term:api_terms()) -> api_formatter_return(). register(Prop) when is_list(Prop) -> case register_v(Prop) of 'true' -> kz_api:build_message(Prop, ?REGISTER_REQ_HEADERS, ?OPTIONAL_REGISTER_REQ_HEADERS); @@ -212,13 +212,13 @@ register(Prop) when is_list(Prop) -> register(JObj) -> register(kz_json:to_proplist(JObj)). --spec register_v(api_terms()) -> boolean(). +-spec register_v(kz_term:api_terms()) -> boolean(). register_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?REGISTER_REQ_HEADERS, ?REGISTER_REQ_VALUES, ?REGISTER_REQ_TYPES); register_v(JObj) -> register_v(kz_json:to_proplist(JObj)). --spec register_resp(api_terms()) -> api_formatter_return(). +-spec register_resp(kz_term:api_terms()) -> api_formatter_return(). register_resp(Prop) when is_list(Prop) -> case register_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?REGISTER_RESP_HEADERS, ?OPTIONAL_REGISTER_RESP_HEADERS); @@ -227,13 +227,13 @@ register_resp(Prop) when is_list(Prop) -> register_resp(JObj) -> register_resp(kz_json:to_proplist(JObj)). --spec register_resp_v(api_terms()) -> boolean(). +-spec register_resp_v(kz_term:api_terms()) -> boolean(). register_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?REGISTER_RESP_HEADERS, ?REGISTER_RESP_VALUES, ?REGISTER_RESP_TYPES); register_resp_v(JObj) -> register_resp_v(kz_json:to_proplist(JObj)). --spec unregister(api_terms()) -> api_formatter_return(). +-spec unregister(kz_term:api_terms()) -> api_formatter_return(). unregister(Prop) when is_list(Prop) -> case unregister_v(Prop) of 'true' -> kz_api:build_message(Prop, ?UNREGISTER_REQ_HEADERS, ?OPTIONAL_UNREGISTER_REQ_HEADERS); @@ -242,13 +242,13 @@ unregister(Prop) when is_list(Prop) -> unregister(JObj) -> unregister(kz_json:to_proplist(JObj)). --spec unregister_v(api_terms()) -> boolean(). +-spec unregister_v(kz_term:api_terms()) -> boolean(). unregister_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?UNREGISTER_REQ_HEADERS, ?UNREGISTER_REQ_VALUES, ?UNREGISTER_REQ_TYPES); unregister_v(JObj) -> unregister_v(kz_json:to_proplist(JObj)). --spec call(api_terms()) -> api_formatter_return(). +-spec call(kz_term:api_terms()) -> api_formatter_return(). call(Prop) when is_list(Prop) -> case call_v(Prop) of 'true' -> kz_api:build_message(Prop, ?CALL_REQ_HEADERS, ?OPTIONAL_CALL_REQ_HEADERS); @@ -257,13 +257,13 @@ call(Prop) when is_list(Prop) -> call(JObj) -> call(kz_json:to_proplist(JObj)). --spec call_v(api_terms()) -> boolean(). +-spec call_v(kz_term:api_terms()) -> boolean(). call_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CALL_REQ_HEADERS, ?CALL_REQ_VALUES, ?CALL_REQ_TYPES); call_v(JObj) -> call_v(kz_json:to_proplist(JObj)). --spec send(api_terms()) -> api_formatter_return(). +-spec send(kz_term:api_terms()) -> api_formatter_return(). send(Prop) when is_list(Prop) -> case send_v(Prop) of 'true' -> kz_api:build_message(Prop, ?SEND_REQ_HEADERS, ?OPTIONAL_SEND_REQ_HEADERS); @@ -272,13 +272,13 @@ send(Prop) when is_list(Prop) -> send(JObj) -> send(kz_json:to_proplist(JObj)). --spec send_v(api_terms()) -> boolean(). +-spec send_v(kz_term:api_terms()) -> boolean(). send_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SEND_REQ_HEADERS, ?SEND_REQ_VALUES, ?SEND_REQ_TYPES); send_v(JObj) -> send_v(kz_json:to_proplist(JObj)). --spec reply_msg(api_terms()) -> api_formatter_return(). +-spec reply_msg(kz_term:api_terms()) -> api_formatter_return(). reply_msg(Prop) when is_list(Prop) -> case reply_msg_v(Prop) of 'true' -> kz_api:build_message(Prop, ?REPLY_REQ_HEADERS, ?OPTIONAL_REPLY_REQ_HEADERS); @@ -287,13 +287,13 @@ reply_msg(Prop) when is_list(Prop) -> reply_msg(JObj) -> reply_msg(kz_json:to_proplist(JObj)). --spec reply_msg_v(api_terms()) -> boolean(). +-spec reply_msg_v(kz_term:api_terms()) -> boolean(). reply_msg_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?REPLY_REQ_HEADERS, ?REPLY_REQ_VALUES, ?REPLY_REQ_TYPES); reply_msg_v(JObj) -> reply_msg_v(kz_json:to_proplist(JObj)). --spec query(api_terms()) -> api_formatter_return(). +-spec query(kz_term:api_terms()) -> api_formatter_return(). query(Prop) when is_list(Prop) -> case query_v(Prop) of 'true' -> kz_api:build_message(Prop, ?QUERY_REQ_HEADERS, ?OPTIONAL_QUERY_REQ_HEADERS); @@ -302,13 +302,13 @@ query(Prop) when is_list(Prop) -> query(JObj) -> query(kz_json:to_proplist(JObj)). --spec query_v(api_terms()) -> boolean(). +-spec query_v(kz_term:api_terms()) -> boolean(). query_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?QUERY_REQ_HEADERS, ?QUERY_REQ_VALUES, ?QUERY_REQ_TYPES); query_v(JObj) -> query_v(kz_json:to_proplist(JObj)). --spec query_resp(api_terms()) -> api_formatter_return(). +-spec query_resp(kz_term:api_terms()) -> api_formatter_return(). query_resp(Prop) when is_list(Prop) -> case query_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?QUERY_RESP_HEADERS, ?OPTIONAL_QUERY_RESP_HEADERS); @@ -317,7 +317,7 @@ query_resp(Prop) when is_list(Prop) -> query_resp(JObj) -> query_resp(kz_json:to_proplist(JObj)). --spec query_resp_v(api_terms()) -> boolean(). +-spec query_resp_v(kz_term:api_terms()) -> boolean(). query_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?QUERY_RESP_HEADERS, ?QUERY_RESP_VALUES, ?QUERY_RESP_TYPES); query_resp_v(JObj) -> @@ -332,16 +332,16 @@ query_resp_v(JObj) -> declare_exchanges() -> amqp_util:new_exchange(?GLOBALS_EXCHANGE, ?GLOBALS_EXCHANGE_TYPE). --spec publish_targeted_call(ne_binary(), api_terms()) -> 'ok'. --spec publish_targeted_call(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_targeted_call(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_targeted_call(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_targeted_call(ServerId, JObj) -> publish_targeted_call(ServerId, JObj, ?DEFAULT_CONTENT_TYPE). publish_targeted_call(ServerId, Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(encode_req(Req), ?CALL_REQ_VALUES, fun call/1), amqp_util:targeted_publish(ServerId, Payload, ContentType). --spec publish_call(api_terms()) -> 'ok'. --spec publish_call(api_terms(), ne_binary()) -> 'ok'. +-spec publish_call(kz_term:api_terms()) -> 'ok'. +-spec publish_call(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_call(JObj) -> publish_call(JObj, ?DEFAULT_CONTENT_TYPE). publish_call(Req, ContentType) -> @@ -350,16 +350,16 @@ publish_call(Req, ContentType) -> RoutingKey = ?GLOBALS_EVENT_ROUTING_KEY(<<"call">>, Name), publish(RoutingKey, Payload, ContentType). --spec publish_targeted_send(ne_binary(), api_terms()) -> 'ok'. --spec publish_targeted_send(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_targeted_send(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_targeted_send(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_targeted_send(ServerId, JObj) -> publish_targeted_send(ServerId, JObj, ?DEFAULT_CONTENT_TYPE). publish_targeted_send(ServerId, Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(encode_req(Req), ?SEND_REQ_VALUES, fun send/1), amqp_util:targeted_publish(ServerId, Payload, ContentType). --spec publish_send(api_terms()) -> 'ok'. --spec publish_send(api_terms(), ne_binary()) -> 'ok'. +-spec publish_send(kz_term:api_terms()) -> 'ok'. +-spec publish_send(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_send(JObj) -> publish_send(JObj, ?DEFAULT_CONTENT_TYPE). publish_send(Req, ContentType) -> @@ -368,16 +368,16 @@ publish_send(Req, ContentType) -> RoutingKey = ?GLOBALS_EVENT_ROUTING_KEY(<<"send">>, Name), publish(RoutingKey, Payload, ContentType). --spec publish_reply(ne_binary(), api_terms()) -> 'ok'. --spec publish_reply(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_reply(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_reply(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_reply(ServerId, JObj) -> publish_reply(ServerId, JObj, ?DEFAULT_CONTENT_TYPE). publish_reply(ServerId, Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(encode_req(Req), ?REPLY_REQ_VALUES, fun reply_msg/1), amqp_util:targeted_publish(ServerId, Payload, ContentType). --spec publish_register(api_terms()) -> 'ok'. --spec publish_register(api_terms(), ne_binary()) -> 'ok'. +-spec publish_register(kz_term:api_terms()) -> 'ok'. +-spec publish_register(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_register(Req) -> publish_register(Req, ?DEFAULT_CONTENT_TYPE). publish_register(Req, ContentType) -> @@ -385,16 +385,16 @@ publish_register(Req, ContentType) -> RoutingKey = ?GLOBALS_EVENT_ROUTING_KEY(<<"register">>, name(Req)), publish(RoutingKey, Payload, ContentType). --spec publish_register_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_register_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_register_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_register_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_register_resp(ServerId, JObj) -> publish_register_resp(ServerId, JObj, ?DEFAULT_CONTENT_TYPE). publish_register_resp(ServerId, Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(encode_req(Req), ?REGISTER_RESP_VALUES, fun register_resp/1), amqp_util:targeted_publish(ServerId, Payload, ContentType). --spec publish_unregister(api_terms()) -> 'ok'. --spec publish_unregister(api_terms(), ne_binary()) -> 'ok'. +-spec publish_unregister(kz_term:api_terms()) -> 'ok'. +-spec publish_unregister(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_unregister(Req) -> publish_unregister(Req, ?DEFAULT_CONTENT_TYPE). publish_unregister(Req, ContentType) -> @@ -402,16 +402,16 @@ publish_unregister(Req, ContentType) -> RoutingKey = ?GLOBALS_EVENT_ROUTING_KEY(<<"unregister">>, name(Req)), publish(RoutingKey, Payload, ContentType). --spec publish_query_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_query_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_query_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_query_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_query_resp(ServerId, JObj) -> publish_query_resp(ServerId, JObj, ?DEFAULT_CONTENT_TYPE). publish_query_resp(ServerId, Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(encode_req(Req), ?QUERY_RESP_VALUES, fun query_resp/1), amqp_util:targeted_publish(ServerId, Payload, ContentType). --spec publish_query(api_terms()) -> 'ok'. --spec publish_query(api_terms(), ne_binary()) -> 'ok'. +-spec publish_query(kz_term:api_terms()) -> 'ok'. +-spec publish_query(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_query(JObj) -> publish_query(JObj, ?DEFAULT_CONTENT_TYPE). publish_query(Req, ContentType) -> @@ -420,7 +420,7 @@ publish_query(Req, ContentType) -> RoutingKey = ?GLOBALS_EVENT_ROUTING_KEY(<<"query">>, Name), publish(RoutingKey, Payload, ContentType). --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, Props) -> Name = props:get_value('name', Props, <<"*">>), Events = props:get_value('restrict_to', Props, [<<"*">>]), @@ -431,7 +431,7 @@ bind_q(Q, [Event|T], Name) -> bind_q(Q, T, Name); bind_q(_Q, [], _Name) -> 'ok'. --spec unbind_q(ne_binary(), any()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), any()) -> 'ok'. unbind_q(Queue, Props) -> Name = props:get_value('name', Props, <<"*">>), Events = props:get_value('restrict_to', Props, [<<"*">>]), diff --git a/core/kazoo_amqp/src/api/kapi_hangups.erl b/core/kazoo_amqp/src/api/kapi_hangups.erl index 64954e42af2..c930dbb76a9 100644 --- a/core/kazoo_amqp/src/api/kapi_hangups.erl +++ b/core/kazoo_amqp/src/api/kapi_hangups.erl @@ -48,7 +48,7 @@ %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec query_req(api_terms()) -> +-spec query_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. query_req(Prop) when is_list(Prop) -> @@ -58,7 +58,7 @@ query_req(Prop) when is_list(Prop) -> end; query_req(JObj) -> query_req(kz_json:to_proplist(JObj)). --spec query_req_v(api_terms()) -> boolean(). +-spec query_req_v(kz_term:api_terms()) -> boolean(). query_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?QUERY_REQ_HEADERS, ?QUERY_REQ_VALUES, ?QUERY_REQ_TYPES); query_req_v(JObj) -> query_req_v(kz_json:to_proplist(JObj)). @@ -68,7 +68,7 @@ query_req_v(JObj) -> query_req_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec query_resp(api_terms()) -> +-spec query_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. query_resp(Prop) when is_list(Prop) -> @@ -78,16 +78,16 @@ query_resp(Prop) when is_list(Prop) -> end; query_resp(JObj) -> query_resp(kz_json:to_proplist(JObj)). --spec query_resp_v(api_terms()) -> boolean(). +-spec query_resp_v(kz_term:api_terms()) -> boolean(). query_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?QUERY_RESP_HEADERS, ?QUERY_RESP_VALUES, ?QUERY_RESP_TYPES); query_resp_v(JObj) -> query_resp_v(kz_json:to_proplist(JObj)). --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, _Props) -> 'ok' = amqp_util:bind_q_to_kapps(Queue, ?QUERY_REQ_ROUTING_KEY). --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Queue, _Props) -> 'ok' = amqp_util:unbind_q_from_kapps(Queue, ?QUERY_REQ_ROUTING_KEY). @@ -95,16 +95,16 @@ unbind_q(Queue, _Props) -> declare_exchanges() -> amqp_util:kapps_exchange(). --spec publish_query_req(api_terms()) -> 'ok'. --spec publish_query_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_query_req(kz_term:api_terms()) -> 'ok'. +-spec publish_query_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_query_req(JObj) -> publish_query_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_query_req(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?QUERY_REQ_VALUES, fun query_req/1), amqp_util:kapps_publish(?QUERY_REQ_ROUTING_KEY, Payload, ContentType). --spec publish_query_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_query_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_query_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_query_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_query_resp(RespQ, JObj) -> publish_query_resp(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_query_resp(RespQ, API, ContentType) -> diff --git a/core/kazoo_amqp/src/api/kapi_inspector.erl b/core/kazoo_amqp/src/api/kapi_inspector.erl index 25a29be8a1f..8ad3df360d8 100644 --- a/core/kazoo_amqp/src/api/kapi_inspector.erl +++ b/core/kazoo_amqp/src/api/kapi_inspector.erl @@ -51,7 +51,7 @@ -define(CI_AMQP_KEY(SubKey), <<"call_inspector.", SubKey/binary>>). --spec lookup_req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec lookup_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. lookup_req(Prop) when is_list(Prop) -> case lookup_req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?LOOKUP_REQ_HEADERS, ?OPTIONAL_LOOKUP_REQ_HEADERS); @@ -60,13 +60,13 @@ lookup_req(Prop) when is_list(Prop) -> lookup_req(JObj) -> lookup_req(kz_json:to_proplist(JObj)). --spec lookup_req_v(api_terms()) -> boolean(). +-spec lookup_req_v(kz_term:api_terms()) -> boolean(). lookup_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?LOOKUP_REQ_HEADERS, ?LOOKUP_REQ_VALUES, ?LOOKUP_REQ_TYPES); lookup_req_v(JObj) -> lookup_req_v(kz_json:to_proplist(JObj)). --spec lookup_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec lookup_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. lookup_resp(Prop) when is_list(Prop) -> case lookup_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?LOOKUP_RESP_HEADERS, ?OPTIONAL_LOOKUP_RESP_HEADERS); @@ -75,13 +75,13 @@ lookup_resp(Prop) when is_list(Prop) -> lookup_resp(JObj) -> lookup_resp(kz_json:to_proplist(JObj)). --spec lookup_resp_v(api_terms()) -> boolean(). +-spec lookup_resp_v(kz_term:api_terms()) -> boolean(). lookup_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?LOOKUP_RESP_HEADERS, ?LOOKUP_RESP_VALUES, ?LOOKUP_RESP_TYPES); lookup_resp_v(JObj) -> lookup_resp_v(kz_json:to_proplist(JObj)). --spec filter_req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec filter_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. filter_req(Prop) when is_list(Prop) -> case filter_req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?FILTER_REQ_HEADERS, ?OPTIONAL_FILTER_REQ_HEADERS); @@ -90,13 +90,13 @@ filter_req(Prop) when is_list(Prop) -> filter_req(JObj) -> filter_req(kz_json:to_proplist(JObj)). --spec filter_req_v(api_terms()) -> boolean(). +-spec filter_req_v(kz_term:api_terms()) -> boolean(). filter_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?FILTER_REQ_HEADERS, ?FILTER_REQ_VALUES, ?FILTER_REQ_TYPES); filter_req_v(JObj) -> filter_req_v(kz_json:to_proplist(JObj)). --spec filter_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec filter_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. filter_resp(Prop) when is_list(Prop) -> case filter_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?FILTER_RESP_HEADERS, ?OPTIONAL_FILTER_RESP_HEADERS); @@ -105,17 +105,17 @@ filter_resp(Prop) when is_list(Prop) -> filter_resp(JObj) -> filter_resp(kz_json:to_proplist(JObj)). --spec filter_resp_v(api_terms()) -> boolean(). +-spec filter_resp_v(kz_term:api_terms()) -> boolean(). filter_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?FILTER_RESP_HEADERS, ?FILTER_RESP_VALUES, ?FILTER_RESP_TYPES); filter_resp_v(JObj) -> filter_resp_v(kz_json:to_proplist(JObj)). --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Q, _Props) -> amqp_util:bind_q_to_monitor(Q, ?CI_AMQP_KEY(<<"*">>)). --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Q, _Props) -> amqp_util:unbind_q_from_monitor(Q, ?CI_AMQP_KEY(<<"*">>)). @@ -123,32 +123,32 @@ unbind_q(Q, _Props) -> declare_exchanges() -> amqp_util:monitor_exchange(). --spec publish_lookup_req(api_terms()) -> 'ok'. --spec publish_lookup_req(api_terms(), binary()) -> 'ok'. +-spec publish_lookup_req(kz_term:api_terms()) -> 'ok'. +-spec publish_lookup_req(kz_term:api_terms(), binary()) -> 'ok'. publish_lookup_req(JObj) -> publish_lookup_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_lookup_req(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?LOOKUP_REQ_VALUES, fun lookup_req/1), amqp_util:monitor_publish(Payload, ContentType, ?CI_AMQP_KEY(<<"lookup">>)). --spec publish_lookup_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_lookup_resp(ne_binary(), api_terms(), binary()) -> 'ok'. +-spec publish_lookup_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_lookup_resp(kz_term:ne_binary(), kz_term:api_terms(), binary()) -> 'ok'. publish_lookup_resp(RespQ, JObj) -> publish_lookup_resp(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_lookup_resp(RespQ, JObj, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(JObj, ?LOOKUP_RESP_VALUES, fun lookup_resp/1), amqp_util:targeted_publish(RespQ, Payload, ContentType). --spec publish_filter_req(api_terms()) -> 'ok'. --spec publish_filter_req(api_terms(), binary()) -> 'ok'. +-spec publish_filter_req(kz_term:api_terms()) -> 'ok'. +-spec publish_filter_req(kz_term:api_terms(), binary()) -> 'ok'. publish_filter_req(JObj) -> publish_filter_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_filter_req(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?FILTER_REQ_VALUES, fun filter_req/1), amqp_util:monitor_publish(Payload, ContentType, ?CI_AMQP_KEY(<<"filter">>)). --spec publish_filter_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_filter_resp(ne_binary(), api_terms(), binary()) -> 'ok'. +-spec publish_filter_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_filter_resp(kz_term:ne_binary(), kz_term:api_terms(), binary()) -> 'ok'. publish_filter_resp(RespQ, JObj) -> publish_filter_resp(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_filter_resp(RespQ, JObj, ContentType) -> diff --git a/core/kazoo_amqp/src/api/kapi_leader.erl b/core/kazoo_amqp/src/api/kapi_leader.erl index bc19cabb0d4..0b300b9949c 100644 --- a/core/kazoo_amqp/src/api/kapi_leader.erl +++ b/core/kazoo_amqp/src/api/kapi_leader.erl @@ -32,11 +32,11 @@ whoami(Pid) when is_pid(Pid) -> _ -> Pid end. --spec queue() -> ne_binary(). +-spec queue() -> kz_term:ne_binary(). queue() -> queue(self()). --spec queue(pid()) -> ne_binary(). +-spec queue(pid()) -> kz_term:ne_binary(). queue(Pid) when is_pid(Pid) -> case whoami(Pid) of Pid -> exit(<<"not registered">>); @@ -48,26 +48,26 @@ queue(Name) when is_atom(Name) -> queue({Name, Node}) -> queue(Name, Node). --spec queue(atom(), atom()) -> ne_binary(). +-spec queue(atom(), atom()) -> kz_term:ne_binary(). queue(Name, Node) -> iolist_to_binary(io_lib:format("~s-~s", [Node, Name])). --spec route() -> ne_binary(). +-spec route() -> kz_term:ne_binary(). route() -> route(self()). --spec route(pid() | atom()) -> ne_binary(). +-spec route(pid() | atom()) -> kz_term:ne_binary(). route(Pid) when is_pid(Pid) -> {'registered_name', Name} = erlang:process_info(Pid, 'registered_name'), route(Name); route(Name) when is_atom(Name) -> route(Name, node()). --spec route(atom(), atom()) -> ne_binary(). +-spec route(atom(), atom()) -> kz_term:ne_binary(). route(Name, Node) -> iolist_to_binary(io_lib:format("~s.~s", [Name, Node])). --spec req(api_terms()) -> api_formatter_return(). +-spec req(kz_term:api_terms()) -> api_formatter_return(). req(Prop) when is_list(Prop) -> case req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?LEADER_REQ_HEADERS, ?OPTIONAL_LEADER_REQ_HEADERS); @@ -76,7 +76,7 @@ req(Prop) when is_list(Prop) -> req(JObj) -> req(kz_json:to_proplist(JObj)). --spec req_v(api_terms()) -> boolean(). +-spec req_v(kz_term:api_terms()) -> boolean(). req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?LEADER_REQ_HEADERS, ?LEADER_REQ_VALUES, ?LEADER_REQ_TYPES); req_v(JObj) -> @@ -91,15 +91,15 @@ req_v(JObj) -> declare_exchanges() -> amqp_util:leader_exchange(). --spec publish_req(ne_binary(), api_terms()) -> 'ok'. --spec publish_req(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_req(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_req(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_req(Routing, JObj) -> publish_req(Routing, JObj, ?DEFAULT_CONTENT_TYPE). publish_req(Routing, Req, ContentType) -> {ok, Payload} = kz_api:prepare_api_payload(Req, ?LEADER_REQ_VALUES, fun req/1), amqp_util:leader_publish(Routing, Payload, ContentType). --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, [{'name', Name}]) -> Node = node(), ProcessQ = iolist_to_binary(io_lib:format("~s.~s", [Name, Node])), @@ -107,6 +107,6 @@ bind_q(Queue, [{'name', Name}]) -> _ = ['ok' = amqp_util:bind_q_to_leader(Queue, Bind) || Bind <- [ProcessQ, BroadcastQ]], 'ok'. --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Queue, _) -> 'ok' = amqp_util:unbind_q_from_leader(Queue, <<"process">>). diff --git a/core/kazoo_amqp/src/api/kapi_maintenance.erl b/core/kazoo_amqp/src/api/kapi_maintenance.erl index ea43e4d375e..b0cce6669dc 100644 --- a/core/kazoo_amqp/src/api/kapi_maintenance.erl +++ b/core/kazoo_amqp/src/api/kapi_maintenance.erl @@ -30,8 +30,8 @@ -export_type([req/0, resp/0]). --type req() :: api_terms(). --type resp() :: api_terms(). +-type req() :: kz_term:api_terms(). +-type resp() :: kz_term:api_terms(). -include_lib("amqp_util.hrl"). @@ -62,7 +62,7 @@ ,{?KEY_DATABASE, fun is_binary/1} ]). --spec req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. req(Prop) when is_list(Prop) -> case req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?REQ_HEADERS, ?OPTIONAL_REQ_HEADERS); @@ -71,7 +71,7 @@ req(Prop) when is_list(Prop) -> req(JObj) -> req(kz_json:to_proplist(JObj)). --spec req_v(api_terms()) -> boolean(). +-spec req_v(kz_term:api_terms()) -> boolean(). req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?REQ_HEADERS, ?REQ_VALUES, ?REQ_TYPES); req_v(JObj) -> @@ -86,7 +86,7 @@ req_v(JObj) -> ,{<<"Code">>, fun is_integer/1} ]). --spec resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. resp(Prop) when is_list(Prop) -> case resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?RESP_HEADERS, ?OPTIONAL_RESP_HEADERS); @@ -95,7 +95,7 @@ resp(Prop) when is_list(Prop) -> resp(JObj) -> resp(kz_json:to_proplist(JObj)). --spec resp_v(api_terms()) -> boolean(). +-spec resp_v(kz_term:api_terms()) -> boolean(). resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?RESP_HEADERS, ?RESP_VALUES, ?RESP_TYPES); resp_v(JObj) -> @@ -107,16 +107,16 @@ resp_v(JObj) -> -define(REFRESH_VIEWS_TYPE(Type), {'refresh_views', 'type', Type}). -define(CLEAN_SERVICES_ID(AccountId), {'clean_services', AccountId}). --type db_type() :: kz_datamgr:db_classification() | ne_binary(). --type binding() :: ?REFRESH_DB_DB(ne_binary()) | +-type db_type() :: kz_datamgr:db_classification() | kz_term:ne_binary(). +-type binding() :: ?REFRESH_DB_DB(kz_term:ne_binary()) | ?REFRESH_DB_TYPE(db_type()) | - ?REFRESH_VIEWS_DB(ne_binary()) | + ?REFRESH_VIEWS_DB(kz_term:ne_binary()) | ?REFRESH_VIEWS_TYPE(db_type()) | - ?CLEAN_SERVICES_ID(ne_binary()). + ?CLEAN_SERVICES_ID(kz_term:ne_binary()). -type bind_prop() :: {'restrict_to', [binding()]}. -type binds() :: [bind_prop()]. --spec restrict_to_db(ne_binary()) -> ?REFRESH_DB_DB(ne_binary()). +-spec restrict_to_db(kz_term:ne_binary()) -> ?REFRESH_DB_DB(kz_term:ne_binary()). restrict_to_db(<<_/binary>>=Db) -> ?REFRESH_DB_DB(Db). @@ -124,7 +124,7 @@ restrict_to_db(<<_/binary>>=Db) -> restrict_to_classification(Classification) -> ?REFRESH_DB_TYPE(Classification). --spec restrict_to_views_db(ne_binary()) -> ?REFRESH_VIEWS_DB(ne_binary()). +-spec restrict_to_views_db(kz_term:ne_binary()) -> ?REFRESH_VIEWS_DB(kz_term:ne_binary()). restrict_to_views_db(Db) -> ?REFRESH_VIEWS_DB(Db). @@ -132,22 +132,22 @@ restrict_to_views_db(Db) -> restrict_to_views_classification(Classification) -> ?REFRESH_VIEWS_TYPE(Classification). --spec restrict_to_clean_services(ne_binary()) -> ?CLEAN_SERVICES_ID(ne_binary()). +-spec restrict_to_clean_services(kz_term:ne_binary()) -> ?CLEAN_SERVICES_ID(kz_term:ne_binary()). restrict_to_clean_services(AccountId) -> ?CLEAN_SERVICES_ID(AccountId). --spec refresh_routing_db(ne_binary(), ne_binary()) -> ne_binary(). +-spec refresh_routing_db(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). refresh_routing_db(RefreshWhat, <<_/binary>>=Db) -> refresh_routing(RefreshWhat, kz_datamgr:db_classification(Db), Db). --spec refresh_routing_classification(ne_binary(), db_type()) -> ne_binary(). +-spec refresh_routing_classification(kz_term:ne_binary(), db_type()) -> kz_term:ne_binary(). refresh_routing_classification(RefreshWhat, Classification) -> refresh_routing(RefreshWhat, Classification, <<"*">>). refresh_routing_clean_services(AccountId) -> refresh_routing(?CLEAN_SERVICES, 'account', AccountId). --spec refresh_routing(ne_binary(), db_type(), ne_binary()) -> ne_binary(). +-spec refresh_routing(kz_term:ne_binary(), db_type(), kz_term:ne_binary()) -> kz_term:ne_binary(). refresh_routing(RefreshWhat, Classification, Database) -> kz_binary:join([?EVENT_CAT ,RefreshWhat @@ -157,8 +157,8 @@ refresh_routing(RefreshWhat, Classification, Database) -> ,$. ). --spec bind_q(ne_binary(), binds()) -> 'ok'. --spec bind_to_q(ne_binary(), 'undefined' | [binding()], kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), binds()) -> 'ok'. +-spec bind_to_q(kz_term:ne_binary(), 'undefined' | [binding()], kz_term:proplist()) -> 'ok'. bind_q(Queue, Props) -> bind_to_q(Queue, props:get_value('restrict_to', Props), Props). @@ -181,8 +181,8 @@ bind_to_q(Queue, [?CLEAN_SERVICES_ID(AccountId)|Rest], Props) -> bind_to_q(Queue, Rest, Props); bind_to_q(_Queue, [], _Props) -> 'ok'. --spec unbind_q(ne_binary(), binds()) -> 'ok'. --spec unbind_from_q(ne_binary(), 'undefined' | [binding()], kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), binds()) -> 'ok'. +-spec unbind_from_q(kz_term:ne_binary(), 'undefined' | [binding()], kz_term:proplist()) -> 'ok'. unbind_q(Queue, Props) -> unbind_from_q(Queue, props:get_value('restrict_to', Props), Props). @@ -209,16 +209,16 @@ unbind_from_q(_Queue, [], _Props) -> 'ok'. declare_exchanges() -> amqp_util:sysconf_exchange(). --spec publish_req(api_terms()) -> 'ok'. --spec publish_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_req(kz_term:api_terms()) -> 'ok'. +-spec publish_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_req(JObj) -> publish_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_req(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?REQ_VALUES, fun req/1), amqp_util:sysconf_publish(routing_key(Req), Payload, ContentType). --spec publish_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_resp(TargetQ, JObj) -> publish_resp(TargetQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_resp(TargetQ, Resp, ContentType) -> @@ -245,11 +245,11 @@ routing_key(Req, Get, ?REFRESH_VIEWS) -> ). --spec refresh_database(ne_binary()) -> +-spec refresh_database(kz_term:ne_binary()) -> kz_amqp_worker:request_return(). --spec refresh_database(ne_binary(), pid() | kz_datamgr:db_classification()) -> +-spec refresh_database(kz_term:ne_binary(), pid() | kz_datamgr:db_classification()) -> kz_amqp_worker:request_return(). --spec refresh_database(ne_binary(), pid(), kz_datamgr:db_classification()) -> +-spec refresh_database(kz_term:ne_binary(), pid(), kz_datamgr:db_classification()) -> kz_amqp_worker:request_return(). refresh_database(Database) -> {'ok', Worker} = kz_amqp_worker:checkout_worker(), @@ -282,15 +282,15 @@ refresh_database(Database, Worker, Classification) -> kz_util:put_callid(OldCallId), Resp. --spec msg_id(ne_binary()) -> ne_binary(). +-spec msg_id(kz_term:ne_binary()) -> kz_term:ne_binary(). msg_id(Database) -> kz_binary:join([<<"refresh">>, Database, kz_binary:rand_hex(8)], $-). --spec refresh_views(ne_binary()) -> +-spec refresh_views(kz_term:ne_binary()) -> kz_amqp_worker:request_return(). --spec refresh_views(ne_binary(), pid() | kz_datamgr:db_classification()) -> +-spec refresh_views(kz_term:ne_binary(), pid() | kz_datamgr:db_classification()) -> kz_amqp_worker:request_return(). --spec refresh_views(ne_binary(), pid(), kz_datamgr:db_classification()) -> +-spec refresh_views(kz_term:ne_binary(), pid(), kz_datamgr:db_classification()) -> kz_amqp_worker:request_return(). refresh_views(Database) -> {'ok', Worker} = kz_amqp_worker:checkout_worker(), @@ -326,8 +326,8 @@ refresh_views(Database, Worker, Classification) -> kz_util:put_callid(OldCallId), Resp. --spec clean_services(ne_binary()) -> kz_amqp_worker:request_return(). --spec clean_services(ne_binary(), pid()) -> kz_amqp_worker:request_return(). +-spec clean_services(kz_term:ne_binary()) -> kz_amqp_worker:request_return(). +-spec clean_services(kz_term:ne_binary(), pid()) -> kz_amqp_worker:request_return(). clean_services(AccountId) -> {'ok', Worker} = kz_amqp_worker:checkout_worker(), kz_amqp_worker:relay_to(Worker, self()), @@ -352,9 +352,9 @@ clean_services(AccountId, Worker) -> kz_util:put_callid(OldCallId), Resp. --spec wait_for_response(ne_binary(), kz_timeout()) -> +-spec wait_for_response(kz_term:ne_binary(), timeout()) -> kz_amqp_worker:request_return(). --spec wait_for_response(ne_binary(), kz_timeout(), kz_json:objects()) -> +-spec wait_for_response(kz_term:ne_binary(), timeout(), kz_json:objects()) -> kz_amqp_worker:request_return(). wait_for_response(MsgId, Timeout) -> wait_for_response(MsgId, Timeout, []). @@ -381,7 +381,7 @@ wait_for_response(MsgId, Timeout, Resps) -> Timeout -> wait_for_response(MsgId, 0, Resps) end. --spec clear_mailbox(ne_binary(), kz_json:objects()) -> +-spec clear_mailbox(kz_term:ne_binary(), kz_json:objects()) -> {'ok', kz_json:objects()}. clear_mailbox(MsgId, Resps) -> receive @@ -397,14 +397,14 @@ clear_mailbox(MsgId, Resps) -> end. --spec req_action(req()) -> api_ne_binary(). +-spec req_action(req()) -> kz_term:api_ne_binary(). req_action(Req) -> kz_json:get_ne_binary_value(?KEY_ACTION, Req). --spec req_database(req()) -> api_ne_binary(). +-spec req_database(req()) -> kz_term:api_ne_binary(). req_database(Req) -> kz_json:get_ne_binary_value(?KEY_DATABASE, Req). --spec req_classification(req()) -> api_ne_binary(). +-spec req_classification(req()) -> kz_term:api_ne_binary(). req_classification(Req) -> kz_json:get_ne_binary_value(?KEY_CLASSIFICATION, Req). diff --git a/core/kazoo_amqp/src/api/kapi_media.erl b/core/kazoo_amqp/src/api/kapi_media.erl index 9d21e023c10..98fd2e1c234 100644 --- a/core/kazoo_amqp/src/api/kapi_media.erl +++ b/core/kazoo_amqp/src/api/kapi_media.erl @@ -67,7 +67,7 @@ %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec req(api_terms()) -> +-spec req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. req(Prop) when is_list(Prop) -> @@ -77,7 +77,7 @@ req(Prop) when is_list(Prop) -> end; req(JObj) -> req(kz_json:to_proplist(JObj)). --spec req_v(api_terms()) -> boolean(). +-spec req_v(kz_term:api_terms()) -> boolean(). req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?MEDIA_REQ_HEADERS, ?MEDIA_REQ_VALUES, ?MEDIA_REQ_TYPES); req_v(JObj) -> req_v(kz_json:to_proplist(JObj)). @@ -87,7 +87,7 @@ req_v(JObj) -> req_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec resp(kz_json:object() | kz_proplist()) -> +-spec resp(kz_json:object() | kz_term:proplist()) -> {'ok', iolist()} | {'error', string()}. resp(Prop) when is_list(Prop) -> @@ -97,7 +97,7 @@ resp(Prop) when is_list(Prop) -> end; resp(JObj) -> resp(kz_json:to_proplist(JObj)). --spec resp_v(kz_proplist() | kz_json:object()) -> boolean(). +-spec resp_v(kz_term:proplist() | kz_json:object()) -> boolean(). resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?MEDIA_RESP_HEADERS, ?MEDIA_RESP_VALUES, ?MEDIA_RESP_TYPES); resp_v(JObj) -> resp_v(kz_json:to_proplist(JObj)). @@ -107,7 +107,7 @@ resp_v(JObj) -> resp_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec error(kz_proplist() | kz_json:object()) -> +-spec error(kz_term:proplist() | kz_json:object()) -> {'ok', iolist()} | {'error', string()}. error(Prop) when is_list(Prop) -> @@ -117,16 +117,16 @@ error(Prop) when is_list(Prop) -> end; error(JObj) -> error(kz_json:to_proplist(JObj)). --spec error_v(kz_proplist() | kz_json:object()) -> boolean(). +-spec error_v(kz_term:proplist() | kz_json:object()) -> boolean(). error_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?MEDIA_ERROR_HEADERS, ?MEDIA_ERROR_VALUES, ?MEDIA_ERROR_TYPES); error_v(JObj) -> error_v(kz_json:to_proplist(JObj)). --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, _Props) -> amqp_util:bind_q_to_kapps(Queue, ?MEDIA_REQ_ROUTING_KEY). --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Queue, _Props) -> amqp_util:unbind_q_from_kapps(Queue, ?MEDIA_REQ_ROUTING_KEY). @@ -139,24 +139,24 @@ unbind_q(Queue, _Props) -> declare_exchanges() -> amqp_util:kapps_exchange(). --spec publish_req(api_terms()) -> 'ok'. --spec publish_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_req(kz_term:api_terms()) -> 'ok'. +-spec publish_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_req(JObj) -> publish_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_req(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?MEDIA_REQ_VALUES, fun req/1), amqp_util:kapps_publish(?MEDIA_REQ_ROUTING_KEY, Payload, ContentType). --spec publish_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_resp(Queue, JObj) -> publish_resp(Queue, JObj, ?DEFAULT_CONTENT_TYPE). publish_resp(Queue, Resp, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Resp, ?MEDIA_RESP_VALUES, fun resp/1), amqp_util:targeted_publish(Queue, Payload, ContentType). --spec publish_error(ne_binary(), api_terms()) -> 'ok'. --spec publish_error(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_error(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_error(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_error(Queue, JObj) -> publish_error(Queue, JObj, ?DEFAULT_CONTENT_TYPE). publish_error(Queue, Error, ContentType) -> diff --git a/core/kazoo_amqp/src/api/kapi_metaflow.erl b/core/kazoo_amqp/src/api/kapi_metaflow.erl index 139bbe0adfe..6ed63d212db 100644 --- a/core/kazoo_amqp/src/api/kapi_metaflow.erl +++ b/core/kazoo_amqp/src/api/kapi_metaflow.erl @@ -108,7 +108,7 @@ %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec action(kz_json:object() | kz_proplist()) -> +-spec action(kz_json:object() | kz_term:proplist()) -> {'ok', iolist()} | {'error', string()}. action(Prop) when is_list(Prop) -> @@ -118,7 +118,7 @@ action(Prop) when is_list(Prop) -> end; action(JObj) -> action(kz_json:to_proplist(JObj)). --spec action_v(kz_json:object() | kz_proplist()) -> boolean(). +-spec action_v(kz_json:object() | kz_term:proplist()) -> boolean(). action_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?METAFLOW_ACTION_HEADERS, ?METAFLOW_ACTION_VALUES, ?METAFLOW_ACTION_TYPES); action_v(JObj) -> action_v(kz_json:to_proplist(JObj)). @@ -129,7 +129,7 @@ action_v(JObj) -> action_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec flow(kz_json:object() | kz_proplist()) -> +-spec flow(kz_json:object() | kz_term:proplist()) -> {'ok', iolist()} | {'error', string()}. flow(Prop) when is_list(Prop) -> @@ -139,7 +139,7 @@ flow(Prop) when is_list(Prop) -> end; flow(JObj) -> flow(kz_json:to_proplist(JObj)). --spec flow_v(kz_json:object() | kz_proplist()) -> boolean(). +-spec flow_v(kz_json:object() | kz_term:proplist()) -> boolean(). flow_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?METAFLOW_FLOW_HEADERS, ?METAFLOW_FLOW_VALUES, ?METAFLOW_FLOW_TYPES); flow_v(JObj) -> flow_v(kz_json:to_proplist(JObj)). @@ -149,7 +149,7 @@ flow_v(JObj) -> flow_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec bind_req(kz_json:object() | kz_proplist()) -> +-spec bind_req(kz_json:object() | kz_term:proplist()) -> {'ok', iolist()} | {'error', string()}. bind_req(Prop) when is_list(Prop) -> @@ -159,17 +159,17 @@ bind_req(Prop) when is_list(Prop) -> end; bind_req(JObj) -> bind_req(kz_json:to_proplist(JObj)). --spec bind_req_v(kz_json:object() | kz_proplist()) -> boolean(). +-spec bind_req_v(kz_json:object() | kz_term:proplist()) -> boolean(). bind_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?METAFLOW_BIND_REQ_HEADERS, ?METAFLOW_BIND_REQ_VALUES, ?METAFLOW_BIND_REQ_TYPES); bind_req_v(JObj) -> bind_req_v(kz_json:to_proplist(JObj)). --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, Props) -> ALL = ['bind_req', 'action', 'bindings'], bind_q(Queue, Props, props:get_value('restrict_to', Props, ALL)). --spec bind_q(ne_binary(), kz_proplist(), list()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist(), list()) -> 'ok'. bind_q(Queue, Props, ['bind_req' | T]) -> AccountId = props:get_value('account_id', Props, <<"*">>), Leg = props:get_value('leg', Props, <<"*">>), @@ -194,12 +194,12 @@ bind_q(Queue, Props, [_U | T]) -> bind_q(Queue, Props, T); bind_q(_, _, []) -> 'ok'. --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Queue, Props) -> ALL = ['bind_req', 'action', 'bindings'], unbind_q(Queue, Props, props:get_value('restrict_to', Props, ALL)). --spec unbind_q(ne_binary(), list(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), list(), kz_term:proplist()) -> 'ok'. unbind_q(Queue, Props, ['bind_req' | T]) -> AccountId = props:get_value('account_id', Props, <<"*">>), Leg = props:get_value('leg', Props, <<"*">>), @@ -233,8 +233,8 @@ unbind_q(_, _, []) -> 'ok'. declare_exchanges() -> amqp_util:new_exchange(?METAFLOW_EXCHANGE, ?METAFLOW_EXCHANGE_TYPE). --spec publish_flow(api_terms()) -> 'ok'. --spec publish_flow(api_terms(), ne_binary()) -> 'ok'. +-spec publish_flow(kz_term:api_terms()) -> 'ok'. +-spec publish_flow(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_flow(JObj) -> publish_flow(JObj, ?DEFAULT_CONTENT_TYPE). publish_flow(Req, ContentType) -> @@ -242,8 +242,8 @@ publish_flow(Req, ContentType) -> RK = ?METAFLOW_FLOW_ROUTING_KEY(rk_call_id(Req)), amqp_util:basic_publish(?METAFLOW_EXCHANGE, RK, Payload, ContentType). --spec publish_action(api_terms()) -> 'ok'. --spec publish_action(api_terms(), ne_binary()) -> 'ok'. +-spec publish_action(kz_term:api_terms()) -> 'ok'. +-spec publish_action(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_action(JObj) -> publish_action(JObj, ?DEFAULT_CONTENT_TYPE). publish_action(Req, ContentType) -> @@ -251,8 +251,8 @@ publish_action(Req, ContentType) -> RK = ?METAFLOW_ACTION_ROUTING_KEY(rk_call_id(Req), rk_action(Req)), amqp_util:basic_publish(?METAFLOW_EXCHANGE, RK, Payload, ContentType). --spec publish_bind_req(api_terms()) -> 'ok'. --spec publish_bind_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_bind_req(kz_term:api_terms()) -> 'ok'. +-spec publish_bind_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_bind_req(JObj) -> publish_bind_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_bind_req(Req, ContentType) -> @@ -280,8 +280,8 @@ rk_binding_leg([_|_]=API) -> rk_binding_leg(JObj) -> kz_json:get_value(<<"Binding-Leg">>, JObj). --spec publish_binding(api_terms()) -> 'ok'. --spec publish_binding(api_terms(), ne_binary()) -> 'ok'. +-spec publish_binding(kz_term:api_terms()) -> 'ok'. +-spec publish_binding(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_binding(API) -> publish_binding(API, ?DEFAULT_CONTENT_TYPE). publish_binding(API0, ContentType) -> @@ -292,15 +292,15 @@ publish_binding(API0, ContentType) -> RK = ?METAFLOW_BIND_ROUTING_KEY(AccountId, CallId), amqp_util:basic_publish(?METAFLOW_EXCHANGE, RK, Payload, ContentType). --spec publish_bind_reply(ne_binary(), api_terms()) -> 'ok'. --spec publish_bind_reply(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_bind_reply(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_bind_reply(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_bind_reply(Q, API) -> publish_bind_reply(Q, API, ?DEFAULT_CONTENT_TYPE). publish_bind_reply(Q, API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?METAFLOW_BIND_VALUES, fun binding/1), amqp_util:targeted_publish(Q, Payload, ContentType). --spec callid(api_terms()) -> api_binary(). +-spec callid(kz_term:api_terms()) -> kz_term:api_binary(). callid([_|_]=Props) -> case props:get_value(<<"Call-ID">>, Props) of 'undefined' -> callid(props:get_value(<<"Call">>, Props)); @@ -311,7 +311,7 @@ callid(JObj) -> ,[<<"Call">>, <<"Call-ID">>] ], JObj). --spec ensure_callid(api_terms()) -> api_terms(). +-spec ensure_callid(kz_term:api_terms()) -> kz_term:api_terms(). ensure_callid([_|_]=Props) -> props:insert_value(<<"Call-ID">>, callid(Props), Props); ensure_callid(JObj) -> @@ -322,7 +322,7 @@ ensure_callid(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec binding(api_terms()) -> api_formatter_return(). +-spec binding(kz_term:api_terms()) -> api_formatter_return(). binding(Prop) when is_list(Prop) -> case binding_v(Prop) of 'true' -> kz_api:build_message(Prop, ?METAFLOW_BIND_HEADERS, ?OPTIONAL_METAFLOW_BIND_HEADERS); @@ -330,7 +330,7 @@ binding(Prop) when is_list(Prop) -> end; binding(JObj) -> binding(kz_json:to_proplist(JObj)). --spec binding_v(api_terms()) -> boolean(). +-spec binding_v(kz_term:api_terms()) -> boolean(). binding_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?METAFLOW_BIND_HEADERS, ?METAFLOW_BIND_VALUES, ?METAFLOW_BIND_TYPES); binding_v(JObj) -> binding_v(kz_json:to_proplist(JObj)). diff --git a/core/kazoo_amqp/src/api/kapi_money.erl b/core/kazoo_amqp/src/api/kapi_money.erl index 946205b8db2..9cba8abd11d 100644 --- a/core/kazoo_amqp/src/api/kapi_money.erl +++ b/core/kazoo_amqp/src/api/kapi_money.erl @@ -60,10 +60,10 @@ %%-------------------------------------------------------------------- %% @doc Credit Update - see wiki -%% Takes kz_proplist(), creates JSON iolist or error +%% Takes kz_term:proplist(), creates JSON iolist or error %% @end %%-------------------------------------------------------------------- --spec credit(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec credit(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. credit(Prop) when is_list(Prop) -> case credit_v(Prop) of true -> kz_api:build_message(Prop, ?CREDIT_HEADERS, ?OPTIONAL_CREDIT_HEADERS); @@ -72,7 +72,7 @@ credit(Prop) when is_list(Prop) -> credit(JObj) -> credit(kz_json:to_proplist(JObj)). --spec credit_v(api_terms()) -> boolean(). +-spec credit_v(kz_term:api_terms()) -> boolean(). credit_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?CREDIT_HEADERS, ?CREDIT_VALUES, ?CREDIT_TYPES); credit_v(JObj) -> @@ -80,10 +80,10 @@ credit_v(JObj) -> %%-------------------------------------------------------------------- %% @doc Debit Update - see wiki -%% Takes kz_proplist(), creates JSON iolist or error +%% Takes kz_term:proplist(), creates JSON iolist or error %% @end %%-------------------------------------------------------------------- --spec debit(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec debit(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. debit(Prop) when is_list(Prop) -> case debit_v(Prop) of true -> kz_api:build_message(Prop, ?DEBIT_HEADERS, ?OPTIONAL_DEBIT_HEADERS); @@ -92,7 +92,7 @@ debit(Prop) when is_list(Prop) -> debit(JObj) -> debit(kz_json:to_proplist(JObj)). --spec debit_v(api_terms()) -> boolean(). +-spec debit_v(kz_term:api_terms()) -> boolean(). debit_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?DEBIT_HEADERS, ?DEBIT_VALUES, ?DEBIT_TYPES); debit_v(JObj) -> @@ -100,10 +100,10 @@ debit_v(JObj) -> %%-------------------------------------------------------------------- %% @doc Balance Request - see wiki -%% Takes kz_proplist(), creates JSON iolist or error +%% Takes kz_term:proplist(), creates JSON iolist or error %% @end %%-------------------------------------------------------------------- --spec balance_req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec balance_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. balance_req(Prop) when is_list(Prop) -> case balance_req_v(Prop) of true -> kz_api:build_message(Prop, ?BALANCE_REQ_HEADERS, ?OPTIONAL_BALANCE_REQ_HEADERS); @@ -112,7 +112,7 @@ balance_req(Prop) when is_list(Prop) -> balance_req(JObj) -> balance_req(kz_json:to_proplist(JObj)). --spec balance_req_v(api_terms()) -> boolean(). +-spec balance_req_v(kz_term:api_terms()) -> boolean(). balance_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?BALANCE_REQ_HEADERS, ?BALANCE_REQ_VALUES, ?BALANCE_REQ_TYPES); balance_req_v(JObj) -> @@ -120,10 +120,10 @@ balance_req_v(JObj) -> %%-------------------------------------------------------------------- %% @doc Balance Response - see wiki -%% Takes kz_proplist(), creates JSON iolist or error +%% Takes kz_term:proplist(), creates JSON iolist or error %% @end %%-------------------------------------------------------------------- --spec balance_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec balance_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. balance_resp(Prop) when is_list(Prop) -> case balance_resp_v(Prop) of true -> kz_api:build_message(Prop, ?BALANCE_RESP_HEADERS, ?OPTIONAL_BALANCE_RESP_HEADERS); @@ -132,18 +132,18 @@ balance_resp(Prop) when is_list(Prop) -> balance_resp(JObj) -> balance_resp(kz_json:to_proplist(JObj)). --spec balance_resp_v(api_terms()) -> boolean(). +-spec balance_resp_v(kz_term:api_terms()) -> boolean(). balance_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?BALANCE_RESP_HEADERS, ?BALANCE_RESP_VALUES, ?BALANCE_RESP_TYPES); balance_resp_v(JObj) -> balance_resp_v(kz_json:to_proplist(JObj)). --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, Props) -> Routing = routing_key(Props), amqp_util:bind_q_to_configuration(Queue, Routing). --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Queue, Props) -> Routing = routing_key(Props), amqp_util:unbind_q_from_configuration(Queue, Routing). @@ -164,8 +164,8 @@ routing_key(Props) -> ,props:get_value('account_id', Props, <<"*">>) ]). --spec publish_credit(api_terms()) -> 'ok'. --spec publish_credit(api_terms(), ne_binary()) -> 'ok'. +-spec publish_credit(kz_term:api_terms()) -> 'ok'. +-spec publish_credit(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_credit(Req) -> publish_credit(Req, ?DEFAULT_CONTENT_TYPE). publish_credit(Req, ContentType) -> @@ -173,8 +173,8 @@ publish_credit(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?CREDIT_VALUES, fun credit/1), amqp_util:configuration_publish(RoutingKey, Payload, ContentType). --spec publish_debit(api_terms()) -> 'ok'. --spec publish_debit(api_terms(), ne_binary()) -> 'ok'. +-spec publish_debit(kz_term:api_terms()) -> 'ok'. +-spec publish_debit(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_debit(Req) -> publish_debit(Req, ?DEFAULT_CONTENT_TYPE). publish_debit(Req, ContentType) -> @@ -182,8 +182,8 @@ publish_debit(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?DEBIT_VALUES, fun debit/1), amqp_util:configuration_publish(RoutingKey, Payload, ContentType). --spec publish_balance_req(api_terms()) -> 'ok'. --spec publish_balance_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_balance_req(kz_term:api_terms()) -> 'ok'. +-spec publish_balance_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_balance_req(Req) -> publish_balance_req(Req, ?DEFAULT_CONTENT_TYPE). publish_balance_req(Req, ContentType) -> @@ -191,8 +191,8 @@ publish_balance_req(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?BALANCE_REQ_VALUES, fun balance_req/1), amqp_util:configuration_publish(RoutingKey, Payload, ContentType). --spec publish_balance_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_balance_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_balance_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_balance_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_balance_resp(Queue, Req) -> publish_balance_resp(Queue, Req, ?DEFAULT_CONTENT_TYPE). publish_balance_resp(Queue, Req, ContentType) -> diff --git a/core/kazoo_amqp/src/api/kapi_nodes.erl b/core/kazoo_amqp/src/api/kapi_nodes.erl index 16f0131dd0e..7fda7778984 100644 --- a/core/kazoo_amqp/src/api/kapi_nodes.erl +++ b/core/kazoo_amqp/src/api/kapi_nodes.erl @@ -42,8 +42,8 @@ %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec advertise(api_terms()) -> {'ok', iolist()} | - {'error', string()}. +-spec advertise(kz_term:api_terms()) -> {'ok', iolist()} | + {'error', string()}. advertise(Prop) when is_list(Prop) -> case advertise_v(Prop) of 'true' -> kz_api:build_message(Prop, ?ADVERTISE_HEADERS, ?OPTIONAL_ADVERTISE_HEADERS); @@ -52,7 +52,7 @@ advertise(Prop) when is_list(Prop) -> advertise(JObj) -> advertise(kz_json:to_proplist(JObj)). --spec advertise_v(api_terms()) -> boolean(). +-spec advertise_v(kz_term:api_terms()) -> boolean(). advertise_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?ADVERTISE_HEADERS, ?ADVERTISE_VALUES, ?ADVERTISE_TYPES); advertise_v(JObj) -> @@ -63,7 +63,7 @@ advertise_v(JObj) -> %% bind to a queue to the asr exchange and events %% @end %%-------------------------------------------------------------------- --spec bind_q(binary(), kz_proplist()) -> 'ok'. +-spec bind_q(binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, _Props) -> amqp_util:bind_q_to_nodes(Queue). @@ -90,8 +90,8 @@ declare_exchanges() -> %% prepare and publish a nodes advertise message %% @end %%-------------------------------------------------------------------- --spec publish_advertise(api_terms()) -> 'ok'. --spec publish_advertise(api_terms(), ne_binary()) -> 'ok'. +-spec publish_advertise(kz_term:api_terms()) -> 'ok'. +-spec publish_advertise(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_advertise(JObj) -> publish_advertise(JObj, ?DEFAULT_CONTENT_TYPE). publish_advertise(Advertise, ContentType) -> diff --git a/core/kazoo_amqp/src/api/kapi_notifications.erl b/core/kazoo_amqp/src/api/kapi_notifications.erl index 0ff7e63ccb8..ff2bdd9a6fc 100644 --- a/core/kazoo_amqp/src/api/kapi_notifications.erl +++ b/core/kazoo_amqp/src/api/kapi_notifications.erl @@ -1134,7 +1134,7 @@ api_definitions() -> ,webhook_disabled_definition() ]. --spec api_definition(atom() | text() | ne_binary()) -> kapi_definition:api(). +-spec api_definition(atom() | kz_term:text() | kz_term:ne_binary()) -> kapi_definition:api(). api_definition(Name) when is_atom(Name) -> api_definition(kz_term:to_binary(Name)); api_definition(Name) when is_list(Name) -> @@ -1212,11 +1212,11 @@ api_definition(<<"webhook">>) -> api_definition(<<"webhook_disabled">>) -> webhook_disabled_definition(). --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, Props) -> bind_to_q(Queue, props:get_value('restrict_to', Props)). --spec bind_to_q(ne_binary(), api_atoms()) -> 'ok'. +-spec bind_to_q(kz_term:ne_binary(), kz_term:api_atoms()) -> 'ok'. bind_to_q(Q, 'undefined') -> 'ok' = amqp_util:bind_q_to_notifications(Q, <<"notifications.*.*">>); bind_to_q(Q, ['new_fax'|T]) -> @@ -1249,11 +1249,11 @@ bind_to_q(Q, [RestrictTo|T]) -> bind_to_q(_Q, []) -> 'ok'. --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Queue, Props) -> unbind_q_from(Queue, props:get_value('restrict_to', Props)). --spec unbind_q_from(ne_binary(), api_atoms()) -> 'ok'. +-spec unbind_q_from(kz_term:ne_binary(), kz_term:api_atoms()) -> 'ok'. unbind_q_from(Q, 'undefined') -> 'ok' = amqp_util:unbind_q_from_notifications(Q, <<"notifications.*.*">>); unbind_q_from(Q, ['new_fax'|T]) -> @@ -1298,12 +1298,12 @@ declare_exchanges() -> %%% Helpers %%%=================================================================== --spec account_id(api_terms()) -> api_ne_binary(). +-spec account_id(kz_term:api_terms()) -> kz_term:api_ne_binary(). account_id('undefined') -> 'undefined'; account_id(Req) when is_list(Req) -> find_account_id(Req, fun props:get_first_defined/2); account_id(Req) -> find_account_id(Req, fun kz_json:get_first_defined/2). --spec find_account_id(api_terms(), function()) -> api_ne_binary(). +-spec find_account_id(kz_term:api_terms(), function()) -> kz_term:api_ne_binary(). find_account_id(Req, GetFun) -> Paths = [<<"account_id">> ,[<<"account">>, <<"_id">>] @@ -1320,12 +1320,12 @@ find_account_id(Req, GetFun) -> _ -> 'undefined' end. --spec account_db(api_terms(), boolean()) -> api_ne_binary(). +-spec account_db(kz_term:api_terms(), boolean()) -> kz_term:api_ne_binary(). account_db('undefined', _) -> 'undefined'; account_db(Req, StrictMODB) when is_list(Req) -> find_account_db(Req, StrictMODB, fun props:get_first_defined/2); account_db(Req, StrictMODB) -> find_account_db(Req, StrictMODB, fun kz_json:get_first_defined/2). --spec find_account_db(api_terms(), boolean(), function()) -> api_ne_binary(). +-spec find_account_db(kz_term:api_terms(), boolean(), function()) -> kz_term:api_ne_binary(). find_account_db(Req, StrictMODB, GetFun) -> Paths = [<<"account_db">>, <<"pvt_account_db">>, <<"Account-DB">>], case GetFun(Paths, Req) of @@ -1341,7 +1341,7 @@ find_account_db(Req, StrictMODB, GetFun) -> _ -> 'undefined' end. --spec headers(ne_binary()) -> ne_binaries(). +-spec headers(kz_term:ne_binary()) -> kz_term:ne_binaries(). headers(<<"fax_inbound_to_email">>) -> headers(<<"inbound_fax">>); headers(<<"fax_inbound_error_to_email">>) -> @@ -1368,7 +1368,7 @@ headers(Name) -> %% Generic function to build API payload %% @end %%-------------------------------------------------------------------- --spec build_message(api_terms(), kapi_definition:api()) -> api_formatter_return(). +-spec build_message(kz_term:api_terms(), kapi_definition:api()) -> api_formatter_return(). build_message(Prop, #kapi_definition{required_headers = ReqH ,optional_headers = OptH ,validate_fun = Validate @@ -1406,19 +1406,19 @@ validate(JObj, Definition) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec notify_update(api_terms()) -> api_formatter_return(). +-spec notify_update(kz_term:api_terms()) -> api_formatter_return(). notify_update(Prop) -> build_message(Prop, notify_update_definition()). --spec notify_update_v(api_terms()) -> boolean(). +-spec notify_update_v(kz_term:api_terms()) -> boolean(). notify_update_v(Prop) -> validate(Prop, notify_update_definition()). --spec publish_notify_update(ne_binary(), api_terms()) -> 'ok'. +-spec publish_notify_update(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. publish_notify_update(RespQ, JObj) -> publish_notify_update(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_notify_update(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_notify_update(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_notify_update(RespQ, API, ContentType) -> #kapi_definition{values = Values} = notify_update_definition(), {'ok', Payload} = kz_api:prepare_api_payload(API, Values, fun notify_update/1), @@ -1430,19 +1430,19 @@ publish_notify_update(RespQ, API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec skel(api_terms()) -> api_formatter_return(). +-spec skel(kz_term:api_terms()) -> api_formatter_return(). skel(Prop) -> build_message(Prop, skel_definition()). --spec skel_v(api_terms()) -> boolean(). +-spec skel_v(kz_term:api_terms()) -> boolean(). skel_v(Prop) -> validate(Prop, skel_definition()). --spec publish_skel(api_terms()) -> 'ok'. +-spec publish_skel(kz_term:api_terms()) -> 'ok'. publish_skel(JObj) -> publish_skel(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_skel(api_terms(), ne_binary()) -> 'ok'. +-spec publish_skel(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_skel(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -1461,19 +1461,19 @@ publish_skel(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec account_zone_change(api_terms()) -> api_formatter_return(). +-spec account_zone_change(kz_term:api_terms()) -> api_formatter_return(). account_zone_change(Prop) -> build_message(Prop, account_zone_change_definition()). --spec account_zone_change_v(api_terms()) -> boolean(). +-spec account_zone_change_v(kz_term:api_terms()) -> boolean(). account_zone_change_v(Prop) -> validate(Prop, account_zone_change_definition()). --spec publish_account_zone_change(api_terms()) -> 'ok'. +-spec publish_account_zone_change(kz_term:api_terms()) -> 'ok'. publish_account_zone_change(JObj) -> publish_account_zone_change(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_account_zone_change(api_terms(), ne_binary()) -> 'ok'. +-spec publish_account_zone_change(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_account_zone_change(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -1486,19 +1486,19 @@ publish_account_zone_change(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec low_balance(api_terms()) -> api_formatter_return(). +-spec low_balance(kz_term:api_terms()) -> api_formatter_return(). low_balance(Prop) -> build_message(Prop, low_balance_definition()). --spec low_balance_v(api_terms()) -> boolean(). +-spec low_balance_v(kz_term:api_terms()) -> boolean(). low_balance_v(Prop) -> validate(Prop, low_balance_definition()). --spec publish_low_balance(api_terms()) -> 'ok'. +-spec publish_low_balance(kz_term:api_terms()) -> 'ok'. publish_low_balance(JObj) -> publish_low_balance(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_low_balance(api_terms(), ne_binary()) -> 'ok'. +-spec publish_low_balance(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_low_balance(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -1511,19 +1511,19 @@ publish_low_balance(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec new_account(api_terms()) -> api_formatter_return(). +-spec new_account(kz_term:api_terms()) -> api_formatter_return(). new_account(Prop) -> build_message(Prop, new_account_definition()). --spec new_account_v(api_terms()) -> boolean(). +-spec new_account_v(kz_term:api_terms()) -> boolean(). new_account_v(Prop) -> validate(Prop, new_account_definition()). --spec publish_new_account(api_terms()) -> 'ok'. +-spec publish_new_account(kz_term:api_terms()) -> 'ok'. publish_new_account(JObj) -> publish_new_account(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_new_account(api_terms(), ne_binary()) -> 'ok'. +-spec publish_new_account(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_new_account(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -1536,19 +1536,19 @@ publish_new_account(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec service_added(api_terms()) -> api_formatter_return(). +-spec service_added(kz_term:api_terms()) -> api_formatter_return(). service_added(Prop) -> build_message(Prop, service_added_definition()). --spec service_added_v(api_terms()) -> boolean(). +-spec service_added_v(kz_term:api_terms()) -> boolean(). service_added_v(Prop) -> validate(Prop, service_added_definition()). --spec publish_service_added(api_terms()) -> 'ok'. +-spec publish_service_added(kz_term:api_terms()) -> 'ok'. publish_service_added(JObj) -> publish_service_added(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_service_added(api_terms(), ne_binary()) -> 'ok'. +-spec publish_service_added(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_service_added(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -1561,19 +1561,19 @@ publish_service_added(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec topup(api_terms()) -> api_formatter_return(). +-spec topup(kz_term:api_terms()) -> api_formatter_return(). topup(Prop) -> build_message(Prop, topup_definition()). --spec topup_v(api_terms()) -> boolean(). +-spec topup_v(kz_term:api_terms()) -> boolean(). topup_v(Prop) -> validate(Prop, topup_definition()). --spec publish_topup(api_terms()) -> 'ok'. +-spec publish_topup(kz_term:api_terms()) -> 'ok'. publish_topup(JObj) -> publish_topup(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_topup(api_terms(), ne_binary()) -> 'ok'. +-spec publish_topup(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_topup(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -1586,19 +1586,19 @@ publish_topup(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec transaction(api_terms()) -> api_formatter_return(). +-spec transaction(kz_term:api_terms()) -> api_formatter_return(). transaction(Prop) -> build_message(Prop, transaction_definition()). --spec transaction_v(api_terms()) -> boolean(). +-spec transaction_v(kz_term:api_terms()) -> boolean(). transaction_v(Prop) -> validate(Prop, transaction_definition()). --spec publish_transaction(api_terms()) -> 'ok'. +-spec publish_transaction(kz_term:api_terms()) -> 'ok'. publish_transaction(JObj) -> publish_transaction(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_transaction(api_terms(), ne_binary()) -> 'ok'. +-spec publish_transaction(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_transaction(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -1617,19 +1617,19 @@ publish_transaction(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec fax_inbound(api_terms()) -> api_formatter_return(). +-spec fax_inbound(kz_term:api_terms()) -> api_formatter_return(). fax_inbound(Prop) -> build_message(Prop, inbound_fax_definition()). --spec fax_inbound_v(api_terms()) -> boolean(). +-spec fax_inbound_v(kz_term:api_terms()) -> boolean(). fax_inbound_v(Prop) -> validate(Prop, inbound_fax_definition()). --spec publish_fax_inbound(api_terms()) -> 'ok'. +-spec publish_fax_inbound(kz_term:api_terms()) -> 'ok'. publish_fax_inbound(JObj) -> publish_fax_inbound(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_fax_inbound(api_terms(), ne_binary()) -> 'ok'. +-spec publish_fax_inbound(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_fax_inbound(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -1642,19 +1642,19 @@ publish_fax_inbound(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec fax_inbound_error(api_terms()) -> api_formatter_return(). +-spec fax_inbound_error(kz_term:api_terms()) -> api_formatter_return(). fax_inbound_error(Prop) -> build_message(Prop, inbound_fax_error_definition()). --spec fax_inbound_error_v(api_terms()) -> boolean(). +-spec fax_inbound_error_v(kz_term:api_terms()) -> boolean(). fax_inbound_error_v(Prop) -> validate(Prop, inbound_fax_error_definition()). --spec publish_fax_inbound_error(api_terms()) -> 'ok'. +-spec publish_fax_inbound_error(kz_term:api_terms()) -> 'ok'. publish_fax_inbound_error(JObj) -> publish_fax_inbound_error(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_fax_inbound_error(api_terms(), ne_binary()) -> 'ok'. +-spec publish_fax_inbound_error(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_fax_inbound_error(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -1667,19 +1667,19 @@ publish_fax_inbound_error(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec fax_outbound(api_terms()) -> api_formatter_return(). +-spec fax_outbound(kz_term:api_terms()) -> api_formatter_return(). fax_outbound(Prop) -> build_message(Prop, outbound_fax_definition()). --spec fax_outbound_v(api_terms()) -> boolean(). +-spec fax_outbound_v(kz_term:api_terms()) -> boolean(). fax_outbound_v(Prop) -> validate(Prop, outbound_fax_definition()). --spec publish_fax_outbound(api_terms()) -> 'ok'. +-spec publish_fax_outbound(kz_term:api_terms()) -> 'ok'. publish_fax_outbound(JObj) -> publish_fax_outbound(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_fax_outbound(api_terms(), ne_binary()) -> 'ok'. +-spec publish_fax_outbound(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_fax_outbound(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -1692,19 +1692,19 @@ publish_fax_outbound(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec fax_outbound_error(api_terms()) -> api_formatter_return(). +-spec fax_outbound_error(kz_term:api_terms()) -> api_formatter_return(). fax_outbound_error(Prop) -> build_message(Prop, outbound_fax_error_definition()). --spec fax_outbound_error_v(api_terms()) -> boolean(). +-spec fax_outbound_error_v(kz_term:api_terms()) -> boolean(). fax_outbound_error_v(Prop) -> validate(Prop, outbound_fax_error_definition()). --spec publish_fax_outbound_error(api_terms()) -> 'ok'. +-spec publish_fax_outbound_error(kz_term:api_terms()) -> 'ok'. publish_fax_outbound_error(JObj) -> publish_fax_outbound_error(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_fax_outbound_error(api_terms(), ne_binary()) -> 'ok'. +-spec publish_fax_outbound_error(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_fax_outbound_error(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -1717,19 +1717,19 @@ publish_fax_outbound_error(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec fax_outbound_smtp_error(api_terms()) -> api_formatter_return(). +-spec fax_outbound_smtp_error(kz_term:api_terms()) -> api_formatter_return(). fax_outbound_smtp_error(Prop) -> build_message(Prop, outbound_smtp_fax_error_definition()). --spec fax_outbound_smtp_error_v(api_terms()) -> boolean(). +-spec fax_outbound_smtp_error_v(kz_term:api_terms()) -> boolean(). fax_outbound_smtp_error_v(Prop) -> validate(Prop, outbound_smtp_fax_error_definition()). --spec publish_fax_outbound_smtp_error(api_terms()) -> 'ok'. +-spec publish_fax_outbound_smtp_error(kz_term:api_terms()) -> 'ok'. publish_fax_outbound_smtp_error(JObj) -> publish_fax_outbound_smtp_error(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_fax_outbound_smtp_error(api_terms(), ne_binary()) -> 'ok'. +-spec publish_fax_outbound_smtp_error(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_fax_outbound_smtp_error(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -1748,19 +1748,19 @@ publish_fax_outbound_smtp_error(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec cnam_request(api_terms()) -> api_formatter_return(). +-spec cnam_request(kz_term:api_terms()) -> api_formatter_return(). cnam_request(Prop) -> build_message(Prop, cnam_request_definition()). --spec cnam_request_v(api_terms()) -> boolean(). +-spec cnam_request_v(kz_term:api_terms()) -> boolean(). cnam_request_v(Prop) -> validate(Prop, cnam_request_definition()). --spec publish_cnam_request(api_terms()) -> 'ok'. +-spec publish_cnam_request(kz_term:api_terms()) -> 'ok'. publish_cnam_request(JObj) -> publish_cnam_request(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_cnam_request(api_terms(), ne_binary()) -> 'ok'. +-spec publish_cnam_request(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_cnam_request(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -1773,19 +1773,19 @@ publish_cnam_request(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec port_cancel(api_terms()) -> api_formatter_return(). +-spec port_cancel(kz_term:api_terms()) -> api_formatter_return(). port_cancel(Prop) -> build_message(Prop, port_cancel_definition()). --spec port_cancel_v(api_terms()) -> boolean(). +-spec port_cancel_v(kz_term:api_terms()) -> boolean(). port_cancel_v(Prop) -> validate(Prop, port_cancel_definition()). --spec publish_port_cancel(api_terms()) -> 'ok'. +-spec publish_port_cancel(kz_term:api_terms()) -> 'ok'. publish_port_cancel(JObj) -> publish_port_cancel(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_port_cancel(api_terms(), ne_binary()) -> 'ok'. +-spec publish_port_cancel(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_port_cancel(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -1798,19 +1798,19 @@ publish_port_cancel(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec port_comment(api_terms()) -> api_formatter_return(). +-spec port_comment(kz_term:api_terms()) -> api_formatter_return(). port_comment(Prop) -> build_message(Prop, port_comment_definition()). --spec port_comment_v(api_terms()) -> boolean(). +-spec port_comment_v(kz_term:api_terms()) -> boolean(). port_comment_v(Prop) -> validate(Prop, port_comment_definition()). --spec publish_port_comment(api_terms()) -> 'ok'. +-spec publish_port_comment(kz_term:api_terms()) -> 'ok'. publish_port_comment(JObj) -> publish_port_comment(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_port_comment(api_terms(), ne_binary()) -> 'ok'. +-spec publish_port_comment(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_port_comment(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -1823,19 +1823,19 @@ publish_port_comment(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec port_pending(api_terms()) -> api_formatter_return(). +-spec port_pending(kz_term:api_terms()) -> api_formatter_return(). port_pending(Prop) -> build_message(Prop, port_pending_definition()). --spec port_pending_v(api_terms()) -> boolean(). +-spec port_pending_v(kz_term:api_terms()) -> boolean(). port_pending_v(Prop) -> validate(Prop, port_pending_definition()). --spec publish_port_pending(api_terms()) -> 'ok'. +-spec publish_port_pending(kz_term:api_terms()) -> 'ok'. publish_port_pending(JObj) -> publish_port_pending(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_port_pending(api_terms(), ne_binary()) -> 'ok'. +-spec publish_port_pending(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_port_pending(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -1848,19 +1848,19 @@ publish_port_pending(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec port_rejected(api_terms()) -> api_formatter_return(). +-spec port_rejected(kz_term:api_terms()) -> api_formatter_return(). port_rejected(Prop) -> build_message(Prop, port_rejected_definition()). --spec port_rejected_v(api_terms()) -> boolean(). +-spec port_rejected_v(kz_term:api_terms()) -> boolean(). port_rejected_v(Prop) -> validate(Prop, port_rejected_definition()). --spec publish_port_rejected(api_terms()) -> 'ok'. +-spec publish_port_rejected(kz_term:api_terms()) -> 'ok'. publish_port_rejected(JObj) -> publish_port_rejected(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_port_rejected(api_terms(), ne_binary()) -> 'ok'. +-spec publish_port_rejected(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_port_rejected(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -1873,19 +1873,19 @@ publish_port_rejected(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec port_request(api_terms()) -> api_formatter_return(). +-spec port_request(kz_term:api_terms()) -> api_formatter_return(). port_request(Prop) -> build_message(Prop, port_request_definition()). --spec port_request_v(api_terms()) -> boolean(). +-spec port_request_v(kz_term:api_terms()) -> boolean(). port_request_v(Prop) -> validate(Prop, port_request_definition()). --spec publish_port_request(api_terms()) -> 'ok'. +-spec publish_port_request(kz_term:api_terms()) -> 'ok'. publish_port_request(JObj) -> publish_port_request(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_port_request(api_terms(), ne_binary()) -> 'ok'. +-spec publish_port_request(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_port_request(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -1898,19 +1898,19 @@ publish_port_request(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec port_scheduled(api_terms()) -> api_formatter_return(). +-spec port_scheduled(kz_term:api_terms()) -> api_formatter_return(). port_scheduled(Prop) -> build_message(Prop, port_scheduled_definition()). --spec port_scheduled_v(api_terms()) -> boolean(). +-spec port_scheduled_v(kz_term:api_terms()) -> boolean(). port_scheduled_v(Prop) -> validate(Prop, port_scheduled_definition()). --spec publish_port_scheduled(api_terms()) -> 'ok'. +-spec publish_port_scheduled(kz_term:api_terms()) -> 'ok'. publish_port_scheduled(JObj) -> publish_port_scheduled(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_port_scheduled(api_terms(), ne_binary()) -> 'ok'. +-spec publish_port_scheduled(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_port_scheduled(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -1923,19 +1923,19 @@ publish_port_scheduled(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec port_unconfirmed(api_terms()) -> api_formatter_return(). +-spec port_unconfirmed(kz_term:api_terms()) -> api_formatter_return(). port_unconfirmed(Prop) -> build_message(Prop, port_unconfirmed_definition()). --spec port_unconfirmed_v(api_terms()) -> boolean(). +-spec port_unconfirmed_v(kz_term:api_terms()) -> boolean(). port_unconfirmed_v(Prop) -> validate(Prop, port_unconfirmed_definition()). --spec publish_port_unconfirmed(api_terms()) -> 'ok'. +-spec publish_port_unconfirmed(kz_term:api_terms()) -> 'ok'. publish_port_unconfirmed(JObj) -> publish_port_unconfirmed(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_port_unconfirmed(api_terms(), ne_binary()) -> 'ok'. +-spec publish_port_unconfirmed(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_port_unconfirmed(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -1948,19 +1948,19 @@ publish_port_unconfirmed(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec ported(api_terms()) -> api_formatter_return(). +-spec ported(kz_term:api_terms()) -> api_formatter_return(). ported(Prop) -> build_message(Prop, ported_definition()). --spec ported_v(api_terms()) -> boolean(). +-spec ported_v(kz_term:api_terms()) -> boolean(). ported_v(Prop) -> validate(Prop, ported_definition()). --spec publish_ported(api_terms()) -> 'ok'. +-spec publish_ported(kz_term:api_terms()) -> 'ok'. publish_ported(JObj) -> publish_ported(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_ported(api_terms(), ne_binary()) -> 'ok'. +-spec publish_ported(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_ported(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -1979,19 +1979,19 @@ publish_ported(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec denied_emergency_bridge(api_terms()) -> api_formatter_return(). +-spec denied_emergency_bridge(kz_term:api_terms()) -> api_formatter_return(). denied_emergency_bridge(Prop) -> build_message(Prop, denied_emergency_bridge_definition()). --spec denied_emergency_bridge_v(api_terms()) -> boolean(). +-spec denied_emergency_bridge_v(kz_term:api_terms()) -> boolean(). denied_emergency_bridge_v(Prop) -> validate(Prop, denied_emergency_bridge_definition()). --spec publish_denied_emergency_bridge(api_terms()) -> 'ok'. +-spec publish_denied_emergency_bridge(kz_term:api_terms()) -> 'ok'. publish_denied_emergency_bridge(JObj) -> publish_denied_emergency_bridge(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_denied_emergency_bridge(api_terms(), ne_binary()) -> 'ok'. +-spec publish_denied_emergency_bridge(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_denied_emergency_bridge(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -2010,19 +2010,19 @@ publish_denied_emergency_bridge(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec deregister(api_terms()) -> api_formatter_return(). +-spec deregister(kz_term:api_terms()) -> api_formatter_return(). deregister(Prop) -> build_message(Prop, deregister_definition()). --spec deregister_v(api_terms()) -> boolean(). +-spec deregister_v(kz_term:api_terms()) -> boolean(). deregister_v(Prop) -> validate(Prop, deregister_definition()). --spec publish_deregister(api_terms()) -> 'ok'. +-spec publish_deregister(kz_term:api_terms()) -> 'ok'. publish_deregister(JObj) -> publish_deregister(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_deregister(api_terms(), ne_binary()) -> 'ok'. +-spec publish_deregister(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_deregister(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -2035,19 +2035,19 @@ publish_deregister(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec first_occurrence(api_terms()) -> api_formatter_return(). +-spec first_occurrence(kz_term:api_terms()) -> api_formatter_return(). first_occurrence(Prop) -> build_message(Prop, first_occurrence_definition()). --spec first_occurrence_v(api_terms()) -> boolean(). +-spec first_occurrence_v(kz_term:api_terms()) -> boolean(). first_occurrence_v(Prop) -> validate(Prop, first_occurrence_definition()). --spec publish_first_occurrence(api_terms()) -> 'ok'. +-spec publish_first_occurrence(kz_term:api_terms()) -> 'ok'. publish_first_occurrence(JObj) -> publish_first_occurrence(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_first_occurrence(api_terms(), ne_binary()) -> 'ok'. +-spec publish_first_occurrence(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_first_occurrence(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -2060,19 +2060,19 @@ publish_first_occurrence(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec missed_call(api_terms()) -> api_formatter_return(). +-spec missed_call(kz_term:api_terms()) -> api_formatter_return(). missed_call(Prop) -> build_message(Prop, missed_call_definition()). --spec missed_call_v(api_terms()) -> boolean(). +-spec missed_call_v(kz_term:api_terms()) -> boolean(). missed_call_v(Prop) -> validate(Prop, missed_call_definition()). --spec publish_missed_call(api_terms()) -> 'ok'. +-spec publish_missed_call(kz_term:api_terms()) -> 'ok'. publish_missed_call(JObj) -> publish_missed_call(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_missed_call(api_terms(), ne_binary()) -> 'ok'. +-spec publish_missed_call(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_missed_call(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -2085,19 +2085,19 @@ publish_missed_call(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec register(api_terms()) -> api_formatter_return(). +-spec register(kz_term:api_terms()) -> api_formatter_return(). register(Prop) -> build_message(Prop, register_definition()). --spec register_v(api_terms()) -> boolean(). +-spec register_v(kz_term:api_terms()) -> boolean(). register_v(Prop) -> validate(Prop, register_definition()). --spec publish_register(api_terms()) -> 'ok'. +-spec publish_register(kz_term:api_terms()) -> 'ok'. publish_register(JObj) -> publish_register(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_register(api_terms(), ne_binary()) -> 'ok'. +-spec publish_register(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_register(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -2116,19 +2116,19 @@ publish_register(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec system_alert(api_terms()) -> api_formatter_return(). +-spec system_alert(kz_term:api_terms()) -> api_formatter_return(). system_alert(Prop) -> build_message(Prop, system_alert_definition()). --spec system_alert_v(api_terms()) -> boolean(). +-spec system_alert_v(kz_term:api_terms()) -> boolean(). system_alert_v(Prop) -> validate(Prop, system_alert_definition()). --spec publish_system_alert(api_terms()) -> 'ok'. +-spec publish_system_alert(kz_term:api_terms()) -> 'ok'. publish_system_alert(JObj) -> publish_system_alert(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_system_alert(api_terms(), ne_binary()) -> 'ok'. +-spec publish_system_alert(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_system_alert(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -2147,19 +2147,19 @@ publish_system_alert(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec customer_update(api_terms()) -> api_formatter_return(). +-spec customer_update(kz_term:api_terms()) -> api_formatter_return(). customer_update(Prop) -> build_message(Prop, customer_update_definition()). --spec customer_update_v(api_terms()) -> boolean(). +-spec customer_update_v(kz_term:api_terms()) -> boolean(). customer_update_v(Prop) -> validate(Prop, customer_update_definition()). --spec publish_customer_update(api_terms()) -> 'ok'. +-spec publish_customer_update(kz_term:api_terms()) -> 'ok'. publish_customer_update(JObj) -> publish_customer_update(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_customer_update(api_terms(), ne_binary()) -> 'ok'. +-spec publish_customer_update(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_customer_update(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -2172,19 +2172,19 @@ publish_customer_update(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec new_user(api_terms()) -> api_formatter_return(). +-spec new_user(kz_term:api_terms()) -> api_formatter_return(). new_user(Prop) -> build_message(Prop, new_user_definition()). --spec new_user_v(api_terms()) -> boolean(). +-spec new_user_v(kz_term:api_terms()) -> boolean(). new_user_v(Prop) -> validate(Prop, new_user_definition()). --spec publish_new_user(api_terms()) -> 'ok'. +-spec publish_new_user(kz_term:api_terms()) -> 'ok'. publish_new_user(JObj) -> publish_new_user(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_new_user(api_terms(), ne_binary()) -> 'ok'. +-spec publish_new_user(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_new_user(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -2197,19 +2197,19 @@ publish_new_user(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec password_recovery(api_terms()) -> api_formatter_return(). +-spec password_recovery(kz_term:api_terms()) -> api_formatter_return(). password_recovery(Prop) -> build_message(Prop, password_recovery_definition()). --spec password_recovery_v(api_terms()) -> boolean(). +-spec password_recovery_v(kz_term:api_terms()) -> boolean(). password_recovery_v(Prop) -> validate(Prop, password_recovery_definition()). --spec publish_password_recovery(api_terms()) -> 'ok'. +-spec publish_password_recovery(kz_term:api_terms()) -> 'ok'. publish_password_recovery(JObj) -> publish_password_recovery(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_password_recovery(api_terms(), ne_binary()) -> 'ok'. +-spec publish_password_recovery(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_password_recovery(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -2228,19 +2228,19 @@ publish_password_recovery(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec voicemail_full(api_terms()) -> api_formatter_return(). +-spec voicemail_full(kz_term:api_terms()) -> api_formatter_return(). voicemail_full(Prop) -> build_message(Prop, voicemail_full_definition()). --spec voicemail_full_v(api_terms()) -> boolean(). +-spec voicemail_full_v(kz_term:api_terms()) -> boolean(). voicemail_full_v(Prop) -> validate(Prop, voicemail_full_definition()). --spec publish_voicemail_full(api_terms()) -> 'ok'. +-spec publish_voicemail_full(kz_term:api_terms()) -> 'ok'. publish_voicemail_full(JObj) -> publish_voicemail_full(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_voicemail_full(api_terms(), ne_binary()) -> 'ok'. +-spec publish_voicemail_full(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_voicemail_full(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -2253,19 +2253,19 @@ publish_voicemail_full(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec voicemail_new(api_terms()) -> api_formatter_return(). +-spec voicemail_new(kz_term:api_terms()) -> api_formatter_return(). voicemail_new(Prop) -> build_message(Prop, voicemail_new_definition()). --spec voicemail_new_v(api_terms()) -> boolean(). +-spec voicemail_new_v(kz_term:api_terms()) -> boolean(). voicemail_new_v(Prop) -> validate(Prop, voicemail_new_definition()). --spec publish_voicemail_new(api_terms()) -> 'ok'. +-spec publish_voicemail_new(kz_term:api_terms()) -> 'ok'. publish_voicemail_new(JObj) -> publish_voicemail_new(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_voicemail_new(api_terms(), ne_binary()) -> 'ok'. +-spec publish_voicemail_new(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_voicemail_new(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -2278,19 +2278,19 @@ publish_voicemail_new(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec voicemail_saved(api_terms()) -> api_formatter_return(). +-spec voicemail_saved(kz_term:api_terms()) -> api_formatter_return(). voicemail_saved(Prop) -> build_message(Prop, voicemail_saved_definition()). --spec voicemail_saved_v(api_terms()) -> boolean(). +-spec voicemail_saved_v(kz_term:api_terms()) -> boolean(). voicemail_saved_v(Prop) -> validate(Prop, voicemail_saved_definition()). --spec publish_voicemail_saved(api_terms()) -> 'ok'. +-spec publish_voicemail_saved(kz_term:api_terms()) -> 'ok'. publish_voicemail_saved(JObj) -> publish_voicemail_saved(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_voicemail_saved(api_terms(), ne_binary()) -> 'ok'. +-spec publish_voicemail_saved(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_voicemail_saved(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -2309,19 +2309,19 @@ publish_voicemail_saved(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec webhook(api_terms()) -> api_formatter_return(). +-spec webhook(kz_term:api_terms()) -> api_formatter_return(). webhook(Prop) -> build_message(Prop, webhook_definition()). --spec webhook_v(api_terms()) -> boolean(). +-spec webhook_v(kz_term:api_terms()) -> boolean(). webhook_v(Prop) -> validate(Prop, webhook_definition()). --spec publish_webhook(api_terms()) -> 'ok'. +-spec publish_webhook(kz_term:api_terms()) -> 'ok'. publish_webhook(JObj) -> publish_webhook(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_webhook(api_terms(), ne_binary()) -> 'ok'. +-spec publish_webhook(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_webhook(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values @@ -2334,19 +2334,19 @@ publish_webhook(API, ContentType) -> %% Takes prop-list, creates JSON string and publish it on AMQP %% @end %%-------------------------------------------------------------------- --spec webhook_disabled(api_terms()) -> api_formatter_return(). +-spec webhook_disabled(kz_term:api_terms()) -> api_formatter_return(). webhook_disabled(Prop) -> build_message(Prop, webhook_disabled_definition()). --spec webhook_disabled_v(api_terms()) -> boolean(). +-spec webhook_disabled_v(kz_term:api_terms()) -> boolean(). webhook_disabled_v(Prop) -> validate(Prop, webhook_disabled_definition()). --spec publish_webhook_disabled(api_terms()) -> 'ok'. +-spec publish_webhook_disabled(kz_term:api_terms()) -> 'ok'. publish_webhook_disabled(JObj) -> publish_webhook_disabled(JObj, ?DEFAULT_CONTENT_TYPE). --spec publish_webhook_disabled(api_terms(), ne_binary()) -> 'ok'. +-spec publish_webhook_disabled(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_webhook_disabled(API, ContentType) -> #kapi_definition{binding = Binding ,values = Values diff --git a/core/kazoo_amqp/src/api/kapi_offnet_resource.erl b/core/kazoo_amqp/src/api/kapi_offnet_resource.erl index 0b53a33cad6..b6351ae53fb 100644 --- a/core/kazoo_amqp/src/api/kapi_offnet_resource.erl +++ b/core/kazoo_amqp/src/api/kapi_offnet_resource.erl @@ -188,7 +188,7 @@ %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec req(api_terms()) -> +-spec req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. req(Prop) when is_list(Prop) -> @@ -198,7 +198,7 @@ req(Prop) when is_list(Prop) -> end; req(JObj) -> req(kz_json:to_proplist(JObj)). --spec req_v(api_terms()) -> boolean(). +-spec req_v(kz_term:api_terms()) -> boolean(). req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?OFFNET_RESOURCE_REQ_HEADERS, ?OFFNET_RESOURCE_REQ_VALUES, ?OFFNET_RESOURCE_REQ_TYPES); req_v(JObj) -> req_v(kz_json:to_proplist(JObj)). @@ -208,7 +208,7 @@ req_v(JObj) -> req_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec resp(api_terms()) -> +-spec resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. resp(Prop) when is_list(Prop) -> @@ -218,16 +218,16 @@ resp(Prop) when is_list(Prop) -> end; resp(JObj) -> resp(kz_json:to_proplist(JObj)). --spec resp_v(api_terms()) -> boolean(). +-spec resp_v(kz_term:api_terms()) -> boolean(). resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?OFFNET_RESOURCE_RESP_HEADERS, ?OFFNET_RESOURCE_RESP_VALUES, ?OFFNET_RESOURCE_RESP_TYPES); resp_v(JObj) -> resp_v(kz_json:to_proplist(JObj)). --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, _Props) -> amqp_util:bind_q_to_resource(Queue, ?KEY_OFFNET_RESOURCE_REQ). --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Queue, _Props) -> amqp_util:unbind_q_from_resource(Queue, ?KEY_OFFNET_RESOURCE_REQ). @@ -240,8 +240,8 @@ unbind_q(Queue, _Props) -> declare_exchanges() -> amqp_util:resource_exchange(). --spec publish_req(api_terms()) -> 'ok'. --spec publish_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_req(kz_term:api_terms()) -> 'ok'. +-spec publish_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_req(JObj) -> publish_req(JObj, ?DEFAULT_CONTENT_TYPE). @@ -249,8 +249,8 @@ publish_req(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?OFFNET_RESOURCE_REQ_VALUES, fun req/1), amqp_util:offnet_resource_publish(Payload, ContentType). --spec publish_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_resp(TargetQ, JObj) -> publish_resp(TargetQ, JObj, ?DEFAULT_CONTENT_TYPE). @@ -265,85 +265,85 @@ force_outbound(Req) -> force_outbound(?REQ_TYPE(JObj), Default) -> kz_json:is_true(?KEY_FORCE_OUTBOUND, JObj, Default). --spec resource_type(req()) -> ne_binary(). --spec resource_type(req(), Default) -> ne_binary() | Default. +-spec resource_type(req()) -> kz_term:ne_binary(). +-spec resource_type(req(), Default) -> kz_term:ne_binary() | Default. resource_type(Req) -> resource_type(Req, ?RESOURCE_TYPE_AUDIO). resource_type(?REQ_TYPE(JObj), Default) -> kz_json:get_ne_value(?KEY_RESOURCE_TYPE, JObj, Default). --spec account_id(req()) -> api_binary(). --spec account_id(req(), Default) -> ne_binary() | Default. +-spec account_id(req()) -> kz_term:api_binary(). +-spec account_id(req(), Default) -> kz_term:ne_binary() | Default. account_id(Req) -> account_id(Req, 'undefined'). account_id(?REQ_TYPE(JObj), Default) -> kz_json:get_ne_value(?KEY_ACCOUNT_ID, JObj, Default). --spec hunt_account_id(req()) -> api_binary(). --spec hunt_account_id(req(), Default) -> ne_binary() | Default. +-spec hunt_account_id(req()) -> kz_term:api_binary(). +-spec hunt_account_id(req(), Default) -> kz_term:ne_binary() | Default. hunt_account_id(Req) -> hunt_account_id(Req, 'undefined'). hunt_account_id(?REQ_TYPE(JObj), Default) -> kz_json:get_ne_value(?KEY_HUNT_ACCOUNT_ID, JObj, Default). --spec outbound_call_id(req()) -> api_binary(). --spec outbound_call_id(req(), Default) -> ne_binary() | Default. +-spec outbound_call_id(req()) -> kz_term:api_binary(). +-spec outbound_call_id(req(), Default) -> kz_term:ne_binary() | Default. outbound_call_id(Req) -> outbound_call_id(Req, 'undefined'). outbound_call_id(?REQ_TYPE(JObj), Default) -> kz_json:get_ne_value(?KEY_OUTBOUND_CALL_ID, JObj, Default). --spec outbound_caller_id_number(req()) -> api_binary(). --spec outbound_caller_id_number(req(), Default) -> ne_binary() | Default. +-spec outbound_caller_id_number(req()) -> kz_term:api_binary(). +-spec outbound_caller_id_number(req(), Default) -> kz_term:ne_binary() | Default. outbound_caller_id_number(Req) -> outbound_caller_id_number(Req, 'undefined'). outbound_caller_id_number(?REQ_TYPE(JObj), Default) -> kz_json:get_ne_value(?KEY_OUTBOUND_CALLER_ID_NUMBER, JObj, Default). --spec outbound_caller_id_name(req()) -> api_binary(). --spec outbound_caller_id_name(req(), Default) -> ne_binary() | Default. +-spec outbound_caller_id_name(req()) -> kz_term:api_binary(). +-spec outbound_caller_id_name(req(), Default) -> kz_term:ne_binary() | Default. outbound_caller_id_name(Req) -> outbound_caller_id_name(Req, 'undefined'). outbound_caller_id_name(?REQ_TYPE(JObj), Default) -> kz_json:get_ne_value(?KEY_OUTBOUND_CALLER_ID_NAME, JObj, Default). --spec emergency_caller_id_number(req()) -> api_binary(). --spec emergency_caller_id_number(req(), Default) -> ne_binary() | Default. +-spec emergency_caller_id_number(req()) -> kz_term:api_binary(). +-spec emergency_caller_id_number(req(), Default) -> kz_term:ne_binary() | Default. emergency_caller_id_number(Req) -> emergency_caller_id_number(Req, 'undefined'). emergency_caller_id_number(?REQ_TYPE(JObj), Default) -> kz_json:get_ne_value(?KEY_E_CALLER_ID_NUMBER, JObj, Default). --spec emergency_caller_id_name(req()) -> api_binary(). --spec emergency_caller_id_name(req(), Default) -> ne_binary() | Default. +-spec emergency_caller_id_name(req()) -> kz_term:api_binary(). +-spec emergency_caller_id_name(req(), Default) -> kz_term:ne_binary() | Default. emergency_caller_id_name(Req) -> emergency_caller_id_name(Req, 'undefined'). emergency_caller_id_name(?REQ_TYPE(JObj), Default) -> kz_json:get_ne_value(?KEY_E_CALLER_ID_NAME, JObj, Default). --spec to_did(req()) -> api_binary(). --spec to_did(req(), Default) -> ne_binary() | Default. +-spec to_did(req()) -> kz_term:api_binary(). +-spec to_did(req(), Default) -> kz_term:ne_binary() | Default. to_did(Req) -> to_did(Req, 'undefined'). to_did(?REQ_TYPE(JObj), Default) -> kz_json:get_ne_value(?KEY_TO_DID, JObj, Default). --spec call_id(req()) -> api_binary(). --spec call_id(req(), Default) -> ne_binary() | Default. +-spec call_id(req()) -> kz_term:api_binary(). +-spec call_id(req(), Default) -> kz_term:ne_binary() | Default. call_id(Req) -> call_id(Req, 'undefined'). call_id(?REQ_TYPE(JObj), Default) -> kz_json:get_ne_value(?KEY_CALL_ID, JObj, Default). --spec control_queue(req()) -> api_binary(). --spec control_queue(req(), Default) -> ne_binary() | Default. +-spec control_queue(req()) -> kz_term:api_binary(). +-spec control_queue(req(), Default) -> kz_term:ne_binary() | Default. control_queue(Req) -> control_queue(Req, 'undefined'). control_queue(?REQ_TYPE(JObj), Default) -> kz_json:get_ne_value(?KEY_CONTROL_QUEUE, JObj, Default). --spec flags(req()) -> ne_binaries(). --spec flags(req(), Default) -> ne_binaries() | Default. +-spec flags(req()) -> kz_term:ne_binaries(). +-spec flags(req(), Default) -> kz_term:ne_binaries() | Default. flags(Req) -> flags(Req, []). flags(?REQ_TYPE(JObj), Default) -> @@ -359,32 +359,32 @@ req_to_jobj(?REQ_TYPE(JObj)) -> JObj. put_callid(?REQ_TYPE(JObj)) -> kz_util:put_callid(JObj). --spec set_outbound_call_id(req(), ne_binary()) -> req(). +-spec set_outbound_call_id(req(), kz_term:ne_binary()) -> req(). set_outbound_call_id(?REQ_TYPE(JObj), CallId) -> ?REQ_TYPE(kz_json:insert_value(?KEY_OUTBOUND_CALL_ID, CallId, JObj)). --spec custom_channel_vars(req()) -> api_object(). +-spec custom_channel_vars(req()) -> kz_term:api_object(). -spec custom_channel_vars(req(), Default) -> kz_json:object() | Default. custom_channel_vars(Req) -> custom_channel_vars(Req, 'undefined'). custom_channel_vars(?REQ_TYPE(JObj), Default) -> kz_json:get_json_value(?KEY_CCVS, JObj, Default). --spec custom_application_vars(req()) -> api_object(). +-spec custom_application_vars(req()) -> kz_term:api_object(). -spec custom_application_vars(req(), Default) -> kz_json:object() | Default. custom_application_vars(Req) -> custom_application_vars(Req, 'undefined'). custom_application_vars(?REQ_TYPE(JObj), Default) -> kz_json:get_json_value(?KEY_CAVS, JObj, Default). --spec requestor_custom_channel_vars(req()) -> api_object(). +-spec requestor_custom_channel_vars(req()) -> kz_term:api_object(). -spec requestor_custom_channel_vars(req(), Default) -> kz_json:object() | Default. requestor_custom_channel_vars(Req) -> requestor_custom_channel_vars(Req, 'undefined'). requestor_custom_channel_vars(?REQ_TYPE(JObj), Default) -> kz_json:get_json_value(?KEY_REQUESTOR_CCVS, JObj, Default). --spec custom_sip_headers(req()) -> api_object(). +-spec custom_sip_headers(req()) -> kz_term:api_object(). -spec custom_sip_headers(req(), Default) -> kz_json:object() | Default. custom_sip_headers(Req) -> custom_sip_headers(Req, 'undefined'). @@ -396,7 +396,7 @@ custom_sip_header(Req, Header) -> SipHeaders = custom_sip_headers(Req, kz_json:new()), kz_json:get_value(Header, SipHeaders). --spec requestor_custom_sip_headers(req()) -> api_object(). +-spec requestor_custom_sip_headers(req()) -> kz_term:api_object(). -spec requestor_custom_sip_headers(req(), Default) -> kz_json:object() | Default. requestor_custom_sip_headers(Req) -> requestor_custom_sip_headers(Req, 'undefined'). @@ -408,99 +408,99 @@ requestor_custom_sip_header(Req, Header) -> SipHeaders = requestor_custom_sip_headers(Req, kz_json:new()), kz_json:get_value(Header, SipHeaders). --spec timeout(req()) -> api_integer(). +-spec timeout(req()) -> kz_term:api_integer(). -spec timeout(req(), Default) -> integer() | Default. timeout(Req) -> timeout(Req, 'undefined'). timeout(?REQ_TYPE(JObj), Default) -> kz_json:get_integer_value(?KEY_TIMEOUT, JObj, Default). --spec ignore_early_media(req()) -> api_boolean(). +-spec ignore_early_media(req()) -> kz_term:api_boolean(). -spec ignore_early_media(req(), Default) -> boolean() | Default. ignore_early_media(Req) -> ignore_early_media(Req, 'undefined'). ignore_early_media(?REQ_TYPE(JObj), Default) -> kz_json:is_true(?KEY_IGNORE_EARLY_MEDIA, JObj, Default). --spec media(req()) -> api_binary(). --spec media(req(), Default) -> ne_binary() | Default. +-spec media(req()) -> kz_term:api_binary(). +-spec media(req(), Default) -> kz_term:ne_binary() | Default. media(Req) -> media(Req, 'undefined'). media(?REQ_TYPE(JObj), Default) -> kz_json:get_binary_value(?KEY_MEDIA, JObj, Default). --spec message_id(req()) -> api_binary(). --spec message_id(req(), Default) -> ne_binary() | Default. +-spec message_id(req()) -> kz_term:api_binary(). +-spec message_id(req(), Default) -> kz_term:ne_binary() | Default. message_id(Req) -> message_id(Req, 'undefined'). message_id(?REQ_TYPE(JObj), Default) -> kz_json:get_binary_value(?KEY_MESSAGE_ID, JObj, Default). --spec hold_media(req()) -> api_binary(). --spec hold_media(req(), Default) -> ne_binary() | Default. +-spec hold_media(req()) -> kz_term:api_binary(). +-spec hold_media(req(), Default) -> kz_term:ne_binary() | Default. hold_media(Req) -> hold_media(Req, 'undefined'). hold_media(?REQ_TYPE(JObj), Default) -> kz_json:get_binary_value(?KEY_HOLD_MEDIA, JObj, Default). --spec presence_id(req()) -> api_binary(). --spec presence_id(req(), Default) -> ne_binary() | Default. +-spec presence_id(req()) -> kz_term:api_binary(). +-spec presence_id(req(), Default) -> kz_term:ne_binary() | Default. presence_id(Req) -> presence_id(Req, 'undefined'). presence_id(?REQ_TYPE(JObj), Default) -> kz_json:get_binary_value(?KEY_PRESENCE_ID, JObj, Default). --spec ringback(req()) -> api_binary(). --spec ringback(req(), Default) -> ne_binary() | Default. +-spec ringback(req()) -> kz_term:api_binary(). +-spec ringback(req(), Default) -> kz_term:ne_binary() | Default. ringback(Req) -> ringback(Req, 'undefined'). ringback(?REQ_TYPE(JObj), Default) -> kz_json:get_binary_value(?KEY_RINGBACK, JObj, Default). --spec fax_identity_number(req()) -> api_binary(). --spec fax_identity_number(req(), Default) -> ne_binary() | Default. +-spec fax_identity_number(req()) -> kz_term:api_binary(). +-spec fax_identity_number(req(), Default) -> kz_term:ne_binary() | Default. fax_identity_number(Req) -> fax_identity_number(Req, 'undefined'). fax_identity_number(?REQ_TYPE(JObj), Default) -> kz_json:get_binary_value(?KEY_FAX_IDENTITY_NUMBER, JObj, Default). --spec fax_identity_name(req()) -> api_binary(). --spec fax_identity_name(req(), Default) -> ne_binary() | Default. +-spec fax_identity_name(req()) -> kz_term:api_binary(). +-spec fax_identity_name(req(), Default) -> kz_term:ne_binary() | Default. fax_identity_name(Req) -> fax_identity_name(Req, 'undefined'). fax_identity_name(?REQ_TYPE(JObj), Default) -> kz_json:get_binary_value(?KEY_FAX_IDENTITY_NAME, JObj, Default). --spec outbound_callee_id_number(req()) -> api_binary(). --spec outbound_callee_id_number(req(), Default) -> ne_binary() | Default. +-spec outbound_callee_id_number(req()) -> kz_term:api_binary(). +-spec outbound_callee_id_number(req(), Default) -> kz_term:ne_binary() | Default. outbound_callee_id_number(Req) -> outbound_callee_id_number(Req, 'undefined'). outbound_callee_id_number(?REQ_TYPE(JObj), Default) -> kz_json:get_ne_value(?KEY_OUTBOUND_CALLEE_ID_NUMBER, JObj, Default). --spec outbound_callee_id_name(req()) -> api_binary(). --spec outbound_callee_id_name(req(), Default) -> ne_binary() | Default. +-spec outbound_callee_id_name(req()) -> kz_term:api_binary(). +-spec outbound_callee_id_name(req(), Default) -> kz_term:ne_binary() | Default. outbound_callee_id_name(Req) -> outbound_callee_id_name(Req, 'undefined'). outbound_callee_id_name(?REQ_TYPE(JObj), Default) -> kz_json:get_ne_value(?KEY_OUTBOUND_CALLEE_ID_NAME, JObj, Default). --spec b_leg_events(req()) -> api_binaries(). --spec b_leg_events(req(), Default) -> ne_binaries() | Default. +-spec b_leg_events(req()) -> kz_term:api_binaries(). +-spec b_leg_events(req(), Default) -> kz_term:ne_binaries() | Default. b_leg_events(Req) -> b_leg_events(Req, 'undefined'). b_leg_events(?REQ_TYPE(JObj), Default) -> kz_json:get_list_value(?KEY_B_LEG_EVENTS, JObj, Default). --spec from_uri_realm(req()) -> api_binary(). --spec from_uri_realm(req(), Default) -> ne_binary() | Default. +-spec from_uri_realm(req()) -> kz_term:api_binary(). +-spec from_uri_realm(req(), Default) -> kz_term:ne_binary() | Default. from_uri_realm(Req) -> from_uri_realm(Req, 'undefined'). from_uri_realm(?REQ_TYPE(JObj), Default) -> kz_json:get_ne_value(?KEY_FROM_URI_REALM, JObj, Default). --spec account_realm(req()) -> api_binary(). --spec account_realm(req(), Default) -> ne_binary() | Default. +-spec account_realm(req()) -> kz_term:api_binary(). +-spec account_realm(req(), Default) -> kz_term:ne_binary() | Default. account_realm(Req) -> account_realm(Req, 'undefined'). account_realm(?REQ_TYPE(JObj), Default) -> @@ -513,8 +513,8 @@ format_from_uri(Req) -> format_from_uri(?REQ_TYPE(JObj), Default) -> kz_json:is_true(?KEY_FORMAT_FROM_URI, JObj, Default). --spec body(req()) -> api_binary(). --spec body(req(), Default) -> ne_binary() | Default. +-spec body(req()) -> kz_term:api_binary(). +-spec body(req(), Default) -> kz_term:ne_binary() | Default. body(Req) -> body(Req, 'undefined'). body(?REQ_TYPE(JObj), Default) -> @@ -534,18 +534,18 @@ t38_enabled(Req) -> t38_enabled(?REQ_TYPE(JObj), Default) -> kz_json:is_true(?KEY_T38_ENABLED, JObj, Default). --spec msg_id(req()) -> api_binary(). +-spec msg_id(req()) -> kz_term:api_binary(). msg_id(?REQ_TYPE(JObj)) -> kz_api:msg_id(JObj). --spec server_id(req()) -> api_binary(). +-spec server_id(req()) -> kz_term:api_binary(). server_id(?REQ_TYPE(JObj)) -> kz_api:server_id(JObj). --spec delete_keys(req(), ne_binaries()) -> req(). +-spec delete_keys(req(), kz_term:ne_binaries()) -> req(). delete_keys(?REQ_TYPE(JObj), Keys) -> ?REQ_TYPE(kz_json:delete_keys(Keys, JObj)). --spec set_values(req(), kz_proplist()) -> req(). +-spec set_values(req(), kz_term:proplist()) -> req(). set_values(?REQ_TYPE(JObj), Props) -> ?REQ_TYPE(kz_json:set_values(Props, JObj)). diff --git a/core/kazoo_amqp/src/api/kapi_pivot.erl b/core/kazoo_amqp/src/api/kapi_pivot.erl index 314003ea4ae..559e4b4b0fc 100644 --- a/core/kazoo_amqp/src/api/kapi_pivot.erl +++ b/core/kazoo_amqp/src/api/kapi_pivot.erl @@ -45,8 +45,8 @@ ]). -define(PIVOT_FAILED_TYPES, []). --spec req(api_terms()) -> {'ok', iolist()} | - {'error', string()}. +-spec req(kz_term:api_terms()) -> {'ok', iolist()} | + {'error', string()}. req(Prop) when is_list(Prop) -> case req_v(Prop) of 'false' -> {'error', "Proplist failed validation for pivot_req"}; @@ -55,14 +55,14 @@ req(Prop) when is_list(Prop) -> req(JObj) -> req(kz_json:to_proplist(JObj)). --spec req_v(api_terms()) -> boolean(). +-spec req_v(kz_term:api_terms()) -> boolean(). req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?PIVOT_REQ_HEADERS, ?PIVOT_REQ_VALUES, ?PIVOT_REQ_TYPES); req_v(JObj) -> req_v(kz_json:to_proplist(JObj)). --spec failed(api_terms()) -> {'ok', iolist()} | - {'error', string()}. +-spec failed(kz_term:api_terms()) -> {'ok', iolist()} | + {'error', string()}. failed(Prop) when is_list(Prop) -> case failed_v(Prop) of 'false' -> {'error', "Proplist failed validation for pivot_failed"}; @@ -71,18 +71,18 @@ failed(Prop) when is_list(Prop) -> failed(JObj) -> failed(kz_json:to_proplist(JObj)). --spec failed_v(api_terms()) -> boolean(). +-spec failed_v(kz_term:api_terms()) -> boolean(). failed_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?PIVOT_FAILED_HEADERS, ?PIVOT_FAILED_VALUES, ?PIVOT_FAILED_TYPES); failed_v(JObj) -> failed_v(kz_json:to_proplist(JObj)). --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, Props) -> Realm = props:get_value('realm', Props, <<"*">>), amqp_util:bind_q_to_callmgr(Queue, get_pivot_req_routing(Realm)). --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Queue, Props) -> Realm = props:get_value('realm', Props, <<"*">>), amqp_util:unbind_q_from_callmgr(Queue, get_pivot_req_routing(Realm)). @@ -101,8 +101,8 @@ get_pivot_req_routing(Realm) when is_binary(Realm) -> get_pivot_req_routing(Api) -> get_pivot_req_routing(get_from_realm(Api)). --spec publish_req(api_terms()) -> 'ok'. --spec publish_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_req(kz_term:api_terms()) -> 'ok'. +-spec publish_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_req(JObj) -> publish_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_req(Req, ContentType) -> @@ -110,12 +110,12 @@ publish_req(Req, ContentType) -> amqp_util:callmgr_publish(Payload, ContentType, get_pivot_req_routing(Req)). --spec publish_failed(ne_binary(), api_terms()) -> 'ok'. +-spec publish_failed(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. publish_failed(Target, JObj) -> {'ok', Payload} = kz_api:prepare_api_payload(JObj, ?PIVOT_FAILED_VALUES, fun failed/1), amqp_util:targeted_publish(Target, Payload). --spec get_from_realm(api_terms()) -> ne_binary(). +-spec get_from_realm(kz_term:api_terms()) -> kz_term:ne_binary(). get_from_realm(Prop) when is_list(Prop) -> kz_json:get_value(<<"From-Realm">>, props:get_value(<<"Call">>, Prop)); get_from_realm(JObj) -> diff --git a/core/kazoo_amqp/src/api/kapi_presence.erl b/core/kazoo_amqp/src/api/kapi_presence.erl index fd3b01e30c6..8fd8fb4fc4c 100644 --- a/core/kazoo_amqp/src/api/kapi_presence.erl +++ b/core/kazoo_amqp/src/api/kapi_presence.erl @@ -59,7 +59,7 @@ %% %% @end %%-------------------------------------------------------------------- --spec search_req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec search_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. search_req(Prop) when is_list(Prop) -> case search_req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?SEARCH_REQ_HEADERS, ?OPTIONAL_SEARCH_REQ_HEADERS); @@ -68,21 +68,21 @@ search_req(Prop) when is_list(Prop) -> search_req(JObj) -> search_req(kz_json:to_proplist(JObj)). --spec search_req_v(api_terms()) -> boolean(). +-spec search_req_v(kz_term:api_terms()) -> boolean(). search_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SEARCH_REQ_HEADERS, ?SEARCH_REQ_VALUES, ?SEARCH_REQ_TYPES); search_req_v(JObj) -> search_req_v(kz_json:to_proplist(JObj)). --spec publish_search_req(api_terms()) -> 'ok'. --spec publish_search_req(api_terms(), binary()) -> 'ok'. +-spec publish_search_req(kz_term:api_terms()) -> 'ok'. +-spec publish_search_req(kz_term:api_terms(), binary()) -> 'ok'. publish_search_req(JObj) -> publish_search_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_search_req(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?SEARCH_REQ_VALUES, fun search_req/1), amqp_util:presence_publish(search_req_routing_key(Req), Payload, ContentType). --spec search_req_routing_key(ne_binary() | api_terms()) -> ne_binary(). +-spec search_req_routing_key(kz_term:ne_binary() | kz_term:api_terms()) -> kz_term:ne_binary(). search_req_routing_key(Req) when is_list(Req) -> search_req_routing_key(props:get_value(<<"Realm">>, Req)); search_req_routing_key(Realm) when is_binary(Realm) -> @@ -95,7 +95,7 @@ search_req_routing_key(Req) -> %% %% @end %%-------------------------------------------------------------------- --spec search_partial_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec search_partial_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. search_partial_resp(Prop) when is_list(Prop) -> case search_partial_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?SEARCH_PARTIAL_RESP_HEADERS, ?OPTIONAL_SEARCH_PARTIAL_RESP_HEADERS); @@ -104,14 +104,14 @@ search_partial_resp(Prop) when is_list(Prop) -> search_partial_resp(JObj) -> search_partial_resp(kz_json:to_proplist(JObj)). --spec search_partial_resp_v(api_terms()) -> boolean(). +-spec search_partial_resp_v(kz_term:api_terms()) -> boolean(). search_partial_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SEARCH_PARTIAL_RESP_HEADERS, ?SEARCH_PARTIAL_RESP_VALUES, ?SEARCH_PARTIAL_RESP_TYPES); search_partial_resp_v(JObj) -> search_partial_resp_v(kz_json:to_proplist(JObj)). --spec publish_search_partial_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_search_partial_resp(ne_binary(), api_terms(), binary()) -> 'ok'. +-spec publish_search_partial_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_search_partial_resp(kz_term:ne_binary(), kz_term:api_terms(), binary()) -> 'ok'. publish_search_partial_resp(Queue, JObj) -> publish_search_partial_resp(Queue, JObj, ?DEFAULT_CONTENT_TYPE). publish_search_partial_resp(Queue, Resp, ContentType) -> @@ -123,7 +123,7 @@ publish_search_partial_resp(Queue, Resp, ContentType) -> %% %% @end %%-------------------------------------------------------------------- --spec search_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec search_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. search_resp(Prop) when is_list(Prop) -> case search_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?SEARCH_RESP_HEADERS, ?OPTIONAL_SEARCH_RESP_HEADERS); @@ -132,14 +132,14 @@ search_resp(Prop) when is_list(Prop) -> search_resp(JObj) -> search_resp(kz_json:to_proplist(JObj)). --spec search_resp_v(api_terms()) -> boolean(). +-spec search_resp_v(kz_term:api_terms()) -> boolean(). search_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SEARCH_RESP_HEADERS, ?SEARCH_RESP_VALUES, ?SEARCH_RESP_TYPES); search_resp_v(JObj) -> search_resp_v(kz_json:to_proplist(JObj)). --spec publish_search_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_search_resp(ne_binary(), api_terms(), binary()) -> 'ok'. +-spec publish_search_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_search_resp(kz_term:ne_binary(), kz_term:api_terms(), binary()) -> 'ok'. publish_search_resp(Queue, JObj) -> publish_search_resp(Queue, JObj, ?DEFAULT_CONTENT_TYPE). publish_search_resp(Queue, Resp, ContentType) -> @@ -151,7 +151,7 @@ publish_search_resp(Queue, Resp, ContentType) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec subscribe(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec subscribe(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. subscribe(Prop) when is_list(Prop) -> case subscribe_v(Prop) of 'true' -> kz_api:build_message(Prop, ?SUBSCRIBE_HEADERS, ?OPTIONAL_SUBSCRIBE_HEADERS); @@ -159,20 +159,20 @@ subscribe(Prop) when is_list(Prop) -> end; subscribe(JObj) -> subscribe(kz_json:to_proplist(JObj)). --spec subscribe_v(api_terms()) -> boolean(). +-spec subscribe_v(kz_term:api_terms()) -> boolean(). subscribe_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SUBSCRIBE_HEADERS, ?SUBSCRIBE_VALUES, ?SUBSCRIBE_TYPES); subscribe_v(JObj) -> subscribe_v(kz_json:to_proplist(JObj)). --spec publish_subscribe(api_terms()) -> 'ok'. --spec publish_subscribe(api_terms(), ne_binary()) -> 'ok'. +-spec publish_subscribe(kz_term:api_terms()) -> 'ok'. +-spec publish_subscribe(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_subscribe(JObj) -> publish_subscribe(JObj, ?DEFAULT_CONTENT_TYPE). publish_subscribe(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?SUBSCRIBE_VALUES, fun subscribe/1), amqp_util:presence_publish(subscribe_routing_key(Req), Payload, ContentType). --spec subscribe_routing_key(api_terms() | ne_binary()) -> ne_binary(). +-spec subscribe_routing_key(kz_term:api_terms() | kz_term:ne_binary()) -> kz_term:ne_binary(). subscribe_routing_key(Prop) when is_list(Prop) -> subscribe_routing_key(props:get_value(<<"User">>, Prop)); subscribe_routing_key(User) when is_binary(User) -> @@ -189,7 +189,7 @@ subscribe_routing_key(JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec update(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec update(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. update(Prop) when is_list(Prop) -> case update_v(Prop) of 'true' -> kz_api:build_message(Prop, ?UPDATE_HEADERS, ?OPTIONAL_UPDATE_HEADERS); @@ -197,21 +197,21 @@ update(Prop) when is_list(Prop) -> end; update(JObj) -> update(kz_json:to_proplist(JObj)). --spec update_v(api_terms()) -> boolean(). +-spec update_v(kz_term:api_terms()) -> boolean(). update_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?UPDATE_HEADERS, ?UPDATE_VALUES, ?UPDATE_TYPES); update_v(JObj) -> update_v(kz_json:to_proplist(JObj)). --spec publish_update(api_terms()) -> 'ok'. --spec publish_update(api_terms(), ne_binary()) -> 'ok'. +-spec publish_update(kz_term:api_terms()) -> 'ok'. +-spec publish_update(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_update(JObj) -> publish_update(JObj, ?DEFAULT_CONTENT_TYPE). publish_update(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?UPDATE_VALUES, fun update/1), amqp_util:presence_publish(update_routing_key(Req), Payload, ContentType). --spec update_routing_key(ne_binary() | api_terms()) -> ne_binary(). --spec update_routing_key(ne_binary(), ne_binary()) -> ne_binary(). +-spec update_routing_key(kz_term:ne_binary() | kz_term:api_terms()) -> kz_term:ne_binary(). +-spec update_routing_key(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). update_routing_key(Req) when is_list(Req) -> update_routing_key(props:get_value(<<"Call-ID">>, Req) ,props:get_value(<<"Presence-ID">>, Req) @@ -228,7 +228,7 @@ update_routing_key(CallId, PresenceID) -> ,amqp_util:encode(CallId) ]). --spec realm_from_presence_id(ne_binary()) -> ne_binary(). +-spec realm_from_presence_id(kz_term:ne_binary()) -> kz_term:ne_binary(). realm_from_presence_id(PresenceID) -> case binary:split(PresenceID, <<"@">>) of [_To, Realm] -> Realm; @@ -240,7 +240,7 @@ realm_from_presence_id(PresenceID) -> %% %% @end %%-------------------------------------------------------------------- --spec dialog(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec dialog(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. dialog(Prop) when is_list(Prop) -> case dialog_v(Prop) of 'true' -> kz_api:build_message(Prop, ?DIALOG_HEADERS, ?OPTIONAL_DIALOG_HEADERS); @@ -248,21 +248,21 @@ dialog(Prop) when is_list(Prop) -> end; dialog(JObj) -> dialog(kz_json:to_proplist(JObj)). --spec dialog_v(api_terms()) -> boolean(). +-spec dialog_v(kz_term:api_terms()) -> boolean(). dialog_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?DIALOG_HEADERS, ?DIALOG_VALUES, ?DIALOG_TYPES); dialog_v(JObj) -> dialog_v(kz_json:to_proplist(JObj)). --spec publish_dialog(api_terms()) -> 'ok'. --spec publish_dialog(api_terms(), ne_binary()) -> 'ok'. +-spec publish_dialog(kz_term:api_terms()) -> 'ok'. +-spec publish_dialog(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_dialog(JObj) -> publish_dialog(JObj, ?DEFAULT_CONTENT_TYPE). publish_dialog(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?DIALOG_VALUES, fun dialog/1), amqp_util:presence_publish(dialog_routing_key(Req), Payload, ContentType). --spec dialog_routing_key(ne_binary() | api_terms()) -> ne_binary(). --spec dialog_routing_key(ne_binary(), ne_binary()) -> ne_binary(). +-spec dialog_routing_key(kz_term:ne_binary() | kz_term:api_terms()) -> kz_term:ne_binary(). +-spec dialog_routing_key(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). dialog_routing_key(Req) when is_list(Req) -> dialog_routing_key(props:get_value(<<"Call-ID">>, Req) ,props:get_value(<<"Presence-ID">>, Req) @@ -284,7 +284,7 @@ dialog_routing_key(CallId, PresenceID) -> %% %% @end %%-------------------------------------------------------------------- --spec probe(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec probe(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. probe(Prop) when is_list(Prop) -> case probe_v(Prop) of 'true' -> kz_api:build_message(Prop, ?PROBE_HEADERS, ?OPTIONAL_PROBE_HEADERS); @@ -292,13 +292,13 @@ probe(Prop) when is_list(Prop) -> end; probe(JObj) -> probe(kz_json:to_proplist(JObj)). --spec probe_v(api_terms()) -> boolean(). +-spec probe_v(kz_term:api_terms()) -> boolean(). probe_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?PROBE_HEADERS, ?PROBE_VALUES, ?PROBE_TYPES); probe_v(JObj) -> probe_v(kz_json:to_proplist(JObj)). --spec publish_probe(api_terms()) -> 'ok'. --spec publish_probe(api_terms(), ne_binary()) -> 'ok'. +-spec publish_probe(kz_term:api_terms()) -> 'ok'. +-spec publish_probe(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_probe(JObj) -> publish_probe(JObj, ?DEFAULT_CONTENT_TYPE). publish_probe(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?PROBE_VALUES, fun probe/1), @@ -316,7 +316,7 @@ probe_routing_key(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec mwi_extended_update(kz_proplist()) -> kz_proplist(). +-spec mwi_extended_update(kz_term:proplist()) -> kz_term:proplist(). mwi_extended_update(Prop) -> MessagesNew = props:get_integer_value(<<"Messages-New">>, Prop, 0), MessagesWaiting = case MessagesNew of 0 -> <<"no">>; _ -> <<"yes">> end, @@ -336,7 +336,7 @@ mwi_extended_update(Prop) -> ,{<<"Call-ID">>, CallId} ]. --spec mwi_update(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec mwi_update(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. mwi_update(Prop) when is_list(Prop) -> case mwi_update_v(Prop) of 'true' -> kz_api:build_message(mwi_extended_update(Prop), ?MWI_REQ_HEADERS, ?OPTIONAL_MWI_REQ_HEADERS); @@ -344,19 +344,19 @@ mwi_update(Prop) when is_list(Prop) -> end; mwi_update(JObj) -> mwi_update(kz_json:to_proplist(JObj)). --spec mwi_update_v(api_terms()) -> boolean(). +-spec mwi_update_v(kz_term:api_terms()) -> boolean(). mwi_update_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?MWI_REQ_HEADERS, ?MWI_REQ_VALUES, ?MWI_REQ_TYPES); mwi_update_v(JObj) -> mwi_update_v(kz_json:to_proplist(JObj)). --spec publish_mwi_update(api_terms()) -> 'ok'. --spec publish_mwi_update(api_terms(), ne_binary()) -> 'ok'. +-spec publish_mwi_update(kz_term:api_terms()) -> 'ok'. +-spec publish_mwi_update(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_mwi_update(JObj) -> publish_mwi_update(JObj, ?DEFAULT_CONTENT_TYPE). publish_mwi_update(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?MWI_REQ_VALUES, fun mwi_update/1), amqp_util:presence_publish(mwi_update_routing_key(Req), Payload, ContentType). --spec mwi_update_routing_key(api_terms() | api_binary()) -> ne_binary(). +-spec mwi_update_routing_key(kz_term:api_terms() | kz_term:api_binary()) -> kz_term:ne_binary(). mwi_update_routing_key(Prop) when is_list(Prop) -> mwi_update_routing_key(props:get_value(<<"To">>, Prop)); mwi_update_routing_key(To) when is_binary(To) -> @@ -365,7 +365,7 @@ mwi_update_routing_key(To) when is_binary(To) -> mwi_update_routing_key(JObj) -> mwi_update_routing_key(kz_json:get_value(<<"To">>, JObj)). --spec mwi_update_routing_key(ne_binary(), ne_binary()) -> ne_binary(). +-spec mwi_update_routing_key(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). mwi_update_routing_key(User, Realm) -> list_to_binary([<<"mwi_updates.">> ,amqp_util:encode(Realm) @@ -373,7 +373,7 @@ mwi_update_routing_key(User, Realm) -> ,amqp_util:encode(User) ]). --spec mwi_unsolicited_update(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec mwi_unsolicited_update(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. mwi_unsolicited_update(Prop) when is_list(Prop) -> case mwi_unsolicited_update_v(Prop) of 'true' -> kz_api:build_message(Prop, ?MWI_REQ_HEADERS, ?OPTIONAL_MWI_REQ_HEADERS); @@ -381,19 +381,19 @@ mwi_unsolicited_update(Prop) when is_list(Prop) -> end; mwi_unsolicited_update(JObj) -> mwi_unsolicited_update(kz_json:to_proplist(JObj)). --spec mwi_unsolicited_update_v(api_terms()) -> boolean(). +-spec mwi_unsolicited_update_v(kz_term:api_terms()) -> boolean(). mwi_unsolicited_update_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?MWI_REQ_HEADERS, ?MWI_UNSOLICITED_REQ_VALUES, ?MWI_REQ_TYPES); mwi_unsolicited_update_v(JObj) -> mwi_unsolicited_update_v(kz_json:to_proplist(JObj)). --spec publish_unsolicited_mwi_update(api_terms()) -> 'ok'. --spec publish_unsolicited_mwi_update(api_terms(), ne_binary()) -> 'ok'. +-spec publish_unsolicited_mwi_update(kz_term:api_terms()) -> 'ok'. +-spec publish_unsolicited_mwi_update(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_unsolicited_mwi_update(JObj) -> publish_unsolicited_mwi_update(JObj, ?DEFAULT_CONTENT_TYPE). publish_unsolicited_mwi_update(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?MWI_UNSOLICITED_REQ_VALUES, fun mwi_unsolicited_update/1), amqp_util:presence_publish(mwi_unsolicited_update_routing_key(Req), Payload, ContentType). --spec mwi_unsolicited_update_routing_key(api_terms() | api_binary()) -> ne_binary(). +-spec mwi_unsolicited_update_routing_key(kz_term:api_terms() | kz_term:api_binary()) -> kz_term:ne_binary(). mwi_unsolicited_update_routing_key(Prop) when is_list(Prop) -> mwi_unsolicited_update_routing_key(props:get_value(<<"To">>, Prop)); mwi_unsolicited_update_routing_key(To) when is_binary(To) -> @@ -410,7 +410,7 @@ mwi_unsolicited_update_routing_key(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec mwi_query(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec mwi_query(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. mwi_query(Prop) when is_list(Prop) -> case mwi_query_v(Prop) of 'true' -> kz_api:build_message(Prop, ?MWI_QUERY_HEADERS, ?OPTIONAL_MWI_QUERY_HEADERS); @@ -418,19 +418,19 @@ mwi_query(Prop) when is_list(Prop) -> end; mwi_query(JObj) -> mwi_query(kz_json:to_proplist(JObj)). --spec mwi_query_v(api_terms()) -> boolean(). +-spec mwi_query_v(kz_term:api_terms()) -> boolean(). mwi_query_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?MWI_QUERY_HEADERS, ?MWI_QUERY_VALUES, ?MWI_QUERY_TYPES); mwi_query_v(JObj) -> mwi_query_v(kz_json:to_proplist(JObj)). --spec publish_mwi_query(api_terms()) -> 'ok'. --spec publish_mwi_query(api_terms(), ne_binary()) -> 'ok'. +-spec publish_mwi_query(kz_term:api_terms()) -> 'ok'. +-spec publish_mwi_query(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_mwi_query(JObj) -> publish_mwi_query(JObj, ?DEFAULT_CONTENT_TYPE). publish_mwi_query(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?MWI_QUERY_VALUES, fun mwi_query/1), amqp_util:presence_publish(mwi_query_routing_key(Req), Payload, ContentType). --spec mwi_query_routing_key(api_terms() | ne_binary()) -> ne_binary(). +-spec mwi_query_routing_key(kz_term:api_terms() | kz_term:ne_binary()) -> kz_term:ne_binary(). mwi_query_routing_key(Prop) when is_list(Prop) -> mwi_query_routing_key(props:get_value(<<"Realm">>, Prop)); mwi_query_routing_key(Realm) when is_binary(Realm) -> @@ -443,7 +443,7 @@ mwi_query_routing_key(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec register_overwrite(api_terms()) -> api_formatter_return(). +-spec register_overwrite(kz_term:api_terms()) -> api_formatter_return(). register_overwrite(Prop) when is_list(Prop) -> case register_overwrite_v(Prop) of 'true' -> kz_api:build_message(Prop, ?REGISTER_OVERWRITE_HEADERS, ?OPTIONAL_REGISTER_OVERWRITE_HEADERS); @@ -451,13 +451,13 @@ register_overwrite(Prop) when is_list(Prop) -> end; register_overwrite(JObj) -> register_overwrite(kz_json:to_proplist(JObj)). --spec register_overwrite_v(api_terms()) -> boolean(). +-spec register_overwrite_v(kz_term:api_terms()) -> boolean(). register_overwrite_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?REGISTER_OVERWRITE_HEADERS, ?REGISTER_OVERWRITE_VALUES, ?REGISTER_OVERWRITE_TYPES); register_overwrite_v(JObj) -> register_overwrite_v(kz_json:to_proplist(JObj)). --spec publish_register_overwrite(api_terms()) -> 'ok'. --spec publish_register_overwrite(api_terms(), ne_binary()) -> 'ok'. +-spec publish_register_overwrite(kz_term:api_terms()) -> 'ok'. +-spec publish_register_overwrite(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_register_overwrite(JObj) -> publish_register_overwrite(JObj, ?DEFAULT_CONTENT_TYPE). publish_register_overwrite(Req, ContentType) when is_list(Req) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?REGISTER_OVERWRITE_VALUES, fun register_overwrite/1), @@ -477,7 +477,7 @@ register_overwrite_routing_key(JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec reset(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec reset(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. reset(Prop) when is_list(Prop) -> case reset_v(Prop) of 'true' -> kz_api:build_message(Prop, ?RESET_HEADERS, ?OPTIONAL_RESET_HEADERS); @@ -486,22 +486,22 @@ reset(Prop) when is_list(Prop) -> reset(JObj) -> reset(kz_json:to_proplist(JObj)). --spec reset_v(api_terms()) -> boolean(). +-spec reset_v(kz_term:api_terms()) -> boolean(). reset_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?RESET_HEADERS, ?RESET_VALUES, ?RESET_TYPES); reset_v(JObj) -> reset_v(kz_json:to_proplist(JObj)). --spec publish_reset(api_terms()) -> 'ok'. --spec publish_reset(api_terms(), binary()) -> 'ok'. +-spec publish_reset(kz_term:api_terms()) -> 'ok'. +-spec publish_reset(kz_term:api_terms(), binary()) -> 'ok'. publish_reset(JObj) -> publish_reset(JObj, ?DEFAULT_CONTENT_TYPE). publish_reset(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?RESET_VALUES, fun reset/1), amqp_util:presence_publish(reset_routing_key(Req), Payload, ContentType). --spec reset_routing_key(ne_binary() | api_terms()) -> ne_binary(). --spec reset_routing_key(ne_binary(), ne_binary()) -> ne_binary(). +-spec reset_routing_key(kz_term:ne_binary() | kz_term:api_terms()) -> kz_term:ne_binary(). +-spec reset_routing_key(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). reset_routing_key(Req) when is_list(Req) -> reset_routing_key(props:get_value(<<"Realm">>, Req) ,props:get_value(<<"Username">>, Req) @@ -523,7 +523,7 @@ reset_routing_key(Realm, Username) when is_binary(Realm) -> %% %% @end %%-------------------------------------------------------------------- --spec flush(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec flush(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. flush(Prop) when is_list(Prop) -> case flush_v(Prop) of 'true' -> kz_api:build_message(Prop, ?FLUSH_HEADERS, ?OPTIONAL_FLUSH_HEADERS); @@ -531,13 +531,13 @@ flush(Prop) when is_list(Prop) -> end; flush(JObj) -> flush(kz_json:to_proplist(JObj)). --spec flush_v(api_terms()) -> boolean(). +-spec flush_v(kz_term:api_terms()) -> boolean(). flush_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?FLUSH_HEADERS, ?FLUSH_VALUES, ?FLUSH_TYPES); flush_v(JObj) -> flush_v(kz_json:to_proplist(JObj)). --spec publish_flush(api_terms()) -> 'ok'. --spec publish_flush(api_terms(), ne_binary()) -> 'ok'. +-spec publish_flush(kz_term:api_terms()) -> 'ok'. +-spec publish_flush(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_flush(JObj) -> publish_flush(JObj, ?DEFAULT_CONTENT_TYPE). publish_flush(Req, ContentType) -> @@ -549,7 +549,7 @@ publish_flush(Req, ContentType) -> %% %% @end %%-------------------------------------------------------------------- --spec sync(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec sync(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. sync(Prop) when is_list(Prop) -> case sync_v(Prop) of 'true' -> kz_api:build_message(Prop, ?SYNC_HEADERS, ?OPTIONAL_SYNC_HEADERS); @@ -557,13 +557,13 @@ sync(Prop) when is_list(Prop) -> end; sync(JObj) -> sync(kz_json:to_proplist(JObj)). --spec sync_v(api_terms()) -> boolean(). +-spec sync_v(kz_term:api_terms()) -> boolean(). sync_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SYNC_HEADERS, ?SYNC_VALUES, ?SYNC_TYPES); sync_v(JObj) -> sync_v(kz_json:to_proplist(JObj)). --spec publish_sync(api_terms()) -> 'ok'. --spec publish_sync(api_terms(), ne_binary()) -> 'ok'. +-spec publish_sync(kz_term:api_terms()) -> 'ok'. +-spec publish_sync(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_sync(JObj) -> publish_sync(JObj, ?DEFAULT_CONTENT_TYPE). publish_sync(Req, ContentType) -> @@ -575,12 +575,12 @@ publish_sync(Req, ContentType) -> %% %% @end %%-------------------------------------------------------------------- --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, Props) -> RestrictTo = props:get_value('restrict_to', Props), bind_q(Queue, RestrictTo, Props). --spec bind_q(ne_binary(), api_binaries(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:api_binaries(), kz_term:proplist()) -> 'ok'. bind_q(Queue, 'undefined', _) -> amqp_util:bind_q_to_presence(Queue, <<"#">>); bind_q(Queue, ['search_req'|Restrict], Props) -> @@ -647,12 +647,12 @@ bind_q(Queue, [_|Restrict], Props) -> bind_q(Queue, Restrict, Props); bind_q(_, [], _) -> 'ok'. --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Queue, Props) -> RestrictTo = props:get_value('restrict_to', Props), unbind_q(Queue, RestrictTo, Props). --spec unbind_q(ne_binary(), api_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:api_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Queue, 'undefined', _) -> amqp_util:unbind_q_from_presence(Queue, <<"#">>); unbind_q(Queue, ['search_req'|Restrict], Props) -> @@ -724,7 +724,7 @@ unbind_q(_, [], _) -> 'ok'. %% %% @end %%-------------------------------------------------------------------- --spec presence_states() -> ne_binaries(). +-spec presence_states() -> kz_term:ne_binaries(). presence_states() -> ?PRESENCE_STATES. %%-------------------------------------------------------------------- @@ -732,7 +732,7 @@ presence_states() -> ?PRESENCE_STATES. %% %% @end %%-------------------------------------------------------------------- --spec is_valid_state(api_binary() | api_terms()) -> boolean(). +-spec is_valid_state(kz_term:api_binary() | kz_term:api_terms()) -> boolean(). is_valid_state(State) when is_binary(State) -> lists:member(State, ?PRESENCE_STATES); is_valid_state(Prop) when is_list(Prop) -> diff --git a/core/kazoo_amqp/src/api/kapi_rate.erl b/core/kazoo_amqp/src/api/kapi_rate.erl index da8dfb74889..845c156a2a5 100644 --- a/core/kazoo_amqp/src/api/kapi_rate.erl +++ b/core/kazoo_amqp/src/api/kapi_rate.erl @@ -83,7 +83,7 @@ %% Takes proplist, creates JSON iolist or error %% @end %%-------------------------------------------------------------------- --spec req(api_terms()) -> +-spec req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. req(Prop) when is_list(Prop) -> @@ -94,7 +94,7 @@ req(Prop) when is_list(Prop) -> req(JObj) -> req(kz_json:to_proplist(JObj)). --spec req_v(api_terms()) -> boolean(). +-spec req_v(kz_term:api_terms()) -> boolean(). req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?RATE_REQ_HEADERS, ?RATE_REQ_VALUES, ?RATE_REQ_TYPES); req_v(JObj) -> @@ -105,7 +105,7 @@ req_v(JObj) -> %% Takes proplist, creates JSON iolist or error %% @end %%-------------------------------------------------------------------- --spec resp(api_terms()) -> +-spec resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. resp(Prop) when is_list(Prop) -> @@ -116,7 +116,7 @@ resp(Prop) when is_list(Prop) -> resp(JObj) -> resp(kz_json:to_proplist(JObj)). --spec resp_v(api_terms()) -> boolean(). +-spec resp_v(kz_term:api_terms()) -> boolean(). resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?RATE_RESP_HEADERS, ?RATE_RESP_VALUES, ?RATE_RESP_TYPES); resp_v(JObj) -> @@ -126,7 +126,7 @@ resp_v(JObj) -> %% @doc Setup and tear down bindings for rate gen_listeners %% @end %%-------------------------------------------------------------------- --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, Props) -> bind_to_q(Queue, props:get_value('restrict_to', Props)). @@ -143,7 +143,7 @@ bind_to_q(Q, [_|T]) -> bind_to_q(_Q, []) -> 'ok'. --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Q, Props) -> unbind_q_from(Q, props:get_value('restrict_to', Props)). @@ -173,24 +173,24 @@ declare_exchanges() -> %% @doc Publish the JSON iolist() to the proper Exchange %% @end %%-------------------------------------------------------------------- --spec publish_req(api_terms()) -> 'ok'. --spec publish_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_req(kz_term:api_terms()) -> 'ok'. +-spec publish_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_req(JObj) -> publish_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_req(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?RATE_REQ_VALUES, fun req/1), amqp_util:callmgr_publish(Payload, ContentType, ?KEY_RATE_REQ). --spec publish_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_resp(Queue, JObj) -> publish_resp(Queue, JObj, ?DEFAULT_CONTENT_TYPE). publish_resp(Queue, Resp, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Resp, ?RATE_RESP_VALUES, fun resp/1), amqp_util:targeted_publish(Queue, Payload, ContentType). --spec broadcast_resp(api_terms()) -> 'ok'. --spec broadcast_resp(api_terms(), ne_binary()) -> 'ok'. +-spec broadcast_resp(kz_term:api_terms()) -> 'ok'. +-spec broadcast_resp(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. broadcast_resp(JObj) -> broadcast_resp(JObj, ?DEFAULT_CONTENT_TYPE). broadcast_resp(Resp, ContentType) -> diff --git a/core/kazoo_amqp/src/api/kapi_registration.erl b/core/kazoo_amqp/src/api/kapi_registration.erl index 18317ce9f2a..9e742b47d90 100644 --- a/core/kazoo_amqp/src/api/kapi_registration.erl +++ b/core/kazoo_amqp/src/api/kapi_registration.erl @@ -122,7 +122,7 @@ %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec success(api_terms()) -> +-spec success(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. success(Prop) when is_list(Prop) -> @@ -132,7 +132,7 @@ success(Prop) when is_list(Prop) -> end; success(JObj) -> success(kz_json:to_proplist(JObj)). --spec success_v(api_terms()) -> boolean(). +-spec success_v(kz_term:api_terms()) -> boolean(). success_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?REG_SUCCESS_HEADERS, ?REG_SUCCESS_VALUES, ?REG_SUCCESS_TYPES); success_v(JObj) -> success_v(kz_json:to_proplist(JObj)). @@ -142,7 +142,7 @@ success_v(JObj) -> success_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec flush(api_terms()) -> +-spec flush(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. flush(Prop) when is_list(Prop) -> @@ -152,13 +152,13 @@ flush(Prop) when is_list(Prop) -> end; flush(JObj) -> flush(kz_json:to_proplist(JObj)). --spec flush_v(api_terms()) -> boolean(). +-spec flush_v(kz_term:api_terms()) -> boolean(). flush_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?REG_FLUSH_HEADERS, ?REG_FLUSH_VALUES, ?REG_FLUSH_TYPES); flush_v(JObj) -> flush_v(kz_json:to_proplist(JObj)). --spec sync(api_terms()) -> +-spec sync(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. sync(Prop) when is_list(Prop) -> @@ -168,7 +168,7 @@ sync(Prop) when is_list(Prop) -> end; sync(JObj) -> sync(kz_json:to_proplist(JObj)). --spec sync_v(api_terms()) -> boolean(). +-spec sync_v(kz_term:api_terms()) -> boolean(). sync_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?REG_SYNC_HEADERS, ?REG_SYNC_VALUES, ?REG_SYNC_TYPES); sync_v(JObj) -> sync_v(kz_json:to_proplist(JObj)). @@ -178,7 +178,7 @@ sync_v(JObj) -> sync_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec query_req(api_terms()) -> +-spec query_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. query_req(Prop) when is_list(Prop) -> @@ -188,7 +188,7 @@ query_req(Prop) when is_list(Prop) -> end; query_req(JObj) -> query_req(kz_json:to_proplist(JObj)). --spec query_req_v(api_terms()) -> boolean(). +-spec query_req_v(kz_term:api_terms()) -> boolean(). query_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?REG_QUERY_HEADERS, ?REG_QUERY_VALUES, ?REG_QUERY_TYPES); query_req_v(JObj) -> query_req_v(kz_json:to_proplist(JObj)). @@ -198,7 +198,7 @@ query_req_v(JObj) -> query_req_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec query_resp(api_terms()) -> +-spec query_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. query_resp(Prop) when is_list(Prop) -> @@ -208,7 +208,7 @@ query_resp(Prop) when is_list(Prop) -> end; query_resp(JObj) -> query_resp(kz_json:to_proplist(JObj)). --spec query_resp_v(api_terms()) -> boolean(). +-spec query_resp_v(kz_term:api_terms()) -> boolean(). query_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?REG_QUERY_RESP_HEADERS, ?REG_QUERY_RESP_VALUES, ?REG_QUERY_RESP_TYPES); query_resp_v(JObj) -> query_resp_v(kz_json:to_proplist(JObj)). @@ -218,7 +218,7 @@ query_resp_v(JObj) -> query_resp_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec query_err(api_terms()) -> +-spec query_err(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. query_err(Prop) when is_list(Prop) -> @@ -228,7 +228,7 @@ query_err(Prop) when is_list(Prop) -> end; query_err(JObj) -> query_err(kz_json:to_proplist(JObj)). --spec query_err_v(api_terms()) -> boolean(). +-spec query_err_v(kz_term:api_terms()) -> boolean(). query_err_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?REG_QUERY_ERR_HEADERS, ?REG_QUERY_ERR_VALUES, ?REG_QUERY_ERR_TYPES); query_err_v(JObj) -> query_err_v(kz_json:to_proplist(JObj)). @@ -237,7 +237,7 @@ query_err_v(JObj) -> query_err_v(kz_json:to_proplist(JObj)). %% @doc Setup and tear down bindings for authn gen_listeners %% @end %%-------------------------------------------------------------------- --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Q, Props) -> bind_q(Q, props:get_value('restrict_to', Props), Props). @@ -257,7 +257,7 @@ bind_q(Q, ['reg_flush'|T], Props) -> bind_q(Q, [_|T], Props) -> bind_q(Q, T, Props); bind_q(_, [], _) -> 'ok'. --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Q, Props) -> unbind_q(Q, props:get_value('restrict_to', Props), Props). @@ -290,8 +290,8 @@ declare_exchanges() -> %% @doc Publish the JSON iolist() to the proper Exchange %% @end %%-------------------------------------------------------------------- --spec publish_success(api_terms()) -> 'ok'. --spec publish_success(api_terms(), ne_binary()) -> 'ok'. +-spec publish_success(kz_term:api_terms()) -> 'ok'. +-spec publish_success(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_success(JObj) -> publish_success(JObj, ?DEFAULT_CONTENT_TYPE). publish_success(Success, ContentType) -> @@ -302,32 +302,32 @@ publish_success(Success, ContentType) -> %% @doc Publish the JSON iolist() to the proper Exchange %% @end %%-------------------------------------------------------------------- --spec publish_flush(api_terms()) -> 'ok'. --spec publish_flush(api_terms(), ne_binary()) -> 'ok'. +-spec publish_flush(kz_term:api_terms()) -> 'ok'. +-spec publish_flush(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_flush(JObj) -> publish_flush(JObj, ?DEFAULT_CONTENT_TYPE). publish_flush(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?REG_FLUSH_VALUES, fun flush/1), amqp_util:registrar_publish(get_flush_routing(API), Payload, ContentType). --spec publish_query_req(api_terms()) -> 'ok'. --spec publish_query_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_query_req(kz_term:api_terms()) -> 'ok'. +-spec publish_query_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_query_req(JObj) -> publish_query_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_query_req(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?REG_QUERY_VALUES, fun query_req/1), amqp_util:registrar_publish(get_query_routing(Req), Payload, ContentType). --spec publish_query_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_query_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_query_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_query_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_query_resp(Queue, JObj) -> publish_query_resp(Queue, JObj, ?DEFAULT_CONTENT_TYPE). publish_query_resp(Queue, Resp, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Resp, ?REG_QUERY_RESP_VALUES, fun query_resp/1), amqp_util:targeted_publish(Queue, Payload, ContentType). --spec publish_query_err(ne_binary(), api_terms()) -> 'ok'. --spec publish_query_err(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_query_err(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_query_err(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_query_err(Queue, JObj) -> publish_query_err(Queue, JObj, ?DEFAULT_CONTENT_TYPE). publish_query_err(Queue, Resp, ContentType) -> @@ -335,8 +335,8 @@ publish_query_err(Queue, Resp, ContentType) -> amqp_util:targeted_publish(Queue, Payload, ContentType). -spec publish_sync() -> 'ok'. --spec publish_sync(api_terms()) -> 'ok'. --spec publish_sync(api_terms(), ne_binary()) -> 'ok'. +-spec publish_sync(kz_term:api_terms()) -> 'ok'. +-spec publish_sync(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_sync() -> kz_amqp_worker:cast(kz_api:default_headers(<<"KAPI">>, <<"1.0">>), fun publish_sync/1). publish_sync(JObj) -> @@ -349,11 +349,11 @@ publish_sync(API, ContentType) -> %% @doc Special access to the API keys %% @end %%-------------------------------------------------------------------- --spec success_keys() -> ne_binaries(). +-spec success_keys() -> kz_term:ne_binaries(). success_keys() -> ?OPTIONAL_REG_SUCCESS_HEADERS ++ ?REG_SUCCESS_HEADERS. --spec get_success_routing(api_terms()) -> ne_binary(). +-spec get_success_routing(kz_term:api_terms()) -> kz_term:ne_binary(). get_success_routing(Prop) when is_list(Prop) -> User = props:get_value(<<"Username">>, Prop), Realm = props:get_value(<<"Realm">>, Prop), @@ -363,11 +363,11 @@ get_success_routing(JObj) -> Realm = kz_json:get_value(<<"Realm">>, JObj), get_success_routing(Realm, User). --spec get_success_routing(ne_binary(), ne_binary()) -> ne_binary(). +-spec get_success_routing(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). get_success_routing(Realm, User) -> list_to_binary([?KEY_REG_SUCCESS, ".", amqp_util:encode(Realm), ".", amqp_util:encode(User)]). --spec get_query_routing(api_terms()) -> ne_binary(). +-spec get_query_routing(kz_term:api_terms()) -> kz_term:ne_binary(). get_query_routing(Prop) when is_list(Prop) -> User = props:get_value(<<"Username">>, Prop), Realm = props:get_value(<<"Realm">>, Prop), @@ -377,7 +377,7 @@ get_query_routing(JObj) -> Realm = kz_json:get_value(<<"Realm">>, JObj), get_query_routing(Realm, User). --spec get_query_routing(ne_binary(), ne_binary()) -> ne_binary(). +-spec get_query_routing(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). get_query_routing(Realm, 'undefined') -> list_to_binary([?KEY_REG_QUERY, ".", amqp_util:encode(Realm), ".*"]); get_query_routing(Realm, User) -> diff --git a/core/kazoo_amqp/src/api/kapi_resource.erl b/core/kazoo_amqp/src/api/kapi_resource.erl index ff15e309e89..2294e399820 100644 --- a/core/kazoo_amqp/src/api/kapi_resource.erl +++ b/core/kazoo_amqp/src/api/kapi_resource.erl @@ -147,15 +147,15 @@ ]). -define(ORIGINATE_UUID_TYPES, []). --spec originate_ready(api_terms()) -> api_formatter_return(). --spec originate_ready_v(api_terms()) -> boolean(). +-spec originate_ready(kz_term:api_terms()) -> api_formatter_return(). +-spec originate_ready_v(kz_term:api_terms()) -> boolean(). originate_ready(API) -> kapi_dialplan:originate_ready(API). originate_ready_v(API) -> kapi_dialplan:originate_ready_v(API). --spec originate_execute(api_terms()) -> api_formatter_return(). --spec originate_execute_v(api_terms()) -> boolean(). +-spec originate_execute(kz_term:api_terms()) -> api_formatter_return(). +-spec originate_execute_v(kz_term:api_terms()) -> boolean(). originate_execute(API) -> kapi_dialplan:originate_execute(API). originate_execute_v(API) -> @@ -166,7 +166,7 @@ originate_execute_v(API) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec originate_req(api_terms()) -> api_formatter_return(). +-spec originate_req(kz_term:api_terms()) -> api_formatter_return(). originate_req(Prop) when is_list(Prop) -> EPs = [begin {'ok', EPProps} = originate_req_endpoint_headers(EP), @@ -182,19 +182,19 @@ originate_req(Prop) when is_list(Prop) -> originate_req(JObj) -> originate_req(kz_json:to_proplist(JObj)). --spec originate_req_v(api_terms()) -> boolean(). +-spec originate_req_v(kz_term:api_terms()) -> boolean(). originate_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?ORIGINATE_REQ_HEADERS, ?ORIGINATE_REQ_VALUES, ?ORIGINATE_REQ_TYPES); originate_req_v(JObj) -> originate_req_v(kz_json:to_proplist(JObj)). --spec originate_req_endpoint_headers(api_terms()) -> api_formatter_return(). +-spec originate_req_endpoint_headers(kz_term:api_terms()) -> api_formatter_return(). originate_req_endpoint_headers(Prop) when is_list(Prop) -> kz_api:build_message_specific_headers(Prop, ?ORIGINATE_REQ_ENDPOINT_HEADERS, ?OPTIONAL_ORIGINATE_REQ_ENDPOINT_HEADERS); originate_req_endpoint_headers(JObj) -> originate_req_endpoint_headers(kz_json:to_proplist(JObj)). --spec originate_req_endpoint_v(api_terms()) -> boolean(). +-spec originate_req_endpoint_v(kz_term:api_terms()) -> boolean(). originate_req_endpoint_v(Prop) when is_list(Prop) -> kz_api:validate_message(Prop, ?ORIGINATE_REQ_ENDPOINT_HEADERS, ?ORIGINATE_REQ_ENDPOINT_VALUES, ?ORIGINATE_REQ_ENDPOINT_TYPES); originate_req_endpoint_v(JObj) -> @@ -206,7 +206,7 @@ originate_req_endpoint_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec originate_resp(api_terms()) -> api_formatter_return(). +-spec originate_resp(kz_term:api_terms()) -> api_formatter_return(). originate_resp(Prop) when is_list(Prop) -> case originate_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?ORIGINATE_RESP_HEADERS, ?OPTIONAL_ORIGINATE_RESP_HEADERS); @@ -215,7 +215,7 @@ originate_resp(Prop) when is_list(Prop) -> originate_resp(JObj) -> originate_resp(kz_json:to_proplist(JObj)). --spec originate_resp_v(api_terms()) -> boolean(). +-spec originate_resp_v(kz_term:api_terms()) -> boolean(). originate_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?ORIGINATE_RESP_HEADERS, ?ORIGINATE_RESP_VALUES, ?ORIGINATE_RESP_TYPES); originate_resp_v(JObj) -> @@ -226,7 +226,7 @@ originate_resp_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec originate_started(api_terms()) -> api_formatter_return(). +-spec originate_started(kz_term:api_terms()) -> api_formatter_return(). originate_started(Prop) when is_list(Prop) -> case originate_started_v(Prop) of 'true' -> kz_api:build_message(Prop, ?ORIGINATE_STARTED_HEADERS, ?OPTIONAL_ORIGINATE_STARTED_HEADERS); @@ -235,7 +235,7 @@ originate_started(Prop) when is_list(Prop) -> originate_started(JObj) -> originate_started(kz_json:to_proplist(JObj)). --spec originate_started_v(api_terms()) -> boolean(). +-spec originate_started_v(kz_term:api_terms()) -> boolean(). originate_started_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?ORIGINATE_STARTED_HEADERS, ?ORIGINATE_STARTED_VALUES, ?ORIGINATE_STARTED_TYPES); originate_started_v(JObj) -> @@ -246,7 +246,7 @@ originate_started_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec originate_uuid(api_terms()) -> api_formatter_return(). +-spec originate_uuid(kz_term:api_terms()) -> api_formatter_return(). originate_uuid(Prop) when is_list(Prop) -> case originate_uuid_v(Prop) of 'true' -> kz_api:build_message(Prop, ?ORIGINATE_UUID_HEADERS, ?OPTIONAL_ORIGINATE_UUID_HEADERS); @@ -255,7 +255,7 @@ originate_uuid(Prop) when is_list(Prop) -> originate_uuid(JObj) -> originate_uuid(kz_json:to_proplist(JObj)). --spec originate_uuid_v(api_terms()) -> boolean(). +-spec originate_uuid_v(kz_term:api_terms()) -> boolean(). originate_uuid_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?ORIGINATE_UUID_HEADERS, ?ORIGINATE_UUID_VALUES, ?ORIGINATE_UUID_TYPES); originate_uuid_v(JObj) -> @@ -266,7 +266,7 @@ originate_uuid_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec eavesdrop_req(api_terms()) -> api_formatter_return(). +-spec eavesdrop_req(kz_term:api_terms()) -> api_formatter_return(). eavesdrop_req(Prop) when is_list(Prop) -> case eavesdrop_req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?EAVESDROP_REQ_HEADERS, ?OPTIONAL_EAVESDROP_REQ_HEADERS); @@ -275,7 +275,7 @@ eavesdrop_req(Prop) when is_list(Prop) -> eavesdrop_req(JObj) -> eavesdrop_req(kz_json:to_proplist(JObj)). --spec eavesdrop_req_v(api_terms()) -> boolean(). +-spec eavesdrop_req_v(kz_term:api_terms()) -> boolean(). eavesdrop_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?EAVESDROP_REQ_HEADERS, ?EAVESDROP_REQ_VALUES, ?EAVESDROP_REQ_TYPES); eavesdrop_req_v(JObj) -> @@ -286,7 +286,7 @@ eavesdrop_req_v(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec eavesdrop_resp(api_terms()) -> api_formatter_return(). +-spec eavesdrop_resp(kz_term:api_terms()) -> api_formatter_return(). eavesdrop_resp(Prop) when is_list(Prop) -> case eavesdrop_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?EAVESDROP_RESP_HEADERS, ?OPTIONAL_EAVESDROP_RESP_HEADERS); @@ -295,17 +295,17 @@ eavesdrop_resp(Prop) when is_list(Prop) -> eavesdrop_resp(JObj) -> eavesdrop_resp(kz_json:to_proplist(JObj)). --spec eavesdrop_resp_v(api_terms()) -> boolean(). +-spec eavesdrop_resp_v(kz_term:api_terms()) -> boolean(). eavesdrop_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?EAVESDROP_RESP_HEADERS, ?EAVESDROP_RESP_VALUES, ?EAVESDROP_RESP_TYPES); eavesdrop_resp_v(JObj) -> eavesdrop_resp_v(kz_json:to_proplist(JObj)). --spec is_valid_mode(ne_binary()) -> boolean(). +-spec is_valid_mode(kz_term:ne_binary()) -> boolean(). is_valid_mode(M) -> lists:member(M, ?EAVESDROP_VALID_MODES). --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, Prop) -> bind_q(Queue, Prop, props:get_value('restrict_to', Prop)). @@ -323,7 +323,7 @@ bind_q(Queue, Prop, [_|T]) -> bind_q(_, _, []) -> 'ok'. --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Queue, Prop) -> unbind_q(Queue, Prop, props:get_value('restrict_to', Prop)). @@ -350,48 +350,48 @@ unbind_q(_, _, []) -> declare_exchanges() -> amqp_util:callmgr_exchange(). --spec publish_originate_req(api_terms()) -> 'ok'. --spec publish_originate_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_originate_req(kz_term:api_terms()) -> 'ok'. +-spec publish_originate_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_originate_req(JObj) -> publish_originate_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_originate_req(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?ORIGINATE_REQ_VALUES, fun originate_req/1), amqp_util:callmgr_publish(Payload, ContentType, ?KEY_RESOURCE_REQ, [{'mandatory', 'true'}]). --spec publish_originate_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_originate_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_originate_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_originate_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_originate_resp(TargetQ, JObj) -> publish_originate_resp(TargetQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_originate_resp(TargetQ, Resp, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Resp, ?ORIGINATE_RESP_VALUES, fun originate_resp/1), amqp_util:targeted_publish(TargetQ, Payload, ContentType). --spec publish_originate_started(ne_binary(), api_terms()) -> 'ok'. --spec publish_originate_started(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_originate_started(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_originate_started(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_originate_started(TargetQ, JObj) -> publish_originate_started(TargetQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_originate_started(TargetQ, Resp, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Resp, ?ORIGINATE_STARTED_VALUES, fun originate_started/1), amqp_util:targeted_publish(TargetQ, Payload, ContentType). --spec publish_originate_uuid(ne_binary(), api_terms()) -> 'ok'. --spec publish_originate_uuid(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_originate_uuid(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_originate_uuid(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_originate_uuid(TargetQ, JObj) -> publish_originate_uuid(TargetQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_originate_uuid(TargetQ, Resp, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Resp, ?ORIGINATE_UUID_VALUES, fun originate_uuid/1), amqp_util:targeted_publish(TargetQ, Payload, ContentType). --spec publish_eavesdrop_req(api_terms()) -> 'ok'. --spec publish_eavesdrop_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_eavesdrop_req(kz_term:api_terms()) -> 'ok'. +-spec publish_eavesdrop_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_eavesdrop_req(JObj) -> publish_eavesdrop_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_eavesdrop_req(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?EAVESDROP_REQ_VALUES, fun eavesdrop_req/1), amqp_util:callmgr_publish(Payload, ContentType, ?KEY_EAVESDROP_REQ). --spec publish_eavesdrop_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_eavesdrop_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_eavesdrop_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_eavesdrop_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_eavesdrop_resp(TargetQ, JObj) -> publish_eavesdrop_resp(TargetQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_eavesdrop_resp(TargetQ, Resp, ContentType) -> diff --git a/core/kazoo_amqp/src/api/kapi_route.erl b/core/kazoo_amqp/src/api/kapi_route.erl index c9bd8fb3c47..f23e4b940d6 100644 --- a/core/kazoo_amqp/src/api/kapi_route.erl +++ b/core/kazoo_amqp/src/api/kapi_route.erl @@ -41,7 +41,7 @@ %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec req(api_terms()) -> +-spec req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. req(Prop) when is_list(Prop) -> @@ -51,12 +51,12 @@ req(Prop) when is_list(Prop) -> end; req(JObj) -> req(kz_json:to_proplist(JObj)). --spec req_v(api_terms()) -> boolean(). +-spec req_v(kz_term:api_terms()) -> boolean(). req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?ROUTE_REQ_HEADERS, ?ROUTE_REQ_VALUES, ?ROUTE_REQ_TYPES); req_v(JObj) -> req_v(kz_json:to_proplist(JObj)). --spec req_event_type() -> {ne_binary(), ne_binary()}. +-spec req_event_type() -> {kz_term:ne_binary(), kz_term:ne_binary()}. req_event_type() -> {?EVENT_CATEGORY, ?ROUTE_REQ_EVENT_NAME}. %%-------------------------------------------------------------------- @@ -64,7 +64,7 @@ req_event_type() -> {?EVENT_CATEGORY, ?ROUTE_REQ_EVENT_NAME}. %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec resp(api_terms()) -> +-spec resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. resp(Prop) when is_list(Prop) -> @@ -84,7 +84,7 @@ resp(Prop) when is_list(Prop) -> end; resp(JObj) -> resp(kz_json:to_proplist(JObj)). --spec resp_v(api_terms()) -> boolean(). +-spec resp_v(kz_term:api_terms()) -> boolean(). resp_v(Prop) when is_list(Prop) -> Valid = kz_api:validate(Prop, ?ROUTE_RESP_HEADERS, ?ROUTE_RESP_VALUES, ?ROUTE_RESP_TYPES), case props:get_value(<<"Method">>, Prop) of @@ -97,7 +97,7 @@ resp_v(Prop) when is_list(Prop) -> end; resp_v(JObj) -> resp_v(kz_json:to_proplist(JObj)). --spec is_actionable_resp(api_terms()) -> boolean(). +-spec is_actionable_resp(kz_term:api_terms()) -> boolean(). is_actionable_resp(Prop) when is_list(Prop) -> case props:get_value(<<"Method">>, Prop) of <<"bridge">> -> 'true'; @@ -116,7 +116,7 @@ is_actionable_resp(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec resp_route(api_terms()) -> +-spec resp_route(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. resp_route(Prop) when is_list(Prop) -> @@ -126,7 +126,7 @@ resp_route(Prop) when is_list(Prop) -> end; resp_route(JObj) -> resp_route(kz_json:to_proplist(JObj)). --spec resp_route_v(api_terms()) -> boolean(). +-spec resp_route_v(kz_term:api_terms()) -> boolean(). resp_route_v(Prop) when is_list(Prop) -> kz_api:validate_message(Prop, ?ROUTE_RESP_ROUTE_HEADERS, ?ROUTE_RESP_ROUTE_VALUES, ?ROUTE_RESP_ROUTE_TYPES); resp_route_v(JObj) -> resp_route_v(kz_json:to_proplist(JObj)). @@ -136,7 +136,7 @@ resp_route_v(JObj) -> resp_route_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec win(api_terms()) -> +-spec win(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. win(Prop) when is_list(Prop) -> @@ -146,7 +146,7 @@ win(Prop) when is_list(Prop) -> end; win(JObj) -> win(kz_json:to_proplist(JObj)). --spec win_v(api_terms()) -> boolean(). +-spec win_v(kz_term:api_terms()) -> boolean(). win_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?ROUTE_WIN_HEADERS, ?ROUTE_WIN_VALUES, ?ROUTE_WIN_TYPES); win_v(JObj) -> win_v(kz_json:to_proplist(JObj)). @@ -155,11 +155,11 @@ win_v(JObj) -> win_v(kz_json:to_proplist(JObj)). %% @doc Bind AMQP Queue for routing requests %% @end %%-------------------------------------------------------------------- --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, Props) -> bind_q(Queue, props:get_value('restrict_to', Props), Props). --spec bind_q(ne_binary(), list() | 'undefined', kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), list() | 'undefined', kz_term:proplist()) -> 'ok'. bind_q(Queue, 'undefined', Props) -> Keys = get_all_routing_keys(Props), lists:foreach(fun(Key) -> amqp_util:bind_q_to_callmgr(Queue, Key) end, Keys); @@ -175,11 +175,11 @@ bind_q(Queue, [_ | T], Props) -> bind_q(Queue, T, Props); bind_q(_, [], _) -> 'ok'. --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Queue, Props) -> unbind_q(Queue, props:get_value('restrict_to', Props), Props). --spec unbind_q(ne_binary(), list() | 'undefined', kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), list() | 'undefined', kz_term:proplist()) -> 'ok'. unbind_q(Queue, 'undefined', Props) -> Keys = get_all_routing_keys(Props), lists:foreach(fun(Key) -> amqp_util:unbind_q_from_callmgr(Queue, Key) end, Keys); @@ -218,15 +218,15 @@ get_account_routing_keys(Props) -> declare_exchanges() -> amqp_util:callmgr_exchange(). --spec get_route_req_account_routing(ne_binary(), ne_binary()) -> ne_binary(). +-spec get_route_req_account_routing(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). get_route_req_account_routing(Type, AccountId) -> list_to_binary([?KEY_ROUTE_REQ, ".", amqp_util:encode(Type), ".", amqp_util:encode(AccountId)]). --spec get_route_req_realm_routing(ne_binary(), ne_binary(), ne_binary()) -> ne_binary(). +-spec get_route_req_realm_routing(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). get_route_req_realm_routing(Type, Realm, User) -> list_to_binary([?KEY_ROUTE_REQ, ".", amqp_util:encode(Type), ".", amqp_util:encode(Realm), ".", amqp_util:encode(User)]). --spec get_route_req_routing(api_terms()) -> ne_binary(). +-spec get_route_req_routing(kz_term:api_terms()) -> kz_term:ne_binary(). get_route_req_routing(Api) -> {User, Realm} = get_auth_user_realm(Api), Type = resource_type(Api), @@ -235,24 +235,24 @@ get_route_req_routing(Api) -> AccountId -> get_route_req_account_routing(Type, AccountId) end. --spec publish_req(api_terms()) -> 'ok'. --spec publish_req(api_terms(), binary()) -> 'ok'. +-spec publish_req(kz_term:api_terms()) -> 'ok'. +-spec publish_req(kz_term:api_terms(), binary()) -> 'ok'. publish_req(JObj) -> publish_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_req(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?ROUTE_REQ_VALUES, fun req/1), amqp_util:callmgr_publish(Payload, ContentType, get_route_req_routing(Req)). --spec publish_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_resp(RespQ, JObj) -> publish_resp(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_resp(RespQ, Resp, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Resp, ?ROUTE_RESP_VALUES, fun resp/1), amqp_util:targeted_publish(RespQ, Payload, ContentType). --spec publish_win(ne_binary(), api_terms()) -> 'ok'. --spec publish_win(ne_binary(), api_terms(), binary()) -> 'ok'. +-spec publish_win(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_win(kz_term:ne_binary(), kz_term:api_terms(), binary()) -> 'ok'. publish_win(RespQ, JObj) -> publish_win(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_win(RespQ, Win, ContentType) -> @@ -266,7 +266,7 @@ publish_win(RespQ, Win, ContentType) -> %% when provided with an IP %% @end %%----------------------------------------------------------------------------- --spec get_auth_realm(api_terms()) -> ne_binary(). +-spec get_auth_realm(kz_term:api_terms()) -> kz_term:ne_binary(). get_auth_realm(ApiProp) when is_list(ApiProp) -> [_ReqUser, ReqDomain] = binary:split(props:get_value(<<"From">>, ApiProp), <<"@">>), ReqDomain; @@ -274,7 +274,7 @@ get_auth_realm(ApiJObj) -> [_ReqUser, ReqDomain] = binary:split(kz_json:get_value(<<"From">>, ApiJObj), <<"@">>), ReqDomain. --spec get_auth_user(api_terms()) -> ne_binary(). +-spec get_auth_user(kz_term:api_terms()) -> kz_term:ne_binary(). get_auth_user(ApiProp) when is_list(ApiProp) -> [ReqUser, _ReqDomain] = binary:split(props:get_value(<<"From">>, ApiProp), <<"@">>), ReqUser; @@ -282,7 +282,7 @@ get_auth_user(ApiJObj) -> [ReqUser, _ReqDomain] = binary:split(kz_json:get_value(<<"From">>, ApiJObj), <<"@">>), ReqUser. --spec get_auth_user_realm(api_terms()) -> {ne_binary(), ne_binary()}. +-spec get_auth_user_realm(kz_term:api_terms()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. get_auth_user_realm(ApiProp) when is_list(ApiProp) -> [ReqUser, ReqDomain] = binary:split(props:get_value(<<"From">>, ApiProp), <<"@">>), {ReqUser, ReqDomain}; @@ -290,7 +290,7 @@ get_auth_user_realm(ApiJObj) -> [ReqUser, ReqDomain] = binary:split(kz_json:get_value(<<"From">>, ApiJObj), <<"@">>), {ReqUser, ReqDomain}. --spec account_id(api_terms()) -> api_binary(). +-spec account_id(kz_term:api_terms()) -> kz_term:api_binary(). account_id(API) when is_list(API) -> account_id(kz_json:from_list(API)); account_id(API) -> @@ -300,21 +300,21 @@ account_id(API) -> ,API ). --spec resource_type(api_terms()) -> ne_binary(). +-spec resource_type(kz_term:api_terms()) -> kz_term:ne_binary(). resource_type(ApiProp) when is_list(ApiProp) -> props:get_value(<<"Resource-Type">>, ApiProp); resource_type(ApiJObj) -> kz_json:get_value(<<"Resource-Type">>, ApiJObj). --spec call_id(kz_json:object()) -> api_binary(). +-spec call_id(kz_json:object()) -> kz_term:api_binary(). call_id(JObj) -> kz_json:get_value(?KEY_CALL_ID, JObj). --spec fetch_id(kz_json:object()) -> api_binary(). +-spec fetch_id(kz_json:object()) -> kz_term:api_binary(). fetch_id(JObj) -> kz_json:get_value(?KEY_FETCH_ID, JObj). --spec control_queue(kz_json:object()) -> api_binary(). +-spec control_queue(kz_json:object()) -> kz_term:api_binary(). control_queue(JObj) -> kz_json:get_value(?KEY_CONTROL_QUEUE, JObj). diff --git a/core/kazoo_amqp/src/api/kapi_self.erl b/core/kazoo_amqp/src/api/kapi_self.erl index f892eb2e780..6f66374833e 100644 --- a/core/kazoo_amqp/src/api/kapi_self.erl +++ b/core/kazoo_amqp/src/api/kapi_self.erl @@ -14,11 +14,11 @@ -include_lib("amqp_util.hrl"). --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Q, _Props) -> amqp_util:bind_q_to_targeted(Q). --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Q, _Props) -> amqp_util:unbind_q_from_targeted(Q). @@ -31,15 +31,15 @@ unbind_q(Q, _Props) -> declare_exchanges() -> amqp_util:targeted_exchange(). --spec publish_message(ne_binary(), kz_json:object()) -> 'ok'. --spec publish_message(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_message(kz_term:ne_binary(), kz_json:object()) -> 'ok'. +-spec publish_message(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_message(ServerId, JObj) -> publish_message(ServerId, JObj, ?DEFAULT_CONTENT_TYPE). publish_message(ServerId, API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, [], fun build/1), amqp_util:targeted_publish(ServerId, Payload, ContentType). --spec build(api_terms()) -> {'ok', iolist()}. +-spec build(kz_term:api_terms()) -> {'ok', iolist()}. build(Prop) when is_list(Prop) -> kz_api:build_message(Prop, [], []); build(JObj) -> diff --git a/core/kazoo_amqp/src/api/kapi_sms.erl b/core/kazoo_amqp/src/api/kapi_sms.erl index 7b400a37074..74ad545acd8 100644 --- a/core/kazoo_amqp/src/api/kapi_sms.erl +++ b/core/kazoo_amqp/src/api/kapi_sms.erl @@ -204,7 +204,7 @@ -define(SMS_OUTBOUND_OPTIONS_KEY, [<<"outbound">>, <<"options">>]). -define(SMS_OUTBOUND_OPTIONS, kapps_config:get_json(<<"sms">>, ?SMS_OUTBOUND_OPTIONS_KEY, ?SMS_DEFAULT_OUTBOUND_OPTIONS)). --spec message(api_terms()) -> api_formatter_return(). +-spec message(kz_term:api_terms()) -> api_formatter_return(). message(Prop) when is_list(Prop) -> EPs = [begin {'ok', EPProps} = message_endpoint_headers(EP), @@ -221,27 +221,27 @@ message(Prop) when is_list(Prop) -> message(JObj) -> message(kz_json:to_proplist(JObj)). --spec message_v(api_terms()) -> boolean(). +-spec message_v(kz_term:api_terms()) -> boolean(). message_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SMS_REQ_HEADERS, ?SMS_REQ_VALUES, ?SMS_REQ_TYPES); message_v(JObj) -> message_v(kz_json:to_proplist(JObj)). --spec message_endpoint_headers(api_terms()) -> {'ok', kz_proplist()} | - {'error', string()}. +-spec message_endpoint_headers(kz_term:api_terms()) -> {'ok', kz_term:proplist()} | + {'error', string()}. message_endpoint_headers(Prop) when is_list(Prop) -> kz_api:build_message_specific_headers(Prop, ?SMS_REQ_ENDPOINT_HEADERS, ?OPTIONAL_SMS_REQ_ENDPOINT_HEADERS); message_endpoint_headers(JObj) -> message_endpoint_headers(kz_json:to_proplist(JObj)). --spec message_endpoint_v(api_terms()) -> boolean(). +-spec message_endpoint_v(kz_term:api_terms()) -> boolean(). message_endpoint_v(Prop) when is_list(Prop) -> kz_api:validate_message(Prop, ?SMS_REQ_ENDPOINT_HEADERS, ?SMS_REQ_ENDPOINT_VALUES, ?SMS_REQ_ENDPOINT_TYPES); message_endpoint_v(JObj) -> message_endpoint_v(kz_json:to_proplist(JObj)). --spec delivery(api_terms()) -> {'ok', iolist()} | - {'error', string()}. +-spec delivery(kz_term:api_terms()) -> {'ok', iolist()} | + {'error', string()}. delivery(Prop) when is_list(Prop) -> case delivery_v(Prop) of 'true' -> kz_api:build_message(Prop, ?DELIVERY_HEADERS, ?OPTIONAL_DELIVERY_HEADERS); @@ -249,13 +249,13 @@ delivery(Prop) when is_list(Prop) -> end; delivery(JObj) -> delivery(kz_json:to_proplist(JObj)). --spec delivery_v(api_terms()) -> boolean(). +-spec delivery_v(kz_term:api_terms()) -> boolean(). delivery_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?DELIVERY_HEADERS, ?DELIVERY_REQ_VALUES, ?DELIVERY_TYPES); delivery_v(JObj) -> delivery_v(kz_json:to_proplist(JObj)). --spec inbound(api_terms()) -> {'ok', iolist()} | - {'error', string()}. +-spec inbound(kz_term:api_terms()) -> {'ok', iolist()} | + {'error', string()}. inbound(Prop) when is_list(Prop) -> case inbound_v(Prop) of 'true' -> kz_api:build_message(Prop, ?INBOUND_HEADERS, ?OPTIONAL_INBOUND_HEADERS); @@ -263,13 +263,13 @@ inbound(Prop) when is_list(Prop) -> end; inbound(JObj) -> inbound(kz_json:to_proplist(JObj)). --spec inbound_v(api_terms()) -> boolean(). +-spec inbound_v(kz_term:api_terms()) -> boolean(). inbound_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?INBOUND_HEADERS, ?INBOUND_REQ_VALUES, ?INBOUND_TYPES); inbound_v(JObj) -> inbound_v(kz_json:to_proplist(JObj)). --spec outbound(api_terms()) -> {'ok', iolist()} | - {'error', string()}. +-spec outbound(kz_term:api_terms()) -> {'ok', iolist()} | + {'error', string()}. outbound(Prop) when is_list(Prop) -> case outbound_v(Prop) of 'true' -> kz_api:build_message(Prop, ?OUTBOUND_HEADERS, ?OPTIONAL_OUTBOUND_HEADERS); @@ -277,13 +277,13 @@ outbound(Prop) when is_list(Prop) -> end; outbound(JObj) -> outbound(kz_json:to_proplist(JObj)). --spec outbound_v(api_terms()) -> boolean(). +-spec outbound_v(kz_term:api_terms()) -> boolean(). outbound_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?OUTBOUND_HEADERS, ?OUTBOUND_REQ_VALUES, ?OUTBOUND_TYPES); outbound_v(JObj) -> outbound_v(kz_json:to_proplist(JObj)). --spec resume(api_terms()) -> {'ok', iolist()} | - {'error', string()}. +-spec resume(kz_term:api_terms()) -> {'ok', iolist()} | + {'error', string()}. resume(Prop) when is_list(Prop) -> case resume_v(Prop) of 'true' -> kz_api:build_message(Prop, ?RESUME_REQ_HEADERS, ?OPTIONAL_RESUME_REQ_HEADERS); @@ -291,7 +291,7 @@ resume(Prop) when is_list(Prop) -> end; resume(JObj) -> resume(kz_json:to_proplist(JObj)). --spec resume_v(api_terms()) -> boolean(). +-spec resume_v(kz_term:api_terms()) -> boolean(). resume_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?RESUME_REQ_HEADERS, ?RESUME_REQ_VALUES, ?RESUME_REQ_TYPES); resume_v(JObj) -> resume_v(kz_json:to_proplist(JObj)). @@ -300,14 +300,14 @@ resume_v(JObj) -> resume_v(kz_json:to_proplist(JObj)). %% @doc Bind AMQP Queue for routing requests %% @end %%-------------------------------------------------------------------- --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, Props) -> CallId = props:get_value('call_id', Props, props:get_value('message_id', Props, <<"*">>)), RouteId = ?LOWER(props:get_value('route_id', Props, <<"*">>)), Exchange = props:get_value('exchange', Props, ?SMS_EXCHANGE), bind_q(Exchange, Queue, CallId, RouteId, props:get_value('restrict_to', Props)). --spec bind_q(ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Exchange, Queue, CallId, RouteId, 'undefined') -> amqp_util:bind_q_to_exchange(Queue, ?SMS_ROUTING_KEY(RouteId,CallId), Exchange), amqp_util:bind_q_to_exchange(Queue, ?DELIVERY_ROUTING_KEY(CallId), Exchange), @@ -331,14 +331,14 @@ bind_q(Exchange, Queue, CallId, RouteId, ['outbound'|Restrict]) -> bind_q(Exchange, Queue, CallId, RouteId, Restrict); bind_q(_, _, _, _, []) -> 'ok'. --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Queue, Props) -> CallId = props:get_value('call_id', Props, props:get_value('message_id', Props, <<"*">>)), RouteId = ?LOWER(props:get_value('route_id', Props, <<"*">>)), Exchange = props:get_value('exchange', Props, ?SMS_EXCHANGE), unbind_q(Exchange, Queue, CallId, RouteId, props:get_value('restrict_to', Props)). --spec unbind_q(ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Exchange, Queue, CallId, RouteId, 'undefined') -> 'ok' = amqp_util:unbind_q_from_exchange(Queue, ?SMS_ROUTING_KEY(RouteId,CallId), Exchange), 'ok' = amqp_util:unbind_q_from_exchange(Queue, ?DELIVERY_ROUTING_KEY(CallId), Exchange), @@ -371,8 +371,8 @@ unbind_q(_, _, _, _, []) -> 'ok'. declare_exchanges() -> amqp_util:new_exchange(?SMS_EXCHANGE, <<"topic">>). --spec publish_message(api_terms()) -> 'ok'. --spec publish_message(api_terms(), binary()) -> 'ok'. +-spec publish_message(kz_term:api_terms()) -> 'ok'. +-spec publish_message(kz_term:api_terms(), binary()) -> 'ok'. publish_message(JObj) -> publish_message(JObj, ?DEFAULT_CONTENT_TYPE). publish_message(Req, ContentType) -> @@ -382,8 +382,8 @@ publish_message(Req, ContentType) -> Exchange = props:get_value(<<"Exchange-ID">>, Req, ?SMS_EXCHANGE), amqp_util:basic_publish(Exchange, ?SMS_ROUTING_KEY(RouteId, CallId), Payload, ContentType). --spec publish_inbound(api_terms()) -> 'ok'. --spec publish_inbound(api_terms(), binary()) -> 'ok'. +-spec publish_inbound(kz_term:api_terms()) -> 'ok'. +-spec publish_inbound(kz_term:api_terms(), binary()) -> 'ok'. publish_inbound(JObj) -> publish_inbound(JObj, ?DEFAULT_CONTENT_TYPE). publish_inbound(Req, ContentType) -> @@ -393,8 +393,8 @@ publish_inbound(Req, ContentType) -> Exchange = props:get_value(<<"Exchange-ID">>, Req, ?SMS_EXCHANGE), amqp_util:basic_publish(Exchange, ?INBOUND_ROUTING_KEY(RouteId, MessageId), Payload, ContentType). --spec publish_outbound(api_terms()) -> 'ok'. --spec publish_outbound(api_terms(), binary()) -> 'ok'. +-spec publish_outbound(kz_term:api_terms()) -> 'ok'. +-spec publish_outbound(kz_term:api_terms(), binary()) -> 'ok'. publish_outbound(JObj) -> publish_outbound(JObj, ?DEFAULT_CONTENT_TYPE). publish_outbound(Req, ContentType) -> @@ -406,8 +406,8 @@ publish_outbound(Req, ContentType) -> Opts = amqp_options(?SMS_OUTBOUND_OPTIONS), amqp_util:basic_publish(Exchange, RK, Payload, ContentType, Opts). --spec publish_delivery(api_terms()) -> 'ok'. --spec publish_delivery(api_terms(), binary()) -> 'ok'. +-spec publish_delivery(kz_term:api_terms()) -> 'ok'. +-spec publish_delivery(kz_term:api_terms(), binary()) -> 'ok'. publish_delivery(JObj) -> publish_delivery(JObj, ?DEFAULT_CONTENT_TYPE). publish_delivery(Req, ContentType) -> @@ -416,16 +416,16 @@ publish_delivery(Req, ContentType) -> Exchange = props:get_value(<<"Exchange-ID">>, Req, ?SMS_EXCHANGE), amqp_util:basic_publish(Exchange, ?DELIVERY_ROUTING_KEY(CallId), Payload, ContentType). --spec publish_targeted_delivery(ne_binary(), api_terms()) -> 'ok'. --spec publish_targeted_delivery(ne_binary(), api_terms(), binary()) -> 'ok'. +-spec publish_targeted_delivery(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_targeted_delivery(kz_term:ne_binary(), kz_term:api_terms(), binary()) -> 'ok'. publish_targeted_delivery(RespQ, JObj) -> publish_targeted_delivery(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_targeted_delivery(RespQ, JObj, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(JObj, ?DELIVERY_REQ_VALUES, fun delivery/1), amqp_util:targeted_publish(RespQ, Payload, ContentType). --spec publish_resume(api_terms() | ne_binary()) -> 'ok'. --spec publish_resume(api_terms(), binary()) -> 'ok'. +-spec publish_resume(kz_term:api_terms() | kz_term:ne_binary()) -> 'ok'. +-spec publish_resume(kz_term:api_terms(), binary()) -> 'ok'. publish_resume(SMS) when is_binary(SMS) -> Payload = [{<<"SMS-ID">>, SMS} | kz_api:default_headers(<<"API">>, <<"0.9.7">>) @@ -439,7 +439,7 @@ publish_resume(Req, ContentType) -> Exchange = props:get_value(<<"Exchange-ID">>, Req, ?SMS_EXCHANGE), amqp_util:basic_publish(Exchange, ?RESUME_ROUTING_KEY(CallId), Payload, ContentType). --spec amqp_options(api_object()) -> kz_proplist(). +-spec amqp_options(kz_term:api_object()) -> kz_term:proplist(). amqp_options('undefined') -> []; amqp_options(JObj) -> [{kz_term:to_atom(K, 'true'), V} diff --git a/core/kazoo_amqp/src/api/kapi_switch.erl b/core/kazoo_amqp/src/api/kapi_switch.erl index 1938eed1688..594fdc150e9 100644 --- a/core/kazoo_amqp/src/api/kapi_switch.erl +++ b/core/kazoo_amqp/src/api/kapi_switch.erl @@ -96,7 +96,7 @@ -define(FSREPLY_COMMAND_TYPES, []). %% Request a reload_acls --spec reload_acls(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec reload_acls(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. reload_acls(Prop) when is_list(Prop) -> case reload_acls_v(Prop) of 'true' -> kz_api:build_message(Prop, ?RELOAD_ACLS_HEADERS, ?OPTIONAL_RELOAD_ACLS_HEADERS); @@ -105,14 +105,14 @@ reload_acls(Prop) when is_list(Prop) -> reload_acls(JObj) -> reload_acls(kz_json:to_proplist(JObj)). --spec reload_acls_v(api_terms()) -> boolean(). +-spec reload_acls_v(kz_term:api_terms()) -> boolean(). reload_acls_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?RELOAD_ACLS_HEADERS, ?RELOAD_ACLS_VALUES, ?RELOAD_ACLS_TYPES); reload_acls_v(JObj) -> reload_acls_v(kz_json:to_proplist(JObj)). %% Request a reload_gateways --spec reload_gateways(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec reload_gateways(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. reload_gateways(Prop) when is_list(Prop) -> case reload_gateways_v(Prop) of 'true' -> kz_api:build_message(Prop, ?RELOAD_GATEWAYS_HEADERS, ?OPTIONAL_RELOAD_GATEWAYS_HEADERS); @@ -121,14 +121,14 @@ reload_gateways(Prop) when is_list(Prop) -> reload_gateways(JObj) -> reload_gateways(kz_json:to_proplist(JObj)). --spec reload_gateways_v(api_terms()) -> boolean(). +-spec reload_gateways_v(kz_term:api_terms()) -> boolean(). reload_gateways_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?RELOAD_GATEWAYS_HEADERS, ?RELOAD_GATEWAYS_VALUES, ?RELOAD_GATEWAYS_TYPES); reload_gateways_v(JObj) -> reload_gateways_v(kz_json:to_proplist(JObj)). %% Request a fs_xml_flush --spec fs_xml_flush(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec fs_xml_flush(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. fs_xml_flush(Prop) when is_list(Prop) -> case fs_xml_flush_v(Prop) of 'true' -> kz_api:build_message(Prop, ?FS_XML_FLUSH_HEADERS, ?OPTIONAL_FS_XML_FLUSH_HEADERS); @@ -137,14 +137,14 @@ fs_xml_flush(Prop) when is_list(Prop) -> fs_xml_flush(JObj) -> fs_xml_flush(kz_json:to_proplist(JObj)). --spec fs_xml_flush_v(api_terms()) -> boolean(). +-spec fs_xml_flush_v(kz_term:api_terms()) -> boolean(). fs_xml_flush_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?FS_XML_FLUSH_HEADERS, ?FS_XML_FLUSH_VALUES, ?FS_XML_FLUSH_TYPES); fs_xml_flush_v(JObj) -> fs_xml_flush_v(kz_json:to_proplist(JObj)). %% Request that fs send a NOTIFY message --spec notify(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec notify(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. notify(Prop) when is_list(Prop) -> case notify_v(Prop) of 'true' -> kz_api:build_message(Prop, ?NOTIFY_HEADERS, ?OPTIONAL_NOTIFY_HEADERS); @@ -153,14 +153,14 @@ notify(Prop) when is_list(Prop) -> notify(JObj) -> notify(kz_json:to_proplist(JObj)). --spec notify_v(api_terms()) -> boolean(). +-spec notify_v(kz_term:api_terms()) -> boolean(). notify_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?NOTIFY_HEADERS, ?NOTIFY_VALUES, ?NOTIFY_TYPES); notify_v(JObj) -> notify_v(kz_json:to_proplist(JObj)). %% Request a fs command --spec fs_command(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec fs_command(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. fs_command(Prop) when is_list(Prop) -> case fs_command_v(Prop) of 'true' -> kz_api:build_message(Prop, ?FS_COMMAND_HEADERS, ?OPTIONAL_FS_COMMAND_HEADERS); @@ -169,14 +169,14 @@ fs_command(Prop) when is_list(Prop) -> fs_command(JObj) -> fs_command(kz_json:to_proplist(JObj)). --spec fs_command_v(api_terms()) -> boolean(). +-spec fs_command_v(kz_term:api_terms()) -> boolean(). fs_command_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?FS_COMMAND_HEADERS, ?FS_COMMAND_VALUES, ?FS_COMMAND_TYPES); fs_command_v(JObj) -> fs_command_v(kz_json:to_proplist(JObj)). %% Reply to fs command --spec fs_reply(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec fs_reply(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. fs_reply(Prop) when is_list(Prop) -> case fs_reply_v(Prop) of 'true' -> kz_api:build_message(Prop, ?FSREPLY_COMMAND_HEADERS, ?OPTIONAL_FSREPLY_COMMAND_HEADERS); @@ -185,13 +185,13 @@ fs_reply(Prop) when is_list(Prop) -> fs_reply(JObj) -> fs_reply(kz_json:to_proplist(JObj)). --spec fs_reply_v(api_terms()) -> boolean(). +-spec fs_reply_v(kz_term:api_terms()) -> boolean(). fs_reply_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?FSREPLY_COMMAND_HEADERS, ?FSREPLY_COMMAND_VALUES, ?FSREPLY_COMMAND_TYPES); fs_reply_v(JObj) -> fs_reply_v(kz_json:to_proplist(JObj)). --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, Props) -> bind_to_q(Queue, props:get_value('restrict_to', Props), Props). @@ -217,7 +217,7 @@ bind_to_q(Q, ['command'|T], Props) -> bind_to_q(Q, T, Props); bind_to_q(_Q, [], _Props) -> 'ok'. --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Queue, Props) -> unbind_q_from(Queue, props:get_value('restrict_to', Props), Props). @@ -264,16 +264,16 @@ publish_reload_gateways() -> {'ok', Payload} = kz_api:prepare_api_payload(Defaults, ?RELOAD_GATEWAYS_VALUES, fun reload_gateways/1), amqp_util:basic_publish(?SWITCH_EXCHANGE, ?RELOAD_GATEWAYS_KEY, Payload, ?DEFAULT_CONTENT_TYPE). --spec publish_fs_xml_flush(api_terms()) -> 'ok'. --spec publish_fs_xml_flush(api_terms(), binary()) -> 'ok'. +-spec publish_fs_xml_flush(kz_term:api_terms()) -> 'ok'. +-spec publish_fs_xml_flush(kz_term:api_terms(), binary()) -> 'ok'. publish_fs_xml_flush(JObj) -> publish_fs_xml_flush(JObj, ?DEFAULT_CONTENT_TYPE). publish_fs_xml_flush(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?FS_XML_FLUSH_VALUES, fun fs_xml_flush/1), amqp_util:basic_publish(?SWITCH_EXCHANGE, ?FS_XML_FLUSH_KEY, Payload, ContentType). --spec publish_notify(api_terms()) -> 'ok'. --spec publish_notify(api_terms(), binary()) -> 'ok'. +-spec publish_notify(kz_term:api_terms()) -> 'ok'. +-spec publish_notify(kz_term:api_terms(), binary()) -> 'ok'. publish_notify(JObj) -> publish_notify(JObj, ?DEFAULT_CONTENT_TYPE). publish_notify(Req, ContentType) -> @@ -288,24 +288,24 @@ publish_notify(Req, ContentType) -> ,ContentType ). --spec notify_realm(api_terms()) -> api_binary(). +-spec notify_realm(kz_term:api_terms()) -> kz_term:api_binary(). notify_realm(Props) when is_list(Props) -> notify_value(Props, <<"Realm">>, fun props:get_value/2); notify_realm(JObj) -> notify_value(JObj, <<"Realm">>, fun kz_json:get_value/2). --spec notify_username(api_terms()) -> api_binary(). +-spec notify_username(kz_term:api_terms()) -> kz_term:api_binary(). notify_username(Props) when is_list(Props) -> notify_value(Props, <<"Username">>, fun props:get_value/2); notify_username(JObj) -> notify_value(JObj, <<"Username">>, fun kz_json:get_value/2). --spec notify_value(api_terms(), ne_binary(), fun()) -> api_binary(). +-spec notify_value(kz_term:api_terms(), kz_term:ne_binary(), fun()) -> kz_term:api_binary(). notify_value(API, Key, Get) -> Get(Key, API). --spec publish_command(api_terms()) -> 'ok'. --spec publish_command(api_terms(), binary()) -> 'ok'. +-spec publish_command(kz_term:api_terms()) -> 'ok'. +-spec publish_command(kz_term:api_terms(), binary()) -> 'ok'. publish_command(JObj) -> publish_command(JObj, ?DEFAULT_CONTENT_TYPE). publish_command(Req, ContentType) -> @@ -313,21 +313,21 @@ publish_command(Req, ContentType) -> N = check_fs_node(Req), amqp_util:basic_publish(?SWITCH_EXCHANGE, ?FS_COMMAND_KEY(N), Payload, ContentType). --spec publish_reply(binary(), api_terms()) -> 'ok'. +-spec publish_reply(binary(), kz_term:api_terms()) -> 'ok'. publish_reply(Queue, Req) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?FSREPLY_COMMAND_VALUES, fun fs_reply/1), amqp_util:targeted_publish(Queue, Payload). --spec check_fs_node(api_terms()) -> api_binary(). +-spec check_fs_node(kz_term:api_terms()) -> kz_term:api_binary(). check_fs_node(Props) -> get_value(Props, <<"FreeSWITCH-Node">>, <<"*">>). --spec get_value(api_terms(), kz_json:path(), ne_binary()) -> api_binary(). +-spec get_value(kz_term:api_terms(), kz_json:path(), kz_term:ne_binary()) -> kz_term:api_binary(). get_value(Props, Key, Default) when is_list(Props) -> get_value(Props, Key, fun props:get_value/3, Default); get_value(JObj, Key, Default) -> get_value(JObj, Key, fun kz_json:get_value/3, Default). --spec get_value(api_terms(), ne_binary(), fun(), ne_binary()) -> api_binary(). +-spec get_value(kz_term:api_terms(), kz_term:ne_binary(), fun(), kz_term:ne_binary()) -> kz_term:api_binary(). get_value(API, Key, Get, Default) -> Get(Key, API, Default). diff --git a/core/kazoo_amqp/src/api/kapi_sysconf.erl b/core/kazoo_amqp/src/api/kapi_sysconf.erl index 4acb7c22133..e0040cfd84e 100644 --- a/core/kazoo_amqp/src/api/kapi_sysconf.erl +++ b/core/kazoo_amqp/src/api/kapi_sysconf.erl @@ -79,7 +79,7 @@ %% READ %% @end %%-------------------------------------------------------------------- --spec get_req(api_terms()) -> +-spec get_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. get_req(Prop) when is_list(Prop) -> @@ -90,13 +90,13 @@ get_req(Prop) when is_list(Prop) -> get_req(JObj) -> get_req(kz_json:to_proplist(JObj)). --spec get_req_v(api_terms()) -> boolean(). +-spec get_req_v(kz_term:api_terms()) -> boolean(). get_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SYSCONF_GET_REQ_HEADERS, ?SYSCONF_GET_REQ_VALUES, ?SYSCONF_TYPES); get_req_v(JObj) -> get_req_v(kz_json:to_proplist(JObj)). --spec get_resp(api_terms()) -> +-spec get_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. get_resp(Prop) when is_list(Prop) -> @@ -107,7 +107,7 @@ get_resp(Prop) when is_list(Prop) -> get_resp(JObj) -> get_resp(kz_json:to_proplist(JObj)). --spec get_resp_v(api_terms()) -> boolean(). +-spec get_resp_v(kz_term:api_terms()) -> boolean(). get_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SYSCONF_GET_RESP_HEADERS, ?SYSCONF_GET_RESP_VALUES, ?SYSCONF_TYPES); get_resp_v(JObj) -> @@ -118,7 +118,7 @@ get_resp_v(JObj) -> %% WRITE %% @end %%-------------------------------------------------------------------- --spec set_req(api_terms()) -> +-spec set_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. set_req(Prop) when is_list(Prop) -> @@ -129,13 +129,13 @@ set_req(Prop) when is_list(Prop) -> set_req(JObj) -> set_req(kz_json:to_proplist(JObj)). --spec set_req_v(api_terms()) -> boolean(). +-spec set_req_v(kz_term:api_terms()) -> boolean(). set_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SYSCONF_SET_REQ_HEADERS, ?SYSCONF_SET_REQ_VALUES, ?SYSCONF_TYPES); set_req_v(JObj) -> set_req_v(kz_json:to_proplist(JObj)). --spec set_resp(api_terms()) -> +-spec set_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. set_resp(Prop) when is_list(Prop) -> @@ -146,7 +146,7 @@ set_resp(Prop) when is_list(Prop) -> set_resp(JObj) -> set_resp(kz_json:to_proplist(JObj)). --spec set_resp_v(api_terms()) -> boolean(). +-spec set_resp_v(kz_term:api_terms()) -> boolean(). set_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SYSCONF_SET_RESP_HEADERS, ?SYSCONF_SET_RESP_VALUES, ?SYSCONF_TYPES); set_resp_v(JObj) -> @@ -157,7 +157,7 @@ set_resp_v(JObj) -> %% Flush a given key %% @end %%-------------------------------------------------------------------- --spec flush_req(api_terms()) -> +-spec flush_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. flush_req(Prop) when is_list(Prop) -> @@ -168,13 +168,13 @@ flush_req(Prop) when is_list(Prop) -> flush_req(JObj) -> flush_req(kz_json:to_proplist(JObj)). --spec flush_req_v(api_terms()) -> boolean(). +-spec flush_req_v(kz_term:api_terms()) -> boolean(). flush_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?SYSCONF_FLUSH_REQ_HEADERS, ?SYSCONF_FLUSH_REQ_VALUES, ?SYSCONF_TYPES); flush_req_v(JObj) -> flush_req_v(kz_json:to_proplist(JObj)). --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Q, Prop) -> add_bindings(Q, props:get_value('restrict_to', Prop)). @@ -196,7 +196,7 @@ add_bindings(Q, [_|T]) -> add_bindings(_, []) -> 'ok'. --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Q, Prop) -> rm_bindings(Q, props:get_value('restrict_to', Prop)). @@ -227,16 +227,16 @@ rm_bindings(_, []) -> declare_exchanges() -> amqp_util:sysconf_exchange(). --spec publish_get_req(api_terms()) -> 'ok'. --spec publish_get_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_get_req(kz_term:api_terms()) -> 'ok'. +-spec publish_get_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_get_req(JObj) -> publish_get_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_get_req(Api, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Api, ?SYSCONF_GET_REQ_VALUES, fun get_req/1), amqp_util:sysconf_publish(routing_key_get(), Payload, ContentType). --spec publish_get_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_get_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_get_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_get_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_get_resp(RespQ, JObj) -> publish_get_resp(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_get_resp(RespQ, Api, ContentType) -> @@ -246,24 +246,24 @@ publish_get_resp(RespQ, Api, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Api, ?SYSCONF_GET_RESP_VALUES, PrepareOptions), amqp_util:targeted_publish(RespQ, Payload, ContentType). --spec publish_set_req(api_terms()) -> 'ok'. --spec publish_set_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_set_req(kz_term:api_terms()) -> 'ok'. +-spec publish_set_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_set_req(JObj) -> publish_set_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_set_req(Api, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Api, ?SYSCONF_SET_REQ_VALUES, fun set_req/1), amqp_util:sysconf_publish(routing_key_set(), Payload, ContentType). --spec publish_set_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_set_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_set_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_set_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_set_resp(RespQ, JObj) -> publish_set_resp(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_set_resp(RespQ, Api, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Api, ?SYSCONF_SET_RESP_VALUES, fun set_resp/1), amqp_util:targeted_publish(RespQ, Payload, ContentType). --spec publish_flush_req(api_terms()) -> 'ok'. --spec publish_flush_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_flush_req(kz_term:api_terms()) -> 'ok'. +-spec publish_flush_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_flush_req(JObj) -> publish_flush_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_flush_req(Api, ContentType) -> @@ -280,21 +280,21 @@ routing_key_flush() -> ?KEY_SYSCONF_FLUSH_REQ. --spec get_category(kz_json:object()) -> api_binary(). --spec get_category(kz_json:object(), Default) -> ne_binary() | Default. +-spec get_category(kz_json:object()) -> kz_term:api_binary(). +-spec get_category(kz_json:object(), Default) -> kz_term:ne_binary() | Default. get_category(JObj) -> get_category(JObj, 'undefined'). get_category(JObj, Default) -> kz_json:get_value(?CAT_KEY, JObj, Default). --spec get_key(kz_json:object()) -> api_binary(). --spec get_key(kz_json:object(), Default) -> ne_binary() | Default. +-spec get_key(kz_json:object()) -> kz_term:api_binary(). +-spec get_key(kz_json:object(), Default) -> kz_term:ne_binary() | Default. get_key(JObj) -> get_key(JObj, 'undefined'). get_key(JObj, Default) -> kz_json:get_value(?KEY_KEY, JObj, Default). --spec get_value(kz_json:object()) -> api_object(). +-spec get_value(kz_json:object()) -> kz_term:api_object(). -spec get_value(kz_json:object(), Default) -> kz_json:object() | Default. get_value(JObj) -> get_value(JObj, 'undefined'). diff --git a/core/kazoo_amqp/src/api/kapi_tasks.erl b/core/kazoo_amqp/src/api/kapi_tasks.erl index b9061ef69f7..56f524de03f 100644 --- a/core/kazoo_amqp/src/api/kapi_tasks.erl +++ b/core/kazoo_amqp/src/api/kapi_tasks.erl @@ -104,11 +104,11 @@ -define(TASKS_AMQP_KEY(SubKey), <<"tasks.", SubKey>>). --spec category(kz_json:object()) -> api_binary(). +-spec category(kz_json:object()) -> kz_term:api_binary(). category(JObj) -> kz_json:get_value(<<"Category">>, JObj). --spec action(kz_json:object()) -> api_binary(). +-spec action(kz_json:object()) -> kz_term:api_binary(). action(JObj) -> kz_json:get_value(<<"Action">>, JObj). @@ -116,26 +116,26 @@ action(JObj) -> task_id(JObj) -> kz_json:get_value(<<"Task-ID">>, JObj). --spec reply(kz_json:object()) -> kz_json:object() | ne_binary(). +-spec reply(kz_json:object()) -> kz_json:object() | kz_term:ne_binary(). reply(JObj) -> kz_json:get_value(<<"Reply">>, JObj). --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Q, Props) -> bind_to_q(Q, props:get_value('restrict_to', Props)). --spec bind_to_q(ne_binary(), atoms()) -> 'ok'. +-spec bind_to_q(kz_term:ne_binary(), kz_term:atoms()) -> 'ok'. bind_to_q(Q, 'undefined') -> 'ok' = amqp_util:bind_q_to_tasks(Q, ?TASKS_AMQP_KEY("*")); bind_to_q(_Q, []) -> 'ok'. --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Q, Props) -> unbind_from_q(Q, props:get_value('restrict_to', Props)). --spec unbind_from_q(ne_binary(), atoms()) -> 'ok'. +-spec unbind_from_q(kz_term:ne_binary(), kz_term:atoms()) -> 'ok'. unbind_from_q(Q, 'undefined') -> 'ok' = amqp_util:unbind_q_from_tasks(Q, ?TASKS_AMQP_KEY("*")); unbind_from_q(_Q, []) -> @@ -146,7 +146,7 @@ declare_exchanges() -> amqp_util:tasks_exchange(). --spec lookup_req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec lookup_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. lookup_req(Prop) when is_list(Prop) -> case lookup_req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?LOOKUP_REQ_HEADERS, ?OPTIONAL_LOOKUP_REQ_HEADERS); @@ -155,13 +155,13 @@ lookup_req(Prop) when is_list(Prop) -> lookup_req(JObj) -> lookup_req(kz_json:to_proplist(JObj)). --spec lookup_req_v(api_terms()) -> boolean(). +-spec lookup_req_v(kz_term:api_terms()) -> boolean(). lookup_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?LOOKUP_REQ_HEADERS, ?LOOKUP_REQ_VALUES, ?LOOKUP_REQ_TYPES); lookup_req_v(JObj) -> lookup_req_v(kz_json:to_proplist(JObj)). --spec lookup_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec lookup_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. lookup_resp(Prop) when is_list(Prop) -> case lookup_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?LOOKUP_RESP_HEADERS, ?OPTIONAL_LOOKUP_RESP_HEADERS); @@ -170,22 +170,22 @@ lookup_resp(Prop) when is_list(Prop) -> lookup_resp(JObj) -> lookup_resp(kz_json:to_proplist(JObj)). --spec lookup_resp_v(api_terms()) -> boolean(). +-spec lookup_resp_v(kz_term:api_terms()) -> boolean(). lookup_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?LOOKUP_RESP_HEADERS, ?LOOKUP_RESP_VALUES, ?LOOKUP_RESP_TYPES); lookup_resp_v(JObj) -> lookup_resp_v(kz_json:to_proplist(JObj)). --spec publish_lookup_req(api_terms()) -> 'ok'. --spec publish_lookup_req(api_terms(), binary()) -> 'ok'. +-spec publish_lookup_req(kz_term:api_terms()) -> 'ok'. +-spec publish_lookup_req(kz_term:api_terms(), binary()) -> 'ok'. publish_lookup_req(JObj) -> publish_lookup_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_lookup_req(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?LOOKUP_REQ_VALUES, fun lookup_req/1), amqp_util:tasks_publish(?TASKS_AMQP_KEY("lookup"), Payload, ContentType). --spec publish_lookup_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_lookup_resp(ne_binary(), api_terms(), binary()) -> 'ok'. +-spec publish_lookup_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_lookup_resp(kz_term:ne_binary(), kz_term:api_terms(), binary()) -> 'ok'. publish_lookup_resp(RespQ, JObj) -> publish_lookup_resp(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_lookup_resp(RespQ, JObj, ContentType) -> @@ -193,7 +193,7 @@ publish_lookup_resp(RespQ, JObj, ContentType) -> amqp_util:targeted_publish(RespQ, Payload, ContentType). --spec start_req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec start_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. start_req(Prop) when is_list(Prop) -> case start_req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?START_REQ_HEADERS, ?OPTIONAL_START_REQ_HEADERS); @@ -202,13 +202,13 @@ start_req(Prop) when is_list(Prop) -> start_req(JObj) -> start_req(kz_json:to_proplist(JObj)). --spec start_req_v(api_terms()) -> boolean(). +-spec start_req_v(kz_term:api_terms()) -> boolean(). start_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?START_REQ_HEADERS, ?START_REQ_VALUES, ?START_REQ_TYPES); start_req_v(JObj) -> start_req_v(kz_json:to_proplist(JObj)). --spec start_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec start_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. start_resp(Prop) when is_list(Prop) -> case start_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?START_RESP_HEADERS, ?OPTIONAL_START_RESP_HEADERS); @@ -217,22 +217,22 @@ start_resp(Prop) when is_list(Prop) -> start_resp(JObj) -> start_resp(kz_json:to_proplist(JObj)). --spec start_resp_v(api_terms()) -> boolean(). +-spec start_resp_v(kz_term:api_terms()) -> boolean(). start_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?START_RESP_HEADERS, ?START_RESP_VALUES, ?START_RESP_TYPES); start_resp_v(JObj) -> start_resp_v(kz_json:to_proplist(JObj)). --spec publish_start_req(api_terms()) -> 'ok'. --spec publish_start_req(api_terms(), binary()) -> 'ok'. +-spec publish_start_req(kz_term:api_terms()) -> 'ok'. +-spec publish_start_req(kz_term:api_terms(), binary()) -> 'ok'. publish_start_req(JObj) -> publish_start_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_start_req(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?START_REQ_VALUES, fun start_req/1), amqp_util:tasks_publish(?TASKS_AMQP_KEY("start"), Payload, ContentType). --spec publish_start_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_start_resp(ne_binary(), api_terms(), binary()) -> 'ok'. +-spec publish_start_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_start_resp(kz_term:ne_binary(), kz_term:api_terms(), binary()) -> 'ok'. publish_start_resp(RespQ, JObj) -> publish_start_resp(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_start_resp(RespQ, JObj, ContentType) -> @@ -240,7 +240,7 @@ publish_start_resp(RespQ, JObj, ContentType) -> amqp_util:targeted_publish(RespQ, Payload, ContentType). --spec stop_req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec stop_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. stop_req(Prop) when is_list(Prop) -> case stop_req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?STOP_REQ_HEADERS, ?OPTIONAL_STOP_REQ_HEADERS); @@ -249,13 +249,13 @@ stop_req(Prop) when is_list(Prop) -> stop_req(JObj) -> stop_req(kz_json:to_proplist(JObj)). --spec stop_req_v(api_terms()) -> boolean(). +-spec stop_req_v(kz_term:api_terms()) -> boolean(). stop_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?STOP_REQ_HEADERS, ?STOP_REQ_VALUES, ?STOP_REQ_TYPES); stop_req_v(JObj) -> stop_req_v(kz_json:to_proplist(JObj)). --spec stop_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec stop_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. stop_resp(Prop) when is_list(Prop) -> case stop_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?STOP_RESP_HEADERS, ?OPTIONAL_STOP_RESP_HEADERS); @@ -264,22 +264,22 @@ stop_resp(Prop) when is_list(Prop) -> stop_resp(JObj) -> stop_resp(kz_json:to_proplist(JObj)). --spec stop_resp_v(api_terms()) -> boolean(). +-spec stop_resp_v(kz_term:api_terms()) -> boolean(). stop_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?STOP_RESP_HEADERS, ?STOP_RESP_VALUES, ?STOP_RESP_TYPES); stop_resp_v(JObj) -> stop_resp_v(kz_json:to_proplist(JObj)). --spec publish_stop_req(api_terms()) -> 'ok'. --spec publish_stop_req(api_terms(), binary()) -> 'ok'. +-spec publish_stop_req(kz_term:api_terms()) -> 'ok'. +-spec publish_stop_req(kz_term:api_terms(), binary()) -> 'ok'. publish_stop_req(JObj) -> publish_stop_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_stop_req(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?STOP_REQ_VALUES, fun stop_req/1), amqp_util:tasks_publish(?TASKS_AMQP_KEY("stop"), Payload, ContentType). --spec publish_stop_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_stop_resp(ne_binary(), api_terms(), binary()) -> 'ok'. +-spec publish_stop_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_stop_resp(kz_term:ne_binary(), kz_term:api_terms(), binary()) -> 'ok'. publish_stop_resp(RespQ, JObj) -> publish_stop_resp(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_stop_resp(RespQ, JObj, ContentType) -> @@ -287,7 +287,7 @@ publish_stop_resp(RespQ, JObj, ContentType) -> amqp_util:targeted_publish(RespQ, Payload, ContentType). --spec remove_req(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec remove_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. remove_req(Prop) when is_list(Prop) -> case remove_req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?REMOVE_REQ_HEADERS, ?OPTIONAL_REMOVE_REQ_HEADERS); @@ -296,13 +296,13 @@ remove_req(Prop) when is_list(Prop) -> remove_req(JObj) -> remove_req(kz_json:to_proplist(JObj)). --spec remove_req_v(api_terms()) -> boolean(). +-spec remove_req_v(kz_term:api_terms()) -> boolean(). remove_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?REMOVE_REQ_HEADERS, ?REMOVE_REQ_VALUES, ?REMOVE_REQ_TYPES); remove_req_v(JObj) -> remove_req_v(kz_json:to_proplist(JObj)). --spec remove_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec remove_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. remove_resp(Prop) when is_list(Prop) -> case remove_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?REMOVE_RESP_HEADERS, ?OPTIONAL_REMOVE_RESP_HEADERS); @@ -311,22 +311,22 @@ remove_resp(Prop) when is_list(Prop) -> remove_resp(JObj) -> remove_resp(kz_json:to_proplist(JObj)). --spec remove_resp_v(api_terms()) -> boolean(). +-spec remove_resp_v(kz_term:api_terms()) -> boolean(). remove_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?REMOVE_RESP_HEADERS, ?REMOVE_RESP_VALUES, ?REMOVE_RESP_TYPES); remove_resp_v(JObj) -> remove_resp_v(kz_json:to_proplist(JObj)). --spec publish_remove_req(api_terms()) -> 'ok'. --spec publish_remove_req(api_terms(), binary()) -> 'ok'. +-spec publish_remove_req(kz_term:api_terms()) -> 'ok'. +-spec publish_remove_req(kz_term:api_terms(), binary()) -> 'ok'. publish_remove_req(JObj) -> publish_remove_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_remove_req(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?REMOVE_REQ_VALUES, fun remove_req/1), amqp_util:tasks_publish(?TASKS_AMQP_KEY("remove"), Payload, ContentType). --spec publish_remove_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_remove_resp(ne_binary(), api_terms(), binary()) -> 'ok'. +-spec publish_remove_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_remove_resp(kz_term:ne_binary(), kz_term:api_terms(), binary()) -> 'ok'. publish_remove_resp(RespQ, JObj) -> publish_remove_resp(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_remove_resp(RespQ, JObj, ContentType) -> diff --git a/core/kazoo_amqp/src/api/kapi_websockets.erl b/core/kazoo_amqp/src/api/kapi_websockets.erl index 3c19bc2f99e..4133254ac80 100644 --- a/core/kazoo_amqp/src/api/kapi_websockets.erl +++ b/core/kazoo_amqp/src/api/kapi_websockets.erl @@ -27,7 +27,7 @@ -export_type([bind_props/0]). --spec get_req(api_terms()) ->{'ok', iolist()} | {'error', string()}. +-spec get_req(kz_term:api_terms()) ->{'ok', iolist()} | {'error', string()}. get_req(Prop) when is_list(Prop) -> case get_req_v(Prop) of 'true' -> kz_api:build_message(Prop, ?WEBSOCKETS_GET_REQ_HEADERS, ?OPTIONAL_WEBSOCKETS_GET_REQ_HEADERS); @@ -41,7 +41,7 @@ get_req(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_req_v(api_terms()) -> boolean(). +-spec get_req_v(kz_term:api_terms()) -> boolean(). get_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?WEBSOCKETS_GET_REQ_HEADERS, ?WEBSOCKETS_GET_REQ_VALUES, ?WEBSOCKETS_TYPES); get_req_v(JObj) -> @@ -52,7 +52,7 @@ get_req_v(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_resp(api_terms()) -> {'ok', iolist()} | {'error', string()}. +-spec get_resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. get_resp(Prop) when is_list(Prop) -> case get_resp_v(Prop) of 'true' -> kz_api:build_message(Prop, ?WEBSOCKETS_GET_RESP_HEADERS, ?OPTIONAL_WEBSOCKETS_GET_RESP_HEADERS); @@ -66,15 +66,15 @@ get_resp(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_resp_v(api_terms()) -> boolean(). +-spec get_resp_v(kz_term:api_terms()) -> boolean(). get_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?WEBSOCKETS_GET_RESP_HEADERS, ?WEBSOCKETS_GET_RESP_VALUES, ?WEBSOCKETS_TYPES); get_resp_v(JObj) -> get_resp_v(kz_json:to_proplist(JObj)). --spec module_req(api_terms()) -> {'ok', iolist()} | - {'error', string()}. +-spec module_req(kz_term:api_terms()) -> {'ok', iolist()} | + {'error', string()}. module_req(Prop) when is_list(Prop) -> case module_req_v(Prop) of 'false' -> {'error', "Proplist failed validation for module_req"}; @@ -83,14 +83,14 @@ module_req(Prop) when is_list(Prop) -> module_req(JObj) -> module_req(kz_json:to_proplist(JObj)). --spec module_req_v(api_terms()) -> boolean(). +-spec module_req_v(kz_term:api_terms()) -> boolean(). module_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?MODULE_REQ_HEADERS, ?MODULE_REQ_VALUES, ?MODULE_REQ_TYPES); module_req_v(JObj) -> module_req_v(kz_json:to_proplist(JObj)). --spec module_resp(api_terms()) -> {'ok', iolist()} | - {'error', string()}. +-spec module_resp(kz_term:api_terms()) -> {'ok', iolist()} | + {'error', string()}. module_resp(Prop) when is_list(Prop) -> case module_resp_v(Prop) of 'false' -> {'error', "Proplist failed validation for module_resp"}; @@ -99,32 +99,32 @@ module_resp(Prop) when is_list(Prop) -> module_resp(JObj) -> module_resp(kz_json:to_proplist(JObj)). --spec module_resp_v(api_terms()) -> boolean(). +-spec module_resp_v(kz_term:api_terms()) -> boolean(). module_resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?MODULE_RESP_HEADERS, ?MODULE_RESP_VALUES, ?MODULE_RESP_TYPES); module_resp_v(JObj) -> module_resp_v(kz_json:to_proplist(JObj)). --spec bind_q(ne_binary(), bind_props()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), bind_props()) -> 'ok'. bind_q(Queue, Props) -> lists:foreach(fun(Restriction) -> add_restriction(Queue, Restriction) end ,props:get_value('restrict_to', Props, ?DEFAULT_RESTRICTIONS) ). --spec add_restriction(ne_binary(), restriction()) -> 'ok'. +-spec add_restriction(kz_term:ne_binary(), restriction()) -> 'ok'. add_restriction(Queue, 'get') -> amqp_util:bind_q_to_sysconf(Queue, ?KEY_WEBSOCKETS_GET_REQ); add_restriction(Queue, 'module_req') -> amqp_util:bind_q_to_kapps(Queue, ?MODULE_REQ_ROUTING_KEY). --spec unbind_q(ne_binary(), bind_props()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), bind_props()) -> 'ok'. unbind_q(Queue, Props) -> lists:foreach(fun(Restriction) -> remove_restriction(Queue, Restriction) end ,props:get_value('restrict_to', Props, ?DEFAULT_RESTRICTIONS) ). --spec remove_restriction(ne_binary(), restriction()) -> 'ok'. +-spec remove_restriction(kz_term:ne_binary(), restriction()) -> 'ok'. remove_restriction(Queue, 'get') -> amqp_util:unbind_q_from_sysconf(Queue, ?KEY_WEBSOCKETS_GET_REQ); remove_restriction(Queue, 'module_req') -> @@ -136,16 +136,16 @@ declare_exchanges() -> amqp_util:targeted_exchange(), amqp_util:sysconf_exchange(). --spec publish_module_req(api_terms()) -> 'ok'. --spec publish_module_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_module_req(kz_term:api_terms()) -> 'ok'. +-spec publish_module_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_module_req(API) -> publish_module_req(API, ?DEFAULT_CONTENT_TYPE). publish_module_req(API, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(API, ?MODULE_REQ_VALUES, fun module_req/1), amqp_util:kapps_publish(?MODULE_REQ_ROUTING_KEY, Payload, ContentType). --spec publish_module_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_module_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_module_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_module_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_module_resp(ServerId, API) -> publish_module_resp(ServerId, API, ?DEFAULT_CONTENT_TYPE). publish_module_resp(ServerId, API, ContentType) -> @@ -157,8 +157,8 @@ publish_module_resp(ServerId, API, ContentType) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec publish_get_req(api_terms()) -> 'ok'. --spec publish_get_req(api_terms(), ne_binary()) -> 'ok'. +-spec publish_get_req(kz_term:api_terms()) -> 'ok'. +-spec publish_get_req(kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_get_req(JObj) -> publish_get_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_get_req(Api, ContentType) -> @@ -170,8 +170,8 @@ publish_get_req(Api, ContentType) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec publish_get_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_get_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_get_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_get_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_get_resp(RespQ, JObj) -> publish_get_resp(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_get_resp(RespQ, Api, ContentType) -> diff --git a/core/kazoo_amqp/src/api/kz_api.erl b/core/kazoo_amqp/src/api/kz_api.erl index ecaa43133c7..241bbeb952c 100644 --- a/core/kazoo_amqp/src/api/kz_api.erl +++ b/core/kazoo_amqp/src/api/kz_api.erl @@ -72,71 +72,71 @@ %%%=================================================================== %%% API %%%=================================================================== --spec server_id(kz_json:object()) -> api_binary(). +-spec server_id(kz_json:object()) -> kz_term:api_binary(). server_id(JObj) -> kz_json:get_ne_binary_value(?KEY_SERVER_ID, JObj). --spec queue_id(kz_json:object()) -> api_binary(). +-spec queue_id(kz_json:object()) -> kz_term:api_binary(). queue_id(JObj) -> kz_json:get_ne_binary_value(?KEY_QUEUE_ID, JObj, server_id(JObj)). --spec event_category(kz_json:object()) -> api_binary(). +-spec event_category(kz_json:object()) -> kz_term:api_binary(). event_category(JObj) -> kz_json:get_value(?KEY_EVENT_CATEGORY, JObj). --spec event_name(kz_json:object()) -> api_binary(). +-spec event_name(kz_json:object()) -> kz_term:api_binary(). event_name(JObj) -> kz_json:get_value(?KEY_EVENT_NAME, JObj). --spec app_name(kz_json:object()) -> api_binary(). +-spec app_name(kz_json:object()) -> kz_term:api_binary(). app_name(JObj) -> kz_json:get_value(?KEY_APP_NAME, JObj). --spec app_version(kz_json:object()) -> api_binary(). +-spec app_version(kz_json:object()) -> kz_term:api_binary(). app_version(JObj) -> kz_json:get_value(?KEY_APP_VERSION, JObj). --spec node(kz_json:object()) -> api_ne_binary(). +-spec node(kz_json:object()) -> kz_term:api_ne_binary(). node(JObj) -> kz_json:get_ne_binary_value(?KEY_NODE, JObj). --spec msg_id(api_terms()) -> api_binary(). +-spec msg_id(kz_term:api_terms()) -> kz_term:api_binary(). msg_id(Props) when is_list(Props) -> props:get_value(?KEY_MSG_ID, Props); msg_id(JObj) -> kz_json:get_value(?KEY_MSG_ID, JObj). --spec msg_reply_id(api_terms()) -> api_binary(). +-spec msg_reply_id(kz_term:api_terms()) -> kz_term:api_binary(). msg_reply_id(Props) when is_list(Props) -> props:get_value(?KEY_MSG_REPLY_ID, Props, msg_id(Props)); msg_reply_id(JObj) -> kz_json:get_value(?KEY_MSG_REPLY_ID, JObj, msg_id(JObj)). --spec account_id(api_terms()) -> api_binary(). +-spec account_id(kz_term:api_terms()) -> kz_term:api_binary(). account_id(Props) when is_list(Props) -> props:get_value(?KEY_API_ACCOUNT_ID, Props); account_id(JObj) -> kz_json:get_value(?KEY_API_ACCOUNT_ID, JObj). --spec call_id(api_terms()) -> api_binary(). +-spec call_id(kz_term:api_terms()) -> kz_term:api_binary(). call_id(Props) when is_list(Props) -> props:get_value(?KEY_API_CALL_ID, Props); call_id(JObj) -> kz_json:get_value(?KEY_API_CALL_ID, JObj). --spec defer_response(api_terms()) -> api_binary(). +-spec defer_response(kz_term:api_terms()) -> kz_term:api_binary(). defer_response(Props) when is_list(Props) -> props:get_is_true(?KEY_DEFER_RESPONSE, Props); defer_response(JObj) -> kz_json:is_true(?KEY_DEFER_RESPONSE, JObj). --spec from_pid(api_terms()) -> api_binary(). +-spec from_pid(kz_term:api_terms()) -> kz_term:api_binary(). from_pid(Props) when is_list(Props) -> props:get_value(?KEY_REQUEST_FROM_PID, Props); from_pid(JObj) -> kz_json:get_value(?KEY_REQUEST_FROM_PID, JObj). --spec reply_to(api_terms()) -> api_binary(). +-spec reply_to(kz_term:api_terms()) -> kz_term:api_binary(). reply_to(Props) when is_list(Props) -> props:get_value(?KEY_REPLY_TO_PID, Props); reply_to(JObj) -> @@ -148,12 +148,12 @@ reply_to(JObj) -> %% All fields are required general headers. %% @end %%-------------------------------------------------------------------- --spec default_headers_v(api_terms()) -> boolean(). +-spec default_headers_v(kz_term:api_terms()) -> boolean(). --spec default_headers(ne_binary(), ne_binary()) -> kz_proplist(). --spec default_headers(api_binary(), ne_binary(), ne_binary()) -> kz_proplist(). --spec default_headers(api_binary(), ne_binary(), ne_binary(), ne_binary()) -> kz_proplist(). --spec default_headers(api_binary(), ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> kz_proplist(). +-spec default_headers(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:proplist(). +-spec default_headers(kz_term:api_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:proplist(). +-spec default_headers(kz_term:api_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:proplist(). +-spec default_headers(kz_term:api_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:proplist(). default_headers(AppName, AppVsn) -> default_headers('undefined', AppName, AppVsn). @@ -183,11 +183,11 @@ default_headers_v(Props) when is_list(Props) -> default_headers_v(JObj) -> default_headers_v(kz_json:to_proplist(JObj)). --spec default_header_v(ne_binary(), kz_proplist()) -> boolean(). +-spec default_header_v(kz_term:ne_binary(), kz_term:proplist()) -> boolean(). default_header_v(Header, Props) -> not kz_term:is_empty(props:get_value(Header, Props)). --spec disambiguate_and_publish(kz_json:object(), kz_json:object(), ne_binary() | atom()) -> any(). +-spec disambiguate_and_publish(kz_json:object(), kz_json:object(), kz_term:ne_binary() | atom()) -> any(). disambiguate_and_publish(ReqJObj, RespJObj, Binding) -> Wapi = list_to_binary([<<"kapi_">>, kz_term:to_binary(Binding)]), ApiMod = kz_term:to_atom(Wapi), @@ -199,14 +199,14 @@ disambiguate_and_publish(ReqJObj, RespJObj, Binding) -> %% validation definitions and remove any empty values %% @end %%-------------------------------------------------------------------- --type api_formatter_fun() :: fun((api_terms()) -> api_formatter_return()). +-type api_formatter_fun() :: fun((kz_term:api_terms()) -> api_formatter_return()). -type prepare_option_el() :: {'formatter', api_formatter_fun()} | {'remove_recursive', boolean()}. -type prepare_options() :: [prepare_option_el()]. --spec prepare_api_payload(api_terms(), kz_proplist()) -> api_formatter_return() | kz_proplist(). --spec prepare_api_payload(api_terms(), kz_proplist(), api_formatter_fun() | prepare_options()) -> - api_formatter_return() | kz_proplist(). +-spec prepare_api_payload(kz_term:api_terms(), kz_term:proplist()) -> api_formatter_return() | kz_term:proplist(). +-spec prepare_api_payload(kz_term:api_terms(), kz_term:proplist(), api_formatter_fun() | prepare_options()) -> + api_formatter_return() | kz_term:proplist(). prepare_api_payload(Prop, HeaderValues) -> prepare_api_payload(Prop, HeaderValues, []). @@ -229,7 +229,7 @@ prepare_api_payload(JObj, HeaderValues, Options) -> %% validation definitions %% @end %%-------------------------------------------------------------------- --spec set_missing_values(api_terms(), kz_proplist()) -> api_terms(). +-spec set_missing_values(kz_term:api_terms(), kz_term:proplist()) -> kz_term:api_terms(). set_missing_values(Prop, HeaderValues) when is_list(Prop) -> lists:foldl(fun({_, V}, PropAcc) when is_list(V) -> PropAcc; @@ -248,7 +248,7 @@ set_missing_values(JObj, HeaderValues) -> %% type given %% @end %%-------------------------------------------------------------------- --spec remove_empty_values(api_terms()) -> api_terms(). +-spec remove_empty_values(kz_term:api_terms()) -> kz_term:api_terms(). remove_empty_values(API) -> remove_empty_values(API, 'true'). @@ -291,7 +291,7 @@ is_empty(_) -> 'false'. %% @doc Extract just the default headers from a message %% @end %%-------------------------------------------------------------------- --spec extract_defaults(api_terms()) -> kz_proplist(). +-spec extract_defaults(kz_term:api_terms()) -> kz_term:proplist(). extract_defaults(Prop) when is_list(Prop) -> %% not measurable faster over the foldl, but cleaner (imo) [ {H, V} || H <- ?DEFAULT_HEADERS ++ ?OPTIONAL_DEFAULT_HEADERS, @@ -300,7 +300,7 @@ extract_defaults(Prop) when is_list(Prop) -> extract_defaults(JObj) -> extract_defaults(kz_json:to_proplist(JObj)). --spec remove_defaults(api_terms()) -> api_terms(). +-spec remove_defaults(kz_term:api_terms()) -> kz_term:api_terms(). remove_defaults(Prop) when is_list(Prop) -> props:delete_keys(?OPTIONAL_DEFAULT_HEADERS ,props:delete_keys(?DEFAULT_HEADERS, Prop) @@ -315,7 +315,7 @@ remove_defaults(JObj) -> %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec error_resp(api_terms()) -> api_formatter_return(). +-spec error_resp(kz_term:api_terms()) -> api_formatter_return(). error_resp(Prop) when is_list(Prop) -> case error_resp_v(Prop) of 'true' -> build_message(Prop, ?ERROR_RESP_HEADERS, ?OPTIONAL_ERROR_RESP_HEADERS); @@ -324,14 +324,14 @@ error_resp(Prop) when is_list(Prop) -> error_resp(JObj) -> error_resp(kz_json:to_proplist(JObj)). --spec error_resp_v(api_terms()) -> boolean(). +-spec error_resp_v(kz_term:api_terms()) -> boolean(). error_resp_v(Prop) when is_list(Prop) -> validate(Prop, ?ERROR_RESP_HEADERS, ?ERROR_RESP_VALUES, ?ERROR_RESP_TYPES); error_resp_v(JObj) -> error_resp_v(kz_json:to_proplist(JObj)). --spec publish_error(ne_binary(), api_terms()) -> 'ok'. --spec publish_error(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_error(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_error(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_error(TargetQ, JObj) -> publish_error(TargetQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_error(TargetQ, Error, ContentType) -> @@ -341,7 +341,7 @@ publish_error(TargetQ, Error, ContentType) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec validate(api_terms(), api_headers(), api_valid_values(), api_types()) -> boolean(). +-spec validate(kz_term:api_terms(), api_headers(), api_valid_values(), api_types()) -> boolean(). validate(Prop, ReqH, Vals, Types) when is_list(Prop) -> case has_all(Prop, ?DEFAULT_HEADERS) andalso validate_message(Prop, ReqH, Vals, Types) @@ -354,7 +354,7 @@ validate(Prop, ReqH, Vals, Types) when is_list(Prop) -> validate(JObj, ReqH, Vals, Types) -> validate(kz_json:to_proplist(JObj), ReqH, Vals, Types). --spec validate_message(api_terms(), api_headers(), kz_proplist(), kz_proplist()) -> boolean(). +-spec validate_message(kz_term:api_terms(), api_headers(), kz_term:proplist(), kz_term:proplist()) -> boolean(). validate_message(Prop, ReqH, Vals, Types) when is_list(Prop) -> has_all(Prop, ReqH) andalso values_check(Prop, Vals) @@ -362,7 +362,7 @@ validate_message(Prop, ReqH, Vals, Types) when is_list(Prop) -> validate_message(JObj, ReqH, Vals, Types) -> validate_message(kz_json:to_proplist(JObj), ReqH, Vals, Types). --spec build_message(api_terms(), api_headers(), api_headers()) -> api_formatter_return(). +-spec build_message(kz_term:api_terms(), api_headers(), api_headers()) -> api_formatter_return(). build_message(Prop, ReqH, OptH) when is_list(Prop) -> case defaults(Prop, ReqH ++ OptH) of {'error', _Reason}=Error -> @@ -379,8 +379,8 @@ build_message(Prop, ReqH, OptH) when is_list(Prop) -> build_message(JObj, ReqH, OptH) -> build_message(kz_json:to_proplist(JObj), ReqH, OptH). --spec build_message_specific_headers(kz_proplist() | {api_headers(), kz_proplist()}, api_headers(), api_headers()) -> - {'ok', kz_proplist()} | +-spec build_message_specific_headers(kz_term:proplist() | {api_headers(), kz_term:proplist()}, api_headers(), api_headers()) -> + {'ok', kz_term:proplist()} | {'error', string()}. build_message_specific_headers({Headers, Prop}, ReqH, OptH) -> case update_required_headers(Prop, ReqH, Headers) of @@ -396,7 +396,7 @@ build_message_specific_headers({Headers, Prop}, ReqH, OptH) -> build_message_specific_headers(Prop, ReqH, OptH) -> build_message_specific_headers({[], Prop}, ReqH, OptH). --spec build_message_specific(kz_proplist() | {api_headers(), kz_proplist()}, api_headers(), api_headers()) -> +-spec build_message_specific(kz_term:proplist() | {api_headers(), kz_term:proplist()}, api_headers(), api_headers()) -> api_formatter_return(). build_message_specific({Headers, Prop}, ReqH, OptH) -> case update_required_headers(Prop, ReqH, Headers) of @@ -412,7 +412,7 @@ build_message_specific({Headers, Prop}, ReqH, OptH) -> build_message_specific(Prop, ReqH, OptH) -> build_message_specific({[], Prop}, ReqH, OptH). --spec headers_to_json(kz_proplist()) -> api_formatter_return(). +-spec headers_to_json(kz_term:proplist()) -> api_formatter_return(). headers_to_json([_|_]=HeadersProp) -> _ = kz_util:kz_log_md_put('msg_id', msg_id(HeadersProp)), try kz_json:encode(kz_json:from_list(HeadersProp)) of @@ -424,8 +424,8 @@ headers_to_json([_|_]=HeadersProp) -> %% Checks Prop for all default headers, throws error if one is missing %% defaults(PassedProps, MessageHeaders) -> { Headers, NewPropList } | {error, Reason} --spec defaults(api_terms(), api_headers()) -> - {kz_proplist(), kz_proplist()} | +-spec defaults(kz_term:api_terms(), api_headers()) -> + {kz_term:proplist(), kz_term:proplist()} | {'error', string()}. defaults(Prop, MsgHeaders) -> defaults(Prop, expand_headers(MsgHeaders), []). defaults(Prop, MsgHeaders, Headers) -> @@ -436,18 +436,18 @@ defaults(Prop, MsgHeaders, Headers) -> update_optional_headers(Prop1, ?OPTIONAL_DEFAULT_HEADERS -- MsgHeaders, Headers1) end. --spec expand_headers(list()) -> ne_binaries(). +-spec expand_headers(list()) -> kz_term:ne_binaries(). expand_headers(Headers) -> lists:foldr(fun expand_header/2, [], Headers). --spec expand_header(ne_binary() | ne_binaries(), ne_binaries()) -> ne_binaries(). +-spec expand_header(kz_term:ne_binary() | kz_term:ne_binaries(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). expand_header(Header, Acc) when is_binary(Header) -> [Header | Acc]; expand_header(Headers, Acc) when is_list(Headers) -> expand_headers(Headers) ++ Acc. --spec update_required_headers(kz_proplist(), api_headers(), kz_proplist()) -> - {kz_proplist(), kz_proplist()} | +-spec update_required_headers(kz_term:proplist(), api_headers(), kz_term:proplist()) -> + {kz_term:proplist(), kz_term:proplist()} | {'error', string()}. update_required_headers(Prop, Fields, Headers) -> case has_all(Prop, Fields) of @@ -455,8 +455,8 @@ update_required_headers(Prop, Fields, Headers) -> 'false' -> {'error', "All required headers not defined"} end. --spec update_optional_headers(kz_proplist(), api_headers(), kz_proplist()) -> - {kz_proplist(), kz_proplist()}. +-spec update_optional_headers(kz_term:proplist(), api_headers(), kz_term:proplist()) -> + {kz_term:proplist(), kz_term:proplist()}. update_optional_headers(Prop, Fields, Headers) -> case has_any(Prop, Fields) of 'true' -> add_optional_headers(Prop, Fields, Headers); @@ -464,8 +464,8 @@ update_optional_headers(Prop, Fields, Headers) -> end. %% add [Header] from Prop to HeadProp --spec add_headers(kz_proplist(), api_headers(), kz_proplist()) -> - {kz_proplist(), kz_proplist()}. +-spec add_headers(kz_term:proplist(), api_headers(), kz_term:proplist()) -> + {kz_term:proplist(), kz_term:proplist()}. add_headers(Prop, Fields, Headers) -> lists:foldl(fun(K, {Headers1, KVs}) when is_list(K) -> K1 = [Ki || Ki <- K, props:is_defined(Ki, KVs)], @@ -474,8 +474,8 @@ add_headers(Prop, Fields, Headers) -> {[{K, props:get_value(K, KVs)} | Headers1], props:delete(K, KVs)} end, {Headers, Prop}, Fields). --spec add_optional_headers(kz_proplist(), api_headers(), kz_proplist()) -> - {kz_proplist(), kz_proplist()}. +-spec add_optional_headers(kz_term:proplist(), api_headers(), kz_term:proplist()) -> + {kz_term:proplist(), kz_term:proplist()}. add_optional_headers(Prop, Fields, Headers) -> lists:foldl(fun(K, {Headers1, KVs}) -> case props:get_value(K, KVs) of @@ -485,11 +485,11 @@ add_optional_headers(Prop, Fields, Headers) -> end, {Headers, Prop}, Fields). %% Checks Prop against a list of required headers, returns true | false --spec has_all(kz_proplist(), api_headers()) -> boolean(). +-spec has_all(kz_term:proplist(), api_headers()) -> boolean(). has_all(Prop, Headers) -> lists:all(fun(Header) -> has_all_header(Header, Prop) end, Headers). --spec has_all_header(api_headers(), kz_proplist()) -> boolean(). +-spec has_all_header(api_headers(), kz_term:proplist()) -> boolean(). has_all_header(Headers, Prop) when is_list(Headers) -> case has_any(Prop, Headers) of 'true' -> 'true'; @@ -506,17 +506,17 @@ has_all_header(Header, Prop) when is_binary(Header) -> end. %% Checks Prop against a list of optional headers, returns true | false if at least one if found --spec has_any(kz_proplist(), api_headers()) -> boolean(). +-spec has_any(kz_term:proplist(), api_headers()) -> boolean(). has_any(Prop, Headers) -> lists:any(fun(Header) -> props:is_defined(Header, Prop) end, Headers). %% checks Prop against a list of values to ensure known key/value pairs are correct (like Event-Category %% and Event-Name). We don't care if a key is defined in Values and not in Prop; that is handled by has_all/1 --spec values_check(kz_proplist(), kz_proplist()) -> boolean(). +-spec values_check(kz_term:proplist(), kz_term:proplist()) -> boolean(). values_check(Prop, Values) -> lists:all(fun(Value) -> values_check_all(Prop, Value) end, Values). --spec values_check_all(kz_proplist(), {any(), any()}) -> boolean(). +-spec values_check_all(kz_term:proplist(), {any(), any()}) -> boolean(). values_check_all(Prop, {Key, Vs}) when is_list(Vs) -> case props:get_value(Key, Prop) of 'undefined' -> 'true'; % isn't defined in Prop, has_all will error if req'd @@ -541,13 +541,13 @@ values_check_all(Prop, {Key, V}) -> %% checks Prop against a list of {Key, Fun}, running the value of Key through Fun, which returns a %% boolean. --type typecheck() :: {ne_binary(), fun((_) -> boolean())}. +-type typecheck() :: {kz_term:ne_binary(), fun((_) -> boolean())}. -type typechecks() :: [typecheck()]. --spec type_check(kz_proplist(), typechecks()) -> boolean(). +-spec type_check(kz_term:proplist(), typechecks()) -> boolean(). type_check(Prop, Types) -> lists:all(fun(Type) -> type_check_all(Prop, Type) end, Types). --spec type_check_all(kz_proplist(), typecheck()) -> boolean(). +-spec type_check_all(kz_term:proplist(), typecheck()) -> boolean(). type_check_all(Prop, {Key, Fun}) -> case props:get_value(Key, Prop) of %% isn't defined in Prop, has_all will error if req'd @@ -572,13 +572,13 @@ is_federated_event(JObj) -> _Broker -> 'true' end. --spec event_zone(kz_json:object()) -> ne_binary(). +-spec event_zone(kz_json:object()) -> kz_term:ne_binary(). event_zone(JObj) -> kz_json:get_ne_binary_value(?KEY_AMQP_ZONE, JObj). --type exec_fun_1() :: fun((api_terms()) -> api_terms()). --type exec_fun_2() :: {fun((_, api_terms()) -> api_terms()), _}. --type exec_fun_3() :: {fun((_, _, api_terms()) -> api_terms()), _, _}. +-type exec_fun_1() :: fun((kz_term:api_terms()) -> kz_term:api_terms()). +-type exec_fun_2() :: {fun((_, kz_term:api_terms()) -> kz_term:api_terms()), _}. +-type exec_fun_3() :: {fun((_, _, kz_term:api_terms()) -> kz_term:api_terms()), _, _}. -type exec_fun() :: exec_fun_1() | exec_fun_2() | exec_fun_3(). -type exec_funs() :: [exec_fun(),...]. @@ -586,13 +586,13 @@ event_zone(JObj) -> andalso is_list(element(1, Obj)) ). --spec exec(exec_funs(), api_terms()) -> api_terms(). +-spec exec(exec_funs(), kz_term:api_terms()) -> kz_term:api_terms(). exec(Funs, API) when is_list(API); ?is_json(API) -> lists:foldl(fun exec_fold/2, API, Funs). --spec exec_fold(exec_fun(), api_terms()) -> api_terms(). +-spec exec_fold(exec_fun(), kz_term:api_terms()) -> kz_term:api_terms(). exec_fold({F, K, V}, C) when is_function(F, 3) -> F(K, V, C); exec_fold({F, V}, C) when is_function(F, 2) -> F(V, C); exec_fold(F, C) when is_function(F, 1) -> F(C); diff --git a/core/kazoo_amqp/src/gen_listener.erl b/core/kazoo_amqp/src/gen_listener.erl index 33ceaba55df..81d4fd71510 100644 --- a/core/kazoo_amqp/src/gen_listener.erl +++ b/core/kazoo_amqp/src/gen_listener.erl @@ -8,7 +8,7 @@ %%% the kz_json:object() from the AMQP request. %%% %%% Params :: [ -%%% {bindings, [ {atom(), kz_proplist()}, ...]} -> the type of bindings, with optional properties to pass along +%%% {bindings, [ {atom(), kz_term:proplist()}, ...]} -> the type of bindings, with optional properties to pass along %%% {responders, [ {responder, [ {<<"event-category">>, <<"event-name">>}, ...]} ] %%% responder is the module name to call handle_req/2 on for those category/name combos %%% responder can also be {module, function}, to call module:function/2 instead of handle_req/2 @@ -18,7 +18,7 @@ %%% {queue_options, [{key, value}]} -> optional, if the queue requires different params %%% {consume_options, [{key, value}]} -> optional, if the consumption requires special params %%% {basic_qos, integer()} -> optional, if QoS is being set on this queue -%%% {broker | broker_tag, ne_binary()} -> optional, for binding to specific brokers +%%% {broker | broker_tag, kz_term:ne_binary()} -> optional, for binding to specific brokers %%% {declare_exchanges, declare_exchanges()} -> optional, for declaring dynamic exchanges used only in this connection %%% ] %%% @end @@ -104,22 +104,22 @@ -type module_state() :: any(). --type federator_listener() :: {ne_binary(), pid()}. +-type federator_listener() :: {kz_term:ne_binary(), pid()}. -type federator_listeners() :: [federator_listener()]. --record(state, {queue :: api_binary() +-record(state, {queue :: kz_term:api_binary() ,is_consuming = 'false' :: boolean() ,responders = [] :: listener_utils:responders() %% { {EvtCat, EvtName}, Module } ,bindings = [] :: bindings() %% {authentication, [{key, value},...]} - ,params = [] :: kz_proplist() + ,params = [] :: kz_term:proplist() ,module :: atom() ,module_state :: module_state() - ,module_timeout_ref :: api_reference() % when the client sets a timeout, gen_listener calls shouldn't negate it, only calls that pass through to the client - ,other_queues = [] :: [{ne_binary(), {kz_proplist(), kz_proplist()}}] %% {QueueName, {proplist(), kz_proplist()}} + ,module_timeout_ref :: kz_term:api_reference() % when the client sets a timeout, gen_listener calls shouldn't negate it, only calls that pass through to the client + ,other_queues = [] :: [{kz_term:ne_binary(), {kz_term:proplist(), kz_term:proplist()}}] %% {QueueName, {kz_term:proplist(), kz_term:proplist()}} ,federators = [] :: federator_listeners() ,self = self() :: pid() ,consumer_key = kz_amqp_channel:consumer_pid() - ,consumer_tags = [] :: binaries() + ,consumer_tags = [] :: kz_term:binaries() ,handle_event_mfa = 'undefined' :: mfa() | 'undefined' ,auto_ack = 'false' :: boolean() }). @@ -128,9 +128,9 @@ -type deliver() :: {basic_deliver(), amqp_basic()}. -type callback_datum() :: {'server', pid()} | - {'queue', api_binary()} | - {'other_queues', ne_binaries()}. --type callback_data() :: kz_proplist() | + {'queue', kz_term:api_binary()} | + {'other_queues', kz_term:ne_binaries()}. +-type callback_data() :: kz_term:proplist() | [callback_datum()]. -export_type([handle_event_return/0 @@ -172,8 +172,8 @@ -type handle_event_return() :: 'ignore' | {'ignore', module_state()} | - {'reply', kz_proplist()} | - {'reply', kz_proplist(), module_state()}. + {'reply', kz_term:proplist()} | + {'reply', kz_term:proplist(), module_state()}. -callback handle_event(kz_json:object(), module_state()) -> handle_event_return(). -callback handle_event(kz_json:object(), basic_deliver(), module_state()) -> handle_event_return(). @@ -186,14 +186,14 @@ -optional_callbacks([handle_event/2, handle_event/3, handle_event/4]). --spec start_link(atom(), start_params(), list()) -> startlink_ret(). +-spec start_link(atom(), start_params(), list()) -> kz_types:startlink_ret(). start_link(Module, Params, InitArgs) when is_atom(Module), is_list(Params), is_list(InitArgs) -> gen_server:start_link(?SERVER, [Module, Params, InitArgs], []). --spec start_link(gen_server_name() | atom(), atom() | start_params(), start_params() | list(), gen_server_options() | list()) -> startlink_ret(). +-spec start_link(kz_types:gen_server_name() | atom(), atom() | start_params(), start_params() | list(), kz_types:gen_server_options() | list()) -> kz_types:startlink_ret(). start_link(Module, Params, InitArgs, Options) when is_atom(Module), is_list(Params), is_list(InitArgs), @@ -206,7 +206,7 @@ start_link(Name, Module, Params, InitArgs) when is_atom(Module), -> gen_server:start_link(Name, ?MODULE, [Module, Params, InitArgs], []). --spec start_link(gen_server_name(), atom(), start_params(), list(), gen_server_options()) -> startlink_ret(). +-spec start_link(kz_types:gen_server_name(), atom(), start_params(), list(), kz_types:gen_server_options()) -> kz_types:startlink_ret(). start_link(Name, Module, Params, InitArgs, Options) when is_atom(Module), is_list(Params), is_list(InitArgs), @@ -214,39 +214,39 @@ start_link(Name, Module, Params, InitArgs, Options) when is_atom(Module), -> gen_server:start_link(Name, ?MODULE, [Module, Params, InitArgs], Options). --spec queue_name(server_ref()) -> api_ne_binary(). +-spec queue_name(kz_types:server_ref()) -> kz_term:api_ne_binary(). queue_name(Srv) -> gen_server:call(Srv, 'queue_name'). --spec is_consuming(server_ref()) -> boolean(). +-spec is_consuming(kz_types:server_ref()) -> boolean(). is_consuming(Srv) -> gen_server:call(Srv, 'is_consuming'). --spec responders(server_ref()) -> listener_utils:responders(). +-spec responders(kz_types:server_ref()) -> listener_utils:responders(). responders(Srv) -> gen_server:call(Srv, 'responders'). --spec bindings(server_ref()) -> bindings(). +-spec bindings(kz_types:server_ref()) -> bindings(). bindings(Srv) -> gen_server:call(Srv, 'bindings'). --spec routing_key_used(basic_deliver()) -> ne_binary(). +-spec routing_key_used(basic_deliver()) -> kz_term:ne_binary(). routing_key_used(#'basic.deliver'{routing_key=RoutingKey}) -> kz_term:to_binary(RoutingKey). --spec ack(server_ref(), basic_deliver()) -> 'ok'. +-spec ack(kz_types:server_ref(), basic_deliver()) -> 'ok'. ack(Srv, Delivery) -> gen_server:cast(Srv, {'ack', Delivery}). --spec nack(server_ref(), basic_deliver()) -> 'ok'. +-spec nack(kz_types:server_ref(), basic_deliver()) -> 'ok'. nack(Srv, Delivery) -> gen_server:cast(Srv, {'nack', Delivery}). %% API functions that mirror gen_server:call,cast,reply --spec call(server_ref(), any()) -> any(). +-spec call(kz_types:server_ref(), any()) -> any(). call(Name, Request) -> gen_server:call(Name, {'$client_call', Request}). --spec call(server_ref(), any(), kz_timeout()) -> any(). +-spec call(kz_types:server_ref(), any(), timeout()) -> any(). call(Name, Request, Timeout) -> gen_server:call(Name, {'$client_call', Request}, Timeout). --spec cast(server_ref(), any()) -> 'ok'. +-spec cast(kz_types:server_ref(), any()) -> 'ok'. cast(Name, Request) -> gen_server:cast(Name, {'$client_cast', Request}). --spec delayed_cast(server_ref(), any(), pos_integer()) -> 'ok'. +-spec delayed_cast(kz_types:server_ref(), any(), pos_integer()) -> 'ok'. delayed_cast(Name, Request, Wait) when is_integer(Wait), Wait > 0 -> _P = kz_util:spawn( fun() -> @@ -256,14 +256,14 @@ delayed_cast(Name, Request, Wait) when is_integer(Wait), Wait > 0 -> end), 'ok'. --spec reply(pid_ref(), any()) -> no_return(). +-spec reply(kz_term:pid_ref(), any()) -> no_return(). reply(From, Msg) -> gen_server:reply(From, Msg). -type server_name() :: {'global' | 'local', atom()} | pid(). -spec enter_loop(atom(), list(), any()) -> no_return(). --spec enter_loop(atom(), list(), any(), kz_timeout() | server_name()) -> no_return(). --spec enter_loop(atom(), list(), any(), server_name(), kz_timeout()) -> no_return(). +-spec enter_loop(atom(), list(), any(), timeout() | server_name()) -> no_return(). +-spec enter_loop(atom(), list(), any(), server_name(), timeout()) -> no_return(). enter_loop(Module, Options, ModuleState) -> enter_loop(Module, Options, ModuleState, self(), 'infinity'). enter_loop(Module, Options, ModuleState, {Scope, _Name}=ServerName) @@ -277,23 +277,23 @@ enter_loop(Module, Options, ModuleState, ServerName, Timeout) -> {'ok', MyState} = init_state([Module, Options, ModuleState]), gen_server:enter_loop(?MODULE, [], MyState, ServerName, Timeout). --spec add_responder(server_ref(), responder_callback(), responder_callback_mapping() | responder_callback_mappings()) -> 'ok'. +-spec add_responder(kz_types:server_ref(), responder_callback(), responder_callback_mapping() | responder_callback_mappings()) -> 'ok'. add_responder(Srv, Responder, {_,_}=Key) -> add_responder(Srv, Responder, [Key]); add_responder(Srv, Responder, [{_,_}|_] = Keys) -> gen_server:cast(Srv, {'add_responder', Responder, Keys}). --spec rm_responder(server_ref(), responder_callback()) -> 'ok'. +-spec rm_responder(kz_types:server_ref(), responder_callback()) -> 'ok'. %% empty list removes all rm_responder(Srv, Responder) -> rm_responder(Srv, Responder, []). --spec rm_responder(server_ref(), responder_callback(), responder_callback_mappings()) -> 'ok'. +-spec rm_responder(kz_types:server_ref(), responder_callback(), responder_callback_mappings()) -> 'ok'. rm_responder(Srv, Responder, {_,_}=Key) -> rm_responder(Srv, Responder, [Key]); rm_responder(Srv, Responder, Keys) -> gen_server:cast(Srv, {'rm_responder', Responder, Keys}). --spec add_binding(server_ref(), binding() | ne_binary() | atom()) -> 'ok'. +-spec add_binding(kz_types:server_ref(), binding() | kz_term:ne_binary() | atom()) -> 'ok'. add_binding(Srv, {Binding, Props}) when is_list(Props) ,(is_atom(Binding) orelse is_binary(Binding) @@ -303,12 +303,12 @@ add_binding(Srv, Binding) when is_binary(Binding) orelse is_atom(Binding) -> gen_server:cast(Srv, {'add_binding', kz_term:to_binary(Binding), []}). --spec add_binding(server_ref(), ne_binary() | atom(), kz_proplist()) -> 'ok'. +-spec add_binding(kz_types:server_ref(), kz_term:ne_binary() | atom(), kz_term:proplist()) -> 'ok'. add_binding(Srv, Binding, Props) when is_binary(Binding) orelse is_atom(Binding) -> gen_server:cast(Srv, {'add_binding', kz_term:to_binary(Binding), Props}). --spec b_add_binding(server_ref(), binding() | ne_binary() | atom()) -> 'ok'. +-spec b_add_binding(kz_types:server_ref(), binding() | kz_term:ne_binary() | atom()) -> 'ok'. b_add_binding(Srv, {Binding, Props}) when is_list(Props) ,(is_atom(Binding) orelse is_binary(Binding) @@ -318,48 +318,48 @@ b_add_binding(Srv, Binding) when is_binary(Binding) orelse is_atom(Binding) -> gen_server:call(Srv, {'add_binding', kz_term:to_binary(Binding), []}). --spec b_add_binding(server_ref(), ne_binary() | atom(), kz_proplist()) -> 'ok'. +-spec b_add_binding(kz_types:server_ref(), kz_term:ne_binary() | atom(), kz_term:proplist()) -> 'ok'. b_add_binding(Srv, Binding, Props) when is_binary(Binding) orelse is_atom(Binding) -> gen_server:call(Srv, {'add_binding', kz_term:to_binary(Binding), Props}). %% It is expected that responders have been set up already, prior to binding the new queue --spec add_queue(server_ref(), binary(), kz_proplist(), binding() | bindings()) -> - {'ok', ne_binary()} | +-spec add_queue(kz_types:server_ref(), binary(), kz_term:proplist(), binding() | bindings()) -> + {'ok', kz_term:ne_binary()} | {'error', any()}. add_queue(Srv, QueueName, QueueProps, {_Type, _Props}=Binding) -> add_queue(Srv, QueueName, QueueProps, [Binding]); add_queue(Srv, QueueName, QueueProps, [{_,_}|_]=Bindings) -> gen_server:call(Srv, {'add_queue', QueueName, QueueProps, Bindings}). --spec rm_queue(server_ref(), ne_binary()) -> 'ok'. +-spec rm_queue(kz_types:server_ref(), kz_term:ne_binary()) -> 'ok'. rm_queue(Srv, ?NE_BINARY = QueueName) -> gen_server:cast(Srv, {'rm_queue', QueueName}). --spec other_queues(server_ref()) -> ne_binaries(). +-spec other_queues(kz_types:server_ref()) -> kz_term:ne_binaries(). other_queues(Srv) -> gen_server:call(Srv, 'other_queues'). --spec rm_binding(server_ref(), binding()) -> 'ok'. +-spec rm_binding(kz_types:server_ref(), binding()) -> 'ok'. rm_binding(Srv, {Binding, Props}) -> rm_binding(Srv, Binding, Props). --spec rm_binding(server_ref(), ne_binary() | atom(), kz_proplist()) -> 'ok'. +-spec rm_binding(kz_types:server_ref(), kz_term:ne_binary() | atom(), kz_term:proplist()) -> 'ok'. rm_binding(Srv, Binding, Props) -> gen_server:cast(Srv, {'rm_binding', kz_term:to_binary(Binding), Props}). --spec federated_event(server_ref(), kz_json:object(), basic_deliver(), amqp_basic()) -> 'ok'. +-spec federated_event(kz_types:server_ref(), kz_json:object(), basic_deliver(), amqp_basic()) -> 'ok'. federated_event(Srv, JObj, BasicDeliver, BasicData) -> gen_server:cast(Srv, {'federated_event', JObj, BasicDeliver, BasicData}). --spec execute(server_ref(), module(), atom(), [any()]) -> 'ok'. +-spec execute(kz_types:server_ref(), module(), atom(), [any()]) -> 'ok'. execute(Srv, Module, Function, Args) -> gen_server:cast(Srv, {'$execute', Module, Function, Args}). --spec execute(server_ref(), atom(), [any()]) -> 'ok'. +-spec execute(kz_types:server_ref(), atom(), [any()]) -> 'ok'. execute(Srv, Function, Args) -> gen_server:cast(Srv, {'$execute', Function, Args}). --spec execute(server_ref(), function()) -> 'ok'. +-spec execute(kz_types:server_ref(), function()) -> 'ok'. execute(Srv, Function) when is_function(Function) -> gen_server:cast(Srv, {'$execute', Function}). @@ -377,7 +377,7 @@ init_state([Module, Params, ModuleState]) -> lager:debug("continuing as a gen_listener proc : ~s", [Module]), init(Module, Params, ModuleState, 'undefined'). --spec init([atom() | kz_proplist(),...]) -> +-spec init([atom() | kz_term:proplist(),...]) -> {'ok', state()} | {'stop', any()} | 'ignore'. @@ -395,7 +395,7 @@ init([Module, Params, InitArgs]) -> 'ignore' -> 'ignore' end. --spec init(atom(), kz_proplist(), module_state(), api_reference()) -> +-spec init(atom(), kz_term:proplist(), module_state(), kz_term:api_reference()) -> {'ok', state()}. init(Module, Params, ModuleState, TimeoutRef) -> _ = channel_requisition(Params), @@ -424,7 +424,7 @@ init(Module, Params, ModuleState, TimeoutRef) -> %% {'stop', Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_return(). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> handle_call_return(). handle_call({'add_queue', QueueName, QueueProps, Bindings}, _From, State) -> {Q, S} = add_other_queue(QueueName, QueueProps, Bindings, State), {'reply', {'ok', Q}, S}; @@ -578,7 +578,7 @@ handle_cast({'resume_consumers'}, #state{is_consuming='false' handle_cast(Message, State) -> handle_module_cast(Message, State). --spec maybe_remove_binding(binding(), binding_module(), kz_proplist(), ne_binary()) -> boolean(). +-spec maybe_remove_binding(binding(), binding_module(), kz_term:proplist(), kz_term:ne_binary()) -> boolean(). maybe_remove_binding({B, P}, B, P, Q) -> lager:debug("removing ~s: ~p", [B, P]), remove_binding(B, P, Q), @@ -595,7 +595,7 @@ maybe_remove_binding(_BP, _B, _P, _Q) -> 'true'. %% {'stop', Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret(). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret(). handle_info({#'basic.deliver'{}=BD, #amqp_msg{props=#'P_basic'{content_type=CT}=Basic ,payload=Payload }} @@ -671,7 +671,7 @@ handle_info(Message, State) -> %% @spec handle_event(JObj, State) -> {'reply', Options} | ignore %% @end %%-------------------------------------------------------------------- --spec handle_event(ne_binary(), ne_binary(), deliver(), state()) -> state(). +-spec handle_event(kz_term:ne_binary(), kz_term:ne_binary(), deliver(), state()) -> state(). handle_event(Payload, <<"application/json">>, Deliver, State) -> JObj = kz_json:decode(Payload), _ = kz_util:put_callid(JObj), @@ -690,7 +690,7 @@ handle_event(Payload, <<"application/erlang">>, Deliver, State) -> %% @spec handle_event(JObj, State) -> {'reply', Options} | ignore %% @end %%-------------------------------------------------------------------- --spec handle_return(ne_binary(), ne_binary(), #'basic.return'{}, state()) -> handle_cast_return(). +-spec handle_return(kz_term:ne_binary(), kz_term:ne_binary(), #'basic.return'{}, state()) -> handle_cast_return(). handle_return(Payload, <<"application/json">>, BR, State) -> JObj = kz_json:decode(Payload), _ = kz_util:put_callid(JObj), @@ -782,7 +782,7 @@ handle_callback_info(Message, #state{module=Module {'stop', R, State} end. --spec format_status('normal' | 'terminate', [kz_proplist() | state()]) -> any(). +-spec format_status('normal' | 'terminate', [kz_term:proplist() | state()]) -> any(). format_status(_Opt, [_PDict, #state{module=Module ,module_state=ModuleState }=State]) -> @@ -932,7 +932,7 @@ maybe_event_matches_key({_, Name}, {<<"*">>, Name}) -> 'true'; maybe_event_matches_key({Cat, _}, {Cat, <<"*">>}) -> 'true'; maybe_event_matches_key(_A, _B) -> 'false'. --spec start_amqp(kz_proplist(), boolean()) -> +-spec start_amqp(kz_term:proplist(), boolean()) -> {'ok', binary()} | {'error', _}. start_amqp(Props, AutoAck) -> @@ -953,11 +953,11 @@ start_amqp(Props, AutoAck) -> set_qos('undefined') -> 'ok'; set_qos(N) when is_integer(N), N >= 0 -> amqp_util:basic_qos(N). --spec start_consumer(ne_binary(), kz_proplist()) -> 'ok'. +-spec start_consumer(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. start_consumer(Q, 'undefined') -> amqp_util:basic_consume(Q, []); start_consumer(Q, ConsumeProps) -> amqp_util:basic_consume(Q, ConsumeProps). --spec remove_binding(binding_module(), kz_proplist(), api_binary()) -> 'ok'. +-spec remove_binding(binding_module(), kz_term:proplist(), kz_term:api_binary()) -> 'ok'. remove_binding(Binding, Props, Q) -> Wapi = list_to_binary([<<"kapi_">>, kz_term:to_binary(Binding)]), lager:debug("trying to remove bindings with ~s:unbind_q(~s, ~p)", [Wapi, Q, Props]), @@ -967,7 +967,7 @@ remove_binding(Binding, Props, Q) -> erlang:error({'api_module_undefined', Wapi}) end. --spec create_binding(ne_binary(), kz_proplist(), ne_binary()) -> any(). +-spec create_binding(kz_term:ne_binary(), kz_term:proplist(), kz_term:ne_binary()) -> any(). create_binding(Binding, Props, Q) when not is_binary(Binding) -> create_binding(kz_term:to_binary(Binding), Props, Q); create_binding(Binding, Props, Q) -> @@ -978,11 +978,11 @@ create_binding(Binding, Props, Q) -> erlang:error({'api_module_undefined', Wapi}) end. --spec stop_timer(api_reference()) -> non_neg_integer() | 'false'. +-spec stop_timer(kz_term:api_reference()) -> non_neg_integer() | 'false'. stop_timer('undefined') -> 'false'; stop_timer(Ref) when is_reference(Ref) -> erlang:cancel_timer(Ref). --spec start_timer(kz_timeout()) -> api_reference(). +-spec start_timer(timeout()) -> kz_term:api_reference(). start_timer(0) -> self() ! ?CALLBACK_TIMEOUT_MSG, 'undefined'; @@ -991,7 +991,7 @@ start_timer(Timeout) when is_integer(Timeout) erlang:send_after(Timeout, self(), ?CALLBACK_TIMEOUT_MSG); start_timer(_) -> 'undefined'. --spec add_other_queue(binary(), kz_proplist(), kz_proplist(), state()) -> {ne_binary(), state()}. +-spec add_other_queue(binary(), kz_term:proplist(), kz_term:proplist(), state()) -> {kz_term:ne_binary(), state()}. add_other_queue(<<>>, QueueProps, Bindings, #state{other_queues=OtherQueues, auto_ack=AutoAck}=State) -> {'ok', Q} = start_amqp(QueueProps, AutoAck), gen_server:cast(self(), {?MODULE, {'created_queue', Q}}), @@ -1011,7 +1011,7 @@ add_other_queue(QueueName, QueueProps, Bindings, #state{other_queues=OtherQueues ]}} end. --spec handle_module_call(any(), pid_ref(), state()) -> handle_call_return(). +-spec handle_module_call(any(), kz_term:pid_ref(), state()) -> handle_call_return(). handle_module_call(Request, From, #state{module=Module ,module_state=ModuleState ,module_timeout_ref=OldRef @@ -1075,7 +1075,7 @@ handle_module_cast(Msg, #state{module=Module {'stop', R, State} end. --spec handle_rm_binding(binding(), kz_proplist(), state()) -> state(). +-spec handle_rm_binding(binding(), kz_term:proplist(), state()) -> state(). handle_rm_binding(Binding, Props, #state{queue=Q ,bindings=Bs }=State) -> @@ -1087,7 +1087,7 @@ handle_rm_binding(Binding, Props, #state{queue=Q )], State#state{bindings=KeepBs}. --spec handle_add_binding(binding_module(), kz_proplist(), state()) -> +-spec handle_add_binding(binding_module(), kz_term:proplist(), state()) -> state(). handle_add_binding(Binding, Props, #state{queue=Q ,bindings=Bs @@ -1101,7 +1101,7 @@ handle_add_binding(Binding, Props, #state{queue=Q handle_existing_binding(Binding, Props, State, Q, ExistingProps, Bs) end. --spec handle_existing_binding(binding_module(), kz_proplist(), state(), ne_binary(), kz_proplist(), bindings()) -> +-spec handle_existing_binding(binding_module(), kz_term:proplist(), state(), kz_term:ne_binary(), kz_term:proplist(), bindings()) -> state(). handle_existing_binding(Binding, Props, State, Q, ExistingProps, Bs) -> case lists:all(fun({K,V}) -> @@ -1128,7 +1128,7 @@ maybe_update_federated_bindings(#state{bindings=[{_Binding, Props}|_]}=State) -> 'true' -> update_federated_bindings(State) end. --spec is_federated_binding(kz_proplist()) -> boolean(). +-spec is_federated_binding(kz_term:proplist()) -> boolean(). is_federated_binding(Props) -> props:get_value('federate', Props) =:= 'true'. @@ -1148,41 +1148,41 @@ update_federated_bindings(#state{bindings=[{Binding, Props}|_] State#state{federators=NewListeners ++ Fs} end. --spec broker_connections(federator_listeners(), ne_binaries()) -> - {ne_binaries(), ne_binaries()}. +-spec broker_connections(federator_listeners(), kz_term:ne_binaries()) -> + {kz_term:ne_binaries(), kz_term:ne_binaries()}. broker_connections(Listeners, Brokers) -> lists:partition(fun(Broker) -> props:get_value(Broker, Listeners) =/= 'undefined' end, Brokers). --spec start_new_listeners(ne_binaries(), binding_module(), kz_proplist(), state()) -> +-spec start_new_listeners(kz_term:ne_binaries(), binding_module(), kz_term:proplist(), state()) -> {'ok', federator_listeners()}. start_new_listeners(Brokers, Binding, Props, State) -> {'ok', [start_new_listener(Broker, Binding, Props, State) || Broker <- Brokers ]}. --spec start_new_listener(ne_binary(), binding_module(), kz_proplist(), state()) -> federator_listener(). +-spec start_new_listener(kz_term:ne_binary(), binding_module(), kz_term:proplist(), state()) -> federator_listener(). start_new_listener(Broker, Binding, Props, #state{params=Ps}) -> FederateParams = create_federated_params({Binding, Props}, Ps), {'ok', Pid} = listener_federator:start_link(self(), Broker, FederateParams), lager:debug("started federated listener on broker ~s: ~p", [Broker, Pid]), {Broker, Pid}. --spec update_existing_listeners_bindings(federator_listeners(), binding_module(), kz_proplist()) -> 'ok'. +-spec update_existing_listeners_bindings(federator_listeners(), binding_module(), kz_term:proplist()) -> 'ok'. update_existing_listeners_bindings(Listeners, Binding, Props) -> _ = [update_existing_listener_bindings(Listener, Binding, Props) || Listener <- Listeners ], 'ok'. --spec update_existing_listener_bindings(federator_listener(), binding_module(), kz_proplist()) -> 'ok'. +-spec update_existing_listener_bindings(federator_listener(), binding_module(), kz_term:proplist()) -> 'ok'. update_existing_listener_bindings({_Broker, Pid}, Binding, Props) -> lager:debug("updating listener ~p with ~s", [Pid, Binding]), ?MODULE:add_binding(Pid, Binding, Props). --spec create_federated_params({binding_module(), kz_proplist()}, kz_proplist()) -> - kz_proplist(). +-spec create_federated_params({binding_module(), kz_term:proplist()}, kz_term:proplist()) -> + kz_term:proplist(). create_federated_params(FederateBindings, Params) -> [{'responders', []} ,{'bindings', [FederateBindings]} @@ -1191,7 +1191,7 @@ create_federated_params(FederateBindings, Params) -> ,{'consume_options', props:get_value('consume_options', Params, [])} ]. --spec federated_queue_name(kz_proplist()) -> api_binary(). +-spec federated_queue_name(kz_term:proplist()) -> kz_term:api_binary(). federated_queue_name(Params) -> QueueName = props:get_value('queue_name', Params, <<>>), case kz_term:is_empty(QueueName) of @@ -1222,7 +1222,7 @@ handle_exchanges_ready(#state{params=Params, auto_ack=AutoAck}=State) -> handle_amqp_errored(State) end. --spec handle_amqp_started(state(), ne_binary()) -> state(). +-spec handle_amqp_started(state(), kz_term:ne_binary()) -> state(). handle_amqp_started(#state{params=Params}=State, Q) -> State1 = start_initial_bindings(State#state{queue=Q}, Params), @@ -1284,7 +1284,7 @@ declare_exchange(Channel, Exchange, Exchanges) -> E -> E end. --spec start_initial_bindings(state(), kz_proplist()) -> state(). +-spec start_initial_bindings(state(), kz_term:proplist()) -> state(). start_initial_bindings(State, Params) -> lists:foldl(fun({Binding, Props}, StateAcc) -> handle_add_binding(Binding, Props, StateAcc) @@ -1293,7 +1293,7 @@ start_initial_bindings(State, Params) -> ,props:get_value('bindings', Params, []) ). --spec channel_requisition(kz_proplist()) -> boolean(). +-spec channel_requisition(kz_term:proplist()) -> boolean(). channel_requisition([]) -> 'false'; channel_requisition(Params) -> case props:get_value('broker_tag', Params) of @@ -1321,7 +1321,7 @@ maybe_add_broker_connection(Broker, Count) when Count =:= 0 -> maybe_add_broker_connection(Broker, _Count) -> kz_amqp_channel:requisition(self(), Broker). --spec start_listener(pid(), kz_proplist()) -> 'ok'. +-spec start_listener(pid(), kz_term:proplist()) -> 'ok'. start_listener(Srv, Params) -> gen_server:cast(Srv, {'start_listener', Params}). diff --git a/core/kazoo_amqp/src/kapi_definition.erl b/core/kazoo_amqp/src/kapi_definition.erl index ab78aa55be8..7fe632cd002 100644 --- a/core/kazoo_amqp/src/kapi_definition.erl +++ b/core/kazoo_amqp/src/kapi_definition.erl @@ -29,28 +29,28 @@ -export_type([api/0, apis/0]). --spec name(api()) -> ne_binary(). +-spec name(api()) -> kz_term:ne_binary(). name(#kapi_definition{name = Name}) -> Name. --spec friendly_name(api()) -> ne_binary(). +-spec friendly_name(api()) -> kz_term:ne_binary(). friendly_name(#kapi_definition{friendly_name = FreindlyName}) -> FreindlyName. --spec description(api()) -> ne_binary(). +-spec description(api()) -> kz_term:ne_binary(). description(#kapi_definition{description = Description}) -> Description. --spec build_fun(api()) -> fun((api_terms()) -> api_formatter_return()). +-spec build_fun(api()) -> fun((kz_term:api_terms()) -> api_formatter_return()). build_fun(#kapi_definition{build_fun = BuildFun}) -> BuildFun. --spec validate_fun(api()) -> fun((api_terms()) -> boolean()). +-spec validate_fun(api()) -> fun((kz_term:api_terms()) -> boolean()). validate_fun(#kapi_definition{validate_fun = ValidateFun}) -> ValidateFun. --spec publish_fun(api()) -> fun((api_terms()) -> api_formatter_return()). +-spec publish_fun(api()) -> fun((kz_term:api_terms()) -> api_formatter_return()). publish_fun(#kapi_definition{publish_fun = PublishFun}) -> PublishFun. --spec binding(api()) -> api_ne_binary(). +-spec binding(api()) -> kz_term:api_ne_binary(). binding(#kapi_definition{binding = Binding}) -> Binding. --spec restrict_to(api()) -> api_atom(). +-spec restrict_to(api()) -> kz_term:api_atom(). restrict_to(#kapi_definition{restrict_to = RestrictTo}) -> RestrictTo. -spec required_headers(api()) -> api_headers(). diff --git a/core/kazoo_amqp/src/kazoo_amqp_app.erl b/core/kazoo_amqp/src/kazoo_amqp_app.erl index d68b4d8fc81..f6ca48ef249 100644 --- a/core/kazoo_amqp/src/kazoo_amqp_app.erl +++ b/core/kazoo_amqp/src/kazoo_amqp_app.erl @@ -10,7 +10,7 @@ %% =================================================================== %% Application callbacks %% =================================================================== --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_StartType, _StartArgs) -> kz_amqp_sup:start_link(). diff --git a/core/kazoo_amqp/src/kazoo_amqp_maintenance.erl b/core/kazoo_amqp/src/kazoo_amqp_maintenance.erl index 7fe37efa4bc..aadd10185b9 100644 --- a/core/kazoo_amqp/src/kazoo_amqp_maintenance.erl +++ b/core/kazoo_amqp/src/kazoo_amqp_maintenance.erl @@ -38,11 +38,11 @@ %% %% @end %%-------------------------------------------------------------------- --spec add_broker(ne_binary()) -> 'ok' | 'no_return'. +-spec add_broker(kz_term:ne_binary()) -> 'ok' | 'no_return'. add_broker(Broker) -> add_broker(Broker, 'local'). --spec add_broker(ne_binary(), atom()) -> 'ok' | 'no_return'. +-spec add_broker(kz_term:ne_binary(), atom()) -> 'ok' | 'no_return'. add_broker(Broker, Zone) when not is_binary(Broker) -> add_broker(kz_term:to_binary(Broker), Zone); add_broker(Broker, Zone) when not is_atom(Zone) -> @@ -71,7 +71,7 @@ add_broker(Broker, Zone) -> %% %% @end %%-------------------------------------------------------------------- --spec remove_broker(ne_binary()) -> 'ok'. +-spec remove_broker(kz_term:ne_binary()) -> 'ok'. remove_broker(Broker) when not is_binary(Broker) -> remove_broker(kz_term:to_binary(Broker)); remove_broker(Broker) -> @@ -83,11 +83,11 @@ remove_broker(Broker) -> %% %% @end %%-------------------------------------------------------------------- --spec add_connection(ne_binary()) -> 'ok' | 'no_return'. +-spec add_connection(kz_term:ne_binary()) -> 'ok' | 'no_return'. add_connection(Broker) -> add_connection(Broker, 'local'). --spec add_connection(ne_binary(), atom()) -> 'ok' | 'no_return'. +-spec add_connection(kz_term:ne_binary(), atom()) -> 'ok' | 'no_return'. add_connection(Broker, Zone) when not is_binary(Broker) -> add_connection(kz_term:to_binary(Broker), Zone); add_connection(Broker, Zone) when not is_atom(Zone) -> @@ -445,11 +445,11 @@ consumer_details() -> }], print_consumer_details(ets:select(?ASSIGNMENTS, MatchSpec, 1)). --spec consumer_details(ne_binary()) -> 'ok'. +-spec consumer_details(kz_term:ne_binary()) -> 'ok'. consumer_details(ProcessUpper) -> consumer_details(<<"0">>, ProcessUpper, <<"0">>). --spec consumer_details(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec consumer_details(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. consumer_details(NodeNumber, ProcessUpper, ProcessLower) when not is_binary(NodeNumber) -> consumer_details(kz_term:to_binary(NodeNumber), ProcessUpper, ProcessLower); consumer_details(NodeNumber, ProcessUpper, ProcessLower) when not is_binary(ProcessUpper) -> @@ -528,7 +528,7 @@ gc_pools() -> _ = [gc_pool(Pool, Pid) || {Pool, Pid} <- kz_amqp_sup:pools()], 'ok'. --spec gc_pool(text()) -> 'ok'. +-spec gc_pool(kz_term:text()) -> 'ok'. gc_pool(Pool) when is_atom(Pool) -> case [P || {Name, _}=P <- kz_amqp_sup:pools(), Pool =:= Name] of [] -> io:format("no pool named ~p found~n", [Pool]); diff --git a/core/kazoo_amqp/src/kz_amqp_assignments.erl b/core/kazoo_amqp/src/kz_amqp_assignments.erl index c330cb91526..68dd34e7eab 100644 --- a/core/kazoo_amqp/src/kz_amqp_assignments.erl +++ b/core/kazoo_amqp/src/kz_amqp_assignments.erl @@ -43,7 +43,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_server:start_link({'local', ?SERVER}, ?MODULE, [], []). @@ -84,14 +84,14 @@ get_channel(Consumer, Timeout) when is_pid(Consumer) -> request_and_wait(Consumer, kz_amqp_channel:consumer_broker(), Timeout) end. --spec request_channel(pid(), api_binary()) -> kz_amqp_assignment(). +-spec request_channel(pid(), kz_term:api_binary()) -> kz_amqp_assignment(). request_channel(Consumer, 'undefined') when is_pid(Consumer) -> Broker = kz_amqp_connections:primary_broker(), gen_server:call(?SERVER, {'request_float', Consumer, Broker}); request_channel(Consumer, Broker) when is_pid(Consumer) -> gen_server:call(?SERVER, {'request_sticky', Consumer, Broker}). --spec add_channel(ne_binary(), pid(), pid()) -> 'ok'. +-spec add_channel(kz_term:ne_binary(), pid(), pid()) -> 'ok'. add_channel(Broker, Connection, Channel) when is_pid(Channel) andalso is_binary(Broker) -> @@ -145,7 +145,7 @@ init([]) -> %% {'stop', Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call({'request_float', Consumer, Broker}, _, State) -> _ = import_pending_channels(), {'reply', assign_or_reserve(Consumer, Broker, 'float'), State}; @@ -167,7 +167,7 @@ handle_call(_Msg, _From, State) -> %% {'stop', Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'add_channel_primary_broker', Broker, Connection, Channel}, State) -> _ = add_channel_primary_broker(Broker, Connection, Channel), {'noreply', State}; @@ -205,7 +205,7 @@ handle_cast(_Msg, State) -> %% {'stop', Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'DOWN', Ref, 'process', _Pid, Reason}, State) -> erlang:demonitor(Ref, ['flush']), handle_down_msg(find_reference(Ref), Reason), @@ -366,7 +366,7 @@ maybe_reassign(#kz_amqp_assignment{}=ConsumerAssignment, Broker) -> %% %% @end %%-------------------------------------------------------------------- --spec assign_or_reserve(pid(), api_binary(), kz_amqp_type()) -> kz_amqp_assignment(). +-spec assign_or_reserve(pid(), kz_term:api_binary(), kz_amqp_type()) -> kz_amqp_assignment(). assign_or_reserve(Consumer, 'undefined', Type) -> %% When there is no primary broker we will not be able to %% find a channel so just make a reservation @@ -485,7 +485,7 @@ add_consumer_to_channel(#kz_amqp_assignment{channel=Channel %% %% @end %%-------------------------------------------------------------------- --spec add_channel_primary_broker(ne_binary(), pid(), pid()) -> 'true'. +-spec add_channel_primary_broker(kz_term:ne_binary(), pid(), pid()) -> 'true'. add_channel_primary_broker(Broker, Connection, Channel) -> %% This will find any reservations that require a channel %% and assign it the new channel @@ -511,7 +511,7 @@ add_channel_primary_broker(Broker, Connection, Channel) -> assign_channel(Assignment, Broker, Connection, Channel) end. --spec maybe_reclaim_channel(ne_binary(), pid(), pid()) -> 'true'. +-spec maybe_reclaim_channel(kz_term:ne_binary(), pid(), pid()) -> 'true'. maybe_reclaim_channel(Broker, Connection, Channel) -> %% This will attemp to find a floating channel not using %% the primary broker and move to the new channel @@ -534,7 +534,7 @@ maybe_reclaim_channel(Broker, Connection, Channel) -> assign_channel(Assignment, Broker, Connection, Channel) end. --spec add_channel_alternate_broker(ne_binary(), pid(), pid()) -> 'true'. +-spec add_channel_alternate_broker(kz_term:ne_binary(), pid(), pid()) -> 'true'. add_channel_alternate_broker(Broker, Connection, Channel) -> %% This will find any sticky reservations that require a %% channel from this broker and assign it the new channel @@ -549,7 +549,7 @@ add_channel_alternate_broker(Broker, Connection, Channel) -> assign_channel(Assignment, Broker, Connection, Channel) end. --spec assign_channel(kz_amqp_assignment(), ne_binary(), pid(), pid()) -> 'true'. +-spec assign_channel(kz_amqp_assignment(), kz_term:ne_binary(), pid(), pid()) -> 'true'. assign_channel(#kz_amqp_assignment{channel_ref=Ref}=Assignment ,Broker, Connection, Channel) when is_reference(Ref) -> @@ -594,7 +594,7 @@ assign_channel(#kz_amqp_assignment{timestamp=Timestamp _ = send_notifications(Assigment), 'true'. --spec cache(ne_binary(), pid(), pid()) -> 'true'. +-spec cache(kz_term:ne_binary(), pid(), pid()) -> 'true'. cache(Broker, Connection, Channel) -> Ref = erlang:monitor('process', Channel), lager:debug("added new channel ~p on ~s to available pool" @@ -672,7 +672,7 @@ notify_watchers(#kz_amqp_assignment{}=Assignment, [Watcher|Watchers]) -> %% %% @end %%-------------------------------------------------------------------- --spec maybe_reserve(api_pid(), api_binary(), kz_amqp_type()) -> kz_amqp_assignment(). +-spec maybe_reserve(kz_term:api_pid(), kz_term:api_binary(), kz_amqp_type()) -> kz_amqp_assignment(). maybe_reserve(Consumer, Broker, Type) -> Pattern = #kz_amqp_assignment{consumer=Consumer, _='_'}, case ets:match_object(?TAB, Pattern, 1) of @@ -690,7 +690,7 @@ maybe_reserve(Consumer, Broker, Type) -> ExistingAssignment end. --spec reserve(api_pid(), api_binary(), kz_amqp_type()) -> kz_amqp_assignment(). +-spec reserve(kz_term:api_pid(), kz_term:api_binary(), kz_amqp_type()) -> kz_amqp_assignment(). reserve(Consumer, Broker, 'sticky') when Broker =/= 'undefined' -> Ref = erlang:monitor('process', Consumer), Assignment = #kz_amqp_assignment{consumer=Consumer @@ -829,9 +829,9 @@ wait_for_assignment(Timeout) -> Timeout -> {'error', 'timeout'} end. --spec request_and_wait(pid(), api_binary(), 'infinity') -> kz_amqp_assignment(); - (pid(), api_binary(), non_neg_integer()) -> kz_amqp_assignment() | - {'error', 'timeout'}. +-spec request_and_wait(pid(), kz_term:api_binary(), 'infinity') -> kz_amqp_assignment(); + (pid(), kz_term:api_binary(), non_neg_integer()) -> kz_amqp_assignment() | + {'error', 'timeout'}. request_and_wait(Consumer, Broker, Timeout) when is_pid(Consumer) -> case request_channel(Consumer, Broker) of #kz_amqp_assignment{channel=Channel}=Assignment diff --git a/core/kazoo_amqp/src/kz_amqp_bootstrap.erl b/core/kazoo_amqp/src/kz_amqp_bootstrap.erl index 37aae0458c5..047de49daf0 100644 --- a/core/kazoo_amqp/src/kz_amqp_bootstrap.erl +++ b/core/kazoo_amqp/src/kz_amqp_bootstrap.erl @@ -36,7 +36,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_server:start_link({'local', ?SERVER}, ?MODULE, [], []). @@ -79,7 +79,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -93,7 +93,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> {'noreply', State}. @@ -107,7 +107,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info('timeout', State) -> _ = kz_amqp_sup:stop_bootstrap(), {'noreply', State}; @@ -145,19 +145,19 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec add_zones(kz_proplist()) -> 'ok'. +-spec add_zones(kz_term:proplist()) -> 'ok'. add_zones([]) -> 'ok'; add_zones([{ZoneName, Brokers}|Zones]) -> _ = add_brokers(Brokers, ZoneName), add_zones(Zones). --spec add_brokers(ne_binaries(), atom()) -> 'ok'. +-spec add_brokers(kz_term:ne_binaries(), atom()) -> 'ok'. add_brokers([], _) -> 'ok'; add_brokers([Broker|Brokers], ZoneName) -> _ = kz_amqp_connections:add(Broker, ZoneName), add_brokers(Brokers, ZoneName). --spec get_config() -> kz_proplist(). +-spec get_config() -> kz_term:proplist(). get_config() -> get_from_zone(kz_config:zone()). %% case kz_config:get(kz_config:get_node_section_name(), 'zone') of @@ -165,18 +165,18 @@ get_config() -> %% _Else -> get_from_amqp() %% end. %% -%% -spec get_from_amqp() -> kz_proplist(). +%% -spec get_from_amqp() -> kz_term:proplist(). %% get_from_amqp() -> %% [{'local', kz_config:get('amqp', 'uri', [?DEFAULT_AMQP_URI])}]. --spec get_zones() -> kz_proplist(). +-spec get_zones() -> kz_term:proplist(). get_zones() -> case kz_config:get_section('zone') of [] -> kz_config:get_section('amqp'); Zones -> Zones end. --spec get_from_zone(atom()) -> kz_proplist(). +-spec get_from_zone(atom()) -> kz_term:proplist(). get_from_zone(ZoneName) -> Zones = get_zones(), Props = dict:to_list(get_from_zone(ZoneName, Zones, dict:new())), @@ -185,7 +185,7 @@ get_from_zone(ZoneName) -> _Else -> Props end. --spec get_from_zone(atom(), kz_proplist(), dict:dict()) -> dict:dict(). +-spec get_from_zone(atom(), kz_term:proplist(), dict:dict()) -> dict:dict(). get_from_zone(_, [], Dict) -> Dict; get_from_zone(ZoneName, [{_, Zone}|Zones], Dict) -> case props:get_first_defined(['name', 'zone'], Zone) of @@ -196,7 +196,7 @@ get_from_zone(ZoneName, [{_, Zone}|Zones], Dict) -> get_from_zone(ZoneName, Zones, import_zone(RemoteZoneName, Zone, Dict)) end. --spec import_zone(atom(), kz_proplist(), dict:dict()) -> dict:dict(). +-spec import_zone(atom(), kz_term:proplist(), dict:dict()) -> dict:dict(). import_zone(_, [], Dict) -> Dict; import_zone(ZoneName, [{'amqp_uri', URI}|Props], Dict) -> case dict:find(ZoneName, Dict) of diff --git a/core/kazoo_amqp/src/kz_amqp_channel.erl b/core/kazoo_amqp/src/kz_amqp_channel.erl index ce4d781800d..0447d75b313 100644 --- a/core/kazoo_amqp/src/kz_amqp_channel.erl +++ b/core/kazoo_amqp/src/kz_amqp_channel.erl @@ -56,7 +56,7 @@ consumer_pid() -> _Else -> self() end. --spec consumer_pid(pid()) -> api_pid(). +-spec consumer_pid(pid()) -> kz_term:api_pid(). consumer_pid(Pid) when is_pid(Pid) -> put('$kz_amqp_consumer_pid', Pid). @@ -79,14 +79,14 @@ consumer_channel(Channel) -> remove_consumer_channel() -> put('$kz_amqp_consumer_channel', 'undefined'). --spec consumer_broker() -> api_binary(). +-spec consumer_broker() -> kz_term:api_binary(). consumer_broker() -> case get('$kz_amqp_consumer_broker') of Broker when is_binary(Broker) -> Broker; _Else -> 'undefined' end. --spec consumer_broker(ne_binary()) -> api_binary(). +-spec consumer_broker(kz_term:ne_binary()) -> kz_term:api_binary(). consumer_broker(Broker) when is_binary(Broker) -> put('$kz_amqp_consumer_broker', Broker). @@ -111,14 +111,14 @@ channel_publish_method(Method) -spec requisition() -> boolean(). requisition() -> requisition(consumer_pid()). --spec requisition(pid() | api_binary()) -> boolean(). +-spec requisition(pid() | kz_term:api_binary()) -> boolean(). requisition(Consumer) when is_pid(Consumer) -> requisition(Consumer, consumer_broker()); requisition(Broker) -> put('$kz_amqp_consumer_broker', Broker), requisition(consumer_pid(), Broker). --spec requisition(pid(), api_binary()) -> boolean(). +-spec requisition(pid(), kz_term:api_binary()) -> boolean(). requisition(Consumer, Broker) when is_pid(Consumer) -> case kz_amqp_assignments:request_channel(Consumer, Broker) of #kz_amqp_assignment{channel=Channel} @@ -135,10 +135,10 @@ release(Pid) when is_pid(Pid) -> _ = kz_amqp_history:remove(Pid), kz_amqp_assignments:release(Pid). --spec close(api_pid()) -> 'ok'. +-spec close(kz_term:api_pid()) -> 'ok'. close(Channel) -> close(Channel, []). --spec close(api_pid(), list()) -> 'ok'. +-spec close(kz_term:api_pid(), list()) -> 'ok'. close(Channel, []) when is_pid(Channel) -> _ = (catch gen_server:call(Channel, {'close', 200, <<"Goodbye">>}, 5 * ?MILLISECONDS_IN_SECOND)), lager:debug("closed amqp channel ~p", [Channel]); @@ -253,7 +253,7 @@ basic_publish(Channel when is_pid(Channel) -> amqp_channel:Method(Channel, BasicPub, AmqpMsg). --spec maybe_split_routing_key(binary()) -> {api_pid(), binary()}. +-spec maybe_split_routing_key(binary()) -> {kz_term:api_pid(), binary()}. maybe_split_routing_key(<<"consumer://", _/binary>> = RoutingKey) -> Size = byte_size(RoutingKey), {Start, _} = lists:last(binary:matches(RoutingKey, <<"/">>)), diff --git a/core/kazoo_amqp/src/kz_amqp_connection.erl b/core/kazoo_amqp/src/kz_amqp_connection.erl index 9e6f6550d06..a001872156d 100644 --- a/core/kazoo_amqp/src/kz_amqp_connection.erl +++ b/core/kazoo_amqp/src/kz_amqp_connection.erl @@ -39,7 +39,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(kz_amqp_connection()) -> startlink_ret(). +-spec start_link(kz_amqp_connection()) -> kz_types:startlink_ret(). start_link(#kz_amqp_connection{}=Connection) -> gen_server:start_link(?SERVER, [Connection], []). @@ -94,7 +94,7 @@ init([#kz_amqp_connection{}=Connection]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call('get_connection', _, Connection) -> {'reply', Connection, Connection}; handle_call('stop', _, Connection) -> @@ -121,7 +121,7 @@ handle_call(_Msg, _From, Connection) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('disconnect' ,#kz_amqp_connection{available='false'}=Connection) -> {'noreply', Connection, 'hibernate'}; @@ -160,7 +160,7 @@ handle_cast(_Msg, Connection) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'DOWN', _Ref, 'process', _Pid, _Reason} ,#kz_amqp_connection{available='false'}=Connection ) -> diff --git a/core/kazoo_amqp/src/kz_amqp_connection_sup.erl b/core/kazoo_amqp/src/kz_amqp_connection_sup.erl index 52cee44a5a5..43a71418fc1 100644 --- a/core/kazoo_amqp/src/kz_amqp_connection_sup.erl +++ b/core/kazoo_amqp/src/kz_amqp_connection_sup.erl @@ -28,11 +28,11 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec add(#kz_amqp_connection{}) -> sup_startchild_ret(). +-spec add(#kz_amqp_connection{}) -> kz_types:sup_startchild_ret(). add(#kz_amqp_connection{}=Connection) -> supervisor:start_child(?SERVER, [Connection]). @@ -53,7 +53,7 @@ remove(Connection) when is_pid(Connection) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 5, diff --git a/core/kazoo_amqp/src/kz_amqp_connections.erl b/core/kazoo_amqp/src/kz_amqp_connections.erl index 1bda7d16203..539bf617484 100644 --- a/core/kazoo_amqp/src/kz_amqp_connections.erl +++ b/core/kazoo_amqp/src/kz_amqp_connections.erl @@ -59,16 +59,16 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_server:start_link({'local', ?SERVER}, ?MODULE, [], []). --spec new(kz_amqp_connection() | text()) -> +-spec new(kz_amqp_connection() | kz_term:text()) -> kz_amqp_connection() | {'error', any()}. new(Broker) -> new(Broker, 'local'). --spec new(kz_amqp_connection() | text(), text()) -> +-spec new(kz_amqp_connection() | kz_term:text(), kz_term:text()) -> kz_amqp_connection() | {'error', any()}. new(<<_/binary>> = Broker, Zone) -> @@ -79,13 +79,13 @@ new(<<_/binary>> = Broker, Zone) -> new(Broker, Zone) -> new(kz_term:to_binary(Broker), Zone). --spec add(kz_amqp_connection() | text()) -> +-spec add(kz_amqp_connection() | kz_term:text()) -> kz_amqp_connection() | {'error', any()}. --spec add(kz_amqp_connection() | text(), text()) -> +-spec add(kz_amqp_connection() | kz_term:text(), kz_term:text()) -> kz_amqp_connection() | {'error', any()}. --spec add(kz_amqp_connection() | text(), text(), list()) -> +-spec add(kz_amqp_connection() | kz_term:text(), kz_term:text(), list()) -> kz_amqp_connection() | {'error', any()}. @@ -135,7 +135,7 @@ add(Broker, Zone, Tags) -> ) end. --spec remove(pids() | pid() | text()) -> 'ok'. +-spec remove(kz_term:pids() | pid() | kz_term:text()) -> 'ok'. remove([]) -> 'ok'; remove([Connection|Connections]) when is_pid(Connection) -> _ = kz_amqp_connection_sup:remove(Connection), @@ -159,7 +159,7 @@ available(Connection) when is_pid(Connection) -> unavailable(Connection) when is_pid(Connection) -> gen_server:cast(?SERVER, {'connection_unavailable', Connection}). --spec arbitrator_broker() -> api_binary(). +-spec arbitrator_broker() -> kz_term:api_binary(). arbitrator_broker() -> MatchSpec = [{#kz_amqp_connections{broker='$1' ,available='true' @@ -174,7 +174,7 @@ arbitrator_broker() -> [Arbitrator|_] -> Arbitrator end. --spec broker_connections(ne_binary()) -> non_neg_integer(). +-spec broker_connections(kz_term:ne_binary()) -> non_neg_integer(). broker_connections(Broker) -> MatchSpec = [{#kz_amqp_connections{broker=Broker ,_='_' @@ -184,7 +184,7 @@ broker_connections(Broker) -> ], ets:select_count(?TAB, MatchSpec). --spec broker_available_connections(ne_binary()) -> non_neg_integer(). +-spec broker_available_connections(kz_term:ne_binary()) -> non_neg_integer(). broker_available_connections(Broker) -> MatchSpec = [{#kz_amqp_connections{broker=Broker ,available='true' @@ -195,7 +195,7 @@ broker_available_connections(Broker) -> ], ets:select_count(?TAB, MatchSpec). --spec primary_broker() -> api_binary(). +-spec primary_broker() -> kz_term:api_binary(). primary_broker() -> Pattern = #kz_amqp_connections{available='true' ,zone='local' @@ -211,7 +211,7 @@ primary_broker() -> [Broker|_] -> Broker end. --spec federated_brokers() -> ne_binaries(). +-spec federated_brokers() -> kz_term:ne_binaries(). federated_brokers() -> MatchSpec = [{#kz_amqp_connections{zone='$1' ,broker='$2' @@ -231,7 +231,7 @@ federated_brokers() -> ) ). --spec broker_zone(ne_binary()) -> atom(). +-spec broker_zone(kz_term:ne_binary()) -> atom(). broker_zone(Broker) -> Pattern = #kz_amqp_connections{broker=Broker ,zone='$1' @@ -300,7 +300,7 @@ init([]) -> %% {'stop', Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Msg, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -314,7 +314,7 @@ handle_call(_Msg, _From, State) -> %% {'stop', Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'new_connection', Connection, Broker, Zone, Tags}, State) -> Ref = erlang:monitor('process', Connection), _ = ets:insert(?TAB, #kz_amqp_connections{connection=Connection @@ -355,7 +355,7 @@ handle_cast(_Msg, State) -> %% {'stop', Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'DOWN', Ref, 'process', Connection, _Reason}, State) -> lager:warning("connection ~p went down: ~p" ,[Connection, _Reason]), @@ -417,7 +417,7 @@ notify_watcher(Watcher) -> Watcher ! {?MODULE, 'connection_available'}, ok. --spec wait_for_notification(kz_timeout()) -> +-spec wait_for_notification(timeout()) -> 'ok' | {'error', 'timeout'}. wait_for_notification(Timeout) -> @@ -427,8 +427,8 @@ wait_for_notification(Timeout) -> Timeout -> {'error', 'timeout'} end. --spec brokers_with_tag(ne_binary()) -> kz_amqp_connections_list(). --spec brokers_with_tag(ne_binary(), api_boolean()) -> kz_amqp_connections_list(). +-spec brokers_with_tag(kz_term:ne_binary()) -> kz_amqp_connections_list(). +-spec brokers_with_tag(kz_term:ne_binary(), kz_term:api_boolean()) -> kz_amqp_connections_list(). brokers_with_tag(Tag) -> %% by default we want all the brokers brokers_with_tag(Tag, 'undefined'). @@ -450,7 +450,7 @@ brokers_with_tag(Tag, Available) -> lists:member(Tag, Tags) ]. --spec broker_with_tag(ne_binary()) -> api_binary(). +-spec broker_with_tag(kz_term:ne_binary()) -> kz_term:api_binary(). broker_with_tag(Tag) -> case brokers_with_tag(Tag, 'true') of [] -> 'undefined'; @@ -458,7 +458,7 @@ broker_with_tag(Tag) -> end. -spec brokers_for_zone(atom()) -> kz_amqp_connections_list(). --spec brokers_for_zone(atom(), api_boolean()) -> kz_amqp_connections_list(). +-spec brokers_for_zone(atom(), kz_term:api_boolean()) -> kz_amqp_connections_list(). brokers_for_zone(Zone) -> %% by default we want all the brokers @@ -482,7 +482,7 @@ brokers_for_zone(Zone, Available) -> ], ets:select(?TAB, MatchSpec). --spec broker_for_zone(atom()) -> api_binary(). +-spec broker_for_zone(atom()) -> kz_term:api_binary(). broker_for_zone(Zone) -> case brokers_for_zone(Zone, 'true') of [] -> 'undefined'; @@ -492,7 +492,7 @@ broker_for_zone(Zone) -> -spec is_zone_available(atom()) -> boolean(). is_zone_available(Zone) -> broker_for_zone(Zone) =/= 'undefined'. --spec is_tag_available(ne_binary()) -> boolean(). +-spec is_tag_available(kz_term:ne_binary()) -> boolean(). is_tag_available(Tag) -> broker_with_tag(Tag) =/= 'undefined'. -spec is_hidden_broker(list()) -> boolean(). diff --git a/core/kazoo_amqp/src/kz_amqp_history.erl b/core/kazoo_amqp/src/kz_amqp_history.erl index 0a938e620e1..9144917b1b8 100644 --- a/core/kazoo_amqp/src/kz_amqp_history.erl +++ b/core/kazoo_amqp/src/kz_amqp_history.erl @@ -35,13 +35,13 @@ -define(TAB, ?MODULE). -record(state, {consumers = sets:new() :: sets:set(pid()) - ,exchanges = dict:new() :: dict:dict(ne_binary(), kz_amqp_exchange()) + ,exchanges = dict:new() :: dict:dict(kz_term:ne_binary(), kz_amqp_exchange()) ,connections = sets:new() :: sets:set(pid()) }). -type state() :: #state{}. --record(kz_amqp_history, {timestamp = os:timestamp() :: kz_now() | '_' - ,consumer :: api_pid() | '_' +-record(kz_amqp_history, {timestamp = os:timestamp() :: kz_time:now() | '_' + ,consumer :: kz_term:api_pid() | '_' ,command :: kz_amqp_command() | '_' }). -type kz_amqp_history() :: #kz_amqp_history{}. @@ -53,7 +53,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_server:start_link({'local', ?SERVER}, ?MODULE, [], []). @@ -84,7 +84,7 @@ send_command(Consumer, Command, 'async') -> send_command(Consumer, Command, 'sync') -> gen_server:call(?SERVER, {'command', Consumer, Command}). --spec update_consumer_tag(pid(), ne_binary(), ne_binary()) -> 'ok'. +-spec update_consumer_tag(pid(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. update_consumer_tag(Consumer, OldTag, NewTag) -> gen_server:cast(?SERVER, {'update_consumer_tag', Consumer, OldTag, NewTag}). @@ -94,7 +94,7 @@ remove(Consumer) when is_pid(Consumer) -> gen_server:cast(?SERVER, {'remove', Consumer}); remove(_) -> 'ok'. --spec get(api_pid()) -> kz_amqp_commands(). +-spec get(kz_term:api_pid()) -> kz_amqp_commands(). get('undefined') -> []; get(Consumer) -> Pattern = #kz_amqp_history{consumer=Consumer @@ -123,7 +123,7 @@ list_consume(Consumer) -> || #kz_amqp_history{command=Command} <- ets:match_object(?TAB, Pattern) ]. --spec is_consuming(pid(), ne_binary()) -> boolean(). +-spec is_consuming(pid(), kz_term:ne_binary()) -> boolean(). is_consuming(Consumer, Queue) -> MatchSpec = [{#kz_amqp_history{consumer=Consumer ,command=#'basic.consume'{queue=Queue @@ -136,7 +136,7 @@ is_consuming(Consumer, Queue) -> }], ets:select_count(?TAB, MatchSpec) =/= 0. --spec is_bound(pid(), ne_binary(), ne_binary(), ne_binary()) -> boolean(). +-spec is_bound(pid(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_bound(Consumer, Exchange, Queue, RoutingKey) when is_pid(Consumer) -> MatchSpec = [{#kz_amqp_history{consumer=Consumer ,command=#'queue.bind'{queue=Queue @@ -190,7 +190,7 @@ init([]) -> %% {'stop', Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call({'command', Consumer, #'queue.unbind'{}=Unbind}, _From, State) -> unbind_queue(Consumer, Unbind), {'reply', 'ok', State}; @@ -225,7 +225,7 @@ handle_call(_Msg, _From, State) -> %% {'stop', Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'update_consumer_tag', Consumer, OldTag, NewTag}, State) -> Pattern = #kz_amqp_history{consumer=Consumer ,command=#'basic.consume'{consumer_tag=OldTag @@ -285,7 +285,7 @@ handle_cast(_Msg, State) -> %% {'stop', Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'remove_history', Pid}, State) -> _ = remove(Pid), {'noreply', State}; @@ -337,7 +337,7 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec update_consumer_tag({kz_amqp_history(), ets:continuation()} | '$end_of_table', ne_binary()) -> 'ok'. +-spec update_consumer_tag({kz_amqp_history(), ets:continuation()} | '$end_of_table', kz_term:ne_binary()) -> 'ok'. update_consumer_tag('$end_of_table', _) -> 'ok'; update_consumer_tag({[#kz_amqp_history{timestamp=Timestamp ,command=Command} diff --git a/core/kazoo_amqp/src/kz_amqp_sup.erl b/core/kazoo_amqp/src/kz_amqp_sup.erl index 3d7a96257ae..e9651352414 100644 --- a/core/kazoo_amqp/src/kz_amqp_sup.erl +++ b/core/kazoo_amqp/src/kz_amqp_sup.erl @@ -66,7 +66,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -88,38 +88,38 @@ pool_name() -> Name end. --spec add_amqp_pool(atom() | binary(), binary(), integer(), integer()) -> sup_startchild_ret(). +-spec add_amqp_pool(atom() | binary(), binary(), integer(), integer()) -> kz_types:sup_startchild_ret(). add_amqp_pool(UUID, Broker, PoolSize, PoolOverflow) -> add_amqp_pool(UUID, Broker, PoolSize, PoolOverflow, []). --spec add_amqp_pool(UUID, Broker, PoolSize, PoolOverflow, Bindings) -> sup_startchild_ret() when +-spec add_amqp_pool(UUID, Broker, PoolSize, PoolOverflow, Bindings) -> kz_types:sup_startchild_ret() when UUID :: atom() | binary(), Broker :: binary(), PoolSize :: integer(), PoolOverflow :: integer(), - Bindings :: kz_proplist(). + Bindings :: kz_term:proplist(). add_amqp_pool(UUID, Broker, PoolSize, PoolOverflow, Bindings) -> add_amqp_pool(UUID, Broker, PoolSize, PoolOverflow, Bindings, []). --type exchange() :: {ne_binary(), ne_binary(), kz_proplist()}. +-type exchange() :: {kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()}. -type exchanges() :: [exchange()]. --spec add_amqp_pool(UUID, Broker, PoolSize, PoolOverflow, Bindings, Exchanges) -> sup_startchild_ret() when +-spec add_amqp_pool(UUID, Broker, PoolSize, PoolOverflow, Bindings, Exchanges) -> kz_types:sup_startchild_ret() when UUID :: atom() | binary(), Broker :: binary(), PoolSize :: integer(), PoolOverflow :: integer(), - Bindings :: kz_proplist(), + Bindings :: kz_term:proplist(), Exchanges :: exchanges(). add_amqp_pool(UUID, Broker, PoolSize, PoolOverflow, Bindings, Exchanges) -> add_amqp_pool(UUID, Broker, PoolSize, PoolOverflow, Bindings, Exchanges, 'false'). --spec add_amqp_pool(UUID, Broker, PoolSize, PoolOverflow, Bindings, Exchanges, ServerAck) -> sup_startchild_ret() when +-spec add_amqp_pool(UUID, Broker, PoolSize, PoolOverflow, Bindings, Exchanges, ServerAck) -> kz_types:sup_startchild_ret() when UUID :: atom() | binary(), Broker :: binary(), PoolSize :: integer(), PoolOverflow :: integer(), - Bindings :: kz_proplist(), + Bindings :: kz_term:proplist(), Exchanges :: exchanges(), ServerAck :: boolean(). add_amqp_pool(Uuid, Broker, PoolSize, PoolOverflow, Bindings, Exchanges, ServerAck) -> @@ -127,7 +127,7 @@ add_amqp_pool(Uuid, Broker, PoolSize, PoolOverflow, Bindings, Exchanges, ServerA Args = ?ADD_POOL_ARGS(UUID, Broker, PoolSize, PoolOverflow, Bindings, Exchanges, ServerAck), supervisor:start_child(?SERVER, ?POOL_NAME_ARGS(UUID, Args)). --spec pool_pid(atom() | binary()) -> api_pid(). +-spec pool_pid(atom() | binary()) -> kz_term:api_pid(). pool_pid(Pool) -> ID = kz_term:to_atom(Pool, 'true'), case [ Pid || {Id,Pid,_,_} <- supervisor:which_children(?SERVER), Id == ID] of @@ -149,7 +149,7 @@ pool_pid(Pool) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, diff --git a/core/kazoo_amqp/src/kz_amqp_worker.erl b/core/kazoo_amqp/src/kz_amqp_worker.erl index b570b84caf0..dba40fbfcb8 100644 --- a/core/kazoo_amqp/src/kz_amqp_worker.erl +++ b/core/kazoo_amqp/src/kz_amqp_worker.erl @@ -64,8 +64,8 @@ -define(QUEUE_OPTIONS, []). -define(CONSUME_OPTIONS, []). --type publish_fun() :: fun((api_terms()) -> any()). --type validate_fun() :: fun((api_terms()) -> boolean()). +-type publish_fun() :: fun((kz_term:api_terms()) -> any()). +-type validate_fun() :: fun((kz_term:api_terms()) -> boolean()). -type collect_until_acc() :: any(). @@ -74,7 +74,7 @@ collect_until_acc_fun() | {collect_until_acc_fun(), collect_until_acc()}. --type whapp() :: atom() | ne_binary(). +-type whapp() :: atom() | kz_term:ne_binary(). -type collect_until() :: collect_until_fun() | whapp() | @@ -82,7 +82,7 @@ {whapp(), validate_fun(), boolean()} | %% {Whapp, VFun, IncludeFederated} {whapp(), boolean(), boolean()} | %% {Whapp, IncludeFederated, IsShared} {whapp(), validate_fun(), boolean(), boolean()}. %% {Whapp, VFun, IncludeFederated, IsShared} --type timeout_or_until() :: kz_timeout() | collect_until(). +-type timeout_or_until() :: timeout() | collect_until(). %% case {IsFederated, IsShared} of %% {'true', 'true'} -> Get from {0,1} whapp instance per zone @@ -97,24 +97,24 @@ ,cast_return/0 ]). --record(state, {current_msg_id :: api_binary() - ,client_pid :: api_pid() - ,client_ref :: api_reference() - ,client_from :: api_pid_ref() | 'relay' +-record(state, {current_msg_id :: kz_term:api_binary() + ,client_pid :: kz_term:api_pid() + ,client_ref :: kz_term:api_reference() + ,client_from :: kz_term:api_pid_ref() | 'relay' ,client_vfun :: validate_fun() | 'undefined' ,client_cfun = collect_until_timeout() :: collect_until_fun() - ,responses :: api_objects() - ,neg_resp :: api_object() + ,responses :: kz_term:api_objects() + ,neg_resp :: kz_term:api_object() ,neg_resp_count = 0 :: non_neg_integer() ,neg_resp_threshold = 1 :: pos_integer() - ,req_timeout_ref :: api_reference() - ,req_start_time :: kz_now() | 'undefined' - ,callid :: api_binary() - ,pool_ref :: server_ref() - ,defer_response :: api_object() - ,queue :: api_binary() + ,req_timeout_ref :: kz_term:api_reference() + ,req_start_time :: kz_time:now() | 'undefined' + ,callid :: kz_term:api_binary() + ,pool_ref :: kz_types:server_ref() + ,defer_response :: kz_term:api_object() + ,queue :: kz_term:api_binary() ,confirms = 'false' :: boolean() - ,flow = 'undefined' :: api_boolean() + ,flow = 'undefined' :: kz_term:api_boolean() ,acc = 'undefined' :: any() ,defer = 'undefined' :: 'undefined' | {any(), {pid(), reference()}} }). @@ -127,7 +127,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(kz_proplist()) -> startlink_ret(). +-spec start_link(kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Args) -> gen_listener:start_link(?SERVER, [{'bindings', maybe_bindings(Args)} ,{'responders', ?RESPONDERS} @@ -139,35 +139,35 @@ start_link(Args) -> ++ maybe_server_confirms(Args) ], [Args]). --spec maybe_broker(kz_proplist()) -> kz_proplist(). +-spec maybe_broker(kz_term:proplist()) -> kz_term:proplist(). maybe_broker(Args) -> case props:get_value('amqp_broker', Args) of 'undefined' -> []; Broker -> [{'broker', Broker}] end. --spec maybe_queuename(kz_proplist()) -> binary(). +-spec maybe_queuename(kz_term:proplist()) -> binary(). maybe_queuename(Args) -> case props:get_value('amqp_queuename_start', Args) of 'undefined' -> ?QUEUE_NAME; QueueStart -> <<(kz_term:to_binary(QueueStart))/binary, "_", (kz_binary:rand_hex(4))/binary>> end. --spec maybe_bindings(kz_proplist()) -> kz_proplist(). +-spec maybe_bindings(kz_term:proplist()) -> kz_term:proplist(). maybe_bindings(Args) -> case props:get_value('amqp_bindings', Args) of 'undefined' -> ?BINDINGS; Bindings -> Bindings end. --spec maybe_exchanges(kz_proplist()) -> kz_proplist(). +-spec maybe_exchanges(kz_term:proplist()) -> kz_term:proplist(). maybe_exchanges(Args) -> case props:get_value('amqp_exchanges', Args) of 'undefined' -> []; Exchanges -> [{'declare_exchanges', Exchanges}] end. --spec maybe_server_confirms(kz_proplist()) -> kz_proplist(). +-spec maybe_server_confirms(kz_term:proplist()) -> kz_term:proplist(). maybe_server_confirms(Args) -> case props:get_value('amqp_server_confirms', Args) of 'undefined' -> []; @@ -181,11 +181,11 @@ default_timeout() -> 2 * ?MILLISECONDS_IN_SECOND. {'returned', kz_json:object(), kz_json:object()} | {'timeout', kz_json:objects()} | {'error', any()}. --spec call(api_terms(), publish_fun(), validate_fun()) -> +-spec call(kz_term:api_terms(), publish_fun(), validate_fun()) -> request_return(). --spec call(api_terms(), publish_fun(), validate_fun(), kz_timeout()) -> +-spec call(kz_term:api_terms(), publish_fun(), validate_fun(), timeout()) -> request_return(). --spec call(api_terms(), publish_fun(), validate_fun(), kz_timeout(), pid() | atom()) -> +-spec call(kz_term:api_terms(), publish_fun(), validate_fun(), timeout(), pid() | atom()) -> request_return(). call(Req, PubFun, VFun) -> call(Req, PubFun, VFun, default_timeout()). @@ -258,11 +258,11 @@ checkin_worker(Worker) -> checkin_worker(Worker, Pool) -> poolboy:checkin(Pool, Worker). --spec call_custom(api_terms(), publish_fun(), validate_fun(), gen_listener:binding()) -> +-spec call_custom(kz_term:api_terms(), publish_fun(), validate_fun(), gen_listener:binding()) -> request_return(). --spec call_custom(api_terms(), publish_fun(), validate_fun(), kz_timeout(), gen_listener:binding()) -> +-spec call_custom(kz_term:api_terms(), publish_fun(), validate_fun(), timeout(), gen_listener:binding()) -> request_return(). --spec call_custom(api_terms(), publish_fun(), validate_fun(), kz_timeout(), gen_listener:binding(), pid()) -> +-spec call_custom(kz_term:api_terms(), publish_fun(), validate_fun(), timeout(), gen_listener:binding(), pid()) -> request_return(). call_custom(Req, PubFun, VFun, Bind) -> call_custom(Req, PubFun, VFun, default_timeout(), Bind). @@ -288,13 +288,13 @@ call_custom(Req, PubFun, VFun, Timeout, Bind, Worker) -> checkin_worker(Worker) end. --spec call_collect(api_terms(), publish_fun()) -> +-spec call_collect(kz_term:api_terms(), publish_fun()) -> request_return(). --spec call_collect(api_terms(), publish_fun(), timeout_or_until()) -> +-spec call_collect(kz_term:api_terms(), publish_fun(), timeout_or_until()) -> request_return(). --spec call_collect(api_terms(), publish_fun(), collect_until(), kz_timeout()) -> +-spec call_collect(kz_term:api_terms(), publish_fun(), collect_until(), timeout()) -> request_return(). --spec call_collect(api_terms(), publish_fun(), collect_until(), kz_timeout(), pid()) -> +-spec call_collect(kz_term:api_terms(), publish_fun(), collect_until(), timeout(), pid()) -> request_return(). call_collect(Req, PubFun) -> call_collect(Req, PubFun, default_timeout()). @@ -393,8 +393,8 @@ call_collect(Req, PubFun, UntilFun, Timeout, Acc, Worker) -> {'error', any()} | {'returned', kz_json:object(), kz_json:object()}. --spec cast(api_terms(), publish_fun()) -> cast_return(). --spec cast(api_terms(), publish_fun(), pid() | atom()) -> cast_return(). +-spec cast(kz_term:api_terms(), publish_fun()) -> cast_return(). +-spec cast(kz_term:api_terms(), publish_fun(), pid() | atom()) -> cast_return(). cast(Req, PubFun) -> cast(Req, PubFun, worker_pool()). @@ -426,16 +426,16 @@ stop_relay(Worker, RelayPid) -> -spec collect_until_timeout() -> collect_until_fun(). collect_until_timeout() -> fun kz_term:always_false/1. --spec collect_from_whapp(text()) -> 'undefined' | collect_until_fun(). +-spec collect_from_whapp(kz_term:text()) -> 'undefined' | collect_until_fun(). collect_from_whapp(Whapp) -> collect_from_whapp(Whapp, 'false'). --spec collect_from_whapp(text(), boolean()) -> +-spec collect_from_whapp(kz_term:text(), boolean()) -> 'undefined' | collect_until_fun(). collect_from_whapp(Whapp, IncludeFederated) -> collect_from_whapp(Whapp, IncludeFederated, 'false'). --spec collect_from_whapp(text(), boolean(), boolean()) -> +-spec collect_from_whapp(kz_term:text(), boolean(), boolean()) -> 'undefined' | collect_until_fun(). collect_from_whapp(Whapp, IncludeFederated, IsShared) -> Count = case {IncludeFederated, IsShared} of @@ -451,15 +451,15 @@ count_fun(0) -> 'undefined'; count_fun(Count) -> fun(Responses) -> length(Responses) >= Count end. --spec collect_from_whapp_or_validate(text(), validate_fun()) -> collect_until_fun(). +-spec collect_from_whapp_or_validate(kz_term:text(), validate_fun()) -> collect_until_fun(). collect_from_whapp_or_validate(Whapp, VFun) -> collect_from_whapp_or_validate(Whapp, VFun, 'false'). --spec collect_from_whapp_or_validate(text(),validate_fun(), boolean()) -> collect_until_fun(). +-spec collect_from_whapp_or_validate(kz_term:text(),validate_fun(), boolean()) -> collect_until_fun(). collect_from_whapp_or_validate(Whapp, VFun, IncludeFederated) -> collect_from_whapp_or_validate(Whapp, VFun, IncludeFederated, 'false'). --spec collect_from_whapp_or_validate(text(),validate_fun(), boolean(), boolean()) -> collect_until_fun(). +-spec collect_from_whapp_or_validate(kz_term:text(),validate_fun(), boolean(), boolean()) -> collect_until_fun(). collect_from_whapp_or_validate(Whapp, VFun, 'true', 'true') -> Count = kz_nodes:whapp_zone_count(Whapp), lager:debug("attempting to collect ~p responses from ~s or the first valid", [Count, Whapp]), @@ -482,13 +482,13 @@ collect_or_validate_fun(VFun, Count) -> orelse VFun(Response) end. --spec handle_resp(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_resp(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_resp(JObj, Props) -> gen_listener:cast(props:get_value('server', Props) ,{'event', kz_api:msg_id(JObj), JObj} ). --spec send_request(ne_binary(), ne_binary(), publish_fun(), kz_proplist()) -> +-spec send_request(kz_term:ne_binary(), kz_term:ne_binary(), publish_fun(), kz_term:proplist()) -> 'ok' | {'error', any()}. send_request(CallId, Self, PublishFun, ReqProps) when is_function(PublishFun, 1) -> @@ -509,11 +509,11 @@ send_request(CallId, Self, PublishFun, ReqProps) {'error', E} end. --spec request_filter(kz_proplist()) -> kz_proplist(). +-spec request_filter(kz_term:proplist()) -> kz_term:proplist(). request_filter(Props) -> props:filter(fun request_proplist_filter/1, Props). --spec request_proplist_filter({kz_proplist_key(), kz_proplist_value()}) -> boolean(). +-spec request_proplist_filter({kz_term:proplist_key(), kz_term:proplist_value()}) -> boolean(). request_proplist_filter({<<"Server-ID">>, Value}) -> not kz_term:is_empty(Value); request_proplist_filter({_, 'undefined'}) -> 'false'; @@ -558,7 +558,7 @@ init([Args]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(Call, From, #state{queue='undefined'}=State) when is_tuple(Call) -> kz_util:put_callid(element(2, Call)), @@ -689,7 +689,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', Q}}, #state{defer='undefined'}=State) -> {'noreply', State#state{queue=Q}}; handle_cast({'gen_listener', {'created_queue', Q}}, #state{defer={Call,From}}=State) -> @@ -861,7 +861,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'DOWN', ClientRef, 'process', _Pid, _Reason} ,#state{current_msg_id = _MsgId ,client_ref = ClientRef @@ -936,7 +936,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(JObj, #state{client_from='relay' ,client_pid=Pid }) -> @@ -1005,23 +1005,23 @@ reset(#state{req_timeout_ref = ReqRef ,responses = 'undefined' }. --spec fudge_timeout(kz_timeout()) -> kz_timeout(). +-spec fudge_timeout(timeout()) -> timeout(). fudge_timeout('infinity'=T) -> T; fudge_timeout(T) -> T + ?FUDGE. --spec start_req_timeout(kz_timeout()) -> reference(). +-spec start_req_timeout(timeout()) -> reference(). start_req_timeout('infinity') -> make_ref(); start_req_timeout(Timeout) -> erlang:start_timer(Timeout, self(), 'req_timeout'). --spec maybe_convert_to_proplist(kz_proplist() | kz_json:object()) -> kz_proplist(). +-spec maybe_convert_to_proplist(kz_term:proplist() | kz_json:object()) -> kz_term:proplist(). maybe_convert_to_proplist(Req) -> case kz_json:is_json_object(Req) of 'true' -> maybe_set_msg_id(kz_json:to_proplist(Req)); 'false' -> maybe_set_msg_id(Req) end. --spec maybe_set_msg_id(kz_proplist()) -> kz_proplist(). +-spec maybe_set_msg_id(kz_term:proplist()) -> kz_term:proplist(). maybe_set_msg_id(Props) -> case kz_api:msg_id(Props) of 'undefined' -> @@ -1030,7 +1030,7 @@ maybe_set_msg_id(Props) -> Props end. --spec publish_api(fun(), api_terms()) -> 'ok' | {'error', any()}. +-spec publish_api(fun(), kz_term:api_terms()) -> 'ok' | {'error', any()}. publish_api(PublishFun, ReqProps) -> try PublishFun(ReqProps) of 'ok' -> 'ok'; diff --git a/core/kazoo_amqp/src/listener_federator.erl b/core/kazoo_amqp/src/listener_federator.erl index 307230c6b9f..96359e65cf8 100644 --- a/core/kazoo_amqp/src/listener_federator.erl +++ b/core/kazoo_amqp/src/listener_federator.erl @@ -29,9 +29,9 @@ -define(SERVER, ?MODULE). -record(state, {parent :: pid() - ,broker :: ne_binary() - ,self_binary = kz_term:to_binary(pid_to_list(self())) :: ne_binary() - ,zone :: ne_binary() + ,broker :: kz_term:ne_binary() + ,self_binary = kz_term:to_binary(pid_to_list(self())) :: kz_term:ne_binary() + ,zone :: kz_term:ne_binary() }). -type state() :: #state{}. @@ -42,15 +42,15 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(pid(), ne_binary(), kz_proplist()) -> startlink_ret(). +-spec start_link(pid(), kz_term:ne_binary(), kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Parent, Broker, Params) -> gen_listener:start_link(?SERVER, Params, [Parent, Broker]). --spec broker(server_ref()) -> ne_binary(). +-spec broker(kz_types:server_ref()) -> kz_term:ne_binary(). broker(Pid) -> gen_listener:call(Pid, 'get_broker'). --spec stop(server_ref()) -> 'ok'. +-spec stop(kz_types:server_ref()) -> 'ok'. stop(Pid) -> gen_listener:call(Pid, {'stop', self()}). @@ -69,7 +69,7 @@ stop(Pid) -> %% {stop, Reason} %% @end %%-------------------------------------------------------------------- --spec init([pid() | ne_binary()]) -> {'ok', state()}. +-spec init([pid() | kz_term:ne_binary()]) -> {'ok', state()}. init([Parent, Broker]=L) -> lager:debug("federating listener ~p on broker ~s", L), _ = kz_amqp_channel:consumer_broker(Broker), @@ -93,7 +93,7 @@ init([Parent, Broker]=L) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), any(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), any(), state()) -> kz_types:handle_call_ret_state(state()). handle_call({'stop', Parent}, _From, #state{parent=Parent}=State) -> {'stop', 'normal', 'ok', State}; handle_call('get_broker', _From, #state{broker=Broker}=State) -> @@ -111,7 +111,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _}}, State) -> {'noreply', State}; handle_cast(_Msg, State) -> @@ -127,7 +127,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. diff --git a/core/kazoo_amqp/src/listener_types.hrl b/core/kazoo_amqp/src/listener_types.hrl index 9e7705ac2c8..5dce6f6a81a 100644 --- a/core/kazoo_amqp/src/listener_types.hrl +++ b/core/kazoo_amqp/src/listener_types.hrl @@ -4,7 +4,7 @@ -include_lib("kazoo_stdlib/include/kz_types.hrl"). -include_lib("kazoo_stdlib/include/kz_log.hrl"). --type binding_module() :: atom() | ne_binary(). +-type binding_module() :: atom() | kz_term:ne_binary(). -type binding_property() :: {'restrict_to', list()}. -type binding_properties() :: [binding_property()]. @@ -13,24 +13,24 @@ -type bindings() :: [binding()]. %% ExchangeName, ExchangeType[, ExchangeOptions] --type declare_exchange() :: {ne_binary(), ne_binary()} | - {ne_binary(), ne_binary(), kz_proplist()}. +-type declare_exchange() :: {kz_term:ne_binary(), kz_term:ne_binary()} | + {kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()}. -type declare_exchanges() :: [declare_exchange()]. -type start_params() :: [{'responders', responder_start_params()} | {'bindings', bindings()} | {'queue_name', binary()} | - {'queue_options', kz_proplist()} | - {'consume_options', kz_proplist()} | + {'queue_options', kz_term:proplist()} | + {'consume_options', kz_term:proplist()} | {'basic_qos', non_neg_integer()} | - {'broker' | 'broker_tag', ne_binary()} | + {'broker' | 'broker_tag', kz_term:ne_binary()} | {'declare_exchanges', declare_exchanges()} | {'auto_ack', boolean()} ]. --type responder_callback_fun2() :: fun((kz_json:object(), kz_proplist()) -> any()). --type responder_callback_fun3() :: fun((kz_json:object(), kz_proplist(), basic_deliver()) -> any()). --type responder_callback_fun4() :: fun((kz_json:object(), kz_proplist(), basic_deliver(), amqp_basic()) -> any()). +-type responder_callback_fun2() :: fun((kz_json:object(), kz_term:proplist()) -> any()). +-type responder_callback_fun3() :: fun((kz_json:object(), kz_term:proplist(), basic_deliver()) -> any()). +-type responder_callback_fun4() :: fun((kz_json:object(), kz_term:proplist(), basic_deliver(), amqp_basic()) -> any()). -type responder_callback_fun() :: responder_callback_fun2() | responder_callback_fun3() | responder_callback_fun4(). @@ -38,7 +38,7 @@ -type responder_callback() :: module() | {module(), atom()} | responder_callback_fun(). --type responder_callback_mapping() :: {ne_binary(), ne_binary()}. +-type responder_callback_mapping() :: {kz_term:ne_binary(), kz_term:ne_binary()}. -type responder_callback_mappings() :: [responder_callback_mapping()]. -type responder_start_params() :: [{responder_callback(), responder_callback_mappings()}]. diff --git a/core/kazoo_apps/src/kapps_alert.erl b/core/kazoo_apps/src/kapps_alert.erl index 712e675e407..a020b0aff8f 100644 --- a/core/kazoo_apps/src/kapps_alert.erl +++ b/core/kazoo_apps/src/kapps_alert.erl @@ -32,7 +32,7 @@ enabled() -> %% @doc %% @end %%-------------------------------------------------------------------- --spec fetch(ne_binary()) -> +-spec fetch(kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. fetch(AlertId) -> @@ -43,14 +43,14 @@ fetch(AlertId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec create(ne_binary(), ne_binary(), kz_json:objects(), kz_json:objects()) -> +-spec create(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:objects(), kz_json:objects()) -> {'ok', kzd_alert:doc()} | {'error', any()}. --spec create(ne_binary(), ne_binary(), kz_json:objects() - ,kz_json:objects(), kz_proplist() +-spec create(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:objects() + ,kz_json:objects(), kz_term:proplist() ) -> {'ok', kz_json:object()} | - {'required', ne_binary()} | + {'required', kz_term:ne_binary()} | {'error', 'disabled'}. create(Title, Message, From, To) -> create(Title, Message, From, To, []). @@ -96,7 +96,7 @@ save(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec delete(kzd_alert:doc() | ne_binary()) -> +-spec delete(kzd_alert:doc() | kz_term:ne_binary()) -> {'ok', kzd_alert:doc()} | {'error', any()}. delete(AlertId) when is_binary(AlertId) -> @@ -118,7 +118,7 @@ delete(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec maybe_add_options(kz_json:object(), kz_proplist()) -> kz_json:object(). +-spec maybe_add_options(kz_json:object(), kz_term:proplist()) -> kz_json:object(). maybe_add_options(JObj, Props) -> Options = [{kzd_alert:category(), fun kzd_alert:set_category/2} ,{kzd_alert:metadata(), fun kzd_alert:set_metadata/2} @@ -131,7 +131,7 @@ maybe_add_options(JObj, Props) -> ). -type update_fun() :: fun((kzd_alert:doc(), kz_json:json_term()) -> kzd_alert:doc()). --spec maybe_add_option({ne_binary(), update_fun()}, kzd_alert:doc(), kz_proplist()) -> +-spec maybe_add_option({kz_term:ne_binary(), update_fun()}, kzd_alert:doc(), kz_term:proplist()) -> kzd_alert:doc(). maybe_add_option({Option, Fun}, Acc, Props) -> case props:get_value(Option, Props) of diff --git a/core/kazoo_apps/src/kapps_controller.erl b/core/kazoo_apps/src/kapps_controller.erl index d29381fed38..31e72a65708 100644 --- a/core/kazoo_apps/src/kapps_controller.erl +++ b/core/kazoo_apps/src/kapps_controller.erl @@ -29,7 +29,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> _ = kz_util:spawn(fun initialize_kapps/0), 'ignore'. @@ -38,8 +38,8 @@ start_link() -> start_default_apps() -> [{App, start_app(App)} || App <- ?DEFAULT_KAPPS]. --spec start_app(atom() | nonempty_string() | ne_binary()) -> - {'ok', atoms()} | +-spec start_app(atom() | nonempty_string() | kz_term:ne_binary()) -> + {'ok', kz_term:atoms()} | {'error', any()}. start_app(App) when is_atom(App) -> case application:ensure_all_started(App) of @@ -53,7 +53,7 @@ start_app(App) when is_atom(App) -> start_app(App) -> start_app(kz_term:to_atom(App, 'true')). --spec stop_app(atom() | nonempty_string() | ne_binary()) -> 'ok' | {'error', any()}. +-spec stop_app(atom() | nonempty_string() | kz_term:ne_binary()) -> 'ok' | {'error', any()}. stop_app(App) when is_atom(App) -> case application:stop(App) of 'ok' -> @@ -68,7 +68,7 @@ stop_app(App) when is_atom(App) -> stop_app(App) -> stop_app(kz_term:to_atom(App)). --spec restart_app(atom() | nonempty_string() | ne_binary()) -> 'ok' | {'error', any()}. +-spec restart_app(atom() | nonempty_string() | kz_term:ne_binary()) -> 'ok' | {'error', any()}. restart_app(App) when is_atom(App) -> lager:info("restarting kazoo application ~s", [App]), _ = stop_app(App), @@ -76,8 +76,8 @@ restart_app(App) when is_atom(App) -> restart_app(App) -> restart_app(kz_term:to_atom(App, 'true')). --spec running_apps() -> atoms() | string(). --spec running_apps(boolean()) -> atoms() | string(). +-spec running_apps() -> kz_term:atoms() | string(). +-spec running_apps(boolean()) -> kz_term:atoms() | string(). running_apps() -> running_apps('false'). @@ -87,7 +87,7 @@ running_apps(Verbose) -> 'false' -> running_apps_list() end. --spec running_apps_verbose() -> atoms() | string(). +-spec running_apps_verbose() -> kz_term:atoms() | string(). running_apps_verbose() -> case get_running_apps() of [] -> "kapps have not started yet, check that rabbitmq and bigcouch/haproxy are running at the configured addresses"; @@ -106,7 +106,7 @@ get_running_apps() -> is_kapp(App) ]. --spec running_apps_list() -> atoms() | string(). +-spec running_apps_list() -> kz_term:atoms() | string(). running_apps_list() -> case get_running_apps() of [] -> "kapps have not started yet, check that rabbitmq and bigcouch/haproxy are running at the configured addresses"; @@ -125,7 +125,7 @@ initialize_kapps() -> ], lager:notice("auto-started kapps ~p", [lists:sort(Started)]). --spec start_which_kapps() -> [ne_binary() | atom() | nonempty_string()]. +-spec start_which_kapps() -> [kz_term:ne_binary() | atom() | nonempty_string()]. start_which_kapps() -> Routines = [fun maybe_start_from_env/0 ,fun maybe_start_from_node_config/0 @@ -149,7 +149,7 @@ maybe_start_from_env() -> string:tokens(KazooApps, ", ") end. --spec maybe_start_from_node_name() -> 'false' | atoms(). +-spec maybe_start_from_node_name() -> 'false' | kz_term:atoms(). maybe_start_from_node_name() -> KApp = kapp_from_node_name(), case is_kapp(KApp) of @@ -159,7 +159,7 @@ maybe_start_from_node_name() -> [KApp] end. --spec maybe_start_from_node_config() -> 'false' | [ne_binary() | atom()]. +-spec maybe_start_from_node_config() -> 'false' | [kz_term:ne_binary() | atom()]. maybe_start_from_node_config() -> case kapps_config:get_node_value(?MODULE, <<"kapps">>) of 'undefined' -> 'false'; @@ -170,7 +170,7 @@ maybe_start_from_node_config() -> KazooApps end. --spec start_from_default_config() -> 'false' | [ne_binary() | atom()]. +-spec start_from_default_config() -> 'false' | [kz_term:ne_binary() | atom()]. start_from_default_config() -> lager:info("starting applications from default configuration"), kapps_config:get(?MODULE, <<"kapps">>, ?DEFAULT_KAPPS). @@ -184,7 +184,7 @@ sysconf_first('sysconf', _) -> 'true'; sysconf_first(_, 'sysconf') -> 'false'; sysconf_first(_, _) -> 'true'. --spec list_apps() -> atoms(). +-spec list_apps() -> kz_term:atoms(). list_apps() -> [App || {App, _, _} <- get_running_apps()]. diff --git a/core/kazoo_apps/src/kapps_maintenance.erl b/core/kazoo_apps/src/kapps_maintenance.erl index 0cea02164c3..a660d8928fe 100644 --- a/core/kazoo_apps/src/kapps_maintenance.erl +++ b/core/kazoo_apps/src/kapps_maintenance.erl @@ -64,7 +64,7 @@ -include("kazoo_apps.hrl"). -type bind() :: 'migrate' | 'refresh' | 'refresh_account'. --spec binding(bind() | {bind(), ne_binary()}) -> ne_binary(). +-spec binding(bind() | {bind(), kz_term:ne_binary()}) -> kz_term:ne_binary(). binding('migrate') -> <<"maintenance.migrate">>; binding('refresh') -> <<"maintenance.refresh">>; binding('refresh_account') -> <<"maintenance.refresh.account">>; @@ -85,7 +85,7 @@ unbind(Event, M, F) -> kazoo_bindings:unbind(binding(Event), M, F). -define(VMBOX_VIEW, <<"vmboxes/crossbar_listing">>). -define(PMEDIA_VIEW, <<"media/listing_private_media">>). --spec refresh_account_db(ne_binary()) -> 'ok'. +-spec refresh_account_db(kz_term:ne_binary()) -> 'ok'. refresh_account_db(Database) -> kz_datamgr:refresh_views(Database), 'ok'. @@ -100,7 +100,7 @@ refresh_account_db(Database) -> rebuild_token_auth() -> rebuild_token_auth(5 * ?MILLISECONDS_IN_SECOND). --spec rebuild_token_auth(text() | integer()) -> 'ok'. +-spec rebuild_token_auth(kz_term:text() | integer()) -> 'ok'. rebuild_token_auth(Pause) -> _ = kz_datamgr:db_delete(?KZ_TOKEN_DB), timer:sleep(kz_term:to_integer(Pause)), @@ -131,7 +131,7 @@ migrate_to_4_0() -> migrate() -> migrate(2 * ?MILLISECONDS_IN_SECOND). --spec migrate(text() | integer()) -> 'no_return'. +-spec migrate(kz_term:text() | integer()) -> 'no_return'. migrate(Pause) -> _ = migrate_system(), _ = kapps_config:migrate(), @@ -145,7 +145,7 @@ migrate(Pause) -> 'no_return'. --spec migrate(text() | integer(), ne_binaries()) -> 'no_return'. +-spec migrate(kz_term:text() | integer(), kz_term:ne_binaries()) -> 'no_return'. migrate(Pause, Databases) -> Accounts = [kz_util:format_account_id(Db, 'encoded') || Db <- Databases, @@ -162,11 +162,11 @@ migrate(Pause, Databases) -> 'no_return'. --spec parallel_migrate(text() | integer()) -> 'no_return'. +-spec parallel_migrate(kz_term:text() | integer()) -> 'no_return'. parallel_migrate(Workers) -> parallel_migrate(Workers, 2 * ?MILLISECONDS_IN_SECOND). --spec parallel_migrate(text() | integer(), text() | integer()) -> 'no_return'. +-spec parallel_migrate(kz_term:text() | integer(), kz_term:text() | integer()) -> 'no_return'. parallel_migrate(Workers, Pause) -> _ = migrate_system(), _ = kapps_config:migrate(), @@ -177,8 +177,8 @@ parallel_migrate(Workers, Pause) -> SplitDbs = split(AccountSplit, AccountDbs, OtherSplit, Others, []), parallel_migrate(Pause, SplitDbs, []). --type split_results() :: [{ne_binaries(), ne_binaries()}]. --spec split(integer(), ne_binaries(), integer(), ne_binaries(), split_results()) -> split_results(). +-type split_results() :: [{kz_term:ne_binaries(), kz_term:ne_binaries()}]. +-spec split(integer(), kz_term:ne_binaries(), integer(), kz_term:ne_binaries(), split_results()) -> split_results(). split(_, [], _, [], Results) -> Results; split(AccountSplit, Accounts, OtherSplit, Others, Results) -> {OtherDbs, RemainingOthers} = split(OtherSplit, Others), @@ -193,7 +193,7 @@ split(Count, List) -> 'true' -> lists:split(Count, List) end. --spec parallel_migrate(integer(), split_results(), references()) -> 'no_return'. +-spec parallel_migrate(integer(), split_results(), kz_term:references()) -> 'no_return'. parallel_migrate(_, [], Refs) -> wait_for_parallel_migrate(Refs); parallel_migrate(Pause, [{Accounts, Others}|Remaining], Refs) -> Self = self(), @@ -202,12 +202,12 @@ parallel_migrate(Pause, [{Accounts, Others}|Remaining], Refs) -> _Pid = kz_util:spawn_link(fun parallel_migrate_worker/4, [Ref, Pause, Dbs, Self]), parallel_migrate(Pause, Remaining, [Ref|Refs]). --spec parallel_migrate_worker(reference(), integer(), ne_binaries(), pid()) -> reference(). +-spec parallel_migrate_worker(reference(), integer(), kz_term:ne_binaries(), pid()) -> reference(). parallel_migrate_worker(Ref, Pause, Databases, Parent) -> _ = (catch migrate(Pause, Databases)), Parent ! Ref. --spec wait_for_parallel_migrate(references()) -> 'no_return'. +-spec wait_for_parallel_migrate(kz_term:references()) -> 'no_return'. wait_for_parallel_migrate([]) -> %% Migrate settings for kazoo_media io:format("running media migrations...~n"), @@ -227,7 +227,7 @@ wait_for_parallel_migrate([Ref|Refs]) -> -spec blocking_refresh() -> 'no_return'. blocking_refresh() -> refresh(). --spec blocking_refresh(text() | non_neg_integer()) -> 'no_return'. +-spec blocking_refresh(kz_term:text() | non_neg_integer()) -> 'no_return'. blocking_refresh(Pause) -> Databases = get_databases(), refresh(Databases, Pause). @@ -239,8 +239,8 @@ blocking_refresh(Pause) -> %% @end %%-------------------------------------------------------------------- -spec refresh() -> 'no_return'. --spec refresh(ne_binaries(), text() | non_neg_integer()) -> 'no_return'. --spec refresh(ne_binaries(), non_neg_integer(), non_neg_integer()) -> 'no_return'. +-spec refresh(kz_term:ne_binaries(), kz_term:text() | non_neg_integer()) -> 'no_return'. +-spec refresh(kz_term:ne_binaries(), non_neg_integer(), non_neg_integer()) -> 'no_return'. refresh() -> Databases = get_databases(), refresh(Databases, 2 * ?MILLISECONDS_IN_SECOND). @@ -260,16 +260,16 @@ refresh([Database|Databases], Pause, Total) -> end, refresh(Databases, Pause, Total). --spec get_databases() -> ne_binaries(). +-spec get_databases() -> kz_term:ne_binaries(). get_databases() -> {'ok', Databases} = kz_datamgr:db_info(), lists:sort(fun get_database_sort/2, lists:usort(Databases ++ ?KZ_SYSTEM_DBS)). --spec get_database_sort(ne_binary(), ne_binary()) -> boolean(). +-spec get_database_sort(kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). get_database_sort(Db1, Db2) -> kzs_util:db_priority(Db1) < kzs_util:db_priority(Db2). --spec refresh(ne_binary()) -> 'ok'. +-spec refresh(kz_term:ne_binary()) -> 'ok'. refresh(Database) -> kz_datamgr:refresh_views(Database), 'ok'. @@ -285,7 +285,7 @@ remove_depreciated_databases() -> Databases = get_databases(), remove_depreciated_databases(Databases). --spec remove_depreciated_databases(ne_binaries()) -> 'ok'. +-spec remove_depreciated_databases(kz_term:ne_binaries()) -> 'ok'. remove_depreciated_databases([]) -> 'ok'; remove_depreciated_databases([Database|Databases]) -> _ = case kz_datamgr:db_classification(Database) of @@ -321,7 +321,7 @@ cleanup_aggregated_accounts([JObj|JObjs]) -> end, cleanup_aggregated_accounts(JObjs). --spec cleanup_aggregated_account(ne_binary()) -> 'ok'. +-spec cleanup_aggregated_account(kz_term:ne_binary()) -> 'ok'. cleanup_aggregated_account(Account) -> AccountDb = kz_util:format_account_id(Account, 'encoded'), AccountId = kz_util:format_account_id(Account, 'raw'), @@ -330,7 +330,7 @@ cleanup_aggregated_account(Account) -> _Else -> 'ok' end. --spec remove_aggregated_account(ne_binary()) -> 'ok'. +-spec remove_aggregated_account(kz_term:ne_binary()) -> 'ok'. remove_aggregated_account(Account) -> AccountId = kz_util:format_account_id(Account, 'raw'), {'ok', JObj} = kz_datamgr:open_doc(?KZ_ACCOUNTS_DB, AccountId), @@ -362,7 +362,7 @@ cleanup_aggregated_devices([JObj|JObjs]) -> end, cleanup_aggregated_devices(JObjs). --spec cleanup_aggregated_device(ne_binary()) -> 'ok'. +-spec cleanup_aggregated_device(kz_term:ne_binary()) -> 'ok'. cleanup_aggregated_device(DocId) -> {'ok', JObj} = kz_datamgr:open_doc(?KZ_SIP_DB, DocId), case kz_json:get_first_defined([<<"pvt_account_db">> @@ -376,7 +376,7 @@ cleanup_aggregated_device(DocId) -> verify_aggregated_device(AccountDb, AccountId, JObj) end. --spec verify_aggregated_device(ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec verify_aggregated_device(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. verify_aggregated_device(AccountDb, AccountId, JObj) -> case kz_datamgr:open_doc(AccountDb, AccountId) of {'error', 'not_found'} -> @@ -393,7 +393,7 @@ verify_aggregated_device(AccountDb, AccountId, JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec cleanup_voicemail_media(ne_binary()) -> +-spec cleanup_voicemail_media(kz_term:ne_binary()) -> {'ok', kz_json:objects()} | {'error', any()}. cleanup_voicemail_media(Account) -> @@ -417,7 +417,7 @@ cleanup_orphan_modbs() -> end, lists:foreach(DeleteOrphaned, AccountMODbs). --spec get_messages(ne_binary()) -> ne_binaries(). +-spec get_messages(kz_term:ne_binary()) -> kz_term:ne_binaries(). get_messages(Account) -> AccountDb = kz_util:format_account_id(Account, 'encoded'), ViewOptions = ['include_docs'], @@ -429,7 +429,7 @@ get_messages(Account) -> [] end. --spec extract_messages(kz_json:objects() | kz_json:object(), ne_binaries()) -> ne_binaries(). +-spec extract_messages(kz_json:objects() | kz_json:object(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). extract_messages([], CurMessages) -> CurMessages; extract_messages([Mess|Messages], CurMessages) -> extract_messages(Messages, [kz_json:get_value(<<"media_id">>, Mess)|CurMessages]); @@ -437,7 +437,7 @@ extract_messages(JObj, CurMessages) -> Messages = kz_json:get_value([<<"doc">>, <<"messages">>], JObj, []), extract_messages(Messages, CurMessages). --spec get_medias(ne_binary()) -> ne_binaries(). +-spec get_medias(kz_term:ne_binary()) -> kz_term:ne_binaries(). get_medias(Account) -> AccountDb = kz_util:format_account_id(Account, 'encoded'), ViewOptions = [], @@ -460,7 +460,7 @@ get_medias(Account) -> migrate_limits() -> migrate_all_limits(kapps_util:get_all_accounts()). --spec migrate_all_limits(ne_binaries()) -> 'ok'. +-spec migrate_all_limits(kz_term:ne_binaries()) -> 'ok'. migrate_all_limits(Accounts) -> Total = length(Accounts), lists:foldr(fun(A, C) -> migrate_limits_fold(A, C, Total) end, 1, Accounts), @@ -501,7 +501,7 @@ migrate_limits(Account) -> _ = kz_datamgr:save_doc(AccountDb, JObj), 'ok'. --spec clean_trunkstore_docs(ne_binary(), integer(), integer()) -> +-spec clean_trunkstore_docs(kz_term:ne_binary(), integer(), integer()) -> {integer(), integer()}. clean_trunkstore_docs(AccountDb, TwowayTrunks, InboundTrunks) -> ViewOptions = ['include_docs' @@ -512,7 +512,7 @@ clean_trunkstore_docs(AccountDb, TwowayTrunks, InboundTrunks) -> {'error', _}=E -> E end. --spec clean_trunkstore_docs(ne_binary(), kz_json:objects(), integer(), integer()) -> +-spec clean_trunkstore_docs(kz_term:ne_binary(), kz_json:objects(), integer(), integer()) -> {integer(), integer()}. clean_trunkstore_docs(_, [], Trunks, InboundTrunks) -> @@ -592,13 +592,13 @@ migrate_media(Account) -> ensure_aggregate_devices() -> ensure_aggregate_devices(kapps_util:get_all_accounts()). --spec ensure_aggregate_devices(ne_binaries()) -> 'ok'. +-spec ensure_aggregate_devices(kz_term:ne_binaries()) -> 'ok'. ensure_aggregate_devices([]) -> 'ok'; ensure_aggregate_devices([Account|Accounts]) -> _ = ensure_aggregate_device(Account), ensure_aggregate_devices(Accounts). --spec ensure_aggregate_device(ne_binary()) -> 'ok'. +-spec ensure_aggregate_device(kz_term:ne_binary()) -> 'ok'. ensure_aggregate_device(Account) -> AccountDb = kz_util:format_account_id(Account, 'encoded'), case kz_datamgr:get_results(AccountDb, ?DEVICES_CB_LIST, ['include_docs']) of @@ -609,7 +609,7 @@ ensure_aggregate_device(Account) -> {'error', _} -> 'ok' end. --spec refresh_account_devices(ne_binary(), ne_binary(), kz_json:objects()) -> 'ok'. +-spec refresh_account_devices(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:objects()) -> 'ok'. refresh_account_devices(AccountDb, AccountRealm, Devices) -> _ = [kapps_util:add_aggregate_device(AccountDb, kz_json:get_value(<<"doc">>, Device)) || Device <- Devices, @@ -617,12 +617,12 @@ refresh_account_devices(AccountDb, AccountRealm, Devices) -> ], 'ok'. --spec should_aggregate_device(ne_binary(), kz_json:object()) -> boolean(). +-spec should_aggregate_device(kz_term:ne_binary(), kz_json:object()) -> boolean(). should_aggregate_device(AccountRealm, Device) -> kz_device:sip_realm(Device, AccountRealm) =/= AccountRealm orelse kz_device:sip_ip(Device) =/= 'undefined'. --spec remove_aggregate_devices(ne_binary(), ne_binary(), kz_json:objects()) -> 'ok'. +-spec remove_aggregate_devices(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:objects()) -> 'ok'. remove_aggregate_devices(AccountDb, AccountRealm, Devices) -> _ = [kapps_util:rm_aggregate_device(AccountDb, kz_json:get_value(<<"doc">>, Device)) || Device <- Devices, @@ -630,7 +630,7 @@ remove_aggregate_devices(AccountDb, AccountRealm, Devices) -> ], 'ok'. --spec should_remove_aggregate(ne_binary(), kz_json:object()) -> boolean(). +-spec should_remove_aggregate(kz_term:ne_binary(), kz_json:object()) -> boolean(). should_remove_aggregate(AccountRealm, Device) -> kz_device:sip_realm(Device, AccountRealm) =:= AccountRealm andalso kz_device:sip_ip(Device) =:= 'undefined'. @@ -641,7 +641,7 @@ should_remove_aggregate(AccountRealm, Device) -> %% %% @end %%-------------------------------------------------------------------- --spec find_invalid_acccount_dbs() -> ne_binaries(). +-spec find_invalid_acccount_dbs() -> kz_term:ne_binaries(). find_invalid_acccount_dbs() -> lists:foldr(fun find_invalid_acccount_dbs_fold/2, [], kapps_util:get_all_accounts()). @@ -658,7 +658,7 @@ find_invalid_acccount_dbs_fold(AccountDb, Acc) -> %% %% @end %%-------------------------------------------------------------------- --spec maybe_migrate_attachments(ne_binary(), ne_binary(), kz_json:object()) -> any(). +-spec maybe_migrate_attachments(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> any(). maybe_migrate_attachments(AccountDb, Id, JObj) -> case kz_doc:attachments(JObj) of 'undefined' -> @@ -670,7 +670,7 @@ maybe_migrate_attachments(AccountDb, Id, JObj) -> ] end. --spec migrate_attachment(ne_binary(), kz_json:object()) -> 'ok'. +-spec migrate_attachment(kz_term:ne_binary(), kz_json:object()) -> 'ok'. migrate_attachment(AccountDb, ViewJObj) -> Id = kz_doc:id(ViewJObj), _ = case kz_datamgr:open_doc(AccountDb, Id) of @@ -716,7 +716,7 @@ remove_deprecated_attachment_properties(AccountDb, Id, JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec migrate_attachment(ne_binary(), kz_json:object(), ne_binary(), kz_json:object()) -> 'ok'. +-spec migrate_attachment(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. migrate_attachment(AccountDb, JObj, Attachment, MetaData) -> DocCT = kz_json:get_value(<<"content_type">>, JObj), MetaCT = kz_json:get_value(<<"content_type">>, MetaData), @@ -736,7 +736,7 @@ maybe_update_attachment_content_type(A, MCT, DocCT) -> {'false', 'false'} -> {A, find_attachment_content_type(A)} end. --spec find_attachment_content_type(ne_binary()) -> ne_binary(). +-spec find_attachment_content_type(kz_term:ne_binary()) -> kz_term:ne_binary(). find_attachment_content_type(A) -> try cow_mimetypes:all(A) of {Type, SubType, _Options} -> kz_binary:join([Type, SubType], <<"/">>) @@ -744,7 +744,7 @@ find_attachment_content_type(A) -> 'error':'function_clause' -> <<"audio/mpeg">> end. --spec maybe_add_extension({ne_binary(), ne_binary()}) -> {ne_binary(), ne_binary()}. +-spec maybe_add_extension({kz_term:ne_binary(), kz_term:ne_binary()}) -> {kz_term:ne_binary(), kz_term:ne_binary()}. maybe_add_extension({A, CT}=T) -> case kz_term:is_empty(filename:extension(A)) of 'false' -> T; @@ -757,8 +757,8 @@ maybe_add_extension({A, CT}=T) -> %% %% @end %%-------------------------------------------------------------------- --type attachment_and_content() :: {ne_binary(), ne_binary()}. --spec maybe_update_attachment(ne_binary(), ne_binary(), attachment_and_content(), attachment_and_content()) -> 'ok'. +-type attachment_and_content() :: {kz_term:ne_binary(), kz_term:ne_binary()}. +-spec maybe_update_attachment(kz_term:ne_binary(), kz_term:ne_binary(), attachment_and_content(), attachment_and_content()) -> 'ok'. maybe_update_attachment(_, _, {Attachment, CT}, {Attachment, CT}) -> 'ok'; maybe_update_attachment(AccountDb, Id, {OrigAttach, _CT1}, {NewAttach, CT}) -> %% this preforms the following: @@ -778,7 +778,7 @@ maybe_update_attachment(AccountDb, Id, {OrigAttach, _CT1}, {NewAttach, CT}) -> ], lists:foldl(fun(F, Acc) -> F(Acc) end, [], Updaters). --spec try_load_attachment(ne_binary(), ne_binary(), ne_binary()) -> +-spec try_load_attachment(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> binary(). try_load_attachment(AccountDb, Id, OrigAttach) -> case kz_datamgr:fetch_attachment(AccountDb, Id, OrigAttach) of @@ -788,7 +788,7 @@ try_load_attachment(AccountDb, Id, OrigAttach) -> throw(E) end. --spec maybe_resave_attachment(binary(), ne_binary(), ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> +-spec maybe_resave_attachment(binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. maybe_resave_attachment(Content1, AccountDb, Id, OrigAttach, NewAttach, CT) -> {'ok', Rev} = kz_datamgr:lookup_doc_rev(AccountDb, Id), @@ -816,7 +816,7 @@ maybe_resave_attachment(Content1, AccountDb, Id, OrigAttach, NewAttach, CT) -> end end. --spec maybe_cleanup_old_attachment(ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec maybe_cleanup_old_attachment(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. maybe_cleanup_old_attachment(_AccountDb, _Id, NewAttach, NewAttach) -> io:format("updated content type for ~s/~s/~s~n", [_AccountDb, _Id, NewAttach]); maybe_cleanup_old_attachment(AccountDb, Id, OrigAttach, NewAttach) -> @@ -835,7 +835,7 @@ maybe_cleanup_old_attachment(AccountDb, Id, OrigAttach, NewAttach) -> %% %% @end %%-------------------------------------------------------------------- --spec add_extension(ne_binary(), ne_binary()) -> ne_binary(). +-spec add_extension(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). add_extension(A, <<"audio/x-wav">>) -> <>; add_extension(A, <<"audio/wav">>) -> @@ -858,7 +858,7 @@ add_extension(A, _) -> A. %% %% @end %%-------------------------------------------------------------------- --spec is_audio_content(ne_binary()) -> boolean(). +-spec is_audio_content(kz_term:ne_binary()) -> boolean(). is_audio_content(<<"audio/", _/binary>>) -> 'true'; is_audio_content(_) -> 'false'. @@ -868,7 +868,7 @@ is_audio_content(_) -> 'false'. %% %% @end %%-------------------------------------------------------------------- --spec maybe_delete_db(ne_binary()) -> 'ok'. +-spec maybe_delete_db(kz_term:ne_binary()) -> 'ok'. maybe_delete_db(Database) -> case kapps_config:get_is_true(?SYSCONFIG_COUCH, <<"allow_maintenance_db_delete">>, 'false') of 'true' -> @@ -884,11 +884,11 @@ maybe_delete_db(Database) -> %% %% @end %%-------------------------------------------------------------------- --spec purge_doc_type(ne_binaries() | ne_binary(), ne_binary()) -> +-spec purge_doc_type(kz_term:ne_binaries() | kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:objects()} | {'error', _} | 'ok'. --spec purge_doc_type(ne_binaries() | ne_binary(), ne_binary(), integer()) -> +-spec purge_doc_type(kz_term:ne_binaries() | kz_term:ne_binary(), kz_term:ne_binary(), integer()) -> {'ok', kz_json:objects()} | {'error', _} | 'ok'. @@ -932,8 +932,8 @@ purge_doc_type(Type, Account, ChunkSize) -> purge_doc_type(Type, Account, ChunkSize) end. --spec call_id_status(ne_binary()) -> 'ok'. --spec call_id_status(ne_binary(), boolean() | ne_binary()) -> 'ok'. +-spec call_id_status(kz_term:ne_binary()) -> 'ok'. +-spec call_id_status(kz_term:ne_binary(), boolean() | kz_term:ne_binary()) -> 'ok'. call_id_status(CallId) -> call_id_status(CallId, 'false'). call_id_status(CallId, Verbose) -> @@ -951,7 +951,7 @@ call_id_status(CallId, Verbose) -> lager:info("failed to get status of '~s': '~p'", [CallId, _E]) end. --spec show_status(ne_binary(), boolean(), api_terms()) -> 'ok'. +-spec show_status(kz_term:ne_binary(), boolean(), kz_term:api_terms()) -> 'ok'. show_status(CallId, 'false', Resp) -> lager:info("channel '~s' has status '~s'", [CallId, kapi_call:get_status(Resp)]); show_status(CallId, 'true', Resp) -> @@ -961,11 +961,11 @@ show_status(CallId, 'true', Resp) -> lager:info("Responding App: ~s", [kz_json:get_value(<<"App-Name">>, Resp)]), lager:info("Responding Node: ~s", [kz_json:get_value(<<"Node">>, Resp)]). --spec last_migrate_version() -> ne_binary(). +-spec last_migrate_version() -> kz_term:ne_binary(). last_migrate_version() -> kapps_config:get_ne_binary(?MODULE, <<"migrate_current_version">>, <<"3.22">>). --spec set_last_migrate_version(ne_binary()) -> {'ok', kz_json:object()}. +-spec set_last_migrate_version(kz_term:ne_binary()) -> {'ok', kz_json:object()}. set_last_migrate_version(Version) -> kapps_config:set(?MODULE, <<"migrate_current_version">>, Version). @@ -973,7 +973,7 @@ set_last_migrate_version(Version) -> migrate_system() -> migrate_system(last_migrate_version(), kz_util:kazoo_version()). --spec migrate_system(ne_binary(), ne_binary()) -> 'ok'. +-spec migrate_system(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. migrate_system(ThisVersion, ThisVersion) -> lager:notice("system config version is ~s", [ThisVersion]); migrate_system(PreviousVersion, ThisVersion) -> @@ -992,7 +992,7 @@ migrate_system(PreviousVersion, ThisVersion) -> 'false' -> 'ok' end. --spec migrate_system_version_routines(ne_binary(), ne_binary()) -> [fun()]. +-spec migrate_system_version_routines(kz_term:ne_binary(), kz_term:ne_binary()) -> [fun()]. migrate_system_version_routines(<<"3.22">>, _) -> [fun handle_module_rename/0]; migrate_system_version_routines(_, _) -> []. @@ -1024,7 +1024,7 @@ maybe_new(_) -> kz_json:new(). get_config_document(Id) -> kz_doc:public_fields(maybe_new(kapps_config:get_category(Id))). --spec validate_system_config(ne_binary()) -> [{_, _}]. +-spec validate_system_config(kz_term:ne_binary()) -> [{_, _}]. validate_system_config(Id) -> Doc = get_config_document(Id), Keys = kz_json:get_keys(Doc), @@ -1045,7 +1045,7 @@ get_error({error, Errors}) -> [ get_error(Error) || Error <- Errors ]; get_error({Code, _Schema, Error, Value, Path}) -> {Code, Error, Value, Path}; get_error(X) -> X. --spec cleanup_system_config(ne_binary()) -> {'ok', kz_json:object()}. +-spec cleanup_system_config(kz_term:ne_binary()) -> {'ok', kz_json:object()}. cleanup_system_config(Id) -> Doc = maybe_new(kapps_config:get_category(Id)), ErrorKeys = [ Key || {Key, _} <- validate_system_config(Id), Key =/= no_schema_for ], @@ -1056,7 +1056,7 @@ cleanup_system_config(Id) -> cleanup_system_configs() -> [ cleanup_system_config(Id) || {Id, _Err} <- validate_system_configs() ]. --spec validate_system_configs() -> [{ne_binary(), _}]. +-spec validate_system_configs() -> [{kz_term:ne_binary(), _}]. validate_system_configs() -> Results = [ {Config, validate_system_config(Config)} || Config <- kapps_config_doc:list_configs() ], [ Result || Result = {_, Status} <- Results, Status =/= [] ]. diff --git a/core/kazoo_apps/src/kapps_notify_publisher.erl b/core/kazoo_apps/src/kapps_notify_publisher.erl index b9623b6dfc9..7f6c0f029c5 100644 --- a/core/kazoo_apps/src/kapps_notify_publisher.erl +++ b/core/kazoo_apps/src/kapps_notify_publisher.erl @@ -36,7 +36,7 @@ kapps_account_config:get_global(AccountId, ?NOTIFY_CAT, <<"notify_persist_exceptions">>, ?DEFAULT_TYPE_EXCEPTION) ). --type failure_reason() :: {ne_binary(), api_object()}. +-type failure_reason() :: {kz_term:ne_binary(), kz_term:api_object()}. %%-------------------------------------------------------------------- %% @public @@ -46,7 +46,7 @@ %% the notification completely (e.g. new voicemail) %% @end %%-------------------------------------------------------------------- --spec call_collect(api_terms(), kz_amqp_worker:publish_fun()) -> kz_amqp_worker:request_return(). +-spec call_collect(kz_term:api_terms(), kz_amqp_worker:publish_fun()) -> kz_amqp_worker:request_return(). call_collect(Req, PublishFun) -> NotifyType = notify_type(PublishFun), CallResp = kz_amqp_worker:call_collect(Req, PublishFun, fun collecting/1, ?TIMEOUT), @@ -60,7 +60,7 @@ call_collect(Req, PublishFun) -> %% if it failed. %% @end %%-------------------------------------------------------------------- --spec cast(api_terms(), kz_amqp_worker:publish_fun()) -> 'ok'. +-spec cast(kz_term:api_terms(), kz_amqp_worker:publish_fun()) -> 'ok'. cast(Req, PublishFun) -> CallId = kz_util:get_callid(), Fun = fun() -> @@ -83,7 +83,7 @@ cast(Req, PublishFun) -> %% handle amqp worker responses %% @end %%-------------------------------------------------------------------- --spec handle_resp(api_ne_binary(), api_terms(), kz_amqp_worker:request_return()) -> 'ok'. +-spec handle_resp(kz_term:api_ne_binary(), kz_term:api_terms(), kz_amqp_worker:request_return()) -> 'ok'. handle_resp(NotifyType, Req, {'ok', _}=Resp) -> check_for_failure(NotifyType, Req, Resp); @@ -102,7 +102,7 @@ handle_resp(NotifyType, Req, {'timeout', _}=Resp) -> %% check for notify update messages from teletype/notify apps %% @end %%-------------------------------------------------------------------- --spec check_for_failure(api_ne_binary(), api_terms(), {'ok' | 'returned' | 'timeout', kz_json:object() | kz_json:objects()}) -> 'ok'. +-spec check_for_failure(kz_term:api_ne_binary(), kz_term:api_terms(), {'ok' | 'returned' | 'timeout', kz_json:object() | kz_json:objects()}) -> 'ok'. check_for_failure(NotifyType, Req, {_ErrorType, Responses}=Resp) -> Reason = json_to_reason(Resp), case is_completed(Responses) of @@ -111,7 +111,7 @@ check_for_failure(NotifyType, Req, {_ErrorType, Responses}=Resp) -> end. %% @private --spec maybe_log_metadata(api_ne_binary(), failure_reason()) -> 'ok'. +-spec maybe_log_metadata(kz_term:api_ne_binary(), failure_reason()) -> 'ok'. maybe_log_metadata('undefined', _) -> 'ok'; maybe_log_metadata(_, {<<"completed">>, 'undefined'}) -> 'ok'; maybe_log_metadata(NotifyType, {<<"completed">>=Reason, Metadata}) -> @@ -124,7 +124,7 @@ maybe_log_metadata(_, _) -> 'ok'. %% @doc %% @end %%-------------------------------------------------------------------- --spec maybe_handle_error(api_binary(), api_terms(), failure_reason()) -> 'ok'. +-spec maybe_handle_error(kz_term:api_binary(), kz_term:api_terms(), failure_reason()) -> 'ok'. maybe_handle_error('undefined', _, _) -> lager:warning("not saving unknown notification type"); maybe_handle_error(NotifyType, Req, Reason) -> @@ -139,7 +139,7 @@ maybe_handle_error(NotifyType, Req, Reason) -> %% create document with notification payload to save in db %% @end %%-------------------------------------------------------------------- --spec handle_error(ne_binary(), api_terms(), failure_reason()) -> 'ok'. +-spec handle_error(kz_term:ne_binary(), kz_term:api_terms(), failure_reason()) -> 'ok'. handle_error(NotifyType, Req, {Reason, Metadata}) -> lager:warning("attempt to publishing notification ~s was unsuccessful: ~p", [NotifyType, Reason]), Props = props:filter_undefined( @@ -158,7 +158,7 @@ handle_error(NotifyType, Req, {Reason, Metadata}) -> save_pending_notification(NotifyType, JObj, 2). %% @private --spec save_pending_notification(ne_binary(), kz_json:object(), integer()) -> 'ok'. +-spec save_pending_notification(kz_term:ne_binary(), kz_json:object(), integer()) -> 'ok'. save_pending_notification(_NotifyType, _JObj, Loop) when Loop < 0 -> lager:error("max try to save payload for notification ~s publish attempt", [_NotifyType]); save_pending_notification(NotifyType, JObj, Loop) -> @@ -224,7 +224,7 @@ is_completed(JObj) -> %% Check the reason to see if this failure should be saved or not. %% @end %%-------------------------------------------------------------------- --spec should_ignore_failure(api_ne_binary()) -> boolean(). +-spec should_ignore_failure(kz_term:api_ne_binary()) -> boolean(). should_ignore_failure(<<"missing_from">>) -> 'true'; should_ignore_failure(<<"invalid_to_addresses">>) -> 'true'; should_ignore_failure(<<"no_to_addresses">>) -> 'true'; @@ -315,7 +315,7 @@ find_reason_from_jsons(Reason, JObjs, Map) -> end. %% @private --spec cast_to_binary(any()) -> ne_binary(). +-spec cast_to_binary(any()) -> kz_term:ne_binary(). cast_to_binary(Error) -> try kz_term:to_binary(Error) catch @@ -330,7 +330,7 @@ cast_to_binary(Error) -> %% Find notification type from the publish function %% @end %%-------------------------------------------------------------------- --spec notify_type(kz_amqp_worker:publish_fun() | ne_binary()) -> api_ne_binary(). +-spec notify_type(kz_amqp_worker:publish_fun() | kz_term:ne_binary()) -> kz_term:api_ne_binary(). notify_type(<<"publish_", NotifyType/binary>>) -> NotifyType; notify_type(NotifyType) when is_binary(NotifyType) -> @@ -344,12 +344,12 @@ notify_type(PublishFun) -> 'undefined' end. --spec should_persist_notify(api_binary()) -> boolean(). +-spec should_persist_notify(kz_term:api_binary()) -> boolean(). should_persist_notify(AccountId) -> ?DEFAULT_PUBLISHER_ENABLED andalso ?ACCOUNT_SHOULD_PRESIST(AccountId). --spec should_handle_notify_type(ne_binary(), api_binary()) -> boolean(). +-spec should_handle_notify_type(kz_term:ne_binary(), kz_term:api_binary()) -> boolean(). should_handle_notify_type(NotifyType, AccountId) -> not lists:member(NotifyType, ?GLOBAL_FORCE_NOTIFY_TYPE_EXCEPTION) andalso not lists:member(NotifyType, ?NOTIFY_TYPE_EXCEPTION(AccountId)). diff --git a/core/kazoo_apps/src/kapps_util.erl b/core/kazoo_apps/src/kapps_util.erl index f6ed6df5668..0f442402b8e 100644 --- a/core/kazoo_apps/src/kapps_util.erl +++ b/core/kazoo_apps/src/kapps_util.erl @@ -83,7 +83,7 @@ %% @spec update_all_accounts() -> ok | error %% @end %%-------------------------------------------------------------------- --spec update_all_accounts(ne_binary()) -> 'ok'. +-spec update_all_accounts(kz_term:ne_binary()) -> 'ok'. update_all_accounts(File) -> lists:foreach(fun(AccountDb) -> timer:sleep(2 * ?MILLISECONDS_IN_SECOND), @@ -111,7 +111,7 @@ revise_whapp_views_in_accounts(App) -> %% account db into the target database %% @end %%-------------------------------------------------------------------- --spec replicate_from_accounts(ne_binary(), ne_binary()) -> 'ok'. +-spec replicate_from_accounts(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. replicate_from_accounts(TargetDb, FilterDoc) when is_binary(FilterDoc) -> lists:foreach(fun(AccountDb) -> timer:sleep(2 * ?MILLISECONDS_IN_SECOND), @@ -125,7 +125,7 @@ replicate_from_accounts(TargetDb, FilterDoc) when is_binary(FilterDoc) -> %% source database into the target database %% @end %%-------------------------------------------------------------------- --spec replicate_from_account(ne_binary(), ne_binary(), ne_binary()) -> +-spec replicate_from_account(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | {'error', 'matching_dbs'}. replicate_from_account(AccountDb, AccountDb, _) -> lager:debug("requested to replicate from db ~s to self, skipping", [AccountDb]), @@ -153,7 +153,7 @@ replicate_from_account(AccountDb, TargetDb, FilterDoc) -> %% set it to the oldest acccount and return that. %% @end %%-------------------------------------------------------------------- --spec get_master_account_id() -> {'ok', ne_binary()} | +-spec get_master_account_id() -> {'ok', kz_term:ne_binary()} | {'error', atom()}. get_master_account_id() -> case kapps_config:get_ne_binary(?KZ_SYSTEM_CONFIG_ACCOUNT, <<"master_account_id">>) of @@ -174,7 +174,7 @@ find_master_account_id({'ok', Accounts}) -> {'ok', _} = kapps_config:set(?KZ_SYSTEM_CONFIG_ACCOUNT, <<"master_account_id">>, OldestAccountId), Ok. --spec get_master_account_db() -> {'ok', ne_binary()} | +-spec get_master_account_db() -> {'ok', kz_term:ne_binary()} | {'error', any()}. get_master_account_db() -> case get_master_account_id() of @@ -183,7 +183,7 @@ get_master_account_db() -> {'ok', kz_util:format_account_db(AccountId)} end. --spec is_master_account(ne_binary()) -> boolean(). +-spec is_master_account(kz_term:ne_binary()) -> boolean(). is_master_account(Account) -> AccountId = kz_util:format_account_id(Account), case get_master_account_id() of @@ -196,7 +196,7 @@ is_master_account(Account) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec account_depth(ne_binary()) -> api_non_neg_integer(). +-spec account_depth(kz_term:ne_binary()) -> kz_term:api_non_neg_integer(). account_depth(Account) -> {'ok', JObj} = kz_account:fetch(Account), length(kz_account:tree(JObj)). @@ -207,7 +207,7 @@ account_depth(Account) -> %% List an account's descendants (including the provided AccountId). %% @end %%-------------------------------------------------------------------- --spec account_descendants(ne_binary()) -> ne_binaries(). +-spec account_descendants(kz_term:ne_binary()) -> kz_term:ne_binaries(). account_descendants(?MATCH_ACCOUNT_RAW(AccountId)) -> View = <<"accounts/listing_by_descendants">>, ViewOptions = [{startkey, [AccountId]} @@ -225,7 +225,7 @@ account_descendants(?MATCH_ACCOUNT_RAW(AccountId)) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec account_has_descendants(ne_binary()) -> boolean(). +-spec account_has_descendants(kz_term:ne_binary()) -> boolean(). account_has_descendants(Account) -> AccountId = kz_util:format_account_id(Account), [] =/= (account_descendants(AccountId) -- [AccountId]). @@ -237,7 +237,7 @@ account_has_descendants(Account) -> %% @end %%-------------------------------------------------------------------- -spec find_oldest_doc(kz_json:objects()) -> - {'ok', ne_binary()} | + {'ok', kz_term:ne_binary()} | {'error', 'no_docs'}. find_oldest_doc([]) -> {'error', 'no_docs'}; find_oldest_doc([First|Docs]) -> @@ -260,8 +260,8 @@ find_oldest_doc([First|Docs]) -> %% in the requested encoding %% @end %%-------------------------------------------------------------------- --spec get_all_accounts() -> ne_binaries(). --spec get_all_accounts(kz_util:account_format()) -> ne_binaries(). +-spec get_all_accounts() -> kz_term:ne_binaries(). +-spec get_all_accounts(kz_util:account_format()) -> kz_term:ne_binaries(). get_all_accounts() -> get_all_accounts(?REPLICATE_ENCODING). get_all_accounts(Encoding) -> @@ -272,8 +272,8 @@ get_all_accounts(Encoding) -> || Db <- Dbs, is_account_db(Db) ]. --spec get_all_accounts_and_mods() -> ne_binaries(). --spec get_all_accounts_and_mods(kz_util:account_format()) -> ne_binaries(). +-spec get_all_accounts_and_mods() -> kz_term:ne_binaries(). +-spec get_all_accounts_and_mods(kz_util:account_format()) -> kz_term:ne_binaries(). get_all_accounts_and_mods() -> get_all_accounts_and_mods(?REPLICATE_ENCODING). @@ -285,7 +285,7 @@ get_all_accounts_and_mods(Encoding) -> orelse is_account_mod(Db) ]. --spec format_db(ne_binary(), kz_util:account_format()) -> ne_binary(). +-spec format_db(kz_term:ne_binary(), kz_util:account_format()) -> kz_term:ne_binary(). format_db(Db, Encoding) -> Fs = [{fun is_account_db/1, fun kz_util:format_account_id/2} ,{fun is_account_mod/1, fun kz_util:format_account_modb/2} @@ -298,8 +298,8 @@ format_db(Db, Encoding, [{Predicate, Formatter}|Fs]) -> 'false' -> format_db(Db, Encoding, Fs) end. --spec get_all_account_mods() -> ne_binaries(). --spec get_all_account_mods(kz_util:account_format()) -> ne_binaries(). +-spec get_all_account_mods() -> kz_term:ne_binaries(). +-spec get_all_account_mods(kz_util:account_format()) -> kz_term:ne_binaries(). get_all_account_mods() -> get_all_account_mods(?REPLICATE_ENCODING). @@ -310,8 +310,8 @@ get_all_account_mods(Encoding) -> is_account_mod(Db) ]. --spec get_account_mods(ne_binary()) -> ne_binaries(). --spec get_account_mods(ne_binary(), kz_util:account_format()) -> ne_binaries(). +-spec get_account_mods(kz_term:ne_binary()) -> kz_term:ne_binaries(). +-spec get_account_mods(kz_term:ne_binary(), kz_util:account_format()) -> kz_term:ne_binaries(). get_account_mods(Account) -> get_account_mods(Account, ?REPLICATE_ENCODING). @@ -323,7 +323,7 @@ get_account_mods(Account, Encoding) -> is_matched_account_mod(Encoding, MOD, AccountId) ]. --spec is_matched_account_mod(kz_util:account_format(), ne_binary(), ne_binary()) -> boolean(). +-spec is_matched_account_mod(kz_util:account_format(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_matched_account_mod('unencoded' ,?MATCH_MODB_SUFFIX_UNENCODED(A, B, Rest, _, _) ,?MATCH_ACCOUNT_UNENCODED(A, B, Rest) @@ -342,17 +342,17 @@ is_matched_account_mod('raw' is_matched_account_mod(_, _, _) -> 'false'. --spec is_account_mod(ne_binary()) -> boolean(). +-spec is_account_mod(kz_term:ne_binary()) -> boolean(). is_account_mod(Db) -> kz_datamgr:db_classification(Db) =:= 'modb'. --spec is_account_db(ne_binary()) -> boolean(). +-spec is_account_db(kz_term:ne_binary()) -> boolean(). is_account_db(Db) -> kz_datamgr:db_classification(Db) =:= 'account'. --type getby_return() :: {'ok', ne_binary()} | - {'multiples', ne_binaries()} | +-type getby_return() :: {'ok', kz_term:ne_binary()} | + {'multiples', kz_term:ne_binaries()} | {'error', 'not_found'}. %%-------------------------------------------------------------------- @@ -360,13 +360,13 @@ is_account_db(Db) -> %% @doc Realms are one->one with accounts. %% @end %%-------------------------------------------------------------------- --spec get_account_by_realm(ne_binary()) -> getby_return(). +-spec get_account_by_realm(kz_term:ne_binary()) -> getby_return(). get_account_by_realm(RawRealm) -> Realm = kz_term:to_lower_binary(RawRealm), get_accounts_by(Realm, ?ACCT_BY_REALM_CACHE(Realm), ?AGG_LIST_BY_REALM). --spec get_ccvs_by_ip(ne_binary()) -> - {'ok', kz_proplist()} | +-spec get_ccvs_by_ip(kz_term:ne_binary()) -> + {'ok', kz_term:proplist()} | {'error', 'not_found'}. get_ccvs_by_ip(IP) -> case kz_cache:peek_local(?KAPPS_GETBY_CACHE, ?ACCT_BY_IP_CACHE(IP)) of @@ -375,8 +375,8 @@ get_ccvs_by_ip(IP) -> {'ok', _AccountCCVs} = OK -> OK end. --spec do_get_ccvs_by_ip(ne_binary()) -> - {'ok', kz_proplist()} | +-spec do_get_ccvs_by_ip(kz_term:ne_binary()) -> + {'ok', kz_term:proplist()} | {'error', 'not_found'}. do_get_ccvs_by_ip(IP) -> case kapps_config:get_is_true(<<"registrar">>, <<"use_aggregate">>, 'true') @@ -402,7 +402,7 @@ do_get_ccvs_by_ip(IP) -> Error end. --spec account_ccvs_from_ip_auth(kz_json:object()) -> kz_proplist(). +-spec account_ccvs_from_ip_auth(kz_json:object()) -> kz_term:proplist(). account_ccvs_from_ip_auth(Doc) -> AccountId = kz_json:get_value([<<"value">>, <<"account_id">>], Doc), OwnerId = kz_json:get_value([<<"value">>, <<"owner_id">>], Doc), @@ -429,9 +429,9 @@ account_ccvs_from_ip_auth(Doc) -> -type not_enabled_error() :: 'device_disabled' | 'owner_disabled' | 'account_disabled'. --spec are_all_enabled(kz_proplist()) -> +-spec are_all_enabled(kz_term:proplist()) -> 'true' | - {'false', {not_enabled_error(), ne_binary()}}. + {'false', {not_enabled_error(), kz_term:ne_binary()}}. are_all_enabled(Things) -> ?MATCH_ACCOUNT_RAW(AccountId) = props:get_value(<<"account">>, Things), try lists:all(fun(Thing) -> is_enabled(AccountId, Thing) end, Things) @@ -439,7 +439,7 @@ are_all_enabled(Things) -> 'throw':{'error', Reason} -> {'false', Reason} end. --spec is_enabled(ne_binary(), {ne_binary(), api_ne_binary()}) -> boolean(). +-spec is_enabled(kz_term:ne_binary(), {kz_term:ne_binary(), kz_term:api_ne_binary()}) -> boolean(). is_enabled(_AccountId, {_Type, 'undefined'}) -> 'true'; is_enabled(AccountId, {<<"device">>, DeviceId}) -> Default = kapps_config:get_is_true(<<"registrar">>, <<"device_enabled_default">>, 'true'), @@ -467,11 +467,11 @@ is_enabled(_AccountId, {_Type, _Thing}) -> 'true'. %% unique. %% @end %%-------------------------------------------------------------------- --spec get_accounts_by_name(ne_binary()) -> getby_return(). +-spec get_accounts_by_name(kz_term:ne_binary()) -> getby_return(). get_accounts_by_name(Name) -> get_accounts_by(Name, ?ACCT_BY_NAME_CACHE(Name), ?AGG_LIST_BY_NAME). --spec get_accounts_by(ne_binary(), tuple(), ne_binary()) -> getby_return(). +-spec get_accounts_by(kz_term:ne_binary(), tuple(), kz_term:ne_binary()) -> getby_return(). get_accounts_by(What, CacheKey, View) -> case kz_cache:peek_local(?KAPPS_GETBY_CACHE, CacheKey) of {'ok', [AccountDb]} -> {'ok', AccountDb}; @@ -480,7 +480,7 @@ get_accounts_by(What, CacheKey, View) -> do_get_accounts_by(What, CacheKey, View) end. --spec do_get_accounts_by(ne_binary(), tuple(), ne_binary()) -> getby_return(). +-spec do_get_accounts_by(kz_term:ne_binary(), tuple(), kz_term:ne_binary()) -> getby_return(). do_get_accounts_by(What, CacheKey, View) -> ViewOptions = [{'key', What}], case kz_datamgr:get_results(?KZ_ACCOUNTS_DB, View, ViewOptions) of @@ -499,7 +499,7 @@ do_get_accounts_by(What, CacheKey, View) -> {'error', 'not_found'} end. --spec cache(tuple(), ne_binaries()) -> 'ok'. +-spec cache(tuple(), kz_term:ne_binaries()) -> 'ok'. cache(Key, AccountDbs) -> kz_cache:store_local(?KAPPS_GETBY_CACHE, Key, AccountDbs, ?GET_BY_CACHE_ORIGIN). @@ -510,7 +510,7 @@ cache(Key, AccountDbs) -> %% this returns the cause and code for the call termination %% @end %%-------------------------------------------------------------------- --spec get_call_termination_reason(kz_json:object()) -> {ne_binary(), ne_binary()}. +-spec get_call_termination_reason(kz_json:object()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. get_call_termination_reason(JObj) -> Cause = case kz_json:get_ne_value(<<"Application-Response">>, JObj) of 'undefined' -> @@ -535,12 +535,12 @@ get_views_json(App, Folder) -> {?NE_BINARY,_}=ViewListing <- [catch get_view_json(File)] ]. --spec get_view_json(atom(), text()) -> kz_datamgr:view_listing(). +-spec get_view_json(atom(), kz_term:text()) -> kz_datamgr:view_listing(). get_view_json(App, File) -> Path = filename:join([code:priv_dir(App), "couchdb", File]), get_view_json(Path). --spec get_view_json(text()) -> kz_datamgr:view_listing(). +-spec get_view_json(kz_term:text()) -> kz_datamgr:view_listing(). get_view_json(Path) -> lager:debug("fetching view from ~s", [Path]), {'ok', Bin} = file:read_file(Path), @@ -553,11 +553,11 @@ get_view_json(Path) -> %% %% @end %%-------------------------------------------------------------------- --spec update_views(ne_binary(), kz_datamgr:views_listing()) -> boolean(). +-spec update_views(kz_term:ne_binary(), kz_datamgr:views_listing()) -> boolean(). update_views(Db, Views) -> update_views(Db, Views, 'false'). --spec update_views(ne_binary(), kz_datamgr:views_listing(), boolean()) -> boolean(). +-spec update_views(kz_term:ne_binary(), kz_datamgr:views_listing(), boolean()) -> boolean(). update_views(Db, Views, ShouldRemove) -> kz_term:is_true(kz_datamgr:db_view_update(Db, Views, ShouldRemove)). @@ -567,7 +567,7 @@ update_views(Db, Views, ShouldRemove) -> %% %% @end %%-------------------------------------------------------------------- --spec add_aggregate_device(ne_binary(), api_binary()) -> 'ok'. +-spec add_aggregate_device(kz_term:ne_binary(), kz_term:api_binary()) -> 'ok'. add_aggregate_device(_, 'undefined') -> 'ok'; add_aggregate_device(Db, Device) -> DeviceId = kz_doc:id(Device), @@ -587,7 +587,7 @@ add_aggregate_device(Db, Device) -> %% %% @end %%-------------------------------------------------------------------- --spec rm_aggregate_device(ne_binary(), api_object() | api_binary()) -> 'ok'. +-spec rm_aggregate_device(kz_term:ne_binary(), kz_term:api_object() | kz_term:api_binary()) -> 'ok'. rm_aggregate_device(_, 'undefined') -> 'ok'; rm_aggregate_device(Db, DeviceId) when is_binary(DeviceId) -> case kz_datamgr:open_doc(?KZ_SIP_DB, DeviceId) of @@ -600,14 +600,14 @@ rm_aggregate_device(Db, DeviceId) when is_binary(DeviceId) -> rm_aggregate_device(Db, Device) -> rm_aggregate_device(Db, kz_doc:id(Device)). --spec amqp_pool_send(api_terms(), kz_amqp_worker:publish_fun()) -> +-spec amqp_pool_send(kz_term:api_terms(), kz_amqp_worker:publish_fun()) -> 'ok' | {'error', any()}. amqp_pool_send(Api, PubFun) when is_function(PubFun, 1) -> kz_amqp_worker:cast(Api, PubFun). --spec amqp_pool_request(api_terms(), kz_amqp_worker:publish_fun(), kz_amqp_worker:validate_fun()) -> +-spec amqp_pool_request(kz_term:api_terms(), kz_amqp_worker:publish_fun(), kz_amqp_worker:validate_fun()) -> kz_amqp_worker:request_return(). --spec amqp_pool_request(api_terms(), kz_amqp_worker:publish_fun(), kz_amqp_worker:validate_fun(), kz_timeout()) -> +-spec amqp_pool_request(kz_term:api_terms(), kz_amqp_worker:publish_fun(), kz_amqp_worker:validate_fun(), timeout()) -> kz_amqp_worker:request_return(). amqp_pool_request(Api, PubFun, ValidateFun) when is_function(PubFun, 1), @@ -622,9 +622,9 @@ amqp_pool_request(Api, PubFun, ValidateFun, Timeout) orelse Timeout =:= 'infinity') -> kz_amqp_worker:call(Api, PubFun, ValidateFun, Timeout). --spec amqp_pool_request_custom(api_terms(), kz_amqp_worker:publish_fun(), kz_amqp_worker:validate_fun(), gen_listener:binding()) -> +-spec amqp_pool_request_custom(kz_term:api_terms(), kz_amqp_worker:publish_fun(), kz_amqp_worker:validate_fun(), gen_listener:binding()) -> kz_amqp_worker:request_return(). --spec amqp_pool_request_custom(api_terms(), kz_amqp_worker:publish_fun(), kz_amqp_worker:validate_fun(), kz_timeout(), gen_listener:binding()) -> +-spec amqp_pool_request_custom(kz_term:api_terms(), kz_amqp_worker:publish_fun(), kz_amqp_worker:validate_fun(), timeout(), gen_listener:binding()) -> kz_amqp_worker:request_return(). amqp_pool_request_custom(Api, PubFun, ValidateFun, Bind) when is_function(PubFun, 1), @@ -639,21 +639,21 @@ amqp_pool_request_custom(Api, PubFun, ValidateFun, Timeout, Bind) orelse Timeout =:= 'infinity') -> kz_amqp_worker:call_custom(Api, PubFun, ValidateFun, Timeout, Bind). --spec amqp_pool_collect(api_terms(), kz_amqp_worker:publish_fun()) -> +-spec amqp_pool_collect(kz_term:api_terms(), kz_amqp_worker:publish_fun()) -> {'ok', kz_json:objects()} | {'timeout', kz_json:objects()} | {'error', any()}. amqp_pool_collect(Api, PubFun) -> amqp_pool_collect(Api, PubFun, kz_amqp_worker:default_timeout()). --spec amqp_pool_collect(api_terms(), kz_amqp_worker:publish_fun(), kz_amqp_worker:timeout_or_until()) -> +-spec amqp_pool_collect(kz_term:api_terms(), kz_amqp_worker:publish_fun(), kz_amqp_worker:timeout_or_until()) -> {'ok', kz_json:objects()} | {'timeout', kz_json:objects()} | {'error', any()}. amqp_pool_collect(Api, PubFun, TimeoutOrUntil) -> kz_amqp_worker:call_collect(Api, PubFun, TimeoutOrUntil). --spec amqp_pool_collect(api_terms(), kz_amqp_worker:publish_fun(), kz_amqp_worker:collect_until(), kz_timeout()) -> +-spec amqp_pool_collect(kz_term:api_terms(), kz_amqp_worker:publish_fun(), kz_amqp_worker:collect_until(), timeout()) -> {'ok', kz_json:objects()} | {'timeout', kz_json:objects()} | {'error', any()}. @@ -667,8 +667,8 @@ amqp_pool_collect(Api, PubFun, Until, Timeout) -> %% in the system_config DB. Defaults to Request (To is the other option) %% @end %%-------------------------------------------------------------------- --spec get_destination(kz_json:object(), ne_binary(), ne_binary()) -> - {ne_binary(), ne_binary()}. +-spec get_destination(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> + {kz_term:ne_binary(), kz_term:ne_binary()}. get_destination(JObj, Cat, Key) -> case kapps_config:get(Cat, Key, <<"Request">>) of <<"To">> -> @@ -677,8 +677,8 @@ get_destination(JObj, Cat, Key) -> get_destination(JObj, [<<"Request">>, <<"To">>]) end. --spec get_destination(kz_json:object(), ne_binaries()) -> - {ne_binary(), ne_binary()}. +-spec get_destination(kz_json:object(), kz_term:ne_binaries()) -> + {kz_term:ne_binary(), kz_term:ne_binary()}. get_destination(JObj, [Key|Keys]) -> case maybe_split(Key, JObj) of [User,Realm] -> {User,Realm}; @@ -696,7 +696,7 @@ maybe_split(Key, JObj) -> Bin -> binary:split(Bin, <<"@">>) end. --spec write_tts_file(ne_binary(), ne_binary()) -> +-spec write_tts_file(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | {'error', file:posix() | 'badarg' | 'terminated'}. write_tts_file(Path, Say) -> @@ -704,16 +704,16 @@ write_tts_file(Path, Say) -> {'ok', _, Wav} = kazoo_tts:create(Say), file:write_file(Path, Wav). --spec to_magic_hash(iodata()) -> ne_binary(). +-spec to_magic_hash(iodata()) -> kz_term:ne_binary(). to_magic_hash(Bin) -> kz_term:to_hex_binary(zlib:zip(Bin)). --spec from_magic_hash(ne_binary()) -> ne_binary(). +-spec from_magic_hash(kz_term:ne_binary()) -> kz_term:ne_binary(). from_magic_hash(Bin) -> zlib:unzip(kz_binary:from_hex(Bin)). -spec media_local_store_url(kapps_call:call(), kz_json:object()) -> - {'ok', ne_binary()} | + {'ok', kz_term:ne_binary()} | {'proxy', tuple()} | {'error', any()}. media_local_store_url(Call, JObj) -> diff --git a/core/kazoo_apps/src/kazoo_apps_app.erl b/core/kazoo_apps/src/kazoo_apps_app.erl index 5f0fd1c44a0..c14d4c8620d 100644 --- a/core/kazoo_apps/src/kazoo_apps_app.erl +++ b/core/kazoo_apps/src/kazoo_apps_app.erl @@ -15,7 +15,7 @@ -export([start/0]). --spec start() -> {'ok', atoms()}. +-spec start() -> {'ok', kz_term:atoms()}. start() -> {'ok', _Apps} = application:ensure_all_started(?APP). @@ -23,7 +23,7 @@ start() -> %% @public %% @doc Implement the application start behaviour --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_StartType, _StartArgs) -> kazoo_apps_sup:start_link(). diff --git a/core/kazoo_apps/src/kazoo_apps_init.erl b/core/kazoo_apps/src/kazoo_apps_init.erl index 7626738a0a9..601bed4b287 100644 --- a/core/kazoo_apps/src/kazoo_apps_init.erl +++ b/core/kazoo_apps/src/kazoo_apps_init.erl @@ -15,7 +15,7 @@ -include("kazoo_apps.hrl"). --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> _ = sanity_checks(), %% one day make this true _ = kz_util:spawn(fun init/0), diff --git a/core/kazoo_apps/src/kazoo_apps_maint_listener.erl b/core/kazoo_apps/src/kazoo_apps_maint_listener.erl index 0ad28219556..5fa46096099 100644 --- a/core/kazoo_apps/src/kazoo_apps_maint_listener.erl +++ b/core/kazoo_apps/src/kazoo_apps_maint_listener.erl @@ -61,7 +61,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER ,[{'bindings', ?BINDINGS} @@ -74,7 +74,7 @@ start_link() -> ,[] ). --spec handle_req(kapi_maintenance:req(), kz_proplist()) -> 'ok'. +-spec handle_req(kapi_maintenance:req(), kz_term:proplist()) -> 'ok'. handle_req(MaintJObj, _Props) -> 'true' = kapi_maintenance:req_v(MaintJObj), handle_refresh(MaintJObj @@ -160,7 +160,7 @@ init([]) -> %% {stop, Reason, Reply, State} | %% {stop, Reason, State} %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -171,7 +171,7 @@ handle_call(_Request, _From, State) -> %% {noreply, State, Timeout} | %% {stop, Reason, State} %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _QueueNAme}}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'is_consuming', _IsConsuming}}, State) -> @@ -186,7 +186,7 @@ handle_cast(_Msg, State) -> %% {noreply, State, Timeout} | %% {stop, Reason, State} %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -195,7 +195,7 @@ handle_info(_Info, State) -> %% @doc Allows listener to pass options to handlers %% @spec handle_event(JObj, State) -> {reply, Options} %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. @@ -233,7 +233,7 @@ code_change(_OldVsn, State, _Extra) -> %%-------------------------------------------------------------------- -define(VIEW_NUMBERS_ACCOUNT, <<"_design/numbers">>). --spec refresh_account_db(ne_binary()) -> 'ok'. +-spec refresh_account_db(kz_term:ne_binary()) -> 'ok'. refresh_account_db(Database) -> AccountDb = kz_util:format_account_id(Database, 'encoded'), AccountId = kz_util:format_account_id(Database, 'raw'), @@ -254,20 +254,20 @@ refresh_account_db(Database) -> _ = kazoo_bindings:map(kapps_maintenance:binding({'refresh_account', AccountDb}), AccountId), 'ok'. --spec remove_depreciated_account_views(ne_binary()) -> 'ok'. +-spec remove_depreciated_account_views(kz_term:ne_binary()) -> 'ok'. remove_depreciated_account_views(AccountDb) -> _ = kz_datamgr:del_doc(AccountDb, <<"_design/limits">>), _ = kz_datamgr:del_doc(AccountDb, <<"_design/sub_account_reps">>), 'ok'. --spec ensure_account_definition(ne_binary(), ne_binary()) -> 'ok'. +-spec ensure_account_definition(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. ensure_account_definition(AccountDb, AccountId) -> case kz_datamgr:open_doc(AccountDb, AccountId) of {'error', 'not_found'} -> get_definition_from_accounts(AccountDb, AccountId); {'ok', _} -> 'ok' end. --spec get_definition_from_accounts(ne_binary(), ne_binary()) -> 'ok'. +-spec get_definition_from_accounts(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. get_definition_from_accounts(AccountDb, AccountId) -> case kz_datamgr:open_doc(?KZ_ACCOUNTS_DB, AccountId) of {'ok', JObj} -> kz_datamgr:ensure_saved(AccountDb, kz_doc:delete_revision(JObj)); diff --git a/core/kazoo_apps/src/kazoo_apps_sup.erl b/core/kazoo_apps/src/kazoo_apps_sup.erl index 759a71487a5..3dfa9797c1c 100644 --- a/core/kazoo_apps/src/kazoo_apps_sup.erl +++ b/core/kazoo_apps/src/kazoo_apps_sup.erl @@ -30,11 +30,11 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec start_child(supervisor:child_spec()) -> sup_startchild_ret(). +-spec start_child(supervisor:child_spec()) -> kz_types:sup_startchild_ret(). start_child(Spec) -> supervisor:start_child(?SERVER, Spec). @@ -51,7 +51,7 @@ start_child(Spec) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 25, diff --git a/core/kazoo_apps/src/kz_hooks.erl b/core/kazoo_apps/src/kz_hooks.erl index 33eb977c1ff..cd53242d68a 100644 --- a/core/kazoo_apps/src/kz_hooks.erl +++ b/core/kazoo_apps/src/kz_hooks.erl @@ -16,29 +16,29 @@ -include_lib("kazoo_stdlib/include/kz_types.hrl"). -spec register() -> 'true'. --spec register(ne_binary()) -> 'true'. --spec register(ne_binary(), ne_binary()) -> 'true'. +-spec register(kz_term:ne_binary()) -> 'true'. +-spec register(kz_term:ne_binary(), kz_term:ne_binary()) -> 'true'. register() -> kz_hooks_util:register(). register(AccountId) -> kz_hooks_util:register(AccountId). register(AccountId, EventName) -> kz_hooks_util:register(AccountId, EventName). -spec deregister() -> 'true'. --spec deregister(ne_binary()) -> 'true'. --spec deregister(ne_binary(), ne_binary()) -> 'true'. +-spec deregister(kz_term:ne_binary()) -> 'true'. +-spec deregister(kz_term:ne_binary(), kz_term:ne_binary()) -> 'true'. deregister() -> kz_hooks_util:deregister(). deregister(AccountId) -> kz_hooks_util:deregister(AccountId). deregister(AccountId, EventName) -> kz_hooks_util:deregister(AccountId, EventName). -spec register_rr() -> 'true'. --spec register_rr(ne_binary()) -> 'true'. --spec register_rr(ne_binary(), ne_binary()) -> 'true'. +-spec register_rr(kz_term:ne_binary()) -> 'true'. +-spec register_rr(kz_term:ne_binary(), kz_term:ne_binary()) -> 'true'. register_rr() -> kz_hooks_util:register_rr(). register_rr(AccountId) -> kz_hooks_util:register_rr(AccountId). register_rr(AccountId, EventName) -> kz_hooks_util:register_rr(AccountId, EventName). -spec deregister_rr() -> 'true'. --spec deregister_rr(ne_binary()) -> 'true'. --spec deregister_rr(ne_binary(), ne_binary()) -> 'true'. +-spec deregister_rr(kz_term:ne_binary()) -> 'true'. +-spec deregister_rr(kz_term:ne_binary(), kz_term:ne_binary()) -> 'true'. deregister_rr() -> kz_hooks_util:deregister_rr(). deregister_rr(AccountId) -> kz_hooks_util:deregister_rr(AccountId). deregister_rr(AccountId, EventName) -> kz_hooks_util:deregister_rr(AccountId, EventName). diff --git a/core/kazoo_apps/src/kz_hooks_listener.erl b/core/kazoo_apps/src/kz_hooks_listener.erl index b0299e7e59d..864dfc19d69 100644 --- a/core/kazoo_apps/src/kz_hooks_listener.erl +++ b/core/kazoo_apps/src/kz_hooks_listener.erl @@ -43,7 +43,7 @@ -define(QUEUE_OPTIONS, []). -define(CONSUME_OPTIONS, []). --record(state, {call_events = [] :: ne_binaries()}). +-record(state, {call_events = [] :: kz_term:ne_binaries()}). -type state() :: #state{}. %%%=================================================================== @@ -53,7 +53,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link({'local', ?SERVER} ,?MODULE @@ -102,7 +102,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -116,7 +116,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'maybe_add_binding', 'all'}, #state{call_events=Events}=State) -> case [E || E <- ?ALL_EVENTS, not lists:member(E, Events)] of [] -> {'noreply', State}; @@ -167,7 +167,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> lager:debug("unhandled msg: ~p", [_Info]), {'noreply', State}. @@ -180,7 +180,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', [{'rr', 'false'}]}. diff --git a/core/kazoo_apps/src/kz_hooks_listener_sup.erl b/core/kazoo_apps/src/kz_hooks_listener_sup.erl index 76439ade493..c2dedf76043 100644 --- a/core/kazoo_apps/src/kz_hooks_listener_sup.erl +++ b/core/kazoo_apps/src/kz_hooks_listener_sup.erl @@ -28,7 +28,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -45,7 +45,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 25, diff --git a/core/kazoo_apps/src/kz_hooks_shared_listener.erl b/core/kazoo_apps/src/kz_hooks_shared_listener.erl index 217a072de14..581b318b289 100644 --- a/core/kazoo_apps/src/kz_hooks_shared_listener.erl +++ b/core/kazoo_apps/src/kz_hooks_shared_listener.erl @@ -46,7 +46,7 @@ -define(QUEUE_OPTIONS, [{'exclusive', 'false'}]). -define(CONSUME_OPTIONS, [{'exclusive', 'false'}]). --record(state, {call_events = [] :: ne_binaries()}). +-record(state, {call_events = [] :: kz_term:ne_binaries()}). -type state() :: #state{}. %%%=================================================================== @@ -56,7 +56,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link({'local', ?SERVER} ,?MODULE @@ -104,7 +104,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -118,7 +118,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'maybe_add_binding', 'all'}, #state{call_events=Events}=State) -> case [E || E <- ?ALL_EVENTS, not lists:member(E, Events)] of [] -> {'noreply', State}; @@ -169,7 +169,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> lager:debug("unhandled msg: ~p", [_Info]), {'noreply', State}. @@ -182,7 +182,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', [{'rr', 'true'}]}. diff --git a/core/kazoo_apps/src/kz_hooks_util.erl b/core/kazoo_apps/src/kz_hooks_util.erl index b8891692762..a63f67f2e0b 100644 --- a/core/kazoo_apps/src/kz_hooks_util.erl +++ b/core/kazoo_apps/src/kz_hooks_util.erl @@ -39,8 +39,8 @@ ,{'p', 'l', {'kz_hook_rr', AccountId, EventName}}). -spec register() -> 'true'. --spec register(ne_binary()) -> 'true'. --spec register(ne_binary(), ne_binary()) -> 'true'. +-spec register(kz_term:ne_binary()) -> 'true'. +-spec register(kz_term:ne_binary(), kz_term:ne_binary()) -> 'true'. register() -> maybe_add_hook(?HOOK_REG). register(AccountId) -> @@ -49,8 +49,8 @@ register(AccountId, EventName) -> maybe_add_hook(?HOOK_REG(AccountId, EventName)). -spec deregister() -> 'true'. --spec deregister(ne_binary()) -> 'true'. --spec deregister(ne_binary(), ne_binary()) -> 'true'. +-spec deregister(kz_term:ne_binary()) -> 'true'. +-spec deregister(kz_term:ne_binary(), kz_term:ne_binary()) -> 'true'. deregister() -> maybe_remove_hook(?HOOK_REG). deregister(AccountId) -> @@ -58,9 +58,9 @@ deregister(AccountId) -> deregister(AccountId, EventName) -> maybe_remove_hook(?HOOK_REG(AccountId, EventName)). --spec registered() -> pids(). --spec registered(ne_binary()) -> pids(). --spec registered(ne_binary(), ne_binary()) -> pids(). +-spec registered() -> kz_term:pids(). +-spec registered(kz_term:ne_binary()) -> kz_term:pids(). +-spec registered(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:pids(). registered() -> gproc:lookup_pids(?HOOK_REG). registered(AccountId) -> @@ -68,7 +68,7 @@ registered(AccountId) -> registered(AccountId, EventName) -> gproc:lookup_pids(?HOOK_REG(AccountId, EventName)). --spec all_registered() -> pids(). +-spec all_registered() -> kz_term:pids(). all_registered() -> lists:usort( lists:foldl(fun all_registered_fold/2 @@ -87,8 +87,8 @@ all_registered_fold(HookPattern, Acc) -> gproc:select(Match) ++ Acc. -spec register_rr() -> 'true'. --spec register_rr(ne_binary()) -> 'true'. --spec register_rr(ne_binary(), ne_binary()) -> 'true'. +-spec register_rr(kz_term:ne_binary()) -> 'true'. +-spec register_rr(kz_term:ne_binary(), kz_term:ne_binary()) -> 'true'. register_rr() -> maybe_add_hook(?HOOK_REG_RR). register_rr(AccountId) -> @@ -97,8 +97,8 @@ register_rr(AccountId, EventName) -> maybe_add_hook(?HOOK_REG_RR(AccountId, EventName)). -spec deregister_rr() -> 'true'. --spec deregister_rr(ne_binary()) -> 'true'. --spec deregister_rr(ne_binary(), ne_binary()) -> 'true'. +-spec deregister_rr(kz_term:ne_binary()) -> 'true'. +-spec deregister_rr(kz_term:ne_binary(), kz_term:ne_binary()) -> 'true'. deregister_rr() -> maybe_remove_hook(?HOOK_REG_RR). deregister_rr(AccountId) -> @@ -106,9 +106,9 @@ deregister_rr(AccountId) -> deregister_rr(AccountId, EventName) -> maybe_remove_hook(?HOOK_REG_RR(AccountId, EventName)). --spec registered_rr() -> pids(). --spec registered_rr(ne_binary()) -> pids(). --spec registered_rr(ne_binary(), ne_binary()) -> pids(). +-spec registered_rr() -> kz_term:pids(). +-spec registered_rr(kz_term:ne_binary()) -> kz_term:pids(). +-spec registered_rr(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:pids(). registered_rr() -> gproc:lookup_pids(?HOOK_REG_RR). registered_rr(AccountId) -> @@ -116,7 +116,7 @@ registered_rr(AccountId) -> registered_rr(AccountId, EventName) -> gproc:lookup_pids(?HOOK_REG_RR(AccountId, EventName)). --spec all_registered_rr() -> pids(). +-spec all_registered_rr() -> kz_term:pids(). all_registered_rr() -> lists:usort( lists:foldl(fun all_registered_fold/2 @@ -128,7 +128,7 @@ all_registered_rr() -> ). -spec maybe_add_hook(tuple()) -> 'true'. --spec maybe_add_hook(tuple(), pids()) -> 'true'. +-spec maybe_add_hook(tuple(), kz_term:pids()) -> 'true'. maybe_add_hook(Hook) -> case gproc:lookup_pids(Hook) of [] -> hook_it_up(Hook); @@ -159,7 +159,7 @@ maybe_add_binding(?HOOK_REG_RR(_AccountId, EventName)) -> maybe_add_binding_to_listener('kz_hooks_shared_listener', EventName). -spec maybe_add_binding_to_listener(atom()) -> 'ok'. --spec maybe_add_binding_to_listener(atom(), ne_binary() | 'all') -> 'ok'. +-spec maybe_add_binding_to_listener(atom(), kz_term:ne_binary() | 'all') -> 'ok'. maybe_add_binding_to_listener(ServerName) -> maybe_add_binding_to_listener(ServerName, 'all'). maybe_add_binding_to_listener(ServerName, EventName) -> @@ -192,13 +192,13 @@ maybe_remove_binding(?HOOK_REG_RR(_AccountId, EventName)) -> maybe_remove_binding_to_listener('kz_hooks_shared_listener', EventName). -spec maybe_remove_binding_to_listener(atom()) -> 'ok'. --spec maybe_remove_binding_to_listener(atom(), ne_binary() | 'all') -> 'ok'. +-spec maybe_remove_binding_to_listener(atom(), kz_term:ne_binary() | 'all') -> 'ok'. maybe_remove_binding_to_listener(ServerName) -> maybe_remove_binding_to_listener(ServerName, 'all'). maybe_remove_binding_to_listener(ServerName, EventName) -> gen_listener:cast(ServerName, {'maybe_remove_binding', EventName}). --spec handle_call_event(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_call_event(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_call_event(JObj, Props) -> 'true' = kapi_call:event_v(JObj), HookEvent = kz_json:get_value(<<"Event-Name">>, JObj), @@ -209,7 +209,7 @@ handle_call_event(JObj, Props) -> kz_util:put_callid(CallId), handle_call_event(JObj, AccountId, HookEvent, CallId, props:get_is_true('rr', Props)). --spec handle_call_event(kz_json:object(), api_binary(), ne_binary(), ne_binary(), boolean()) -> +-spec handle_call_event(kz_json:object(), kz_term:api_binary(), kz_term:ne_binary(), kz_term:ne_binary(), boolean()) -> 'ok'. handle_call_event(JObj, 'undefined', <<"CHANNEL_CREATE">>, CallId, RR) -> lager:debug("event 'channel_create' had no account id"), @@ -234,7 +234,7 @@ handle_call_event(JObj, AccountId, HookEvent, _CallId, 'true') -> gproc:send(?HOOK_REG_RR(AccountId), Evt), gproc:send(?HOOK_REG_RR(AccountId, HookEvent), Evt). --spec lookup_account_id(kz_json:object()) -> {'ok', ne_binary()} | {'error', any()}. +-spec lookup_account_id(kz_json:object()) -> {'ok', kz_term:ne_binary()} | {'error', any()}. lookup_account_id(JObj) -> case kz_call_event:account_id(JObj) of 'undefined' -> @@ -246,7 +246,7 @@ lookup_account_id(JObj) -> Id -> {'ok', Id} end. --spec fetch_account_id(ne_binary()) -> {'ok', ne_binary()} | {'error', any()}. +-spec fetch_account_id(kz_term:ne_binary()) -> {'ok', kz_term:ne_binary()} | {'error', any()}. fetch_account_id(Number) -> case knm_number:lookup_account(Number) of {'ok', AccountId, _} -> @@ -256,10 +256,10 @@ fetch_account_id(Number) -> {'error', _}=Error -> Error end. --spec cache_key_number(ne_binary()) -> {'kz_hooks', ne_binary()}. +-spec cache_key_number(kz_term:ne_binary()) -> {'kz_hooks', kz_term:ne_binary()}. cache_key_number(Number) -> {'kz_hooks', Number}. --spec get_inbound_destination(kz_json:object()) -> api_binary(). +-spec get_inbound_destination(kz_json:object()) -> kz_term:api_binary(). get_inbound_destination(JObj) -> {Number, _} = kapps_util:get_destination(JObj, <<"stepswitch">>, <<"inbound_user_field">>), case kapps_config:get_is_true(<<"stepswitch">>, <<"assume_inbound_e164">>, 'false') of @@ -267,6 +267,6 @@ get_inbound_destination(JObj) -> 'false' -> knm_converters:normalize(Number) end. --spec assume_e164(ne_binary()) -> ne_binary(). +-spec assume_e164(kz_term:ne_binary()) -> kz_term:ne_binary(). assume_e164(<<$+, _/binary>> = Number) -> Number; assume_e164(Number) -> <<$+, Number/binary>>. diff --git a/core/kazoo_apps/src/kz_notify.erl b/core/kazoo_apps/src/kz_notify.erl index fc8b5f9d580..e419ce74144 100644 --- a/core/kazoo_apps/src/kz_notify.erl +++ b/core/kazoo_apps/src/kz_notify.erl @@ -18,7 +18,7 @@ system_alert(Format, Args) -> Msg = io_lib:format(Format, Args), system_alert(Msg, Msg, []). --spec system_alert(string() | ne_binary(), string() | ne_binary(), kz_proplist()) -> 'ok'. +-spec system_alert(string() | kz_term:ne_binary(), string() | kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. system_alert(Subject, Msg, Headers) when not is_binary(Subject); not is_binary(Msg) -> @@ -30,17 +30,17 @@ system_alert(Subject, Msg, Headers) -> ], kz_amqp_worker:cast(Notify, fun kapi_notifications:publish_system_alert/1). --spec system_alert(ne_binary(), string() | ne_binary(), [any()], kz_proplist()) -> 'ok'. +-spec system_alert(kz_term:ne_binary(), string() | kz_term:ne_binary(), [any()], kz_term:proplist()) -> 'ok'. system_alert(Subject, Format, Args, Headers) -> Msg = io_lib:format(Format, Args), system_alert(Subject, Msg, Headers). --spec detailed_alert(string(), list(), kz_proplist()) -> 'ok'. +-spec detailed_alert(string(), list(), kz_term:proplist()) -> 'ok'. detailed_alert(Format, Args, Props) -> Msg = io_lib:format(Format, Args), detailed_alert(Msg, Msg, [{<<"Format">>, kz_term:to_binary(Format)} | Props], []). --spec detailed_alert(string() | ne_binary(), string() | ne_binary(), kz_proplist(), kz_proplist()) -> 'ok'. +-spec detailed_alert(string() | kz_term:ne_binary(), string() | kz_term:ne_binary(), kz_term:proplist(), kz_term:proplist()) -> 'ok'. detailed_alert(Subject, Msg, Props, Headers) when not is_binary(Subject); not is_binary(Msg) -> @@ -53,7 +53,7 @@ detailed_alert(Subject, Msg, Props, Headers) -> ], kz_amqp_worker:cast(Notify, fun kapi_notifications:publish_system_alert/1). --spec detailed_alert(string() | ne_binary(), string() | ne_binary(), [any()], kz_proplist(), kz_proplist()) -> 'ok'. +-spec detailed_alert(string() | kz_term:ne_binary(), string() | kz_term:ne_binary(), [any()], kz_term:proplist(), kz_term:proplist()) -> 'ok'. detailed_alert(Subject, Format, Args, Props, Headers) -> Msg = io_lib:format(Format, Args), detailed_alert(Subject, Msg, [{<<"Format">>, kz_term:to_binary(Format)} | Props], Headers). diff --git a/core/kazoo_apps/src/kz_storage.erl b/core/kazoo_apps/src/kz_storage.erl index fd818fe974a..b332a567e0b 100644 --- a/core/kazoo_apps/src/kz_storage.erl +++ b/core/kazoo_apps/src/kz_storage.erl @@ -18,11 +18,11 @@ %% ==================================================================== -export([store_file/3, store_file/4]). --spec store_file(ne_binary(), ne_binary(), ne_binary() | function()) -> 'ok' | {'error', any()}. +-spec store_file(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary() | function()) -> 'ok' | {'error', any()}. store_file(Node, Filename, Url) -> store_file(Node, Filename, Url, #{}). --spec store_file(ne_binary(), ne_binary(), ne_binary() | function(), map()) -> 'ok' | {'error', any()}. +-spec store_file(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary() | function(), map()) -> 'ok' | {'error', any()}. store_file(Node, Filename, Url, Map) -> App = kz_util:calling_app(), store_file(Filename, Url, storage_retries(App), storage_timeout(App), Map#{media_server => Node}). @@ -32,7 +32,7 @@ store_file(Node, Filename, Url, Map) -> %% ==================================================================== --spec store_file_args(ne_binary(), ne_binary() | function()) -> kz_proplist(). +-spec store_file_args(kz_term:ne_binary(), kz_term:ne_binary() | function()) -> kz_term:proplist(). store_file_args(Filename, UrlFun) -> Url = case is_function(UrlFun, 0) of 'true' -> UrlFun(); @@ -43,7 +43,7 @@ store_file_args(Filename, UrlFun) -> ,{<<"Http-Method">>, <<"put">>} ]. --spec store_file(ne_binary(), ne_binary() | function(), pos_integer(), kz_timeout(), map()) -> +-spec store_file(kz_term:ne_binary(), kz_term:ne_binary() | function(), pos_integer(), timeout(), map()) -> 'ok' | {'error', any()}. store_file(Filename, Url, Tries, Timeout, #{media_server := Node}=Map) -> Msg = case kz_maps:get('alert_msg', Map) of @@ -60,7 +60,7 @@ store_file(Filename, Url, Tries, Timeout, #{media_server := Node}=Map) -> end, do_store_file(Tries, Timeout, API, Msg, Map). --spec do_store_file(pos_integer(), kz_timeout(), function(), ne_binary(), map()) -> +-spec do_store_file(pos_integer(), timeout(), function(), kz_term:ne_binary(), map()) -> 'ok' | {'error', any()}. do_store_file(Tries, Timeout, API, Msg, #{media_server := Node}=Map) -> Payload = API(), @@ -86,8 +86,8 @@ do_store_file(Tries, Timeout, API, Msg, #{media_server := Node}=Map) -> retry_store_file(Tries - 1, Timeout, API, Msg, kz_term:to_binary(Error), Map) end. --spec retry_store_file(integer(), kz_timeout(), kz_proplist() | function() - ,ne_binary(), ne_binary(), map()) -> +-spec retry_store_file(integer(), timeout(), kz_term:proplist() | function() + ,kz_term:ne_binary(), kz_term:ne_binary(), map()) -> 'ok' | {'error', any()}. retry_store_file(0, _Timeout, _API, Msg, Error, Map) -> lager:critical("~s : ~s", [Msg, Error]), @@ -108,10 +108,10 @@ maybe_add_debug_data(JObj, Map) -> Data -> Map#{error_details => Data} end. --spec storage_timeout(ne_binary()) -> pos_integer(). +-spec storage_timeout(kz_term:ne_binary()) -> pos_integer(). storage_timeout(App) -> ?STORAGE_TIMEOUT(App). --spec storage_retries(ne_binary()) -> pos_integer(). +-spec storage_retries(kz_term:ne_binary()) -> pos_integer(). storage_retries(App) -> ?STORAGE_RETRIES(App). diff --git a/core/kazoo_ast/src/cb_api_endpoints.erl b/core/kazoo_ast/src/cb_api_endpoints.erl index a7ad5f1a3a1..5949c456ab5 100644 --- a/core/kazoo_ast/src/cb_api_endpoints.erl +++ b/core/kazoo_ast/src/cb_api_endpoints.erl @@ -114,7 +114,7 @@ methods_to_section(ModuleName, {Path, Methods}, Acc) -> ,sort_methods(Methods) ). --spec sort_methods(ne_binaries()) -> ne_binaries(). +-spec sort_methods(kz_term:ne_binaries()) -> kz_term:ne_binaries(). sort_methods(Methods) -> Ordering = [?HTTP_GET, ?HTTP_PUT, ?HTTP_POST, ?HTTP_PATCH, ?HTTP_DELETE], sort_methods(Methods, Ordering, []). @@ -142,14 +142,14 @@ method_to_section(Method, Acc, APIPath) -> | Acc ]. --spec method_as_action(ne_binary()) -> ne_binary(). +-spec method_as_action(kz_term:ne_binary()) -> kz_term:ne_binary(). method_as_action(?HTTP_GET) -> <<"Fetch">>; method_as_action(?HTTP_PUT) -> <<"Create">>; method_as_action(?HTTP_POST) -> <<"Change">>; method_as_action(?HTTP_DELETE) -> <<"Remove">>; method_as_action(?HTTP_PATCH) -> <<"Patch">>. --spec ref_doc_header(ne_binary()) -> iolist(). +-spec ref_doc_header(kz_term:ne_binary()) -> iolist(). ref_doc_header(BaseName) -> CleanedUpName = kz_ast_util:smash_snake(BaseName), [[maybe_add_schema(BaseName)] @@ -157,7 +157,7 @@ ref_doc_header(BaseName) -> ,["### ", CleanedUpName, "\n\n"] ]. --spec maybe_add_schema(ne_binary()) -> iolist(). +-spec maybe_add_schema(kz_term:ne_binary()) -> iolist(). maybe_add_schema(BaseName) -> case kz_ast_util:load_ref_schema(BaseName) of 'undefined' -> [?SCHEMA_SECTION, "\n\n"]; @@ -167,7 +167,7 @@ maybe_add_schema(BaseName) -> %% This looks for "#### Schema" in the doc file and adds the JSON schema formatted as the markdown table %% Schema = "vmboxes" or "devices" %% Doc = "voicemail.md" or "devices.md" --spec schema_to_doc(ne_binary(), ne_binary()) -> 'ok'. +-spec schema_to_doc(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. schema_to_doc(Schema, Doc) -> {'ok', SchemaJObj} = kz_json_schema:load(Schema), DocFile = filename:join([code:lib_dir('crossbar'), "doc", Doc]), @@ -180,7 +180,7 @@ schema_to_doc(Schema, Doc) -> io:format("file ~s appears to have a schema section already~n", [DocFile]) end. --type ref_table() :: {ne_binary(), ref_tables()} | ne_binary(). +-type ref_table() :: {kz_term:ne_binary(), ref_tables()} | kz_term:ne_binary(). -type ref_tables() :: [ref_table()] | []. -spec ref_tables_to_doc(ref_tables()) -> iolist(). @@ -242,7 +242,7 @@ to_swagger_definitions() -> ,kz_json:new() ). --spec process_schema(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec process_schema(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). process_schema(Filename, Definitions) -> {'ok', Bin} = file:read_file(Filename), KeysToDelete = [<<"_id">> @@ -263,12 +263,12 @@ process_schema(Filename, Definitions) -> Name = kz_term:to_binary(filename:basename(Filename, ".json")), kz_json:set_value(Name, JObj, Definitions). --spec is_kazoo_prefixed(ne_binaries()) -> boolean(). +-spec is_kazoo_prefixed(kz_term:ne_binaries()) -> boolean(). is_kazoo_prefixed([]) -> 'false'; is_kazoo_prefixed([<<"kazoo-", _/binary>>|_]) -> 'true'; is_kazoo_prefixed([_Field|Path]) -> is_kazoo_prefixed(Path). --spec maybe_fix_ref(ne_binary()) -> ne_binary(). +-spec maybe_fix_ref(kz_term:ne_binary()) -> kz_term:ne_binary(). maybe_fix_ref(<<"#",_/binary>>=Ref) -> Ref; maybe_fix_ref(RelativePath=?NE_BINARY) -> <<"#/definitions/", RelativePath/binary>>. @@ -302,7 +302,7 @@ to_swagger_path(Path, PathMeta, Acc) -> F = fun(Method, Acc1) -> add_swagger_path(Method, Acc1, Path, SchemaParameter) end, lists:foldl(F, Acc, Methods). --spec add_swagger_path(ne_binary(), kz_json:object(), kz_json:key(), api_object()) -> +-spec add_swagger_path(kz_term:ne_binary(), kz_json:object(), kz_json:key(), kz_term:api_object()) -> kz_json:object(). add_swagger_path(Method, Acc, Path, SchemaParameter) -> MethodJObj = kz_json:get_value([Path, Method], Acc, kz_json:new()), @@ -315,7 +315,7 @@ add_swagger_path(Method, Acc, Path, SchemaParameter) -> ]), kz_json:insert_values(Vs, Acc). --spec make_parameters(ne_binary(), ne_binary(), api_object()) -> ne_binaries(). +-spec make_parameters(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_object()) -> kz_term:ne_binaries(). make_parameters(Path, Method, SchemaParameter) -> lists:usort(fun compare_parameters/2 ,lists:flatten( @@ -333,7 +333,7 @@ compare_parameters(Param1, Param2) -> Keys = [<<"name">>, <<"$ref">>], kz_json:get_first_defined(Keys, Param1) >= kz_json:get_first_defined(Keys, Param2). --spec maybe_add_schema(any(), ne_binary(), kz_json:object()) -> api_object(). +-spec maybe_add_schema(any(), kz_term:ne_binary(), kz_json:object()) -> kz_term:api_object(). maybe_add_schema(_Path, Method, Schema) when Method =:= <<"put">>; Method =:= <<"post">> -> @@ -341,7 +341,7 @@ maybe_add_schema(_Path, Method, Schema) maybe_add_schema(_Path, _Method, _Parameters) -> 'undefined'. --spec swagger_params(kz_json:object()) -> api_object(). +-spec swagger_params(kz_json:object()) -> kz_term:api_object(). swagger_params(PathMeta) -> case kz_json:get_ne_binary_value(<<"schema">>, PathMeta) of 'undefined' -> 'undefined'; @@ -356,7 +356,7 @@ swagger_params(PathMeta) -> ]) end. --spec auth_token_param(ne_binary(), ne_binary()) -> api_object(). +-spec auth_token_param(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_object(). auth_token_param(Path, _Method) -> case is_authtoken_required(Path) of 'undefined' -> 'undefined'; @@ -364,32 +364,32 @@ auth_token_param(Path, _Method) -> false -> kz_json:from_list([{<<"$ref">>, <<"#/parameters/"?X_AUTH_TOKEN_NOT_REQUIRED>>}]) end. --spec is_authtoken_required(ne_binary()) -> api_boolean(). +-spec is_authtoken_required(kz_term:ne_binary()) -> kz_term:api_boolean(). is_authtoken_required(<<"/"?ACCOUNTS_PREFIX"/", _/binary>>=Path) -> not is_api_c2c_connect(Path); is_authtoken_required(_Path) -> 'undefined'. --spec is_api_c2c_connect(ne_binary()) -> boolean(). +-spec is_api_c2c_connect(kz_term:ne_binary()) -> boolean(). is_api_c2c_connect(<<"/"?ACCOUNTS_PREFIX"/clicktocall/", _/binary>>=Path) -> kz_binary:suffix(<<"/connect">>, Path); is_api_c2c_connect(_) -> 'false'. --spec path_params(ne_binary(), any()) -> kz_json:objects(). +-spec path_params(kz_term:ne_binary(), any()) -> kz_json:objects(). path_params(Path, _Method) -> [path_param(Param) || Param <- split_url(Path), is_path_variable(Param) ]. --spec path_param(ne_binary()) -> kz_json:object(). +-spec path_param(kz_term:ne_binary()) -> kz_json:object(). path_param(PathToken) -> Param = unbrace_param(PathToken), kz_json:from_list([{<<"$ref">>, <<"#/parameters/", Param/binary>>}]). --spec split_url(ne_binary()) -> ne_binaries(). +-spec split_url(kz_term:ne_binary()) -> kz_term:ne_binaries(). split_url(Path) -> binary:split(Path, <<$/>>, ['global']). --spec is_path_variable(ne_binary()) -> boolean(). +-spec is_path_variable(kz_term:ne_binary()) -> boolean(). is_path_variable(Param) -> -1 =/= kz_binary:pos(${, Param). @@ -405,7 +405,7 @@ format_pc_module({Module, CallbackConfig}, Acc) -> format_pc_module(_MC, Acc) -> Acc. --spec format_pc_config(path_with_methods(), kz_json:object(), module(), api_ne_binary()) -> +-spec format_pc_config(path_with_methods(), kz_json:object(), module(), kz_term:api_ne_binary()) -> kz_json:object(). format_pc_config(_ConfigData, Acc, _Module, 'undefined') -> Acc; format_pc_config({Callback, Paths}, Acc, Module, ModuleName) -> @@ -488,7 +488,7 @@ swagger_api_path(Path, ModuleName) -> API = kz_util:iolist_join($/, [ModuleName | format_path_tokens(Path)]), iolist_to_binary([$/, API]). --spec path_name(atom()) -> api_ne_binary(). +-spec path_name(atom()) -> kz_term:api_ne_binary(). path_name(Module) -> case grep_cb_module(Module) of {'match', [<<"about">>=Name]} -> Name; @@ -632,7 +632,7 @@ arg_to_path(?MATCH(?BINARY_MATCH(_), ?VAR(Name)), Acc) -> [kz_term:to_binary(Name) | Acc]. -spec binary_match_to_path([?BINARY_STRING(atom()) | ?BINARY_VAR(atom())]) -> - ne_binary(). + kz_term:ne_binary(). binary_match_to_path(Matches) -> iolist_to_binary([binary_to_path(Match) || Match <- Matches]). @@ -650,7 +650,7 @@ find_methods(ClauseBody, Acc) -> -define(CB_CONTEXT_CALL(Fun), ?MOD_FUN('cb_context', Fun)). --spec find_methods_in_clause(erl_parse:abstract_expr(), ne_binaries()) -> ne_binaries(). +-spec find_methods_in_clause(erl_parse:abstract_expr(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). find_methods_in_clause(?VAR('Context'), Acc) -> Acc; find_methods_in_clause(?VAR('Context1'), Acc) -> @@ -762,8 +762,8 @@ find_methods_in_clause(?CASE(_CaseConditional, CaseClauses), Acc0) -> -define(CONTENT_TYPE_BINS(Type, SubType), [?BINARY(Type), ?BINARY(SubType)]). -define(CONTENT_TYPE_VARS(Type, SubType), [?VAR(Type), ?VAR(SubType)]). --spec find_content_types_in_clause(erl_parse:abstract_expr(), ne_binaries()) -> - ne_binaries(). +-spec find_content_types_in_clause(erl_parse:abstract_expr(), kz_term:ne_binaries()) -> + kz_term:ne_binaries(). find_content_types_in_clause(?EMPTY_LIST, Acc) -> Acc; find_content_types_in_clause(?LIST(?TUPLE(?CONTENT_TYPE_VARS(_Type, _SubType)) ,Rest @@ -777,8 +777,8 @@ find_content_types_in_clause(?LIST(?TUPLE(?CONTENT_TYPE_BINS(Type, SubType)) CT = kz_binary:join([Type, SubType], <<"/">>), find_content_types_in_clause(Rest, [CT | Acc]). --spec grep_cb_module(atom() | ne_binary()) -> - {'match', ne_binaries()} | +-spec grep_cb_module(atom() | kz_term:ne_binary()) -> + {'match', kz_term:ne_binaries()} | 'nomatch'. grep_cb_module(Module) when is_atom(Module) -> grep_cb_module(kz_term:to_binary(Module)); @@ -788,7 +788,7 @@ grep_cb_module(?NE_BINARY=Module) -> ,[{'capture', 'all_but_first', 'binary'}] ). --spec to_swagger_parameters(ne_binaries()) -> kz_json:object(). +-spec to_swagger_parameters(kz_term:ne_binaries()) -> kz_json:object(). to_swagger_parameters(Paths) -> Params = [Param || Path <- Paths, Param <- split_url(Path), @@ -813,7 +813,7 @@ parameter_auth_token(IsRequired) -> ,{<<"description">>, <<"request authentication token">>} ]). --spec generic_id_path_param(ne_binary()) -> kz_json:json_proplist(). +-spec generic_id_path_param(kz_term:ne_binary()) -> kz_json:json_proplist(). generic_id_path_param(Name) -> [{<<"minLength">>, 32} ,{<<"maxLength">>, 32} @@ -821,7 +821,7 @@ generic_id_path_param(Name) -> | base_path_param(Name) ]. --spec base_path_param(ne_binary()) -> kz_json:json_proplist(). +-spec base_path_param(kz_term:ne_binary()) -> kz_json:json_proplist(). base_path_param(Param) -> [{<<"name">>, unbrace_param(Param)} ,{<<"in">>, <<"path">>} @@ -829,7 +829,7 @@ base_path_param(Param) -> ,{<<"type">>, <<"string">>} ]. --spec modb_id_path_param(ne_binary()) -> kz_json:json_proplist(). +-spec modb_id_path_param(kz_term:ne_binary()) -> kz_json:json_proplist(). modb_id_path_param(Param) -> %% Matches an MoDB id: [{<<"pattern">>, <<"^[0-9a-f-]+\$">>} @@ -839,7 +839,7 @@ modb_id_path_param(Param) -> ]. %% When param represents an account id (i.e. 32 bytes of hexa): --spec def_path_param(ne_binary()) -> kz_json:json_proplist(). +-spec def_path_param(kz_term:ne_binary()) -> kz_json:json_proplist(). def_path_param(<<"{ACCOUNT_ID}">>=P) -> generic_id_path_param(P); def_path_param(<<"{ADDRESS_ID}">>=P) -> generic_id_path_param(P); def_path_param(<<"{ALERT_ID}">>=P) -> generic_id_path_param(P); diff --git a/core/kazoo_ast/src/kapi_schemas.erl b/core/kazoo_ast/src/kapi_schemas.erl index a4700323214..10d4e64cdaf 100644 --- a/core/kazoo_ast/src/kapi_schemas.erl +++ b/core/kazoo_ast/src/kapi_schemas.erl @@ -13,8 +13,8 @@ -define(DEBUG(_Fmt, _Args), 'ok'). %%-define(DEBUG(Fmt, Args), io:format([$~, $p, $ | Fmt], [?LINE | Args])). --record(acc, {kapi_name = <<"empty">> :: ne_binary() %% s/kapi_(.+)/\1/ - ,api_name = <<"empty">> :: api_ne_binary() %% api function +-record(acc, {kapi_name = <<"empty">> :: kz_term:ne_binary() %% s/kapi_(.+)/\1/ + ,api_name = <<"empty">> :: kz_term:api_ne_binary() %% api function ,app_schemas = kz_json:new() :: kz_json:object() ,project_schemas = kz_json:new() :: kz_json:object() ,schema_dir = kz_ast_util:default_schema_priv_dir() :: file:filename_all() @@ -112,7 +112,7 @@ process_module(KapiModule) -> io:format(" done~n", []), Schemas. --spec print_dot(ne_binary() | module(), acc()) -> +-spec print_dot(kz_term:ne_binary() | module(), acc()) -> acc() | {'skip', acc()}. print_dot(<<"kapi_fs">>, #acc{}=Acc) -> @@ -156,7 +156,7 @@ add_schemas_to_bucket(_App, #acc{schema_dir = PrivDir ,project_schemas = kz_json:set_value(PrivDir, UpdatedSchema, ProjectSchemas) }. --spec set_function(ne_binary() | function(), integer(), acc()) -> acc(). +-spec set_function(kz_term:ne_binary() | function(), integer(), acc()) -> acc(). set_function(<<_/binary>> = Function, 0, #acc{kapi_name = <<"notifications">>}=Acc) -> case kz_binary:reverse(Function) of <<"noitinifed_", Nuf/binary>> -> diff --git a/core/kazoo_ast/src/kapps_config_usage.erl b/core/kazoo_ast/src/kapps_config_usage.erl index 7e91b8cf421..8cdcdb259e1 100644 --- a/core/kazoo_ast/src/kapps_config_usage.erl +++ b/core/kazoo_ast/src/kapps_config_usage.erl @@ -52,7 +52,7 @@ update_schema(Name, AutoGenSchema, PrivDir) -> andalso update_schema(Name, AccountSchema, PrivDir, <<"account_config">>), update_schema(Name, AutoGenSchema, PrivDir, <<"system_config">>). --spec update_schema(ne_binary(), kz_json:object(), file:filename_all(), ne_binary()) -> 'ok'. +-spec update_schema(kz_term:ne_binary(), kz_json:object(), file:filename_all(), kz_term:ne_binary()) -> 'ok'. update_schema(Name, AutoGenSchema, PrivDir, ConfigType) -> Path = kz_ast_util:schema_path(<>, PrivDir), diff --git a/core/kazoo_ast/src/kast_app_deps.erl b/core/kazoo_ast/src/kast_app_deps.erl index 7d5ff4f0152..ea0cb58c4a9 100644 --- a/core/kazoo_ast/src/kast_app_deps.erl +++ b/core/kazoo_ast/src/kast_app_deps.erl @@ -141,7 +141,7 @@ start_cache() -> {'ok', _Cache} = kz_cache:start_link(?MODULE). -spec stop_cache() -> 'ok'. --spec stop_cache(server_ref()) -> 'ok'. +-spec stop_cache(kz_types:server_ref()) -> 'ok'. stop_cache() -> stop_cache(?MODULE). stop_cache(Cache) -> diff --git a/core/kazoo_ast/src/kazoo_ast.erl b/core/kazoo_ast/src/kazoo_ast.erl index cf10e5cb1ee..23ca175fbe0 100644 --- a/core/kazoo_ast/src/kazoo_ast.erl +++ b/core/kazoo_ast/src/kazoo_ast.erl @@ -53,7 +53,7 @@ walk_app(App, Options) -> ConfigMap = options_to_config(Options), result(process_app(App, ConfigMap)). --spec walk_modules(atoms(), options()) -> accumulator() | 'undefined'. +-spec walk_modules(kz_term:atoms(), options()) -> accumulator() | 'undefined'. walk_modules(Modules, Options) when is_list(Modules) -> ConfigMap = options_to_config(Options), result(process_modules(Modules, ConfigMap)). diff --git a/core/kazoo_ast/src/kz_ast_util.erl b/core/kazoo_ast/src/kz_ast_util.erl index 7c56fe4c6c3..7e734d35422 100644 --- a/core/kazoo_ast/src/kz_ast_util.erl +++ b/core/kazoo_ast/src/kz_ast_util.erl @@ -58,7 +58,7 @@ add_module_ast_fold(?AST_RECORD(Name, Fields), _Module, #module_ast{records=Rs}= add_module_ast_fold(_Other, _Module, Acc) -> Acc. --spec ast_to_list_of_binaries(erl_parse:abstract_expr()) -> ne_binaries(). +-spec ast_to_list_of_binaries(erl_parse:abstract_expr()) -> kz_term:ne_binaries(). ast_to_list_of_binaries(ASTList) -> ast_to_list_of_binaries(ASTList, []). @@ -110,7 +110,7 @@ ast_list_el_to_el(?TUPLE(Fields)) -> list_to_tuple(Fields). %% user_auth -> User Auth --spec smash_snake(ne_binary()) -> iolist(). +-spec smash_snake(kz_term:ne_binary()) -> iolist(). smash_snake(BaseName) -> case binary:split(BaseName, <<"_">>, ['global']) of [Part] -> format_name_part(Part); @@ -120,7 +120,7 @@ smash_snake(BaseName) -> ] end. --spec format_name_part(ne_binary()) -> ne_binary(). +-spec format_name_part(kz_term:ne_binary()) -> kz_term:ne_binary(). format_name_part(<<"api">>) -> <<"API">>; format_name_part(<<"ip">>) -> <<"IP">>; format_name_part(<<"auth">>) -> <<"Authentication">>; @@ -203,7 +203,7 @@ app_modules(App) -> ,?TABLE_ROW(<<"---">>, <<"-----------">>, <<"----">>, <<"-------">>, <<"--------">>) ]). --spec schema_to_table(ne_binary() | kz_json:object()) -> iolist(). +-spec schema_to_table(kz_term:ne_binary() | kz_json:object()) -> iolist(). schema_to_table(<<"#/definitions/", _/binary>>=_S) -> []; schema_to_table(Schema=?NE_BINARY) -> case kz_json_schema:fload(Schema) of @@ -289,7 +289,7 @@ include_sub_refs_from_schema(_Key, Value, Acc) -> kz_json:foldl(fun include_sub_refs_from_schema/3, Acc, Value) end. --spec load_ref_schema(ne_binary()) -> api_object(). +-spec load_ref_schema(kz_term:ne_binary()) -> kz_term:api_object(). load_ref_schema(SchemaName) -> File = schema_path(<>), case file:read_file(File) of @@ -303,8 +303,8 @@ one_of_to_row(Option, Refs) -> any_of_to_row(Option, Refs) -> maybe_add_ref(Refs, Option). --spec property_to_row(kz_json:object(), ne_binary() | ne_binaries(), kz_json:object(), {iodata(), ne_binaries()}) -> - {iodata(), ne_binaries()}. +-spec property_to_row(kz_json:object(), kz_term:ne_binary() | kz_term:ne_binaries(), kz_json:object(), {iodata(), kz_term:ne_binaries()}) -> + {iodata(), kz_term:ne_binaries()}. property_to_row(SchemaJObj, Name=?NE_BINARY, Settings, {_, _}=Acc) -> property_to_row(SchemaJObj, [Name], Settings, Acc); property_to_row(SchemaJObj, Names, Settings, {Table, Refs}) -> @@ -333,14 +333,14 @@ property_to_row(SchemaJObj, Names, Settings, {Table, Refs}) -> } ). --spec maybe_add_ref(ne_binaries(), kz_json:object()) -> ne_binaries(). +-spec maybe_add_ref(kz_term:ne_binaries(), kz_json:object()) -> kz_term:ne_binaries(). maybe_add_ref(Refs, Settings) -> case kz_json:get_ne_binary_value(<<"$ref">>, Settings) of 'undefined' -> Refs; Ref -> lists:usort([Ref | Refs]) end. --spec is_row_required([ne_binary() | nonempty_string()], kz_json:object()) -> boolean(). +-spec is_row_required([kz_term:ne_binary() | nonempty_string()], kz_json:object()) -> boolean(). is_row_required(Names=[_|_], SchemaJObj) -> Path = lists:flatten( [case Key of diff --git a/core/kazoo_attachments/src/kazoo_attachments_app.erl b/core/kazoo_attachments/src/kazoo_attachments_app.erl index bb7808e216a..91f274879dc 100644 --- a/core/kazoo_attachments/src/kazoo_attachments_app.erl +++ b/core/kazoo_attachments/src/kazoo_attachments_app.erl @@ -17,7 +17,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> kazoo_attachments_sup:start_link(). diff --git a/core/kazoo_attachments/src/kazoo_attachments_sup.erl b/core/kazoo_attachments/src/kazoo_attachments_sup.erl index 3615ccc7fb2..40be6447ebe 100644 --- a/core/kazoo_attachments/src/kazoo_attachments_sup.erl +++ b/core/kazoo_attachments/src/kazoo_attachments_sup.erl @@ -27,7 +27,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -44,7 +44,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, diff --git a/core/kazoo_attachments/src/kz_att.hrl b/core/kazoo_attachments/src/kz_att.hrl index fcf31dc657e..8b9bac8e9ee 100644 --- a/core/kazoo_attachments/src/kz_att.hrl +++ b/core/kazoo_attachments/src/kz_att.hrl @@ -7,7 +7,7 @@ -define(CONFIG_CAT, <<"attachments">>). --type attachment_info() :: {ne_binary(), ne_binary(), ne_binary()}. +-type attachment_info() :: {kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()}. -define(KZ_ATT_HRL, 'true'). -endif. diff --git a/core/kazoo_attachments/src/kz_att_azure.erl b/core/kazoo_attachments/src/kz_att_azure.erl index cd63bb89b3f..334f4707ea5 100644 --- a/core/kazoo_attachments/src/kz_att_azure.erl +++ b/core/kazoo_attachments/src/kz_att_azure.erl @@ -25,7 +25,7 @@ resolve_path(#{container := Container} = Settings, AttInfo) -> Url = azure_format_url(Settings, AttInfo), {kz_term:to_list(Container), kz_term:to_list(Url)}. --spec azure_default_fields() -> kz_proplist(). +-spec azure_default_fields() -> kz_term:proplist(). azure_default_fields() -> [{group, [{arg, <<"id">>} ,<<"_">> @@ -33,7 +33,7 @@ azure_default_fields() -> ]} ]. --spec azure_format_url(map(), attachment_info()) -> ne_binary(). +-spec azure_format_url(map(), attachment_info()) -> kz_term:ne_binary(). azure_format_url(Map, AttInfo) -> kz_att_util:format_url(Map, AttInfo, azure_default_fields()). @@ -50,7 +50,7 @@ azure_pid(Account, Key) -> Pid -> Pid end. --spec put_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_data:options()) -> any(). +-spec put_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> any(). put_attachment(Settings, DbName, DocId, AName, Contents, _Options) -> CT = kz_mime:from_filename(AName), @@ -72,7 +72,7 @@ put_attachment(Settings, DbName, DocId, AName, Contents, _Options) -> end. --spec fetch_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary()) -> +-spec fetch_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', iodata()} | {'error', 'invalid_data' | 'not_found'}. fetch_attachment(HandlerProps, DbName, DocId, AName) -> diff --git a/core/kazoo_attachments/src/kz_att_azure_sup.erl b/core/kazoo_attachments/src/kz_att_azure_sup.erl index 5573843beae..c04de3b4b09 100644 --- a/core/kazoo_attachments/src/kz_att_azure_sup.erl +++ b/core/kazoo_attachments/src/kz_att_azure_sup.erl @@ -31,11 +31,11 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec start_azure(ne_binary() | string(), ne_binary() | string()) -> sup_startchild_ret(). +-spec start_azure(kz_term:ne_binary() | string(), kz_term:ne_binary() | string()) -> kz_types:sup_startchild_ret(). start_azure(Account, Key) when is_binary(Account) -> start_azure(kz_term:to_list(Account), Key); start_azure(Account, Key) when is_binary(Key) -> @@ -44,11 +44,11 @@ start_azure(Account, Key) -> supervisor:start_child(?SERVER, [{local, list_to_atom("erlazure_" ++ Account)}, Account, Key]). --spec workers() -> pids(). +-spec workers() -> kz_term:pids(). workers() -> [Pid || {_, Pid, 'worker', [_]} <- supervisor:which_children(?SERVER)]. --spec worker(ne_binary() | string()) -> api_pid(). +-spec worker(kz_term:ne_binary() | string()) -> kz_term:api_pid(). worker(Name) when is_binary(Name) -> worker(kz_term:to_list(Name)); worker(Name) -> @@ -76,7 +76,7 @@ worker(Name) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 0, diff --git a/core/kazoo_attachments/src/kz_att_dropbox.erl b/core/kazoo_attachments/src/kz_att_dropbox.erl index fa9c897b391..13bfa1cb2e1 100644 --- a/core/kazoo_attachments/src/kz_att_dropbox.erl +++ b/core/kazoo_attachments/src/kz_att_dropbox.erl @@ -24,11 +24,11 @@ %% API functions %% ==================================================================== --spec resolve_path(map(), attachment_info()) -> ne_binary(). +-spec resolve_path(map(), attachment_info()) -> kz_term:ne_binary(). resolve_path(Settings, AttInfo) -> <<"/", (dropbox_format_url(Settings, AttInfo))/binary>>. --spec dropbox_default_fields() -> kz_proplist(). +-spec dropbox_default_fields() -> kz_term:proplist(). dropbox_default_fields() -> [{group, [{arg, <<"id">>} ,<<"_">> @@ -36,7 +36,7 @@ dropbox_default_fields() -> ]} ]. --spec dropbox_format_url(map(), attachment_info()) -> ne_binary(). +-spec dropbox_format_url(map(), attachment_info()) -> kz_term:ne_binary(). dropbox_format_url(Map, AttInfo) -> kz_att_util:format_url(Map, AttInfo, dropbox_default_fields()). @@ -44,7 +44,7 @@ dropbox_token(#{oauth_doc_id := TokenDocId}) -> {'ok', #{token := #{authorization := Authorization}}} = kz_auth_client:token_for_auth_id(TokenDocId), Authorization. --spec put_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_data:options()) -> any(). +-spec put_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> any(). put_attachment(Settings, DbName, DocId, AName, Contents, _Options) -> Authorization = dropbox_token(Settings), Url = resolve_path(Settings, {DbName, DocId, AName}), @@ -62,7 +62,7 @@ put_attachment(Settings, DbName, DocId, AName, Contents, _Options) -> Else -> Else end. --spec dropbox_post(binary(), kz_proplist(), binary()) -> dropbox_result(). +-spec dropbox_post(binary(), kz_term:proplist(), binary()) -> dropbox_result(). dropbox_post(Url, Headers, Body) -> case kz_http:post(Url, Headers, Body) of {'ok', 200, ResponseHeaders, ResponseBody} -> @@ -76,7 +76,7 @@ dropbox_post(Url, Headers, Body) -> {'error', 'dropbox_error'} end. --spec fetch_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary()) -> +-spec fetch_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', iodata()} | {'error', 'invalid_data' | 'not_found'}. fetch_attachment(HandlerProps, _DbName, _DocId, _AName) -> diff --git a/core/kazoo_attachments/src/kz_att_ftp.erl b/core/kazoo_attachments/src/kz_att_ftp.erl index 5f5fb71f0ca..b520aac1455 100644 --- a/core/kazoo_attachments/src/kz_att_ftp.erl +++ b/core/kazoo_attachments/src/kz_att_ftp.erl @@ -17,7 +17,7 @@ -export([put_attachment/6]). -export([fetch_attachment/4]). --spec put_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_data:options()) -> any(). +-spec put_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> any(). put_attachment(Params, DbName, DocId, AName, Contents, _Options) -> #{url := BaseUrlParam} = Params, DocUrlField = maps:get('document_url_field', Params, 'undefined'), @@ -37,7 +37,7 @@ put_attachment(Params, DbName, DocId, AName, Contents, _Options) -> Error end. --spec send_request(ne_binary(), ne_binary()) -> 'ok' | {'error', any()}. +-spec send_request(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | {'error', any()}. send_request(Url, Contents) -> case http_uri:parse(kz_term:to_list(Url)) of {'ok',{'ftp', UserPass, Host, Port, FullPath,_Query}} -> @@ -96,14 +96,14 @@ url_fields(DocUrlField, Url) -> ,{'document', [{DocUrlField, Url}]} ]. --spec fetch_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary()) -> any(). +-spec fetch_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> any(). fetch_attachment(HandlerProps, _DbName, _DocId, _AName) -> case kz_json:get_value(<<"url">>, HandlerProps) of 'undefined' -> {'error', 'invalid_data'}; Url -> fetch_attachment(Url) end. --spec fetch_attachment(ne_binary()) -> {'ok', binary()} | {'error', any()}. +-spec fetch_attachment(kz_term:ne_binary()) -> {'ok', binary()} | {'error', any()}. fetch_attachment(Url) -> {_, Host, File, _, _} = kz_http_util:urlsplit(Url), try ftp:open(kz_term:to_list(Host)) of diff --git a/core/kazoo_attachments/src/kz_att_google_drive.erl b/core/kazoo_attachments/src/kz_att_google_drive.erl index 42bf3e05c6b..ca47a6daaea 100644 --- a/core/kazoo_attachments/src/kz_att_google_drive.erl +++ b/core/kazoo_attachments/src/kz_att_google_drive.erl @@ -33,7 +33,7 @@ %% API functions %% ==================================================================== --spec get_json_from_url(ne_binary(), kz_proplist()) -> {'ok', kz_json:object()} | {'error', any()}. +-spec get_json_from_url(kz_term:ne_binary(), kz_term:proplist()) -> {'ok', kz_json:object()} | {'error', any()}. get_json_from_url(Url, ReqHeaders) -> case kz_http:get(kz_term:to_list(Url), ReqHeaders, [{ssl, [{versions, ['tlsv1.2']}]}]) of {'ok', 200, _RespHeaders, Body} -> @@ -83,7 +83,7 @@ resolve_id(Name, Parent, Authorization) -> end. --spec resolve_ids(binaries(), binaries(), binary()) -> binaries(). +-spec resolve_ids(kz_term:binaries(), kz_term:binaries(), binary()) -> kz_term:binaries(). resolve_ids([], Acc, _Authorization) -> lists:reverse(Acc); resolve_ids([Id | Ids], [Parent | _]=Acc, Authorization) -> @@ -96,7 +96,7 @@ resolve_ids([Id | Ids], [Parent | _]=Acc, Authorization) -> end end. --spec resolve_folder(map(), ne_binaries(), binary()) -> ne_binaries(). +-spec resolve_folder(map(), kz_term:ne_binaries(), binary()) -> kz_term:ne_binaries(). resolve_folder(Settings, PathTokens, Authorization) -> case maps:get(folder_id, Settings, undefined) of undefined -> @@ -105,7 +105,7 @@ resolve_folder(Settings, PathTokens, Authorization) -> Path -> [Path] end. --spec resolve_path(map(), attachment_info(), binary()) -> {ne_binaries(), ne_binary()}. +-spec resolve_path(map(), attachment_info(), binary()) -> {kz_term:ne_binaries(), kz_term:ne_binary()}. resolve_path(Settings, AttInfo, Authorization) -> Url = gdrive_format_url(Settings, AttInfo), PathTokens = binary:split(Url, <<"/">>, ['global', 'trim_all']), @@ -113,7 +113,7 @@ resolve_path(Settings, AttInfo, Authorization) -> Folder = resolve_folder(Settings, lists:droplast(PathTokens), Authorization), {Folder, Name}. --spec gdrive_default_fields() -> kz_proplist(). +-spec gdrive_default_fields() -> kz_term:proplist(). gdrive_default_fields() -> [{group, [{arg, <<"id">>} ,<<"_">> @@ -121,11 +121,11 @@ gdrive_default_fields() -> ]} ]. --spec gdrive_format_url(map(), attachment_info()) -> ne_binary(). +-spec gdrive_format_url(map(), attachment_info()) -> kz_term:ne_binary(). gdrive_format_url(Map, AttInfo) -> kz_att_util:format_url(Map, AttInfo, gdrive_default_fields()). --spec put_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_data:options()) -> any(). +-spec put_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> any(). put_attachment(#{oauth_doc_id := TokenDocId}=Settings, DbName, DocId, AName, Contents, Options) -> {'ok', #{token := #{authorization := Authorization}}} = kz_auth_client:token_for_auth_id(TokenDocId, ?DRV_TOKEN_OPTIONS), CT = kz_mime:from_filename(AName), @@ -136,7 +136,7 @@ put_attachment(#{oauth_doc_id := TokenDocId}=Settings, DbName, DocId, AName, Con Else -> Else end. --spec gdrive_post(binary(), kz_proplist(), binary()) -> gdrive_result(). +-spec gdrive_post(binary(), kz_term:proplist(), binary()) -> gdrive_result(). gdrive_post(Url, Headers, Body) -> case kz_http:post(Url, Headers, Body) of {'ok', 200, ResponseHeaders, ResponseBody} -> @@ -151,8 +151,8 @@ gdrive_post(Url, Headers, Body) -> end. --spec send_attachment(binary(), binaries(), binary(), binary(), binary(), kz_proplist(), binary()) -> - {ok, kz_proplist()} | {'error', 'google_drive_error'}. +-spec send_attachment(binary(), kz_term:binaries(), binary(), binary(), binary(), kz_term:proplist(), binary()) -> + {ok, kz_term:proplist()} | {'error', 'google_drive_error'}. send_attachment(Authorization, Folder, TokenDocId, AName, CT, Options, Contents) -> JObj = kz_json:from_list( props:filter_empty( @@ -191,7 +191,7 @@ send_attachment(Authorization, Folder, TokenDocId, AName, CT, Options, Contents) Else -> Else end. --spec fetch_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary()) -> +-spec fetch_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', iodata()} | {'error', 'invalid_data' | 'not_found'}. fetch_attachment(HandlerProps, _DbName, _DocId, _AName) -> diff --git a/core/kazoo_attachments/src/kz_att_google_storage.erl b/core/kazoo_attachments/src/kz_att_google_storage.erl index 371d62c1706..3126f3140c9 100644 --- a/core/kazoo_attachments/src/kz_att_google_storage.erl +++ b/core/kazoo_attachments/src/kz_att_google_storage.erl @@ -28,7 +28,7 @@ %% API functions %% ==================================================================== --spec gstorage_default_fields() -> kz_proplist(). +-spec gstorage_default_fields() -> kz_term:proplist(). gstorage_default_fields() -> [{group, [{arg, <<"id">>} ,<<"_">> @@ -36,16 +36,16 @@ gstorage_default_fields() -> ]} ]. --spec gstorage_format_url(map(), attachment_info()) -> ne_binary(). +-spec gstorage_format_url(map(), attachment_info()) -> kz_term:ne_binary(). gstorage_format_url(Map, AttInfo) -> kz_att_util:format_url(Map, AttInfo, gstorage_default_fields()). --spec resolve_path(map(), attachment_info()) -> {ne_binary(), ne_binary()}. +-spec resolve_path(map(), attachment_info()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. resolve_path(#{bucket := Bucket} = Settings, AttInfo) -> Url = gstorage_format_url(Settings, AttInfo), {Bucket, Url}. --spec gstorage_token(map()) -> ne_binary(). +-spec gstorage_token(map()) -> kz_term:ne_binary(). gstorage_token(#{oauth_doc_id := TokenDocId}) -> {'ok', #{token := #{authorization := Authorization}}} = kz_auth_client:token_for_auth_id(TokenDocId, ?DRV_TOKEN_OPTIONS), Authorization; @@ -53,7 +53,7 @@ gstorage_token(#{oauth_app_id := AppId}) -> {'ok', #{token := #{authorization := Authorization}}} = kz_auth_client:token_for_app(AppId, ?DRV_TOKEN_OPTIONS), Authorization. --spec put_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_data:options()) -> any(). +-spec put_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> any(). put_attachment(Settings, DbName, DocId, AName, Contents, Options) -> Authorization = gstorage_token(Settings), CT = kz_mime:from_filename(AName), @@ -75,8 +75,8 @@ put_attachment(Settings, DbName, DocId, AName, Contents, Options) -> Else -> Else end. --spec send_attachment(binary(), ne_binary(), ne_binary(), binary(), kz_proplist(), binary()) -> - {ok, kz_proplist()} | {'error', 'gstorage_drive_error'}. +-spec send_attachment(binary(), kz_term:ne_binary(), kz_term:ne_binary(), binary(), kz_term:proplist(), binary()) -> + {ok, kz_term:proplist()} | {'error', 'gstorage_drive_error'}. send_attachment(Authorization, Bucket, AName, CT, Options, Contents) -> JObj = kz_json:from_list( props:filter_empty( @@ -117,7 +117,7 @@ send_attachment(Authorization, Bucket, AName, CT, Options, Contents) -> {'error', 'google_storage_error'} end. --spec fetch_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary()) -> +-spec fetch_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', iodata()} | {'error', 'invalid_data' | 'not_found'}. fetch_attachment(HandlerProps, _DbName, _DocId, _AName) -> diff --git a/core/kazoo_attachments/src/kz_att_http.erl b/core/kazoo_attachments/src/kz_att_http.erl index 0b392fd64bd..29de905eef2 100644 --- a/core/kazoo_attachments/src/kz_att_http.erl +++ b/core/kazoo_attachments/src/kz_att_http.erl @@ -19,7 +19,7 @@ -export([put_attachment/6]). -export([fetch_attachment/4]). --spec put_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_data:options()) -> any(). +-spec put_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> any(). put_attachment(Params, DbName, DocId, AName, Contents, Options) -> #{url := BaseUrlParam, verb := Verb} = Params, DocUrlField = maps:get('document_url_field', Params, 'undefined'), @@ -32,7 +32,7 @@ put_attachment(Params, DbName, DocId, AName, Contents, Options) -> {'error', _} = Error -> Error end. --spec base_separator(ne_binary()) -> binary(). +-spec base_separator(kz_term:ne_binary()) -> binary(). base_separator(Url) -> case kz_http_util:urlsplit(Url) of {_, _, _, <<>>, _} -> <<"/">>; @@ -96,7 +96,7 @@ url_fields(DocUrlField, Url) -> ,{'document', [{DocUrlField, Url}]} ]. --spec fetch_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary()) -> any(). +-spec fetch_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> any(). fetch_attachment(HandlerProps, _DbName, _DocId, _AName) -> case kz_json:get_value(<<"url">>, HandlerProps) of 'undefined' -> {'error', 'invalid_data'}; @@ -109,7 +109,7 @@ fetch_attachment(URL) -> {'error', _} = Error -> Error end. --spec fetch_attachment(ne_binary(), integer(), kz_json:object()) -> any(). +-spec fetch_attachment(kz_term:ne_binary(), integer(), kz_json:object()) -> any(). fetch_attachment(_Url, Redirects, _) when Redirects > ?MAX_REDIRECTS -> {'error', 'too_many_redirects'}; diff --git a/core/kazoo_attachments/src/kz_att_link.erl b/core/kazoo_attachments/src/kz_att_link.erl index c6657e1e2e2..044b62c09ff 100644 --- a/core/kazoo_attachments/src/kz_att_link.erl +++ b/core/kazoo_attachments/src/kz_att_link.erl @@ -21,7 +21,7 @@ -export([put_attachment/6]). -export([fetch_attachment/4]). --spec put_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_data:options()) -> any(). +-spec put_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> any(). put_attachment(_Params, _DbName, _DocId, _AName, _Contents, Options) -> Props = props:filter_undefined( [{<<"att_dbname">>, props:get_value('att_dbname', Options)} @@ -34,7 +34,7 @@ put_attachment(_Params, _DbName, _DocId, _AName, _Contents, Options) -> end. --spec fetch_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary()) -> any(). +-spec fetch_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> any(). fetch_attachment(HandlerProps, _DbName, _DocId, _AName) -> case kz_json:get_value(<<"att_name">>, HandlerProps) of 'undefined' -> get_att_name(HandlerProps); diff --git a/core/kazoo_attachments/src/kz_att_onedrive.erl b/core/kazoo_attachments/src/kz_att_onedrive.erl index cd638144c8a..1b515f80f3c 100644 --- a/core/kazoo_attachments/src/kz_att_onedrive.erl +++ b/core/kazoo_attachments/src/kz_att_onedrive.erl @@ -58,12 +58,12 @@ %% API functions %% ==================================================================== --spec resolve_put_url(map(), attachment_info()) -> ne_binary(). +-spec resolve_put_url(map(), attachment_info()) -> kz_term:ne_binary(). resolve_put_url(Settings, AttInfo) -> Url = onedrive_format_url(Settings, AttInfo), kz_binary:join(?GRAPH_ME_UPLOAD_URL(Url), <<"/">>). --spec onedrive_default_fields() -> kz_proplist(). +-spec onedrive_default_fields() -> kz_term:proplist(). onedrive_default_fields() -> [{group, [{arg, <<"id">>} ,<<"_">> @@ -71,16 +71,16 @@ onedrive_default_fields() -> ]} ]. --spec onedrive_format_url(map(), attachment_info()) -> ne_binary(). +-spec onedrive_format_url(map(), attachment_info()) -> kz_term:ne_binary(). onedrive_format_url(Map, AttInfo) -> kz_att_util:format_url(Map, AttInfo, onedrive_default_fields()). --spec onedrive_token(map(), map()) -> ne_binary(). +-spec onedrive_token(map(), map()) -> kz_term:ne_binary(). onedrive_token(#{oauth_doc_id := TokenDocId}, Options) -> {'ok', #{token := #{authorization := Authorization}}} = kz_auth_client:token_for_auth_id(TokenDocId, Options), Authorization. --spec put_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_data:options()) -> any(). +-spec put_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> any(). put_attachment(Settings, DbName, DocId, AName, Contents, _Options) -> Authorization = onedrive_token(Settings, ?DRV_PUT_TOKEN_OPTIONS), Headers = [{<<"Authorization">>, Authorization} @@ -97,7 +97,7 @@ put_attachment(Settings, DbName, DocId, AName, Contents, _Options) -> Else -> Else end. --spec onedrive_put(binary(), kz_proplist(), binary()) -> graph_result(). +-spec onedrive_put(binary(), kz_term:proplist(), binary()) -> graph_result(). onedrive_put(Url, Headers, Body) -> case kz_http:put(Url, Headers, Body, ?GRAPH_HTTP_OPTIONS) of {'ok', Code, ResponseHeaders, ResponseBody} @@ -118,7 +118,7 @@ onedrive_put(Url, Headers, Body) -> {'error', 'graph_drive_error'} end. --spec fetch_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary()) -> +-spec fetch_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', iodata()} | {'error', 'invalid_data' | 'not_found'}. fetch_attachment(HandlerProps, _DbName, _DocId, _AName) -> diff --git a/core/kazoo_attachments/src/kz_att_s3.erl b/core/kazoo_attachments/src/kz_att_s3.erl index 0c9c2e204f6..417ad338198 100644 --- a/core/kazoo_attachments/src/kz_att_s3.erl +++ b/core/kazoo_attachments/src/kz_att_s3.erl @@ -23,7 +23,7 @@ -spec bucket(map()) -> string(). bucket(#{bucket := Bucket}) -> kz_term:to_list(Bucket). --spec fix_scheme(ne_binary()) -> ne_binary(). +-spec fix_scheme(kz_term:ne_binary()) -> kz_term:ne_binary(). fix_scheme(<<"https://">> = Scheme) -> Scheme; fix_scheme(<<"http://">> = Scheme) -> Scheme; fix_scheme(<<"https">> = Scheme) -> <>; @@ -63,7 +63,7 @@ aws_config(#{'key' := Key }. --spec aws_default_fields() -> kz_proplist(). +-spec aws_default_fields() -> kz_term:proplist(). aws_default_fields() -> [{arg, <<"db">>} ,{group, [{arg, <<"id">>} @@ -72,11 +72,11 @@ aws_default_fields() -> ]} ]. --spec aws_format_url(map(), attachment_info()) -> ne_binary(). +-spec aws_format_url(map(), attachment_info()) -> kz_term:ne_binary(). aws_format_url(Map, AttInfo) -> kz_att_util:format_url(Map, AttInfo, aws_default_fields()). --spec merge_params(map() | ne_binary(), map() | undefined) -> map(). +-spec merge_params(map() | kz_term:ne_binary(), map() | undefined) -> map(). merge_params(#{bucket := Bucket, host := Host} = M1, #{bucket := Bucket, host := Host} = M2) -> kz_maps:merge(M1, M2); merge_params(#{bucket := Bucket} = M1, #{bucket := Bucket} = M2) -> @@ -90,20 +90,20 @@ merge_params(S3, M2) M1 = decode_retrieval(S3), merge_params(M1, M2). --spec aws_bpc(map(), attachment_info()) -> {string(), api_ne_binary(), aws_config()}. +-spec aws_bpc(map(), attachment_info()) -> {string(), kz_term:api_ne_binary(), aws_config()}. aws_bpc(Map, AttInfo) -> {bucket(Map), aws_format_url(Map, AttInfo), aws_config(Map)}. --spec aws_bpc(ne_binary(), map() | undefined, attachment_info()) -> {string(), api_ne_binary(), aws_config()}. +-spec aws_bpc(kz_term:ne_binary(), map() | undefined, attachment_info()) -> {string(), kz_term:api_ne_binary(), aws_config()}. aws_bpc(S3, Handler, Attinfo) -> aws_bpc(merge_params(S3, Handler), Attinfo). --spec encode_retrieval(map(), ne_binary()) -> ne_binary(). +-spec encode_retrieval(map(), kz_term:ne_binary()) -> kz_term:ne_binary(). encode_retrieval(Map, FilePath) -> base64:encode(term_to_binary({Map, FilePath})). --spec decode_retrieval(ne_binary()) -> map(). +-spec decode_retrieval(kz_term:ne_binary()) -> map(). decode_retrieval(S3) -> case binary_to_term(base64:decode(S3)) of {Key, Secret, Bucket, Path} -> @@ -134,7 +134,7 @@ decode_retrieval(S3) -> #{} = Map -> Map end. --spec put_attachment(map(), ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_data:options()) -> any(). +-spec put_attachment(map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> any(). put_attachment(Params, DbName, DocId, AName, Contents, _Options) -> {Bucket, FilePath, Config} = aws_bpc(Params, {DbName, DocId, AName}), case put_object(Bucket, FilePath, Contents, Config) of @@ -149,7 +149,7 @@ put_attachment(Params, DbName, DocId, AName, Contents, _Options) -> _E -> _E end. --spec fetch_attachment(kz_json:object(), ne_binary(), ne_binary(), ne_binary()) -> +-spec fetch_attachment(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'error', 'invalid_data'} | {'ok', binary()}. fetch_attachment(Conn, DbName, DocId, AName) -> @@ -178,7 +178,7 @@ convert_kv({<<"etag">> = K, V}) -> {K, binary:replace(V, <<$">>, <<>>, ['global'])}; convert_kv(KV) -> KV. --spec put_object(string(), string() | ne_binary(), binary(), aws_config()) -> {ok, kz_proplist()} | {error, any()}. +-spec put_object(string(), string() | kz_term:ne_binary(), binary(), aws_config()) -> {ok, kz_term:proplist()} | {error, any()}. put_object(Bucket, FilePath, Contents,Config) when is_binary(FilePath) -> put_object(Bucket, kz_term:to_list(FilePath), Contents,Config); @@ -196,7 +196,7 @@ put_object(Bucket, FilePath, Contents, #aws_config{s3_host=Host} = Config) -> {error, Reason} end. --spec get_object(string(), string() | ne_binary(), aws_config()) -> {ok, kz_proplist()} | {error, any()}. +-spec get_object(string(), string() | kz_term:ne_binary(), aws_config()) -> {ok, kz_term:proplist()} | {error, any()}. get_object(Bucket, FilePath, Config) when is_binary(FilePath) -> get_object(Bucket, kz_term:to_list(FilePath), Config); diff --git a/core/kazoo_attachments/src/kz_att_util.erl b/core/kazoo_attachments/src/kz_att_util.erl index 8c76d659dbb..825b244580c 100644 --- a/core/kazoo_attachments/src/kz_att_util.erl +++ b/core/kazoo_attachments/src/kz_att_util.erl @@ -16,10 +16,10 @@ -include("kz_att.hrl"). -type format_field() :: map() - | {'group', kz_proplist()} - | {'arg', ne_binary()} - | {'field', ne_binary()} - | ne_binary(). + | {'group', kz_term:proplist()} + | {'arg', kz_term:ne_binary()} + | {'field', kz_term:ne_binary()} + | kz_term:ne_binary(). -type format_fields() :: [format_field()]. -spec sha_mac(iodata(), iodata()) -> binary(). @@ -50,12 +50,12 @@ sha256(V) -> md5(V) -> crypto:hash('md5', V). --spec format_url(map(), attachment_info()) -> ne_binary(). +-spec format_url(map(), attachment_info()) -> kz_term:ne_binary(). format_url(#{file := Path}, _AttInfo) -> Path; format_url(Map, AttInfo) -> format_url(Map, AttInfo, default_format_url_fields()). --spec format_url(map(), attachment_info(), kz_proplist()) -> ne_binary(). +-spec format_url(map(), attachment_info(), kz_term:proplist()) -> kz_term:ne_binary(). format_url(#{file := Path}, _AttInfo, _Format) -> Path; format_url(Map, {DbName, DocId, AName}, Format) -> {'ok', JObj} = kz_datamgr:open_cache_doc(DbName, DocId), @@ -66,7 +66,7 @@ format_url(Map, {DbName, DocId, AName}, Format) -> ], format_url(Map, kz_doc:public_fields(JObj), Args, Format). --spec format_url(map(), kz_json:object(), kz_proplist(), kz_proplist()) -> ne_binary(). +-spec format_url(map(), kz_json:object(), kz_term:proplist(), kz_term:proplist()) -> kz_term:ne_binary(). format_url(#{file := Path}, _JObj, _Args, _DefaultFields) -> Path; format_url(Params, JObj, Args, DefaultFields) -> Fields = maps:get('field_list', Params, DefaultFields), @@ -77,7 +77,7 @@ format_url(Params, JObj, Args, DefaultFields) -> Path -> list_to_binary([Path, "/", BaseUrl]) end. --spec do_format_url(kz_proplist(), kz_json:object(), kz_proplist(), binary()) -> ne_binary(). +-spec do_format_url(kz_term:proplist(), kz_json:object(), kz_term:proplist(), binary()) -> kz_term:ne_binary(). do_format_url(Fields, JObj, Args, Separator) -> FormattedFields = lists:foldl(fun(F, Acc) -> format_url_field(JObj, Args, F, Acc) @@ -88,7 +88,7 @@ do_format_url(Fields, JObj, Args, Separator) -> Reversed = lists:reverse(FormattedFields), kz_binary:join(Reversed, Separator). --spec format_url_field(kz_json:object(), kz_proplist(), format_field(), ne_binaries()) -> ne_binaries(). +-spec format_url_field(kz_json:object(), kz_term:proplist(), format_field(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). format_url_field(JObj, Args, #{<<"group">> := Arg}, Acc) -> format_url_field(JObj, Args, {'group', Arg}, Acc); format_url_field(JObj, Args, {'group', Arg}, Acc) -> @@ -110,7 +110,7 @@ format_url_field(JObj, _Args, {'field', Field}, Fields) -> format_url_field(_JObj, _Args, Field, Fields) -> [Field | Fields]. --spec default_format_url_fields() -> kz_proplist(). +-spec default_format_url_fields() -> kz_term:proplist(). default_format_url_fields() -> [{'arg', <<"account_id">>} ,{'field', <<"owner_id">>} @@ -118,14 +118,14 @@ default_format_url_fields() -> ,{'arg', <<"attachment">>} ]. --spec combined_path(api_binary(), api_binary()) -> api_binary(). +-spec combined_path(kz_term:api_binary(), kz_term:api_binary()) -> kz_term:api_binary(). combined_path('undefined', 'undefined') -> 'undefined'; combined_path('undefined', Path) -> Path; combined_path(Path, 'undefined') -> Path; combined_path(BasePath, OtherPath) -> filename:join(BasePath, OtherPath). --spec path_from_settings(map()) -> api_ne_binary(). +-spec path_from_settings(map()) -> kz_term:api_ne_binary(). path_from_settings(#{file := Path}) -> Path; path_from_settings(#{path := Path}) -> Path; path_from_settings(Map) -> @@ -133,7 +133,7 @@ path_from_settings(Map) -> OtherPath = maps:get('folder_path', Map, 'undefined'), combined_path(BasePath, OtherPath). --spec headers_as_binaries(kz_proplist()) -> kz_proplist(). +-spec headers_as_binaries(kz_term:proplist()) -> kz_term:proplist(). headers_as_binaries(Headers) -> [{kz_term:to_binary(K), kz_term:to_binary(V)} || {K,V} <- Headers]. @@ -151,11 +151,11 @@ encode_multipart([{Body, Headers} | Parts], Boundary, Encoded) -> Acc = <>, encode_multipart(Parts, Boundary, Acc). --spec encode_multipart_headers(kz_proplist()) -> binary(). +-spec encode_multipart_headers(kz_term:proplist()) -> binary(). encode_multipart_headers(Headers) -> encode_multipart_headers(Headers, <<>>). --spec encode_multipart_headers(kz_proplist(), binary()) -> binary(). +-spec encode_multipart_headers(kz_term:proplist(), binary()) -> binary(). encode_multipart_headers([], Encoded) -> <>; encode_multipart_headers([{K, V} | Headers], Encoded) -> Acc = <>, diff --git a/core/kazoo_auth/src/kazoo_auth.hrl b/core/kazoo_auth/src/kazoo_auth.hrl index f660deeffbb..f5586e2c931 100644 --- a/core/kazoo_auth/src/kazoo_auth.hrl +++ b/core/kazoo_auth/src/kazoo_auth.hrl @@ -58,7 +58,7 @@ -type mfa_errors() :: 'no_provider' | 'unauthorized' | - ne_binary(). + kz_term:ne_binary(). -type mfa_result() :: {'ok', 'authenticated'} | {'error', mfa_errors()} | diff --git a/core/kazoo_auth/src/kazoo_auth_app.erl b/core/kazoo_auth/src/kazoo_auth_app.erl index fcead7a0baf..80d2aabdea0 100644 --- a/core/kazoo_auth/src/kazoo_auth_app.erl +++ b/core/kazoo_auth/src/kazoo_auth_app.erl @@ -17,7 +17,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = kazoo_auth_maintenance:refresh(), _ = kazoo_auth_maintenance:register_common_providers(), diff --git a/core/kazoo_auth/src/kazoo_auth_maintenance.erl b/core/kazoo_auth/src/kazoo_auth_maintenance.erl index 0f860d89356..11f44db04aa 100644 --- a/core/kazoo_auth/src/kazoo_auth_maintenance.erl +++ b/core/kazoo_auth/src/kazoo_auth_maintenance.erl @@ -19,7 +19,7 @@ %% Internal functions %% ==================================================================== --spec register_auth_app(ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> any(). +-spec register_auth_app(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> any(). register_auth_app(AccountId, OAuthId, Secret, Provider) -> Doc = kz_json:from_list([{<<"_id">>, OAuthId} ,{<<"pvt_account_id">>, AccountId} @@ -33,7 +33,7 @@ register_auth_app(AccountId, OAuthId, Secret, Provider) -> {'error', _} -> kz_datamgr:save_doc(?KZ_AUTH_DB, Doc) end. --spec register_auth_app_key(ne_binary(), ne_binary()) -> any(). +-spec register_auth_app_key(kz_term:ne_binary(), kz_term:ne_binary()) -> any(). register_auth_app_key(AppId, PemFile) -> Pem = kz_auth_keys:get_private_key_from_file(PemFile), KeyId = kz_binary:rand_hex(16), diff --git a/core/kazoo_auth/src/kazoo_auth_sup.erl b/core/kazoo_auth/src/kazoo_auth_sup.erl index 171e259ddee..935dd439316 100644 --- a/core/kazoo_auth/src/kazoo_auth_sup.erl +++ b/core/kazoo_auth/src/kazoo_auth_sup.erl @@ -39,7 +39,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -56,7 +56,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, diff --git a/core/kazoo_auth/src/kz_auth.erl b/core/kazoo_auth/src/kz_auth.erl index d8f62ce4e41..35960052c14 100644 --- a/core/kazoo_auth/src/kz_auth.erl +++ b/core/kazoo_auth/src/kz_auth.erl @@ -21,18 +21,18 @@ -include("kazoo_auth.hrl"). --spec create_token(kz_proplist()) -> {'ok', ne_binary()} | - {'error', 'algorithm_not_supported'}. +-spec create_token(kz_term:proplist()) -> {'ok', kz_term:ne_binary()} | + {'error', 'algorithm_not_supported'}. create_token(Claims) -> kz_auth_jwt:encode(include_claims(Claims)). --spec validate_token(ne_binary() | map()) -> +-spec validate_token(kz_term:ne_binary() | map()) -> {'ok', kz_json:object()} | {'error', any()}. validate_token(Token) -> validate_token(Token, []). --spec validate_token(ne_binary() | map(), kz_proplist()) -> +-spec validate_token(kz_term:ne_binary() | map(), kz_term:proplist()) -> {'ok', kz_json:object()} | {'error', any()}. validate_token(JWToken, Options) -> @@ -51,8 +51,8 @@ access_code(JObj) -> RedirectURI = kz_json:get_first_defined(?REDIRECT_URI_KEYS, JObj, <<"postmessage">>), kz_auth_util:fetch_access_code(AppId, Code, RedirectURI). --spec authenticate(map() | ne_binary() | kz_json:object()) -> - {'ok', kz_proplist()} | +-spec authenticate(map() | kz_term:ne_binary() | kz_json:object()) -> + {'ok', kz_term:proplist()} | {'error', any()}. authenticate(JWTToken) when is_binary(JWTToken) -> @@ -80,7 +80,7 @@ authenticate(JObj) -> Token = kz_maps:keys_to_atoms(kz_json:to_map(JObj)), authenticate(Token#{original => JObj}). --spec authorize_token(map() | ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. +-spec authorize_token(map() | kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. authorize_token(JWToken) -> case kz_auth_jwt:token(JWToken) of #{verify_result := 'true'} = Token -> ensure_claims(Token); @@ -92,11 +92,11 @@ authorize_token(JWToken) -> %% Internal functions %% ==================================================================== --spec verify_claims(map()) -> {'ok', kz_proplist()} | {'error', any()}. +-spec verify_claims(map()) -> {'ok', kz_term:proplist()} | {'error', any()}. verify_claims(#{claims := Claims}) -> {'ok', Claims}. --spec validate_claims(map(), kz_proplist()) -> {'ok', kz_json:object()} | {'error', any()}. +-spec validate_claims(map(), kz_term:proplist()) -> {'ok', kz_json:object()} | {'error', any()}. validate_claims(#{payload := #{<<"account_id">> := AccountId} = Payload}, Options) -> case props:get_value(<<"account_id">>, Options, AccountId) of AccountId -> @@ -159,14 +159,14 @@ ensure_claims(#{payload := Payload}) -> Claims = kz_json:from_map(Payload), {'ok', Claims}. --spec include_claims(kz_proplist()) -> kz_proplist(). +-spec include_claims(kz_term:proplist()) -> kz_term:proplist(). include_claims(Claims) -> Routines = [fun include_identity_sign/1 ,fun ensure_issuer/1 ], lists:foldl(fun(Fun, Acc) -> Fun(Acc) end, Claims, Routines). --spec include_identity_sign(kz_proplist()) -> kz_proplist(). +-spec include_identity_sign(kz_term:proplist()) -> kz_term:proplist(). include_identity_sign(Claims) -> case kz_auth_identity:sign(Claims) of {'ok', Signature} -> [{<<"identity_sig">>, kz_base64url:encode(Signature)} | Claims]; @@ -175,7 +175,7 @@ include_identity_sign(Claims) -> Claims end. --spec ensure_issuer(kz_proplist()) -> kz_proplist(). +-spec ensure_issuer(kz_term:proplist()) -> kz_term:proplist(). ensure_issuer(Claims) -> Issuer = props:get_value(<<"iss">>, Claims, <<"kazoo">>), props:set_value(<<"iss">>, Issuer, Claims). @@ -193,7 +193,7 @@ authenticate_fold(Token, [Fun | Routines]) -> authenticate_fold(Token, Routines) end. --spec link(ne_binary(), ne_binary(), ne_binary()) -> 'ok' | {'error', any()}. +-spec link(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | {'error', any()}. link(AccountId, OwnerId, AuthId) -> Props = [{<<"pvt_account_id">>, AccountId} ,{<<"pvt_owner_id">>, OwnerId} @@ -203,7 +203,7 @@ link(AccountId, OwnerId, AuthId) -> Error -> Error end. --spec unlink(ne_binary()) -> 'ok' | {'error', any()}. +-spec unlink(kz_term:ne_binary()) -> 'ok' | {'error', any()}. unlink(AuthId) -> Props = [{<<"pvt_account_id">>, null} ,{<<"pvt_owner_id">>, null} diff --git a/core/kazoo_auth/src/kz_auth_apps.erl b/core/kazoo_auth/src/kz_auth_apps.erl index aec2ad74185..ede1b6a1608 100644 --- a/core/kazoo_auth/src/kz_auth_apps.erl +++ b/core/kazoo_auth/src/kz_auth_apps.erl @@ -16,11 +16,11 @@ ]). --spec get_auth_app(ne_binary()) -> map() | {'error', ne_binary()}. +-spec get_auth_app(kz_term:ne_binary()) -> map() | {'error', kz_term:ne_binary()}. get_auth_app(AppId) -> get_auth_app(AppId, 'none'). --spec get_auth_app(ne_binary(), atom()) -> map() | {'error', ne_binary()}. +-spec get_auth_app(kz_term:ne_binary(), atom()) -> map() | {'error', kz_term:ne_binary()}. get_auth_app(AppId, Option) -> case do_get_auth_app(AppId) of {'error', _} = Error -> Error; @@ -38,7 +38,7 @@ get_auth_app(AppId, Option) -> #{}=App -> App end. --spec do_get_auth_app(ne_binary()) -> map() | {'error', ne_binary()}. +-spec do_get_auth_app(kz_term:ne_binary()) -> map() | {'error', kz_term:ne_binary()}. do_get_auth_app(<<"kazoo">>) -> #{name => <<"kazoo">> ,pvt_server_key => ?SYSTEM_KEY_ID diff --git a/core/kazoo_auth/src/kz_auth_client.erl b/core/kazoo_auth/src/kz_auth_client.erl index f4a420ea568..e0c2613bd94 100644 --- a/core/kazoo_auth/src/kz_auth_client.erl +++ b/core/kazoo_auth/src/kz_auth_client.erl @@ -19,11 +19,11 @@ ]). --spec token_for_auth_id(ne_binary()) -> {ok | error, map()}. +-spec token_for_auth_id(kz_term:ne_binary()) -> {ok | error, map()}. token_for_auth_id(AuthId) -> token_for_auth_id(AuthId, #{}). --spec token_for_auth_id(ne_binary(), map()) -> {ok | error, map()}. +-spec token_for_auth_id(kz_term:ne_binary(), map()) -> {ok | error, map()}. token_for_auth_id(AuthId, Options) -> Map = #{options => Options#{auth_id => AuthId}}, Routines = [fun add_subject/1 @@ -40,11 +40,11 @@ token_for_auth_id(AuthId, Options) -> kz_auth_util:run(Map, Routines). --spec token_for_app(ne_binary()) -> {ok | error, map()}. +-spec token_for_app(kz_term:ne_binary()) -> {ok | error, map()}. token_for_app(AppId) -> token_for_app(AppId, #{}). --spec token_for_app(ne_binary(), map()) -> {ok | error, map()}. +-spec token_for_app(kz_term:ne_binary(), map()) -> {ok | error, map()}. token_for_app(AppId, Options) -> Map = #{app_id => AppId ,options => Options diff --git a/core/kazoo_auth/src/kz_auth_identity.erl b/core/kazoo_auth/src/kz_auth_identity.erl index 7981cfd66ed..d5e64380881 100644 --- a/core/kazoo_auth/src/kz_auth_identity.erl +++ b/core/kazoo_auth/src/kz_auth_identity.erl @@ -31,7 +31,7 @@ %% (Kazoo is the only provider for signing) %% @end %%-------------------------------------------------------------------- --spec sign(map() | kz_proplist() | kz_json:object()) -> {'ok', ne_binary()} | {'error', any()}. +-spec sign(map() | kz_term:proplist() | kz_json:object()) -> {'ok', kz_term:ne_binary()} | {'error', any()}. sign(Claims) when is_map(Claims) -> #{jwt_identity_signature_secret := ServerSecret @@ -234,7 +234,7 @@ update_kazoo_secret(#{auth_db := Db lager:debug("generating new kazoo signing secret for ~s/~s", [Db, Key]), update_kazoo_secret(Token, generate_new_kazoo_signing_secret()). --spec update_kazoo_secret(map(), ne_binary()) -> map() | {'error', any()}. +-spec update_kazoo_secret(map(), kz_term:ne_binary()) -> map() | {'error', any()}. update_kazoo_secret(#{auth_db := Db ,auth_db_id := Key }=Token, Secret) -> @@ -291,7 +291,7 @@ token(#{payload := Payload end; token(#{}=Token) -> Token#{identify_verified => 'true'}. --spec verify_identity_signature(map(), ne_binary(), ne_binary(), ne_binary()) -> map(). +-spec verify_identity_signature(map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> map(). verify_identity_signature(#{identity_secret := IdentitySecret, auth_id := Identity}=Token, Secret, Hash, IdentitySig) -> lager:debug("verifying key for identity '~s'", [Identity]), IdentitySignature = kz_base64url:decode(IdentitySig), @@ -300,7 +300,7 @@ verify_identity_signature(#{identity_secret := IdentitySecret, auth_id := Identi ExpectedSignature = crypto:hmac(HashMethod, CryptoKey, Identity), verify_identity_signature(Token, IdentitySignature, ExpectedSignature). --spec verify_identity_signature(map(), ne_binary(), ne_binary()) -> map(). +-spec verify_identity_signature(map(), kz_term:ne_binary(), kz_term:ne_binary()) -> map(). verify_identity_signature(Token, ExpectedSignature, ExpectedSignature) -> Token#{identify_verified => 'true'}; verify_identity_signature(Token, _IdentitySignature, _ExpectedSignature) -> @@ -335,7 +335,7 @@ reset_system_secret() -> %% Reset account/user identity secret %% @end %%-------------------------------------------------------------------- --spec reset_secret(map() | kz_proplist() | kz_json:object()) -> 'ok' | {'error', any()}. +-spec reset_secret(map() | kz_term:proplist() | kz_json:object()) -> 'ok' | {'error', any()}. reset_secret(#{<<"account_id">> := Account ,<<"owner_id">> := OwnerId }) -> @@ -402,6 +402,6 @@ reset_identity_secret(#{auth_db := Db %% Generate a new Kazoo signing secret %% @end %%-------------------------------------------------------------------- --spec generate_new_kazoo_signing_secret() -> ne_binary(). +-spec generate_new_kazoo_signing_secret() -> kz_term:ne_binary(). generate_new_kazoo_signing_secret() -> kz_binary:rand_hex(16). diff --git a/core/kazoo_auth/src/kz_auth_init.erl b/core/kazoo_auth/src/kz_auth_init.erl index b8586a7db99..4cc37433345 100644 --- a/core/kazoo_auth/src/kz_auth_init.erl +++ b/core/kazoo_auth/src/kz_auth_init.erl @@ -15,7 +15,7 @@ %% @public %% @doc Starts the app for inclusion in a supervisor tree %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> _ = init(), 'ignore'. diff --git a/core/kazoo_auth/src/kz_auth_jwt.erl b/core/kazoo_auth/src/kz_auth_jwt.erl index 05c27c70711..87699098b17 100644 --- a/core/kazoo_auth/src/kz_auth_jwt.erl +++ b/core/kazoo_auth/src/kz_auth_jwt.erl @@ -29,11 +29,11 @@ -define(DEFAULT_ALGORITHM, ?ALG_RS256). --spec decode(ne_binary()) -> {'ok', kz_proplist(), kz_proplist()} | {'error', any()}. +-spec decode(kz_term:ne_binary()) -> {'ok', kz_term:proplist(), kz_term:proplist()} | {'error', any()}. decode(JWTToken) -> decode(JWTToken, 'true'). --spec decode(ne_binary() | map(), boolean()) -> {'ok', kz_proplist(), kz_proplist()} | {'error', any()}. +-spec decode(kz_term:ne_binary() | map(), boolean()) -> {'ok', kz_term:proplist(), kz_term:proplist()} | {'error', any()}. decode(JWTToken, Verify) when is_binary(JWTToken) -> case parse(JWTToken) of {'ok', Token} -> decode(Token, Verify); @@ -47,7 +47,7 @@ decode(#{header := Header, payload := Payload} = Token, 'true') -> decode(#{header := Header, payload := Payload}, 'false') -> {'ok', maps:to_list(Header), maps:to_list(Payload)}. --spec verify(ne_binary() | map()) -> boolean(). +-spec verify(kz_term:ne_binary() | map()) -> boolean(). verify(JWTToken) when is_binary(JWTToken) -> case parse(JWTToken) of {'ok', Token} -> verify(Token); @@ -150,8 +150,8 @@ alg_2_digest_type(_) -> 'undefined'. -spec epoch() -> integer(). epoch() -> erlang:system_time('seconds'). --spec encode(kz_proplist() | map()) -> - {'ok', ne_binary()} | +-spec encode(kz_term:proplist() | map()) -> + {'ok', kz_term:ne_binary()} | {'error', any()}. encode(Claims) when is_list(Claims) -> case props:get_value(<<"iss">>, Claims) of @@ -270,7 +270,7 @@ set_provider(#{payload := #{<<"iss">> := Issuer}}=Token) -> Token#{auth_provider => kz_auth_providers:provider_by_issuer(Issuer)}. --spec parse(ne_binary()) -> {'ok', jwt()} | {'error', 'invalid_jwt'}. +-spec parse(kz_term:ne_binary()) -> {'ok', jwt()} | {'error', 'invalid_jwt'}. parse(JWTToken) when is_binary(JWTToken) -> case binary:split(JWTToken, <<".">>, ['global']) of [Header, Payload, Signature] -> @@ -288,11 +288,11 @@ parse(JWTToken) when is_binary(JWTToken) -> {'error', 'invalid_jwt'} end. --spec token(ne_binary() | map()) -> map(). +-spec token(kz_term:ne_binary() | map()) -> map(). token(JWTToken) -> token(JWTToken, []). --spec token(ne_binary() | map(), kz_proplist()) -> map(). +-spec token(kz_term:ne_binary() | map(), kz_term:proplist()) -> map(). token(JWTToken, Options) when is_binary(JWTToken) -> case parse(JWTToken) of {'ok', Token} -> token(Token, Options); diff --git a/core/kazoo_auth/src/kz_auth_keys.erl b/core/kazoo_auth/src/kz_auth_keys.erl index 4e1bb07985d..aa2ab7d0bfd 100644 --- a/core/kazoo_auth/src/kz_auth_keys.erl +++ b/core/kazoo_auth/src/kz_auth_keys.erl @@ -130,7 +130,7 @@ maybe_get_key(#{auth_provider := #{name := <<"kazoo">>} Token#{key_id => KeyId}; maybe_get_key(#{}=Token) -> Token. --spec key_id(ne_binary(), ne_binary(), map()) -> api_binary(). +-spec key_id(kz_term:ne_binary(), kz_term:ne_binary(), map()) -> kz_term:api_binary(). key_id(<<"payload">>, Field, #{payload := Payload}) -> maps:get(Field, Payload, 'undefined'); key_id(<<"header">>, Field, Token) -> @@ -233,19 +233,19 @@ extract_key(#{}=Token) -> lager:debug("public key not obtained : ~p", [Token]), Token. --spec public_key(ne_binary()) -> public_key:rsa_public_key(). +-spec public_key(kz_term:ne_binary()) -> public_key:rsa_public_key(). public_key(KeyId) -> {'ok', Key} = private_key(KeyId), get_public_key_from_private_key(Key). --spec private_key(ne_binary()) -> {'ok', public_key:rsa_private_key()} | {'error', any()}. +-spec private_key(kz_term:ne_binary()) -> {'ok', public_key:rsa_private_key()} | {'error', any()}. private_key(KeyId) -> case lookup({'private', KeyId}) of {'error', 'not_found'} -> load_private_key(KeyId); Found -> Found end. --spec load_private_key(ne_binary()) -> {'ok', public_key:rsa_private_key()} | {'error', any()}. +-spec load_private_key(kz_term:ne_binary()) -> {'ok', public_key:rsa_private_key()} | {'error', any()}. load_private_key(KeyId) -> case kz_datamgr:open_cache_doc(?KZ_AUTH_DB, KeyId) of {'ok', JObj} -> load_private_key_attachment(JObj); @@ -265,12 +265,12 @@ load_private_key_attachment(JObj) -> save_private_key(JObj, Key) end. --spec new_private_key(ne_binary()) -> {'ok', public_key:rsa_private_key()} | {'error', any()}. +-spec new_private_key(kz_term:ne_binary()) -> {'ok', public_key:rsa_private_key()} | {'error', any()}. new_private_key(KeyId) -> {'ok', Key} = gen_private_key(), new_private_key(KeyId, Key). --spec new_private_key(ne_binary(), public_key:rsa_private_key()) -> {'ok', public_key:rsa_private_key()} | {'error', any()}. +-spec new_private_key(kz_term:ne_binary(), public_key:rsa_private_key()) -> {'ok', public_key:rsa_private_key()} | {'error', any()}. new_private_key(KeyId, Key) -> Doc = [{<<"pvt_type">>, <<"system_key">>} ,{<<"_id">>, KeyId} @@ -328,12 +328,12 @@ erlint(<>) -> Int. %% * generate a new private key and put it in cache %% @end %%-------------------------------------------------------------------- --spec reset_kazoo_private_key() -> {'ok', ne_binary()} | {'error', any()}. +-spec reset_kazoo_private_key() -> {'ok', kz_term:ne_binary()} | {'error', any()}. reset_kazoo_private_key() -> lager:warning("trying to reset kazoo private key"), reset_private_key(kz_auth_apps:get_auth_app(<<"kazoo">>)). --spec reset_private_key(map() | ne_binary()) -> {'ok', ne_binary()} | {'error', any()}. +-spec reset_private_key(map() | kz_term:ne_binary()) -> {'ok', kz_term:ne_binary()} | {'error', any()}. reset_private_key(#{pvt_server_key := KeyId}) -> reset_private_key(KeyId); reset_private_key(#{}) -> diff --git a/core/kazoo_auth/src/kz_auth_profile.erl b/core/kazoo_auth/src/kz_auth_profile.erl index 7d1a5a049ad..9092d3db88f 100644 --- a/core/kazoo_auth/src/kz_auth_profile.erl +++ b/core/kazoo_auth/src/kz_auth_profile.erl @@ -117,7 +117,7 @@ maybe_load_profile(#{auth_provider := #{profile_url := _ProfileURL} maybe_load_profile(Token#{access_token => Original}); maybe_load_profile(#{} = Token) -> Token#{profile => kz_json:new()}. --spec profile_authorization(map(), ne_binary()) -> binary(). +-spec profile_authorization(map(), kz_term:ne_binary()) -> binary(). profile_authorization(#{auth_provider := Provider} = Token, AccessToken) -> case maps:get(profile_access_auth_type, Provider, <<"token">>) of <<"token">> -> @@ -131,7 +131,7 @@ profile_authorization(#{auth_provider := Provider} = Token, AccessToken) -> <<"url">> -> <<>> end. --spec profile_authorization_headers(map(), ne_binary()) -> kz_proplist(). +-spec profile_authorization_headers(map(), kz_term:ne_binary()) -> kz_term:proplist(). profile_authorization_headers(Provider, AccessToken) -> case profile_authorization(Provider, AccessToken) of <<>> -> []; @@ -152,14 +152,14 @@ profile_url(#{auth_provider := #{profile_url := ProfileURL} = Provider -define(PROFILE_URL_REGEX_OPTIONS, [{'capture', 'all_but_first', 'binary'}, 'global']). -define(PROFILE_URL_REPLACE_OPTIONS, ['global', {'return', 'binary'}]). --spec maybe_compose_profile_url(ne_binary(), map()) -> binary(). +-spec maybe_compose_profile_url(kz_term:ne_binary(), map()) -> binary(). maybe_compose_profile_url(Url, Token) -> case re:run(Url, ?PROFILE_URL_REGEX, ?PROFILE_URL_REGEX_OPTIONS) of {match, [_ | _] = Fields} -> compose_profile_url(Url, lists:flatten(Fields), Token); _ -> Url end. --spec compose_profile_url(ne_binary(), ne_binaries(), map()) -> binary(). +-spec compose_profile_url(kz_term:ne_binary(), kz_term:ne_binaries(), map()) -> binary(). compose_profile_url(Url, Fields, Token) -> Payload = maps:get(payload, Token, #{}), lists:foldl(fun(Field, Acc) -> @@ -297,7 +297,7 @@ maybe_add_user(#{} = Token) -> lager:debug("identity not set, skip adding user"), Token. --spec ensure_profile_properties(ne_binary(), kz_proplist(), kz_proplist(), map()) -> map(). +-spec ensure_profile_properties(kz_term:ne_binary(), kz_term:proplist(), kz_term:proplist(), map()) -> map(). ensure_profile_properties(DocId, Missing, Props, #{} = Token) -> case kz_datamgr:open_cache_doc(?KZ_AUTH_DB, DocId) of {'ok', Doc} -> @@ -312,7 +312,7 @@ ensure_profile_properties(DocId, Missing, Props, #{} = Token) -> Token#{profile_error_code => {403, 'invalid_profile'}, profile => kz_json:new()} end. --spec update_user(ne_binary(), kz_proplist(), map()) -> map(). +-spec update_user(kz_term:ne_binary(), kz_term:proplist(), map()) -> map(). update_user(DocId, Props, #{auth_provider := #{profile_required_props := RequiredProps}} = Token) -> case RequiredProps -- props:get_keys(Props) of [] -> do_update_user(DocId, Props, Token); @@ -321,7 +321,7 @@ update_user(DocId, Props, #{auth_provider := #{profile_required_props := Require update_user(DocId, Props, Token) -> do_update_user(DocId, Props, Token). --spec do_update_user(ne_binary(), kz_proplist(), map()) -> map(). +-spec do_update_user(kz_term:ne_binary(), kz_term:proplist(), map()) -> map(). do_update_user(DocId, Props, Token) -> case kz_datamgr:update_doc(?KZ_AUTH_DB, DocId, Props) of {'ok', DocObj} -> maybe_cache_user(Token#{user_doc => DocObj @@ -334,7 +334,7 @@ do_update_user(DocId, Props, Token) -> Token#{profile_error_code => {500, 'datastore_fault'}, profile => kz_json:new()} end. --spec maybe_cache_user(map(), ne_binary()) -> map(). +-spec maybe_cache_user(map(), kz_term:ne_binary()) -> map(). maybe_cache_user(#{auth_provider := #{profile_cache_timer := Timer} ,user_identity := Identity } = Token @@ -346,7 +346,7 @@ maybe_cache_user(#{auth_provider := #{profile_cache_timer := Timer} Token; maybe_cache_user(Token, _DocId) -> Token. --spec maybe_update_user(ne_binary(), kz_json:object(), map()) -> map(). +-spec maybe_update_user(kz_term:ne_binary(), kz_json:object(), map()) -> map(). maybe_update_user(DocId, JObj, Token) -> Props = format_user_doc(Token), case updates_needed(JObj, Props) of @@ -354,7 +354,7 @@ maybe_update_user(DocId, JObj, Token) -> Updates -> update_user(DocId, Updates, Token) end. --spec maybe_required_properties_missing(map(), kz_proplist(), kz_json:object()) -> map(). +-spec maybe_required_properties_missing(map(), kz_term:proplist(), kz_json:object()) -> map(). maybe_required_properties_missing(#{auth_provider := #{profile_required_props := RequiredProps} } = Token, Props, JObj) -> case RequiredProps -- props:get_keys(Props) of @@ -370,7 +370,7 @@ maybe_required_properties_missing(Token, _Props, JObj) -> ,user_map => kz_json:to_map(JObj) }. --spec updates_needed(kz_json:object(), kz_proplist()) -> kz_proplist(). +-spec updates_needed(kz_json:object(), kz_term:proplist()) -> kz_term:proplist(). updates_needed(JObj, Props) -> lists:foldl(fun(K, KVs) -> case {props:get_value(K, Props) @@ -386,7 +386,7 @@ updates_needed(JObj, Props) -> ,?UPDATE_CHK_FIELDS ). --spec format_user_doc(map()) -> kz_proplist(). +-spec format_user_doc(map()) -> kz_term:proplist(). format_user_doc(#{auth_provider := #{name := ProviderId} = Provider ,profile := Profile ,user_identity := Identity diff --git a/core/kazoo_auth/src/kz_auth_providers.erl b/core/kazoo_auth/src/kz_auth_providers.erl index aa9ddba090c..c1757d32aa7 100644 --- a/core/kazoo_auth/src/kz_auth_providers.erl +++ b/core/kazoo_auth/src/kz_auth_providers.erl @@ -27,7 +27,7 @@ kazoo_auth_provider() -> ,jwt_user_id_signature_hash => <<"sha256">> }. --spec provider_by_issuer(ne_binary()) -> map() | {'error', any()}. +-spec provider_by_issuer(kz_term:ne_binary()) -> map() | {'error', any()}. provider_by_issuer(<<"kazoo">>) -> kazoo_auth_provider(); provider_by_issuer(Issuer) -> @@ -43,7 +43,7 @@ provider_by_issuer(Issuer) -> %% Internal functions %% ==================================================================== --spec get_auth_provider(ne_binary()) -> map() | {'error', any()}. +-spec get_auth_provider(kz_term:ne_binary()) -> map() | {'error', any()}. get_auth_provider(<<"kazoo">>) -> kazoo_auth_provider(); get_auth_provider(ProviderId) -> diff --git a/core/kazoo_auth/src/kz_auth_rsa.erl b/core/kazoo_auth/src/kz_auth_rsa.erl index d28f75c23ba..3e6a4c56cce 100644 --- a/core/kazoo_auth/src/kz_auth_rsa.erl +++ b/core/kazoo_auth/src/kz_auth_rsa.erl @@ -23,7 +23,7 @@ -type state() :: #state{}. -type gen_rsa() :: {gen_rsa, integer(), integer()}. --type job() :: {integer(), pid_ref(), gen_rsa()}. +-type job() :: {integer(), kz_term:pid_ref(), gen_rsa()}. -include("kazoo_auth.hrl"). @@ -45,7 +45,7 @@ max_jobs(Limit) when is_integer(Limit) andalso Limit > 0 -> gen_server:call(?SERVER, {set_limit, Limit}, infinity). --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> Limit = case application:get_env(kazoo_auth, max_jobs) of undefined -> ?DEFAULT_MAXJOBS; @@ -64,7 +64,7 @@ init(Limit) when is_integer(Limit) Port = kz_auth_rsa_drv:open(), {ok, #state{port = Port}}. --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(stop, _From, #state{} = State) -> {stop, normal, ok, State}; handle_call({gen_rsa, _Bits, _E} = Req, From, #state{} = State) -> @@ -81,11 +81,11 @@ handle_call({set_limit, Limit}, _From, #state{} = State) handle_call(_Request, _From, State) -> {noreply, State}. --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> {noreply, State}. --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({Port, Ref, Data}, #state{port = Port, requests = Reqs} = State) -> case lists:keytake(Ref, 1, Reqs) of {value, {Ref, From}, NewRequests} -> diff --git a/core/kazoo_auth/src/kz_auth_token_util.erl b/core/kazoo_auth/src/kz_auth_token_util.erl index dce13274bac..a68ba9e6375 100644 --- a/core/kazoo_auth/src/kz_auth_token_util.erl +++ b/core/kazoo_auth/src/kz_auth_token_util.erl @@ -105,11 +105,11 @@ create_claims(#{}=Token) -> Token. -type claim_map_input() :: map() | kz_json:objects(). --spec build_claims(kz_proplist(), claim_map_input()) -> kz_proplist(). +-spec build_claims(kz_term:proplist(), claim_map_input()) -> kz_term:proplist(). build_claims(ClaimsMap, BuildFrom) -> build_claims(ClaimsMap, BuildFrom, []). --spec build_claims(kz_proplist(), claim_map_input(), kz_proplist()) -> kz_proplist(). +-spec build_claims(kz_term:proplist(), claim_map_input(), kz_term:proplist()) -> kz_term:proplist(). build_claims([], _, Claims) -> Claims; build_claims([{K1, K2} | KVs], Map, Claims) when is_map(Map) -> diff --git a/core/kazoo_auth/src/kz_auth_util.erl b/core/kazoo_auth/src/kz_auth_util.erl index 11c3b0bad8b..e76e9e62ed1 100644 --- a/core/kazoo_auth/src/kz_auth_util.erl +++ b/core/kazoo_auth/src/kz_auth_util.erl @@ -16,11 +16,11 @@ -export([fetch_access_code/2, fetch_access_code/3]). -export([run/2]). --spec get_json_from_url(ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. +-spec get_json_from_url(kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. get_json_from_url(Url) -> get_json_from_url(Url, []). --spec get_json_from_url(ne_binary(), kz_proplist()) -> {'ok', kz_json:object()} | {'error', any()}. +-spec get_json_from_url(kz_term:ne_binary(), kz_term:proplist()) -> {'ok', kz_json:object()} | {'error', any()}. get_json_from_url(Url, ReqHeaders) -> case kz_http:get(kz_term:to_list(Url), ReqHeaders, [{ssl, [{versions, ['tlsv1.2']}]}]) of {'ok', 200, _RespHeaders, Body} -> @@ -37,14 +37,14 @@ get_json_from_url(Url, ReqHeaders) -> {'error', Else} end. --spec fetch_access_code(ne_binary() | map(), ne_binary() ) -> +-spec fetch_access_code(kz_term:ne_binary() | map(), kz_term:ne_binary() ) -> {'ok', kz_json:object()} | {'error', any()}. fetch_access_code(AppId, AuthorizationCode) -> fetch_access_code(AppId, AuthorizationCode, <<"postmessage">>). --spec fetch_access_code(ne_binary() | map(), ne_binary(), ne_binary()) -> +-spec fetch_access_code(kz_term:ne_binary() | map(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. fetch_access_code(AppId, AuthorizationCode, RedirectUri) diff --git a/core/kazoo_auth/src/kz_mfa_auth.erl b/core/kazoo_auth/src/kz_mfa_auth.erl index f7cb570542b..3c3965e5097 100644 --- a/core/kazoo_auth/src/kz_mfa_auth.erl +++ b/core/kazoo_auth/src/kz_mfa_auth.erl @@ -24,7 +24,7 @@ %% @doc Read configuration and do authentication with configured MFA provider %% @end %%-------------------------------------------------------------------- --spec authenticate(kz_proplist()) -> result(). +-spec authenticate(kz_term:proplist()) -> result(). authenticate(Claims) -> Configs = get_configs(props:get_value(<<"mfa_options">>, Claims)), case provider(Configs) of @@ -46,7 +46,7 @@ authenticate(Claims) -> %% @doc Get MFA provider and checks it's enabled or not %% @end %%-------------------------------------------------------------------- --spec provider(api_object()) -> ne_binary() | {'disabled', ne_binary()} | {'error', 'no_provider'}. +-spec provider(kz_term:api_object()) -> kz_term:ne_binary() | {'disabled', kz_term:ne_binary()} | {'error', 'no_provider'}. provider(Configs) -> Name = kz_json:get_ne_value(<<"provider_name">>, Configs), IsDefined = kz_term:is_not_empty(Name), @@ -62,7 +62,7 @@ provider(Configs) -> %% get system default configuration %% @end %%-------------------------------------------------------------------- --spec get_configs('undefined' | kz_proplist() | kz_json:object()) -> api_object(). +-spec get_configs('undefined' | kz_term:proplist() | kz_json:object()) -> kz_term:api_object(). get_configs('undefined') -> get_system_configs(); get_configs(Options) when is_list(Options) -> @@ -72,7 +72,7 @@ get_configs(Options) when is_list(Options) -> get_configs(JObj) -> get_configs(kz_json:recursive_to_proplist(JObj)). --spec get_account_configs(api_binary(), api_binary()) -> api_object(). +-spec get_account_configs(kz_term:api_binary(), kz_term:api_binary()) -> kz_term:api_object(). get_account_configs('undefined', _ConfigId) -> get_system_configs(); get_account_configs(_AccountId, 'undefined') -> get_system_configs(); get_account_configs(AccountId, ConfigId) -> @@ -90,7 +90,7 @@ get_account_configs(AccountId, ConfigId) -> 'undefined' end. --spec get_system_configs() -> api_object(). +-spec get_system_configs() -> kz_term:api_object(). get_system_configs() -> lager:debug("get authentication factor configuration from system config"), DefaultProvider = default_provider(), @@ -101,9 +101,9 @@ get_system_configs() -> 'undefined' end. --spec module_name(ne_binary()) -> atom(). +-spec module_name(kz_term:ne_binary()) -> atom(). module_name(Provider) -> kz_term:to_atom(<<"kz_mfa_", Provider/binary>>, 'true'). --spec default_provider() -> ne_binary(). +-spec default_provider() -> kz_term:ne_binary(). default_provider() -> kapps_config:get_binary(?CONFIG_CAT, <<"default_multi_factor_provider">>, <<"duo">>). diff --git a/core/kazoo_auth/src/mfa_provider/kz_mfa_duo.erl b/core/kazoo_auth/src/mfa_provider/kz_mfa_duo.erl index 7e0724d4313..dae32804e5c 100644 --- a/core/kazoo_auth/src/mfa_provider/kz_mfa_duo.erl +++ b/core/kazoo_auth/src/mfa_provider/kz_mfa_duo.erl @@ -44,7 +44,7 @@ %% @doc %% @end %%-------------------------------------------------------------------- --spec authenticate(kz_proplist(), kz_json:object()) -> mfa_result(). +-spec authenticate(kz_term:proplist(), kz_json:object()) -> mfa_result(). authenticate(Claims, JObj) -> Identity = map_config(Claims, JObj), case is_map(Identity) @@ -87,7 +87,7 @@ sign_request(#{<<"user_name">> := UserId ], {'error', 401, kz_json:from_list(Resp)}. --spec sign_value(ne_binary(), ne_binary(), ne_binary(), integer()) -> ne_binary(). +-spec sign_value(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), integer()) -> kz_term:ne_binary(). sign_value(Key, Value, Prefix, Exp) -> Expire = expire(Exp), BinaryValue = <>, @@ -95,7 +95,7 @@ sign_value(Key, Value, Prefix, Exp) -> <>. --spec signature(ne_binary(), ne_binary()) -> ne_binary(). +-spec signature(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). signature(Key, Cookie) -> kz_binary:hexencode(crypto:hmac('sha', Key, Cookie)). @@ -104,7 +104,7 @@ signature(Key, Cookie) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec verify_response(map(), ne_binary()) -> mfa_result(). +-spec verify_response(map(), kz_term:ne_binary()) -> mfa_result(). verify_response(#{<<"integration_key">> := IKey ,<<"secret_key">> := SKey ,<<"application_secret_key">> := AKey @@ -120,7 +120,7 @@ verify_response(#{<<"integration_key">> := IKey {'error', 'unauthorized'} end. --spec verify_user(map(), api_binary(), api_binary()) -> mfa_result(). +-spec verify_user(map(), kz_term:api_binary(), kz_term:api_binary()) -> mfa_result(). verify_user(_Identity, 'undefined', _AppUser) -> {'error', 'unauthorized'}; verify_user(_Identity, _AuthUser, 'undefined') -> @@ -133,7 +133,7 @@ verify_user(#{<<"user_name">> := _UserId}, _AuthUser, _AppUser) -> ), {'error', 'unauthorized'}. --spec parse_value(ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> api_ne_binary(). +-spec parse_value(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_ne_binary(). parse_value(IKey, Key, Value, Prefix) -> MaxExpire = kz_time:current_unix_tstamp(), case binary:split(Value, ?VAL_PART_SEP, ['global']) of @@ -155,7 +155,7 @@ parse_value(IKey, Key, Value, Prefix) -> _Else -> 'undefined' end. --spec do_parse(map()) -> api_ne_binary(). +-spec do_parse(map()) -> kz_term:api_ne_binary(). do_parse(Maps) -> Routines = [fun verify_prefix/1 ,fun verify_signature/1 @@ -166,7 +166,7 @@ do_parse(Maps) -> ], do_parse_fold(Maps, Routines). --spec do_parse_fold(map(), list()) -> api_ne_binary(). +-spec do_parse_fold(map(), list()) -> kz_term:api_ne_binary(). do_parse_fold(#{verify_result := 'false'}, _) -> 'undefined'; do_parse_fold(#{user_name := UserId}, []) -> UserId; do_parse_fold(Maps, [Fun | Funs]) -> @@ -240,9 +240,9 @@ is_user_name(Maps) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec map_config(kz_proplist(), kz_json:object()) -> +-spec map_config(kz_term:proplist(), kz_json:object()) -> map() | - {'error', ne_binary()}. + {'error', kz_term:ne_binary()}. map_config(Claims, JObj) -> Identity = maps:from_list( [{<<"user_name">>, props:get_value(<<"owner_id">>, Claims)} @@ -263,7 +263,7 @@ map_config(Claims, JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec validate_values(map()) -> 'true' | ne_binary(). +-spec validate_values(map()) -> 'true' | kz_term:ne_binary(). validate_values(Identity) -> try lists:all(fun(ReqV) -> validate_value(ReqV, Identity) @@ -278,7 +278,7 @@ validate_values(Identity) -> kz_term:to_binary(io_lib:format("duo ~s config key is invalid", [Key])) end. --spec validate_value(ne_binary(), map()) -> boolean(). +-spec validate_value(kz_term:ne_binary(), map()) -> boolean(). validate_value(<<"user_name">> = K, Identity) -> kz_term:is_ne_binary(maps:get(K, Identity)); validate_value(<<"integration_key">> = K, Identity) -> diff --git a/core/kazoo_bindings/src/kazoo_bindings.erl b/core/kazoo_bindings/src/kazoo_bindings.erl index 5bf0f97a90a..4b01f434848 100644 --- a/core/kazoo_bindings/src/kazoo_bindings.erl +++ b/core/kazoo_bindings/src/kazoo_bindings.erl @@ -78,8 +78,8 @@ -type fold_results() :: payload(). -type map_results() :: list(). --type matches_fun() :: fun((ne_binaries(), ne_binaries()) -> boolean()). --type candidates_fun() :: fun((ne_binary()) -> kz_bindings()). +-type matches_fun() :: fun((kz_term:ne_binaries(), kz_term:ne_binaries()) -> boolean()). +-type candidates_fun() :: fun((kz_term:ne_binary()) -> kz_bindings()). -record(kz_responder, {module :: atom() ,function :: atom() @@ -88,16 +88,16 @@ -type kz_responder() :: #kz_responder{}. -type kz_responders() :: [kz_responder()]. --record(kz_binding, {binding :: ne_binary() | '_' - ,binding_parts :: ne_binaries() | '_' +-record(kz_binding, {binding :: kz_term:ne_binary() | '_' + ,binding_parts :: kz_term:ne_binaries() | '_' ,binding_responders = queue:new() :: queue:queue() | '_' %% queue -> [#kz_responder{}] - ,binding_prefix :: api_binary() | '$1' | '_' + ,binding_prefix :: kz_term:api_binary() | '$1' | '_' }). -type kz_binding() :: #kz_binding{}. -type kz_bindings() :: [kz_binding()]. --type kz_rt_options() :: kz_proplist(). +-type kz_rt_options() :: kz_term:proplist(). -type kz_rt_option() :: 'candidates' | 'matches'. -record(state, {bindings = [] :: kz_bindings() @@ -129,23 +129,23 @@ %% is the payload, possibly modified %% @end %%-------------------------------------------------------------------- --spec map(ne_binary(), payload()) -> map_results(). --spec map(ne_binary(), payload(), kz_rt_options()) -> map_results(). +-spec map(kz_term:ne_binary(), payload()) -> map_results(). +-spec map(kz_term:ne_binary(), payload(), kz_rt_options()) -> map_results(). map(Routing, Payload) -> map_processor(Routing, Payload, rt_options()). map(Routing, Payload, Options) -> map_processor(Routing, Payload, rt_options(Options)). --spec pmap(ne_binary(), payload()) -> map_results(). --spec pmap(ne_binary(), payload(), kz_rt_options()) -> map_results(). +-spec pmap(kz_term:ne_binary(), payload()) -> map_results(). +-spec pmap(kz_term:ne_binary(), payload(), kz_rt_options()) -> map_results(). pmap(Routing, Payload) -> pmap_processor(Routing, Payload, rt_options()). pmap(Routing, Payload, Options) -> pmap_processor(Routing, Payload, rt_options(Options)). --spec get_binding_candidates(ne_binary()) -> kz_bindings(). +-spec get_binding_candidates(kz_term:ne_binary()) -> kz_bindings(). get_binding_candidates(Routing) -> case binary:split(Routing, <<".">>, ['global']) of [Vsn, Action | _] -> @@ -155,7 +155,7 @@ get_binding_candidates(Routing) -> end. %% supports Crossbar-optimized bindings, vs selecting the whole table --spec get_binding_candidates(ne_binary(), ne_binary()) -> kz_bindings(). +-spec get_binding_candidates(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_bindings(). get_binding_candidates(Vsn, Action) -> ets:select(table_id(), [{#kz_binding{binding_prefix='$1' ,_='_' @@ -181,11 +181,11 @@ get_binding_candidates(Vsn, Action) -> %% all matching bindings %% @end %%-------------------------------------------------------------------- --spec fold(ne_binary(), payload()) -> fold_results(). +-spec fold(kz_term:ne_binary(), payload()) -> fold_results(). fold(Routing, Payload) -> fold_processor(Routing, Payload, rt_options()). --spec fold(ne_binary(), payload(), kz_rt_options()) -> fold_results(). +-spec fold(kz_term:ne_binary(), payload(), kz_rt_options()) -> fold_results(). fold(Routing, Payload, Options) -> fold_processor(Routing, Payload, rt_options(Options)). @@ -194,13 +194,13 @@ fold(Routing, Payload, Options) -> %% Helper functions for working on a result set of bindings %% @end %%------------------------------------------------------------------- --spec any(kz_proplist(), function()) -> boolean(). +-spec any(kz_term:proplist(), function()) -> boolean(). any(Res, F) when is_list(Res), is_function(F, 1) -> lists:any(F, Res). --spec all(kz_proplist(), function()) -> boolean(). +-spec all(kz_term:proplist(), function()) -> boolean(). all(Res, F) when is_list(Res), is_function(F, 1) -> @@ -228,7 +228,7 @@ succeeded(Res, F) when is_list(Res), %% <<"#.6.*.1.4.*">>,<<"6.a.a.6.a.1.4.a">> %% %%-------------------------------------------------------------------- --spec matches(ne_binaries(), ne_binaries()) -> boolean(). +-spec matches(kz_term:ne_binaries(), kz_term:ne_binaries()) -> boolean(). %% if both are empty, we made it! matches([], []) -> 'true'; @@ -289,7 +289,7 @@ matches(_, _) -> 'false'. %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_server:start_link({'local', ?SERVER}, ?MODULE, [], []). @@ -299,9 +299,9 @@ stop() -> gen_server:cast(?SERVER, 'stop'). -type bind_result() :: 'ok' | {'error', 'exists'}. -type bind_results() :: [bind_result()]. --spec bind(ne_binary() | ne_binaries(), atom(), atom()) -> +-spec bind(kz_term:ne_binary() | kz_term:ne_binaries(), atom(), atom()) -> bind_result() | bind_results(). --spec bind(ne_binary() | ne_binaries(), atom(), atom(), any()) -> +-spec bind(kz_term:ne_binary() | kz_term:ne_binaries(), atom(), atom(), any()) -> bind_result() | bind_results(). bind([_|_]=Bindings, Module, Fun) -> [bind(Binding, Module, Fun) || Binding <- Bindings]; @@ -318,9 +318,9 @@ bind(Binding, Module, Fun, Payload) -> {'error', 'not_found'}. -type unbind_results() :: [unbind_result()]. --spec unbind(ne_binary() | ne_binaries(), atom(), atom()) -> +-spec unbind(kz_term:ne_binary() | kz_term:ne_binaries(), atom(), atom()) -> unbind_result() | unbind_results(). --spec unbind(ne_binary() | ne_binaries(), atom(), atom(), any()) -> +-spec unbind(kz_term:ne_binary() | kz_term:ne_binaries(), atom(), atom(), any()) -> unbind_result() | unbind_results(). unbind([_|_]=Bindings, Module, Fun) -> [unbind(Binding, Module, Fun) || Binding <- Bindings]; @@ -336,22 +336,22 @@ unbind(Binding, Module, Fun, Payload) -> -spec flush() -> 'ok'. flush() -> gen_server:cast(?SERVER, 'flush'). --spec flush(ne_binary()) -> 'ok'. +-spec flush(kz_term:ne_binary()) -> 'ok'. flush(Binding) -> gen_server:cast(?SERVER, {'flush', Binding}). -spec flush_mod(atom()) -> 'ok'. flush_mod(Module) -> gen_server:cast(?SERVER, {'flush_mod', Module}). --type filter_fun() :: fun((ne_binary(), atom(), atom(), any()) -> boolean()). +-type filter_fun() :: fun((kz_term:ne_binary(), atom(), atom(), any()) -> boolean()). -spec filter(filter_fun()) -> 'ok'. filter(Predicate) when is_function(Predicate, 4) -> gen_server:cast(?SERVER, {'filter', Predicate}). --spec modules_loaded() -> atoms(). +-spec modules_loaded() -> kz_term:atoms(). modules_loaded() -> ets:foldl(fun modules_loaded_fold/2, [], table_id()). --spec modules_loaded_fold(kz_binding(), atoms()) -> atoms(). +-spec modules_loaded_fold(kz_binding(), kz_term:atoms()) -> kz_term:atoms(). modules_loaded_fold(#kz_binding{binding_responders=Responders}, Acc) -> props:unique([M || #kz_responder{module=M} <- queue:to_list(Responders) @@ -365,7 +365,7 @@ table_id() -> ?MODULE. table_options() -> ['set', 'named_table', 'protected', {'keypos', #kz_binding.binding}]. --spec find_me_function() -> api_pid(). +-spec find_me_function() -> kz_term:api_pid(). find_me_function() -> whereis(?SERVER). -spec gift_data() -> 'ok'. @@ -406,7 +406,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call('is_ready', _From, #state{has_ets='true'}=State) -> {'reply', 'true', State}; handle_call('is_ready', _From, State) -> @@ -422,7 +422,7 @@ handle_call({'unbind', Binding, Mod, Fun, Payload}, _, #state{}=State) -> lager:debug("maybe rm binding ~s: ~p", [Binding, Resp]), {'reply', Resp, State}. --spec maybe_add_binding(ne_binary(), atom(), atom(), any()) -> +-spec maybe_add_binding(kz_term:ne_binary(), atom(), atom(), any()) -> 'ok' | {'error', 'exists'}. maybe_add_binding(Binding, Mod, Fun, Payload) -> @@ -455,7 +455,7 @@ maybe_add_binding(Binding, Mod, Fun, Payload) -> end end. --spec maybe_rm_binding(ne_binary(), atom(), atom(), any()) -> +-spec maybe_rm_binding(kz_term:ne_binary(), atom(), atom(), any()) -> {'ok', 'deleted_binding' | 'updated_binding'} | {'error', 'not_found'}. maybe_rm_binding(Binding, Mod, Fun, Payload) -> @@ -469,7 +469,7 @@ maybe_rm_binding(Binding, Mod, Fun, Payload) -> maybe_rm_responder(Binding, Responder, Bind) end. --spec maybe_rm_responder(ne_binary(), kz_responder(), kz_binding()) -> +-spec maybe_rm_responder(kz_term:ne_binary(), kz_responder(), kz_binding()) -> {'ok', 'deleted_binding' | 'updated_binding'} | {'error', 'not_found'}. maybe_rm_responder(Binding, Responder, #kz_binding{binding_responders=Responders}=Bind) -> @@ -488,12 +488,12 @@ maybe_rm_responder(Binding, Responder, #kz_binding{binding_responders=Responders end end. --spec add_optimized_binding(ne_binary(), kz_responder(), ne_binaries(), ne_binary(), ne_binary()) -> boolean(). +-spec add_optimized_binding(kz_term:ne_binary(), kz_responder(), kz_term:ne_binaries(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). add_optimized_binding(Binding, Responder, Pieces, Vsn, Action) -> Prefix = <>, add_binding(Binding, Responder, Pieces, Prefix). --spec add_binding(ne_binary(), kz_responder(), ne_binaries(), api_binary()) -> boolean(). +-spec add_binding(kz_term:ne_binary(), kz_responder(), kz_term:ne_binaries(), kz_term:api_binary()) -> boolean(). add_binding(Binding, Responder, Pieces, Prefix) -> Bind = #kz_binding{binding=Binding ,binding_parts=lists:reverse(Pieces) @@ -512,7 +512,7 @@ add_binding(Binding, Responder, Pieces, Prefix) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('flush', #state{}=State) -> ets:delete_all_objects(table_id()), {'noreply', State, 'hibernate'}; @@ -547,9 +547,9 @@ flush_mod(ClientMod, #kz_binding{binding=Binding end end. --type filter_updates() :: [{ne_binary(), {pos_integer(), queue:queue()}}] | []. +-type filter_updates() :: [{kz_term:ne_binary(), {pos_integer(), queue:queue()}}] | []. -spec filter_bindings(filter_fun()) -> 'ok'. --spec filter_bindings(filter_fun(), ne_binary() | '$end_of_table', filter_updates(), ne_binaries()) -> 'ok'. +-spec filter_bindings(filter_fun(), kz_term:ne_binary() | '$end_of_table', filter_updates(), kz_term:ne_binaries()) -> 'ok'. filter_bindings(Predicate) -> filter_bindings(Predicate, ets:first(table_id()), [], []). @@ -595,7 +595,7 @@ filter_bindings(Predicate, Key, Updates, Deletes) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'ETS-TRANSFER',_TableId, _From, _Gift}, State) -> lager:debug("recv transfer of control for ~s from ~p", [_TableId, _From]), {'noreply', State#state{has_ets='true'}}; @@ -642,13 +642,13 @@ code_change(_OldVsn, State, _Extra) -> %% previous payload being passed to the next invocation. %% @end %%-------------------------------------------------------------------- --spec fold_bind_results(kz_responders(), any(), ne_binary()) -> any(). +-spec fold_bind_results(kz_responders(), any(), kz_term:ne_binary()) -> any(). fold_bind_results(_, {'error', _}=E, _) -> [E]; fold_bind_results([], Payload, _Route) -> Payload; fold_bind_results(Responders, Payload, Route) -> fold_bind_results(Responders, Payload, Route, length(Responders), []). --spec fold_bind_results(kz_responders(), any(), ne_binary(), non_neg_integer(), kz_responders()) -> any(). +-spec fold_bind_results(kz_responders(), any(), kz_term:ne_binary(), non_neg_integer(), kz_responders()) -> any(). fold_bind_results([#kz_responder{module=M ,function=F ,payload='undefined' @@ -729,7 +729,7 @@ log_function_clause(M, F, Lenth, ST) -> ?LOG_ERROR("no matching function clause for ~s:~s/~p", [M, F, Lenth]), kz_util:log_stacktrace(ST). --spec map_processor(ne_binary(), payload(), kz_rt_options()) -> map_results(). +-spec map_processor(kz_term:ne_binary(), payload(), kz_rt_options()) -> map_results(). map_processor(Routing, Payload, Options) when not is_list(Payload) -> map_processor(Routing, [Payload], Options); map_processor(Routing, Payload, Options) -> @@ -741,7 +741,7 @@ map_processor(Routing, Payload, Options) -> ,kazoo_bindings_rt:candidates(Options, Routing) ). --spec pmap_processor(ne_binary(), payload(), kz_rt_options()) -> map_results(). +-spec pmap_processor(kz_term:ne_binary(), payload(), kz_rt_options()) -> map_results(). pmap_processor(Routing, Payload, Options) when not is_list(Payload) -> pmap_processor(Routing, [Payload], Options); pmap_processor(Routing, Payload, Options) -> @@ -753,7 +753,7 @@ pmap_processor(Routing, Payload, Options) -> ,kazoo_bindings_rt:candidates(Options, Routing) ). --spec map_processor_fold(kz_binding(), map_results(), payload(), ne_binary(), ne_binaries(), kz_rt_options()) -> map_results(). +-spec map_processor_fold(kz_binding(), map_results(), payload(), kz_term:ne_binary(), kz_term:ne_binaries(), kz_rt_options()) -> map_results(). map_processor_fold(#kz_binding{binding=Binding ,binding_responders=Responders } @@ -781,7 +781,7 @@ map_processor_fold(#kz_binding{binding_parts=BParts map_responders(Acc, Responders, Payload) end. --spec pmap_processor_fold(kz_binding(), map_results(), payload(), ne_binary(), ne_binaries(), kz_rt_options()) -> map_results(). +-spec pmap_processor_fold(kz_binding(), map_results(), payload(), kz_term:ne_binary(), kz_term:ne_binaries(), kz_rt_options()) -> map_results(). pmap_processor_fold(#kz_binding{binding=Binding ,binding_responders=Responders } @@ -872,7 +872,7 @@ maybe_log_function_clause(M, F, Payload, [{M, F, Payload, _}|_]) -> 'ok'; maybe_log_function_clause(M, F, Payload, ST) -> log_function_clause(M, F, length(Payload), ST). --spec fold_processor(ne_binary(), payload(), kz_rt_options()) -> fold_results(). +-spec fold_processor(kz_term:ne_binary(), payload(), kz_rt_options()) -> fold_results(). fold_processor(Routing, Payload, Options) when not is_list(Payload) -> fold_processor(Routing, [Payload], Options); fold_processor(Routing, Payload, Options) -> @@ -899,7 +899,7 @@ fold_processor(Routing, Payload, Options) -> ), Reply. --spec candidates(ne_binary()) -> kz_bindings(). +-spec candidates(kz_term:ne_binary()) -> kz_bindings(). candidates(Routing) -> get_binding_candidates(Routing). @@ -907,11 +907,11 @@ candidates(Routing) -> bindings() -> bindings(<<"#">>, rt_options()). --spec bindings(ne_binary()) -> kz_bindings(). +-spec bindings(kz_term:ne_binary()) -> kz_bindings(). bindings(Routing) -> bindings(Routing, rt_options()). --spec bindings(ne_binary(), kz_rt_options()) -> kz_bindings(). +-spec bindings(kz_term:ne_binary(), kz_rt_options()) -> kz_bindings(). bindings(Routing, Opts) -> Options = rt_options(Opts), RoutingParts = routing_parts(Routing), @@ -929,7 +929,7 @@ bindings(Routing, Opts) -> ,table_id() ). --spec routing_parts(ne_binary()) -> ne_binaries(). +-spec routing_parts(kz_term:ne_binary()) -> kz_term:ne_binaries(). routing_parts(Routing) -> lists:reverse(binary:split(Routing, <<".">>, ['global'])). diff --git a/core/kazoo_bindings/src/kazoo_bindings_app.erl b/core/kazoo_bindings/src/kazoo_bindings_app.erl index f7edfd2510e..6acc074fd44 100644 --- a/core/kazoo_bindings/src/kazoo_bindings_app.erl +++ b/core/kazoo_bindings/src/kazoo_bindings_app.erl @@ -17,7 +17,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> kazoo_bindings_sup:start_link(). diff --git a/core/kazoo_bindings/src/kazoo_bindings_init.erl b/core/kazoo_bindings/src/kazoo_bindings_init.erl index 73bc2f0ab46..1a97c49ff16 100644 --- a/core/kazoo_bindings/src/kazoo_bindings_init.erl +++ b/core/kazoo_bindings/src/kazoo_bindings_init.erl @@ -12,7 +12,7 @@ -include("kazoo_bindings.hrl"). --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> wait_for_bindings('false'). diff --git a/core/kazoo_bindings/src/kazoo_bindings_rt.erl b/core/kazoo_bindings/src/kazoo_bindings_rt.erl index 4daa088c3f6..b7334517cc2 100644 --- a/core/kazoo_bindings/src/kazoo_bindings_rt.erl +++ b/core/kazoo_bindings/src/kazoo_bindings_rt.erl @@ -17,12 +17,12 @@ -include("kazoo_bindings.hrl"). --spec candidates(kazoo_bindings:kz_rt_options(), ne_binary()) -> kazoo_bindings:kz_bindings(). +-spec candidates(kazoo_bindings:kz_rt_options(), kz_term:ne_binary()) -> kazoo_bindings:kz_bindings(). candidates(Options, Routing) -> Fun = props:get_value('candidates', Options), Fun(Routing). --spec matches(kazoo_bindings:kz_rt_options(), binaries(), binaries()) -> boolean(). +-spec matches(kazoo_bindings:kz_rt_options(), kz_term:binaries(), kz_term:binaries()) -> boolean(). matches(Options, AParts, BParts) -> Fun = props:get_value('matches', Options), Fun(AParts, BParts). diff --git a/core/kazoo_bindings/src/kazoo_bindings_sup.erl b/core/kazoo_bindings/src/kazoo_bindings_sup.erl index 97ef837037a..2f597dac7f4 100644 --- a/core/kazoo_bindings/src/kazoo_bindings_sup.erl +++ b/core/kazoo_bindings/src/kazoo_bindings_sup.erl @@ -40,7 +40,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -57,7 +57,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, diff --git a/core/kazoo_bindings/test/kazoo_bindings_test.erl b/core/kazoo_bindings/test/kazoo_bindings_test.erl index f5357692e0b..5d2e027637e 100644 --- a/core/kazoo_bindings/test/kazoo_bindings_test.erl +++ b/core/kazoo_bindings/test/kazoo_bindings_test.erl @@ -27,7 +27,7 @@ -include_lib("kazoo_stdlib/include/kz_types.hrl"). %% EUNIT and PropEr TESTING %% --spec binding_matches(ne_binary(), binary()) -> boolean(). +-spec binding_matches(kz_term:ne_binary(), binary()) -> boolean(). binding_matches(B, R) -> BRev = lists:reverse(binary:split(B, <<".">>, ['global'])), RRev = lists:reverse(binary:split(R, <<".">>, ['global'])), diff --git a/core/kazoo_caches/include/kazoo_caches.hrl b/core/kazoo_caches/include/kazoo_caches.hrl index f3aca7350ae..d882fac46e4 100644 --- a/core/kazoo_caches/include/kazoo_caches.hrl +++ b/core/kazoo_caches/include/kazoo_caches.hrl @@ -8,18 +8,18 @@ -type callback_fun() :: fun((any(), any(), 'flush' | 'erase' | 'expire') -> any()). -type callback_funs() :: [callback_fun()]. --type origin_tuple() :: {'db', ne_binary(), ne_binary()} | %% {db, Database, PvtType or Id} - {'type', ne_binary(), ne_binary()} | %% {type, PvtType, Id} - {'db', ne_binary()} | %% {db, Database} - {'db', ne_binary(), ne_binary() | '_'} | %% {db, Database, Type} - {'database', ne_binary()} | %% {database, Database} added for notify db create/delete - {'type', ne_binary()}. %% {type, PvtType} +-type origin_tuple() :: {'db', kz_term:ne_binary(), kz_term:ne_binary()} | %% {db, Database, PvtType or Id} + {'type', kz_term:ne_binary(), kz_term:ne_binary()} | %% {type, PvtType, Id} + {'db', kz_term:ne_binary()} | %% {db, Database} + {'db', kz_term:ne_binary(), kz_term:ne_binary() | '_'} | %% {db, Database, Type} + {'database', kz_term:ne_binary()} | %% {database, Database} added for notify db create/delete + {'type', kz_term:ne_binary()}. %% {type, PvtType} -type origin_tuples() :: [origin_tuple()]. -record(cache_obj, {key :: any()| '_' | '$1' ,value :: any() | '_' | '$1' | '$2' - ,expires :: kz_timeout() | '_' | '$3' - ,timestamp = kz_time:now_s() :: gregorian_seconds() | '_' | '$4' + ,expires :: timeout() | '_' | '$3' + ,timestamp = kz_time:now_s() :: kz_time:gregorian_seconds() | '_' | '$4' ,callback :: callback_fun() | '_' | '$2' | '$3' | '$5' | 'undefined' ,origin :: origin_tuple() | origin_tuples() | '$1' | '_' | 'undefined' }). diff --git a/core/kazoo_caches/src/kazoo_caches_app.erl b/core/kazoo_caches/src/kazoo_caches_app.erl index d0d0c794524..ca7ae33fd95 100644 --- a/core/kazoo_caches/src/kazoo_caches_app.erl +++ b/core/kazoo_caches/src/kazoo_caches_app.erl @@ -17,7 +17,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = declare_exchanges(), kazoo_caches_sup:start_link(). diff --git a/core/kazoo_caches/src/kazoo_caches_sup.erl b/core/kazoo_caches/src/kazoo_caches_sup.erl index 03a8756d258..564a2475197 100644 --- a/core/kazoo_caches/src/kazoo_caches_sup.erl +++ b/core/kazoo_caches/src/kazoo_caches_sup.erl @@ -30,7 +30,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -47,7 +47,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, diff --git a/core/kazoo_caches/src/kz_cache.erl b/core/kazoo_caches/src/kz_cache.erl index 4c6edd13716..f270b5bec14 100644 --- a/core/kazoo_caches/src/kz_cache.erl +++ b/core/kazoo_caches/src/kz_cache.erl @@ -66,7 +66,7 @@ -define(DATABASE_BINDING, [{'type', <<"database">>}]). -type store_options() :: [{'origin', origin_tuple() | origin_tuples()} | - {'expires', kz_timeout()} | + {'expires', timeout()} | {'callback', 'undefined' | callback_fun()} ]. -export_type([store_options/0]). @@ -79,9 +79,9 @@ ,channel_reconnect_flush = 'false' :: boolean() ,new_node_flush = 'false' :: boolean() ,expire_node_flush = 'false' :: boolean() - ,expire_period = ?EXPIRE_PERIOD :: kz_timeout() + ,expire_period = ?EXPIRE_PERIOD :: timeout() ,expire_period_ref :: reference() - ,props = [] :: kz_proplist() + ,props = [] :: kz_term:proplist() ,has_monitors = 'false' :: boolean() }). -type state() :: #state{}. @@ -93,8 +93,8 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(atom()) -> startlink_ret(). --spec start_link(atom(), kz_proplist()) -> startlink_ret(). +-spec start_link(atom()) -> kz_types:startlink_ret(). +-spec start_link(atom(), kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Name) when is_atom(Name) -> start_link(Name, ?EXPIRE_PERIOD, []). @@ -102,7 +102,7 @@ start_link(Name) when is_atom(Name) -> start_link(Name, Props) when is_list(Props) -> start_link(Name, ?EXPIRE_PERIOD, Props). --spec start_link(atom(), kz_timeout(), kz_proplist()) -> startlink_ret(). +-spec start_link(atom(), timeout(), kz_term:proplist()) -> kz_types:startlink_ret(). start_link(Name, ExpirePeriod, Props) -> case props:get_value('origin_bindings', Props) of 'undefined' -> @@ -128,14 +128,14 @@ stop_local(Srv) -> catch gen_server:call(Srv, 'stop'), 'ok'. --spec maybe_add_db_binding(kz_proplists()) -> kz_proplists(). +-spec maybe_add_db_binding(kz_term:proplists()) -> kz_term:proplists(). maybe_add_db_binding([]) -> []; maybe_add_db_binding([[]]) -> [[]]; maybe_add_db_binding(BindingProps) -> [?DATABASE_BINDING | BindingProps]. -spec store(any(), any()) -> 'ok'. --spec store(any(), any(), kz_proplist()) -> 'ok'. +-spec store(any(), any(), kz_term:proplist()) -> 'ok'. store(K, V) -> store(K, V, []). @@ -164,21 +164,21 @@ filter(Pred) when is_function(Pred, 2) -> filter_local(?SERVER, Pred). -spec dump() -> 'ok'. dump() -> dump('false'). --spec dump(text()) -> 'ok'. +-spec dump(kz_term:text()) -> 'ok'. dump(ShowValue) -> dump_local(?SERVER, ShowValue). -spec wait_for_key(any()) -> {'ok', any()} | {'error', 'timeout'}. --spec wait_for_key(any(), kz_timeout()) -> {'ok', any()} | - {'error', 'timeout'}. +-spec wait_for_key(any(), timeout()) -> {'ok', any()} | + {'error', 'timeout'}. wait_for_key(Key) -> wait_for_key(Key, ?DEFAULT_WAIT_TIMEOUT). wait_for_key(Key, Timeout) -> wait_for_key_local(?SERVER, Key, Timeout). %% Local cache API --spec store_local(server_ref(), any(), any()) -> 'ok'. --spec store_local(server_ref(), any(), any(), kz_proplist()) -> 'ok'. +-spec store_local(kz_types:server_ref(), any(), any()) -> 'ok'. +-spec store_local(kz_types:server_ref(), any(), any(), kz_term:proplist()) -> 'ok'. store_local(Srv, K, V) -> store_local(Srv, K, V, []). @@ -223,7 +223,7 @@ erase_local(Srv, K) -> {'ok', _} -> gen_server:call(Srv, {'erase', K}) end. --spec flush_local(text() | atom()) -> 'ok'. +-spec flush_local(kz_term:text() | atom()) -> 'ok'. flush_local(Srv) when not is_atom(Srv) -> flush_local(kz_term:to_atom(Srv)); flush_local(Srv) -> @@ -266,10 +266,10 @@ filter_local(Srv, Pred) when is_function(Pred, 2) -> ,Srv ). --spec dump_local(text()) -> 'ok'. +-spec dump_local(kz_term:text()) -> 'ok'. dump_local(Srv) -> dump_local(Srv, 'false'). --spec dump_local(text(), text() | boolean()) -> 'ok'. +-spec dump_local(kz_term:text(), kz_term:text() | boolean()) -> 'ok'. dump_local(Srv, ShowValue) when not is_atom(Srv) -> dump_local(kz_term:to_atom(Srv), ShowValue); dump_local(Srv, ShowValue) when not is_boolean(ShowValue) -> @@ -291,7 +291,7 @@ dump_table(Tab, ShowValue) -> ], 'ok'. --spec display_cache_obj(cache_obj(), boolean(), gregorian_seconds()) -> 'ok'. +-spec display_cache_obj(cache_obj(), boolean(), kz_time:gregorian_seconds()) -> 'ok'. display_cache_obj(#cache_obj{key=Key ,value=Value ,timestamp=Timestamp @@ -330,8 +330,8 @@ wait_for_key_local(Srv, Key, Timeout) when is_integer(Timeout) -> {'ok', Ref} = gen_server:call(Srv, {'wait_for_key', Key, Timeout}, WaitFor), wait_for_response(Ref, WaitFor). --spec wait_for_response(reference(), kz_timeout()) -> {'ok', any()} | - {'error', 'timeout'}. +-spec wait_for_response(reference(), timeout()) -> {'ok', any()} | + {'error', 'timeout'}. wait_for_response(Ref, WaitFor) -> receive {'exists', Ref, Value} -> {'ok', Value}; @@ -355,19 +355,19 @@ wait_for_response(Ref, WaitFor) -> %% {stop, Reason} %% @end %%-------------------------------------------------------------------- --spec init([atom() | kz_timeout() | kz_proplist()]) -> {'ok', state()}. +-spec init([atom() | timeout() | kz_term:proplist()]) -> {'ok', state()}. init([Name, ExpirePeriod, Props]) -> kz_util:put_callid(Name), init(Name, ExpirePeriod, Props, props:get_value('origin_bindings', Props)). --spec init(atom(), kz_timeout(), kz_proplist(), api_list()) -> {'ok', state()}. +-spec init(atom(), timeout(), kz_term:proplist(), kz_term:api_list()) -> {'ok', state()}. init(Name, ExpirePeriod, Props, 'undefined') -> init(Name, ExpirePeriod, Props); init(Name, ExpirePeriod, Props, _Bindings) -> kapi_conf:declare_exchanges(), init(Name, ExpirePeriod, Props). --spec init(atom(), kz_timeout(), kz_proplist()) -> {'ok', state()}. +-spec init(atom(), timeout(), kz_term:proplist()) -> {'ok', state()}. init(Name, ExpirePeriod, Props) -> Tab = ets:new(Name ,['set', 'public', 'named_table', {'keypos', #cache_obj.key}] @@ -430,7 +430,7 @@ to_tab(Tab, Suffix) -> monitor_response_fun(Pid, Ref) -> fun(_, Value, Reason) -> Pid ! {Reason, Ref, Value} end. --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call({'tables'}, _From, #state{pointer_tab=PointerTab ,monitor_tab=MonitorTab }=State) -> @@ -480,7 +480,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'store', CacheObj}, State) -> State1 = handle_store(CacheObj, State), {'noreply', State1}; @@ -580,7 +580,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'timeout', Ref, ?EXPIRE_PERIOD_MSG} ,#state{expire_period_ref=Ref ,expire_period=Period @@ -654,7 +654,7 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec get_props_expires(kz_proplist()) -> kz_timeout(). +-spec get_props_expires(kz_term:proplist()) -> timeout(). get_props_expires(Props) -> case props:get_value('expires', Props) of 'undefined' -> ?EXPIRES; @@ -664,14 +664,14 @@ get_props_expires(Props) -> Expires end. --spec get_props_callback(kz_proplist()) -> 'undefined' | callback_fun(). +-spec get_props_callback(kz_term:proplist()) -> 'undefined' | callback_fun(). get_props_callback(Props) -> case props:get_value('callback', Props) of 'undefined' -> 'undefined'; Fun when is_function(Fun, 3) -> Fun end. --spec get_props_origin(kz_proplist()) -> 'undefined' | origin_tuple() | origin_tuples(). +-spec get_props_origin(kz_term:proplist()) -> 'undefined' | origin_tuple() | origin_tuples(). get_props_origin(Props) -> props:get_value('origin', Props). -spec expire_objects(ets:tab(), [ets:tab()]) -> non_neg_integer(). @@ -906,7 +906,7 @@ handle_document_change(JObj, State) -> _Keys =/= [] andalso lager:debug("removed ~p keys for ~s/~s/~s", [length(_Keys), Db, Id, Type]). --spec handle_document_change(ne_binary(), ne_binary(), ne_binary(), state()) -> +-spec handle_document_change(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), state()) -> list(). handle_document_change(Db, <<"database">>, _Id, #state{pointer_tab=PTab}=State) -> MatchSpec = match_db_changed(Db), @@ -929,7 +929,7 @@ handle_document_change(Db, Type, Id ,Objects ). --spec match_db_changed(ne_binary()) -> ets:match_spec(). +-spec match_db_changed(kz_term:ne_binary()) -> ets:match_spec(). match_db_changed(Db) -> [{#cache_obj{origin = {'db', Db}, _ = '_'} ,[] @@ -945,7 +945,7 @@ match_db_changed(Db) -> } ]. --spec match_doc_changed(ne_binary(), ne_binary(), ne_binary()) -> ets:match_spec(). +-spec match_doc_changed(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> ets:match_spec(). match_doc_changed(Db, Type, Id) -> [{#cache_obj{origin = {'db', Db}, _ = '_'} ,[] diff --git a/core/kazoo_call/include/kapps_call_command_types.hrl b/core/kazoo_call/include/kapps_call_command_types.hrl index c0390b6f5ac..aaa09b4617e 100644 --- a/core/kazoo_call/include/kapps_call_command_types.hrl +++ b/core/kazoo_call/include/kapps_call_command_types.hrl @@ -1,6 +1,6 @@ -ifndef(KAPPS_CALL_COMMAND_TYPES_HRL). --type kapps_custom_publish() :: fun((kz_proplist(), kapps_call:call()) -> 'ok'). +-type kapps_custom_publish() :: fun((kz_term:proplist(), kapps_call:call()) -> 'ok'). -type kapps_api_error() :: {'error', 'channel_hungup' | 'channel_unbridge' | 'channel_disconnected' | @@ -9,7 +9,7 @@ }. -type kapps_api_std_return() :: kapps_api_error() | {'ok', kz_json:object() | - ne_binary() + kz_term:ne_binary() } | 'ok'. -type kapps_api_bridge_return() :: {'error', 'timeout' | diff --git a/core/kazoo_call/src/kapps_call.erl b/core/kazoo_call/src/kapps_call.erl index 790d223e3f8..84b44e6e467 100644 --- a/core/kazoo_call/src/kapps_call.erl +++ b/core/kazoo_call/src/kapps_call.erl @@ -146,49 +146,49 @@ -define(NO_REALM, <<"norealm">>). -define(NO_USER_REALM, <<"nouser@norealm">>). --record(kapps_call, {call_id :: api_binary() %% The UUID of the call +-record(kapps_call, {call_id :: kz_term:api_binary() %% The UUID of the call ,call_id_helper = fun default_helper_function/2 :: kapps_helper_function() %% A function used when requesting the call id, to ensure it is up-to-date - ,control_q :: api_binary() %% The control queue provided on route win + ,control_q :: kz_term:api_binary() %% The control queue provided on route win ,control_q_helper = fun default_helper_function/2 :: kapps_helper_function() %% A function used when requesting the call id, to ensure it is up-to-date - ,controller_q :: api_binary() %% - ,caller_id_name :: api_ne_binary() %% The caller name - ,caller_id_number :: api_ne_binary() %% The caller number - ,callee_id_name :: api_binary() %% The callee name - ,callee_id_number :: api_binary() %% The callee number + ,controller_q :: kz_term:api_binary() %% + ,caller_id_name :: kz_term:api_ne_binary() %% The caller name + ,caller_id_number :: kz_term:api_ne_binary() %% The caller number + ,callee_id_name :: kz_term:api_binary() %% The callee name + ,callee_id_number :: kz_term:api_binary() %% The callee number ,switch_nodename = <<>> :: binary() %% The switch node name (as known in ecallmgr) - ,switch_hostname :: api_ne_binary() %% The switch hostname (as reported by the switch) - ,switch_url :: api_binary() %% The switch url - ,switch_uri :: api_binary() %% The switch uri - ,request = ?NO_USER_REALM :: ne_binary() %% The request of sip_request_user + @ + sip_request_host - ,request_user = ?NO_USER :: ne_binary() %% SIP request user - ,request_realm = ?NO_REALM :: ne_binary() %% SIP request host - ,from = ?NO_USER_REALM :: ne_binary() %% Result of sip_from_user + @ + sip_from_host - ,from_user = ?NO_USER :: ne_binary() %% SIP from user - ,from_realm = ?NO_REALM :: ne_binary() %% SIP from host - ,to = ?NO_USER_REALM :: ne_binary() %% Result of sip_to_user + @ + sip_to_host - ,to_user = ?NO_USER :: ne_binary() %% SIP to user - ,to_realm = ?NO_REALM :: ne_binary() %% SIP to host - ,inception :: api_binary() %% Origin of the call <<"on-net">> | <<"off-net">> - ,account_db :: api_binary() %% The database name of the account that authorized this call - ,account_id :: api_binary() %% The account id that authorized this call - ,authorizing_id :: api_binary() %% The ID of the record that authorized this call - ,authorizing_type :: api_binary() %% The pvt_type of the record that authorized this call - ,owner_id :: api_binary() %% The ID of the owner of this calling device, if any - ,fetch_id :: api_binary() %% The Fetch ID of the Call - ,bridge_id :: api_binary() %% The Bridge ID of the Call - ,language :: api_binary() %% Language of the call to use - ,app_name = <<"kapps_call">> :: ne_binary() %% The application name used during kapps_call_command - ,app_version = <<"1.0.0">> :: ne_binary() %% The application version used during kapps_call_command + ,switch_hostname :: kz_term:api_ne_binary() %% The switch hostname (as reported by the switch) + ,switch_url :: kz_term:api_binary() %% The switch url + ,switch_uri :: kz_term:api_binary() %% The switch uri + ,request = ?NO_USER_REALM :: kz_term:ne_binary() %% The request of sip_request_user + @ + sip_request_host + ,request_user = ?NO_USER :: kz_term:ne_binary() %% SIP request user + ,request_realm = ?NO_REALM :: kz_term:ne_binary() %% SIP request host + ,from = ?NO_USER_REALM :: kz_term:ne_binary() %% Result of sip_from_user + @ + sip_from_host + ,from_user = ?NO_USER :: kz_term:ne_binary() %% SIP from user + ,from_realm = ?NO_REALM :: kz_term:ne_binary() %% SIP from host + ,to = ?NO_USER_REALM :: kz_term:ne_binary() %% Result of sip_to_user + @ + sip_to_host + ,to_user = ?NO_USER :: kz_term:ne_binary() %% SIP to user + ,to_realm = ?NO_REALM :: kz_term:ne_binary() %% SIP to host + ,inception :: kz_term:api_binary() %% Origin of the call <<"on-net">> | <<"off-net">> + ,account_db :: kz_term:api_binary() %% The database name of the account that authorized this call + ,account_id :: kz_term:api_binary() %% The account id that authorized this call + ,authorizing_id :: kz_term:api_binary() %% The ID of the record that authorized this call + ,authorizing_type :: kz_term:api_binary() %% The pvt_type of the record that authorized this call + ,owner_id :: kz_term:api_binary() %% The ID of the owner of this calling device, if any + ,fetch_id :: kz_term:api_binary() %% The Fetch ID of the Call + ,bridge_id :: kz_term:api_binary() %% The Bridge ID of the Call + ,language :: kz_term:api_binary() %% Language of the call to use + ,app_name = <<"kapps_call">> :: kz_term:ne_binary() %% The application name used during kapps_call_command + ,app_version = <<"1.0.0">> :: kz_term:ne_binary() %% The application version used during kapps_call_command ,custom_publish_fun :: kapps_custom_publish() | 'undefined' %% A custom command used to publish kapps_call_command ,ccvs = kz_json:new() :: kz_json:object() %% Any custom channel vars that where provided with the route request ,cavs = kz_json:new() :: kz_json:object() %% Any custom application vars that where provided with the route request ,sip_headers = kz_json:new() :: kz_json:object() %% Custom SIP Headers ,kvs = orddict:new() :: orddict:orddict() %% allows callflows to set values that propogate to children - ,other_leg_call_id :: api_binary() - ,resource_type :: api_binary() %% from route_req - ,to_tag :: api_binary() - ,from_tag :: api_binary() - ,direction = <<"inbound">> :: ne_binary() + ,other_leg_call_id :: kz_term:api_binary() + ,resource_type :: kz_term:api_binary() %% from route_req + ,to_tag :: kz_term:api_binary() + ,from_tag :: kz_term:api_binary() + ,direction = <<"inbound">> :: kz_term:ne_binary() ,call_bridged = 'false' :: boolean() %% Specified during call termination whether the call had been bridged ,message_left = 'false' :: boolean() %% Specified during call termination whether the caller left a voicemail message ,is_recording = 'false' :: boolean() %% Control account level recording @@ -199,7 +199,7 @@ -export_type([kapps_api_std_return/0]). --type kapps_helper_function() :: fun((api_binary(), call()) -> api_binary()). +-type kapps_helper_function() :: fun((kz_term:api_binary(), call()) -> kz_term:api_binary()). -define(SPECIAL_VARS, [{<<"Caller-ID-Name">>, #kapps_call.caller_id_name} ,{<<"Caller-ID-Number">>, #kapps_call.caller_id_number} @@ -225,7 +225,7 @@ clear_helpers(#kapps_call{}=Call) -> -spec new() -> call(). new() -> #kapps_call{}. --spec put_callid(call()) -> api_binary(). +-spec put_callid(call()) -> kz_term:api_binary(). put_callid(#kapps_call{call_id='undefined'}) -> 'undefined'; put_callid(#kapps_call{call_id=CallId}) -> kz_util:put_callid(CallId). @@ -349,8 +349,8 @@ from_route_win(RouteWin, #kapps_call{call_id=OldCallId ,language = kz_media_util:prompt_language(AccountId, OldLanguage) }. --spec find_account_info(api_binary(), api_binary(), api_binary()) -> - {api_binary(), api_binary()}. +-spec find_account_info(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary()) -> + {kz_term:api_binary(), kz_term:api_binary()}. find_account_info(OldId, OldDb, 'undefined') -> {OldId, OldDb}; find_account_info('undefined', _OldDb, AccountId) -> @@ -360,7 +360,7 @@ find_account_info('undefined', _OldDb, AccountId) -> find_account_info(OldId, OldDb, _AccountId) -> {OldId, OldDb}. --spec merge(kz_json:object(), api_object()) -> kz_json:object(). +-spec merge(kz_json:object(), kz_term:api_object()) -> kz_json:object(). merge(OldJObj, 'undefined') -> OldJObj; merge(OldJObj, JObj) -> kz_json:merge(OldJObj, JObj). @@ -487,7 +487,7 @@ to_json(#kapps_call{}=Call) -> kz_json:is_json_term(V) ]). --spec to_proplist(call()) -> kz_proplist(). +-spec to_proplist(call()) -> kz_term:proplist(). to_proplist(#kapps_call{}=Call) -> [{<<"Account-DB">>, account_db(Call)} ,{<<"Account-ID">>, account_id(Call)} @@ -551,32 +551,32 @@ exec_fold({F, K, V}, C) when is_function(F, 3) -> F(K, V, C); exec_fold({F, V}, C) when is_function(F, 2) -> F(V, C); exec_fold(F, C) when is_function(F, 1) -> F(C). --spec set_application_name(ne_binary(), call()) -> call(). +-spec set_application_name(kz_term:ne_binary(), call()) -> call(). set_application_name(AppName, #kapps_call{}=Call) when is_binary(AppName) -> Call#kapps_call{app_name=AppName}. --spec application_name(call()) -> ne_binary(). +-spec application_name(call()) -> kz_term:ne_binary(). application_name(#kapps_call{app_name=AppName}) -> AppName. --spec set_application_version(ne_binary(), call()) -> call(). +-spec set_application_version(kz_term:ne_binary(), call()) -> call(). set_application_version(AppVersion, #kapps_call{}=Call) when is_binary(AppVersion) -> Call#kapps_call{app_version=AppVersion}. --spec application_version(call()) -> ne_binary(). +-spec application_version(call()) -> kz_term:ne_binary(). application_version(#kapps_call{app_version=AppVersion}) -> AppVersion. --spec set_call_id(api_binary(), call()) -> call(). +-spec set_call_id(kz_term:api_binary(), call()) -> call(). set_call_id(CallId, #kapps_call{}=Call) -> Call#kapps_call{call_id=CallId}. --spec set_other_leg_call_id(api_binary(), call()) -> call(). +-spec set_other_leg_call_id(kz_term:api_binary(), call()) -> call(). set_other_leg_call_id(CallId, #kapps_call{}=Call) -> Call#kapps_call{other_leg_call_id=CallId}. --spec call_id(call()) -> api_binary(). --spec call_id_direct(call()) -> api_binary(). +-spec call_id(call()) -> kz_term:api_binary(). +-spec call_id_direct(call()) -> kz_term:api_binary(). call_id(#kapps_call{call_id=CallId, call_id_helper=Fun}=Call) when is_function(Fun, 2) -> Fun(CallId, Call); call_id(#kapps_call{call_id=CallId}=Call) -> @@ -585,7 +585,7 @@ call_id(#kapps_call{call_id=CallId}=Call) -> call_id_direct(#kapps_call{call_id=CallId}) -> CallId. --spec other_leg_call_id(call()) -> api_binary(). +-spec other_leg_call_id(call()) -> kz_term:api_binary(). other_leg_call_id(#kapps_call{other_leg_call_id=CallId}=_Call) -> CallId. @@ -597,12 +597,12 @@ call_id_helper(Fun, #kapps_call{}=Call) when is_function(Fun, 2) -> clear_call_id_helper(Call) -> Call#kapps_call{call_id_helper=fun default_helper_function/2}. --spec set_control_queue(ne_binary(), call()) -> call(). +-spec set_control_queue(kz_term:ne_binary(), call()) -> call(). set_control_queue(ControlQ, #kapps_call{}=Call) when is_binary(ControlQ) -> Call#kapps_call{control_q=ControlQ}. --spec control_queue(call()) -> api_binary(). --spec control_queue_direct(call()) -> api_binary(). +-spec control_queue(call()) -> kz_term:api_binary(). +-spec control_queue_direct(call()) -> kz_term:api_binary(). control_queue(#kapps_call{control_q=ControlQ, control_q_helper=Fun}=Call) when is_function(Fun, 2) -> Fun(ControlQ, Call); control_queue(#kapps_call{control_q=ControlQ}=Call) -> @@ -619,7 +619,7 @@ control_queue_helper(Fun, #kapps_call{}=Call) when is_function(Fun, 2) -> clear_control_queue_helper(#kapps_call{}=Call) -> Call#kapps_call{control_q_helper=fun default_helper_function/2}. --spec set_controller_queue(ne_binary(), call()) -> call(). +-spec set_controller_queue(kz_term:ne_binary(), call()) -> call(). set_controller_queue(ControllerQ, #kapps_call{}=Call) when is_binary(ControllerQ) -> Call#kapps_call{controller_q=ControllerQ}. @@ -627,12 +627,12 @@ set_controller_queue(ControllerQ, #kapps_call{}=Call) when is_binary(ControllerQ controller_queue(#kapps_call{controller_q=ControllerQ}) -> ControllerQ. --spec maybe_format_caller_id(call(), api_object()) -> call(). +-spec maybe_format_caller_id(call(), kz_term:api_object()) -> call(). maybe_format_caller_id(Call, 'undefined') -> Call; maybe_format_caller_id(Call, Format) -> set_caller_id_number(maybe_format_caller_id_str(caller_id_number(Call), Format), Call). --spec maybe_format_caller_id_str(ne_binary(), api_object()) -> ne_binary(). +-spec maybe_format_caller_id_str(kz_term:ne_binary(), kz_term:api_object()) -> kz_term:ne_binary(). maybe_format_caller_id_str(Cid, 'undefined') -> Cid; maybe_format_caller_id_str(Cid, Format) -> Class = knm_converters:classify(Cid), @@ -642,13 +642,13 @@ maybe_format_caller_id_str(Cid, Format) -> UseFormat -> maybe_reformat_caller_id(Cid, UseFormat) end. --spec maybe_reformat_caller_id(ne_binary(), api_object()) -> ne_binary(). +-spec maybe_reformat_caller_id(kz_term:ne_binary(), kz_term:api_object()) -> kz_term:ne_binary(). maybe_reformat_caller_id(CallerId, 'undefined') -> CallerId; maybe_reformat_caller_id(CallerId, Format) -> Regex = kz_json:get_ne_value(<<"regex">>, Format), maybe_regex_caller_id(CallerId, Regex, Format). --spec maybe_regex_caller_id(ne_binary(), api_binary(), kz_json:object()) -> ne_binary(). +-spec maybe_regex_caller_id(kz_term:ne_binary(), kz_term:api_binary(), kz_json:object()) -> kz_term:ne_binary(). maybe_regex_caller_id(CallerId, 'undefined', _) -> CallerId; maybe_regex_caller_id(CallerId, Regex, Format) -> Normalized = knm_converters:normalize(CallerId), @@ -665,21 +665,21 @@ maybe_regex_caller_id(CallerId, Regex, Format) -> _NotMatching -> CallerId end. --spec maybe_prepend_caller_id(ne_binary(), api_binary()) -> ne_binary(). +-spec maybe_prepend_caller_id(kz_term:ne_binary(), kz_term:api_binary()) -> kz_term:ne_binary(). maybe_prepend_caller_id(CallerId, 'undefined') -> CallerId; maybe_prepend_caller_id(CallerId, Prefix) -> BinPrefix = kz_term:to_binary(Prefix), lager:info("prepending cid with ~s~n", [BinPrefix]), <>. --spec maybe_append_caller_id(ne_binary(), api_binary()) -> ne_binary(). +-spec maybe_append_caller_id(kz_term:ne_binary(), kz_term:api_binary()) -> kz_term:ne_binary(). maybe_append_caller_id(CallerId, 'undefined') -> CallerId; maybe_append_caller_id(CallerId, Suffix) -> BinSuffix = kz_term:to_binary(Suffix), lager:info("appending cid with ~s~n", [BinSuffix]), <>. --spec set_caller_id(ne_binary(), ne_binary(), call()) -> call(). +-spec set_caller_id(kz_term:ne_binary(), kz_term:ne_binary(), call()) -> call(). -ifdef(TEST). -include_lib("eunit/include/eunit.hrl"). set_caller_id(CIDNumber, CIDName, #kapps_call{}=Call) @@ -701,11 +701,11 @@ set_caller_id(CIDNumber, CIDName, #kapps_call{}=Call) }. -endif. --spec caller_id(call()) -> {ne_binary(), ne_binary()}. +-spec caller_id(call()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. caller_id(Call) -> {caller_id_number(Call), caller_id_name(Call)}. --spec set_caller_id_name(ne_binary(), call()) -> call(). +-spec set_caller_id_name(kz_term:ne_binary(), call()) -> call(). -ifdef(TEST). set_caller_id_name(CIDName, Call) -> Call#kapps_call{caller_id_name=CIDName}. @@ -715,7 +715,7 @@ set_caller_id_name(CIDName, #kapps_call{}=Call) when is_binary(CIDName) -> Call#kapps_call{caller_id_name=CIDName}. -endif. --spec caller_id_name(call()) -> ne_binary(). +-spec caller_id_name(call()) -> kz_term:ne_binary(). -ifdef(TEST). caller_id_name(#kapps_call{caller_id_name=CIDName}) -> CIDName. -else. @@ -728,7 +728,7 @@ caller_id_name(#kapps_call{caller_id_name=CIDName end. -endif. --spec set_caller_id_number(api_binary(), call()) -> call(). +-spec set_caller_id_number(kz_term:api_binary(), call()) -> call(). -ifdef(TEST). set_caller_id_number(CIDNumber, Call) -> Call#kapps_call{caller_id_number=CIDNumber}. @@ -738,7 +738,7 @@ set_caller_id_number(CIDNumber, #kapps_call{}=Call) -> Call#kapps_call{caller_id_number=CIDNumber}. -endif. --spec caller_id_number(call()) -> ne_binary(). +-spec caller_id_number(call()) -> kz_term:ne_binary(). -ifdef(TEST). caller_id_number(#kapps_call{caller_id_number=CIDNumber}) -> CIDNumber. -else. @@ -751,7 +751,7 @@ caller_id_number(#kapps_call{caller_id_number=CIDNumber end. -endif. --spec set_callee_id(ne_binary(), ne_binary(), call()) -> call(). +-spec set_callee_id(kz_term:ne_binary(), kz_term:ne_binary(), call()) -> call(). -ifdef(TEST). set_callee_id(CIDNumber, CIDName, #kapps_call{}=Call) when is_binary(CIDNumber) @@ -771,11 +771,11 @@ set_callee_id(CIDNumber, CIDName, #kapps_call{}=Call) }. -endif. --spec callee_id(call()) -> {ne_binary(), ne_binary()}. +-spec callee_id(call()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. callee_id(Call) -> {callee_id_number(Call), callee_id_name(Call)}. --spec set_callee_id_name(ne_binary(), call()) -> call(). +-spec set_callee_id_name(kz_term:ne_binary(), call()) -> call(). -ifdef(TEST). set_callee_id_name(CIDName, Call) -> Call#kapps_call{callee_id_name=CIDName}. @@ -789,7 +789,7 @@ set_callee_id_name(CIDName, #kapps_call{}=Call) when is_binary(CIDName) -> callee_id_name(#kapps_call{callee_id_name='undefined'}) -> <<>>; callee_id_name(#kapps_call{callee_id_name=CIDName}) -> CIDName. --spec set_callee_id_number(ne_binary(), call()) -> call(). +-spec set_callee_id_number(kz_term:ne_binary(), call()) -> call(). -ifdef(TEST). set_callee_id_number(CIDNumber, Call) -> Call#kapps_call{callee_id_number=CIDNumber}. @@ -803,7 +803,7 @@ set_callee_id_number(CIDNumber, #kapps_call{}=Call) when is_binary(CIDNumber) -> callee_id_number(#kapps_call{callee_id_number='undefined'}) -> <<>>; callee_id_number(#kapps_call{callee_id_number=CIDNumber}) -> CIDNumber. --spec set_request(ne_binary(), call()) -> call(). +-spec set_request(kz_term:ne_binary(), call()) -> call(). set_request(Request, #kapps_call{}=Call) when is_binary(Request) -> [RequestUser, RequestRealm] = binary:split(Request, <<"@">>), Call#kapps_call{request=Request @@ -819,11 +819,11 @@ to_e164(Number) -> knm_converters:normalize(Number). -endif. --spec request(call()) -> ne_binary(). +-spec request(call()) -> kz_term:ne_binary(). request(#kapps_call{request=Request}) -> Request. --spec request_user(call()) -> ne_binary(). +-spec request_user(call()) -> kz_term:ne_binary(). request_user(#kapps_call{request=?NO_USER_REALM ,request_user=RequestUser }) -> @@ -836,7 +836,7 @@ request_user(#kapps_call{request=Request request_user(#kapps_call{request_user=RequestUser}) -> RequestUser. --spec request_realm(call()) -> ne_binary(). +-spec request_realm(call()) -> kz_term:ne_binary(). request_realm(#kapps_call{request=?NO_USER_REALM ,request_realm=RequestRealm }) -> @@ -849,7 +849,7 @@ request_realm(#kapps_call{request=Request request_realm(#kapps_call{request_realm=RequestRealm}) -> RequestRealm. --spec set_from(ne_binary(), call()) -> call(). +-spec set_from(kz_term:ne_binary(), call()) -> call(). set_from(From, #kapps_call{}=Call) when is_binary(From) -> [FromUser, FromRealm] = binary:split(From, <<"@">>), Call#kapps_call{from=From @@ -857,11 +857,11 @@ set_from(From, #kapps_call{}=Call) when is_binary(From) -> ,from_realm=FromRealm }. --spec from(call()) -> ne_binary(). +-spec from(call()) -> kz_term:ne_binary(). from(#kapps_call{from=From}) -> From. --spec from_user(call()) -> ne_binary(). +-spec from_user(call()) -> kz_term:ne_binary(). from_user(#kapps_call{from=?NO_USER_REALM ,from_user=FromUser }) -> @@ -874,7 +874,7 @@ from_user(#kapps_call{from=From from_user(#kapps_call{from_user=FromUser}) -> FromUser. --spec from_realm(call()) -> ne_binary(). +-spec from_realm(call()) -> kz_term:ne_binary(). from_realm(#kapps_call{from=?NO_USER_REALM ,from_realm=FromRealm }) -> @@ -887,7 +887,7 @@ from_realm(#kapps_call{from=From from_realm(#kapps_call{from_realm=FromRealm}) -> FromRealm. --spec set_to(ne_binary(), call()) -> call(). +-spec set_to(kz_term:ne_binary(), call()) -> call(). set_to(To, #kapps_call{}=Call) when is_binary(To) -> [ToUser, ToRealm] = binary:split(To, <<"@">>), Call#kapps_call{to=To @@ -895,11 +895,11 @@ set_to(To, #kapps_call{}=Call) when is_binary(To) -> ,to_realm=ToRealm }. --spec to(call()) -> ne_binary(). +-spec to(call()) -> kz_term:ne_binary(). to(#kapps_call{to=To}) -> To. --spec to_user(call()) -> ne_binary(). +-spec to_user(call()) -> kz_term:ne_binary(). to_user(#kapps_call{to=?NO_USER_REALM ,to_user=ToUser }) -> @@ -912,7 +912,7 @@ to_user(#kapps_call{to=To to_user(#kapps_call{to_user=ToUser}) -> ToUser. --spec to_realm(call()) -> ne_binary(). +-spec to_realm(call()) -> kz_term:ne_binary(). to_realm(#kapps_call{to=?NO_USER_REALM ,to_realm=ToRealm }) -> @@ -925,15 +925,15 @@ to_realm(#kapps_call{to=To to_realm(#kapps_call{to_realm=ToRealm}) -> ToRealm. --spec set_switch_hostname(ne_binary(), call()) -> call(). +-spec set_switch_hostname(kz_term:ne_binary(), call()) -> call(). set_switch_hostname(<<_/binary>> = Srv, #kapps_call{}=Call) -> Call#kapps_call{switch_hostname=Srv}. --spec switch_hostname(call()) -> api_binary(). +-spec switch_hostname(call()) -> kz_term:api_binary(). switch_hostname(#kapps_call{switch_hostname=Srv}) -> Srv. --spec set_switch_nodename(ne_binary(), call()) -> call(). +-spec set_switch_nodename(kz_term:ne_binary(), call()) -> call(). set_switch_nodename(Srv, #kapps_call{}=Call) -> Call#kapps_call{switch_nodename=Srv}. @@ -941,7 +941,7 @@ set_switch_nodename(Srv, #kapps_call{}=Call) -> switch_nodename(#kapps_call{switch_nodename=Srv}) -> Srv. --spec set_switch_url(ne_binary(), call()) -> call(). +-spec set_switch_url(kz_term:ne_binary(), call()) -> call(). set_switch_url(Srv, #kapps_call{}=Call) -> Call#kapps_call{switch_url=Srv}. @@ -949,7 +949,7 @@ set_switch_url(Srv, #kapps_call{}=Call) -> switch_url(#kapps_call{switch_url=Srv}) -> Srv. --spec set_switch_uri(ne_binary(), call()) -> call(). +-spec set_switch_uri(kz_term:ne_binary(), call()) -> call(). set_switch_uri(Srv, #kapps_call{}=Call) -> Call#kapps_call{switch_uri=Srv}. @@ -957,34 +957,34 @@ set_switch_uri(Srv, #kapps_call{}=Call) -> switch_uri(#kapps_call{switch_uri=Srv}) -> Srv. --spec set_inception(api_binary(), call()) -> call(). +-spec set_inception(kz_term:api_binary(), call()) -> call(). set_inception('undefined', #kapps_call{}=Call) -> Call#kapps_call{inception='undefined'}; set_inception(Inception, #kapps_call{}=Call) -> set_custom_channel_var(<<"Inception">>, Inception, Call#kapps_call{inception=Inception}). --spec inception(call()) -> api_binary(). +-spec inception(call()) -> kz_term:api_binary(). inception(#kapps_call{inception=Inception}) -> Inception. --spec set_resource_type(api_binary(), call()) -> call(). +-spec set_resource_type(kz_term:api_binary(), call()) -> call(). set_resource_type('undefined', #kapps_call{}=Call) -> Call#kapps_call{resource_type='undefined'}; set_resource_type(ResourceType, #kapps_call{}=Call) -> insert_custom_channel_var(<<"Resource-Type">>, ResourceType, Call#kapps_call{resource_type=ResourceType}). --spec resource_type(call()) -> api_ne_binary(). +-spec resource_type(call()) -> kz_term:api_ne_binary(). resource_type(#kapps_call{resource_type=ResourceType}) -> ResourceType. --spec set_account_db(ne_binary(), call()) -> call(). +-spec set_account_db(kz_term:ne_binary(), call()) -> call(). set_account_db(<<_/binary>> = AccountDb, #kapps_call{}=Call) -> AccountId = kz_util:format_account_id(AccountDb, 'raw'), set_custom_channel_var(<<"Account-ID">>, AccountId, Call#kapps_call{account_db=AccountDb ,account_id=AccountId }). --spec account_db(call()) -> api_ne_binary(). +-spec account_db(call()) -> kz_term:api_ne_binary(). account_db(#kapps_call{account_db='undefined' ,account_id='undefined' }) -> 'undefined'; @@ -995,39 +995,39 @@ account_db(#kapps_call{account_db='undefined' account_db(#kapps_call{account_db=AccountDb}) -> AccountDb. --spec set_account_id(ne_binary(), call()) -> call(). +-spec set_account_id(kz_term:ne_binary(), call()) -> call(). set_account_id(<<_/binary>> = AccountId, #kapps_call{}=Call) -> AccountDb = kz_util:format_account_id(AccountId, 'encoded'), set_custom_channel_var(<<"Account-ID">>, AccountId, Call#kapps_call{account_db=AccountDb ,account_id=AccountId }). --spec account_id(call()) -> api_binary(). +-spec account_id(call()) -> kz_term:api_binary(). account_id(#kapps_call{account_id=AccountId}) -> AccountId. --spec account_realm(call()) -> ne_binary(). +-spec account_realm(call()) -> kz_term:ne_binary(). account_realm(#kapps_call{account_id=AccountId}) -> {'ok', Doc} = kz_account:fetch(AccountId), kz_account:realm(Doc). --spec set_authorizing_id(ne_binary(), call()) -> call(). +-spec set_authorizing_id(kz_term:ne_binary(), call()) -> call(). set_authorizing_id(AuthorizingId, #kapps_call{}=Call) when is_binary(AuthorizingId) -> set_custom_channel_var(<<"Authorizing-ID">>, AuthorizingId, Call#kapps_call{authorizing_id=AuthorizingId}). --spec authorizing_id(call()) -> api_binary(). +-spec authorizing_id(call()) -> kz_term:api_binary(). authorizing_id(#kapps_call{authorizing_id=AuthorizingId}) -> AuthorizingId. --spec set_authorizing_type(ne_binary(), call()) -> call(). +-spec set_authorizing_type(kz_term:ne_binary(), call()) -> call(). set_authorizing_type(AuthorizingType, #kapps_call{}=Call) when is_binary(AuthorizingType) -> set_custom_channel_var(<<"Authorizing-Type">>, AuthorizingType, Call#kapps_call{authorizing_type=AuthorizingType}). --spec authorizing_type(call()) -> api_binary(). +-spec authorizing_type(call()) -> kz_term:api_binary(). authorizing_type(#kapps_call{authorizing_type=AuthorizingType}) -> AuthorizingType. --spec set_authorization(ne_binary(), ne_binary(), call()) -> call(). +-spec set_authorization(kz_term:ne_binary(), kz_term:ne_binary(), call()) -> call(). set_authorization(AuthorizingType, AuthorizingId, #kapps_call{}=Call) when is_binary(AuthorizingType) andalso is_binary(AuthorizingId) -> @@ -1039,32 +1039,32 @@ set_authorization(AuthorizingType, AuthorizingId, #kapps_call{}=Call) } ). --spec set_owner_id(ne_binary(), call()) -> call(). +-spec set_owner_id(kz_term:ne_binary(), call()) -> call(). set_owner_id(OwnerId, #kapps_call{}=Call) when is_binary(OwnerId) -> set_custom_channel_var(<<"Owner-ID">>, OwnerId, Call#kapps_call{owner_id=OwnerId}). --spec owner_id(call()) -> api_binary(). +-spec owner_id(call()) -> kz_term:api_binary(). owner_id(#kapps_call{owner_id=OwnerId}) -> OwnerId. --spec set_fetch_id(ne_binary(), call()) -> call(). +-spec set_fetch_id(kz_term:ne_binary(), call()) -> call(). set_fetch_id(FetchId, #kapps_call{}=Call) when is_binary(FetchId) -> set_custom_channel_var(<<"Fetch-Id">>, FetchId, Call#kapps_call{fetch_id=FetchId}). --spec fetch_id(call()) -> api_binary(). +-spec fetch_id(call()) -> kz_term:api_binary(). fetch_id(#kapps_call{fetch_id=FetchId}) -> FetchId. --spec set_bridge_id(ne_binary(), call()) -> call(). +-spec set_bridge_id(kz_term:ne_binary(), call()) -> call(). set_bridge_id(BridgeId, #kapps_call{}=Call) when is_binary(BridgeId) -> set_custom_channel_var(<<"Bridge-Id">>, BridgeId, Call#kapps_call{bridge_id=BridgeId}). --spec bridge_id(call()) -> api_binary(). +-spec bridge_id(call()) -> kz_term:api_binary(). bridge_id(#kapps_call{bridge_id=BridgeId}) -> BridgeId. --spec set_language(ne_binary(), call()) -> call(). +-spec set_language(kz_term:ne_binary(), call()) -> call(). set_language(Language, #kapps_call{}=Call) when is_binary(Language) -> Call#kapps_call{language=Language}. --spec language(call()) -> api_binary(). +-spec language(call()) -> kz_term:api_binary(). -ifdef(TEST). language(#kapps_call{language=L}) -> L. -else. @@ -1073,8 +1073,8 @@ language(#kapps_call{language='undefined', account_id=AccountId}) -> language(#kapps_call{language=Language}) -> Language. -endif. --spec get_prompt(call(), ne_binary()) -> api_ne_binary(). --spec get_prompt(call(), ne_binary(), api_ne_binary()) -> api_ne_binary(). +-spec get_prompt(call(), kz_term:ne_binary()) -> kz_term:api_ne_binary(). +-spec get_prompt(call(), kz_term:ne_binary(), kz_term:api_ne_binary()) -> kz_term:api_ne_binary(). get_prompt(#kapps_call{}=Call, Media) -> get_prompt(Call, Media, language(Call)). @@ -1083,23 +1083,23 @@ get_prompt(Call, Media, 'undefined') -> get_prompt(Call, Media, Language) -> kz_media_util:get_prompt(Media, Language, account_id(Call)). --spec set_to_tag(ne_binary(), call()) -> call(). +-spec set_to_tag(kz_term:ne_binary(), call()) -> call(). set_to_tag(ToTag, #kapps_call{}=Call) when is_binary(ToTag) -> Call#kapps_call{to_tag=ToTag}. --spec to_tag(call()) -> api_binary(). +-spec to_tag(call()) -> kz_term:api_binary(). to_tag(#kapps_call{to_tag=ToTag}) -> ToTag. --spec set_from_tag(ne_binary(), call()) -> call(). +-spec set_from_tag(kz_term:ne_binary(), call()) -> call(). set_from_tag(FromTag, #kapps_call{}=Call) when is_binary(FromTag) -> Call#kapps_call{from_tag=FromTag}. --spec from_tag(call()) -> api_binary(). +-spec from_tag(call()) -> kz_term:api_binary(). from_tag(#kapps_call{from_tag=FromTag}) -> FromTag. --spec direction(call()) -> ne_binary(). +-spec direction(call()) -> kz_term:ne_binary(). direction(#kapps_call{direction=Direction}) -> Direction. @@ -1150,7 +1150,7 @@ set_custom_channel_var(Key, Value, Call) -> insert_custom_channel_var(Key, Value, #kapps_call{ccvs=CCVs}=Call) -> handle_ccvs_update(kz_json:set_value(Key, Value, CCVs), Call). --spec set_custom_channel_vars(kz_proplist(), call()) -> call(). +-spec set_custom_channel_vars(kz_term:proplist(), call()) -> call(). -ifdef(TEST). set_custom_channel_vars(Props, #kapps_call{ccvs=CCVs}=Call) -> NewCCVs = kz_json:set_values(Props, CCVs), @@ -1163,7 +1163,7 @@ set_custom_channel_vars(Props, #kapps_call{ccvs=CCVs}=Call) -> handle_ccvs_update(NewCCVs, Call). --spec maybe_update_call_ccvs(call(), kz_proplist(), kz_proplist()) -> 'ok'. +-spec maybe_update_call_ccvs(call(), kz_term:proplist(), kz_term:proplist()) -> 'ok'. maybe_update_call_ccvs(Call, NewCCVs, ExistingCCVs) -> case updateable_ccvs(NewCCVs, ExistingCCVs) of [] -> 'ok'; @@ -1172,7 +1172,7 @@ maybe_update_call_ccvs(Call, NewCCVs, ExistingCCVs) -> -endif. --spec updateable_ccvs(kz_proplist(), kz_proplist()) -> kz_proplist(). +-spec updateable_ccvs(kz_term:proplist(), kz_term:proplist()) -> kz_term:proplist(). updateable_ccvs(New, Existing) -> New -- Existing. @@ -1223,7 +1223,7 @@ custom_sip_header(Key, #kapps_call{}=Call) -> custom_sip_header(Key, Default, #kapps_call{sip_headers=SHs}) -> kz_json:get_value(Key, SHs, Default). --spec set_custom_sip_headers(kz_proplist(), call()) -> call(). +-spec set_custom_sip_headers(kz_term:proplist(), call()) -> call(). set_custom_sip_headers(Headers, #kapps_call{sip_headers=SHs}=Call) -> Call#kapps_call{sip_headers=kz_json:set_values(Headers, SHs)}. @@ -1290,7 +1290,7 @@ kvs_find(Key, #kapps_call{kvs=Dict}) -> -spec kvs_fold(fun((any(), any(), any()) -> any()), any(), call()) -> call(). kvs_fold(Fun, Acc0, #kapps_call{kvs=Dict}) -> orddict:fold(Fun, Acc0, Dict). --spec kvs_from_proplist(kz_proplist(), call()) -> call(). +-spec kvs_from_proplist(kz_term:proplist(), call()) -> call(). kvs_from_proplist(List, #kapps_call{kvs=Dict}=Call) -> L = orddict:from_list([{kz_term:to_binary(K), V} || {K, V} <- List]), Call#kapps_call{kvs=orddict:merge(fun(_, V1, _) -> V1 end, L, Dict)}. @@ -1307,13 +1307,13 @@ kvs_map(Pred, #kapps_call{kvs=Dict}=Call) -> kvs_store(Key, Value, #kapps_call{kvs=Dict}=Call) -> Call#kapps_call{kvs=orddict:store(kz_term:to_binary(Key), Value, Dict)}. --spec kvs_store_proplist(kz_proplist(), call()) -> call(). +-spec kvs_store_proplist(kz_term:proplist(), call()) -> call(). kvs_store_proplist(List, #kapps_call{kvs=Dict}=Call) -> Call#kapps_call{kvs=lists:foldr(fun({K, V}, D) -> orddict:store(kz_term:to_binary(K), V, D) end, Dict, List)}. --spec kvs_to_proplist(call()) -> kz_proplist(). +-spec kvs_to_proplist(call()) -> kz_term:proplist(). kvs_to_proplist(#kapps_call{kvs=Dict}) -> orddict:to_list(Dict). @@ -1329,8 +1329,8 @@ kvs_update(Key, Fun, Initial, #kapps_call{kvs=Dict}=Call) -> kvs_update_counter(Key, Number, #kapps_call{kvs=Dict}=Call) -> Call#kapps_call{kvs=orddict:update_counter(kz_term:to_binary(Key), Number, Dict)}. --spec set_dtmf_collection(api_binary(), call()) -> call(). --spec set_dtmf_collection(api_binary(), ne_binary(), call()) -> call(). +-spec set_dtmf_collection(kz_term:api_binary(), call()) -> call(). +-spec set_dtmf_collection(kz_term:api_binary(), kz_term:ne_binary(), call()) -> call(). set_dtmf_collection(DTMF, Call) -> set_dtmf_collection(DTMF, <<"default">>, Call). set_dtmf_collection('undefined', Collection, Call) -> @@ -1346,15 +1346,15 @@ set_dtmf_collection(DTMF, Collection, Call) -> ,Call ). --spec get_dtmf_collection(call()) -> api_binary(). --spec get_dtmf_collection(ne_binary(), call()) -> api_binary(). +-spec get_dtmf_collection(call()) -> kz_term:api_binary(). +-spec get_dtmf_collection(kz_term:ne_binary(), call()) -> kz_term:api_binary(). get_dtmf_collection(Call) -> get_dtmf_collection(<<"default">>, Call). get_dtmf_collection(Collection, Call) -> kz_json:get_value(Collection, kvs_fetch(<<"dtmf_collections">>, kz_json:new(), Call)). --spec add_to_dtmf_collection(ne_binary(), call()) -> call(). --spec add_to_dtmf_collection(ne_binary(), ne_binary(), call()) -> call(). +-spec add_to_dtmf_collection(kz_term:ne_binary(), call()) -> call(). +-spec add_to_dtmf_collection(kz_term:ne_binary(), kz_term:ne_binary(), call()) -> call(). add_to_dtmf_collection(DTMF, Call) -> add_to_dtmf_collection(DTMF, <<"default">>, Call). add_to_dtmf_collection(DTMF, Collection, Call) -> @@ -1368,8 +1368,8 @@ flush() -> kz_cache:flush_local(?KAPPS_CALL_CACHE). -spec cache(call()) -> 'ok'. --spec cache(call(), api_binary()) -> 'ok'. --spec cache(call(), api_binary(), pos_integer()) -> 'ok'. +-spec cache(call(), kz_term:api_binary()) -> 'ok'. +-spec cache(call(), kz_term:api_binary(), pos_integer()) -> 'ok'. cache(Call) -> cache(Call, 'undefined', 5 * ?SECONDS_IN_MINUTE). @@ -1381,10 +1381,10 @@ cache(#kapps_call{call_id=CallId}=Call, AppName, Expires) -> CacheProps = [{'expires', Expires}], kz_cache:store_local(?KAPPS_CALL_CACHE, {?MODULE, 'call', AppName, CallId}, Call, CacheProps). --spec retrieve(ne_binary()) -> +-spec retrieve(kz_term:ne_binary()) -> {'ok', call()} | {'error', 'not_found'}. --spec retrieve(ne_binary(), api_binary()) -> +-spec retrieve(kz_term:ne_binary(), kz_term:api_binary()) -> {'ok', call()} | {'error', 'not_found'}. @@ -1401,7 +1401,7 @@ retrieve(CallId, AppName) -> start_recording(Call) -> start_recording(kz_json:new(), Call). --spec start_recording(api_object(), call()) -> call(). +-spec start_recording(kz_term:api_object(), call()) -> call(). start_recording('undefined', Call) -> Call; start_recording(Data0, Call) -> Data = update_recording_id(Data0), @@ -1439,13 +1439,13 @@ stop_recording(OriginalCall) -> Call end. --spec store_recording(ne_binary(), pid(), call()) -> call(). +-spec store_recording(kz_term:ne_binary(), pid(), call()) -> call(). store_recording(MediaName, Pid, Call) -> Q = queue:in({MediaName, Pid}, get_recordings(Call)), kvs_store(?RECORDINGS_KEY, Q, Call). --type recording_ref() :: {ne_binary(), pid()}. +-type recording_ref() :: {kz_term:ne_binary(), pid()}. -type store_return() :: {'ok', recording_ref(), call()} | {'empty', call()}. -spec retrieve_recording(call()) -> store_return(). @@ -1465,7 +1465,7 @@ get_recordings(Call) -> Q -> Q end. --spec inception_type(call()) -> api_binary(). +-spec inception_type(call()) -> kz_term:api_binary(). inception_type(#kapps_call{inception='undefined'}) -> <<"onnet">>; inception_type(#kapps_call{}) -> <<"offnet">>. @@ -1473,7 +1473,7 @@ inception_type(#kapps_call{}) -> <<"offnet">>. is_inter_account(#kapps_call{}=Call) -> inter_account_id(Call) /= 'undefined'. --spec inter_account_id(call()) -> api_binary(). +-spec inter_account_id(call()) -> kz_term:api_binary(). inter_account_id(#kapps_call{}=Call) -> custom_channel_var(<<"Inception-Account-ID">>, Call). diff --git a/core/kazoo_call/src/kapps_call_command.erl b/core/kazoo_call/src/kapps_call_command.erl index 75da4fbe118..42bc0a35676 100644 --- a/core/kazoo_call/src/kapps_call_command.erl +++ b/core/kazoo_call/src/kapps_call_command.erl @@ -211,22 +211,22 @@ ,hold_control_command/1, hold_control_command/2 ]). --type audio_macro_prompt() :: {'play', binary()} | {'play', binary(), binaries()} | - {'prompt', binary()} | {'prompt', binary(), ne_binaries()} | +-type audio_macro_prompt() :: {'play', binary()} | {'play', binary(), kz_term:binaries()} | + {'prompt', binary()} | {'prompt', binary(), kz_term:ne_binaries()} | {'say', binary()} | {'say', binary(), binary()} | {'say', binary(), binary(), binary()} | {'say', binary(), binary(), binary(), binary()} | {'tones', kz_json:objects()} | - {'tts', ne_binary()} | - {'tts', ne_binary(), ne_binary()} | - {'tts', ne_binary(), ne_binary(), ne_binary()}. + {'tts', kz_term:ne_binary()} | + {'tts', kz_term:ne_binary(), kz_term:ne_binary()} | + {'tts', kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()}. -type audio_macro_prompts() :: [audio_macro_prompt()]. -export_type([audio_macro_prompt/0 ,audio_macro_prompts/0 ,store_fun/0 ]). --type store_fun() :: ne_binary() | fun(() -> ne_binary()). +-type store_fun() :: kz_term:ne_binary() | fun(() -> kz_term:ne_binary()). -define(CONFIG_CAT, <<"call_command">>). @@ -263,11 +263,11 @@ default_message_timeout() -> default_application_timeout() -> ?DEFAULT_APPLICATION_TIMEOUT. --spec storage_timeout(ne_binary()) -> pos_integer(). +-spec storage_timeout(kz_term:ne_binary()) -> pos_integer(). storage_timeout(App) -> ?STORAGE_TIMEOUT(App). --spec storage_retries(ne_binary()) -> pos_integer(). +-spec storage_retries(kz_term:ne_binary()) -> pos_integer(). storage_retries(App) -> ?STORAGE_RETRIES(App). @@ -276,10 +276,10 @@ storage_retries(App) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec presence(ne_binary(), ne_binary() | kapps_call:call()) -> 'ok'. --spec presence(ne_binary(), ne_binary(), api_binary() | kapps_call:call()) -> 'ok'. --spec presence(ne_binary(), ne_binary() , api_binary() , kapps_call:call() | 'undefined') -> 'ok'. --spec presence(ne_binary(), ne_binary() , api_binary() , api_binary(), kapps_call:call() | 'undefined') -> 'ok'. +-spec presence(kz_term:ne_binary(), kz_term:ne_binary() | kapps_call:call()) -> 'ok'. +-spec presence(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary() | kapps_call:call()) -> 'ok'. +-spec presence(kz_term:ne_binary(), kz_term:ne_binary() , kz_term:api_binary() , kapps_call:call() | 'undefined') -> 'ok'. +-spec presence(kz_term:ne_binary(), kz_term:ne_binary() , kz_term:api_binary() , kz_term:api_binary(), kapps_call:call() | 'undefined') -> 'ok'. presence(State, <<_/binary>> = PresenceId) -> presence(State, PresenceId, 'undefined'); presence(State, Call) -> @@ -343,7 +343,7 @@ presence(State, PresenceId, CallId, TargetURI, Call) -> ]), kapi_presence:publish_update(Command). --spec module_as_app( kapps_call:call() ) -> ne_binary(). +-spec module_as_app( kapps_call:call() ) -> kz_term:ne_binary(). module_as_app(Call) -> JObj = kapps_call:kvs_fetch(<<"cf_flow">>, kz_json:new(), Call), kz_json:get_value(<<"module">>, JObj, ?APP_NAME). @@ -357,7 +357,7 @@ module_as_app(Call) -> %%-------------------------------------------------------------------- -spec channel_status(kapps_call:call()) -> 'ok' | {'error', 'no_channel_id'}. --spec channel_status(api_binary(), api_binary()) -> +-spec channel_status(kz_term:api_binary(), kz_term:api_binary()) -> 'ok' | {'error', 'no_channel_id'}. channel_status('undefined', _) -> {'error', 'no_channel_id'}; channel_status(CallId, SrvQueue) when is_binary(CallId), is_binary(SrvQueue) -> @@ -367,8 +367,8 @@ channel_status(CallId, SrvQueue) when is_binary(CallId), is_binary(SrvQueue) -> channel_status(Call, SrvQueue) -> channel_status(kapps_call:call_id(Call), SrvQueue). --spec channel_status_command(ne_binary() | kapps_call:call()) -> kz_proplist(). --spec channel_status_command(ne_binary() | kapps_call:call(), api_boolean()) -> kz_proplist(). +-spec channel_status_command(kz_term:ne_binary() | kapps_call:call()) -> kz_term:proplist(). +-spec channel_status_command(kz_term:ne_binary() | kapps_call:call(), kz_term:api_boolean()) -> kz_term:proplist(). channel_status_command(CallId) -> channel_status_command(CallId, 'undefined'). channel_status_command(<<_/binary>> = CallId, ActiveOnly) -> @@ -383,7 +383,7 @@ channel_status(Call) -> 'true' = kapps_call:is_call(Call), channel_status(kapps_call:call_id(Call), kapps_call:controller_queue(Call)). --spec b_channel_status(api_binary() | kapps_call:call()) -> +-spec b_channel_status(kz_term:api_binary() | kapps_call:call()) -> kapps_api_std_return(). b_channel_status('undefined') -> {'error', 'no_channel_id'}; b_channel_status(ChannelId) when is_binary(ChannelId) -> @@ -426,10 +426,10 @@ relay_event(Pid, JObj) -> relay_event(Pid, JObj, RelayFun) -> RelayFun(Pid, {'amqp_msg', JObj}). --spec receive_event(kz_timeout()) -> +-spec receive_event(timeout()) -> {'ok', kz_json:object()} | {'error', 'timeout'}. --spec receive_event(kz_timeout(), boolean()) -> +-spec receive_event(timeout(), boolean()) -> {'ok', kz_json:object()} | {'other', kz_json:object() | any()} | {'error', 'timeout'}. @@ -447,7 +447,7 @@ receive_event(Timeout, IgnoreOthers) -> end. -spec audio_macro(audio_macro_prompts(), kapps_call:call()) -> - ne_binary(). + kz_term:ne_binary(). -spec audio_macro(audio_macro_prompts(), kapps_call:call(), kz_json:objects()) -> binary(). audio_macro([], Call) -> noop(Call); @@ -518,14 +518,14 @@ audio_macro([{'tts', Text, Voice, Lang, Engine}|T], Call, Queue) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec response(ne_binary(), kapps_call:call()) -> - {'ok', ne_binary()} | +-spec response(kz_term:ne_binary(), kapps_call:call()) -> + {'ok', kz_term:ne_binary()} | {'error', 'no_response'}. --spec response(ne_binary(), api_binary(), kapps_call:call()) -> - {'ok', ne_binary()} | +-spec response(kz_term:ne_binary(), kz_term:api_binary(), kapps_call:call()) -> + {'ok', kz_term:ne_binary()} | {'error', 'no_response'}. --spec response(ne_binary(), api_binary(), api_binary(), kapps_call:call()) -> - {'ok', ne_binary()} | +-spec response(kz_term:ne_binary(), kz_term:api_binary(), kz_term:api_binary(), kapps_call:call()) -> + {'ok', kz_term:ne_binary()} | {'error', 'no_response'}. response(Code, Call) -> response(Code, 'undefined', Call). @@ -539,11 +539,11 @@ response(Code, Cause, Media, Call) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec pickup(ne_binary(), kapps_call:call()) -> 'ok'. --spec pickup(ne_binary(), api_binary(), kapps_call:call()) -> 'ok'. --spec pickup(ne_binary(), api_binary(), boolean(), kapps_call:call()) -> 'ok'. --spec pickup(ne_binary(), api_binary(), boolean(), boolean(), kapps_call:call()) -> 'ok'. --spec pickup(ne_binary(), api_binary(), boolean(), boolean(), boolean(), kapps_call:call()) -> 'ok'. +-spec pickup(kz_term:ne_binary(), kapps_call:call()) -> 'ok'. +-spec pickup(kz_term:ne_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. +-spec pickup(kz_term:ne_binary(), kz_term:api_binary(), boolean(), kapps_call:call()) -> 'ok'. +-spec pickup(kz_term:ne_binary(), kz_term:api_binary(), boolean(), boolean(), kapps_call:call()) -> 'ok'. +-spec pickup(kz_term:ne_binary(), kz_term:api_binary(), boolean(), boolean(), boolean(), kapps_call:call()) -> 'ok'. pickup(TargetCallId, Call) -> Command = pickup_command(TargetCallId, Call), @@ -565,11 +565,11 @@ pickup(TargetCallId, Insert, ContinueOnFail, ContinueOnCancel, ParkAfterPickup, Command = pickup_command(TargetCallId, Insert, ContinueOnFail, ContinueOnCancel, ParkAfterPickup, Call), send_command(Command, Call). --spec pickup_command(ne_binary(), kapps_call:call()) -> kz_proplist(). --spec pickup_command(ne_binary(), ne_binary(), kapps_call:call()) -> kz_proplist(). --spec pickup_command(ne_binary(), ne_binary(), boolean(), kapps_call:call()) -> kz_proplist(). --spec pickup_command(ne_binary(), ne_binary(), boolean(), boolean(), kapps_call:call()) -> kz_proplist(). --spec pickup_command(ne_binary(), ne_binary(), boolean(), boolean(), boolean(), kapps_call:call()) -> kz_proplist(). +-spec pickup_command(kz_term:ne_binary(), kapps_call:call()) -> kz_term:proplist(). +-spec pickup_command(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> kz_term:proplist(). +-spec pickup_command(kz_term:ne_binary(), kz_term:ne_binary(), boolean(), kapps_call:call()) -> kz_term:proplist(). +-spec pickup_command(kz_term:ne_binary(), kz_term:ne_binary(), boolean(), boolean(), kapps_call:call()) -> kz_term:proplist(). +-spec pickup_command(kz_term:ne_binary(), kz_term:ne_binary(), boolean(), boolean(), boolean(), kapps_call:call()) -> kz_term:proplist(). pickup_command(TargetCallId, Call) -> pickup_command(TargetCallId, <<"tail">>, Call). pickup_command(TargetCallId, Insert, Call) -> @@ -588,15 +588,15 @@ pickup_command(TargetCallId, Insert, ContinueOnFail, ContinueOnCancel, ParkAfter ,{<<"Call-ID">>, kapps_call:call_id(Call)} ]. --spec b_pickup(ne_binary(), kapps_call:call()) -> +-spec b_pickup(kz_term:ne_binary(), kapps_call:call()) -> {'ok', kz_json:object()}. --spec b_pickup(ne_binary(), ne_binary(), kapps_call:call()) -> +-spec b_pickup(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> {'ok', kz_json:object()}. --spec b_pickup(ne_binary(), ne_binary(), boolean(), kapps_call:call()) -> +-spec b_pickup(kz_term:ne_binary(), kz_term:ne_binary(), boolean(), kapps_call:call()) -> {'ok', kz_json:object()}. --spec b_pickup(ne_binary(), ne_binary(), boolean(), boolean(), kapps_call:call()) -> +-spec b_pickup(kz_term:ne_binary(), kz_term:ne_binary(), boolean(), boolean(), kapps_call:call()) -> {'ok', kz_json:object()}. --spec b_pickup(ne_binary(), ne_binary(), boolean(), boolean(), boolean(), kapps_call:call()) -> +-spec b_pickup(kz_term:ne_binary(), kz_term:ne_binary(), boolean(), boolean(), boolean(), kapps_call:call()) -> {'ok', kz_json:object()}. b_pickup(TargetCallId, Call) -> pickup(TargetCallId, Call), @@ -619,11 +619,11 @@ b_pickup(TargetCallId, Insert, ContinueOnFail, ContinueOnCancel, ParkAfterPickup %% @doc %% @end %%-------------------------------------------------------------------- --spec connect_leg(ne_binary(), kapps_call:call()) -> 'ok'. --spec connect_leg(ne_binary(), api_binary(), kapps_call:call()) -> 'ok'. --spec connect_leg(ne_binary(), api_binary(), boolean(), kapps_call:call()) -> 'ok'. --spec connect_leg(ne_binary(), api_binary(), boolean(), boolean(), kapps_call:call()) -> 'ok'. --spec connect_leg(ne_binary(), api_binary(), boolean(), boolean(), boolean(), kapps_call:call()) -> 'ok'. +-spec connect_leg(kz_term:ne_binary(), kapps_call:call()) -> 'ok'. +-spec connect_leg(kz_term:ne_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. +-spec connect_leg(kz_term:ne_binary(), kz_term:api_binary(), boolean(), kapps_call:call()) -> 'ok'. +-spec connect_leg(kz_term:ne_binary(), kz_term:api_binary(), boolean(), boolean(), kapps_call:call()) -> 'ok'. +-spec connect_leg(kz_term:ne_binary(), kz_term:api_binary(), boolean(), boolean(), boolean(), kapps_call:call()) -> 'ok'. connect_leg(TargetCallId, Call) -> Command = connect_leg_command(TargetCallId, Call), @@ -645,11 +645,11 @@ connect_leg(TargetCallId, Insert, ContinueOnFail, ContinueOnCancel, ParkAfterCon Command = connect_leg_command(TargetCallId, Insert, ContinueOnFail, ContinueOnCancel, ParkAfterConnect_Leg, Call), send_command(Command, Call). --spec connect_leg_command(ne_binary(), kapps_call:call()) -> kz_proplist(). --spec connect_leg_command(ne_binary(), ne_binary(), kapps_call:call()) -> kz_proplist(). --spec connect_leg_command(ne_binary(), ne_binary(), boolean(), kapps_call:call()) -> kz_proplist(). --spec connect_leg_command(ne_binary(), ne_binary(), boolean(), boolean(), kapps_call:call()) -> kz_proplist(). --spec connect_leg_command(ne_binary(), ne_binary(), boolean(), boolean(), boolean(), kapps_call:call()) -> kz_proplist(). +-spec connect_leg_command(kz_term:ne_binary(), kapps_call:call()) -> kz_term:proplist(). +-spec connect_leg_command(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> kz_term:proplist(). +-spec connect_leg_command(kz_term:ne_binary(), kz_term:ne_binary(), boolean(), kapps_call:call()) -> kz_term:proplist(). +-spec connect_leg_command(kz_term:ne_binary(), kz_term:ne_binary(), boolean(), boolean(), kapps_call:call()) -> kz_term:proplist(). +-spec connect_leg_command(kz_term:ne_binary(), kz_term:ne_binary(), boolean(), boolean(), boolean(), kapps_call:call()) -> kz_term:proplist(). connect_leg_command(TargetCallId, Call) -> connect_leg_command(TargetCallId, <<"tail">>, Call). connect_leg_command(TargetCallId, Insert, Call) -> @@ -668,15 +668,15 @@ connect_leg_command(TargetCallId, Insert, ContinueOnFail, ContinueOnCancel, Park ,{<<"Call-ID">>, kapps_call:call_id(Call)} ]. --spec b_connect_leg(ne_binary(), kapps_call:call()) -> +-spec b_connect_leg(kz_term:ne_binary(), kapps_call:call()) -> {'ok', kz_json:object()}. --spec b_connect_leg(ne_binary(), ne_binary(), kapps_call:call()) -> +-spec b_connect_leg(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> {'ok', kz_json:object()}. --spec b_connect_leg(ne_binary(), ne_binary(), boolean(), kapps_call:call()) -> +-spec b_connect_leg(kz_term:ne_binary(), kz_term:ne_binary(), boolean(), kapps_call:call()) -> {'ok', kz_json:object()}. --spec b_connect_leg(ne_binary(), ne_binary(), boolean(), boolean(), kapps_call:call()) -> +-spec b_connect_leg(kz_term:ne_binary(), kz_term:ne_binary(), boolean(), boolean(), kapps_call:call()) -> {'ok', kz_json:object()}. --spec b_connect_leg(ne_binary(), ne_binary(), boolean(), boolean(), boolean(), kapps_call:call()) -> +-spec b_connect_leg(kz_term:ne_binary(), kz_term:ne_binary(), boolean(), boolean(), boolean(), kapps_call:call()) -> {'ok', kz_json:object()}. b_connect_leg(TargetCallId, Call) -> connect_leg(TargetCallId, Call), @@ -700,11 +700,11 @@ b_connect_leg(TargetCallId, Insert, ContinueOnFail, ContinueOnCancel, ParkAfterP %% Create a redirect request to the Contact on Server %% @end %%-------------------------------------------------------------------- --spec redirect(ne_binary(), kapps_call:call()) -> 'ok'. +-spec redirect(kz_term:ne_binary(), kapps_call:call()) -> 'ok'. redirect(Contact, Call) -> redirect(Contact, 'undefined', Call). --spec redirect(ne_binary(), api_binary(), kapps_call:call()) -> 'ok'. +-spec redirect(kz_term:ne_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. redirect(Contact, Server, Call) -> lager:debug("redirect to ~s on ~s", [Contact, Server]), Command = [{<<"Redirect-Contact">>, Contact} @@ -721,7 +721,7 @@ redirect(Contact, Server, Call) -> %% Create a redirect request to Node %% @end %%-------------------------------------------------------------------- --spec redirect_to_node(ne_binary(), api_binary(), kapps_call:call()) -> 'ok'. +-spec redirect_to_node(kz_term:ne_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. redirect_to_node(Contact, Node, Call) -> lager:debug("redirect ~s to ~s", [Contact, Node]), Command = [{<<"Redirect-Contact">>, Contact} @@ -737,18 +737,18 @@ redirect_to_node(Contact, Node, Call) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec flush_dtmf(kapps_call:call()) -> ne_binary(). +-spec flush_dtmf(kapps_call:call()) -> kz_term:ne_binary(). flush_dtmf(Call) -> play(<<"silence_stream://50">>, Call). --spec send_dtmf(ne_binary(), kapps_call:call()) -> 'ok'. --spec send_dtmf(ne_binary(), api_binary(), kapps_call:call()) -> 'ok'. +-spec send_dtmf(kz_term:ne_binary(), kapps_call:call()) -> 'ok'. +-spec send_dtmf(kz_term:ne_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. send_dtmf(DTMFs, Call) -> send_dtmf(DTMFs, 'undefined', Call). send_dtmf(DTMFs, Duration, Call) -> Cmd = send_dtmf_command(DTMFs, Duration), send_command(Cmd, Call). --spec send_dtmf_command(ne_binary(), api_binary()) -> kz_proplist(). +-spec send_dtmf_command(kz_term:ne_binary(), kz_term:api_binary()) -> kz_term:proplist(). send_dtmf_command(DTMFs, Duration) -> props:filter_undefined( [{<<"DTMFs">>, DTMFs} @@ -756,12 +756,12 @@ send_dtmf_command(DTMFs, Duration) -> ,{<<"Application-Name">>, <<"send_dtmf">>} ]). --spec recv_dtmf(ne_binary(), kapps_call:call()) -> 'ok'. +-spec recv_dtmf(kz_term:ne_binary(), kapps_call:call()) -> 'ok'. recv_dtmf(DTMFs, Call) -> Cmd = recv_dtmf_command(DTMFs), send_command(Cmd, Call). --spec recv_dtmf_command(ne_binary()) -> kz_proplist(). +-spec recv_dtmf_command(kz_term:ne_binary()) -> kz_term:proplist(). recv_dtmf_command(DTMFs) -> props:filter_undefined( [{<<"DTMFs">>, DTMFs} @@ -776,8 +776,8 @@ recv_dtmf_command(DTMFs) -> %% can not be used to set system settings %% @end %%-------------------------------------------------------------------- --spec set(api_object(), api_object(), kapps_call:call()) -> 'ok'. --spec set(api_object(), api_object(), api_object(), kapps_call:call()) -> 'ok'. +-spec set(kz_term:api_object(), kz_term:api_object(), kapps_call:call()) -> 'ok'. +-spec set(kz_term:api_object(), kz_term:api_object(), kz_term:api_object(), kapps_call:call()) -> 'ok'. set(ChannelVars, CallVars, Call) -> set(ChannelVars, CallVars, 'undefined', Call). @@ -799,7 +799,7 @@ set(ChannelVars, CallVars, AppVars, Call) -> send_command(Command, Call) end. --spec set_terminators(api_binaries(), kapps_call:call()) -> 'ok'. +-spec set_terminators(kz_term:api_binaries(), kapps_call:call()) -> 'ok'. set_terminators(Terminators, Call) -> Command = [{<<"Application-Name">>, <<"set_terminators">>} ,{<<"Terminators">>, Terminators} @@ -863,12 +863,12 @@ b_ring(Call) -> %%-------------------------------------------------------------------- -spec receive_fax(kapps_call:call()) -> 'ok'. -spec receive_fax(boolean(), kapps_call:call()) -> 'ok'. --spec receive_fax(boolean() | api_binary() - ,boolean() | api_binary() +-spec receive_fax(boolean() | kz_term:api_binary() + ,boolean() | kz_term:api_binary() ,kapps_call:call()) -> 'ok'. --spec receive_fax(boolean() | api_binary() - ,boolean() | api_binary() - ,api_binary() +-spec receive_fax(boolean() | kz_term:api_binary() + ,boolean() | kz_term:api_binary() + ,kz_term:api_binary() ,kapps_call:call()) -> 'ok'. -spec b_receive_fax(kapps_call:call()) -> wait_for_fax_ret(). receive_fax(Call) -> @@ -893,7 +893,7 @@ b_receive_fax(Call) -> receive_fax(Call), wait_for_fax(). --spec get_default_t38_setting() -> boolean() | ne_binary(). +-spec get_default_t38_setting() -> boolean() | kz_term:ne_binary(). get_default_t38_setting() -> case kapps_config:get_ne_binary(<<"fax">>, <<"inbound_t38_default">>, <<"true">>) of <<"auto">> -> <<"auto">>; @@ -1001,25 +1001,25 @@ b_hangup('true', Call) -> %%-------------------------------------------------------------------- -spec page(kz_json:objects(), kapps_call:call()) -> 'ok'. -spec page(kz_json:objects(), integer(), kapps_call:call()) -> 'ok'. --spec page(kz_json:objects(), integer(), api_binary(), kapps_call:call()) -> 'ok'. --spec page(kz_json:objects(), integer(), api_binary(), api_binary(), kapps_call:call()) -> 'ok'. --spec page(kz_json:objects(), integer(), api_binary(), api_binary(), api_object(), kapps_call:call()) -> 'ok'. --spec page(kz_json:objects(), integer(), api_binary(), api_binary(), api_object(), api_object(), kapps_call:call()) -> 'ok'. --spec page(kz_json:objects(), integer(), api_binary(), api_binary(), api_object(), api_object(), api_object(), kapps_call:call()) -> 'ok'. +-spec page(kz_json:objects(), integer(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. +-spec page(kz_json:objects(), integer(), kz_term:api_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. +-spec page(kz_json:objects(), integer(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_object(), kapps_call:call()) -> 'ok'. +-spec page(kz_json:objects(), integer(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_object(), kz_term:api_object(), kapps_call:call()) -> 'ok'. +-spec page(kz_json:objects(), integer(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_object(), kz_term:api_object(), kz_term:api_object(), kapps_call:call()) -> 'ok'. -spec b_page(kz_json:objects(), kapps_call:call()) -> wait_for_application_return(). -spec b_page(kz_json:objects(), integer(), kapps_call:call()) -> wait_for_application_return(). --spec b_page(kz_json:objects(), integer(), api_binary(), kapps_call:call()) -> +-spec b_page(kz_json:objects(), integer(), kz_term:api_binary(), kapps_call:call()) -> wait_for_application_return(). --spec b_page(kz_json:objects(), integer(), api_binary(), api_binary(), kapps_call:call()) -> +-spec b_page(kz_json:objects(), integer(), kz_term:api_binary(), kz_term:api_binary(), kapps_call:call()) -> wait_for_application_return(). --spec b_page(kz_json:objects(), integer(), api_binary(), api_binary(), api_object(), kapps_call:call()) -> +-spec b_page(kz_json:objects(), integer(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_object(), kapps_call:call()) -> wait_for_application_return(). --spec b_page(kz_json:objects(), integer(), api_binary(), api_binary(), api_object(), api_object(), kapps_call:call()) -> +-spec b_page(kz_json:objects(), integer(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_object(), kz_term:api_object(), kapps_call:call()) -> wait_for_application_return(). --spec b_page(kz_json:objects(), integer(), api_binary(), api_binary(), api_object(), api_object(), api_object(), kapps_call:call()) -> +-spec b_page(kz_json:objects(), integer(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_object(), kz_term:api_object(), kz_term:api_object(), kapps_call:call()) -> wait_for_application_return(). page(Endpoints, Call) -> @@ -1070,28 +1070,28 @@ b_page(Endpoints, Timeout, CIDName, CIDNumber, SIPHeaders, CCVs, Options, Call) %%-------------------------------------------------------------------- -spec bridge(kz_json:objects(), kapps_call:call()) -> 'ok'. -spec bridge(kz_json:objects(), integer(), kapps_call:call()) -> 'ok'. --spec bridge(kz_json:objects(), integer(), api_binary(), kapps_call:call()) -> 'ok'. --spec bridge(kz_json:objects(), integer(), api_binary(), api_binary(), kapps_call:call()) -> 'ok'. --spec bridge(kz_json:objects(), integer(), api_binary(), api_binary(), api_binary(), kapps_call:call()) -> 'ok'. --spec bridge(kz_json:objects(), integer(), api_binary(), api_binary(), api_binary(), api_object(), kapps_call:call()) -> 'ok'. --spec bridge(kz_json:objects(), integer(), api_binary(), api_binary(), api_binary(), api_object(), api_binary(), kapps_call:call()) -> 'ok'. --spec bridge(kz_json:objects(), integer(), api_binary(), api_binary(), api_binary(), api_object(), api_binary(), api_binary(), kapps_call:call()) -> 'ok'. +-spec bridge(kz_json:objects(), integer(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. +-spec bridge(kz_json:objects(), integer(), kz_term:api_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. +-spec bridge(kz_json:objects(), integer(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. +-spec bridge(kz_json:objects(), integer(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_object(), kapps_call:call()) -> 'ok'. +-spec bridge(kz_json:objects(), integer(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_object(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. +-spec bridge(kz_json:objects(), integer(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_object(), kz_term:api_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. -spec b_bridge(kz_json:objects(), kapps_call:call()) -> kapps_api_bridge_return(). -spec b_bridge(kz_json:objects(), integer(), kapps_call:call()) -> kapps_api_bridge_return(). --spec b_bridge(kz_json:objects(), integer(), api_binary(), kapps_call:call()) -> +-spec b_bridge(kz_json:objects(), integer(), kz_term:api_binary(), kapps_call:call()) -> kapps_api_bridge_return(). --spec b_bridge(kz_json:objects(), integer(), api_binary(), api_binary(), kapps_call:call()) -> +-spec b_bridge(kz_json:objects(), integer(), kz_term:api_binary(), kz_term:api_binary(), kapps_call:call()) -> kapps_api_bridge_return(). --spec b_bridge(kz_json:objects(), integer(), api_binary(), api_binary(), api_binary(), kapps_call:call()) -> +-spec b_bridge(kz_json:objects(), integer(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kapps_call:call()) -> kapps_api_bridge_return(). --spec b_bridge(kz_json:objects(), integer(), api_binary(), api_binary(), api_binary(), api_object(), kapps_call:call()) -> +-spec b_bridge(kz_json:objects(), integer(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_object(), kapps_call:call()) -> kapps_api_bridge_return(). --spec b_bridge(kz_json:objects(), integer(), api_binary(), api_binary(), api_binary(), api_object(), api_binary(), kapps_call:call()) -> +-spec b_bridge(kz_json:objects(), integer(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_object(), kz_term:api_binary(), kapps_call:call()) -> kapps_api_bridge_return(). --spec b_bridge(kz_json:objects(), integer(), api_binary(), api_binary(), api_binary(), api_object(), api_binary(), api_binary(), kapps_call:call()) -> +-spec b_bridge(kz_json:objects(), integer(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_object(), kz_term:api_binary(), kz_term:api_binary(), kapps_call:call()) -> kapps_api_bridge_return(). bridge_command(Endpoints, Call) -> @@ -1177,8 +1177,8 @@ b_bridge_wait(Timeout, Call) -> wait_for_bridge((kz_term:to_integer(Timeout) * ?MILLISECONDS_IN_SECOND) + ?EXTRA_BRIDGE_TIMEOUT , Call). -spec unbridge(kapps_call:call()) -> 'ok'. --spec unbridge(kapps_call:call(), api_ne_binary()) -> 'ok'. --spec unbridge(kapps_call:call(), api_ne_binary(), ne_binary()) -> 'ok'. +-spec unbridge(kapps_call:call(), kz_term:api_ne_binary()) -> 'ok'. +-spec unbridge(kapps_call:call(), kz_term:api_ne_binary(), kz_term:ne_binary()) -> 'ok'. unbridge(Call) -> Command = unbridge_command(Call), send_command(Command, Call). @@ -1189,9 +1189,9 @@ unbridge(Call, Leg, Insert) -> Command = unbridge_command(Call, Leg, Insert), send_command(Command, Call). --spec unbridge_command(kapps_call:call()) -> kz_proplist(). --spec unbridge_command(kapps_call:call(), api_ne_binary()) -> kz_proplist(). --spec unbridge_command(kapps_call:call(), api_ne_binary(), ne_binary()) -> kz_proplist(). +-spec unbridge_command(kapps_call:call()) -> kz_term:proplist(). +-spec unbridge_command(kapps_call:call(), kz_term:api_ne_binary()) -> kz_term:proplist(). +-spec unbridge_command(kapps_call:call(), kz_term:api_ne_binary(), kz_term:ne_binary()) -> kz_term:proplist(). unbridge_command(Call) -> unbridge_command(Call, <<"Both">>). unbridge_command(Call, Leg) -> @@ -1204,19 +1204,19 @@ unbridge_command(Call, Leg, Insert) -> ]. -spec soft_hold(kapps_call:call()) -> 'ok'. --spec soft_hold(kapps_call:call(), api_binary()) -> 'ok'. +-spec soft_hold(kapps_call:call(), kz_term:api_binary()) -> 'ok'. soft_hold(Call) -> soft_hold(Call, <<"1">>). soft_hold(Call, UnholdKey) -> Command = soft_hold_command(kapps_call:call_id(Call), UnholdKey), send_command(Command, Call). --spec soft_hold_command(ne_binary(), ne_binary()) -> - kz_proplist(). --spec soft_hold_command(ne_binary(), ne_binary(), api_binary(), api_binary()) -> - kz_proplist(). --spec soft_hold_command(ne_binary(), ne_binary(), api_binary(), api_binary(), ne_binary()) -> - kz_proplist(). +-spec soft_hold_command(kz_term:ne_binary(), kz_term:ne_binary()) -> + kz_term:proplist(). +-spec soft_hold_command(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary(), kz_term:api_binary()) -> + kz_term:proplist(). +-spec soft_hold_command(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:ne_binary()) -> + kz_term:proplist(). soft_hold_command(CallId, UnholdKey) -> soft_hold_command(CallId, UnholdKey, 'undefined', 'undefined'). soft_hold_command(CallId, UnholdKey, AMOH, BMOH) -> @@ -1229,8 +1229,8 @@ soft_hold_command(CallId, UnholdKey, AMOH, BMOH, InsertAt) -> | build_moh_keys(AMOH, BMOH) ]). --spec build_moh_keys(api_binary(), api_binary()) -> - kz_proplist_kv(ne_binary(), api_binary()). +-spec build_moh_keys(kz_term:api_binary(), kz_term:api_binary()) -> + kz_term:proplist_kv(kz_term:ne_binary(), kz_term:api_binary()). build_moh_keys('undefiend', _) -> []; build_moh_keys(AMOH, BMOH) -> [{<<"A-MOH">>, AMOH} @@ -1244,18 +1244,18 @@ build_moh_keys(AMOH, BMOH) -> %% @end %%-------------------------------------------------------------------- -spec hold(kapps_call:call()) -> 'ok'. --spec hold(api_binary(), kapps_call:call()) -> 'ok'. +-spec hold(kz_term:api_binary(), kapps_call:call()) -> 'ok'. --spec hold_command(kapps_call:call() | ne_binary()) -> +-spec hold_command(kapps_call:call() | kz_term:ne_binary()) -> kz_json:object(). --spec hold_command(api_binary(), kapps_call:call() | ne_binary()) -> +-spec hold_command(kz_term:api_binary(), kapps_call:call() | kz_term:ne_binary()) -> kz_json:object(). -spec b_hold(kapps_call:call()) -> kapps_api_std_return(). --spec b_hold(kz_timeout() | api_binary(), kapps_call:call()) -> +-spec b_hold(timeout() | kz_term:api_binary(), kapps_call:call()) -> kapps_api_std_return(). --spec b_hold(kz_timeout(), api_binary(), kapps_call:call()) -> +-spec b_hold(timeout(), kz_term:api_binary(), kapps_call:call()) -> kapps_api_std_return(). hold(Call) -> hold('undefined', Call). @@ -1289,11 +1289,11 @@ b_hold(Timeout, MOH, Call) -> wait_for_message(Call, <<"hold">>, <<"CHANNEL_EXECUTE_COMPLETE">>, <<"call_event">>, Timeout). -spec hold_control(kapps_call:call()) -> 'ok'. --spec hold_control(api_binary(), kapps_call:call()) -> 'ok'. +-spec hold_control(kz_term:api_binary(), kapps_call:call()) -> 'ok'. --spec hold_control_command(kapps_call:call() | ne_binary()) -> +-spec hold_control_command(kapps_call:call() | kz_term:ne_binary()) -> kz_json:object(). --spec hold_control_command(api_binary(), kapps_call:call() | ne_binary()) -> +-spec hold_control_command(kz_term:api_binary(), kapps_call:call() | kz_term:ne_binary()) -> kz_json:object(). hold_control(Call) -> hold_control(<<"toggle">>, Call). @@ -1318,7 +1318,7 @@ park(Call) -> Command = park_command(Call), send_command(Command, Call). --spec park_command(kapps_call:call() | ne_binary()) -> kz_json:object(). +-spec park_command(kapps_call:call() | kz_term:ne_binary()) -> kz_json:object(). park_command(CallId=?NE_BINARY) -> kz_json:from_list( [{<<"Application-Name">>, <<"park">>} @@ -1335,11 +1335,11 @@ park_command(Call) -> %% caller. %% @end %%-------------------------------------------------------------------- --spec prompt(ne_binary(), kapps_call:call()) -> ne_binary(). --spec prompt(ne_binary(), ne_binary(), kapps_call:call()) -> ne_binary(). +-spec prompt(kz_term:ne_binary(), kapps_call:call()) -> kz_term:ne_binary(). +-spec prompt(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> kz_term:ne_binary(). --spec b_prompt(ne_binary(), kapps_call:call()) -> kapps_api_std_return(). --spec b_prompt(ne_binary(), ne_binary(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_prompt(kz_term:ne_binary(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_prompt(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> kapps_api_std_return(). prompt(Prompt, Call) -> play(kapps_call:get_prompt(Call, Prompt), Call). @@ -1359,31 +1359,31 @@ b_prompt(Prompt, Lang, Call) -> %% can use to skip playback. %% @end %%-------------------------------------------------------------------- --spec play(ne_binary(), kapps_call:call()) -> - ne_binary(). --spec play(ne_binary(), api_binaries(), kapps_call:call()) -> - ne_binary(). --spec play(ne_binary(), api_binaries(), api_binary(), kapps_call:call()) -> - ne_binary(). --spec play(ne_binary(), api_binaries(), api_binary(), api_boolean(), kapps_call:call()) -> - ne_binary(). +-spec play(kz_term:ne_binary(), kapps_call:call()) -> + kz_term:ne_binary(). +-spec play(kz_term:ne_binary(), kz_term:api_binaries(), kapps_call:call()) -> + kz_term:ne_binary(). +-spec play(kz_term:ne_binary(), kz_term:api_binaries(), kz_term:api_binary(), kapps_call:call()) -> + kz_term:ne_binary(). +-spec play(kz_term:ne_binary(), kz_term:api_binaries(), kz_term:api_binary(), kz_term:api_boolean(), kapps_call:call()) -> + kz_term:ne_binary(). --spec play_command(ne_binary(), kapps_call:call() | ne_binary()) -> +-spec play_command(kz_term:ne_binary(), kapps_call:call() | kz_term:ne_binary()) -> kz_json:object(). --spec play_command(ne_binary(), api_binaries(), kapps_call:call() | ne_binary()) -> +-spec play_command(kz_term:ne_binary(), kz_term:api_binaries(), kapps_call:call() | kz_term:ne_binary()) -> kz_json:object(). --spec play_command(ne_binary(), api_binaries(), api_binary(), kapps_call:call() | ne_binary()) -> +-spec play_command(kz_term:ne_binary(), kz_term:api_binaries(), kz_term:api_binary(), kapps_call:call() | kz_term:ne_binary()) -> kz_json:object(). --spec play_command(ne_binary(), api_binaries(), api_binary(), api_boolean(), kapps_call:call() | ne_binary()) -> +-spec play_command(kz_term:ne_binary(), kz_term:api_binaries(), kz_term:api_binary(), kz_term:api_boolean(), kapps_call:call() | kz_term:ne_binary()) -> kz_json:object(). --spec b_play(ne_binary(), kapps_call:call()) -> +-spec b_play(kz_term:ne_binary(), kapps_call:call()) -> kapps_api_std_return(). --spec b_play(ne_binary(), api_binaries(), kapps_call:call()) -> +-spec b_play(kz_term:ne_binary(), kz_term:api_binaries(), kapps_call:call()) -> kapps_api_std_return(). --spec b_play(ne_binary(), api_binaries(), api_binary(), kapps_call:call()) -> +-spec b_play(kz_term:ne_binary(), kz_term:api_binaries(), kz_term:api_binary(), kapps_call:call()) -> kapps_api_std_return(). --spec b_play(ne_binary(), api_binaries(), api_binary(), api_boolean(), kapps_call:call()) -> +-spec b_play(kz_term:ne_binary(), kz_term:api_binaries(), kz_term:api_binary(), kz_term:api_boolean(), kapps_call:call()) -> kapps_api_std_return(). play_command(Media, Call) -> @@ -1407,11 +1407,11 @@ play_command(Media, Terminators, Leg, Endless, CallId=?NE_BINARY) -> play_command(Media, Terminators, Leg, Endless, Call) -> play_command(Media, Terminators, Leg, Endless, kapps_call:call_id(Call)). --spec play_terminators(api_binaries()) -> ne_binaries(). +-spec play_terminators(kz_term:api_binaries()) -> kz_term:ne_binaries(). play_terminators('undefined') -> ?ANY_DIGIT; play_terminators(Ts) -> lists:usort(Ts). --spec play_leg(api_binary()) -> api_binary(). +-spec play_leg(kz_term:api_binary()) -> kz_term:api_binary(). play_leg('undefined') -> 'undefined'; play_leg(Leg) -> kz_binary:ucfirst(Leg). @@ -1451,11 +1451,11 @@ b_play(Media, Terminators, Leg, Endless, Call) -> %% %% @end %%-------------------------------------------------------------------- --spec tts(api_binary(), kapps_call:call()) -> ne_binary(). --spec tts(api_binary(), api_binary(), kapps_call:call()) -> ne_binary(). --spec tts(api_binary(), api_binary(), api_binary(), kapps_call:call()) -> ne_binary(). --spec tts(api_binary(), api_binary(), api_binary(), api_binaries(), kapps_call:call()) -> ne_binary(). --spec tts(api_binary(), api_binary(), api_binary(), api_binaries(), api_binary(), kapps_call:call()) -> ne_binary(). +-spec tts(kz_term:api_binary(), kapps_call:call()) -> kz_term:ne_binary(). +-spec tts(kz_term:api_binary(), kz_term:api_binary(), kapps_call:call()) -> kz_term:ne_binary(). +-spec tts(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kapps_call:call()) -> kz_term:ne_binary(). +-spec tts(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binaries(), kapps_call:call()) -> kz_term:ne_binary(). +-spec tts(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binaries(), kz_term:api_binary(), kapps_call:call()) -> kz_term:ne_binary(). tts(SayMe, Call) -> tts(SayMe, kazoo_tts:default_voice(), Call). tts(SayMe, Voice, Call) -> tts(SayMe, Voice, kapps_call:language(Call), Call). @@ -1477,11 +1477,11 @@ tts(SayMe, Voice, Lang, Terminators, Engine, Call) -> send_command(Command, Call), NoopId. --spec tts_command(api_binary(), kapps_call:call()) -> kz_json:object(). --spec tts_command(api_binary(), api_binary(), kapps_call:call()) -> kz_json:object(). --spec tts_command(api_binary(), api_binary(), api_binary(), kapps_call:call()) -> kz_json:object(). --spec tts_command(api_binary(), api_binary(), api_binary(), api_binaries(), kapps_call:call()) -> kz_json:object(). --spec tts_command(api_binary(), api_binary(), api_binary(), api_binaries(), api_binary(), kapps_call:call()) -> kz_json:object(). +-spec tts_command(kz_term:api_binary(), kapps_call:call()) -> kz_json:object(). +-spec tts_command(kz_term:api_binary(), kz_term:api_binary(), kapps_call:call()) -> kz_json:object(). +-spec tts_command(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kapps_call:call()) -> kz_json:object(). +-spec tts_command(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binaries(), kapps_call:call()) -> kz_json:object(). +-spec tts_command(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binaries(), kz_term:api_binary(), kapps_call:call()) -> kz_json:object(). tts_command(SayMe, Call) -> tts_command(SayMe, kazoo_tts:default_voice(), Call). tts_command(SayMe, Voice, Call) -> @@ -1501,7 +1501,7 @@ tts_command(SayMe, Voice, Language, Terminators, Engine, Call) -> ,{<<"Call-ID">>, kapps_call:call_id(Call)} ]). --spec tts_terminators(api_ne_binaries()) -> api_ne_binaries(). +-spec tts_terminators(kz_term:api_ne_binaries()) -> kz_term:api_ne_binaries(). tts_terminators('undefined') -> ?ANY_DIGIT; tts_terminators([]) -> 'undefined'; tts_terminators(Terminators) -> Terminators. @@ -1512,15 +1512,15 @@ tts_voice(Voice) -> Voice. tts_language('undefined', Call) -> kapps_call:language(Call); tts_language(Language, _Call) -> Language. --spec tts_engine(api_ne_binary(), kapps_call:call()) -> ne_binary(). +-spec tts_engine(kz_term:api_ne_binary(), kapps_call:call()) -> kz_term:ne_binary(). tts_engine('undefined', Call) -> kazoo_tts:default_provider(Call); tts_engine(Engine, _Call) -> Engine. --spec b_tts(api_binary(), kapps_call:call()) -> kapps_api_std_return(). --spec b_tts(api_binary(), api_binary(), kapps_call:call()) -> kapps_api_std_return(). --spec b_tts(api_binary(), api_binary(), api_binary(), kapps_call:call()) -> kapps_api_std_return(). --spec b_tts(api_binary(), api_binary(), api_binary(), api_binaries(), kapps_call:call()) -> kapps_api_std_return(). --spec b_tts(api_binary(), api_binary(), api_binary(), api_binaries(), api_binary(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_tts(kz_term:api_binary(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_tts(kz_term:api_binary(), kz_term:api_binary(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_tts(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_tts(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binaries(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_tts(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binaries(), kz_term:api_binary(), kapps_call:call()) -> kapps_api_std_return(). b_tts(SayMe, Call) -> wait_for_noop(Call, tts(SayMe, Call)). @@ -1540,17 +1540,17 @@ b_tts(SayMe, Voice, Lang, Terminators, Engine, Call) -> %% A list of keys can be used as the terminator or a silence threshold. %% @end %%-------------------------------------------------------------------- --spec record(ne_binary(), kapps_call:call()) -> 'ok'. --spec record(ne_binary(), binaries(), kapps_call:call()) -> 'ok'. --spec record(ne_binary(), binaries(), api_binary() | integer(), kapps_call:call()) -> 'ok'. --spec record(ne_binary(), binaries(), api_binary() | integer(), api_binary() | integer(), kapps_call:call()) -> 'ok'. --spec record(ne_binary(), binaries(), api_binary() | integer(), api_binary() | integer(), api_binary() | integer(), kapps_call:call()) -> 'ok'. +-spec record(kz_term:ne_binary(), kapps_call:call()) -> 'ok'. +-spec record(kz_term:ne_binary(), kz_term:binaries(), kapps_call:call()) -> 'ok'. +-spec record(kz_term:ne_binary(), kz_term:binaries(), kz_term:api_binary() | integer(), kapps_call:call()) -> 'ok'. +-spec record(kz_term:ne_binary(), kz_term:binaries(), kz_term:api_binary() | integer(), kz_term:api_binary() | integer(), kapps_call:call()) -> 'ok'. +-spec record(kz_term:ne_binary(), kz_term:binaries(), kz_term:api_binary() | integer(), kz_term:api_binary() | integer(), kz_term:api_binary() | integer(), kapps_call:call()) -> 'ok'. --spec b_record(ne_binary(), kapps_call:call()) -> kapps_api_std_return(). --spec b_record(ne_binary(), binaries(), kapps_call:call()) -> kapps_api_std_return(). --spec b_record(ne_binary(), binaries(), api_binary() | integer(), kapps_call:call()) -> kapps_api_std_return(). --spec b_record(ne_binary(), binaries(), api_binary() | integer(), api_binary() | integer(), kapps_call:call()) -> kapps_api_std_return(). --spec b_record(ne_binary(), binaries(), api_binary() | integer(), api_binary() | integer(), api_binary() | integer(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_record(kz_term:ne_binary(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_record(kz_term:ne_binary(), kz_term:binaries(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_record(kz_term:ne_binary(), kz_term:binaries(), kz_term:api_binary() | integer(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_record(kz_term:ne_binary(), kz_term:binaries(), kz_term:api_binary() | integer(), kz_term:api_binary() | integer(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_record(kz_term:ne_binary(), kz_term:binaries(), kz_term:api_binary() | integer(), kz_term:api_binary() | integer(), kz_term:api_binary() | integer(), kapps_call:call()) -> kapps_api_std_return(). record(MediaName, Call) -> record(MediaName, ?ANY_DIGIT, Call). @@ -1587,16 +1587,16 @@ b_record(MediaName, Terminators, TimeLimit, SilenceThreshold, SilenceHits, Call) ,'infinity' ). --spec verify_media_name(kz_json:object(), ne_binary()) -> boolean(). +-spec verify_media_name(kz_json:object(), kz_term:ne_binary()) -> boolean(). verify_media_name(JObj, MediaName) -> case kzc_recording:get_response_media(JObj) of {_, MediaName} -> 'true'; _ -> 'false' end. --spec start_record_call(kz_proplist(), kapps_call:call()) -> 'ok'. --spec start_record_call(kz_proplist(), api_binary() | pos_integer(), kapps_call:call()) -> 'ok'. --spec start_record_call(kz_proplist(), api_binary() | pos_integer(), ne_binaries(), kapps_call:call()) -> 'ok'. +-spec start_record_call(kz_term:proplist(), kapps_call:call()) -> 'ok'. +-spec start_record_call(kz_term:proplist(), kz_term:api_binary() | pos_integer(), kapps_call:call()) -> 'ok'. +-spec start_record_call(kz_term:proplist(), kz_term:api_binary() | pos_integer(), kz_term:ne_binaries(), kapps_call:call()) -> 'ok'. start_record_call(Media, Call) -> record_call(Media, <<"start">>, Call). start_record_call(Media, TimeLimit, Call) -> @@ -1604,14 +1604,14 @@ start_record_call(Media, TimeLimit, Call) -> start_record_call(Media, TimeLimit, Terminators, Call) -> record_call(Media, <<"start">>, TimeLimit, Terminators, Call). --spec stop_record_call(kz_proplist(), kapps_call:call()) -> 'ok'. +-spec stop_record_call(kz_term:proplist(), kapps_call:call()) -> 'ok'. stop_record_call(Media, Call) -> record_call(Media, <<"stop">>, Call). --spec record_call(kz_proplist(), kapps_call:call()) -> 'ok'. --spec record_call(kz_proplist(), ne_binary(), kapps_call:call()) -> 'ok'. --spec record_call(kz_proplist(), ne_binary(), api_binary() | pos_integer(), kapps_call:call()) -> 'ok'. --spec record_call(kz_proplist(), ne_binary(), api_binary() | pos_integer(), list(), kapps_call:call()) -> 'ok'. +-spec record_call(kz_term:proplist(), kapps_call:call()) -> 'ok'. +-spec record_call(kz_term:proplist(), kz_term:ne_binary(), kapps_call:call()) -> 'ok'. +-spec record_call(kz_term:proplist(), kz_term:ne_binary(), kz_term:api_binary() | pos_integer(), kapps_call:call()) -> 'ok'. +-spec record_call(kz_term:proplist(), kz_term:ne_binary(), kz_term:api_binary() | pos_integer(), list(), kapps_call:call()) -> 'ok'. record_call(Media, Call) -> record_call(Media, <<"start">>, Call). record_call(Media, Action, Call) -> @@ -1630,13 +1630,13 @@ record_call(Media, Action, TimeLimit, Terminators, Call) -> ]), send_command(Command, Call). --spec b_record_call(kz_proplist(), kapps_call:call()) -> +-spec b_record_call(kz_term:proplist(), kapps_call:call()) -> wait_for_headless_application_return(). --spec b_record_call(kz_proplist(), ne_binary(), kapps_call:call()) -> +-spec b_record_call(kz_term:proplist(), kz_term:ne_binary(), kapps_call:call()) -> wait_for_headless_application_return(). --spec b_record_call(kz_proplist(), ne_binary(), api_binary() | pos_integer(), kapps_call:call()) -> +-spec b_record_call(kz_term:proplist(), kz_term:ne_binary(), kz_term:api_binary() | pos_integer(), kapps_call:call()) -> wait_for_headless_application_return(). --spec b_record_call(kz_proplist(), ne_binary(), api_binary() | pos_integer(), list(), kapps_call:call()) -> +-spec b_record_call(kz_term:proplist(), kz_term:ne_binary(), kz_term:api_binary() | pos_integer(), list(), kapps_call:call()) -> wait_for_headless_application_return(). b_record_call(MediaName, Call) -> record_call(MediaName, Call), @@ -1659,15 +1659,15 @@ b_record_call(MediaName, Action, TimeLimit, Terminators, Call) -> -type b_store_return() :: {'error', 'timeout' | kz_json:object()} | {'ok', kz_json:object()}. --spec store(ne_binary(), api_binary(), kapps_call:call()) -> 'ok'. --spec store(ne_binary(), api_binary(), api_binary(), kapps_call:call()) -> 'ok'. --spec store(ne_binary(), api_binary(), api_binary(), kz_json:objects(), kapps_call:call()) -> 'ok'. --spec store(ne_binary(), api_binary(), api_binary(), kz_json:objects(), boolean(), kapps_call:call()) -> 'ok'. +-spec store(kz_term:ne_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. +-spec store(kz_term:ne_binary(), kz_term:api_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. +-spec store(kz_term:ne_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_json:objects(), kapps_call:call()) -> 'ok'. +-spec store(kz_term:ne_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_json:objects(), boolean(), kapps_call:call()) -> 'ok'. --spec b_store(ne_binary(), ne_binary(), kapps_call:call()) -> b_store_return(). --spec b_store(ne_binary(), ne_binary(), ne_binary(), kapps_call:call()) -> b_store_return(). --spec b_store(ne_binary(), ne_binary(), ne_binary(), kz_json:objects(), kapps_call:call()) -> b_store_return(). --spec b_store(ne_binary(), ne_binary(), ne_binary(), kz_json:objects(), boolean(), kapps_call:call()) -> b_store_return(). +-spec b_store(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> b_store_return(). +-spec b_store(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> b_store_return(). +-spec b_store(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:objects(), kapps_call:call()) -> b_store_return(). +-spec b_store(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:objects(), boolean(), kapps_call:call()) -> b_store_return(). store(MediaName, Transfer, Call) -> store(MediaName, Transfer, <<"put">>, Call). @@ -1696,7 +1696,7 @@ b_store(MediaName, Transfer, Method, Headers, SuppressReport, Call) -> store(MediaName, Transfer, Method, Headers, SuppressReport, Call), wait_for_headless_application(<<"store">>). --spec b_store_vm(ne_binary(), ne_binary(), ne_binary(), kz_json:objects(), boolean(), kapps_call:call()) -> +-spec b_store_vm(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:objects(), boolean(), kapps_call:call()) -> wait_for_headless_application_return(). b_store_vm(MediaName, Transfer, Method, Headers, SuppressReport, Call) -> Command = [{<<"Application-Name">>, <<"store_vm">>} @@ -1710,8 +1710,8 @@ b_store_vm(MediaName, Transfer, Method, Headers, SuppressReport, Call) -> send_command(Command, Call), wait_for_headless_application(<<"store_vm">>). --spec audio_level_command(kapps_call:call(), ne_binary(), ne_binary(), ne_binary() | integer()) -> - kz_proplist(). +-spec audio_level_command(kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary() | integer()) -> + kz_term:proplist(). audio_level_command(_Call, Mode, Action, Level) -> [{<<"Application-Name">>, <<"audio_level">>} ,{<<"Action">>, Action} @@ -1720,7 +1720,7 @@ audio_level_command(_Call, Mode, Action, Level) -> ,{<<"Insert-At">>, <<"now">>} ]. --spec audio_level(kapps_call:call(), ne_binary(), ne_binary(), ne_binary() | integer()) -> 'ok'. +-spec audio_level(kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary() | integer()) -> 'ok'. audio_level(Call, Mode, Action, Level) -> Command = audio_level_command(Call, Mode, Action, Level), send_command(Command, Call). @@ -1732,10 +1732,10 @@ audio_level(Call, Mode, Action, Level) -> %% caller %% @end %%-------------------------------------------------------------------- --spec store_fax(ne_binary(), kapps_call:call()) -> 'ok'. +-spec store_fax(kz_term:ne_binary(), kapps_call:call()) -> 'ok'. store_fax(URL, Call) -> store_fax(URL, 'undefined', Call). --spec store_fax(ne_binary(), api_binary(), kapps_call:call()) -> 'ok'. +-spec store_fax(kz_term:ne_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. store_fax(URL, LocalFile, Call) -> Command = props:filter_undefined([{<<"Application-Name">>, <<"store_fax">>} @@ -1746,7 +1746,7 @@ store_fax(URL, LocalFile, Call) -> ]), send_command(Command, Call). --spec b_store_fax(ne_binary(), kapps_call:call()) -> b_store_return(). +-spec b_store_fax(kz_term:ne_binary(), kapps_call:call()) -> b_store_return(). b_store_fax(URL, Call) -> store_fax(URL, Call), wait_for_headless_application(<<"store_fax">>). @@ -1780,51 +1780,51 @@ tones_command(Tones, Call) -> %% caller, and collect a number of DTMF events. %% @end %%-------------------------------------------------------------------- --spec prompt_and_collect_digit(ne_binary(), kapps_call:call()) -> 'ok'. --spec prompt_and_collect_digits(integer(), integer(), ne_binary() +-spec prompt_and_collect_digit(kz_term:ne_binary(), kapps_call:call()) -> 'ok'. +-spec prompt_and_collect_digits(integer(), integer(), kz_term:ne_binary() ,kapps_call:call()) -> 'ok'. --spec prompt_and_collect_digits(integer(), integer(), ne_binary() +-spec prompt_and_collect_digits(integer(), integer(), kz_term:ne_binary() ,integer(), kapps_call:call()) -> 'ok'. --spec prompt_and_collect_digits(integer(), integer(), ne_binary() +-spec prompt_and_collect_digits(integer(), integer(), kz_term:ne_binary() ,integer(), integer(), kapps_call:call()) -> 'ok'. --spec prompt_and_collect_digits(integer(), integer(), ne_binary() - ,integer(), integer(), api_binary() +-spec prompt_and_collect_digits(integer(), integer(), kz_term:ne_binary() + ,integer(), integer(), kz_term:api_binary() ,kapps_call:call()) -> 'ok'. --spec prompt_and_collect_digits(integer(), integer(), ne_binary() - ,integer(), integer(), api_binary() - ,ne_binary(), kapps_call:call()) -> +-spec prompt_and_collect_digits(integer(), integer(), kz_term:ne_binary() + ,integer(), integer(), kz_term:api_binary() + ,kz_term:ne_binary(), kapps_call:call()) -> 'ok'. --spec prompt_and_collect_digits(integer(), integer(), ne_binary() - ,integer(), integer(), api_binary() - ,ne_binary(), ne_binaries(), kapps_call:call()) -> +-spec prompt_and_collect_digits(integer(), integer(), kz_term:ne_binary() + ,integer(), integer(), kz_term:api_binary() + ,kz_term:ne_binary(), kz_term:ne_binaries(), kapps_call:call()) -> 'ok'. --spec b_prompt_and_collect_digit(ne_binary(), kapps_call:call()) -> +-spec b_prompt_and_collect_digit(kz_term:ne_binary(), kapps_call:call()) -> b_play_and_collect_digits_return(). --spec b_prompt_and_collect_digits(integer(), integer(), ne_binary() +-spec b_prompt_and_collect_digits(integer(), integer(), kz_term:ne_binary() ,kapps_call:call()) -> b_play_and_collect_digits_return(). --spec b_prompt_and_collect_digits(integer(), integer(), ne_binary() +-spec b_prompt_and_collect_digits(integer(), integer(), kz_term:ne_binary() ,integer(), kapps_call:call()) -> b_play_and_collect_digits_return(). --spec b_prompt_and_collect_digits(integer(), integer(), ne_binary() +-spec b_prompt_and_collect_digits(integer(), integer(), kz_term:ne_binary() ,integer(), integer(), kapps_call:call()) -> b_play_and_collect_digits_return(). --spec b_prompt_and_collect_digits(integer(), integer(), ne_binary() - ,integer(), integer(), api_binary() +-spec b_prompt_and_collect_digits(integer(), integer(), kz_term:ne_binary() + ,integer(), integer(), kz_term:api_binary() ,kapps_call:call()) -> b_play_and_collect_digits_return(). --spec b_prompt_and_collect_digits(integer(), integer(), ne_binary() - ,integer(), integer(), api_binary() - ,ne_binary(), kapps_call:call()) -> +-spec b_prompt_and_collect_digits(integer(), integer(), kz_term:ne_binary() + ,integer(), integer(), kz_term:api_binary() + ,kz_term:ne_binary(), kapps_call:call()) -> b_play_and_collect_digits_return(). --spec b_prompt_and_collect_digits(integer(), integer(), ne_binary() - ,integer(), integer(), api_binary() - ,ne_binary(), ne_binaries(), kapps_call:call()) -> +-spec b_prompt_and_collect_digits(integer(), integer(), kz_term:ne_binary() + ,integer(), integer(), kz_term:api_binary() + ,kz_term:ne_binary(), kz_term:ne_binaries(), kapps_call:call()) -> b_play_and_collect_digits_return(). prompt_and_collect_digit(Prompt, Call) -> @@ -1884,51 +1884,51 @@ b_prompt_and_collect_digits(MinDigits, MaxDigits, Prompt, Tries, Timeout, Invali {'error', 'channel_hungup' | 'channel_unbridge' | kz_json:object()} | {'ok', binary()}. --spec play_and_collect_digit(ne_binary(), kapps_call:call()) -> 'ok'. --spec play_and_collect_digits(integer(), integer(), ne_binary() +-spec play_and_collect_digit(kz_term:ne_binary(), kapps_call:call()) -> 'ok'. +-spec play_and_collect_digits(integer(), integer(), kz_term:ne_binary() ,kapps_call:call()) -> 'ok'. --spec play_and_collect_digits(integer(), integer(), ne_binary() +-spec play_and_collect_digits(integer(), integer(), kz_term:ne_binary() ,integer(), kapps_call:call()) -> 'ok'. --spec play_and_collect_digits(integer(), integer(), ne_binary() +-spec play_and_collect_digits(integer(), integer(), kz_term:ne_binary() ,integer(), integer(), kapps_call:call()) -> 'ok'. --spec play_and_collect_digits(integer(), integer(), ne_binary() - ,integer(), integer(), api_binary() +-spec play_and_collect_digits(integer(), integer(), kz_term:ne_binary() + ,integer(), integer(), kz_term:api_binary() ,kapps_call:call()) -> 'ok'. --spec play_and_collect_digits(integer(), integer(), ne_binary() - ,integer(), integer(), api_binary() - ,ne_binary(), kapps_call:call()) -> +-spec play_and_collect_digits(integer(), integer(), kz_term:ne_binary() + ,integer(), integer(), kz_term:api_binary() + ,kz_term:ne_binary(), kapps_call:call()) -> 'ok'. --spec play_and_collect_digits(integer(), integer(), ne_binary() - ,integer(), integer(), api_binary() - ,ne_binary(), ne_binaries(), kapps_call:call()) -> +-spec play_and_collect_digits(integer(), integer(), kz_term:ne_binary() + ,integer(), integer(), kz_term:api_binary() + ,kz_term:ne_binary(), kz_term:ne_binaries(), kapps_call:call()) -> 'ok'. --spec b_play_and_collect_digit(ne_binary(), kapps_call:call()) -> +-spec b_play_and_collect_digit(kz_term:ne_binary(), kapps_call:call()) -> b_play_and_collect_digits_return(). --spec b_play_and_collect_digits(integer(), integer(), ne_binary() +-spec b_play_and_collect_digits(integer(), integer(), kz_term:ne_binary() ,kapps_call:call()) -> b_play_and_collect_digits_return(). --spec b_play_and_collect_digits(integer(), integer(), ne_binary() +-spec b_play_and_collect_digits(integer(), integer(), kz_term:ne_binary() ,integer(), kapps_call:call()) -> b_play_and_collect_digits_return(). --spec b_play_and_collect_digits(integer(), integer(), ne_binary() +-spec b_play_and_collect_digits(integer(), integer(), kz_term:ne_binary() ,integer(), integer(), kapps_call:call()) -> b_play_and_collect_digits_return(). --spec b_play_and_collect_digits(integer(), integer(), ne_binary() - ,integer(), integer(), api_binary() +-spec b_play_and_collect_digits(integer(), integer(), kz_term:ne_binary() + ,integer(), integer(), kz_term:api_binary() ,kapps_call:call()) -> b_play_and_collect_digits_return(). --spec b_play_and_collect_digits(integer(), integer(), ne_binary() - ,integer(), integer(), api_binary() - ,ne_binary(), kapps_call:call()) -> +-spec b_play_and_collect_digits(integer(), integer(), kz_term:ne_binary() + ,integer(), integer(), kz_term:api_binary() + ,kz_term:ne_binary(), kapps_call:call()) -> b_play_and_collect_digits_return(). --spec b_play_and_collect_digits(integer(), integer(), ne_binary() - ,integer(), integer(), api_binary() - ,ne_binary(), ne_binaries(), kapps_call:call()) -> +-spec b_play_and_collect_digits(integer(), integer(), kz_term:ne_binary() + ,integer(), integer(), kz_term:api_binary() + ,kz_term:ne_binary(), kz_term:ne_binaries(), kapps_call:call()) -> b_play_and_collect_digits_return(). play_and_collect_digit(Media, Call) -> @@ -1999,17 +1999,17 @@ b_play_and_collect_digits(MinDigits, MaxDigits, Media, Tries, Timeout, MediaInva %% Produces the low level kz_api request to say text to a caller %% @end %%-------------------------------------------------------------------- --spec say(ne_binary(), kapps_call:call()) -> 'ok'. --spec say(ne_binary(), ne_binary(), kapps_call:call()) -> 'ok'. --spec say(ne_binary(), ne_binary(), ne_binary(), kapps_call:call()) -> 'ok'. --spec say(ne_binary(), ne_binary(), ne_binary(), ne_binary(), kapps_call:call()) -> 'ok'. --spec say(ne_binary(), ne_binary(), ne_binary(), ne_binary(), api_binary(), kapps_call:call()) -> 'ok'. +-spec say(kz_term:ne_binary(), kapps_call:call()) -> 'ok'. +-spec say(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> 'ok'. +-spec say(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> 'ok'. +-spec say(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> 'ok'. +-spec say(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. --spec b_say(ne_binary(), kapps_call:call()) -> kapps_api_std_return(). --spec b_say(ne_binary(), ne_binary(), kapps_call:call()) -> kapps_api_std_return(). --spec b_say(ne_binary(), ne_binary(), ne_binary(), kapps_call:call()) -> kapps_api_std_return(). --spec b_say(ne_binary(), ne_binary(), ne_binary(), ne_binary(), kapps_call:call()) -> kapps_api_std_return(). --spec b_say(ne_binary(), ne_binary(), ne_binary(), ne_binary(), api_binary(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_say(kz_term:ne_binary(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_say(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_say(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_say(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_say(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary(), kapps_call:call()) -> kapps_api_std_return(). say(Say, Call) -> say(Say, <<"name_spelled">>, Call). @@ -2023,11 +2023,11 @@ say(Say, Type, Method, Language, Gender, Call) -> Command = say_command(Say, Type, Method, Language, Gender, Call), send_command(Command, Call). --spec say_command(ne_binary(), kapps_call:call()) -> kz_json:object(). --spec say_command(ne_binary(), ne_binary(), kapps_call:call()) -> kz_json:object(). --spec say_command(ne_binary(), ne_binary(), ne_binary(), kapps_call:call()) -> kz_json:object(). --spec say_command(ne_binary(), ne_binary(), ne_binary(), ne_binary(), kapps_call:call()) -> kz_json:object(). --spec say_command(ne_binary(), ne_binary(), ne_binary(), ne_binary(), api_binary(), kapps_call:call()) -> kz_json:object(). +-spec say_command(kz_term:ne_binary(), kapps_call:call()) -> kz_json:object(). +-spec say_command(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> kz_json:object(). +-spec say_command(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> kz_json:object(). +-spec say_command(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> kz_json:object(). +-spec say_command(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary(), kapps_call:call()) -> kz_json:object(). say_command(Say, Call) -> say_command(Say, <<"name_spelled">>, Call). @@ -2058,12 +2058,12 @@ say_method(M) -> M. say_language('undefined', Call) -> kapps_call:language(Call); say_language(L, _Call) -> L. --spec say_gender(api_binary()) -> api_binary(). +-spec say_gender(kz_term:api_binary()) -> kz_term:api_binary(). say_gender('undefined') -> 'undefined'; say_gender(Gender) -> say_gender_validate(kz_term:to_lower_binary(Gender)). --spec say_gender_validate(ne_binary()) -> ne_binary(). +-spec say_gender_validate(kz_term:ne_binary()) -> kz_term:ne_binary(). say_gender_validate(<<"masculine">> = G) -> G; say_gender_validate(<<"feminine">> = G) -> G; say_gender_validate(<<"neuter">> = G) -> G. @@ -2095,19 +2095,19 @@ wait_for_say(Call) -> %% with a conference, with optional entry flags %% @end %%-------------------------------------------------------------------- --spec conference(ne_binary(), kapps_call:call()) -> 'ok'. --spec conference(ne_binary(), boolean(), kapps_call:call()) -> 'ok'. --spec conference(ne_binary(), boolean(), boolean(), kapps_call:call()) -> 'ok'. --spec conference(ne_binary(), boolean(), boolean(), boolean(), kapps_call:call()) -> 'ok'. --spec conference(ne_binary(), boolean(), boolean(), boolean(), ne_binary(), kapps_call:call()) -> 'ok'. --spec conference(ne_binary(), boolean(), boolean(), boolean(), ne_binary(), boolean(), kapps_call:call()) -> 'ok'. +-spec conference(kz_term:ne_binary(), kapps_call:call()) -> 'ok'. +-spec conference(kz_term:ne_binary(), boolean(), kapps_call:call()) -> 'ok'. +-spec conference(kz_term:ne_binary(), boolean(), boolean(), kapps_call:call()) -> 'ok'. +-spec conference(kz_term:ne_binary(), boolean(), boolean(), boolean(), kapps_call:call()) -> 'ok'. +-spec conference(kz_term:ne_binary(), boolean(), boolean(), boolean(), kz_term:ne_binary(), kapps_call:call()) -> 'ok'. +-spec conference(kz_term:ne_binary(), boolean(), boolean(), boolean(), kz_term:ne_binary(), boolean(), kapps_call:call()) -> 'ok'. --spec b_conference(ne_binary(), kapps_call:call()) -> kapps_api_std_return(). --spec b_conference(ne_binary(), boolean(), kapps_call:call()) -> kapps_api_std_return(). --spec b_conference(ne_binary(), boolean(), boolean(), kapps_call:call()) -> kapps_api_std_return(). --spec b_conference(ne_binary(), boolean(), boolean(), boolean(), kapps_call:call()) -> kapps_api_std_return(). --spec b_conference(ne_binary(), boolean(), boolean(), boolean(), ne_binary(), kapps_call:call()) -> kapps_api_std_return(). --spec b_conference(ne_binary(), boolean(), boolean(), boolean(), ne_binary(), boolean(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_conference(kz_term:ne_binary(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_conference(kz_term:ne_binary(), boolean(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_conference(kz_term:ne_binary(), boolean(), boolean(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_conference(kz_term:ne_binary(), boolean(), boolean(), boolean(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_conference(kz_term:ne_binary(), boolean(), boolean(), boolean(), kz_term:ne_binary(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_conference(kz_term:ne_binary(), boolean(), boolean(), boolean(), kz_term:ne_binary(), boolean(), kapps_call:call()) -> kapps_api_std_return(). conference(ConfId, Call) -> conference(ConfId, 'false', Call). @@ -2150,7 +2150,7 @@ b_conference(ConfId, Mute, Deaf, Moderator, Profile, Reinvite, Call) -> %% Produces the low level kz_api request to preform a noop %% @end %%-------------------------------------------------------------------- --spec noop(kapps_call:call()) -> ne_binary(). +-spec noop(kapps_call:call()) -> kz_term:ne_binary(). -spec b_noop(kapps_call:call()) -> kapps_api_std_return(). noop(Call) -> @@ -2191,12 +2191,12 @@ b_flush(Call) -> wait_for_noop(Call, flush(Call)). %% @end %%-------------------------------------------------------------------- -spec privacy(kapps_call:call()) -> 'ok'. --spec privacy(api_ne_binary(), kapps_call:call()) -> 'ok'. +-spec privacy(kz_term:api_ne_binary(), kapps_call:call()) -> 'ok'. -spec b_privacy(kapps_call:call()) -> kapps_api_error() | {'ok', kz_json:object()}. --spec b_privacy(api_ne_binary(), kapps_call:call()) -> +-spec b_privacy(kz_term:api_ne_binary(), kapps_call:call()) -> kapps_api_error() | {'ok', kz_json:object()}. @@ -2236,20 +2236,20 @@ b_privacy(Mode, Call) -> %%-------------------------------------------------------------------- -type collect_digits_return() :: {'error','channel_hungup' | 'channel_unbridge' | kz_json:object()} | {'ok', binary()}. --spec collect_digits(integer() | ne_binary(), kapps_call:call()) -> collect_digits_return(). --spec collect_digits(integer() | ne_binary(), integer() | ne_binary(), kapps_call:call()) -> collect_digits_return(). --spec collect_digits(integer() | ne_binary(), integer() | ne_binary(), integer() | ne_binary(), kapps_call:call()) -> +-spec collect_digits(integer() | kz_term:ne_binary(), kapps_call:call()) -> collect_digits_return(). +-spec collect_digits(integer() | kz_term:ne_binary(), integer() | kz_term:ne_binary(), kapps_call:call()) -> collect_digits_return(). +-spec collect_digits(integer() | kz_term:ne_binary(), integer() | kz_term:ne_binary(), integer() | kz_term:ne_binary(), kapps_call:call()) -> collect_digits_return(). --spec collect_digits(integer() | ne_binary(), integer() | ne_binary(), integer() | ne_binary(), api_binary(), kapps_call:call()) -> +-spec collect_digits(integer() | kz_term:ne_binary(), integer() | kz_term:ne_binary(), integer() | kz_term:ne_binary(), kz_term:api_binary(), kapps_call:call()) -> collect_digits_return(). --spec collect_digits(integer(), integer(), integer(), api_binary(), list(), kapps_call:call()) -> +-spec collect_digits(integer(), integer(), integer(), kz_term:api_binary(), list(), kapps_call:call()) -> collect_digits_return(). -record(wcc_collect_digits, {max_digits :: pos_integer() - ,timeout = ?DEFAULT_DIGIT_TIMEOUT :: kz_timeout() + ,timeout = ?DEFAULT_DIGIT_TIMEOUT :: timeout() ,interdigit = ?DEFAULT_INTERDIGIT_TIMEOUT :: pos_integer() - ,noop_id :: api_binary() - ,terminators = [<<"#">>] :: ne_binaries() + ,noop_id :: kz_term:api_binary() + ,terminators = [<<"#">>] :: kz_term:ne_binaries() ,call :: kapps_call:call() ,digits_collected = <<>> :: binary() ,after_timeout = ?MILLISECONDS_IN_DAY :: pos_integer() @@ -2344,14 +2344,14 @@ do_collect_digits(#wcc_collect_digits{max_digits=MaxDigits {'error', 'timeout'} -> {'ok', Digits} end. --spec handle_collect_digit_event(kz_json:object(), api_binary()) -> - {'dtmf', ne_binary()} | +-spec handle_collect_digit_event(kz_json:object(), kz_term:api_binary()) -> + {'dtmf', kz_term:ne_binary()} | {'noop_complete'} | {'continue'} | {'decrement'} | {'error', any()}. --spec handle_collect_digit_event(kz_json:object(), api_binary(), {ne_binary(), ne_binary(), ne_binary()}) -> - {'dtmf', ne_binary()} | +-spec handle_collect_digit_event(kz_json:object(), kz_term:api_binary(), {kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()}) -> + {'dtmf', kz_term:ne_binary()} | {'noop_complete'} | {'continue'} | {'decrement'} | @@ -2402,11 +2402,11 @@ handle_collect_digit_event(_JObj, _NoopId, _EventType) -> %%-------------------------------------------------------------------- -spec wait_for_message(kapps_call:call(), binary()) -> kapps_api_std_return(). --spec wait_for_message(kapps_call:call(), binary(), ne_binary()) -> +-spec wait_for_message(kapps_call:call(), binary(), kz_term:ne_binary()) -> kapps_api_std_return(). --spec wait_for_message(kapps_call:call(), binary(), ne_binary(), ne_binary()) -> +-spec wait_for_message(kapps_call:call(), binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kapps_api_std_return(). --spec wait_for_message(kapps_call:call(), binary(), ne_binary(), ne_binary(), kz_timeout()) -> +-spec wait_for_message(kapps_call:call(), binary(), kz_term:ne_binary(), kz_term:ne_binary(), timeout()) -> kapps_api_std_return(). wait_for_message(Call, Application) -> @@ -2444,13 +2444,13 @@ wait_for_message(Call, Application, Event, Type, Timeout) -> %%-------------------------------------------------------------------- -type wait_for_application_return() :: {'error', 'timeout' | kz_json:object()} | {'ok', kz_json:object()}. --spec wait_for_application(kapps_call:call(), ne_binary()) -> +-spec wait_for_application(kapps_call:call(), kz_term:ne_binary()) -> wait_for_application_return(). --spec wait_for_application(kapps_call:call(), ne_binary(), ne_binary()) -> +-spec wait_for_application(kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary()) -> wait_for_application_return(). --spec wait_for_application(kapps_call:call(), ne_binary(), ne_binary(), ne_binary()) -> +-spec wait_for_application(kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> wait_for_application_return(). --spec wait_for_application(kapps_call:call(), ne_binary(), ne_binary(), ne_binary(), kz_timeout()) -> +-spec wait_for_application(kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), timeout()) -> wait_for_application_return(). wait_for_application(Call, Application) -> @@ -2486,28 +2486,28 @@ wait_for_application(Call, Application, Event, Type, Timeout) -> %% is only interested in events for the application. %% @end %%-------------------------------------------------------------------- --type headless_event() :: ne_binary() | %% STOP EVENT - {ne_binary(), ne_binary()}. %% {START, STOP} +-type headless_event() :: kz_term:ne_binary() | %% STOP EVENT + {kz_term:ne_binary(), kz_term:ne_binary()}. %% {START, STOP} -type wait_for_headless_application_return() :: {'error', 'timeout' | kz_json:object()} | {'ok', kz_json:object()}. --spec wait_for_headless_application(ne_binary()) -> +-spec wait_for_headless_application(kz_term:ne_binary()) -> wait_for_headless_application_return(). --spec wait_for_headless_application(ne_binary(), headless_event()) -> +-spec wait_for_headless_application(kz_term:ne_binary(), headless_event()) -> wait_for_headless_application_return(). --spec wait_for_headless_application(ne_binary(), headless_event(), ne_binary()) -> +-spec wait_for_headless_application(kz_term:ne_binary(), headless_event(), kz_term:ne_binary()) -> wait_for_headless_application_return(). --spec wait_for_headless_application(ne_binary() +-spec wait_for_headless_application(kz_term:ne_binary() ,headless_event() - ,ne_binary() - ,kz_timeout() + ,kz_term:ne_binary() + ,timeout() ) -> wait_for_headless_application_return(). --spec wait_for_headless_application(ne_binary() +-spec wait_for_headless_application(kz_term:ne_binary() ,headless_event() - ,ne_binary() + ,kz_term:ne_binary() ,fun((kz_json:object()) -> boolean()) - ,kz_timeout() + ,timeout() ) -> wait_for_headless_application_return(). @@ -2576,7 +2576,7 @@ wait_for_headless_application(Application, Event, Type, Fun, Timeout) -> %% Wait for a DTMF event and extract the digits when it comes %% @end %%-------------------------------------------------------------------- --spec wait_for_dtmf(kz_timeout()) -> +-spec wait_for_dtmf(timeout()) -> {'error', 'channel_hungup' | 'timeout' | kz_json:object()} | {'ok', binary()}. wait_for_dtmf(Timeout) -> @@ -2606,9 +2606,9 @@ wait_for_dtmf(Timeout) -> %% Waits for and determines the status of the bridge command %% @end %%-------------------------------------------------------------------- --spec wait_for_bridge(kz_timeout(), kapps_call:call()) -> +-spec wait_for_bridge(timeout(), kapps_call:call()) -> kapps_api_bridge_return(). --spec wait_for_bridge(kz_timeout(), 'undefined' | fun((kz_json:object()) -> any()), kapps_call:call()) -> +-spec wait_for_bridge(timeout(), 'undefined' | fun((kz_json:object()) -> any()), kapps_call:call()) -> kapps_api_bridge_return(). wait_for_bridge(0, Call) -> wait_for_bridge(?BRIDGE_DEFAULT_TIMEOUT, 'undefined', Call); @@ -2668,7 +2668,7 @@ wait_for_bridge(Timeout, Fun, Call, Start, {'ok', JObj}) -> %% Wait for a noop or a specific noop to occur %% @end %%-------------------------------------------------------------------- --spec wait_for_noop(kapps_call:call(), api_binary()) -> kapps_api_std_return(). +-spec wait_for_noop(kapps_call:call(), kz_term:api_binary()) -> kapps_api_std_return(). wait_for_noop(Call, NoopId) -> case wait_for_message(Call, <<"noop">>, <<"CHANNEL_EXECUTE_COMPLETE">>, <<"call_event">>, 'infinity') of {'ok', JObj}=OK -> @@ -2724,7 +2724,7 @@ wait_for_channel_bridge() -> %%-------------------------------------------------------------------- -spec wait_for_hangup() -> {'ok', 'channel_hungup'} | {'error', 'timeout'}. --spec wait_for_hangup(kz_timeout()) -> +-spec wait_for_hangup(timeout()) -> {'ok', 'channel_hungup'} | {'error', 'timeout'}. wait_for_hangup() -> @@ -2755,7 +2755,7 @@ wait_for_hangup(Timeout) -> %%-------------------------------------------------------------------- -spec wait_for_unbridge() -> {'ok', 'leg_hungup'} | {'error', 'timeout'}. --spec wait_for_unbridge(kz_timeout()) -> +-spec wait_for_unbridge(timeout()) -> {'ok', 'leg_hungup'} | {'error', 'timeout'}. wait_for_unbridge() -> @@ -2778,7 +2778,7 @@ wait_for_unbridge(Timeout) -> %% Waits for and determines the status of the bridge command %% @end %%-------------------------------------------------------------------- --spec wait_for_application_or_dtmf(ne_binary(), kz_timeout()) -> +-spec wait_for_application_or_dtmf(kz_term:ne_binary(), timeout()) -> kapps_api_std_return() | {'dtmf', binary()}. wait_for_application_or_dtmf(Application, Timeout) -> @@ -2806,7 +2806,7 @@ wait_for_application_or_dtmf(Application, Timeout) -> -define(WAIT_FOR_FAX_TIMEOUT, kapps_config:get_integer(<<"fax">>, <<"wait_for_fax_timeout_ms">>, ?MILLISECONDS_IN_HOUR)). -spec wait_for_fax() -> wait_for_fax_ret(). --spec wait_for_fax(kz_timeout()) -> wait_for_fax_ret(). +-spec wait_for_fax(timeout()) -> wait_for_fax_ret(). wait_for_fax() -> wait_for_fax(?WAIT_FOR_FAX_TIMEOUT). wait_for_fax(Timeout) -> Start = os:timestamp(), @@ -2835,12 +2835,12 @@ wait_for_fax(Timeout) -> %% retrieves event category, type, application from amqp payload %% @end %%-------------------------------------------------------------------- --spec get_event_type(kz_json:object()) -> {api_binary(), api_binary(), api_binary()}. +-spec get_event_type(kz_json:object()) -> {kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary()}. get_event_type(JObj) -> {C, N} = kz_util:get_event_type(JObj), {C, N, get_app(JObj)}. --spec get_app(kz_json:object()) -> api_binary(). +-spec get_app(kz_json:object()) -> kz_term:api_binary(). get_app(JObj) -> kz_json:get_first_defined([<<"Application-Name">> ,[<<"Request">>, <<"Application-Name">>] @@ -2852,7 +2852,7 @@ get_app(JObj) -> %% Sends call commands to the appropriate call control process %% @end %%-------------------------------------------------------------------- --spec send_command(api_terms(), kapps_call:call()) -> 'ok'. +-spec send_command(kz_term:api_terms(), kapps_call:call()) -> 'ok'. send_command(Command, Call) when is_list(Command) -> 'true' = kapps_call:is_call(Call), @@ -2883,8 +2883,8 @@ send_command(JObj, Call) -> send_command(kz_json:to_proplist(JObj), Call). %% Get the t38 settings for an endpoint based on carrier and device %% @end %%-------------------------------------------------------------------- --spec get_outbound_t38_settings(boolean(), api_binary() | boolean()) -> - kz_proplist(). +-spec get_outbound_t38_settings(boolean(), kz_term:api_binary() | boolean()) -> + kz_term:proplist(). get_outbound_t38_settings(CarrierFlag, <<"auto">>) -> get_outbound_t38_settings(CarrierFlag, 'true'); get_outbound_t38_settings(CarrierFlag, 'undefined') -> @@ -2916,7 +2916,7 @@ get_outbound_t38_settings('false','true') -> ,{<<"Enable-T38-Gateway">>, <<"peer">>} ]. --spec get_outbound_t38_settings(boolean()) -> kz_proplist(). +-spec get_outbound_t38_settings(boolean()) -> kz_term:proplist(). get_outbound_t38_settings('true') -> [{<<"Enable-T38-Fax">>, 'true'} ,{<<"Enable-T38-Fax-Request">>, 'true'} @@ -2936,8 +2936,8 @@ get_outbound_t38_settings('false') -> %% %% @end %%-------------------------------------------------------------------- --spec get_inbound_t38_settings(boolean(), api_binary() | boolean()) -> - kz_proplist(). +-spec get_inbound_t38_settings(boolean(), kz_term:api_binary() | boolean()) -> + kz_term:proplist(). get_inbound_t38_settings(CarrierFlag, <<"auto">>) -> get_inbound_t38_settings(CarrierFlag, 'true'); get_inbound_t38_settings(CarrierFlag, 'undefined') -> @@ -2996,7 +2996,7 @@ get_inbound_t38_settings(_Carrier, _CallerFlag) -> ,{<<"Enable-T38-Passthrough">>, 'false'} ]. --spec get_inbound_t38_settings(boolean()) -> kz_proplist(). +-spec get_inbound_t38_settings(boolean()) -> kz_term:proplist(). get_inbound_t38_settings('true') -> [{<<"Enable-T38-Fax">>, 'true'} ,{<<"Enable-T38-Fax-Request">>, 'true'} @@ -3016,7 +3016,7 @@ get_inbound_t38_settings('undefined') -> ,{<<"Enable-T38-Gateway">>, 'undefined'} ]. --spec start_fax_detection(ne_binary(), integer(), kapps_call:call()) -> 'ok'. +-spec start_fax_detection(kz_term:ne_binary(), integer(), kapps_call:call()) -> 'ok'. start_fax_detection(Direction, Duration, Call) -> CallId = kapps_call:call_id(Call), Command = [{<<"Application-Name">>, <<"fax_detection">>} @@ -3038,7 +3038,7 @@ stop_fax_detection(Call) -> ], send_command(Command, Call). --spec fax_detection(ne_binary(), integer(), kapps_call:call()) -> 'true' | 'false'. +-spec fax_detection(kz_term:ne_binary(), integer(), kapps_call:call()) -> 'true' | 'false'. fax_detection(Direction, Duration, Call) -> start_fax_detection(Direction, Duration, Call), Result = case wait_for_fax_detection((Duration + 2) * ?MILLISECONDS_IN_SECOND, Call) of @@ -3073,7 +3073,7 @@ wait_for_fax_detection(Timeout, Call) -> %%-------------------------------------------------------------------- -spec wait_for_unparked_call(kapps_call:call()) -> kapps_api_std_return(). --spec wait_for_unparked_call(kapps_call:call(), kz_timeout()) -> +-spec wait_for_unparked_call(kapps_call:call(), timeout()) -> kapps_api_std_return(). wait_for_unparked_call(Call) -> @@ -3103,30 +3103,30 @@ wait_for_unparked_call(Call, Timeout) -> end end. --spec store_file_args(ne_binary(), store_fun()) -> kz_proplist(). +-spec store_file_args(kz_term:ne_binary(), store_fun()) -> kz_term:proplist(). store_file_args(Filename, URLFun) -> [{<<"File-Name">>, Filename} ,{<<"Url">>, maybe_call_store_fun(URLFun)} ,{<<"Http-Method">>, <<"put">>} ]. --spec maybe_call_store_fun(store_fun()) -> ne_binary(). +-spec maybe_call_store_fun(store_fun()) -> kz_term:ne_binary(). maybe_call_store_fun(URLFun) when is_function(URLFun, 0) -> URLFun(); maybe_call_store_fun(URL) -> URL. --spec store_file(ne_binary(), store_fun(), kapps_call:call()) -> 'ok' | {'error', any()}. +-spec store_file(kz_term:ne_binary(), store_fun(), kapps_call:call()) -> 'ok' | {'error', any()}. store_file(Filename, URLFun, Call) -> App = kz_util:calling_app(), store_file(Filename, URLFun, storage_retries(App), storage_timeout(App), Call). --spec store_file(ne_binary(), store_fun(), pos_integer(), kapps_call:call()) -> +-spec store_file(kz_term:ne_binary(), store_fun(), pos_integer(), kapps_call:call()) -> 'ok' | {'error', any()}. store_file(Filename, URLFun, Tries, Call) -> App = kz_util:calling_app(), store_file(Filename, URLFun, Tries, storage_timeout(App), Call). --spec store_file(ne_binary(), store_fun(), pos_integer(), kz_timeout(), kapps_call:call()) -> +-spec store_file(kz_term:ne_binary(), store_fun(), pos_integer(), timeout(), kapps_call:call()) -> 'ok' | {'error', any()}. store_file(Filename, URLFun, Tries, Timeout, Call) -> Msg = case kapps_call:kvs_fetch('alert_msg', Call) of @@ -3145,8 +3145,8 @@ store_file(Filename, URLFun, Tries, Timeout, Call) -> end, do_store_file(Tries, Timeout, API, Msg, Call). --spec do_store_file(pos_integer(), kz_timeout(), function() - ,ne_binary(), kapps_call:call()) -> +-spec do_store_file(pos_integer(), timeout(), function() + ,kz_term:ne_binary(), kapps_call:call()) -> 'ok' | {'error', any()}. do_store_file(Tries, Timeout, API, Msg, Call) -> Payload = API(), @@ -3179,8 +3179,8 @@ do_store_file(Tries, Timeout, API, Msg, Call) -> retry_store_file(Tries - 1, Timeout, API, Msg, kz_term:to_binary(Error), Call) end. --spec retry_store_file(integer(), kz_timeout(), kz_proplist() | function() - ,ne_binary(), ne_binary(), kapps_call:call()) -> +-spec retry_store_file(integer(), timeout(), kz_term:proplist() | function() + ,kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> 'ok' | {'error', any()}. retry_store_file(0, _Timeout, _API, Msg, Error, Call) -> lager:critical("~s : ~s", [Msg, Error]), @@ -3204,32 +3204,32 @@ maybe_add_debug_data(JObj, Call) -> Data -> kapps_call:kvs_store('error_details', Data, Call) end. --spec attended_transfer(ne_binary(), kapps_call:call()) -> 'ok'. --spec attended_transfer(ne_binary(), api_binary(), kapps_call:call()) -> 'ok'. +-spec attended_transfer(kz_term:ne_binary(), kapps_call:call()) -> 'ok'. +-spec attended_transfer(kz_term:ne_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. attended_transfer(To, Call) -> attended_transfer(To, 'undefined', Call). attended_transfer(To, TransferLeg, Call) -> Command = transfer_command(<<"attended">>, To, TransferLeg, Call), send_command(Command, Call). --spec blind_transfer(ne_binary(), kapps_call:call()) -> 'ok'. --spec blind_transfer(ne_binary(), api_binary(), kapps_call:call()) -> 'ok'. +-spec blind_transfer(kz_term:ne_binary(), kapps_call:call()) -> 'ok'. +-spec blind_transfer(kz_term:ne_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. blind_transfer(To, Call) -> blind_transfer(To, 'undefined', Call). blind_transfer(To, TransferLeg, Call) -> Command = transfer_command(<<"blind">>, To, TransferLeg, Call), send_command(Command, Call). --spec transfer(ne_binary(), ne_binary(), kapps_call:call()) -> 'ok'. --spec transfer(ne_binary(), ne_binary(), api_binary(), kapps_call:call()) -> 'ok'. +-spec transfer(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> 'ok'. +-spec transfer(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary(), kapps_call:call()) -> 'ok'. transfer(TransferType, To, Call) -> transfer(TransferType, To, 'undefined', Call). transfer(TransferType, To, TransferLeg, Call) -> Command = transfer_command(TransferType, To, TransferLeg, Call), send_command(Command, Call). --spec transfer_command(ne_binary(), ne_binary(), kapps_call:call()) -> api_terms(). --spec transfer_command(ne_binary(), ne_binary(), api_binary(), kapps_call:call()) -> api_terms(). +-spec transfer_command(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> kz_term:api_terms(). +-spec transfer_command(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary(), kapps_call:call()) -> kz_term:api_terms(). transfer_command(TransferType, TransferTo, Call) -> transfer_command(TransferType, TransferTo, 'undefined', Call). transfer_command(TransferType, TransferTo, TransferLeg, Call) -> @@ -3245,7 +3245,7 @@ transfer_command(TransferType, TransferTo, TransferLeg, Call) -> ,{<<"Custom-Channel-Vars">>, kapps_call:custom_channel_vars(Call)} ]). --spec play_macro_command(ne_binaries(), kapps_call:call()) -> api_terms(). +-spec play_macro_command(kz_term:ne_binaries(), kapps_call:call()) -> kz_term:api_terms(). play_macro_command(Media, Call) -> kz_json:from_list( [{<<"Application-Name">>, <<"play_macro">>} @@ -3254,11 +3254,11 @@ play_macro_command(Media, Call) -> ,{<<"Call-ID">>, kapps_call:call_id(Call)} ]). --spec b_play_macro(ne_binaries(), kapps_call:call()) -> kapps_api_std_return(). +-spec b_play_macro(kz_term:ne_binaries(), kapps_call:call()) -> kapps_api_std_return(). b_play_macro(Media, Call) -> wait_for_noop(Call, play_macro(Media, Call)). --spec play_macro(ne_binaries(), kapps_call:call()) -> ne_binary(). +-spec play_macro(kz_term:ne_binaries(), kapps_call:call()) -> kz_term:ne_binary(). play_macro(Media, Call) -> NoopId = kz_datamgr:get_uuid(), Commands = [kz_json:from_list([{<<"Application-Name">>, <<"noop">>} @@ -3273,9 +3273,9 @@ play_macro(Media, Call) -> send_command(Command, Call), NoopId. --type media_macro() :: {ne_binary(), ne_binaries()}. +-type media_macro() :: {kz_term:ne_binary(), kz_term:ne_binaries()}. -type media_macros() :: [media_macro()]. --spec media_macro_command(media_macros(), kapps_call:call()) ->api_terms(). +-spec media_macro_command(media_macros(), kapps_call:call()) ->kz_term:api_terms(). media_macro_command(Media, Call) -> kz_json:from_list( [{<<"Application-Name">>, <<"media_macro">>} @@ -3289,7 +3289,7 @@ media_macro(Media, Call) -> Command = media_macro_command(Media, Call), send_command(Command, Call). --spec sound_touch_command(kz_proplist(), kapps_call:call()) ->api_terms(). +-spec sound_touch_command(kz_term:proplist(), kapps_call:call()) ->kz_term:api_terms(). sound_touch_command(Options, Call) -> kz_json:from_list( [{<<"Application-Name">>, <<"sound_touch">>} @@ -3298,7 +3298,7 @@ sound_touch_command(Options, Call) -> | Options ]). --spec start_sound_touch(kz_proplist(), kapps_call:call()) -> 'ok'. +-spec start_sound_touch(kz_term:proplist(), kapps_call:call()) -> 'ok'. start_sound_touch(Options, Call) -> Command = sound_touch_command([{<<"Action">>, <<"start">>} | Options], Call), send_command(Command, Call). diff --git a/core/kazoo_call/src/kapps_call_util.erl b/core/kazoo_call/src/kapps_call_util.erl index 59c6938087d..b2420ca5b55 100644 --- a/core/kazoo_call/src/kapps_call_util.erl +++ b/core/kazoo_call/src/kapps_call_util.erl @@ -12,7 +12,7 @@ -export([filter_ccvs/1]). --spec filter_ccvs(kz_json:object()) -> kz_proplist(). +-spec filter_ccvs(kz_json:object()) -> kz_term:proplist(). filter_ccvs(CCVs) -> lager:debug("extracting CCVs from ~p", [CCVs]), {ReqCCVs, _} = @@ -30,10 +30,10 @@ filter_ccvs(Key, Value, {Acc, Keys}) -> {[{Key, Value} | Acc], Keys} end. --spec is_private_ccv(ne_binary(), ne_binaries()) -> boolean(). +-spec is_private_ccv(kz_term:ne_binary(), kz_term:ne_binaries()) -> boolean(). is_private_ccv(Key, Keys) -> lists:member(Key, Keys). --spec reserved_ccv_keys() -> ne_binaries(). +-spec reserved_ccv_keys() -> kz_term:ne_binaries(). reserved_ccv_keys() -> kapps_config:get_ne_binaries(<<"call_command">>, <<"reserved_ccv_keys">>, ?DEFAULT_CCV_KEYS). diff --git a/core/kazoo_call/src/kapps_conference.erl b/core/kazoo_call/src/kapps_conference.erl index ec5a592c70b..757329d99de 100644 --- a/core/kazoo_call/src/kapps_conference.erl +++ b/core/kazoo_call/src/kapps_conference.erl @@ -107,22 +107,22 @@ %% caller_controls caller controls (config settings) %% --record(kapps_conference, {id :: api_ne_binary() - ,name :: api_ne_binary() - ,focus :: api_ne_binary() - ,profile = 'undefined' :: api_binary() - ,controller_q :: api_ne_binary() - ,bridge_username = ?BRIDGE_USER :: ne_binary() - ,bridge_password = ?BRIDGE_PWD :: ne_binary() - ,member_pins = [] :: ne_binaries() - ,moderator_pins = [] :: ne_binaries() - ,moderator :: api_boolean() +-record(kapps_conference, {id :: kz_term:api_ne_binary() + ,name :: kz_term:api_ne_binary() + ,focus :: kz_term:api_ne_binary() + ,profile = 'undefined' :: kz_term:api_binary() + ,controller_q :: kz_term:api_ne_binary() + ,bridge_username = ?BRIDGE_USER :: kz_term:ne_binary() + ,bridge_password = ?BRIDGE_PWD :: kz_term:ne_binary() + ,member_pins = [] :: kz_term:ne_binaries() + ,moderator_pins = [] :: kz_term:ne_binaries() + ,moderator :: kz_term:api_boolean() ,member_join_muted = 'false' :: boolean() ,member_join_deaf = 'false' :: boolean() ,moderator_join_muted = 'false' :: boolean() ,moderator_join_deaf = 'false' :: boolean() ,max_participants = 0 :: non_neg_integer() - ,max_members_media :: api_ne_binary() + ,max_members_media :: kz_term:api_ne_binary() ,require_moderator = 'false' :: boolean() ,wait_for_moderator = 'false' :: boolean() ,play_name_on_join = 'false' :: boolean() @@ -130,17 +130,17 @@ ,play_exit_tone = 'true' :: tone() ,play_entry_tone = 'true' :: tone() ,play_welcome = 'true' :: boolean() - ,conference_doc :: api_object() - ,app_name = <<"kapps_conference">> :: ne_binary() - ,app_version = <<"1.0.0">> :: ne_binary() + ,conference_doc :: kz_term:api_object() + ,app_name = <<"kapps_conference">> :: kz_term:ne_binary() + ,app_version = <<"1.0.0">> :: kz_term:ne_binary() ,kvs = orddict:new() :: orddict:orddict() ,call :: kapps_call:call() | 'undefined' - ,account_id :: api_ne_binary() - ,moderator_controls = <<"moderator-default">> :: ne_binary() - ,caller_controls = <<"caller-default">> :: ne_binary() + ,account_id :: kz_term:api_ne_binary() + ,moderator_controls = <<"moderator-default">> :: kz_term:ne_binary() + ,caller_controls = <<"caller-default">> :: kz_term:ne_binary() }). --type tone() :: boolean() | ne_binary(). +-type tone() :: boolean() | kz_term:ne_binary(). -export_type([tone/0]). -opaque conference() :: #kapps_conference{}. @@ -209,7 +209,7 @@ to_json(#kapps_conference{}=Conference) -> kz_json:is_json_term(V) ]). --spec to_proplist(conference()) -> kz_proplist(). +-spec to_proplist(conference()) -> kz_term:proplist(). to_proplist(#kapps_conference{}=Conference) -> [{<<"Conference-ID">>, id(Conference)} ,{<<"Conference-Name">>, name(Conference)} @@ -295,123 +295,123 @@ update_fold({Fun, Value}, Conference) when is_function(Fun, 2) -> update_fold(Fun, Conference) when is_function(Fun, 1) -> Fun(Conference). --spec id(conference()) -> api_binary(). +-spec id(conference()) -> kz_term:api_binary(). id(#kapps_conference{id=Id}) -> Id. --spec set_id(api_binary(), conference()) -> conference(). +-spec set_id(kz_term:api_binary(), conference()) -> conference(). set_id(Id, Conference) when is_binary(Id); Id =:= 'undefined' -> Conference#kapps_conference{id=Id}. --spec set_name(ne_binary(), conference()) -> conference(). +-spec set_name(kz_term:ne_binary(), conference()) -> conference(). set_name(Name, Conference) when is_binary(Name) -> Conference#kapps_conference{name=Name}. --spec name(conference()) -> ne_binary(). +-spec name(conference()) -> kz_term:ne_binary(). name(#kapps_conference{name=Name}) -> Name. --spec set_account_id(ne_binary(), conference()) -> conference(). +-spec set_account_id(kz_term:ne_binary(), conference()) -> conference(). set_account_id(AccountId, Conference) when is_binary(AccountId) -> Conference#kapps_conference{account_id=AccountId}. --spec account_id(conference()) -> ne_binary(). +-spec account_id(conference()) -> kz_term:ne_binary(). account_id(#kapps_conference{account_id=AccountId}) -> AccountId. --spec set_moderator_controls(ne_binary(), conference()) -> conference(). +-spec set_moderator_controls(kz_term:ne_binary(), conference()) -> conference(). set_moderator_controls(ModeratorCtrls, Conference) when is_binary(ModeratorCtrls) -> Conference#kapps_conference{moderator_controls=ModeratorCtrls}. --spec moderator_controls(conference()) -> ne_binary(). +-spec moderator_controls(conference()) -> kz_term:ne_binary(). moderator_controls(#kapps_conference{moderator_controls=ModeratorCtrls}) -> ModeratorCtrls. --spec set_caller_controls(ne_binary(), conference()) -> conference(). +-spec set_caller_controls(kz_term:ne_binary(), conference()) -> conference(). set_caller_controls(CallerCtrls, Conference) when is_binary(CallerCtrls) -> Conference#kapps_conference{caller_controls=CallerCtrls}. --spec caller_controls(conference()) -> ne_binary(). +-spec caller_controls(conference()) -> kz_term:ne_binary(). caller_controls(#kapps_conference{caller_controls=CallerCtrls}) -> CallerCtrls. --spec profile(conference()) -> api_binary(). +-spec profile(conference()) -> kz_term:api_binary(). profile(#kapps_conference{profile='undefined'}=Conference) -> id(Conference); profile(#kapps_conference{profile=P}) -> P. --spec set_profile(api_binary(), conference()) -> conference(). +-spec set_profile(kz_term:api_binary(), conference()) -> conference(). set_profile(P, Conference) when is_binary(P); P =:= 'undefined' -> Conference#kapps_conference{profile=P}. --spec application_name(conference()) -> ne_binary(). +-spec application_name(conference()) -> kz_term:ne_binary(). application_name(#kapps_conference{app_name=AppName}) -> AppName. --spec set_application_name(ne_binary(), conference()) -> conference(). +-spec set_application_name(kz_term:ne_binary(), conference()) -> conference(). set_application_name(AppName, #kapps_conference{}=Conference) when is_binary(AppName) -> Conference#kapps_conference{app_name=AppName}. --spec application_version(conference()) -> ne_binary(). +-spec application_version(conference()) -> kz_term:ne_binary(). application_version(#kapps_conference{app_version=AppVersion}) -> AppVersion. --spec set_application_version(ne_binary(), conference()) -> conference(). +-spec set_application_version(kz_term:ne_binary(), conference()) -> conference(). set_application_version(AppVersion, #kapps_conference{}=Conference) when is_binary(AppVersion) -> Conference#kapps_conference{app_version=AppVersion}. --spec focus(conference()) -> api_binary(). +-spec focus(conference()) -> kz_term:api_binary(). focus(#kapps_conference{focus=Focus}) -> Focus. --spec set_focus(ne_binary(), conference()) -> conference(). +-spec set_focus(kz_term:ne_binary(), conference()) -> conference(). set_focus(Focus, Conference) when is_binary(Focus) -> Conference#kapps_conference{focus=Focus}. --spec controller_queue(conference()) -> api_binary(). +-spec controller_queue(conference()) -> kz_term:api_binary(). controller_queue(#kapps_conference{controller_q=ControllerQ}) -> ControllerQ. --spec set_controller_queue(ne_binary(), conference()) -> conference(). +-spec set_controller_queue(kz_term:ne_binary(), conference()) -> conference(). set_controller_queue(ControllerQ, Conference) when is_binary(ControllerQ) -> Conference#kapps_conference{controller_q=ControllerQ}. --spec bridge_username(conference()) -> ne_binary(). +-spec bridge_username(conference()) -> kz_term:ne_binary(). bridge_username(#kapps_conference{bridge_username=BridgeUsername}) -> BridgeUsername. --spec set_bridge_username(ne_binary(), conference()) -> conference(). +-spec set_bridge_username(kz_term:ne_binary(), conference()) -> conference(). set_bridge_username(BridgeUsername, Conference) when is_binary(BridgeUsername) -> Conference#kapps_conference{bridge_username=BridgeUsername}. --spec bridge_password(conference()) -> ne_binary(). +-spec bridge_password(conference()) -> kz_term:ne_binary(). bridge_password(#kapps_conference{bridge_password=BridgePassword}) -> BridgePassword. --spec set_bridge_password(ne_binary(), conference()) -> conference(). +-spec set_bridge_password(kz_term:ne_binary(), conference()) -> conference(). set_bridge_password(BridgePassword, Conference) when is_binary(BridgePassword) -> Conference#kapps_conference{bridge_password=BridgePassword}. --spec member_pins(conference()) -> ne_binaries(). +-spec member_pins(conference()) -> kz_term:ne_binaries(). member_pins(#kapps_conference{member_pins=MemberPins}) -> MemberPins. --spec set_member_pins([ne_binary()], conference()) -> conference(). +-spec set_member_pins([kz_term:ne_binary()], conference()) -> conference(). set_member_pins(MemberPins, Conference) when is_list(MemberPins) -> Conference#kapps_conference{member_pins=MemberPins}. --spec moderator_pins(conference()) -> [ne_binary()]. +-spec moderator_pins(conference()) -> [kz_term:ne_binary()]. moderator_pins(#kapps_conference{moderator_pins=ModeratorPins}) -> ModeratorPins. --spec set_moderator_pins([ne_binary()], conference()) -> conference(). +-spec set_moderator_pins([kz_term:ne_binary()], conference()) -> conference(). set_moderator_pins(ModeratorPins, Conference) when is_list(ModeratorPins) -> Conference#kapps_conference{moderator_pins=ModeratorPins}. --spec moderator(conference()) -> api_boolean(). +-spec moderator(conference()) -> kz_term:api_boolean(). moderator(#kapps_conference{moderator=Moderator}) -> Moderator. --spec set_moderator(api_boolean(), conference()) -> conference(). +-spec set_moderator(kz_term:api_boolean(), conference()) -> conference(). set_moderator('undefined', Conference) -> Conference#kapps_conference{moderator='undefined'}; set_moderator(Moderator, Conference) when is_boolean(Moderator) -> @@ -457,10 +457,10 @@ max_participants(#kapps_conference{max_participants=MaxParticipants}) -> set_max_participants(MaxParticipants, Conference) when is_integer(MaxParticipants) -> Conference#kapps_conference{max_participants=MaxParticipants}. --spec max_members_media(conference()) -> api_binary(). +-spec max_members_media(conference()) -> kz_term:api_binary(). max_members_media(#kapps_conference{max_members_media = Value}) -> Value. --spec set_max_members_media(ne_binary(), conference()) -> conference(). +-spec set_max_members_media(kz_term:ne_binary(), conference()) -> conference(). set_max_members_media(Value, Conference) when is_binary(Value) -> Conference#kapps_conference{max_members_media = Value}. @@ -517,7 +517,7 @@ play_welcome(#kapps_conference{play_welcome=ShouldPlay}) -> set_play_welcome(ShouldPlay, Conference) when is_boolean(ShouldPlay) -> Conference#kapps_conference{play_welcome=ShouldPlay}. --spec conference_doc(conference()) -> api_object(). +-spec conference_doc(conference()) -> kz_term:api_object(). conference_doc(#kapps_conference{conference_doc=JObj}) -> JObj. -spec set_conference_doc(kz_json:object(), conference()) -> conference(). @@ -559,7 +559,7 @@ kvs_find(Key, #kapps_conference{kvs=Dict}) -> kvs_fold(Fun, Acc0, #kapps_conference{kvs=Dict}) -> orddict:fold(Fun, Acc0, Dict). --spec kvs_from_proplist(kz_proplist(), conference()) -> conference(). +-spec kvs_from_proplist(kz_term:proplist(), conference()) -> conference(). kvs_from_proplist(List, #kapps_conference{kvs=Dict}=Conference) -> L = orddict:from_list([{kz_term:to_binary(K), V} || {K, V} <- List]), Conference#kapps_conference{kvs=orddict:merge(fun(_, V, _) -> V end, L, Dict)}. @@ -576,13 +576,13 @@ kvs_map(Pred, #kapps_conference{kvs=Dict}=Conference) -> kvs_store(Key, Value, #kapps_conference{kvs=Dict}=Conference) -> Conference#kapps_conference{kvs=orddict:store(kz_term:to_binary(Key), Value, Dict)}. --spec kvs_store_proplist(kz_proplist(), conference()) -> conference(). +-spec kvs_store_proplist(kz_term:proplist(), conference()) -> conference(). kvs_store_proplist(List, #kapps_conference{kvs=Dict}=Conference) -> Conference#kapps_conference{kvs=lists:foldr(fun({K, V}, D) -> orddict:store(kz_term:to_binary(K), V, D) end, Dict, List)}. --spec kvs_to_proplist(conference()) -> kz_proplist(). +-spec kvs_to_proplist(conference()) -> kz_term:proplist(). kvs_to_proplist(#kapps_conference{kvs=Dict}) -> orddict:to_list(Dict). @@ -611,7 +611,7 @@ cache(#kapps_conference{id=ConferenceId}=Conference, Expires) -> CacheProps = [{'expires', Expires}], kz_cache:store_local(?KAPPS_CALL_CACHE, {?MODULE, 'conference', ConferenceId}, Conference, CacheProps). --spec retrieve(ne_binary()) -> {'ok', conference()} | +-spec retrieve(kz_term:ne_binary()) -> {'ok', conference()} | {'error', 'not_found'}. retrieve(ConferenceId) -> kz_cache:fetch_local(?KAPPS_CALL_CACHE, {?MODULE, 'conference', ConferenceId}). diff --git a/core/kazoo_call/src/kapps_conference_command.erl b/core/kazoo_call/src/kapps_conference_command.erl index a2b0cf162c7..771de23525e 100644 --- a/core/kazoo_call/src/kapps_conference_command.erl +++ b/core/kazoo_call/src/kapps_conference_command.erl @@ -54,7 +54,7 @@ search(Conference) -> {_, JObjs} -> conference_search_filter(JObjs, ConferenceId) end. --spec conference_search_filter(kz_json:objects(), ne_binary()) -> +-spec conference_search_filter(kz_json:objects(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', 'not_found'}. conference_search_filter([], ConferenceId) -> @@ -76,7 +76,7 @@ deaf_participant(ParticipantId, Conference) -> ], send_command(Command, Conference). --spec participant_energy(non_neg_integer(), ne_binary(), kapps_conference:conference()) -> 'ok'. +-spec participant_energy(non_neg_integer(), kz_term:ne_binary(), kapps_conference:conference()) -> 'ok'. participant_energy(ParticipantId, EnergyLevel, Conference) -> Command = [{<<"Application-Name">>, <<"participant_energy">>} ,{<<"Participant-ID">>, ParticipantId} @@ -107,8 +107,8 @@ mute_participant(ParticipantId, Conference) -> ], send_command(Command, Conference). --spec prompt(ne_binary(), kapps_conference:conference()) -> 'ok'. --spec prompt(ne_binary(), non_neg_integer() | 'undefined', kapps_conference:conference()) -> 'ok'. +-spec prompt(kz_term:ne_binary(), kapps_conference:conference()) -> 'ok'. +-spec prompt(kz_term:ne_binary(), non_neg_integer() | 'undefined', kapps_conference:conference()) -> 'ok'. prompt(Media, Conference) -> prompt(Media, 'undefined', Conference). @@ -116,13 +116,13 @@ prompt(Media, ParticipantId, Conference) -> Prompt = get_media_prompt(Media, Conference), play(Prompt, ParticipantId, Conference). --spec get_media_prompt(ne_binary(), kapps_conference:conference()) -> ne_binary(). +-spec get_media_prompt(kz_term:ne_binary(), kapps_conference:conference()) -> kz_term:ne_binary(). get_media_prompt(Media, Conference) -> Call = kapps_conference:call(Conference), kapps_call:get_prompt(Call, Media). --spec play_command(ne_binary()) -> kz_proplist(). --spec play_command(ne_binary(), non_neg_integer() | 'undefined') -> kz_proplist(). +-spec play_command(kz_term:ne_binary()) -> kz_term:proplist(). +-spec play_command(kz_term:ne_binary(), non_neg_integer() | 'undefined') -> kz_term:proplist(). play_command(Media) -> play_command(Media, 'undefined'). @@ -132,8 +132,8 @@ play_command(Media, ParticipantId) -> ,{<<"Participant-ID">>, ParticipantId} ]. --spec play(ne_binary(), kapps_conference:conference()) -> 'ok'. --spec play(ne_binary(), non_neg_integer() | 'undefined', kapps_conference:conference()) -> 'ok'. +-spec play(kz_term:ne_binary(), kapps_conference:conference()) -> 'ok'. +-spec play(kz_term:ne_binary(), non_neg_integer() | 'undefined', kapps_conference:conference()) -> 'ok'. play(Media, Conference) -> play(Media, 'undefined', Conference). @@ -152,7 +152,7 @@ recordstop(Conference) -> send_command(Command, Conference). -spec relate_participants(non_neg_integer(), non_neg_integer(), kapps_conference:conference()) -> 'ok'. --spec relate_participants(non_neg_integer(), non_neg_integer(), api_binary(), kapps_conference:conference()) -> 'ok'. +-spec relate_participants(non_neg_integer(), non_neg_integer(), kz_term:api_binary(), kapps_conference:conference()) -> 'ok'. relate_participants(ParticipantId, OtherParticipantId, Conference) -> relate_participants(ParticipantId, OtherParticipantId, 'undefined', Conference). @@ -167,7 +167,7 @@ relate_participants(ParticipantId, OtherParticipantId, Relationship, Conference) -spec stop_play(kapps_conference:conference()) -> 'ok'. -spec stop_play(non_neg_integer() | 'undefined', kapps_conference:conference()) -> 'ok'. --spec stop_play(non_neg_integer() | 'undefined', api_binary(), kapps_conference:conference()) -> 'ok'. +-spec stop_play(non_neg_integer() | 'undefined', kz_term:api_binary(), kapps_conference:conference()) -> 'ok'. stop_play(Conference) -> stop_play('undefined', Conference). @@ -201,7 +201,7 @@ unmute_participant(ParticipantId, Conference) -> ], send_command(Command, Conference). --spec participant_volume_in(non_neg_integer(), ne_binary(), kapps_conference:conference()) -> 'ok'. +-spec participant_volume_in(non_neg_integer(), kz_term:ne_binary(), kapps_conference:conference()) -> 'ok'. participant_volume_in(ParticipantId, VolumeIn, Conference) -> Command = [{<<"Application-Name">>, <<"participant_energy">>} ,{<<"Participant-ID">>, ParticipantId} @@ -209,7 +209,7 @@ participant_volume_in(ParticipantId, VolumeIn, Conference) -> ], send_command(Command, Conference). --spec participant_volume_out(non_neg_integer(), ne_binary(), kapps_conference:conference()) -> 'ok'. +-spec participant_volume_out(non_neg_integer(), kz_term:ne_binary(), kapps_conference:conference()) -> 'ok'. participant_volume_out(ParticipantId, VolumeOut,Conference) -> Command = [{<<"Application-Name">>, <<"participant_energy">>} ,{<<"Participant-ID">>, ParticipantId} @@ -218,9 +218,9 @@ participant_volume_out(ParticipantId, VolumeOut,Conference) -> send_command(Command, Conference). -spec dial(kz_json:objects(), kapps_conference:conference()) -> 'ok'. --spec dial(kz_json:objects(), api_ne_binary(), kapps_conference:conference()) -> 'ok'. --spec dial(kz_json:objects(), api_ne_binary(), api_ne_binary(), kapps_conference:conference()) -> 'ok'. --spec dial(kz_json:objects(), api_ne_binary(), api_ne_binary(), api_object(), kapps_conference:conference() | ne_binary()) -> 'ok'. +-spec dial(kz_json:objects(), kz_term:api_ne_binary(), kapps_conference:conference()) -> 'ok'. +-spec dial(kz_json:objects(), kz_term:api_ne_binary(), kz_term:api_ne_binary(), kapps_conference:conference()) -> 'ok'. +-spec dial(kz_json:objects(), kz_term:api_ne_binary(), kz_term:api_ne_binary(), kz_term:api_object(), kapps_conference:conference() | kz_term:ne_binary()) -> 'ok'. dial(Endpoints, Conference) when is_list(Endpoints) -> dial(Endpoints, 'undefined', 'undefined', Conference). @@ -245,7 +245,7 @@ dial(Endpoints, CallerIdNumber, CallerIdName, CCVs, ConferenceId) dial(Endpoints, CallerIdNumber, CallerIdName, CCVs, Conference) -> dial(Endpoints, CallerIdNumber, CallerIdName, CCVs, kapps_conference:id(Conference)). --spec send_command(api_terms(), kapps_conference:conference()) -> 'ok'. +-spec send_command(kz_term:api_terms(), kapps_conference:conference()) -> 'ok'. send_command([_|_]=Command, Conference) -> Q = kapps_conference:controller_queue(Conference), ConferenceId = kapps_conference:id(Conference), @@ -261,7 +261,7 @@ send_command([_|_]=Command, Conference) -> end; send_command(JObj, Conference) -> send_command(kz_json:to_proplist(JObj), Conference). --spec play_macro(ne_binaries(), kapps_conference:conference()) -> 'ok'. +-spec play_macro(kz_term:ne_binaries(), kapps_conference:conference()) -> 'ok'. play_macro(Macro, Conference) -> Values = [{<<"Event-Category">>, <<"conference">>} ,{<<"Event-Name">>, <<"command">>} diff --git a/core/kazoo_call/src/kapps_sms_command.erl b/core/kazoo_call/src/kapps_sms_command.erl index 1b4623dc472..4c0703519f2 100644 --- a/core/kazoo_call/src/kapps_sms_command.erl +++ b/core/kazoo_call/src/kapps_sms_command.erl @@ -181,14 +181,14 @@ send(<<"amqp">>, API, Endpoint, _Timeout) -> send(<<"amqp">>, API, FailOver, _Timeout) end. --spec amqp_exchange_options(api_object()) -> kz_proplist(). +-spec amqp_exchange_options(kz_term:api_object()) -> kz_term:proplist(). amqp_exchange_options('undefined') -> []; amqp_exchange_options(JObj) -> [{kz_term:to_atom(K, 'true'), V} || {K, V} <- kz_json:to_proplist(JObj) ]. --spec send_amqp_sms(kz_proplist(), atom()) -> 'ok' | {'error', any()}. +-spec send_amqp_sms(kz_term:proplist(), atom()) -> 'ok' | {'error', any()}. send_amqp_sms(Payload, Pool) -> case kz_amqp_worker:cast(Payload, fun kapi_sms:publish_outbound/1, Pool) of 'ok' -> 'ok'; @@ -197,8 +197,8 @@ send_amqp_sms(Payload, Pool) -> {'error', kz_json:get_value(<<"message">>, Deliver, <<"unknown">>)} end. --spec maybe_add_broker(api_binary(), api_binary(), api_binary(), ne_binary(), kz_proplist(), ne_binary()) -> 'ok'. --spec maybe_add_broker(api_binary(), api_binary(), api_binary(), ne_binary(), kz_proplist(), ne_binary(), api_pid()) -> 'ok'. +-spec maybe_add_broker(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:ne_binary(), kz_term:proplist(), kz_term:ne_binary()) -> 'ok'. +-spec maybe_add_broker(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:ne_binary(), kz_term:proplist(), kz_term:ne_binary(), kz_term:api_pid()) -> 'ok'. maybe_add_broker(Broker, Exchange, RouteId, ExchangeType, ExchangeOptions, BrokerName) -> PoolPid = kz_amqp_sup:pool_pid(?SMS_POOL(Exchange, RouteId, BrokerName)), maybe_add_broker(Broker, Exchange, RouteId, ExchangeType, ExchangeOptions, BrokerName, PoolPid). @@ -209,7 +209,7 @@ maybe_add_broker(Broker, Exchange, RouteId, ExchangeType, ExchangeOptions, Broke 'ok'; maybe_add_broker(_Broker, _Exchange, _RouteId, _ExchangeType, _ExchangeOptions, _BrokerName, _Pid) -> 'ok'. --spec create_sms(kapps_call:call()) -> kz_proplist(). +-spec create_sms(kapps_call:call()) -> kz_term:proplist(). create_sms(Call) -> AccountId = kapps_call:account_id(Call), AccountRealm = kapps_call:to_realm(Call), @@ -243,7 +243,7 @@ create_sms_endpoints([Endpoint | Others], Endpoints) -> NewEndpoint -> create_sms_endpoints(Others, [NewEndpoint | Endpoints]) end. --spec create_sms_endpoint(kz_json:object(), binary()) -> api_object(). +-spec create_sms_endpoint(kz_json:object(), binary()) -> kz_term:api_object(). create_sms_endpoint(Endpoint, <<"amqp">>) -> Endpoint; create_sms_endpoint(Endpoint, <<"sip">>) -> Realm = kz_json:get_value(<<"To-Realm">>, Endpoint), @@ -258,8 +258,8 @@ create_sms_endpoint(Endpoint, <<"sip">>) -> {'error', _E} -> 'undefined' end. --spec lookup_reg(ne_binary(), ne_binary()) -> {'error', any()} | - {'ok', ne_binary()}. +-spec lookup_reg(kz_term:ne_binary(), kz_term:ne_binary()) -> {'error', any()} | + {'ok', kz_term:ne_binary()}. lookup_reg(Username, Realm) -> Req = [{<<"Realm">>, Realm} ,{<<"Username">>, Username} @@ -281,7 +281,7 @@ lookup_reg(Username, Realm) -> end end. --spec extract_device_registrations(kz_json:objects()) -> ne_binaries(). +-spec extract_device_registrations(kz_json:objects()) -> kz_term:ne_binaries(). extract_device_registrations(JObjs) -> sets:to_list(extract_device_registrations(JObjs, sets:new())). @@ -300,16 +300,16 @@ extract_device_registrar_fold(JObj, Set) -> end. -spec get_correlated_msg_type(kz_json:object()) -> - {api_binary(), api_binary(), api_binary()}. --spec get_correlated_msg_type(ne_binary(), kz_json:object()) -> - {api_binary(), api_binary(), api_binary()}. + {kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary()}. +-spec get_correlated_msg_type(kz_term:ne_binary(), kz_json:object()) -> + {kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary()}. get_correlated_msg_type(JObj) -> get_correlated_msg_type(<<"Call-ID">>, JObj). get_correlated_msg_type(Key, JObj) -> {C, N} = kz_util:get_event_type(JObj), {C, N, kz_json:get_value(Key, JObj)}. --spec wait_for_correlated_message(ne_binary() | kapps_call:call(), ne_binary(), ne_binary(), kz_timeout()) -> +-spec wait_for_correlated_message(kz_term:ne_binary() | kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary(), timeout()) -> kapps_api_std_return(). wait_for_correlated_message(CallId, Event, Type, Timeout) when is_binary(CallId) -> Start = os:timestamp(), diff --git a/core/kazoo_call/src/kazoo_call_app.erl b/core/kazoo_call/src/kazoo_call_app.erl index a8c58e576f6..f7101f4b5d9 100644 --- a/core/kazoo_call/src/kazoo_call_app.erl +++ b/core/kazoo_call/src/kazoo_call_app.erl @@ -17,7 +17,7 @@ %% @public %% @doc Implement the application start behaviour --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_StartType, _StartArgs) -> kazoo_call_sup:start_link(). diff --git a/core/kazoo_call/src/kazoo_call_sup.erl b/core/kazoo_call/src/kazoo_call_sup.erl index 83a0b44e706..0659d3b86c1 100644 --- a/core/kazoo_call/src/kazoo_call_sup.erl +++ b/core/kazoo_call/src/kazoo_call_sup.erl @@ -26,7 +26,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -43,7 +43,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 25, diff --git a/core/kazoo_call/src/kz_call_response.erl b/core/kazoo_call/src/kz_call_response.erl index 595a461c946..e239cb032f8 100644 --- a/core/kazoo_call/src/kz_call_response.erl +++ b/core/kazoo_call/src/kz_call_response.erl @@ -18,7 +18,7 @@ -define(CALL_RESPONSE_CONF, <<"call_response">>). --spec config_doc_id() -> ne_binary(). +-spec config_doc_id() -> kz_term:ne_binary(). config_doc_id() -> ?CALL_RESPONSE_CONF. @@ -29,14 +29,14 @@ config_doc_id() -> %% played as part of the error. %% @end %%-------------------------------------------------------------------- --spec send(ne_binary(), ne_binary(), api_binary()) -> - {'ok', ne_binary()} | +-spec send(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary()) -> + {'ok', kz_term:ne_binary()} | {'error', 'no_response'}. --spec send(ne_binary() | kapps_call:call(), ne_binary(), api_binary(), api_binary()) -> - {'ok', ne_binary()} | +-spec send(kz_term:ne_binary() | kapps_call:call(), kz_term:ne_binary(), kz_term:api_binary(), kz_term:api_binary()) -> + {'ok', kz_term:ne_binary()} | {'error', 'no_response'}. --spec send(ne_binary(), ne_binary(), api_binary(), api_binary(), api_binary()) -> - {'ok', ne_binary()} | +-spec send(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary()) -> + {'ok', kz_term:ne_binary()} | {'error', 'no_response'}. send(CallId, CtrlQ, Code) -> @@ -109,7 +109,7 @@ send(CallId, CtrlQ, Code, Cause, Media) -> do_send(CallId, CtrlQ, Commands), {'ok', NoopId}. --spec do_send(ne_binary(), ne_binary(), kz_json:objects()) -> 'ok'. +-spec do_send(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:objects()) -> 'ok'. do_send(CallId, CtrlQ, Commands) -> Command = [{<<"Application-Name">>, <<"queue">>} ,{<<"Call-ID">>, CallId} @@ -130,8 +130,8 @@ do_send(CallId, CtrlQ, Commands) -> %% %% @end %%-------------------------------------------------------------------- --spec send_default(kapps_call:call(), api_binary()) -> - {'ok', ne_binary()} | +-spec send_default(kapps_call:call(), kz_term:api_binary()) -> + {'ok', kz_term:ne_binary()} | {'error', 'no_response'}. send_default(_Call, 'undefined') -> {'error', 'no_response'}; @@ -146,7 +146,7 @@ send_default(Call, Cause) -> end. -spec send_default_response(kapps_call:call(), kz_json:object()) -> - {'ok', ne_binary()} | + {'ok', kz_term:ne_binary()} | {'error', 'no_response'}. send_default_response(Call, Response) -> Media = kz_json:get_value(<<"Media">>, Response), @@ -164,7 +164,7 @@ send_default_response(Call, Response) -> %% returns the configured response proplist %% @end %%-------------------------------------------------------------------- --spec get_response(ne_binary(), kapps_call:call()) -> api_object(). +-spec get_response(kz_term:ne_binary(), kapps_call:call()) -> kz_term:api_object(). get_response(Cause, Call) -> Default = case default_response(Cause) of 'undefined' -> 'undefined'; @@ -179,7 +179,7 @@ get_response(Cause, Call) -> %% returns the default action given the error %% @end %%-------------------------------------------------------------------- --spec default_response(ne_binary()) -> 'undefined' | kz_proplist(). +-spec default_response(kz_term:ne_binary()) -> 'undefined' | kz_term:proplist(). default_response(<<"RESPONSE_TO_STATUS_ENQUIRY">>) -> 'undefined'; default_response(<<"FACILITY_NOT_SUBSCRIBED">>) -> 'undefined'; default_response(<<"INVALID_MSG_UNSPECIFIED">>) -> 'undefined'; diff --git a/core/kazoo_call/src/kzc_recording.erl b/core/kazoo_call/src/kzc_recording.erl index 4a17698807d..726540b5ac0 100644 --- a/core/kazoo_call/src/kzc_recording.erl +++ b/core/kazoo_call/src/kzc_recording.erl @@ -49,30 +49,30 @@ -type store_url() :: 'false' | {'true', 'local'} | - {'true', 'other', ne_binary()}. + {'true', 'other', kz_term:ne_binary()}. --record(state, {url :: api_ne_binary() - ,format :: api_ne_binary() - ,sample_rate :: api_integer() +-record(state, {url :: kz_term:api_ne_binary() + ,format :: kz_term:api_ne_binary() + ,sample_rate :: kz_term:api_integer() ,media :: media() - ,doc_db :: api_ne_binary() - ,doc_id :: api_ne_binary() - ,cdr_id :: api_ne_binary() - ,interaction_id :: api_ne_binary() + ,doc_db :: kz_term:api_ne_binary() + ,doc_id :: kz_term:api_ne_binary() + ,cdr_id :: kz_term:api_ne_binary() + ,interaction_id :: kz_term:api_ne_binary() ,call :: kapps_call:call() | 'undefined' - ,record_on_answer :: api_boolean() - ,record_on_bridge :: api_boolean() + ,record_on_answer :: kz_term:api_boolean() + ,record_on_bridge :: kz_term:api_boolean() ,should_store :: store_url() - ,time_limit :: api_pos_integer() - ,record_min_sec :: api_pos_integer() + ,time_limit :: kz_term:api_pos_integer() + ,record_min_sec :: kz_term:api_pos_integer() ,store_attempted = 'false' :: boolean() ,is_recording = 'false' :: boolean() ,stop_received = 'false' :: boolean() ,retries = 0 :: non_neg_integer() ,verb = 'put' :: atom() - ,account_id :: api_ne_binary() + ,account_id :: kz_term:api_ne_binary() ,event = 'undefined' :: kz_call_event:doc() | 'undefined' - ,origin :: api_ne_binary() + ,origin :: kz_term:api_ne_binary() }). -type state() :: #state{}. @@ -114,7 +114,7 @@ -define(CHECK_CHANNEL_STATUS_TIMEOUT, 5 * ?MILLISECONDS_IN_SECOND). -define(RECORDING_ID_KEY, <<"media_name">>). --spec start_link(kapps_call:call(), kz_json:object()) -> startlink_ret(). +-spec start_link(kapps_call:call(), kz_json:object()) -> kz_types:startlink_ret(). start_link(Call, Data) -> gen_listener:start_link(?SERVER ,[{'bindings', ?BINDINGS(kapps_call:call_id(Call))} @@ -131,7 +131,7 @@ get_response_media(JObj) -> Filename = kz_call_event:application_response(JObj), {filename:dirname(Filename), filename:basename(Filename)}. --spec handle_call_event(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_call_event(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_call_event(JObj, Props) -> kz_util:put_callid(JObj), Pid = props:get_value('server', Props), @@ -219,7 +219,7 @@ init(Call, Data) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -233,7 +233,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'record_start', {_, Media}}, #state{media={_, Media} ,is_recording='true' }=State) -> @@ -381,7 +381,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> lager:debug("unhandled message: ~p", [_Info]), {'noreply', State}. @@ -394,7 +394,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. @@ -429,7 +429,7 @@ code_change(_OldVsn, State, _Extra) -> %%% Internal functions %%%=================================================================== --spec get_timelimit(api_object() | integer()) -> pos_integer(). +-spec get_timelimit(kz_term:api_object() | integer()) -> pos_integer(). get_timelimit('undefined') -> kz_media_util:max_recording_time_limit(); get_timelimit(TL) when is_integer(TL) -> @@ -442,7 +442,7 @@ get_timelimit(TL) when is_integer(TL) -> get_timelimit(Data) -> get_timelimit(kz_json:get_integer_value(<<"time_limit">>, Data)). --spec get_format(api_ne_binary()) -> ne_binary(). +-spec get_format(kz_term:api_ne_binary()) -> kz_term:ne_binary(). get_format('undefined') -> kz_media_config:call_recording_extension(); get_format(<<"mp3">> = MP3) -> MP3; get_format(<<"mp4">> = MP4) -> MP4; @@ -513,14 +513,14 @@ maybe_store_recording_meta(#state{doc_db=Db _ -> store_recording_meta(State) end. --spec get_media_name(ne_binary(), api_ne_binary()) -> ne_binary(). +-spec get_media_name(kz_term:ne_binary(), kz_term:api_ne_binary()) -> kz_term:ne_binary(). get_media_name(Name, Ext) -> case filename:extension(Name) of Ext -> Name; _ -> <> end. --spec store_url(state(), kzd_call_recording:doc()) -> ne_binary(). +-spec store_url(state(), kzd_call_recording:doc()) -> kz_term:ne_binary(). store_url(#state{doc_db=Db ,doc_id=MediaId ,media={_,MediaName} @@ -547,13 +547,13 @@ store_url(#state{doc_db=Db Options = [{'plan_override', Handler}], kz_media_url:store(Db, {kzd_call_recording:type(), MediaId}, MediaName, Options). --spec handler_fields(ne_binary(), state()) -> +-spec handler_fields(kz_term:ne_binary(), state()) -> kz_att_util:format_fields(). handler_fields(Url, State) -> {Protocol, _, _, _, _} = kz_http_util:urlsplit(Url), handler_fields_for_protocol(Protocol, Url, State). --spec handler_fields_for_protocol(ne_binary(), ne_binary(), state()) -> +-spec handler_fields_for_protocol(kz_term:ne_binary(), kz_term:ne_binary(), state()) -> kz_att_util:format_fields(). handler_fields_for_protocol(<<"ftp", _/binary>>, _Url, #state{format=Ext}) -> [<<"call_recording_">> @@ -594,18 +594,18 @@ handler_fields_for_protocol(<<"http", _/binary>> ,{'field', <<"duration_ms">>} ]. --spec check_url(ne_binary()) -> {binary(), ne_binary()}. +-spec check_url(kz_term:ne_binary()) -> {binary(), kz_term:ne_binary()}. check_url(Url) -> case kz_http_util:urlsplit(Url) of {_, _, _, <<>>, _} -> {<<>>, <<"?">>}; {_, _, _, Params, _} -> {check_url_query(Params), <<"&">>} end. --spec check_url_query(ne_binary()) -> binary(). +-spec check_url_query(kz_term:ne_binary()) -> binary(). check_url_query(Query) -> check_url_param(lists:last(binary:split(Query, <<"&">>, ['global']))). --spec check_url_param(ne_binary()) -> binary(). +-spec check_url_param(kz_term:ne_binary()) -> binary(). check_url_param(Param) -> case binary:split(Param, <<"=">>) of [_] -> <<"=">>; @@ -613,7 +613,7 @@ check_url_param(Param) -> _ -> <<"&recording=">> end. --spec handler_from_url(ne_binary()) -> 'kz_att_ftp' | 'kz_att_http' | 'undefined'. +-spec handler_from_url(kz_term:ne_binary()) -> 'kz_att_ftp' | 'kz_att_http' | 'undefined'. handler_from_url(Url) -> case kz_http_util:urlsplit(Url) of {<<"ftp">>, _, _, _, _} -> 'kz_att_ftp'; @@ -623,7 +623,7 @@ handler_from_url(Url) -> _ -> 'undefined' end. --spec should_store_recording(ne_binary(), api_binary()) -> store_url(). +-spec should_store_recording(kz_term:ne_binary(), kz_term:api_binary()) -> store_url(). should_store_recording(AccountId, Url) -> case kz_term:is_empty(Url) of 'true' -> maybe_storage_plan(AccountId); @@ -636,7 +636,7 @@ should_store_recording(AccountId, Url) -> end end. --spec maybe_storage_plan(ne_binary()) -> store_url(). +-spec maybe_storage_plan(kz_term:ne_binary()) -> store_url(). maybe_storage_plan(AccountId) -> AccountDb = kz_util:format_account_mod_id(AccountId), Plan = kzs_plan:get_dataplan(AccountDb, <<"call_recording">>), @@ -669,7 +669,7 @@ save_recording(#state{call=Call store_recording(Media, StoreUrl, Call) end. --spec start_recording(kapps_call:call(), ne_binary(), pos_integer(), ne_binary(), api_integer(), api_integer()) -> 'ok'. +-spec start_recording(kapps_call:call(), kz_term:ne_binary(), pos_integer(), kz_term:ne_binary(), kz_term:api_integer(), kz_term:api_integer()) -> 'ok'. start_recording(Call, MediaName, TimeLimit, MediaDocId, SampleRate, RecordMinSec) -> lager:debug("starting recording of ~s", [MediaName]), FollowTransfer = kapps_call:kvs_fetch('recording_follow_transfer', 'true', Call), @@ -683,13 +683,13 @@ start_recording(Call, MediaName, TimeLimit, MediaDocId, SampleRate, RecordMinSec kapps_call_command:start_record_call(Props, TimeLimit, Call), gen_server:cast(self(), 'recording_started'). --spec store_recording({ne_binary(), ne_binary()}, kapps_call_command:store_fun(), kapps_call:call()) -> +-spec store_recording({kz_term:ne_binary(), kz_term:ne_binary()}, kapps_call_command:store_fun(), kapps_call:call()) -> pid(). store_recording({DirName, MediaName}, StoreUrl, Call) -> Filename = filename:join(DirName, MediaName), kz_util:spawn(fun store_recording/4, [self(), Filename, StoreUrl, Call]). --spec store_recording(pid(), ne_binary(), kapps_call_command:store_fun(), kapps_call:call()) -> 'ok'. +-spec store_recording(pid(), kz_term:ne_binary(), kapps_call_command:store_fun(), kapps_call:call()) -> 'ok'. store_recording(Pid, Filename, StoreUrl, Call) -> case kapps_call_command:store_file(Filename, StoreUrl, Call) of {'error', Error} -> diff --git a/core/kazoo_call/src/kzc_recordings_sup.erl b/core/kazoo_call/src/kzc_recordings_sup.erl index 8f78d71f56d..bdf3038b48a 100644 --- a/core/kazoo_call/src/kzc_recordings_sup.erl +++ b/core/kazoo_call/src/kzc_recordings_sup.erl @@ -32,11 +32,11 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec start_recording(kapps_call:call(), kz_json:object()) -> sup_startchild_ret(). +-spec start_recording(kapps_call:call(), kz_json:object()) -> kz_types:sup_startchild_ret(). start_recording(Call, Data) -> supervisor:start_child(?SERVER, [Call, Data]). @@ -44,11 +44,11 @@ start_recording(Call, Data) -> stop_recording(Pid) -> gen_server:cast(Pid, 'stop_recording'). --spec workers() -> pids(). +-spec workers() -> kz_term:pids(). workers() -> [Pid || {_, Pid, 'worker', [_]} <- supervisor:which_children(?SERVER)]. --spec worker(ne_binary()) -> api_pid(). +-spec worker(kz_term:ne_binary()) -> kz_term:api_pid(). worker(Name) -> case [Pid || {Worker, Pid, 'worker', [_]} <- supervisor:which_children(?SERVER), @@ -72,7 +72,7 @@ worker(Name) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 0, diff --git a/core/kazoo_config/src/kapps_account_config.erl b/core/kazoo_config/src/kapps_account_config.erl index 1ba648fb562..66d6d51060c 100644 --- a/core/kazoo_config/src/kapps_account_config.erl +++ b/core/kazoo_config/src/kapps_account_config.erl @@ -29,8 +29,8 @@ ,migrate/1 ]). --type api_account() :: api_ne_binary() | kapps_call:call() | kz_json:object(). --type account_or_not() :: ne_binary() | no_account_id. +-type api_account() :: kz_term:api_ne_binary() | kapps_call:call() | kz_json:object(). +-type account_or_not() :: kz_term:ne_binary() | no_account_id. %%----------------------------------------------------------------------------- @@ -39,8 +39,8 @@ %% Get a non-empty configuration key for a given category and cast it as a binary %% @end %%----------------------------------------------------------------------------- --spec get_ne_binary(api_account(), ne_binary(), kz_json:path()) -> api_ne_binary(). --spec get_ne_binary(api_account(), ne_binary(), kz_json:path(), Default) -> ne_binary() | Default. +-spec get_ne_binary(api_account(), kz_term:ne_binary(), kz_json:path()) -> kz_term:api_ne_binary(). +-spec get_ne_binary(api_account(), kz_term:ne_binary(), kz_json:path(), Default) -> kz_term:ne_binary() | Default. get_ne_binary(Account, Category, Path) -> get_ne_binary(Account, Category, Path, undefined). get_ne_binary(Account, Category, Path, Default) -> @@ -57,8 +57,8 @@ get_ne_binary(Account, Category, Path, Default) -> %% a list of binary %% @end %%----------------------------------------------------------------------------- --spec get_ne_binaries(api_account(), ne_binary(), kz_json:path()) -> ne_binaries(). --spec get_ne_binaries(api_account(), ne_binary(), kz_json:path(), Default) -> ne_binaries() | Default. +-spec get_ne_binaries(api_account(), kz_term:ne_binary(), kz_json:path()) -> kz_term:ne_binaries(). +-spec get_ne_binaries(api_account(), kz_term:ne_binary(), kz_json:path(), Default) -> kz_term:ne_binaries() | Default. get_ne_binaries(Account, Category, Path) -> get_ne_binaries(Account, Category, Path, undefined). get_ne_binaries(Account, Category, Path, Default) -> @@ -74,11 +74,11 @@ get_ne_binaries(Account, Category, Path, Default) -> %% Get a configuration key for a given category and cast it as a pos_integer %% @end %%----------------------------------------------------------------------------- --spec get_pos_integer(api_account(), ne_binary(), kz_json:path()) -> pos_integer(). +-spec get_pos_integer(api_account(), kz_term:ne_binary(), kz_json:path()) -> pos_integer(). get_pos_integer(Account, Category, Path) -> get_pos_integer(Account, Category, Path, 'undefined'). --spec get_pos_integer(api_account(), ne_binary(), kz_json:path(), Default) -> pos_integer() | Default. +-spec get_pos_integer(api_account(), kz_term:ne_binary(), kz_json:path(), Default) -> pos_integer() | Default. get_pos_integer(Account, Category, Path, Default) -> to_pos_integer(get(Account, Category, Path, Default), Default). @@ -98,9 +98,9 @@ to_pos_integer(Value, Default) -> %% Will search the account db first, then system_config for values. %% @end %%-------------------------------------------------------------------- --spec get_global(api_account(), ne_binary(), kz_json:path()) -> +-spec get_global(api_account(), kz_term:ne_binary(), kz_json:path()) -> kz_json:json_term(). --spec get_global(api_account(), ne_binary(), kz_json:path(), kz_json:api_json_term()) -> +-spec get_global(api_account(), kz_term:ne_binary(), kz_json:path(), kz_json:api_json_term()) -> kz_json:json_term(). get_global(Account, Category, Key) -> get_global(Account, Category, Key, undefined). @@ -113,7 +113,7 @@ get_global(Account, Category, Key, Default) -> get_from_reseller(Account, Category, Key, Default) end. --spec get_global(api_account(), ne_binary()) -> kz_json:object(). +-spec get_global(api_account(), kz_term:ne_binary()) -> kz_json:object(). get_global(Account, Category) -> case load_config_from_account(account_id(Account), Category) of {ok, JObj} -> JObj; @@ -134,11 +134,11 @@ get_global(Account, Category) -> %% i.e. makes sure to skip reading from Account (i.e. sub-account of reseller). %% @end %%-------------------------------------------------------------------- --spec get_from_reseller(api_account(), ne_binary(), kz_json:path()) -> kz_json:api_json_term(). +-spec get_from_reseller(api_account(), kz_term:ne_binary(), kz_json:path()) -> kz_json:api_json_term(). get_from_reseller(Account, Category, Key) -> get_from_reseller(Account, Category, Key, undefined). --spec get_from_reseller(api_account(), ne_binary(), kz_json:path(), kz_json:api_json_term()) -> kz_json:api_json_term(). +-spec get_from_reseller(api_account(), kz_term:ne_binary(), kz_json:path(), kz_json:api_json_term()) -> kz_json:api_json_term(). get_from_reseller(Account, Category, Key, Default) -> case maybe_load_config_from_reseller(Account, Category) of {ok, JObj} -> @@ -167,7 +167,7 @@ maybe_load_config_from_reseller(Account, Category) -> %% Same as get_hierarchy/4 with Default set to undefined %% @end %%-------------------------------------------------------------------- --spec get_hierarchy(api_account(), ne_binary(), kz_json:path()) -> kz_json:json_term(). +-spec get_hierarchy(api_account(), kz_term:ne_binary(), kz_json:path()) -> kz_json:json_term(). get_hierarchy(Account, Category, Key) -> get_hierarchy(Account, Category, Key, undefined). @@ -177,7 +177,7 @@ get_hierarchy(Account, Category, Key) -> %% Same as get_with_strategy/5 with Strategy "hierarchy_merge" %% @end %%-------------------------------------------------------------------- --spec get_hierarchy(api_account(), ne_binary(), kz_json:path(), kz_json:api_json_term()) -> kz_json:json_term(). +-spec get_hierarchy(api_account(), kz_term:ne_binary(), kz_json:path(), kz_json:api_json_term()) -> kz_json:json_term(). get_hierarchy(Account, Category, Key, Default) -> get_with_strategy(<<"hierarchy_merge">>, Account, Category, Key, Default). @@ -199,12 +199,12 @@ get_hierarchy(Account, Category, Key, Default) -> %% the results at the end. %% @end %%-------------------------------------------------------------------- --spec get_with_strategy(ne_binary(), api_account(), ne_binary(), kz_json:path()) -> +-spec get_with_strategy(kz_term:ne_binary(), api_account(), kz_term:ne_binary(), kz_json:path()) -> kz_json:json_term(). get_with_strategy(Strategy, Account, Category, Key) -> get_with_strategy(Strategy, Account, Category, Key, undefined). --spec get_with_strategy(ne_binary(), api_account(), ne_binary(), kz_json:path(), kz_json:api_json_term()) -> +-spec get_with_strategy(kz_term:ne_binary(), api_account(), kz_term:ne_binary(), kz_json:path(), kz_json:api_json_term()) -> kz_json:json_term(). get_with_strategy(Strategy, Account, Category, Key, Default) -> ShouldMerge = is_merge_strategy(Strategy), @@ -224,7 +224,7 @@ get_with_strategy(Strategy, Account, Category, Key, Default) -> Default end. --spec get_from_strategy_cache(ne_binary(), account_or_not(), kz_json:path(), ne_binary(), boolean()) -> +-spec get_from_strategy_cache(kz_term:ne_binary(), account_or_not(), kz_json:path(), kz_term:ne_binary(), boolean()) -> {ok, kz_json:object()} | {error, any()}. get_from_strategy_cache(_, no_account_id, _, _, _) -> @@ -247,7 +247,7 @@ get_from_strategy_cache(Strategy, AccountId, Category, Key, false) -> %% from system_config %% @end %%-------------------------------------------------------------------- --spec get_global_from_doc(ne_binary(), kz_json:path(), kz_json:api_json_term(), kz_json:object()) -> kz_json:object(). +-spec get_global_from_doc(kz_term:ne_binary(), kz_json:path(), kz_json:api_json_term(), kz_json:object()) -> kz_json:object(). get_global_from_doc(Category, Key, Default, JObj) -> case kz_json:get_value(Key, JObj) of undefined -> @@ -256,9 +256,9 @@ get_global_from_doc(Category, Key, Default, JObj) -> Value end. --spec get(api_account(), ne_binary()) -> kz_json:object(). --spec get(api_account(), ne_binary(), kz_json:path()) -> kz_json:api_json_term(). --spec get(api_account(), ne_binary(), kz_json:path(), Default) -> kz_json:json_term() | Default. +-spec get(api_account(), kz_term:ne_binary()) -> kz_json:object(). +-spec get(api_account(), kz_term:ne_binary(), kz_json:path()) -> kz_json:api_json_term(). +-spec get(api_account(), kz_term:ne_binary(), kz_json:path(), Default) -> kz_json:json_term() | Default. get(Account, Category, Key) -> get(Account, Category, Key, undefined). @@ -272,7 +272,7 @@ get(Account, Category) -> {error, _} -> kz_doc:set_id(kz_json:new(), kapps_config_util:account_doc_id(Category)) end. --spec load_config_from_system(api_binary(), ne_binary()) -> kazoo_data:get_results_return(). +-spec load_config_from_system(kz_term:api_binary(), kz_term:ne_binary()) -> kazoo_data:get_results_return(). load_config_from_system(_Account, Category) -> case kapps_config:get_category(Category) of {ok, JObj} -> @@ -281,7 +281,7 @@ load_config_from_system(_Account, Category) -> {error, _}=Error -> Error end. --spec load_config_from_reseller(api_account(), ne_binary()) -> kazoo_data:get_results_return(). +-spec load_config_from_reseller(api_account(), kz_term:ne_binary()) -> kazoo_data:get_results_return(). load_config_from_reseller(Account, Category) -> AccountId = account_id(Account), case AccountId =/= no_account_id @@ -292,7 +292,7 @@ load_config_from_reseller(Account, Category) -> [ResellerId] -> load_config_from_account(ResellerId, Category) end. --spec load_config_from_account(account_or_not(), ne_binary()) -> kazoo_data:get_results_return(). +-spec load_config_from_account(account_or_not(), kz_term:ne_binary()) -> kazoo_data:get_results_return(). load_config_from_account(no_account_id, _Category) -> {error, no_account_id}; load_config_from_account(AccountId, Category) -> @@ -313,11 +313,11 @@ load_config_from_account(AccountId, Category) -> %% 2.2.2. If not reseller, continue the fold %% @end %%-------------------------------------------------------------------- --spec load_config_from_ancestors(ne_binary(), ne_binary()) -> kazoo_data:get_results_return(). +-spec load_config_from_ancestors(kz_term:ne_binary(), kz_term:ne_binary()) -> kazoo_data:get_results_return(). load_config_from_ancestors(AccountId, Category) -> load_config_from_ancestors(AccountId, Category, kz_services:is_reseller(AccountId)). --spec load_config_from_ancestors(ne_binary(), ne_binary(), boolean()) -> kazoo_data:get_results_return(). +-spec load_config_from_ancestors(kz_term:ne_binary(), kz_term:ne_binary(), boolean()) -> kazoo_data:get_results_return(). load_config_from_ancestors(_, _, true) -> %% account is reseller, no need to read from its parents %% Note: load_config_from_account is already read the config from this AccountId @@ -327,7 +327,7 @@ load_config_from_ancestors(AccountId, Category, false) -> Tree = get_account_ancestors_or_reseller(AccountId), load_config_from_ancestors_fold(Tree, Category, []). --spec get_account_ancestors_or_reseller(ne_binary()) -> ne_binaries(). +-spec get_account_ancestors_or_reseller(kz_term:ne_binary()) -> kz_term:ne_binaries(). get_account_ancestors_or_reseller(AccountId) -> case get_account_tree(AccountId) of [] -> find_reseller_account(AccountId); @@ -340,7 +340,7 @@ get_account_ancestors_or_reseller(AccountId) -> %% Get accounts config and walk the account up to accounts reseller %% @end %%-------------------------------------------------------------------- --spec load_config_from_ancestors_fold(ne_binaries(), ne_binary(), kz_json:objects()) -> +-spec load_config_from_ancestors_fold(kz_term:ne_binaries(), kz_term:ne_binary(), kz_json:objects()) -> kazoo_data:get_results_return(). load_config_from_ancestors_fold([], _Category, JObjs) -> {ok, JObjs}; @@ -364,7 +364,7 @@ load_config_from_ancestors_fold([ParentId|AncestorIds], Category, JObjs) -> load_config_from_ancestors_fold(AncestorIds, Category, JObjs) end. --spec find_reseller_account(ne_binary()) -> ne_binaries(). +-spec find_reseller_account(kz_term:ne_binary()) -> kz_term:ne_binaries(). find_reseller_account(AccountId) -> case kz_services:find_reseller_id(AccountId) of undefined -> @@ -374,7 +374,7 @@ find_reseller_account(AccountId) -> ResellerId -> [ResellerId] end. --spec get_account_tree(ne_binary()) -> ne_binaries(). +-spec get_account_tree(kz_term:ne_binary()) -> kz_term:ne_binaries(). get_account_tree(AccountId) -> case kz_account:fetch(AccountId) of {ok , JObj} -> kz_account:tree(JObj); @@ -389,11 +389,11 @@ get_account_tree(AccountId) -> %% Set the Value for the Key in account db %% @end %%-------------------------------------------------------------------- --spec set(api_account(), ne_binary(), kz_json:path(), kz_json:json_term()) -> kz_json:object(). +-spec set(api_account(), kz_term:ne_binary(), kz_json:path(), kz_json:json_term()) -> kz_json:object(). set(Account, Category, Key, Value) -> maybe_set_account(account_id(Account), Category, Key, Value). --spec maybe_set_account(account_or_not(), ne_binary(), kz_json:path(), kz_json:json_term()) -> kz_json:object(). +-spec maybe_set_account(account_or_not(), kz_term:ne_binary(), kz_json:path(), kz_json:json_term()) -> kz_json:object(). maybe_set_account(no_account_id, _, Key, Value) -> kz_json:set_value(Key, Value, kz_json:new()); maybe_set_account(AccountId, Category, Key, Value) -> @@ -410,11 +410,11 @@ maybe_set_account(AccountId, Category, Key, Value) -> %% system_config value then save in account db. %% @end %%-------------------------------------------------------------------- --spec set_global(api_account(), ne_binary(), kz_json:path(), kz_json:json_term()) -> kz_json:object(). +-spec set_global(api_account(), kz_term:ne_binary(), kz_json:path(), kz_json:json_term()) -> kz_json:object(). set_global(Account, Category, Key, Value) -> set_account_or_merge_global(account_id(Account), Category, Key, Value). --spec set_account_or_merge_global(account_or_not(), ne_binary(), kz_json:path(), kz_json:json_term()) -> +-spec set_account_or_merge_global(account_or_not(), kz_term:ne_binary(), kz_json:path(), kz_json:json_term()) -> kz_json:object(). set_account_or_merge_global(no_account_id, _, Key, Value) -> kz_json:set_value(Key, Value, kz_json:new()); @@ -426,7 +426,7 @@ set_account_or_merge_global(AccountId, Category, Key, Value) -> {ok, JObj1} = kz_datamgr:ensure_saved(AccountDb, Doc1), JObj1. --spec update_config_for_saving(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec update_config_for_saving(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). update_config_for_saving(AccountId, JObj) -> AccountDb = kz_util:format_account_db(AccountId), kz_doc:update_pvt_parameters(JObj @@ -441,13 +441,13 @@ update_config_for_saving(AccountId, JObj) -> %% Flush accounts specific config cache %% @end %%-------------------------------------------------------------------- --spec flush(ne_binary(), ne_binary()) -> ok. +-spec flush(kz_term:ne_binary(), kz_term:ne_binary()) -> ok. flush(Account, Category) -> AccountDb = kz_util:format_account_db(Account), kz_datamgr:flush_cache_doc(AccountDb, kapps_config_util:account_doc_id(Category)), flush_all_strategies(Account, Category). --spec flush_all_strategies(ne_binary(), ne_binary()) -> ok. +-spec flush_all_strategies(kz_term:ne_binary(), kz_term:ne_binary()) -> ok. flush_all_strategies(Account, Category) -> Strategies = [<<"hierarchy_merge">> ,<<"global">> @@ -457,7 +457,7 @@ flush_all_strategies(Account, Category) -> ], lists:foreach(fun(Strategy) -> flush(Account, Category, Strategy) end, Strategies). --spec flush(ne_binary(), ne_binary(), ne_binary()) -> ok. +-spec flush(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> ok. flush(Account, Category, Strategy) -> AccountId = kz_util:format_account_id(Account), CacheKey = strategy_cache_key(AccountId, Category, Strategy), @@ -533,12 +533,12 @@ config_origins(Doc, Acc) -> {Db, _} -> [{db, Db, kz_doc:id(Doc)}|Acc] end. --spec strategy_cache_key(ne_binary(), ne_binary(), ne_binary()) -> - {?MODULE, ne_binary(), ne_binary(), ne_binary()}. +-spec strategy_cache_key(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> + {?MODULE, kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()}. strategy_cache_key(AccountId, Category, Strategy) -> {?MODULE, AccountId, Category, Strategy}. --spec strategy_options(ne_binary(), ne_binary(), ne_binary(), boolean(), kz_json:path()) -> map(). +-spec strategy_options(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), boolean(), kz_json:path()) -> map(). strategy_options(Strategy, AccountId, Category, ShouldMerge, Key) -> #{account_id => AccountId ,strategy => Strategy @@ -549,14 +549,14 @@ strategy_options(Strategy, AccountId, Category, ShouldMerge, Key) -> ,key => Key }. --spec is_merge_strategy(ne_binary()) -> boolean(). +-spec is_merge_strategy(kz_term:ne_binary()) -> boolean(). is_merge_strategy(Strategy) -> case kz_binary:reverse(Strategy) of <<"egrem", _/binary>> -> true; _ -> false end. --spec strategy_funs(ne_binary()) -> [function()]. +-spec strategy_funs(kz_term:ne_binary()) -> [function()]. strategy_funs(<<"global", _/binary>>) -> [fun load_config_from_account/2 ,fun load_config_from_reseller/2 @@ -600,11 +600,11 @@ account_id_from_jobj(_Obj, false) -> no_account_id. --spec maybe_format_account_id(api_ne_binary()) -> account_or_not(). +-spec maybe_format_account_id(kz_term:api_ne_binary()) -> account_or_not(). maybe_format_account_id(undefined) -> no_account_id; maybe_format_account_id(Account) -> kz_util:format_account_id(Account). --spec maybe_new_doc({ok, kz_json:object()} | {error, any()}, ne_binary()) -> kz_json:object(). +-spec maybe_new_doc({ok, kz_json:object()} | {error, any()}, kz_term:ne_binary()) -> kz_json:object(). maybe_new_doc({ok, JObj}, _) -> JObj; maybe_new_doc({error, _}, Category) -> kz_doc:set_id(kz_json:new(), Category). @@ -614,8 +614,8 @@ maybe_new_doc({error, _}, Category) -> kz_doc:set_id(kz_json:new(), Category). %% ==================================================================== --type migrate_setting() :: {ne_binary(), kz_json:path()}. --type migrate_value() :: {ne_binary(), ne_binary(), kz_json:path(), _}. +-type migrate_setting() :: {kz_term:ne_binary(), kz_json:path()}. +-type migrate_value() :: {kz_term:ne_binary(), kz_term:ne_binary(), kz_json:path(), _}. -type migrate_values() :: [migrate_value()]. -define(ACCOUNT_CONFIG_MIGRATIONS @@ -627,7 +627,7 @@ maybe_new_doc({error, _}, Category) -> kz_doc:set_id(kz_json:new(), Category). } ]). --spec migrate(ne_binary()) -> ok. +-spec migrate(kz_term:ne_binary()) -> ok. migrate(Account) -> AccountDb = kz_util:format_account_db(Account), _ = [migrate_config_setting(AccountDb, From, To) @@ -635,7 +635,7 @@ migrate(Account) -> ], ok. --spec migrate_config_setting(ne_binary(), migrate_setting(), migrate_setting()) -> +-spec migrate_config_setting(kz_term:ne_binary(), migrate_setting(), migrate_setting()) -> ok | {error, any()}. migrate_config_setting(AccountDb, From, To) -> case remove_config_setting(AccountDb, From) of @@ -646,7 +646,7 @@ migrate_config_setting(AccountDb, From, To) -> {error, Reason} -> {error, {remove, Reason}} end. --spec migrate_config_setting(ne_binary(), kz_json:object(), migrate_values(), migrate_setting()) -> +-spec migrate_config_setting(kz_term:ne_binary(), kz_json:object(), migrate_values(), migrate_setting()) -> ok | {error, any()}. migrate_config_setting(AccountDb, UpdatedFrom, Removed, To) -> case add_config_setting(AccountDb, To, Removed) of @@ -657,12 +657,12 @@ migrate_config_setting(AccountDb, UpdatedFrom, Removed, To) -> {error, Reason} -> {error, {add, Reason}} end. --spec add_config_setting(ne_binary(), migrate_setting(), migrate_values()) -> +-spec add_config_setting(kz_term:ne_binary(), migrate_setting(), migrate_values()) -> ok | {error, any()}. add_config_setting(AccountDb, {Id, Setting}, Values) -> add_config_setting(AccountDb, Id, Setting, Values). --spec add_config_setting(ne_binary(), ne_binary(), kz_json:path(), migrate_values()) -> +-spec add_config_setting(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:path(), migrate_values()) -> ok | {error, any()}. add_config_setting(AccountDb, Id, Setting, Values) when is_binary(Id) -> case kz_datamgr:open_doc(AccountDb, Id) of @@ -705,13 +705,13 @@ add_config_setting(AccountDb, JObj, ToSetting, [{FromId, Node, FromSetting, Valu {error, disparity} end. --spec remove_config_setting(ne_binary(), migrate_setting()) -> +-spec remove_config_setting(kz_term:ne_binary(), migrate_setting()) -> {ok, kz_json:object(), migrate_values()} | {error, any()}. remove_config_setting(AccountDb, {Id, Setting}) -> remove_config_setting(AccountDb, Id, Setting). --spec remove_config_setting(ne_binary(), ne_binary() | kz_json:object(), kz_json:path()) -> +-spec remove_config_setting(kz_term:ne_binary(), kz_term:ne_binary() | kz_json:object(), kz_json:path()) -> {ok, kz_json:object(), migrate_values()} | {error, any()}. remove_config_setting(AccountDb, Id, Setting) when is_binary(Id) -> @@ -727,7 +727,7 @@ remove_config_setting(AccountDb, JObj, Setting) -> ], remove_config_setting(AccountDb, Keys, JObj, []). --spec remove_config_setting(ne_binary(), [{ne_binary(), ne_binary(), kz_json:path()}], kz_json:object(), migrate_values()) -> +-spec remove_config_setting(kz_term:ne_binary(), [{kz_term:ne_binary(), kz_term:ne_binary(), kz_json:path()}], kz_json:object(), migrate_values()) -> {ok, kz_json:object(), migrate_values()}. remove_config_setting(_AccountDb, [], JObj, Removed) -> {ok, JObj, Removed}; @@ -743,7 +743,7 @@ remove_config_setting(AccountDb, [{Id, Node, Setting} | Keys], JObj, Removed) -> ) end. --spec config_setting_key(ne_binary(), kz_json:path()) -> ne_binaries(). +-spec config_setting_key(kz_term:ne_binary(), kz_json:path()) -> kz_term:ne_binaries(). %% NOTE: to support nested keys, update this merge function config_setting_key(Node, Setting) -> [Node, Setting]. diff --git a/core/kazoo_config/src/kapps_config.erl b/core/kazoo_config/src/kapps_config.erl index 4acf017c985..c665e8e60d1 100644 --- a/core/kazoo_config/src/kapps_config.erl +++ b/core/kazoo_config/src/kapps_config.erl @@ -55,11 +55,11 @@ -export([migrate_from_doc/2]). -endif. --type config_category() :: ne_binary() | nonempty_string() | atom(). --type config_key() :: ne_binary() | nonempty_string() | atom() | ne_binaries(). +-type config_category() :: kz_term:ne_binary() | nonempty_string() | atom(). +-type config_key() :: kz_term:ne_binary() | nonempty_string() | atom() | kz_term:ne_binaries(). -type update_option() :: {'node_specific', boolean()} | - {'pvt_fields', api_object()}. + {'pvt_fields', kz_term:api_object()}. -type update_options() :: [update_option()]. -type fetch_ret() :: {'ok', kz_json:object()} | @@ -73,10 +73,10 @@ %% Get a configuration key for a given category and cast it as a list %% @end %%----------------------------------------------------------------------------- --spec get_string(config_category(), config_key()) -> api_string(). +-spec get_string(config_category(), config_key()) -> kz_term:api_string(). -spec get_string(config_category(), config_key(), Default) -> nonempty_string() | Default. --spec get_string(config_category(), config_key(), Default, ne_binary()) -> +-spec get_string(config_category(), config_key(), Default, kz_term:ne_binary()) -> nonempty_string() | Default. get_string(Category, Key) -> @@ -95,9 +95,9 @@ get_string(Category, Key, Default, Node) -> %% Get a configuration key for a given category and cast it as a binary %% @end %%----------------------------------------------------------------------------- --spec get_binary(config_category(), config_key()) -> api_binary(). +-spec get_binary(config_category(), config_key()) -> kz_term:api_binary(). -spec get_binary(config_category(), config_key(), Default) -> binary() | Default. --spec get_binary(config_category(), config_key(), Default, ne_binary()) -> binary() | Default. +-spec get_binary(config_category(), config_key(), Default, kz_term:ne_binary()) -> binary() | Default. get_binary(Category, Key) -> case get(Category, Key) of @@ -116,17 +116,17 @@ get_binary(Category, Key, Default, Node) -> %% @end %%----------------------------------------------------------------------------- -spec get_json(config_category(), config_key()) -> - api_object(). + kz_term:api_object(). -spec get_json(config_category(), config_key(), Default) -> kz_json:object() | Default. --spec get_json(config_category(), config_key(), Default, ne_binary()) -> +-spec get_json(config_category(), config_key(), Default, kz_term:ne_binary()) -> kz_json:object() | Default. get_json(Category, Key) -> V = get(Category, Key), as_json_value(V, undefined). --spec as_json_value(any(), api_object()) -> api_object(). +-spec as_json_value(any(), kz_term:api_object()) -> kz_term:api_object(). as_json_value(undefined, Default) -> Default; as_json_value(V, Default) -> case kz_json:is_json_object(V) of @@ -144,7 +144,7 @@ get_json(Category, Key, Default, Node) -> kz_json:objects(). -spec get_jsons(config_category(), config_key(), Default) -> kz_json:objects() | Default. --spec get_jsons(config_category(), config_key(), Default, ne_binary()) -> +-spec get_jsons(config_category(), config_key(), Default, kz_term:ne_binary()) -> kz_json:objects() | Default. get_jsons(Category, Key) -> @@ -171,9 +171,9 @@ get_jsons(Category, Key, Default, Node) -> %% Get a configuration key for a given category and cast it as a atom %% @end %%----------------------------------------------------------------------------- --spec get_atom(config_category(), config_key()) -> api_atom(). +-spec get_atom(config_category(), config_key()) -> kz_term:api_atom(). -spec get_atom(config_category(), config_key(), Default) -> atom() | Default. --spec get_atom(config_category(), config_key(), Default, ne_binary()) -> atom() | Default. +-spec get_atom(config_category(), config_key(), Default, kz_term:ne_binary()) -> atom() | Default. get_atom(Category, Key) -> case get(Category, Key) of @@ -191,9 +191,9 @@ get_atom(Category, Key, Default, Node) -> %% Get a configuration key for a given category and cast it as a integer %% @end %%----------------------------------------------------------------------------- --spec get_integer(config_category(), config_key()) -> api_integer(). +-spec get_integer(config_category(), config_key()) -> kz_term:api_integer(). -spec get_integer(config_category(), config_key(), Default) -> integer() | Default. --spec get_integer(config_category(), config_key(), Default, ne_binary()) -> integer() | Default. +-spec get_integer(config_category(), config_key(), Default, kz_term:ne_binary()) -> integer() | Default. get_integer(Category, Key) -> case get(Category, Key) of @@ -215,9 +215,9 @@ get_integer(Category, Key, Default, Node) -> %% Get a configuration key for a given category and cast it as a pos_integer %% @end %%----------------------------------------------------------------------------- --spec get_pos_integer(config_category(), config_key()) -> api_pos_integer(). +-spec get_pos_integer(config_category(), config_key()) -> kz_term:api_pos_integer(). -spec get_pos_integer(config_category(), config_key(), Default) -> pos_integer() | Default. --spec get_pos_integer(config_category(), config_key(), Default, ne_binary()) -> pos_integer() | Default. +-spec get_pos_integer(config_category(), config_key(), Default, kz_term:ne_binary()) -> pos_integer() | Default. get_pos_integer(Category, Key) -> case get(Category, Key) of @@ -242,9 +242,9 @@ to_pos_integer(Value, Default) -> %% Get a configuration key for a given category and cast it as a pos_integer %% @end %%----------------------------------------------------------------------------- --spec get_non_neg_integer(config_category(), config_key()) -> api_non_neg_integer(). +-spec get_non_neg_integer(config_category(), config_key()) -> kz_term:api_non_neg_integer(). -spec get_non_neg_integer(config_category(), config_key(), Default) -> non_neg_integer() | Default. --spec get_non_neg_integer(config_category(), config_key(), Default, ne_binary()) -> non_neg_integer() | Default. +-spec get_non_neg_integer(config_category(), config_key(), Default, kz_term:ne_binary()) -> non_neg_integer() | Default. get_non_neg_integer(Category, Key) -> case get(Category, Key) of @@ -269,9 +269,9 @@ to_non_neg_integer(Value, Default) -> %% Get a configuration key for a given category and cast it as a float %% @end %%----------------------------------------------------------------------------- --spec get_float(config_category(), config_key()) -> api_float(). +-spec get_float(config_category(), config_key()) -> kz_term:api_float(). -spec get_float(config_category(), config_key(), Default) -> float() | Default. --spec get_float(config_category(), config_key(), Default, ne_binary()) -> float() | Default. +-spec get_float(config_category(), config_key(), Default, kz_term:ne_binary()) -> float() | Default. get_float(Category, Key) -> case get(Category, Key) of @@ -289,9 +289,9 @@ get_float(Category, Key, Default, Node) -> %% Get a configuration key for a given category and cast it as a is_false %% @end %%----------------------------------------------------------------------------- --spec get_is_false(config_category(), config_key()) -> api_boolean(). +-spec get_is_false(config_category(), config_key()) -> kz_term:api_boolean(). -spec get_is_false(config_category(), config_key(), Default) -> boolean() | Default. --spec get_is_false(config_category(), config_key(), Default, ne_binary()) -> boolean() | Default. +-spec get_is_false(config_category(), config_key(), Default, kz_term:ne_binary()) -> boolean() | Default. get_is_false(Category, Key) -> case get(Category, Key) of @@ -309,9 +309,9 @@ get_is_false(Category, Key, Default, Node) -> %% Get a configuration key for a given category and cast it as a is_true %% @end %%----------------------------------------------------------------------------- --spec get_is_true(config_category(), config_key()) -> api_boolean(). +-spec get_is_true(config_category(), config_key()) -> kz_term:api_boolean(). -spec get_is_true(config_category(), config_key(), Default) -> boolean() | Default. --spec get_is_true(config_category(), config_key(), Default, ne_binary()) -> boolean() | Default. +-spec get_is_true(config_category(), config_key(), Default, kz_term:ne_binary()) -> boolean() | Default. get_is_true(Category, Key) -> case get(Category, Key) of @@ -323,9 +323,9 @@ get_is_true(Category, Key, Default) -> get_is_true(Category, Key, Default, Node) -> kz_term:is_true(get(Category, Key, Default, Node)). --spec get_ne_binary_or_ne_binaries(config_category(), config_key()) -> api_ne_binary() | ne_binaries(). --spec get_ne_binary_or_ne_binaries(config_category(), config_key(), Default) -> ne_binary() | ne_binaries() | Default. --spec get_ne_binary_or_ne_binaries(config_category(), config_key(), Default, ne_binary()) -> ne_binary() | ne_binaries() | Default. +-spec get_ne_binary_or_ne_binaries(config_category(), config_key()) -> kz_term:api_ne_binary() | kz_term:ne_binaries(). +-spec get_ne_binary_or_ne_binaries(config_category(), config_key(), Default) -> kz_term:ne_binary() | kz_term:ne_binaries() | Default. +-spec get_ne_binary_or_ne_binaries(config_category(), config_key(), Default, kz_term:ne_binary()) -> kz_term:ne_binary() | kz_term:ne_binaries() | Default. get_ne_binary_or_ne_binaries(Category, Key) -> get_ne_binary_or_ne_binaries(Category, Key, 'undefined'). @@ -346,9 +346,9 @@ get_ne_binary_or_ne_binaries(Category, Key, Default, Node) -> end end. --spec get_ne_binary(config_category(), config_key()) -> api_ne_binary(). --spec get_ne_binary(config_category(), config_key(), Default) -> ne_binary() | Default. --spec get_ne_binary(config_category(), config_key(), Default, ne_binary()) -> ne_binary() | Default. +-spec get_ne_binary(config_category(), config_key()) -> kz_term:api_ne_binary(). +-spec get_ne_binary(config_category(), config_key(), Default) -> kz_term:ne_binary() | Default. +-spec get_ne_binary(config_category(), config_key(), Default, kz_term:ne_binary()) -> kz_term:ne_binary() | Default. get_ne_binary(Category, Key) -> get_ne_binary(Category, Key, 'undefined'). @@ -361,9 +361,9 @@ get_ne_binary(Category, Key, Default, Node) -> 'false' -> kz_term:to_binary(Value) end. --spec get_ne_binaries(config_category(), config_key()) -> api_ne_binaries(). --spec get_ne_binaries(config_category(), config_key(), Default) -> ne_binaries() | Default. --spec get_ne_binaries(config_category(), config_key(), Default, ne_binary()) -> ne_binaries() | Default. +-spec get_ne_binaries(config_category(), config_key()) -> kz_term:api_ne_binaries(). +-spec get_ne_binaries(config_category(), config_key(), Default) -> kz_term:ne_binaries() | Default. +-spec get_ne_binaries(config_category(), config_key(), Default, kz_term:ne_binary()) -> kz_term:ne_binaries() | Default. get_ne_binaries(Category, Key) -> get_ne_binaries(Category, Key, 'undefined'). @@ -390,7 +390,7 @@ get_ne_binaries(Category, Key, Default, Node) -> %%----------------------------------------------------------------------------- -spec get_node_value(config_category(), config_key()) -> any() | 'undefined'. -spec get_node_value(config_category(), config_key(), Default) -> any() | Default. --spec get_node_value(config_category(), config_key(), Default, ne_binary() | atom()) -> any() | Default. +-spec get_node_value(config_category(), config_key(), Default, kz_term:ne_binary() | atom()) -> any() | Default. get_node_value(Category, Key) -> get_node_value(Category, Key, 'undefined'). @@ -425,7 +425,7 @@ get_node_value(Category, Keys, Default, Node) -> %%----------------------------------------------------------------------------- -spec get(config_category(), config_key()) -> any() | 'undefined'. -spec get(config_category(), config_key(), Default) -> any() | Default. --spec get(config_category(), config_key(), Default, ne_binary() | atom()) -> any() | Default. +-spec get(config_category(), config_key(), Default, kz_term:ne_binary() | atom()) -> any() | Default. get(Category, Key) -> get(Category, Key, 'undefined'). @@ -455,7 +455,7 @@ get(Category, Keys, Default, Node) -> -spec get_current(config_category(), config_key()) -> any() | 'undefined'. -spec get_current(config_category(), config_key(), Default) -> any() | Default. --spec get_current(config_category(), config_key(), Default, ne_binary() | atom()) -> any() | Default. +-spec get_current(config_category(), config_key(), Default, kz_term:ne_binary() | atom()) -> any() | Default. get_current(Category, Key) -> get_current(Category, Key, 'undefined'). @@ -518,21 +518,21 @@ get_default_value(Category, Keys, Default, JObj) -> %% Get all Key-Value pairs for a given category %% @end %%----------------------------------------------------------------------------- --spec get_all_kvs(ne_binary()) -> kz_proplist(). +-spec get_all_kvs(kz_term:ne_binary()) -> kz_term:proplist(). get_all_kvs(Category) -> case get_category(Category) of {'error', _} -> []; {'ok', JObj} -> get_all_kvs(kz_term:to_binary(node()), JObj) end. --spec get_all_kvs(ne_binary(), kz_json:object()) -> kz_proplist(). +-spec get_all_kvs(kz_term:ne_binary(), kz_json:object()) -> kz_term:proplist(). get_all_kvs(Node, JObj) -> case kz_json:get_value(Node, JObj) of 'undefined' -> get_all_default_kvs(JObj); NodeJObj -> kz_json:to_proplist(NodeJObj) end. --spec get_all_default_kvs(kz_json:object()) -> kz_proplist(). +-spec get_all_default_kvs(kz_json:object()) -> kz_term:proplist(). get_all_default_kvs(JObj) -> case kz_json:get_value(?KEY_DEFAULT, JObj) of 'undefined' -> []; @@ -544,15 +544,15 @@ get_all_default_kvs(JObj) -> %% @doc %% @end %%----------------------------------------------------------------------------- --spec set_string(config_category(), config_key(), text() | binary() | string()) -> +-spec set_string(config_category(), config_key(), kz_term:text() | binary() | string()) -> {'ok', kz_json:object()}. --spec set_integer(config_category(), config_key(), text() | integer()) -> +-spec set_integer(config_category(), config_key(), kz_term:text() | integer()) -> {'ok', kz_json:object()}. --spec set_float(config_category(), config_key(), text() | float()) -> +-spec set_float(config_category(), config_key(), kz_term:text() | float()) -> {'ok', kz_json:object()}. --spec set_boolean(config_category(), config_key(), text() | boolean()) -> +-spec set_boolean(config_category(), config_key(), kz_term:text() | boolean()) -> {'ok', kz_json:object()}. --spec set_json(config_category(), config_key(), text() | kz_json:object()) -> +-spec set_json(config_category(), config_key(), kz_term:text() | kz_json:object()) -> {'ok', kz_json:object()}. set_string(Category, Key, Value) -> @@ -581,7 +581,7 @@ set_json(Category, Key, Value) -> set(Category, Key, Value) -> set(Category, Key, Value, node()). --spec set(config_category(), config_key(), any(), ne_binary() | atom()) -> +-spec set(config_category(), config_key(), any(), kz_term:ne_binary() | atom()) -> {'ok', kz_json:object()}. set(Category, Key, Value, Node) -> update_category(Category, Key, Value, Node, []). @@ -603,14 +603,14 @@ update_default(Category, Key, Value) -> update_default(Category, Key, Value, Options) -> update_category(Category, Key, Value, ?KEY_DEFAULT, Options). --spec set_node(config_category(), config_key(), any(), ne_binary() | atom()) -> +-spec set_node(config_category(), config_key(), any(), kz_term:ne_binary() | atom()) -> 'ok' | {'ok', kz_json:object()}. set_node(Category, _, _, 'undefined') -> get_category(Category); set_node(Category, Key, Value, Node) -> update_category(Category, Key, Value, Node, [{'node_specific', 'true'}]). --spec update_category(config_category(), config_key(), any(), ne_binary() | atom(), update_options()) -> +-spec update_category(config_category(), config_key(), any(), kz_term:ne_binary() | atom(), update_options()) -> 'ok' | {'ok', kz_json:object()} | {'error', any()}. @@ -646,7 +646,7 @@ update_category(Category, Keys, Value, Node, Options) -> E end. --spec update_category(config_category(), config_key(), any(), ne_binary(), update_options(), kz_json:object()) +-spec update_category(config_category(), config_key(), any(), kz_term:ne_binary(), update_options(), kz_json:object()) -> {'ok', kz_json:object()}. update_category(Category, Keys, Value, Node, Options, JObj) -> PvtFields = props:get_value('pvt_fields', Options), @@ -660,7 +660,7 @@ update_category(Category, Keys, Value, Node, Options, JObj) -> update_category(Category, kz_json:set_value([?KEY_DEFAULT | Keys], Value, JObj), PvtFields) end. --spec update_category(config_category(), kz_json:object(), api_object()) -> +-spec update_category(config_category(), kz_json:object(), kz_term:api_object()) -> {'ok', kz_json:object()}. update_category(Category, JObj, PvtFields) -> case maybe_save_category(Category, JObj, PvtFields) of @@ -675,13 +675,13 @@ update_category(Category, JObj, PvtFields) -> -endif. %% @private --spec maybe_save_category(ne_binary(), kz_json:object(), api_object()) -> +-spec maybe_save_category(kz_term:ne_binary(), kz_json:object(), kz_term:api_object()) -> {'ok', kz_json:object()} | {'error', 'conflict'}. --spec maybe_save_category(ne_binary(), kz_json:object(), api_object(), boolean()) -> +-spec maybe_save_category(kz_term:ne_binary(), kz_json:object(), kz_term:api_object(), boolean()) -> {'ok', kz_json:object()} | {'error', 'conflict'}. --spec maybe_save_category(ne_binary(), kz_json:object(), api_object(), boolean(), boolean()) -> +-spec maybe_save_category(kz_term:ne_binary(), kz_json:object(), kz_term:api_object(), boolean(), boolean()) -> {'ok', kz_json:object()} | {'error', 'conflict'}. maybe_save_category(Category, JObj, PvtFields) -> @@ -717,7 +717,7 @@ maybe_save_category(Category, JObj, PvtFields, Looped, _) -> {'ok', JObj1} end. --spec update_pvt_fields(config_category(), kz_json:object(), api_object()) -> +-spec update_pvt_fields(config_category(), kz_json:object(), kz_term:api_object()) -> kz_json:object(). update_pvt_fields(Category, JObj, 'undefined') -> kz_doc:update_pvt_parameters(kz_doc:set_id(JObj, Category) @@ -735,7 +735,7 @@ update_pvt_fields(Category, JObj, PvtFields) -> %% @end %%----------------------------------------------------------------------------- -spec lock_db() -> 'ok'. --spec lock_db(text() | boolean()) -> 'ok'. +-spec lock_db(kz_term:text() | boolean()) -> 'ok'. lock_db() -> lock_db('true'). @@ -771,12 +771,12 @@ is_locked() -> flush() -> kz_datamgr:flush_cache_docs(?KZ_CONFIG_DB). --spec flush(ne_binary()) -> 'ok'. +-spec flush(kz_term:ne_binary()) -> 'ok'. flush(Category) -> kz_datamgr:flush_cache_doc(?KZ_CONFIG_DB, Category). --spec flush(ne_binary(), ne_binary()) -> 'ok'. --spec flush(ne_binary(), ne_binary() | ne_binaries(), api_ne_binary()) -> 'ok'. +-spec flush(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. +-spec flush(kz_term:ne_binary(), kz_term:ne_binary() | kz_term:ne_binaries(), kz_term:api_ne_binary()) -> 'ok'. flush(Category, Key) -> flush(Category, Key, ?KEY_DEFAULT). @@ -809,8 +809,8 @@ flush(Category, Keys, Node) -> %% 3. from a flat file %% @end %%----------------------------------------------------------------------------- --spec get_category(ne_binary()) -> fetch_ret(). --spec get_category(ne_binary(), boolean()) -> fetch_ret(). +-spec get_category(kz_term:ne_binary()) -> fetch_ret(). +-spec get_category(kz_term:ne_binary(), boolean()) -> fetch_ret(). get_category(Category) -> get_category(Category, 'true'). @@ -845,8 +845,8 @@ get_category(Category, 'false') -> %% the destination. %% @end %%-------------------------------------------------------------------- --type migrate_setting() :: {ne_binary(), config_key()} | ne_binary(). --type migrate_value() :: {ne_binary(), ne_binary(), config_key(), _}. +-type migrate_setting() :: {kz_term:ne_binary(), config_key()} | kz_term:ne_binary(). +-type migrate_value() :: {kz_term:ne_binary(), kz_term:ne_binary(), config_key(), _}. -type migrate_values() :: [migrate_value()]. -define(CONFIG_MIGRATIONS @@ -1048,7 +1048,7 @@ migrate_config_setting(UpdatedFrom, Removed, {ToId, ToSetting}) -> end end. --spec add_config_setting(ne_binary(), config_key(), migrate_values()) -> +-spec add_config_setting(kz_term:ne_binary(), config_key(), migrate_values()) -> 'ok' | {'error', any()}. add_config_setting(Id, Setting, Values) when is_binary(Id) -> @@ -1095,7 +1095,7 @@ add_config_setting(JObj, ToSetting, [{FromId, Node, FromSetting, Value} | Values remove_config_setting({Id, Setting}) -> remove_config_setting(Id, Setting). --spec remove_config_setting(ne_binary() | kz_json:object(), config_key()) -> +-spec remove_config_setting(kz_term:ne_binary() | kz_json:object(), config_key()) -> {'ok', kz_json:object(), migrate_values()} | {'error', any()}. remove_config_setting(Id, Setting) when is_binary(Id) -> @@ -1110,7 +1110,7 @@ remove_config_setting(JObj, Setting) -> ], remove_config_setting(Keys, JObj, []). --spec remove_config_setting([{ne_binary(), ne_binary(), config_key()}], kz_json:object(), migrate_values()) -> +-spec remove_config_setting([{kz_term:ne_binary(), kz_term:ne_binary(), config_key()}], kz_json:object(), migrate_values()) -> {'ok', kz_json:object(), migrate_values()}. remove_config_setting([], JObj, Removed) -> {'ok', JObj, Removed}; @@ -1125,14 +1125,14 @@ remove_config_setting([{Id, Node, Setting} | Keys], JObj, Removed) -> ) end. --spec config_setting_key(ne_binary(), config_key()) -> ne_binaries(). +-spec config_setting_key(kz_term:ne_binary(), config_key()) -> kz_term:ne_binaries(). %% NOTE: to support nested keys, update this merge function config_setting_key(Node, Setting) when is_list(Setting) -> [Node | Setting]; config_setting_key(Node, Setting) -> [Node, Setting]. --spec migrate_config_doc(ne_binary(), ne_binary()) -> 'ok'. +-spec migrate_config_doc(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. migrate_config_doc(FromId, ToId) -> case kz_datamgr:open_doc(?KZ_CONFIG_DB, FromId) of {'error', 'not_found'} -> lager:debug("didn't find ~s to migrate", [FromId]); @@ -1153,7 +1153,7 @@ migrate_from_doc_to_doc(FromJObj, ToJObj) -> migrate_from_doc(FromJObj, ToJObj) -> kz_json:foldl(fun migrate_config_doc_node/3, ToJObj, kz_doc:public_fields(FromJObj, 'false')). --spec migrate_config_doc_node(ne_binary(), kz_json:object(), kz_json:object()) -> kz_json:object(). +-spec migrate_config_doc_node(kz_term:ne_binary(), kz_json:object(), kz_json:object()) -> kz_json:object(). migrate_config_doc_node(FromNodeBefore, FromConfig, ToJObj) -> FromNode = maybe_fix_nodename(FromNodeBefore), kz_json:foldl(fun(ConfigKey, ConfigValue, Acc) -> @@ -1163,21 +1163,21 @@ migrate_config_doc_node(FromNodeBefore, FromConfig, ToJObj) -> ,FromConfig ). --spec migrate_config_value(ne_binary(), ne_binary(), kz_json:json_term(), kz_json:object()) -> +-spec migrate_config_value(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:json_term(), kz_json:object()) -> kz_json:object(). migrate_config_value(FromNode, <<"whapps">>, ConfigValue, ToJObj) -> kz_json:set_value([FromNode, <<"kapps">>], ConfigValue, ToJObj); migrate_config_value(FromNode, ConfigKey, ConfigValue, ToJObj) -> kz_json:set_value([FromNode, ConfigKey], ConfigValue, ToJObj). --spec maybe_fix_nodename(ne_binary()) -> ne_binary(). +-spec maybe_fix_nodename(kz_term:ne_binary()) -> kz_term:ne_binary(). maybe_fix_nodename(<<"whistle_apps@", Host/binary>>) -> lager:info("changing whistle_apps@~s to kazoo_apps@~s", [Host, Host]), <<"kazoo_apps@", Host/binary>>; maybe_fix_nodename(NodeName) -> NodeName. --spec open_to_doc(ne_binary()) -> kz_json:object(). +-spec open_to_doc(kz_term:ne_binary()) -> kz_json:object(). open_to_doc(ToId) -> case kz_datamgr:open_doc(?KZ_CONFIG_DB, ToId) of {'ok', ToJObj} -> ToJObj; diff --git a/core/kazoo_config/src/kapps_config_doc.erl b/core/kazoo_config/src/kapps_config_doc.erl index 28ce8ff397d..a0858292b3c 100644 --- a/core/kazoo_config/src/kapps_config_doc.erl +++ b/core/kazoo_config/src/kapps_config_doc.erl @@ -22,20 +22,20 @@ maybe_new({ok, JObj}) -> JObj; maybe_new(_) -> kz_json:new(). --spec get_keys(kz_json:object()) -> [ne_binary()]. +-spec get_keys(kz_json:object()) -> [kz_term:ne_binary()]. get_keys(Config) -> kz_json:get_keys(kz_doc:public_fields(Config)) -- [?DEFAULT]. --spec get_config(ne_binary()) -> kz_json:object(). +-spec get_config(kz_term:ne_binary()) -> kz_json:object(). get_config(Id) -> JObj = kz_doc:public_fields(maybe_new(kapps_config:get_category(Id))), kz_json:filter(fun({_, V}) -> kz_json:is_json_object(V) end, JObj). --spec get_node(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec get_node(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). get_node(Config, Node) -> kz_json:get_value(Node, Config, kz_json:new()). --spec apply_default_values(kz_json:object(), ne_binary(), kz_json:object()) -> kz_json:object(). +-spec apply_default_values(kz_json:object(), kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). apply_default_values(Config, Node, Default) -> NodeValue = get_node(Config, Node), kz_json:set_value(Node, kz_json:merge(Default, NodeValue), Config). @@ -45,16 +45,16 @@ apply_default_node(Config) -> Default = kz_json:get_value(?DEFAULT, Config, kz_json:new()), lists:foldl(fun(K,A) -> apply_default_values(A, K, Default) end, Config, get_keys(Config)). --spec apply_schema_defaults(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec apply_schema_defaults(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). apply_schema_defaults(Id, Config) -> Default = schema_defaults(Id), lists:foldl(fun(K,A) -> apply_default_values(A, K, Default) end, Config, [?DEFAULT|get_keys(Config)]). --spec apply_schema_defaults_to_default(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec apply_schema_defaults_to_default(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). apply_schema_defaults_to_default(Id, Config) -> apply_default_values(Config, ?DEFAULT, schema_defaults(Id)). --spec schema_defaults(ne_binary()) -> kz_json:object(). +-spec schema_defaults(kz_term:ne_binary()) -> kz_json:object(). schema_defaults(Id) -> kz_json_schema:default_object(kapps_config_util:system_schema(Id)). @@ -65,31 +65,31 @@ maybe_insert_default_node(Config) -> _Else -> Config end. --spec config_with_defaults(ne_binary()) -> kz_json:object(). +-spec config_with_defaults(kz_term:ne_binary()) -> kz_json:object(). config_with_defaults(Id) -> apply_schema_defaults(Id, maybe_insert_default_node(apply_default_node(get_config(Id)))). --spec default_config(ne_binary(), [ne_binary()]) -> kz_json:object(). +-spec default_config(kz_term:ne_binary(), [kz_term:ne_binary()]) -> kz_json:object(). default_config(Id, Keys) -> DefaultNode = schema_defaults(Id), lists:foldl(fun(Key,A) -> kz_json:set_value(Key, DefaultNode, A) end, kz_json:new(), [?DEFAULT|Keys]). --spec stored_config(ne_binary(), kz_json:keys()) -> kz_json:object(). +-spec stored_config(kz_term:ne_binary(), kz_json:keys()) -> kz_json:object(). stored_config(Id, Keys) -> Config = config_with_default_node(Id), Default = kz_json:get_value(?DEFAULT, Config, kz_json:new()), lists:foldl(fun(K,A) -> apply_default_values(A, K, Default) end, Config, Keys). --spec config_with_default_node(ne_binary()) -> kz_json:object(). +-spec config_with_default_node(kz_term:ne_binary()) -> kz_json:object(). config_with_default_node(Id) -> Config = get_config(Id), apply_default_values(Config, ?DEFAULT, schema_defaults(Id)). --spec diff_from_default(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec diff_from_default(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). diff_from_default(Id, JObj) -> kz_json:diff(JObj, build_default(Id, JObj)). --spec build_default(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec build_default(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). build_default(Id, JObj) -> Default = kz_json:get_value(?DEFAULT, JObj, kz_json:new()), Config = lists:foldl(fun(K,A) -> apply_default_values(A, K, Default) end, kz_json:new(), get_keys(JObj)), @@ -99,23 +99,23 @@ build_default(Id, JObj) -> %% Node API %% ---------------------------------------------------------- --spec default_node(ne_binary(), ne_binary()) -> kz_json:object(). +-spec default_node(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). default_node(Id, ?DEFAULT) -> schema_defaults(Id); default_node(Id, _Node) -> stored_node(Id, ?DEFAULT). --spec stored_node(ne_binary(), ne_binary()) -> kz_json:object(). +-spec stored_node(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). stored_node(Id, Node) -> get_node(stored_config(Id, [Node]), Node). --spec diff_node_from_default(ne_binary(), ne_binary(), kz_json:object()) -> kz_json:object(). +-spec diff_node_from_default(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). diff_node_from_default(Id, ?DEFAULT, JObj) -> kz_json:diff(JObj, schema_defaults(Id)); diff_node_from_default(Id, _Node, JObj) -> kz_json:diff(JObj, stored_node(Id, ?DEFAULT)). --spec list_configs() -> [ne_binary()]. +-spec list_configs() -> [kz_term:ne_binary()]. list_configs() -> case kz_datamgr:get_results(?KZ_CONFIG_DB, <<"system_configs/crossbar_listing">>, []) of {ok, List} -> [ kz_json:get_value(<<"id">>, JSON) || JSON <- List ]; diff --git a/core/kazoo_config/src/kapps_config_util.erl b/core/kazoo_config/src/kapps_config_util.erl index 0f0f2e61143..9a55143c214 100644 --- a/core/kazoo_config/src/kapps_config_util.erl +++ b/core/kazoo_config/src/kapps_config_util.erl @@ -21,10 +21,10 @@ ,account_doc_id/1 ]). --spec account_doc_id(ne_binary()) -> ne_binary(). +-spec account_doc_id(kz_term:ne_binary()) -> kz_term:ne_binary(). account_doc_id(Category) -> <<(?KZ_ACCOUNT_CONFIGS)/binary, Category/binary>>. --spec get_config(ne_binary(), ne_binary()) -> kz_json:object(). +-spec get_config(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). get_config(Account, Config) -> Programm = [fun load_config_from_account/2 ,fun load_config_from_reseller/2 @@ -34,12 +34,12 @@ get_config(Account, Config) -> Schema = account_schema(Config), kz_json_schema:filter(get_config(Account, Config, Programm), Schema). --spec get_config(ne_binary(), ne_binary(), functions()) -> kz_json:object(). +-spec get_config(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:functions()) -> kz_json:object(). get_config(Account, Config, Programm) -> Confs = [maybe_new(P(Account, Config)) || P <- Programm], kz_json:merge(lists:reverse(Confs)). --spec get_reseller_config(ne_binary(), ne_binary()) -> kz_json:object(). +-spec get_reseller_config(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). get_reseller_config(Account, Config) -> Programm = [fun load_config_from_reseller/2 ,fun load_config_from_system/2 @@ -48,13 +48,13 @@ get_reseller_config(Account, Config) -> Schema = account_schema(Config), kz_json_schema:filter(get_config(Account, Config, Programm), Schema). --spec load_config_from_account(api_binary(), ne_binary()) -> {ok, kz_json:object()} | {error, any()}. +-spec load_config_from_account(kz_term:api_binary(), kz_term:ne_binary()) -> {ok, kz_json:object()} | {error, any()}. load_config_from_account(undefined, _Config) -> {ok, kz_json:new()}; load_config_from_account(Account, Config) -> AccountDb = kz_util:format_account_db(Account), kz_datamgr:open_cache_doc(AccountDb, account_doc_id(Config), [{cache_failures, [not_found]}]). --spec load_config_from_reseller(api_binary(), ne_binary()) -> {ok, kz_json:object()} | {error, any()}. +-spec load_config_from_reseller(kz_term:api_binary(), kz_term:ne_binary()) -> {ok, kz_json:object()} | {error, any()}. load_config_from_reseller(undefined, _Config) -> {error, not_found}; load_config_from_reseller(Account, Config) -> case kz_services:find_reseller_id(Account) of @@ -65,11 +65,11 @@ load_config_from_reseller(Account, Config) -> ResellerId -> load_config_from_account(ResellerId, Config) end. --spec load_config_from_system(api_binary(), ne_binary()) -> {ok, kz_json:object()}. +-spec load_config_from_system(kz_term:api_binary(), kz_term:ne_binary()) -> {ok, kz_json:object()}. load_config_from_system(_Account, Config) -> {'ok', kz_json:get_value(<<"default">>, maybe_new(kapps_config:get_category(Config)), kz_json:new())}. --spec load_default_config(api_binary(), ne_binary()) -> {ok, kz_json:object()}. +-spec load_default_config(kz_term:api_binary(), kz_term:ne_binary()) -> {ok, kz_json:object()}. load_default_config(_Account, Config) -> Schema = system_schema(Config), {'ok', kz_doc:set_id(kz_json_schema:default_object(Schema), account_doc_id(Config))}. @@ -78,27 +78,27 @@ load_default_config(_Account, Config) -> maybe_new({'ok', JObj}) -> JObj; maybe_new({'error', _}) -> kz_json:new(). --spec account_schema_name(ne_binary()) -> ne_binary(). +-spec account_schema_name(kz_term:ne_binary()) -> kz_term:ne_binary(). account_schema_name(Config) when is_binary(Config) -> <<"account_config.", Config/binary>>. --spec system_schema_name(ne_binary()) -> ne_binary(). +-spec system_schema_name(kz_term:ne_binary()) -> kz_term:ne_binary(). system_schema_name(Config) when is_binary(Config) -> <<"system_config.", Config/binary>>. --spec system_schema(ne_binary()) -> kz_json:object(). +-spec system_schema(kz_term:ne_binary()) -> kz_json:object(). system_schema(Config) when is_binary(Config) -> Name = system_schema_name(Config), {'ok', Schema} = kz_json_schema:load(Name), Schema. --spec account_schema(ne_binary()) -> kz_json:object(). +-spec account_schema(kz_term:ne_binary()) -> kz_json:object(). account_schema(Config) when is_binary(Config) -> Name = account_schema_name(Config), {'ok', Schema} = kz_json_schema:load(Name), Schema. --spec system_config_document_schema(ne_binary()) -> kz_json:object(). +-spec system_config_document_schema(kz_term:ne_binary()) -> kz_json:object(). system_config_document_schema(Id) -> Flat = [ {[<<"$schema">>],<<"http://json-schema.org/draft-04/schema#">>} diff --git a/core/kazoo_config/src/kazoo_config_app.erl b/core/kazoo_config/src/kazoo_config_app.erl index 9d2746f1a3a..6c6ea1b9ce8 100644 --- a/core/kazoo_config/src/kazoo_config_app.erl +++ b/core/kazoo_config/src/kazoo_config_app.erl @@ -21,7 +21,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_StartType, _StartArgs) -> kazoo_config_sup:start_link(). diff --git a/core/kazoo_config/src/kazoo_config_init.erl b/core/kazoo_config/src/kazoo_config_init.erl index 24adb040e1b..069392946a9 100644 --- a/core/kazoo_config/src/kazoo_config_init.erl +++ b/core/kazoo_config/src/kazoo_config_init.erl @@ -19,7 +19,7 @@ %% @public %% @doc Starts the app for inclusion in a supervisor tree %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> set_env(), 'ignore'. @@ -31,11 +31,11 @@ ini_files() -> File -> [File] end. --spec load_file() -> kz_proplist(). +-spec load_file() -> kz_term:proplist(). load_file() -> maybe_load_file(ini_files()). --spec maybe_load_file(list(file:name())) -> kz_proplist(). +-spec maybe_load_file(list(file:name())) -> kz_term:proplist(). maybe_load_file([]) -> lager:warning("out of config files to attempt, loading defaults..."), ?SECTION_DEFAULTS; diff --git a/core/kazoo_config/src/kazoo_config_sup.erl b/core/kazoo_config/src/kazoo_config_sup.erl index 04daa66a261..a2af95b95b7 100644 --- a/core/kazoo_config/src/kazoo_config_sup.erl +++ b/core/kazoo_config/src/kazoo_config_sup.erl @@ -27,7 +27,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -44,7 +44,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 25, diff --git a/core/kazoo_config/src/kz_config.erl b/core/kazoo_config/src/kz_config.erl index 44e630ac90c..4a7bb1f5ef0 100644 --- a/core/kazoo_config/src/kz_config.erl +++ b/core/kazoo_config/src/kz_config.erl @@ -29,15 +29,15 @@ %% Return a section of the config file %% @end %%-------------------------------------------------------------------- --spec get(section()) -> kz_proplist(). +-spec get(section()) -> kz_term:proplist(). get(Section) -> find_values(Section, ?DEFAULT_DEFAULTS). --spec get(section(), atom()) -> kz_proplist(). +-spec get(section(), atom()) -> kz_term:proplist(). get(Section, Key) -> get(Section, Key, ?DEFAULT_DEFAULTS). --spec get(section(), atom(), Default) -> kz_proplist() | Default. +-spec get(section(), atom(), Default) -> kz_term:proplist() | Default. get(Section, Key, Default) -> case find_values(Section, Key) of [] -> Default; @@ -144,7 +144,7 @@ get_node_section_name() -> %% @end %%-------------------------------------------------------------------- -spec set(section(), atom(), term()) -> 'ok'. --spec set({section(), kz_proplist()}, kz_proplist()) -> 'ok'. +-spec set({section(), kz_term:proplist()}, kz_term:proplist()) -> 'ok'. set(Section, Key, Value) -> Props = load(), case props:get_value(Section, Props) of @@ -176,7 +176,7 @@ unset(Section, Key) -> %% %% @end %%-------------------------------------------------------------------- --spec find_values(section(), kz_proplist()) -> list(). +-spec find_values(section(), kz_term:proplist()) -> list(). find_values(Section, ?DEFAULT_DEFAULTS) -> get_sections(Section, load()); find_values(Section, Keys) when is_list(Keys) -> @@ -191,7 +191,7 @@ find_values(Section, Key) -> %% %% @end %%-------------------------------------------------------------------- --spec get_sections(section(), kz_proplist()) -> kz_proplist(). +-spec get_sections(section(), kz_term:proplist()) -> kz_term:proplist(). get_sections('zone' = Section, Prop) -> Sections = props:get_all_values(Section, Prop), format_sections(Sections, 'name', []); @@ -199,7 +199,7 @@ get_sections(Section, Prop) -> Sections = props:get_all_values(Section, Prop), format_sections(Sections). --spec get_section(section()) -> kz_proplist(). +-spec get_section(section()) -> kz_term:proplist(). get_section(Section) -> Prop = load(), Sections = props:get_all_values(Section, Prop), @@ -211,10 +211,10 @@ get_section(Section) -> %% %% @end %%-------------------------------------------------------------------- --spec format_sections(kz_proplist()) -> kz_proplist(). +-spec format_sections(kz_term:proplist()) -> kz_term:proplist(). format_sections(Sections) -> format_sections(Sections, 'zone', []). --spec format_sections(kz_proplist(), atom(), kz_proplist()) -> kz_proplist(). +-spec format_sections(kz_term:proplist(), atom(), kz_term:proplist()) -> kz_term:proplist(). format_sections([], _, Acc) -> local_sections(lists:reverse(Acc)); format_sections([Section | T], ZoneFilter, Acc) -> case props:get_value('host', Section, 'zone') of @@ -224,8 +224,8 @@ format_sections([Section | T], ZoneFilter, Acc) -> format_sections(T, ZoneFilter, [{kz_term:to_binary(Host), Section} | Acc]) end. --spec format_zone_section(kz_proplist(), kz_proplist(), atom(), kz_proplist()) -> - kz_proplist(). +-spec format_zone_section(kz_term:proplist(), kz_term:proplist(), atom(), kz_term:proplist()) -> + kz_term:proplist(). format_zone_section(Section, Sections, ZoneFilter, Acc) -> case props:get_value(ZoneFilter, Section, 'generic') of 'generic' -> @@ -240,10 +240,10 @@ format_zone_section(Section, Sections, ZoneFilter, Acc) -> %% %% @end %%-------------------------------------------------------------------- --spec local_sections(kz_proplist()) -> kz_proplist(). +-spec local_sections(kz_term:proplist()) -> kz_term:proplist(). local_sections(Sections) -> local_sections(Sections, []). --spec local_sections(kz_proplist(), kz_proplist()) -> kz_proplist(). +-spec local_sections(kz_term:proplist(), kz_term:proplist()) -> kz_term:proplist(). local_sections([], Acc) -> props:get_first_defined(['zones', 'generics'], Acc, []); local_sections([Section | T], Acc) -> @@ -254,10 +254,10 @@ local_sections([Section | T], Acc) -> {'false', _} -> local_sections(T, Acc) end. --type section_type() :: {'generic' | ne_binary() | {'zone', atom()}, kz_proplist()}. +-type section_type() :: {'generic' | kz_term:ne_binary() | {'zone', atom()}, kz_term:proplist()}. --spec add_section('generics' | 'zones', section_type(), kz_proplist()) -> - kz_proplist(). +-spec add_section('generics' | 'zones', section_type(), kz_term:proplist()) -> + kz_term:proplist(). add_section(Group, Value, Props) -> props:set_value(Group, [Value | props:get_value(Group, Props, [])], Props). @@ -267,9 +267,9 @@ add_section(Group, Value, Props) -> %% %% @end %%-------------------------------------------------------------------- --spec is_local_section({ne_binary() | atom(), any()}) -> {'false', 'generic'} | - {'false', 'zone'} | - {boolean(), ne_binary()}. +-spec is_local_section({kz_term:ne_binary() | atom(), any()}) -> {'false', 'generic'} | + {'false', 'zone'} | + {boolean(), kz_term:ne_binary()}. is_local_section({'generic', _}) -> {'false', 'generic'}; is_local_section({{'zone', Zone}, _}) -> @@ -291,7 +291,7 @@ is_local_section({SectionHost, _}) -> %% %% @end %%-------------------------------------------------------------------- --spec get_values(atom(), kz_proplist()) -> list(). +-spec get_values(atom(), kz_term:proplist()) -> list(). get_values(Key, Sections) -> get_values(Sections, Key, []). get_values([], _, []) -> []; @@ -306,7 +306,7 @@ get_values([{_, Values} | T], Key, Acc) -> %% %% @end %%-------------------------------------------------------------------- --spec load() -> kz_proplist(). +-spec load() -> kz_term:proplist(). load() -> case erlang:get(?SETTINGS_KEY) of 'undefined' -> @@ -330,6 +330,6 @@ zone() -> {'ok', Zone} -> Zone end. --spec zone(atom()) -> ne_binary() | atom(). +-spec zone(atom()) -> kz_term:ne_binary() | atom(). zone('binary') -> kz_term:to_binary(zone()); zone(_) -> zone(). diff --git a/core/kazoo_couch/src/kazoo_couch.erl b/core/kazoo_couch/src/kazoo_couch.erl index fe299e2c019..a6d4b2cad83 100644 --- a/core/kazoo_couch/src/kazoo_couch.erl +++ b/core/kazoo_couch/src/kazoo_couch.erl @@ -70,12 +70,12 @@ format_error(Error) -> kz_couch_util:format_error(Error). %% Connection operations --spec get_db(kz_data:connection(), ne_binary()) -> any(). +-spec get_db(kz_data:connection(), kz_term:ne_binary()) -> any(). get_db(Server, DbName) -> kz_couch_util:get_db(Server, DbName). --spec get_admin_dbs() -> ne_binary(). --spec get_admin_dbs(couch_version() | kz_data:connection()) -> ne_binary(). +-spec get_admin_dbs() -> kz_term:ne_binary(). +-spec get_admin_dbs(couch_version() | kz_data:connection()) -> kz_term:ne_binary(). get_admin_dbs() -> #{server := {_App, #server{}=Conn}} = kzs_plan:plan(), get_admin_dbs(Conn). @@ -85,8 +85,8 @@ get_admin_dbs(#server{}=Server) -> get_admin_dbs('bigcouch') -> <<"dbs">>; get_admin_dbs(_Driver) -> <<"_dbs">>. --spec get_admin_nodes() -> ne_binary(). --spec get_admin_nodes(couch_version() | kz_data:connection()) -> ne_binary(). +-spec get_admin_nodes() -> kz_term:ne_binary(). +-spec get_admin_nodes(couch_version() | kz_data:connection()) -> kz_term:ne_binary(). get_admin_nodes() -> #{server := {_App, #server{}=Conn}} = kzs_plan:plan(), get_admin_nodes(Conn). @@ -96,11 +96,11 @@ get_admin_nodes(#server{}=Server) -> get_admin_nodes('bigcouch') -> <<"nodes">>; get_admin_nodes(_Driver) -> <<"_nodes">>. --spec server_url(kz_data:connection()) -> ne_binary(). +-spec server_url(kz_data:connection()) -> kz_term:ne_binary(). server_url(Server) -> kz_couch_util:server_url(Server). --spec db_url(kz_data:connection(), ne_binary()) -> ne_binary(). +-spec db_url(kz_data:connection(), kz_term:ne_binary()) -> kz_term:ne_binary(). db_url(Server, DbName) -> kz_couch_util:db_url(Server, DbName). @@ -109,15 +109,15 @@ server_info(Server) -> kz_couch_util:server_info(Server). %% DB operations --spec db_create(kz_data:connection(), ne_binary(), kz_data:options()) -> any(). +-spec db_create(kz_data:connection(), kz_term:ne_binary(), kz_data:options()) -> any(). db_create(Server, DbName, Options) -> kz_couch_db:db_create(Server, DbName, Options). --spec db_delete(kz_data:connection(), ne_binary()) -> any(). +-spec db_delete(kz_data:connection(), kz_term:ne_binary()) -> any(). db_delete(Server, DbName) -> kz_couch_db:db_delete(Server, DbName). --spec db_view_cleanup(kz_data:connection(), ne_binary()) -> boolean(). +-spec db_view_cleanup(kz_data:connection(), kz_term:ne_binary()) -> boolean(). db_view_cleanup(Server, DbName) -> kz_couch_db:db_view_cleanup(Server, DbName). @@ -125,19 +125,19 @@ db_view_cleanup(Server, DbName) -> db_info(Server) -> kz_couch_db:db_info(Server). --spec db_info(kz_data:connection(), ne_binary()) -> any(). +-spec db_info(kz_data:connection(), kz_term:ne_binary()) -> any(). db_info(Server, DbName) -> kz_couch_db:db_info(Server, DbName). --spec db_exists(kz_data:connection(), ne_binary()) -> boolean(). +-spec db_exists(kz_data:connection(), kz_term:ne_binary()) -> boolean(). db_exists(Server, DbName) -> kz_couch_db:db_exists(Server, DbName). --spec db_archive(kz_data:connection(), ne_binary(), ne_binary()) -> any(). +-spec db_archive(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary()) -> any(). db_archive(Server, DbName, Filename) -> kz_couch_db:db_archive(Server, DbName, Filename). --spec db_import(kz_data:connection(), ne_binary(), ne_binary()) -> any(). +-spec db_import(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary()) -> any(). db_import(Server, DbName, Filename) -> kz_couch_db:db_import(Server, DbName, Filename). @@ -158,31 +158,31 @@ db_list('couchdb_1_6', Server, Options) -> {'ok', db_local_filter(List, Options)}. %% Document operations --spec open_doc(kz_data:connection(), ne_binary(), ne_binary(), kz_data:options()) -> any(). +-spec open_doc(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> any(). open_doc(Server, DbName, DocId, Options) -> kz_couch_doc:open_doc(Server, DbName, DocId, Options). --spec lookup_doc_rev(kz_data:connection(), ne_binary(), ne_binary()) -> any(). +-spec lookup_doc_rev(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary()) -> any(). lookup_doc_rev(Server, DbName, DocId) -> kz_couch_doc:lookup_doc_rev(Server, DbName, DocId). --spec save_doc(kz_data:connection(), ne_binary(), kz_data:document(), kz_data:options()) -> any(). +-spec save_doc(kz_data:connection(), kz_term:ne_binary(), kz_data:document(), kz_data:options()) -> any(). save_doc(Server, DbName, Doc, Options) -> kz_couch_doc:save_doc(Server, DbName, Doc, Options). --spec save_docs(kz_data:connection(), ne_binary(), kz_data:documents(), kz_data:options()) -> any(). +-spec save_docs(kz_data:connection(), kz_term:ne_binary(), kz_data:documents(), kz_data:options()) -> any(). save_docs(Server, DbName, Docs, Options) -> kz_couch_doc:save_docs(Server, DbName, Docs, Options). --spec del_doc(kz_data:connection(), ne_binary(), kz_data:document(), kz_data:options()) -> any(). +-spec del_doc(kz_data:connection(), kz_term:ne_binary(), kz_data:document(), kz_data:options()) -> any(). del_doc(Server, DbName, Doc, Options) -> kz_couch_doc:del_doc(Server, DbName, Doc, Options). --spec del_docs(kz_data:connection(), ne_binary(), kz_data:documents(), kz_data:options()) -> any(). +-spec del_docs(kz_data:connection(), kz_term:ne_binary(), kz_data:documents(), kz_data:options()) -> any(). del_docs(Server, DbName, Docs, Options) -> kz_couch_doc:del_docs(Server, DbName, Docs, Options). --spec ensure_saved(kz_data:connection(), ne_binary(), kz_data:document(), kz_data:options()) -> any(). +-spec ensure_saved(kz_data:connection(), kz_term:ne_binary(), kz_data:document(), kz_data:options()) -> any(). ensure_saved(Server, DbName, DocId, Options) -> kz_couch_doc:ensure_saved(Server, DbName, DocId, Options). @@ -195,50 +195,50 @@ move_doc(Server, CopySpec, Options) -> kz_couch_doc:move_doc(Server, CopySpec, Options). %% Attachment-related --spec fetch_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary()) -> any(). +-spec fetch_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> any(). fetch_attachment(Server, DbName, DocId, AName) -> kz_couch_attachments:fetch_attachment(Server, DbName, DocId, AName). --spec stream_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary(), pid()) -> +-spec stream_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), pid()) -> {'ok', doc()} | {'error', any()}. stream_attachment(Server, DbName, DocId, AName, Caller) -> kz_couch_attachments:stream_attachment(Server, DbName, DocId, AName, Caller). --spec put_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_data:options()) -> any(). +-spec put_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> any(). put_attachment(Server, DbName, DocId, AName, Contents, Options) -> kz_couch_attachments:put_attachment(Server, DbName, DocId, AName, Contents, Options). --spec delete_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary(), kz_data:options()) -> any(). +-spec delete_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> any(). delete_attachment(Server, DbName, DocId, AName, Options) -> kz_couch_attachments:delete_attachment(Server, DbName, DocId, AName, Options). --spec attachment_url(kz_data:connection(), ne_binary(), ne_binary(), ne_binary(), kz_data:options()) -> any(). +-spec attachment_url(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> any(). attachment_url(Server, DbName, DocId, AName, Options) -> kz_couch_attachments:attachment_url(Server, DbName, DocId, AName, Options). %% View-related --spec design_info(kz_data:connection(), ne_binary(), ne_binary()) -> any(). +-spec design_info(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary()) -> any(). design_info(Server, DBName, Design) -> kz_couch_view:design_info(Server, DBName, Design). --spec design_compact(kz_data:connection(), ne_binary(), ne_binary()) -> any(). +-spec design_compact(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary()) -> any(). design_compact(Server, DbName, Design) -> kz_couch_view:design_compact(Server, DbName, Design). --spec all_design_docs(kz_data:connection(), ne_binary(), kz_data:options()) -> any(). +-spec all_design_docs(kz_data:connection(), kz_term:ne_binary(), kz_data:options()) -> any(). all_design_docs(#server{}=Server, ?NE_BINARY = DBName, Options) -> kz_couch_view:all_design_docs(Server, DBName, Options). --spec get_results(kz_data:connection(), ne_binary(), ne_binary(), kz_data:options()) -> any(). +-spec get_results(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> any(). get_results(Server, DbName, DesignDoc, ViewOptions) -> kz_couch_view:get_results(Server, DbName, DesignDoc, ViewOptions). --spec get_results_count(kz_data:connection(), ne_binary(), ne_binary(), kz_data:options()) -> any(). +-spec get_results_count(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> any(). get_results_count(Server, DbName, DesignDoc, ViewOptions) -> kz_couch_view:get_results_count(Server, DbName, DesignDoc, ViewOptions). --spec all_docs(kz_data:connection(), ne_binary(), kz_data:options()) -> any(). +-spec all_docs(kz_data:connection(), kz_term:ne_binary(), kz_data:options()) -> any(). all_docs(Server, DbName, Options) -> kz_couch_view:all_docs(Server, DbName, Options). @@ -246,13 +246,13 @@ all_docs(Server, DbName, Options) -> server_version(#server{options=Options}) -> props:get_value('driver_version', Options). --spec db_local_filter(ne_binaries(), kz_data:options()) -> ne_binaries(). +-spec db_local_filter(kz_term:ne_binaries(), kz_data:options()) -> kz_term:ne_binaries(). db_local_filter(List, Options) -> [DB || DB <- List, all_valid_options(Options, DB) ]. --spec all_valid_options(kz_data:options(), ne_binary()) -> boolean(). +-spec all_valid_options(kz_data:options(), kz_term:ne_binary()) -> boolean(). all_valid_options(Options, DB) -> lists:all(fun(Option) -> db_local_filter_option(Option, DB) @@ -260,7 +260,7 @@ all_valid_options(Options, DB) -> ,Options ). --spec db_local_filter_option(kz_data:option(), ne_binary()) -> boolean(). +-spec db_local_filter_option(kz_data:option(), kz_term:ne_binary()) -> boolean(). db_local_filter_option({'start_key', Value}, DB) -> DB >= Value; db_local_filter_option({'startkey', Value}, DB) -> diff --git a/core/kazoo_couch/src/kazoo_couch_app.erl b/core/kazoo_couch/src/kazoo_couch_app.erl index d699ccbc31d..d7f8eb41735 100644 --- a/core/kazoo_couch/src/kazoo_couch_app.erl +++ b/core/kazoo_couch/src/kazoo_couch_app.erl @@ -14,7 +14,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_StartType, _StartArgs) -> kazoo_couch_sup:start_link(). diff --git a/core/kazoo_couch/src/kazoo_couch_sup.erl b/core/kazoo_couch/src/kazoo_couch_sup.erl index 52464482b6b..2f1538d9432 100644 --- a/core/kazoo_couch/src/kazoo_couch_sup.erl +++ b/core/kazoo_couch/src/kazoo_couch_sup.erl @@ -27,7 +27,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -44,7 +44,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, diff --git a/core/kazoo_couch/src/kz_couch.hrl b/core/kazoo_couch/src/kz_couch.hrl index 1d0b289c9b6..1c1c56cfec1 100644 --- a/core/kazoo_couch/src/kz_couch.hrl +++ b/core/kazoo_couch/src/kz_couch.hrl @@ -39,7 +39,7 @@ -record(design_data, {db_name = <<>> :: binary() %% the actual DB name, encoded (/ -> %2f) ,design_name = <<>> :: binary() ,node :: atom() - ,shards = [] :: ne_binaries() + ,shards = [] :: kz_term:ne_binaries() ,disk_size = 0 :: non_neg_integer() ,data_size = 0 :: non_neg_integer() ,conn = #server{} :: server() @@ -60,7 +60,7 @@ ,port = ?DEFAULT_PORT ,username = "" ,password = "" - ,options = [] :: kz_proplist() + ,options = [] :: kz_term:proplist() ,connected = 'false' ,ready = 'false' ,admin = 'false' @@ -71,10 +71,10 @@ -type couchbeam_db() :: #db{}. --record(kz_copy_doc, {source_dbname :: ne_binary() - ,source_doc_id :: ne_binary() - ,dest_dbname = 'undefined' :: api_binary() - ,dest_doc_id = 'undefined' :: api_binary() +-record(kz_copy_doc, {source_dbname :: kz_term:ne_binary() + ,source_doc_id :: kz_term:ne_binary() + ,dest_dbname = 'undefined' :: kz_term:api_binary() + ,dest_doc_id = 'undefined' :: kz_term:api_binary() }). -type copy_doc() :: #kz_copy_doc{}. diff --git a/core/kazoo_couch/src/kz_couch_attachments.erl b/core/kazoo_couch/src/kz_couch_attachments.erl index 59ba663007c..22c291790b0 100644 --- a/core/kazoo_couch/src/kz_couch_attachments.erl +++ b/core/kazoo_couch/src/kz_couch_attachments.erl @@ -21,23 +21,23 @@ -include("kz_couch.hrl"). %% Attachment-related functions ------------------------------------------------ --spec fetch_attachment(server(), ne_binary(), ne_binary(), ne_binary()) -> +-spec fetch_attachment(server(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', binary()} | couchbeam_error(). fetch_attachment(#server{}=Conn, DbName, DocId, AName) -> Db = kz_couch_util:get_db(Conn, DbName), do_fetch_attachment(Db, DocId, AName). --spec stream_attachment(server(), ne_binary(), ne_binary(), ne_binary(), pid()) -> +-spec stream_attachment(server(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), pid()) -> {'ok', reference()} | couchbeam_error(). stream_attachment(#server{}=Conn, DbName, DocId, AName, Caller) -> do_stream_attachment(kz_couch_util:get_db(Conn, DbName), DocId, AName, Caller). --spec put_attachment(server(), ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> +-spec put_attachment(server(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | couchbeam_error(). --spec put_attachment(server(), ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_proplist()) -> +-spec put_attachment(server(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> {'ok', kz_json:object()} | couchbeam_error(). put_attachment(#server{}=Conn, DbName, DocId, AName, Contents) -> @@ -47,10 +47,10 @@ put_attachment(#server{}=Conn, DbName, DocId, AName, Contents, Options) -> Db = kz_couch_util:get_db(Conn, DbName), do_put_attachment(Db, DocId, AName, Contents, Options). --spec delete_attachment(server(), ne_binary(), ne_binary(), ne_binary()) -> +-spec delete_attachment(server(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | couchbeam_error(). --spec delete_attachment(server(), ne_binary(), ne_binary(), ne_binary(), kz_proplist()) -> +-spec delete_attachment(server(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> {'ok', kz_json:object()} | couchbeam_error(). delete_attachment(#server{}=Conn, DbName, DocId, AName) -> @@ -60,8 +60,8 @@ delete_attachment(#server{}=Conn, DbName, DocId, AName, Options) -> Db = kz_couch_util:get_db(Conn, DbName), do_del_attachment(Db, DocId, AName, kz_couch_util:maybe_add_rev(Db, DocId, Options)). --spec attachment_url(server(), ne_binary(), ne_binary(), ne_binary(), kz_proplist()) -> - ne_binary() | +-spec attachment_url(server(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> + kz_term:ne_binary() | {'proxy', tuple()}. attachment_url(#server{}=Conn, DbName, DocId, AName, Options) -> case kapps_config:get_is_true(?CONFIG_CAT, <<"use_bigcouch_direct">>, 'true') of @@ -76,13 +76,13 @@ attachment_url(#server{}=Conn, DbName, DocId, AName, Options) -> end. %% Internal Attachment-related functions --------------------------------------- --spec do_fetch_attachment(couchbeam_db(), ne_binary(), ne_binary()) -> +-spec do_fetch_attachment(couchbeam_db(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', binary()} | couchbeam_error(). do_fetch_attachment(#db{}=Db, DocId, AName) -> ?RETRY_504(couchbeam:fetch_attachment(Db, DocId, AName)). --spec do_stream_attachment(couchbeam_db(), ne_binary(), ne_binary(), pid()) -> +-spec do_stream_attachment(couchbeam_db(), kz_term:ne_binary(), kz_term:ne_binary(), pid()) -> {'ok', reference() | atom()} | couchbeam_error(). do_stream_attachment(#db{}=Db, DocId, AName, Caller) -> @@ -111,7 +111,7 @@ relay_stream_attachment(Caller, Ref, Msg) -> Caller ! {Ref, Msg}, relay_stream_attachment(Caller, Ref, couchbeam:stream_attachment(Ref)). --spec do_put_attachment(couchbeam_db(), ne_binary(), ne_binary(), ne_binary(), kz_proplist()) -> +-spec do_put_attachment(couchbeam_db(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> {'ok', kz_json:object()} | couchbeam_error(). do_put_attachment(#db{}=Db, DocId, AttName, Contents, Options) -> @@ -120,14 +120,14 @@ do_put_attachment(#db{}=Db, DocId, AttName, Contents, Options) -> AName = kz_http_util:urlencode(AttName), ?RETRY_504(couchbeam:put_attachment(Db, DocId, AName, Contents, Options)). --spec do_del_attachment(couchbeam_db(), ne_binary(), ne_binary(), kz_proplist()) -> +-spec do_del_attachment(couchbeam_db(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> {'ok', kz_json:object()} | couchbeam_error(). do_del_attachment(#db{}=Db, DocId, AName, Options) -> Doc = kz_term:to_binary(http_uri:encode(kz_term:to_list(DocId))), ?RETRY_504(couchbeam:delete_attachment(Db, Doc, AName, Options)). --spec maybe_add_revision(kz_proplist()) -> binary(). +-spec maybe_add_revision(kz_term:proplist()) -> binary(). maybe_add_revision(Options) -> case props:get_value('rev', Options) of 'undefined' -> <<>>; diff --git a/core/kazoo_couch/src/kz_couch_db.erl b/core/kazoo_couch/src/kz_couch_db.erl index 259dacd5587..15e96f17f21 100644 --- a/core/kazoo_couch/src/kz_couch_db.erl +++ b/core/kazoo_couch/src/kz_couch_db.erl @@ -32,16 +32,16 @@ get_db(#server{}=Conn, DbName) -> kz_couch_util:get_db(Conn, DbName). %%% DB-related functions --------------------------------------------- --spec db_compact(server(), ne_binary()) -> boolean(). +-spec db_compact(server(), kz_term:ne_binary()) -> boolean(). db_compact(#server{}=Conn, DbName) -> Db = get_db(Conn, DbName), do_db_compact(Db). --spec db_create(server(), ne_binary()) -> boolean(). +-spec db_create(server(), kz_term:ne_binary()) -> boolean(). db_create(#server{}=Conn, DbName) -> db_create(Conn, DbName, []). --spec db_create(server(), ne_binary(), db_create_options()) -> boolean(). +-spec db_create(server(), kz_term:ne_binary(), db_create_options()) -> boolean(). db_create(#server{}=Conn, DbName, Options) -> case do_db_create_db(Conn, DbName, Options, []) of {'ok', _} -> 'true'; @@ -73,21 +73,21 @@ do_db_create_db(#server{url=ServerUrl, options=Opts}=Server, DbName, Options, Pa Error end. --spec check_db_create_error(server(), ne_binary(), any()) -> boolean(). +-spec check_db_create_error(server(), kz_term:ne_binary(), any()) -> boolean(). check_db_create_error(Server, DbName, <<"conflict">>) -> lager:warning("db ~s creation failed with HTTP error 500 and conflict reason, checking db exists", [DbName]), db_exists(Server, DbName); check_db_create_error(_Server, _DbName, _Reason) -> 'false'. --spec db_delete(server(), ne_binary()) -> boolean(). +-spec db_delete(server(), kz_term:ne_binary()) -> boolean(). db_delete(#server{}=Conn, DbName) -> case couchbeam:delete_db(Conn, kz_term:to_list(DbName)) of {'error', _} -> 'false'; {'ok', _} -> 'true' end. --spec db_replicate(server(), kz_json:object() | kz_proplist()) -> +-spec db_replicate(server(), kz_json:object() | kz_term:proplist()) -> {'ok', kz_json:object()} | couchbeam_error(). db_replicate(#server{}=Conn, Prop) when is_list(Prop) -> @@ -96,31 +96,31 @@ db_replicate(#server{}=Conn, JObj) -> couchbeam:replicate(Conn, JObj). -spec db_list(server(), view_options()) -> - {'ok', kz_json:objects() | ne_binaries()} | couchbeam_error(). + {'ok', kz_json:objects() | kz_term:ne_binaries()} | couchbeam_error(). db_list(#server{}=Conn, Options) -> couchbeam:all_dbs(Conn, Options). --spec db_view_cleanup(server(), ne_binary()) -> boolean(). +-spec db_view_cleanup(server(), kz_term:ne_binary()) -> boolean(). db_view_cleanup(#server{}=Conn, DbName) -> do_db_view_cleanup(get_db(Conn, DbName)). -spec db_info(server()) -> - {'ok', ne_binaries()} | + {'ok', kz_term:ne_binaries()} | couchbeam_error(). db_info(#server{}=Conn) -> ?RETRY_504(couchbeam:all_dbs(Conn)). --spec db_info(server(), ne_binary()) -> +-spec db_info(server(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | couchbeam_error(). db_info(#server{}=Conn, DbName) -> ?RETRY_504(couchbeam:db_info(get_db(Conn, DbName))). --spec db_exists(server(), ne_binary()) -> boolean(). +-spec db_exists(server(), kz_term:ne_binary()) -> boolean(). db_exists(#server{}=Conn, DbName) -> couchbeam:db_exists(Conn, kz_term:to_list(DbName)). --spec db_archive(server(), ne_binary(), ne_binary()) -> +-spec db_archive(server(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | couchbeam_error(). db_archive(#server{}=Conn, DbName, Filename) -> @@ -137,7 +137,7 @@ db_archive(#server{}=Conn, DbName, Filename) -> %% MaxDocs = The biggest set of docs to pull from Couch %% N = The number of docs in the DB that haven't been archived %% Pos = Which doc will the next query start from (the offset) --spec archive(db(), ne_binary(), file:io_device(), pos_integer(), non_neg_integer(), non_neg_integer()) -> 'ok'. +-spec archive(db(), kz_term:ne_binary(), file:io_device(), pos_integer(), non_neg_integer(), non_neg_integer()) -> 'ok'. archive(_Db, DbName, _File, _MaxDocs, 0, _Pos) -> io:format(" archive ~s complete~n", [DbName]); archive(#db{}=Db, DbName, File, MaxDocs, N, Pos) when N =< MaxDocs -> @@ -180,7 +180,7 @@ archive_docs(File, [Doc|Docs]) -> 'ok' = file:write(File, [kz_json:encode(Doc), $,, $\n]), archive_docs(File, Docs). --spec db_import(server(), ne_binary(), ne_binary()) -> +-spec db_import(server(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | couchbeam_error(). db_import(#server{}=Conn, DbName, Filename) -> @@ -189,7 +189,7 @@ db_import(#server{}=Conn, DbName, Filename) -> Error -> Error end. --spec do_db_import(server(), ne_binary(), kz_json:objects()) -> +-spec do_db_import(server(), kz_term:ne_binary(), kz_json:objects()) -> 'ok' | couchbeam_error(). do_db_import(#server{}=Conn, DbName, Docs) -> diff --git a/core/kazoo_couch/src/kz_couch_doc.erl b/core/kazoo_couch/src/kz_couch_doc.erl index 2ad24d9e84b..9bb92ebc165 100644 --- a/core/kazoo_couch/src/kz_couch_doc.erl +++ b/core/kazoo_couch/src/kz_couch_doc.erl @@ -22,7 +22,7 @@ -include("kz_couch.hrl"). --type copy_function() :: fun((server(), ne_binary(), kz_json:object(), kz_proplist()) -> +-type copy_function() :: fun((server(), kz_term:ne_binary(), kz_json:object(), kz_term:proplist()) -> {'ok', kz_json:object()} | couchbeam_error()). -export_type([copy_function/0]). -define(COPY_DOC_OVERRIDE_PROPERTY, 'override_existing_document'). @@ -33,41 +33,41 @@ %% returns the #db{} record %% @end %%------------------------------------------------------------------------------ --spec get_db(server(), ne_binary()) -> db(). +-spec get_db(server(), kz_term:ne_binary()) -> db(). get_db(#server{}=Conn, DbName) -> kz_couch_util:get_db(Conn, DbName). %% Document related functions -------------------------------------------------- --spec open_doc(server(), ne_binary(), ne_binary()) -> +-spec open_doc(server(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | couchbeam_error(). open_doc(Conn, DbName, DocId) -> open_doc(Conn, DbName, DocId, []). --spec open_doc(server(), ne_binary(), ne_binary(), kz_proplist()) -> +-spec open_doc(server(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> {'ok', kz_json:object()} | couchbeam_error(). open_doc(#server{}=Conn, DbName, DocId, Options) -> Db = get_db(Conn, DbName), do_fetch_doc(Db, DocId, Options). --spec save_doc(server(), ne_binary(), kz_json:object(), kz_proplist()) -> +-spec save_doc(server(), kz_term:ne_binary(), kz_json:object(), kz_term:proplist()) -> {'ok', kz_json:object()} | couchbeam_error(). save_doc(#server{}=Conn, DbName, Doc, Options) -> Db = get_db(Conn, DbName), do_save_doc(Db, Doc, Options). --spec save_docs(server(), ne_binary(), kz_json:objects(), kz_proplist()) -> +-spec save_docs(server(), kz_term:ne_binary(), kz_json:objects(), kz_term:proplist()) -> {'ok', kz_json:objects()} | couchbeam_error(). save_docs(#server{}=Conn, DbName, Docs, Options) -> Db = get_db(Conn, DbName), do_save_docs(Db, Docs, Options). --spec lookup_doc_rev(server(), ne_binary(), ne_binary()) -> - {'ok', ne_binary()} | +-spec lookup_doc_rev(server(), kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | couchbeam_error(). lookup_doc_rev(#server{}=Conn, DbName, DocId) -> case do_fetch_rev(get_db(Conn, DbName), DocId) of @@ -75,21 +75,21 @@ lookup_doc_rev(#server{}=Conn, DbName, DocId) -> {'error', _}=E -> E end. --spec ensure_saved(server(), ne_binary(), kz_json:object(), kz_proplist()) -> +-spec ensure_saved(server(), kz_term:ne_binary(), kz_json:object(), kz_term:proplist()) -> {'ok', kz_json:object()} | couchbeam_error(). ensure_saved(#server{}=Conn, DbName, Doc, Opts) -> Db = get_db(Conn, DbName), do_ensure_saved(Db, Doc, Opts). --spec del_doc(server(), ne_binary(), kz_json:object(), kz_proplist()) -> +-spec del_doc(server(), kz_term:ne_binary(), kz_json:object(), kz_term:proplist()) -> {'ok', kz_json:object()} | couchbeam_error(). del_doc(#server{}=Conn, DbName, Doc, Options) -> Db = get_db(Conn, DbName), ?RETRY_504(couchbeam:delete_doc(Db, Doc, Options)). --spec del_docs(server(), ne_binary(), kz_json:objects(), kz_proplist()) -> +-spec del_docs(server(), kz_term:ne_binary(), kz_json:objects(), kz_term:proplist()) -> {'ok', kz_json:objects()} | couchbeam_error(). del_docs(#server{}=Conn, DbName, Doc, Options) -> @@ -98,7 +98,7 @@ del_docs(#server{}=Conn, DbName, Doc, Options) -> %% Internal Doc functions --spec do_ensure_saved(couchbeam_db(), kz_json:object(), kz_proplist()) -> +-spec do_ensure_saved(couchbeam_db(), kz_json:object(), kz_term:proplist()) -> {'ok', kz_json:object()} | couchbeam_error(). do_ensure_saved(#db{}=Db, Doc, Opts) -> @@ -114,8 +114,8 @@ do_ensure_saved(#db{}=Db, Doc, Opts) -> {'error', _}=E -> E end. --spec do_fetch_rev(couchbeam_db(), ne_binary()) -> - ne_binary() | +-spec do_fetch_rev(couchbeam_db(), kz_term:ne_binary()) -> + kz_term:ne_binary() | couchbeam_error(). do_fetch_rev(#db{}=Db, DocId) -> case kz_term:is_empty(DocId) of @@ -123,7 +123,7 @@ do_fetch_rev(#db{}=Db, DocId) -> 'false' -> ?RETRY_504(couchbeam:lookup_doc_rev(Db, DocId)) end. --spec do_fetch_doc(couchbeam_db(), ne_binary(), kz_proplist()) -> +-spec do_fetch_doc(couchbeam_db(), kz_term:ne_binary(), kz_term:proplist()) -> {'ok', kz_json:object()} | couchbeam_error(). do_fetch_doc(#db{}=Db, DocId, Options) -> @@ -132,7 +132,7 @@ do_fetch_doc(#db{}=Db, DocId, Options) -> 'false' -> ?RETRY_504(couchbeam:open_doc(Db, DocId, Options)) end. --spec do_save_doc(couchbeam_db(), kz_json:object() | kz_json:objects(), kz_proplist()) -> +-spec do_save_doc(couchbeam_db(), kz_json:object() | kz_json:objects(), kz_term:proplist()) -> {'ok', kz_json:object()} | couchbeam_error(). do_save_doc(#db{}=Db, Docs, Options) when is_list(Docs) -> @@ -140,13 +140,13 @@ do_save_doc(#db{}=Db, Docs, Options) when is_list(Docs) -> do_save_doc(#db{}=Db, Doc, Options) -> ?RETRY_504(couchbeam:save_doc(Db, Doc, Options)). --spec do_save_docs(couchbeam_db(), kz_json:objects(), kz_proplist()) -> +-spec do_save_docs(couchbeam_db(), kz_json:objects(), kz_term:proplist()) -> {'ok', kz_json:objects()} | couchbeam_error(). do_save_docs(#db{}=Db, Docs, Options) -> do_save_docs(Db, Docs, Options, []). --spec do_save_docs(couchbeam_db(), kz_json:objects(), kz_proplist(), kz_json:objects()) -> +-spec do_save_docs(couchbeam_db(), kz_json:objects(), kz_term:proplist(), kz_json:objects()) -> {'ok', kz_json:objects()} | couchbeam_error(). do_save_docs(#db{}=Db, Docs, Options, Acc) -> @@ -164,7 +164,7 @@ do_save_docs(#db{}=Db, Docs, Options, Acc) -> end end. --spec perform_save_docs(couchbeam_db(), kz_json:objects(), kz_proplist()) -> +-spec perform_save_docs(couchbeam_db(), kz_json:objects(), kz_term:proplist()) -> {'ok', kz_json:objects()} | couchbeam_error(). perform_save_docs(Db, Docs, Options) -> @@ -178,7 +178,7 @@ perform_save_docs(Db, Docs, Options) -> default_copy_function('true') -> fun ensure_saved/4; default_copy_function('false') -> fun save_doc/4. --spec copy_doc(server(), copy_doc(), kz_proplist()) -> +-spec copy_doc(server(), copy_doc(), kz_term:proplist()) -> {'ok', kz_json:object()} | couchbeam_error(). copy_doc(#server{}=Conn, #kz_copy_doc{source_dbname = SourceDb @@ -194,7 +194,7 @@ copy_doc(#server{}=Conn, CopySpec, Options) -> copy_doc(Conn, CopySpec, SaveFun, props:delete(?COPY_DOC_OVERRIDE_PROPERTY, Options)). --spec copy_doc(server(), copy_doc(), copy_function(), kz_proplist()) -> +-spec copy_doc(server(), copy_doc(), copy_function(), kz_term:proplist()) -> {'ok', kz_json:object()} | couchbeam_error(). copy_doc(#server{}=Conn, CopySpec, CopyFun, Options) -> @@ -244,12 +244,12 @@ copy_attachments(#server{}=Conn, CopySpec, {[JObj | JObjs], [Key | Keys]}) -> Error -> Error end. --spec maybe_set_account_db(api_binary(), ne_binary(), ne_binary()) -> kz_proplist(). +-spec maybe_set_account_db(kz_term:api_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:proplist(). maybe_set_account_db(DB, DB, DestDbName) -> [{<<"pvt_account_db">>, DestDbName}]; maybe_set_account_db(_, _, _) -> []. --spec move_doc(server(), copy_doc(), kz_proplist()) -> +-spec move_doc(server(), copy_doc(), kz_term:proplist()) -> {'ok', kz_json:object()} | couchbeam_error(). move_doc(Conn, CopySpec, Options) -> @@ -263,7 +263,7 @@ move_doc(Conn, CopySpec, Options) -> Error -> Error end. --spec maybe_remove_doc(server(), ne_binary(), ne_binary(), kz_proplist()) -> 'ok'. +-spec maybe_remove_doc(server(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. maybe_remove_doc(Conn, SourceDbName, SourceDocId, Options) -> case open_doc(Conn, SourceDbName, SourceDocId, Options) of {'ok', SourceDoc} -> diff --git a/core/kazoo_couch/src/kz_couch_util.erl b/core/kazoo_couch/src/kz_couch_util.erl index 09d4a87a50f..f77f10a85e0 100644 --- a/core/kazoo_couch/src/kz_couch_util.erl +++ b/core/kazoo_couch/src/kz_couch_util.erl @@ -33,9 +33,9 @@ %% @end %%------------------------------------------------------------------------------ -type retry504_ret() :: any(). -%% 'ok' | ne_binary() | +%% 'ok' | kz_term:ne_binary() | %% {'ok', kz_json:object() | kz_json:objects() | -%% binary() | ne_binaries() | boolean() | integer() +%% binary() | kz_term:ne_binaries() | boolean() | integer() %% } | %% couchbeam_error() | %% {'error', 'timeout'}. @@ -93,7 +93,7 @@ retry504s(Fun, Cnt) -> new_connection(#{}=Map) -> connect(maps:fold(fun connection_parse/3, #kz_couch_connection{}, Map)). --spec maybe_add_auth(string(), string(), kz_proplist()) -> kz_proplist(). +-spec maybe_add_auth(string(), string(), kz_term:proplist()) -> kz_term:proplist(). maybe_add_auth("", _Pass, Options) -> Options; maybe_add_auth(User, Pass, Options) -> [{'basic_auth', {User, Pass}} | Options]. @@ -105,7 +105,7 @@ check_options(Options) -> ], lists:foldl(fun(Fun, Opts) -> Fun(Opts) end, Options, Routines). --spec maybe_default_recv_timeout(kz_proplist()) -> kz_proplist(). +-spec maybe_default_recv_timeout(kz_term:proplist()) -> kz_term:proplist(). maybe_default_recv_timeout(Options) -> case props:get_value('recv_timeout', Options) of 'undefined' -> [{'recv_timeout', 20000} | Options]; @@ -182,10 +182,10 @@ add_couch_version(_, _, #server{options=Options}=Conn) -> {'error', any()}. server_info(#server{}=Conn) -> couchbeam:server_info(Conn). --spec server_url(server()) -> ne_binary(). +-spec server_url(server()) -> kz_term:ne_binary(). server_url(#server{url=Url}) -> Url. --spec db_url(server(), ne_binary()) -> ne_binary(). +-spec db_url(server(), kz_term:ne_binary()) -> kz_term:ne_binary(). db_url(#server{}=Conn, DbName) -> Server = server_url(Conn), list_to_binary([Server, "/", DbName]). @@ -196,8 +196,8 @@ db_url(#server{}=Conn, DbName) -> %% returns the #db{} record %% @end %%------------------------------------------------------------------------------ --spec get_db(kz_data:connection(), ne_binary()) -> db(). --spec get_db(kz_data:connection(), ne_binary(), couch_version()) -> db(). +-spec get_db(kz_data:connection(), kz_term:ne_binary()) -> db(). +-spec get_db(kz_data:connection(), kz_term:ne_binary(), couch_version()) -> db(). get_db(Conn, DbName) -> get_db(Conn, DbName, kazoo_couch:server_version(Conn)). @@ -210,7 +210,7 @@ get_db(Conn, DbName, Driver) -> {'ok', Db} = couchbeam:open_db(ConnToUse, DbName), Db. --spec is_admin_db(ne_binary(), couch_version()) -> boolean(). +-spec is_admin_db(kz_term:ne_binary(), couch_version()) -> boolean(). is_admin_db(<<"_dbs">>, 'couchdb_2') -> 'true'; is_admin_db(<<"_users">>, 'couchdb_2') -> 'true'; is_admin_db(<<"_nodes">>, 'couchdb_2') -> 'true'; @@ -294,7 +294,7 @@ format_error(E) -> lager:warning("unformatted error: ~p", [E]), E. --spec maybe_add_rev(couchbeam_db(), ne_binary(), kz_proplist()) -> kz_proplist(). +-spec maybe_add_rev(couchbeam_db(), kz_term:ne_binary(), kz_term:proplist()) -> kz_term:proplist(). maybe_add_rev(#db{name=_Name}=Db, DocId, Options) -> case props:get_value('rev', Options) =:= 'undefined' andalso do_fetch_rev(Db, DocId) @@ -316,8 +316,8 @@ maybe_add_rev(#db{name=_Name}=Db, DocId, Options) -> Options end. --spec do_fetch_rev(couchbeam_db(), ne_binary()) -> - ne_binary() | +-spec do_fetch_rev(couchbeam_db(), kz_term:ne_binary()) -> + kz_term:ne_binary() | couchbeam_error(). do_fetch_rev(#db{}=Db, DocId) -> case kz_term:is_empty(DocId) of diff --git a/core/kazoo_couch/src/kz_couch_view.erl b/core/kazoo_couch/src/kz_couch_view.erl index bccdb4d84e7..9bb1b91d3d2 100644 --- a/core/kazoo_couch/src/kz_couch_view.erl +++ b/core/kazoo_couch/src/kz_couch_view.erl @@ -20,10 +20,10 @@ -include("kz_couch.hrl"). --type ddoc() :: 'all_docs' | ne_binary() | {ne_binary(), ne_binary()}. +-type ddoc() :: 'all_docs' | kz_term:ne_binary() | {kz_term:ne_binary(), kz_term:ne_binary()}. %%% View-related functions ----------------------------------------------------- --spec design_compact(server(), ne_binary(), ne_binary()) -> boolean(). +-spec design_compact(server(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). design_compact(#server{}=Conn, DbName, Design) -> case couchbeam:compact(kz_couch_util:get_db(Conn, DbName), Design) of {'error', _E} -> @@ -32,17 +32,17 @@ design_compact(#server{}=Conn, DbName, Design) -> 'ok' -> 'true' end. --spec design_info(server(), ne_binary(), ne_binary()) -> +-spec design_info(server(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | couchbeam_error(). design_info(#server{}=Conn, DBName, Design) -> Db = kz_couch_util:get_db(Conn, DBName), do_get_design_info(Db, Design). --spec all_design_docs(kz_data:connection(), ne_binary()) -> +-spec all_design_docs(kz_data:connection(), kz_term:ne_binary()) -> {'ok', kz_json:objects()} | couchbeam_error(). --spec all_design_docs(kz_data:connection(), ne_binary(), view_options()) -> +-spec all_design_docs(kz_data:connection(), kz_term:ne_binary(), view_options()) -> {'ok', kz_json:objects()} | couchbeam_error(). all_design_docs(#server{}=Conn, DBName) -> @@ -64,14 +64,14 @@ all_docs(Db) -> all_docs(Db, []). all_docs(#db{}=Db, Options) -> do_fetch_results(Db, 'all_docs', Options). --spec all_docs(server(), ne_binary(), view_options()) -> +-spec all_docs(server(), kz_term:ne_binary(), view_options()) -> {'ok', kz_json:objects()} | couchbeam_error(). all_docs(#server{}=Conn, DbName, Options) -> Db = kz_couch_util:get_db(Conn, DbName), do_fetch_results(Db, 'all_docs', Options). --spec get_results(server(), ne_binary(), ne_binary(), view_options()) -> +-spec get_results(server(), kz_term:ne_binary(), kz_term:ne_binary(), view_options()) -> {'ok', kz_json:objects() | kz_json:path()} | couchbeam_error(). get_results(#server{}=Conn, DbName, DesignDoc, ViewOptions) -> @@ -82,7 +82,7 @@ get_results(#server{}=Conn, DbName, DesignDoc, ViewOptions) -> %% Need to see how to get couchbeam to return the "rows" property instead of the result %% list; that would be better, but for not, setting the view's "reduce" to the _count %% function will suffice (provided a reduce isn't already defined). --spec get_results_count(server(), ne_binary(), ne_binary(), view_options()) -> +-spec get_results_count(server(), kz_term:ne_binary(), kz_term:ne_binary(), view_options()) -> {'ok', integer()} | couchbeam_error(). get_results_count(#server{}=Conn, DbName, DesignDoc, ViewOptions) -> @@ -91,7 +91,7 @@ get_results_count(#server{}=Conn, DbName, DesignDoc, ViewOptions) -> %% Design Doc/View internal functions -spec do_fetch_results(couchbeam_db(), ddoc(), view_options()) -> - {'ok', kz_json:objects() | ne_binaries()} | + {'ok', kz_json:objects() | kz_term:ne_binaries()} | couchbeam_error(). do_fetch_results(Db, DesignDoc, Options) when is_binary(DesignDoc) -> @@ -120,7 +120,7 @@ map_view_option({K, V}) map_view_option(KV) -> KV. -spec do_fetch_results_count(couchbeam_db(), ddoc(), view_options()) -> - {'ok', api_integer()} | + {'ok', kz_term:api_integer()} | couchbeam_error(). do_fetch_results_count(Db, DesignDoc, Options) when is_binary(DesignDoc) -> @@ -134,7 +134,7 @@ do_fetch_results_count(Db, DesignDoc, Options) -> end ). --spec do_get_design_info(couchbeam_db(), ne_binary()) -> +-spec do_get_design_info(couchbeam_db(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | couchbeam_error(). do_get_design_info(#db{}=Db, Design) -> diff --git a/core/kazoo_csv/src/kz_csv.erl b/core/kazoo_csv/src/kz_csv.erl index a8d85fa0caa..79df773a0f8 100644 --- a/core/kazoo_csv/src/kz_csv.erl +++ b/core/kazoo_csv/src/kz_csv.erl @@ -26,9 +26,9 @@ -include_lib("kazoo_csv/include/kazoo_csv.hrl"). -type cell() :: binary() | ?ZILCH. --type header() :: [ne_binary(),...]. +-type header() :: [kz_term:ne_binary(),...]. -type row() :: [cell(),...]. --type mapped_row() :: #{ne_binary() => cell()}. +-type mapped_row() :: #{kz_term:ne_binary() => cell()}. -type csv() :: binary(). -export_type([cell/0 @@ -148,7 +148,7 @@ pad_row_to(_, Row) -> %% @doc %% @end %%-------------------------------------------------------------------- --type fassoc_ret() :: {'ok', mapped_row()} | {'error', ne_binary()}. +-type fassoc_ret() :: {'ok', mapped_row()} | {'error', kz_term:ne_binary()}. -type fassoc() :: fun((row()) -> fassoc_ret()). -type verifier() :: fun((atom(), cell()) -> boolean()). -spec associator(row(), row(), verifier()) -> fassoc(). @@ -188,7 +188,7 @@ verify(Verifier, Header, Row, I, Map) -> %% Returns an unordered list of the name of columns that did not pass validation. %% @end %%-------------------------------------------------------------------- --type mapped_row_verifier() :: fun((ne_binary(), cell()) -> boolean()). +-type mapped_row_verifier() :: fun((kz_term:ne_binary(), cell()) -> boolean()). -spec verify_mapped_row(mapped_row_verifier(), mapped_row()) -> [] | header(). verify_mapped_row(Pred, MappedRow) when is_function(Pred, 2), is_map(MappedRow) -> @@ -256,7 +256,7 @@ json_to_iolist(Records, Fields) from_jobjs(JObjs) -> from_jobjs(JObjs, []). --spec from_jobjs(kz_json:objects(), kz_proplist()) -> iolist(). +-spec from_jobjs(kz_json:objects(), kz_term:proplist()) -> iolist(). from_jobjs(JObjs, Options) -> Routines = [fun maybe_transform/2 ,fun check_integrity/2 @@ -275,7 +275,7 @@ take_line(CSV) -> Split -> Split end. --spec split_row(ne_binary()) -> row(). +-spec split_row(kz_term:ne_binary()) -> row(). split_row(Line) -> Splitted = binary:split(Line, <<$,>>, [global]), {Acc,io,<<>>} = lists:foldl(fun consume/2, {[],io,<<>>}, Splitted), @@ -314,8 +314,8 @@ consume(Bin, {Acc,Sep,AccBin}) -> end. %% @private --spec find_position(ne_binary(), ne_binaries()) -> pos_integer(). --spec find_position(ne_binary(), ne_binaries(), pos_integer()) -> pos_integer(). +-spec find_position(kz_term:ne_binary(), kz_term:ne_binaries()) -> pos_integer(). +-spec find_position(kz_term:ne_binary(), kz_term:ne_binaries(), pos_integer()) -> pos_integer(). find_position(Item, Items) -> find_position(Item, Items, 1). find_position(Item, [Item|_], Pos) -> Pos; @@ -343,19 +343,19 @@ cell_to_binary(Cell=?NE_BINARY) -> cell_to_binary(Cell) -> kz_term:to_binary(Cell). --spec maybe_transform(kz_json:objects(), kz_proplist()) -> kz_json:objects(). +-spec maybe_transform(kz_json:objects(), kz_term:proplist()) -> kz_json:objects(). maybe_transform(JObjs, Options) -> case props:get_value('transform_fun', Options) of 'undefined' -> JObjs; Fun -> [kz_json:map(Fun, JObj) || JObj <- JObjs] end. --spec check_integrity(list(), kz_proplist()) -> kz_json:objects(). +-spec check_integrity(list(), kz_term:proplist()) -> kz_json:objects(). check_integrity(JObjs, _Options) -> Headers = get_headers(JObjs), check_integrity(JObjs, Headers, []). --spec check_integrity(kz_json:objects(), ne_binaries(), kz_json:objects()) -> +-spec check_integrity(kz_json:objects(), kz_term:ne_binaries(), kz_json:objects()) -> kz_json:objects(). check_integrity([], _, Acc) -> lists:reverse(Acc); @@ -373,22 +373,22 @@ check_integrity_fold(Header, JObj) -> _ -> JObj end. --spec get_headers(kz_json:objects()) -> ne_binaries(). +-spec get_headers(kz_json:objects()) -> kz_term:ne_binaries(). get_headers(JObjs) -> lists:foldl(fun fold_over_objects/2, [], JObjs). --spec fold_over_objects(kz_json:object(), ne_binaries()) -> ne_binaries(). +-spec fold_over_objects(kz_json:object(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). fold_over_objects(JObj, Headers) -> lists:foldl(fun fold_over_keys/2, Headers, kz_json:get_keys(JObj)). --spec fold_over_keys(ne_binary(), ne_binaries()) -> ne_binaries(). +-spec fold_over_keys(kz_term:ne_binary(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). fold_over_keys(Key, Hs) -> case lists:member(Key, Hs) of 'false' -> [Key|Hs]; 'true' -> Hs end. --spec create_csv_header(kz_json:objects(), kz_proplist()) -> iolist(). +-spec create_csv_header(kz_json:objects(), kz_term:proplist()) -> iolist(). create_csv_header(JObjs, Options) -> Headers = case props:get_value('header_map', Options) of 'undefined' -> get_headers(JObjs); @@ -399,14 +399,14 @@ create_csv_header(JObjs, Options) -> end, csv_ize(lists:reverse(Headers)). --spec header_map(ne_binary(), kz_proplist()) -> ne_binary(). +-spec header_map(kz_term:ne_binary(), kz_term:proplist()) -> kz_term:ne_binary(). header_map(Header, HeaderMap) -> case props:get_value(Header, HeaderMap) of 'undefined' -> Header; FriendlyHeader -> FriendlyHeader end. --spec json_objs_to_csv(kz_json:objects(), kz_proplist()) -> iolist(). +-spec json_objs_to_csv(kz_json:objects(), kz_term:proplist()) -> iolist(). json_objs_to_csv([], _) -> []; json_objs_to_csv(JObjs, Options) -> [create_csv_header(JObjs, Options), [json_to_csv(JObj) || JObj <- JObjs]]. diff --git a/core/kazoo_data/src/kazoo_data_app.erl b/core/kazoo_data/src/kazoo_data_app.erl index 01136c05a14..78bbbeee36c 100644 --- a/core/kazoo_data/src/kazoo_data_app.erl +++ b/core/kazoo_data/src/kazoo_data_app.erl @@ -14,7 +14,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_StartType, _StartArgs) -> kazoo_data_sup:start_link(). diff --git a/core/kazoo_data/src/kazoo_data_bootstrap.erl b/core/kazoo_data/src/kazoo_data_bootstrap.erl index b4f1b629362..9cd8727f911 100644 --- a/core/kazoo_data/src/kazoo_data_bootstrap.erl +++ b/core/kazoo_data/src/kazoo_data_bootstrap.erl @@ -30,7 +30,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_server:start_link({'local', ?SERVER}, ?MODULE, [], []). @@ -75,7 +75,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -89,7 +89,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> {'noreply', State}. @@ -103,7 +103,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info('timeout', State) -> {'noreply', State}; handle_info(_Info, State) -> diff --git a/core/kazoo_data/src/kazoo_data_config.erl b/core/kazoo_data/src/kazoo_data_config.erl index 0f3108e7b18..c3fd4d2af57 100644 --- a/core/kazoo_data/src/kazoo_data_config.erl +++ b/core/kazoo_data/src/kazoo_data_config.erl @@ -11,8 +11,8 @@ -compile({no_auto_import,[get/1]}). --spec get_pos_integer(ne_binary()) -> api_pos_integer(). --spec get_pos_integer(ne_binary(), Default) -> pos_integer() | Default. +-spec get_pos_integer(kz_term:ne_binary()) -> kz_term:api_pos_integer(). +-spec get_pos_integer(kz_term:ne_binary(), Default) -> pos_integer() | Default. get_pos_integer(Key) -> get_pos_integer(Key, 'undefined'). get_pos_integer(Key, Default) -> @@ -21,8 +21,8 @@ get_pos_integer(Key, Default) -> {'ok', Value} -> as_integer(Value, Default, fun(V) -> V > 0 end) end. --spec get_ne_binary(ne_binary()) -> api_ne_binary(). --spec get_ne_binary(ne_binary(), Default) -> ne_binary() | Default. +-spec get_ne_binary(kz_term:ne_binary()) -> kz_term:api_ne_binary(). +-spec get_ne_binary(kz_term:ne_binary(), Default) -> kz_term:ne_binary() | Default. get_ne_binary(Key) -> get_ne_binary(Key, 'undefined'). get_ne_binary(Key, Default) -> @@ -32,8 +32,8 @@ get_ne_binary(Key, Default) -> nonempty(kz_term:to_binary(Value), Default) end. --spec get_ne_binaries(ne_binary()) -> api_ne_binaries(). --spec get_ne_binaries(ne_binary(), Default) -> ne_binaries() | Default. +-spec get_ne_binaries(kz_term:ne_binary()) -> kz_term:api_ne_binaries(). +-spec get_ne_binaries(kz_term:ne_binary(), Default) -> kz_term:ne_binaries() | Default. get_ne_binaries(Key) -> get_ne_binaries(Key, 'undefined'). get_ne_binaries(Key, Default) -> @@ -43,8 +43,8 @@ get_ne_binaries(Key, Default) -> nonempty(Value, Default) end. --spec get_json(ne_binary()) -> api_object(). --spec get_json(ne_binary(), Default) -> kz_json:object() | Default. +-spec get_json(kz_term:ne_binary()) -> kz_term:api_object(). +-spec get_json(kz_term:ne_binary(), Default) -> kz_json:object() | Default. get_json(Key) -> get_json(Key, 'undefined'). get_json(Key, Default) -> @@ -54,8 +54,8 @@ get_json(Key, Default) -> as_json(Value, Default) end. --spec get_is_true(ne_binary()) -> boolean(). --spec get_is_true(ne_binary(), Default) -> boolean() | Default. +-spec get_is_true(kz_term:ne_binary()) -> boolean(). +-spec get_is_true(kz_term:ne_binary(), Default) -> boolean() | Default. get_is_true(Key) -> get_is_true(Key, 'false'). get_is_true(Key, Default) -> @@ -65,8 +65,8 @@ get_is_true(Key, Default) -> as_boolean(Value, Default) end. --spec get(ne_binary()) -> 'undefined' | - {'ok', any()}. +-spec get(kz_term:ne_binary()) -> 'undefined' | + {'ok', any()}. get(<<_/binary>>=Key) -> application:get_env(?APP, kz_term:to_atom(Key, 'true')). diff --git a/core/kazoo_data/src/kazoo_data_init.erl b/core/kazoo_data/src/kazoo_data_init.erl index 3cb733ddfee..55a03862cb7 100644 --- a/core/kazoo_data/src/kazoo_data_init.erl +++ b/core/kazoo_data/src/kazoo_data_init.erl @@ -16,7 +16,7 @@ %% @public %% @doc Starts the app for inclusion in a supervisor tree %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> _ = declare_exchanges(), 'ignore'. diff --git a/core/kazoo_data/src/kazoo_data_link_sup.erl b/core/kazoo_data/src/kazoo_data_link_sup.erl index 34ae4fee0bf..5233f5a3c68 100644 --- a/core/kazoo_data/src/kazoo_data_link_sup.erl +++ b/core/kazoo_data/src/kazoo_data_link_sup.erl @@ -50,7 +50,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -67,7 +67,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, diff --git a/core/kazoo_data/src/kazoo_data_maintenance.erl b/core/kazoo_data/src/kazoo_data_maintenance.erl index 327657dfee2..9c401473f82 100644 --- a/core/kazoo_data/src/kazoo_data_maintenance.erl +++ b/core/kazoo_data/src/kazoo_data_maintenance.erl @@ -37,8 +37,8 @@ flush_data_plans() -> io:format("flushed all data plans~n"). -spec flush_docs() -> 'ok'. --spec flush_docs(ne_binary()) -> 'ok'. --spec flush_docs(ne_binary(), ne_binary()) -> 'ok'. +-spec flush_docs(kz_term:ne_binary()) -> 'ok'. +-spec flush_docs(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. flush_docs() -> _ = kz_datamgr:flush_cache_docs(), io:format("flushed all cached docs~n"). @@ -51,12 +51,12 @@ flush_docs(Account, DocId) -> _ = kz_datamgr:flush_cache_doc(kz_util:format_account_db(Account), DocId), io:format("flushed cached doc ~s for account ~s~n", [DocId, Account]). --spec trace_module(ne_binary()) -> 'ok'. +-spec trace_module(kz_term:ne_binary()) -> 'ok'. trace_module(Module) -> start_trace([{'module', kz_term:to_atom(Module)}]). --spec trace_function(ne_binary()) -> 'ok'. --spec trace_function(ne_binary(), ne_binary()) -> 'ok'. +-spec trace_function(kz_term:ne_binary()) -> 'ok'. +-spec trace_function(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. trace_function(Function) -> start_trace([{'function', kz_term:to_atom(Function)}]). @@ -65,7 +65,7 @@ trace_function(Module, Function) -> ,{'function', kz_term:to_atom(Function)} ]). --spec trace_pid(ne_binary()) -> 'ok'. +-spec trace_pid(kz_term:ne_binary()) -> 'ok'. trace_pid(Pid) -> start_trace([{'pid', kz_term:to_list(Pid)}]). @@ -74,17 +74,17 @@ start_trace(Filters) -> {'ok', Ref} = kz_data_tracing:trace_file(Filters), io:format("trace started, stop with 'sup kazoo_data_maintenance stop_trace ~s'~n", [Ref]). --spec stop_trace(ne_binary()) -> 'ok'. +-spec stop_trace(kz_term:ne_binary()) -> 'ok'. stop_trace(Ref) -> {'ok', Filename} = kz_data_tracing:stop_trace(Ref), io:format("trace stopped, see log at ~s~n", [Filename]). --spec open_document(ne_binary(), ne_binary()) -> no_return. +-spec open_document(kz_term:ne_binary(), kz_term:ne_binary()) -> no_return. open_document(Db, Id) -> print(kz_datamgr:open_doc(Db, Id)). --spec open_document_cached(ne_binary(), ne_binary()) -> no_return. +-spec open_document_cached(kz_term:ne_binary(), kz_term:ne_binary()) -> no_return. open_document_cached(Db, Id) -> print(kz_datamgr:open_cache_doc(Db, Id)). diff --git a/core/kazoo_data/src/kazoo_data_sup.erl b/core/kazoo_data/src/kazoo_data_sup.erl index efb5d21d5a7..505548fde41 100644 --- a/core/kazoo_data/src/kazoo_data_sup.erl +++ b/core/kazoo_data/src/kazoo_data_sup.erl @@ -30,7 +30,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -47,7 +47,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, diff --git a/core/kazoo_data/src/kazoo_dataconnection_error.erl b/core/kazoo_data/src/kazoo_dataconnection_error.erl index 9ce4d74a9af..ac90ce66c20 100644 --- a/core/kazoo_data/src/kazoo_dataconnection_error.erl +++ b/core/kazoo_data/src/kazoo_dataconnection_error.erl @@ -72,7 +72,7 @@ format_error(Error) -> Error. %% Connection operations --spec get_db(kz_data:connection(), ne_binary()) -> error(). +-spec get_db(kz_data:connection(), kz_term:ne_binary()) -> error(). get_db(_, _) -> {'error', 'resource_not_available'}. @@ -80,7 +80,7 @@ get_db(_, _) -> server_url(_Server) -> {'error', 'resource_not_available'}. --spec db_url(kz_data:connection(), ne_binary()) -> error(). +-spec db_url(kz_data:connection(), kz_term:ne_binary()) -> error(). db_url(_Server, _DbName) -> {'error', 'resource_not_available'}. @@ -89,15 +89,15 @@ server_info(_Server) -> {'error', 'resource_not_available'}. %% DB operations --spec db_create(kz_data:connection(), ne_binary(), kz_data:options()) -> error(). +-spec db_create(kz_data:connection(), kz_term:ne_binary(), kz_data:options()) -> error(). db_create(_Server, _DbName, _Options) -> {'error', 'resource_not_available'}. --spec db_delete(kz_data:connection(), ne_binary()) -> error(). +-spec db_delete(kz_data:connection(), kz_term:ne_binary()) -> error(). db_delete(_Server, _DbName) -> {'error', 'resource_not_available'}. --spec db_view_cleanup(kz_data:connection(), ne_binary()) -> error(). +-spec db_view_cleanup(kz_data:connection(), kz_term:ne_binary()) -> error(). db_view_cleanup(_Server, _DbName) -> {'error', 'resource_not_available'}. @@ -105,15 +105,15 @@ db_view_cleanup(_Server, _DbName) -> db_info(_Server) -> {'error', 'resource_not_available'}. --spec db_info(kz_data:connection(), ne_binary()) -> error(). +-spec db_info(kz_data:connection(), kz_term:ne_binary()) -> error(). db_info(_Server, _DbName) -> {'error', 'resource_not_available'}. --spec db_exists(kz_data:connection(), ne_binary()) -> error(). +-spec db_exists(kz_data:connection(), kz_term:ne_binary()) -> error(). db_exists(_Server, _DbName) -> {'error', 'resource_not_available'}. --spec db_archive(kz_data:connection(), ne_binary(), ne_binary()) -> error(). +-spec db_archive(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary()) -> error(). db_archive(_Server, _DbName, _Filename) -> {'error', 'resource_not_available'}. @@ -122,72 +122,72 @@ db_list(_Server, _Options) -> {'error', 'resource_not_available'}. %% Document operations --spec open_doc(kz_data:connection(), ne_binary(), ne_binary(), kz_data:options()) -> error(). +-spec open_doc(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> error(). open_doc(_Server, _DbName, _DocId, _Options) -> {'error', 'resource_not_available'}. --spec lookup_doc_rev(kz_data:connection(), ne_binary(), ne_binary()) -> error(). +-spec lookup_doc_rev(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary()) -> error(). lookup_doc_rev(_Server, _DbName, _DocId) -> {'error', 'resource_not_available'}. --spec save_doc(kz_data:connection(), ne_binary(), kz_data:document(), kz_data:options()) -> error(). +-spec save_doc(kz_data:connection(), kz_term:ne_binary(), kz_data:document(), kz_data:options()) -> error(). save_doc(_Server, _DbName, _Doc, _Options) -> {'error', 'resource_not_available'}. --spec save_docs(kz_data:connection(), ne_binary(), kz_data:documents(), kz_data:options()) -> error(). +-spec save_docs(kz_data:connection(), kz_term:ne_binary(), kz_data:documents(), kz_data:options()) -> error(). save_docs(_Server, _DbName, _Docs, _Options) -> {'error', 'resource_not_available'}. --spec del_doc(kz_data:connection(), ne_binary(), kz_data:document(), kz_data:options()) -> error(). +-spec del_doc(kz_data:connection(), kz_term:ne_binary(), kz_data:document(), kz_data:options()) -> error(). del_doc(_Server, _DbName, _Doc, _Options) -> {'error', 'resource_not_available'}. --spec del_docs(kz_data:connection(), ne_binary(), kz_data:documents(), kz_data:options()) -> error(). +-spec del_docs(kz_data:connection(), kz_term:ne_binary(), kz_data:documents(), kz_data:options()) -> error(). del_docs(_Server, _DbName, _Docs, _Options) -> {'error', 'resource_not_available'}. --spec ensure_saved(kz_data:connection(), ne_binary(), kz_data:document(), kz_data:options()) -> error(). +-spec ensure_saved(kz_data:connection(), kz_term:ne_binary(), kz_data:document(), kz_data:options()) -> error(). ensure_saved(_Server, _DbName, _Doc, _Options) -> {'error', 'resource_not_available'}. %% Attachment-related --spec fetch_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary()) -> error(). +-spec fetch_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> error(). fetch_attachment(_Server, _DbName, _DocId, _AName) -> {'error', 'resource_not_available'}. --spec stream_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary(), pid()) -> error(). +-spec stream_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), pid()) -> error(). stream_attachment(_Server, _DbName, _DocId, _AName, _Caller) -> {'error', 'resource_not_available'}. --spec put_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_data:options()) -> error(). +-spec put_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> error(). put_attachment(_Server, _DbName, _DocId, _AName, _Contents, _Options) -> {'error', 'resource_not_available'}. --spec delete_attachment(kz_data:connection(), ne_binary(), ne_binary(), ne_binary(), kz_data:options()) -> error(). +-spec delete_attachment(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> error(). delete_attachment(_Server, _DbName, _DocId, _AName, _Options) -> {'error', 'resource_not_available'}. --spec attachment_url(kz_data:connection(), ne_binary(), ne_binary(), ne_binary(), kz_data:options()) -> error(). +-spec attachment_url(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> error(). attachment_url(_Server, _DbName, _DocId, _AName, _Options) -> {'error', 'resource_not_available'}. %% View-related --spec design_info(kz_data:connection(), ne_binary(), ne_binary()) -> error(). +-spec design_info(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary()) -> error(). design_info(_Server, _DBName, _Design) -> {'error', 'resource_not_available'}. --spec all_design_docs(kz_data:connection(), ne_binary(), kz_data:options()) -> error(). +-spec all_design_docs(kz_data:connection(), kz_term:ne_binary(), kz_data:options()) -> error(). all_design_docs(_Server, _DBName, _Options) -> {'error', 'resource_not_available'}. --spec get_results(kz_data:connection(), ne_binary(), ne_binary(), kz_data:options()) -> error(). +-spec get_results(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> error(). get_results(_Server, _DbName, _DesignDoc, _ViewOptions) -> {'error', 'resource_not_available'}. --spec get_results_count(kz_data:connection(), ne_binary(), ne_binary(), kz_data:options()) -> error(). +-spec get_results_count(kz_data:connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> error(). get_results_count(_Server, _DbName, _DesignDoc, _ViewOptions) -> {'error', 'resource_not_available'}. --spec all_docs(kz_data:connection(), ne_binary(), kz_data:options()) -> error(). +-spec all_docs(kz_data:connection(), kz_term:ne_binary(), kz_data:options()) -> error(). all_docs(_Server, _DbName, _Options) -> {'error', 'resource_not_available'}. diff --git a/core/kazoo_data/src/kz_data.erl b/core/kazoo_data/src/kz_data.erl index 2d9be32199d..9d65ca1783f 100644 --- a/core/kazoo_data/src/kz_data.erl +++ b/core/kazoo_data/src/kz_data.erl @@ -25,46 +25,46 @@ -callback format_error(any()) -> any(). %% Connection operations --callback get_db(connection(), ne_binary()) -> any(). +-callback get_db(connection(), kz_term:ne_binary()) -> any(). -callback server_url(connection()) -> - ne_binary() | + kz_term:ne_binary() | {'error', 'resource_not_available'}. --callback db_url(connection(), ne_binary()) -> - ne_binary() | +-callback db_url(connection(), kz_term:ne_binary()) -> + kz_term:ne_binary() | {'error', 'resource_not_available'}. -callback server_info(connection()) -> any(). %% DB operations --callback db_create(connection(), ne_binary(), options()) -> any(). --callback db_delete(connection(), ne_binary()) -> any(). --callback db_view_cleanup(connection(), ne_binary()) -> any(). +-callback db_create(connection(), kz_term:ne_binary(), options()) -> any(). +-callback db_delete(connection(), kz_term:ne_binary()) -> any(). +-callback db_view_cleanup(connection(), kz_term:ne_binary()) -> any(). -callback db_info(connection()) -> any(). --callback db_info(connection(), ne_binary()) -> any(). --callback db_exists(connection(), ne_binary()) -> +-callback db_info(connection(), kz_term:ne_binary()) -> any(). +-callback db_exists(connection(), kz_term:ne_binary()) -> boolean() | {'error', 'resource_not_available'}. --callback db_archive(connection(), ne_binary(), ne_binary()) -> any(). +-callback db_archive(connection(), kz_term:ne_binary(), kz_term:ne_binary()) -> any(). -callback db_list(connection(), options()) -> any(). %% Document operations --callback open_doc(connection(), ne_binary(), ne_binary(), options()) -> any(). --callback lookup_doc_rev(connection(), ne_binary(), ne_binary()) -> any(). --callback save_doc(connection(), ne_binary(), document(), options()) -> any(). --callback save_docs(connection(), ne_binary(), documents(), options()) -> any(). --callback del_doc(connection(), ne_binary(), document(), options()) -> any(). --callback del_docs(connection(), ne_binary(), documents(), options()) -> any(). --callback ensure_saved(connection(), ne_binary(), document(), options()) -> any(). +-callback open_doc(connection(), kz_term:ne_binary(), kz_term:ne_binary(), options()) -> any(). +-callback lookup_doc_rev(connection(), kz_term:ne_binary(), kz_term:ne_binary()) -> any(). +-callback save_doc(connection(), kz_term:ne_binary(), document(), options()) -> any(). +-callback save_docs(connection(), kz_term:ne_binary(), documents(), options()) -> any(). +-callback del_doc(connection(), kz_term:ne_binary(), document(), options()) -> any(). +-callback del_docs(connection(), kz_term:ne_binary(), documents(), options()) -> any(). +-callback ensure_saved(connection(), kz_term:ne_binary(), document(), options()) -> any(). %% Attachment-related --callback fetch_attachment(connection(), ne_binary(), ne_binary(), ne_binary()) -> any(). --callback stream_attachment(connection(), ne_binary(), ne_binary(), ne_binary(), pid()) -> any(). --callback put_attachment(connection(), ne_binary(), ne_binary(), ne_binary(), ne_binary(), options()) -> any(). --callback delete_attachment(connection(), ne_binary(), ne_binary(), ne_binary(), options()) -> any(). --callback attachment_url(connection(), ne_binary(), ne_binary(), ne_binary(), options()) -> any(). +-callback fetch_attachment(connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> any(). +-callback stream_attachment(connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), pid()) -> any(). +-callback put_attachment(connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), options()) -> any(). +-callback delete_attachment(connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), options()) -> any(). +-callback attachment_url(connection(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), options()) -> any(). %% View-related --callback design_info(connection(), ne_binary(), ne_binary()) -> any(). --callback all_design_docs(connection(), ne_binary(), options()) -> any(). --callback get_results(connection(), ne_binary(), ne_binary(), options()) -> any(). --callback get_results_count(connection(), ne_binary(), ne_binary(), options()) -> any(). --callback all_docs(connection(), ne_binary(), options()) -> any(). +-callback design_info(connection(), kz_term:ne_binary(), kz_term:ne_binary()) -> any(). +-callback all_design_docs(connection(), kz_term:ne_binary(), options()) -> any(). +-callback get_results(connection(), kz_term:ne_binary(), kz_term:ne_binary(), options()) -> any(). +-callback get_results_count(connection(), kz_term:ne_binary(), kz_term:ne_binary(), options()) -> any(). +-callback all_docs(connection(), kz_term:ne_binary(), options()) -> any(). diff --git a/core/kazoo_data/src/kz_data.hrl b/core/kazoo_data/src/kz_data.hrl index d34f4cdfbd8..74074c57166 100644 --- a/core/kazoo_data/src/kz_data.hrl +++ b/core/kazoo_data/src/kz_data.hrl @@ -25,7 +25,7 @@ -record(db, {app :: atom() ,server :: any() ,db :: any() - ,name :: ne_binary() + ,name :: kz_term:ne_binary() }). -type data_connection() :: #data_connection{}. @@ -33,10 +33,10 @@ -type server() :: {atom(), any()} | 'undefined'. -type db() :: #db{}. --record(copy_doc, {source_dbname :: ne_binary() - ,source_doc_id :: ne_binary() - ,dest_dbname :: api_binary() - ,dest_doc_id :: api_binary() +-record(copy_doc, {source_dbname :: kz_term:ne_binary() + ,source_doc_id :: kz_term:ne_binary() + ,dest_dbname :: kz_term:api_binary() + ,dest_doc_id :: kz_term:api_binary() }). -type copy_doc() :: #copy_doc{}. @@ -96,7 +96,7 @@ -type view_options() :: [view_option()]. --type view_listing() :: {ne_binary(), kz_json:object()}. +-type view_listing() :: {kz_term:ne_binary(), kz_json:object()}. -type views_listing() :: [view_listing()]. -type db_classification() :: 'account' | @@ -115,9 +115,9 @@ -type db_create_options() :: [{'q',integer()} | {'n',integer()} | 'ensure_other_dbs']. -type db_delete_options() :: ['ensure_other_dbs']. --type ddoc() :: ne_binary() | 'all_docs' | 'design_docs'. +-type ddoc() :: kz_term:ne_binary() | 'all_docs' | 'design_docs'. --type docid() :: ne_binary() | {ne_binary(), ne_binary()}. +-type docid() :: kz_term:ne_binary() | {kz_term:ne_binary(), kz_term:ne_binary()}. -type docids() :: [docid()]. -type get_results_return() :: {'ok', kz_json:objects() | kz_json:path()} | diff --git a/core/kazoo_data/src/kz_data_tracing.erl b/core/kazoo_data/src/kz_data_tracing.erl index 9de3e509d90..309f98c9612 100644 --- a/core/kazoo_data/src/kz_data_tracing.erl +++ b/core/kazoo_data/src/kz_data_tracing.erl @@ -48,7 +48,7 @@ ]). -type trace_result() :: {{'lager_file_backend', file:filename_all()}, filters(), lager:log_level()}. --type trace_results() :: [{ne_binary(), file:filename_all(), trace_result()}]. +-type trace_results() :: [{kz_term:ne_binary(), file:filename_all(), trace_result()}]. -type trace_options() :: #{'filters' => filters() ,'filename' => file:filename_all() @@ -116,7 +116,7 @@ clear_all_traces() -> stop_trace(TraceRef) -> gen_server:call(?MODULE, {'stop_trace', TraceRef}). --spec start_link() -> sup_startchild_ret(). +-spec start_link() -> kz_types:sup_startchild_ret(). start_link() -> gen_server:start_link({'local', ?MODULE}, ?MODULE, [], []). @@ -124,7 +124,7 @@ start_link() -> init([]) -> {'ok', #state{}}. --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call({'trace_file', TraceOptions}, _From, #state{traces=Traces}=State) -> case start_trace(TraceOptions) of {'ok', TraceResult} -> @@ -162,11 +162,11 @@ handle_call({'stop_trace', TraceRef} end end. --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Req, State) -> {'noreply', State}. --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Msg, State) -> {'noreply', State}. diff --git a/core/kazoo_data/src/kz_dataconfig.erl b/core/kazoo_data/src/kz_dataconfig.erl index e30ba13d175..af335133e6b 100644 --- a/core/kazoo_data/src/kz_dataconfig.erl +++ b/core/kazoo_data/src/kz_dataconfig.erl @@ -28,7 +28,7 @@ connection() -> Props = props:get_value('generic', kz_config:get(Section), []), connection(connection_options(Props)). --spec connection_options(kz_proplist()) -> kz_proplist(). +-spec connection_options(kz_term:proplist()) -> kz_term:proplist(). connection_options(Props) -> case props:get_value('connect_options', Props) of 'undefined' -> Props; @@ -37,7 +37,7 @@ connection_options(Props) -> [{'connect_options', Options} | props:delete('connect_options', Props)] end. --spec connection(kz_proplist() | map()) -> data_connection(). +-spec connection(kz_term:proplist() | map()) -> data_connection(). connection(List) when is_list(List) -> connection(maps:from_list(List)); connection(#{driver := App}=Map) diff --git a/core/kazoo_data/src/kz_dataconnection.erl b/core/kazoo_data/src/kz_dataconnection.erl index 80559233f1c..2451d4004ff 100644 --- a/core/kazoo_data/src/kz_dataconnection.erl +++ b/core/kazoo_data/src/kz_dataconnection.erl @@ -30,7 +30,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(data_connection()) -> startlink_ret(). +-spec start_link(data_connection()) -> kz_types:startlink_ret(). start_link(#data_connection{}=Connection) -> gen_server:start_link(?SERVER, [Connection], []). @@ -69,7 +69,7 @@ init([Connection]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, Connection) -> {'reply', {'error', 'not_implemented'}, Connection}. @@ -83,7 +83,7 @@ handle_call(_Request, _From, Connection) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, Connection) -> {'noreply', Connection}. @@ -97,7 +97,7 @@ handle_cast(_Msg, Connection) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info('maintain_connection', #data_connection{connected = 'false'}=Connection) -> case try_connection(Connection) of {'error', _} -> diff --git a/core/kazoo_data/src/kz_dataconnection_sup.erl b/core/kazoo_data/src/kz_dataconnection_sup.erl index 326db5e6847..bf1e477839b 100644 --- a/core/kazoo_data/src/kz_dataconnection_sup.erl +++ b/core/kazoo_data/src/kz_dataconnection_sup.erl @@ -27,11 +27,11 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec add(data_connection()) -> sup_startchild_ret(). +-spec add(data_connection()) -> kz_types:sup_startchild_ret(). add(Connection) -> supervisor:start_child(?SERVER, [Connection]). @@ -48,7 +48,7 @@ add(Connection) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 0, diff --git a/core/kazoo_data/src/kz_dataconnections.erl b/core/kazoo_data/src/kz_dataconnections.erl index 0beb9e7beab..de5b71455c7 100644 --- a/core/kazoo_data/src/kz_dataconnections.erl +++ b/core/kazoo_data/src/kz_dataconnections.erl @@ -40,7 +40,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_server:start_link({'local', ?SERVER}, ?MODULE, [], []). @@ -56,7 +56,7 @@ add(#data_connection{}=Connection) -> -spec wait_for_connection() -> 'ok' | 'no_connection'. -spec wait_for_connection(any()) -> 'ok' | 'no_connection'. --spec wait_for_connection(any(), kz_timeout()) -> 'ok' | 'no_connection'. +-spec wait_for_connection(any(), timeout()) -> 'ok' | 'no_connection'. wait_for_connection() -> wait_for_connection('local'). @@ -152,7 +152,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -166,7 +166,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'add_connection', #data_connection{}=Connection}, State) -> lager:info("adding connection"), maybe_start_new_connection(Connection), @@ -188,7 +188,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> lager:debug("unhandled msg: ~p", [_Info]), {'noreply', State}. diff --git a/core/kazoo_data/src/kz_datamgr.erl b/core/kazoo_data/src/kz_datamgr.erl index ef677d537cf..31c85e9b921 100644 --- a/core/kazoo_data/src/kz_datamgr.erl +++ b/core/kazoo_data/src/kz_datamgr.erl @@ -118,7 +118,7 @@ %% a file %% @end %%-------------------------------------------------------------------- --spec update_doc_from_file(ne_binary(), atom(), nonempty_string() | ne_binary()) -> +-spec update_doc_from_file(kz_term:ne_binary(), atom(), nonempty_string() | kz_term:ne_binary()) -> {'ok', kz_json:object()} | data_error(). update_doc_from_file(DbName, App, File) when ?VALID_DBNAME(DbName) -> @@ -149,7 +149,7 @@ update_doc_from_file(DbName, App, File) -> %% contents of a file %% @end %%-------------------------------------------------------------------- --spec revise_doc_from_file(ne_binary(), atom(), ne_binary() | nonempty_string()) -> +-spec revise_doc_from_file(kz_term:ne_binary(), atom(), kz_term:ne_binary() | nonempty_string()) -> {'ok', kz_json:object()} | data_error(). revise_doc_from_file(DbName, App, File) -> @@ -169,7 +169,7 @@ revise_doc_from_file(DbName, App, File) -> %% into a given database %% @end %%-------------------------------------------------------------------- --spec revise_views_from_folder(ne_binary(), atom()) -> 'ok'. +-spec revise_views_from_folder(kz_term:ne_binary(), atom()) -> 'ok'. revise_views_from_folder(DbName, App) -> revise_docs_from_folder(DbName, App, "views"). @@ -180,8 +180,8 @@ revise_views_from_folder(DbName, App) -> %% priv/couchdb/ into a given database %% @end %%-------------------------------------------------------------------- --spec revise_docs_from_folder(ne_binary(), atom(), ne_binary() | nonempty_string()) -> 'ok'. --spec revise_docs_from_folder(ne_binary(), atom(), ne_binary() | nonempty_string(), boolean()) -> 'ok'. +-spec revise_docs_from_folder(kz_term:ne_binary(), atom(), kz_term:ne_binary() | nonempty_string()) -> 'ok'. +-spec revise_docs_from_folder(kz_term:ne_binary(), atom(), kz_term:ne_binary() | nonempty_string(), boolean()) -> 'ok'. revise_docs_from_folder(DbName, App, Folder) -> revise_docs_from_folder(DbName, App, Folder, 'false'). @@ -196,7 +196,7 @@ revise_docs_from_folder(DbName, App, Folder, Sleep) -> do_revise_docs_from_folder(DbName, Sleep, Files) end. --spec do_revise_docs_from_folder(ne_binary(), boolean(), ne_binaries()) -> 'ok'. +-spec do_revise_docs_from_folder(kz_term:ne_binary(), boolean(), kz_term:ne_binaries()) -> 'ok'. do_revise_docs_from_folder(_, _, []) -> 'ok'; do_revise_docs_from_folder(DbName, Sleep, [H|T]) -> try @@ -244,7 +244,7 @@ maybe_adapt_multilines(JObj) -> end. %% @private --spec inline_js_fun(ne_binary(), ne_binaries() | kz_json:json_term(), kz_json:object()) -> +-spec inline_js_fun(kz_term:ne_binary(), kz_term:ne_binaries() | kz_json:json_term(), kz_json:object()) -> kz_json:object(). inline_js_fun(Type, Code=[<<"function",_/binary>>|_], Acc) -> kz_json:set_value(Type, iolist_to_binary(Code), Acc); @@ -258,12 +258,12 @@ inline_js_fun(Type, Code, Acc) -> %% isn't already existant %% @end %%-------------------------------------------------------------------- --spec load_fixtures_from_folder(ne_binary(), atom()) -> 'ok'. +-spec load_fixtures_from_folder(kz_term:ne_binary(), atom()) -> 'ok'. load_fixtures_from_folder(DbName, App) -> Files = filelib:wildcard([code:priv_dir(App), "/couchdb/", ?FIXTURES_FOLDER, "/*.json"]), do_load_fixtures_from_folder(DbName, Files). --spec do_load_fixtures_from_folder(ne_binary(), ne_binaries()) -> 'ok'. +-spec do_load_fixtures_from_folder(kz_term:ne_binary(), kz_term:ne_binaries()) -> 'ok'. do_load_fixtures_from_folder(_, []) -> 'ok'; do_load_fixtures_from_folder(DbName, [F|Fs]) -> try @@ -291,7 +291,7 @@ do_load_fixtures_from_folder(DbName, [F|Fs]) -> %% Detemine if a database exists %% @end %%-------------------------------------------------------------------- --spec db_exists(text()) -> boolean(). +-spec db_exists(kz_term:text()) -> boolean(). db_exists(DbName) when ?VALID_DBNAME(DbName) -> kzs_db:db_exists(kzs_plan:plan(DbName), DbName); db_exists(DbName) -> @@ -300,7 +300,7 @@ db_exists(DbName) -> {'error', _}=E -> E end. --spec db_exists(text(), api_binary() | kz_proplist()) -> boolean(). +-spec db_exists(kz_term:text(), kz_term:api_binary() | kz_term:proplist()) -> boolean(). db_exists(DbName, 'undefined') -> db_exists(DbName); db_exists(DbName, Type) @@ -323,7 +323,7 @@ db_exists(DbName, Options) -> %% Detemine if a database exists, also checks other connections %% @end %%-------------------------------------------------------------------- --spec db_exists_all(text()) -> boolean(). +-spec db_exists_all(kz_term:text()) -> boolean(). db_exists_all(DbName) when ?VALID_DBNAME(DbName) -> kzs_db:db_exists_all(kzs_plan:plan(DbName), DbName); db_exists_all(DbName) -> @@ -338,7 +338,7 @@ db_exists_all(DbName) -> %% Retrieve information regarding all databases %% @end %%-------------------------------------------------------------------- --spec db_info() -> {'ok', ne_binaries()} | +-spec db_info() -> {'ok', kz_term:ne_binaries()} | data_error(). db_info() -> kzs_db:db_info(kzs_plan:plan()). @@ -349,8 +349,8 @@ db_info() -> %% Retrieve information regarding a database %% @end %%-------------------------------------------------------------------- --spec db_info(text()) -> {'ok', kz_json:object()} | - data_error(). +-spec db_info(kz_term:text()) -> {'ok', kz_json:object()} | + data_error(). db_info(DbName) when ?VALID_DBNAME(DbName) -> kzs_db:db_info(kzs_plan:plan(DbName), DbName); db_info(DbName) -> @@ -365,7 +365,7 @@ db_info(DbName) -> %% Retrieve information regarding a database design doc %% @end %%-------------------------------------------------------------------- --spec design_info(text(), ne_binary()) -> +-spec design_info(kz_term:text(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | data_error(). @@ -377,7 +377,7 @@ design_info(DbName, DesignName) -> {'error', _}=E -> E end. --spec design_compact(ne_binary(), ne_binary()) -> boolean(). +-spec design_compact(kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). design_compact(DbName, DesignName) when ?VALID_DBNAME(DbName)-> kzs_view:design_compact(kzs_plan:plan(DbName, DesignName), DbName, DesignName); @@ -387,7 +387,7 @@ design_compact(DbName, DesignName) -> {'error', _}=E -> E end. --spec db_view_cleanup(ne_binary()) -> boolean(). +-spec db_view_cleanup(kz_term:ne_binary()) -> boolean(). db_view_cleanup(DbName) when ?VALID_DBNAME(DbName) -> kzs_db:db_view_cleanup(kzs_plan:plan(DbName), DbName); @@ -399,10 +399,10 @@ db_view_cleanup(DbName) -> 'false' end. --spec db_view_update(ne_binary(), views_listing()) -> +-spec db_view_update(kz_term:ne_binary(), views_listing()) -> boolean() | {'error', 'invalid_db_name'}. --spec db_view_update(ne_binary(), views_listing(), boolean()) -> +-spec db_view_update(kz_term:ne_binary(), views_listing(), boolean()) -> boolean() | {'error', 'invalid_db_name'}. db_view_update(DbName, Views) -> @@ -452,7 +452,7 @@ db_view_update(DbName, Views, Remove) -> %% %% @end %%-------------------------------------------------------------------- --spec db_replicate(kz_proplist() | kz_json:object()) -> +-spec db_replicate(kz_term:proplist() | kz_json:object()) -> {'ok', kz_json:object()} | data_error(). db_replicate(Prop) when is_list(Prop) -> @@ -466,8 +466,8 @@ db_replicate(JObj) -> %% Detemine if a database exists %% @end %%-------------------------------------------------------------------- --spec db_create(text()) -> boolean(). --spec db_create(text(), kzs_db:db_create_options()) -> boolean(). +-spec db_create(kz_term:text()) -> boolean(). +-spec db_create(kz_term:text(), kzs_db:db_create_options()) -> boolean(). db_create(DbName) -> db_create(DbName, []). @@ -486,7 +486,7 @@ db_create(DbName, Options) -> %% Compact a database %% @end %%-------------------------------------------------------------------- --spec db_compact(text()) -> boolean(). +-spec db_compact(kz_term:text()) -> boolean(). db_compact(DbName) when ?VALID_DBNAME(DbName) -> kzs_db:db_compact(kzs_plan:plan(DbName), DbName); @@ -502,8 +502,8 @@ db_compact(DbName) -> %% Delete a database (takes an 'encoded' DbName) %% @end %%-------------------------------------------------------------------- --spec db_delete(text()) -> boolean(). --spec db_delete(text(), db_delete_options()) -> boolean(). +-spec db_delete(kz_term:text()) -> boolean(). +-spec db_delete(kz_term:text(), db_delete_options()) -> boolean(). db_delete(DbName) -> db_delete(DbName, []). @@ -521,8 +521,8 @@ db_delete(DbName, Options) -> %% Archive a database (takes an 'encoded' DbName) %% @end %%-------------------------------------------------------------------- --spec db_archive(ne_binary()) -> 'ok' | data_error(). --spec db_archive(ne_binary(), ne_binary()) -> 'ok' | data_error(). +-spec db_archive(kz_term:ne_binary()) -> 'ok' | data_error(). +-spec db_archive(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | data_error(). db_archive(DbName) -> Folder = kazoo_data_config:get_ne_binary(<<"default_archive_folder">>, <<"/tmp">>), db_archive(DbName, filename:join([<>])). @@ -535,7 +535,7 @@ db_archive(DbName, Filename) -> {'error', _}=E -> E end. --spec db_import(ne_binary(), file:filename_all()) -> 'ok' | data_error(). +-spec db_import(kz_term:ne_binary(), file:filename_all()) -> 'ok' | data_error(). db_import(DbName, ArchiveFile) when ?VALID_DBNAME(DbName) -> kzs_db:db_import(kzs_plan:plan(DbName), DbName, ArchiveFile); db_import(DbName, ArchiveFile) -> @@ -554,10 +554,10 @@ db_import(DbName, ArchiveFile) -> %% fetch a cached doc or open it if not available. %% @end %%-------------------------------------------------------------------- --spec open_cache_doc(text(), docid()) -> +-spec open_cache_doc(kz_term:text(), docid()) -> {'ok', kz_json:object()} | data_error(). --spec open_cache_doc(text(), docid(), kz_proplist()) -> +-spec open_cache_doc(kz_term:text(), docid(), kz_term:proplist()) -> {'ok', kz_json:object()} | data_error(). open_cache_doc(DbName, {DocType, DocId}) -> @@ -575,7 +575,7 @@ open_cache_doc(DbName, DocId, Options) -> {'error', _}=E -> E end. --spec add_to_doc_cache(text(), ne_binary(), kz_json:object()) -> +-spec add_to_doc_cache(kz_term:text(), kz_term:ne_binary(), kz_json:object()) -> 'ok' | data_error(). add_to_doc_cache(DbName, DocId, Doc) when ?VALID_DBNAME(DbName) -> @@ -586,7 +586,7 @@ add_to_doc_cache(DbName, DocId, Doc) -> {'error', _}=E -> E end. --spec update_cache_doc(text(), ne_binary(), fun((kz_json:object()) -> kz_json:object() | 'skip')) -> +-spec update_cache_doc(kz_term:text(), kz_term:ne_binary(), fun((kz_json:object()) -> kz_json:object() | 'skip')) -> {'ok', kz_json:object()} | data_error(). update_cache_doc(DbName, DocId, Fun) when is_function(Fun, 1) -> @@ -599,7 +599,7 @@ update_cache_doc(DbName, DocId, Fun) when is_function(Fun, 1) -> Else end. --spec maybe_save_doc(text(), kz_json:object() | 'skip', kz_json:object()) -> +-spec maybe_save_doc(kz_term:text(), kz_json:object() | 'skip', kz_json:object()) -> {'ok', kz_json:object() | kz_json:objects()} | data_error(). maybe_save_doc(_DbName, 'skip', Jobj) -> @@ -607,13 +607,13 @@ maybe_save_doc(_DbName, 'skip', Jobj) -> maybe_save_doc(DbName, JObj, _OldJobj) -> save_doc(DbName, JObj). --spec flush_cache_doc(ne_binary(), ne_binary() | kz_json:object()) -> +-spec flush_cache_doc(kz_term:ne_binary(), kz_term:ne_binary() | kz_json:object()) -> 'ok' | {'error', 'invalid_db_name'}. flush_cache_doc(DbName, Doc) -> flush_cache_doc(DbName, Doc, []). --spec flush_cache_doc(ne_binary(), ne_binary() | kz_json:object(), kz_proplist()) -> +-spec flush_cache_doc(kz_term:ne_binary(), kz_term:ne_binary() | kz_json:object(), kz_term:proplist()) -> 'ok' | {'error', 'invalid_db_name'}. flush_cache_doc(DbName, Doc, Options) when ?VALID_DBNAME(DbName) -> @@ -625,7 +625,7 @@ flush_cache_doc(DbName, Doc, Options) -> end. -spec flush_cache_docs() -> 'ok'. --spec flush_cache_docs(text()) -> 'ok' | {'error', 'invalid_db_name'}. +-spec flush_cache_docs(kz_term:text()) -> 'ok' | {'error', 'invalid_db_name'}. flush_cache_docs() -> kzs_cache:flush_cache_docs(). flush_cache_docs(DbName) -> case maybe_convert_dbname(DbName) of @@ -653,11 +653,11 @@ flush_cache_docs(DbName) -> -define(OPEN_DOC_LOG(DbName, DocId, Options), ok). -endif. --spec open_doc(text(), docid()) -> +-spec open_doc(kz_term:text(), docid()) -> {'ok', kz_json:object()} | data_error() | {'error', 'not_found'}. --spec open_doc(text(), docid(), kz_proplist()) -> +-spec open_doc(kz_term:text(), docid(), kz_term:proplist()) -> {'ok', kz_json:object()} | data_error() | {'error', 'not_found'}. @@ -686,11 +686,11 @@ open_doc(DbName, DocId, Options) -> %% So: match both error tuple & each JSON of the list. %% @end %%-------------------------------------------------------------------- --spec open_docs(text(), docids()) -> +-spec open_docs(kz_term:text(), docids()) -> {'ok', kz_json:objects()} | data_error() | {'error', 'not_found'}. --spec open_docs(text(), docids(), kz_proplist()) -> +-spec open_docs(kz_term:text(), docids(), kz_term:proplist()) -> {'ok', kz_json:objects()} | data_error() | {'error', 'not_found'}. @@ -744,11 +744,11 @@ read_chunked_results(DocIds, {error, Reason}, Acc) -> %% Note: no guaranty on order of results is provided. %% @end %%-------------------------------------------------------------------- --spec open_cache_docs(text(), docids()) -> +-spec open_cache_docs(kz_term:text(), docids()) -> {'ok', kz_json:objects()} | data_error() | {'error', 'not_found'}. --spec open_cache_docs(text(), docids(), kz_proplist()) -> +-spec open_cache_docs(kz_term:text(), docids(), kz_term:proplist()) -> {'ok', kz_json:objects()} | data_error() | {'error', 'not_found'}. @@ -765,10 +765,10 @@ open_cache_docs(DbName, DocIds, Options) -> end. --spec all_docs(text()) -> +-spec all_docs(kz_term:text()) -> {'ok', kz_json:objects()} | data_error(). --spec all_docs(text(), kz_proplist()) -> +-spec all_docs(kz_term:text(), kz_term:proplist()) -> {'ok', kz_json:objects()} | data_error(). @@ -783,8 +783,8 @@ all_docs(DbName, Options) -> {'error', _}=E -> E end. --spec db_list() -> {'ok', ne_binaries()} | data_error(). --spec db_list(kz_proplist()) -> {'ok', ne_binaries()} | data_error(). +-spec db_list() -> {'ok', kz_term:ne_binaries()} | data_error(). +-spec db_list(kz_term:proplist()) -> {'ok', kz_term:ne_binaries()} | data_error(). db_list() -> db_list([]). @@ -792,10 +792,10 @@ db_list() -> db_list(Options) -> kzs_db:db_list(kzs_plan:plan(), Options). --spec all_design_docs(text()) -> {'ok', kz_json:objects()} | - data_error(). --spec all_design_docs(text(), kz_proplist()) -> {'ok', kz_json:objects()} | - data_error(). +-spec all_design_docs(kz_term:text()) -> {'ok', kz_json:objects()} | + data_error(). +-spec all_design_docs(kz_term:text(), kz_term:proplist()) -> {'ok', kz_json:objects()} | + data_error(). all_design_docs(DbName) -> all_design_docs(DbName, []). @@ -814,16 +814,16 @@ all_design_docs(DbName, Options) -> %% get the revision of a document (much faster than requesting the whole document) %% @end %%-------------------------------------------------------------------- --spec lookup_doc_rev(text(), docid()) -> - {'ok', ne_binary()} | +-spec lookup_doc_rev(kz_term:text(), docid()) -> + {'ok', kz_term:ne_binary()} | data_error(). lookup_doc_rev(DbName, {DocType, DocId}) -> lookup_doc_rev(DbName, DocId, [{'doc_type', DocType}]); lookup_doc_rev(DbName, DocId) -> lookup_doc_rev(DbName, DocId, []). --spec lookup_doc_rev(text(), docid(), kz_proplist()) -> - {'ok', ne_binary()} | data_error(). +-spec lookup_doc_rev(kz_term:text(), docid(), kz_term:proplist()) -> + {'ok', kz_term:ne_binary()} | data_error(). lookup_doc_rev(DbName, {DocType, DocId}, Options) -> lookup_doc_rev(DbName, DocId, maybe_add_doc_type(DocType, Options)); lookup_doc_rev(DbName, DocId, Options) when ?VALID_DBNAME(DbName) -> @@ -840,7 +840,7 @@ lookup_doc_rev(DbName, DocId, Options) -> %% Save document to database %% @end %%-------------------------------------------------------------------- --spec save_doc(text(), kz_json:object() | kz_json:objects()) -> +-spec save_doc(kz_term:text(), kz_json:object() | kz_json:objects()) -> {'ok', kz_json:object() | kz_json:objects()} | data_error(). save_doc(DbName, Docs) when is_list(Docs) -> @@ -855,10 +855,10 @@ save_doc(DbName, Doc) -> %% revision and tries saving again. Otherwise return. %% @end %%-------------------------------------------------------------------- --spec ensure_saved(text(), kz_json:object()) -> +-spec ensure_saved(kz_term:text(), kz_json:object()) -> {'ok', kz_json:object()} | data_error(). --spec ensure_saved(text(), kz_json:object(), kz_proplist()) -> +-spec ensure_saved(kz_term:text(), kz_json:object(), kz_term:proplist()) -> {'ok', kz_json:object()} | data_error(). @@ -873,7 +873,7 @@ ensure_saved(DbName, Doc, Options) -> {'error', _}=E -> E end. --spec save_doc(text(), kz_json:object(), kz_proplist()) -> +-spec save_doc(kz_term:text(), kz_json:object(), kz_term:proplist()) -> {'ok', kz_json:object()} | data_error(). save_doc(DbName, Doc, Options) when ?VALID_DBNAME(DbName) -> @@ -887,7 +887,7 @@ save_doc(DbName, Doc, Options) -> {'error', _}=E -> E end. --spec maybe_toggle_publish(kz_proplist()) -> boolean(). +-spec maybe_toggle_publish(kz_term:proplist()) -> boolean(). maybe_toggle_publish(Options) -> Old = change_notice(), case props:get_value('publish_change_notice', Options) of @@ -903,10 +903,10 @@ maybe_revert_publish('true') -> maybe_revert_publish('false') -> suppress_change_notice(). --spec save_docs(text(), kz_json:objects()) -> +-spec save_docs(kz_term:text(), kz_json:objects()) -> {'ok', kz_json:objects()} | data_error(). --spec save_docs(text(), kz_json:objects(), kz_proplist()) -> +-spec save_docs(kz_term:text(), kz_json:objects(), kz_term:proplist()) -> {'ok', kz_json:objects()} | data_error(). @@ -935,13 +935,13 @@ save_docs(DbName, Docs, Options) when is_list(Docs) -> %% @end %%-------------------------------------------------------------------- -type update_props() :: [{kz_json:path(), kz_json:json_term()}]. --spec update_doc(ne_binary(), docid(), update_props()) -> +-spec update_doc(kz_term:ne_binary(), docid(), update_props()) -> {'ok', kz_json:object()} | data_error(). --spec update_doc(ne_binary(), docid(), update_props(), kz_proplist()) -> +-spec update_doc(kz_term:ne_binary(), docid(), update_props(), kz_term:proplist()) -> {'ok', kz_json:object()} | data_error(). --spec update_doc(ne_binary(), docid(), update_props(), kz_proplist(), kz_proplist()) -> +-spec update_doc(kz_term:ne_binary(), docid(), update_props(), kz_term:proplist(), kz_term:proplist()) -> {'ok', kz_json:object()} | data_error(). @@ -978,13 +978,13 @@ update_doc(DbName, Id, UpdateProps, CreateProps, ExtraUpdateProps) %% remove document from the db %% @end %%-------------------------------------------------------------------- --spec del_doc(text(), kz_json:object() | kz_json:objects() | ne_binary()) -> +-spec del_doc(kz_term:text(), kz_json:object() | kz_json:objects() | kz_term:ne_binary()) -> {'ok', kz_json:objects()} | data_error(). del_doc(DbName, Doc) -> del_doc(DbName, Doc, []). --spec del_doc(text(), kz_json:object() | kz_json:objects() | ne_binary(), kz_proplist()) -> +-spec del_doc(kz_term:text(), kz_json:object() | kz_json:objects() | kz_term:ne_binary(), kz_term:proplist()) -> {'ok', kz_json:objects()} | data_error(). del_doc(DbName, Doc, Options) when is_list(Doc) -> @@ -1003,13 +1003,13 @@ del_doc(DbName, Doc, Options) -> %% remove documents from the db %% @end %%-------------------------------------------------------------------- --spec del_docs(text(), kz_json:objects() | ne_binaries()) -> +-spec del_docs(kz_term:text(), kz_json:objects() | kz_term:ne_binaries()) -> {'ok', kz_json:objects()} | data_error(). del_docs(DbName, Docs) -> del_docs(DbName, Docs, []). --spec del_docs(text(), kz_json:objects() | ne_binaries(), kz_proplist()) -> +-spec del_docs(kz_term:text(), kz_json:objects() | kz_term:ne_binaries(), kz_term:proplist()) -> {'ok', kz_json:objects()} | data_error(). del_docs(DbName, Docs, Options) @@ -1025,11 +1025,11 @@ del_docs(DbName, Docs, Options) when is_list(Docs) -> %%% Attachment Functions %%%=================================================================== --spec fetch_attachment(text(), docid(), ne_binary()) -> +-spec fetch_attachment(kz_term:text(), docid(), kz_term:ne_binary()) -> {'ok', binary()} | data_error(). --spec fetch_attachment(text(), docid(), ne_binary(), kz_proplist()) -> +-spec fetch_attachment(kz_term:text(), docid(), kz_term:ne_binary(), kz_term:proplist()) -> {'ok', binary()} | data_error(). fetch_attachment(DbName, {DocType, DocId}, AName) -> @@ -1047,19 +1047,19 @@ fetch_attachment(DbName, DocId, AName, Options) -> {'error', _}=E -> E end. --spec stream_attachment(text(), docid(), ne_binary()) -> +-spec stream_attachment(kz_term:text(), docid(), kz_term:ne_binary()) -> {'ok', reference()} | {'error', any()}. stream_attachment(DbName, DocId, AName) -> stream_attachment(DbName, DocId, AName, []). --spec stream_attachment(text(), docid(), ne_binary(), kz_proplist()) -> +-spec stream_attachment(kz_term:text(), docid(), kz_term:ne_binary(), kz_term:proplist()) -> {'ok', reference()} | {'error', any()}. stream_attachment(DbName, DocId, AName, Options) -> stream_attachment(DbName, DocId, AName, Options, self()). --spec stream_attachment(text(), docid(), ne_binary(), kz_proplist(), pid()) -> +-spec stream_attachment(kz_term:text(), docid(), kz_term:ne_binary(), kz_term:proplist(), pid()) -> {'ok', reference()} | {'error', any()}. stream_attachment(DbName, {DocType, DocId}, AName, Options, Pid) when ?VALID_DBNAME(DbName) -> @@ -1072,13 +1072,13 @@ stream_attachment(DbName, DocId, AName, Options, Pid) -> {'error', _}=E -> E end. --spec put_attachment(text(), docid(), ne_binary(), ne_binary()) -> +-spec put_attachment(kz_term:text(), docid(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | data_error(). %% Options = [ {'content_type', Type}, {'content_length', Len}, {'rev', Rev}] <- note atoms as keys in proplist --spec put_attachment(text(), docid(), ne_binary(), ne_binary(), kz_proplist()) -> +-spec put_attachment(kz_term:text(), docid(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> {'ok', kz_json:object()} | - {'ok', kz_json:object(), kz_proplist()} | + {'ok', kz_json:object(), kz_term:proplist()} | data_error(). put_attachment(DbName, DocId, AName, Contents) -> put_attachment(DbName, DocId, AName, Contents, []). @@ -1098,10 +1098,10 @@ put_attachment(DbName, DocId, AName, Contents, Options) -> {'error', _}=E -> E end. --spec delete_attachment(text(), ne_binary(), ne_binary()) -> +-spec delete_attachment(kz_term:text(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | data_error(). --spec delete_attachment(text(), ne_binary(), ne_binary(), kz_proplist()) -> +-spec delete_attachment(kz_term:text(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> {'ok', kz_json:object()} | data_error(). delete_attachment(DbName, DocId, AName) -> @@ -1115,12 +1115,12 @@ delete_attachment(DbName, DocId, AName, Options) -> {'error', _}=E -> E end. --spec attachment_url(text(), docid(), ne_binary()) -> - {'ok', ne_binary()} | +-spec attachment_url(kz_term:text(), docid(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | {'proxy', tuple()} | {'error', any()}. --spec attachment_url(text(), docid(), ne_binary(), kz_proplist()) -> - {'ok', ne_binary()} | +-spec attachment_url(kz_term:text(), docid(), kz_term:ne_binary(), kz_term:proplist()) -> + {'ok', kz_term:ne_binary()} | {'proxy', tuple()} | {'error', any()}. attachment_url(DbName, DocId, AttachmentId) -> @@ -1223,10 +1223,10 @@ add_required_option({Key, Fun}, {JObj, Options}=Acc) -> %% {Total, Offset, Meta, Rows} %% @end %%-------------------------------------------------------------------- --spec get_all_results(ne_binary(), ne_binary()) -> get_results_return(). --spec get_results(ne_binary(), ne_binary()) -> get_results_return(). --spec get_results(ne_binary(), ne_binary(), view_options()) -> get_results_return(). --spec get_results_count(ne_binary(), ne_binary(), view_options()) -> +-spec get_all_results(kz_term:ne_binary(), kz_term:ne_binary()) -> get_results_return(). +-spec get_results(kz_term:ne_binary(), kz_term:ne_binary()) -> get_results_return(). +-spec get_results(kz_term:ne_binary(), kz_term:ne_binary(), view_options()) -> get_results_return(). +-spec get_results_count(kz_term:ne_binary(), kz_term:ne_binary(), view_options()) -> {'ok', integer()} | data_error(). get_all_results(DbName, DesignDoc) -> @@ -1255,7 +1255,7 @@ get_results_count(DbName, DesignDoc, Options) -> Opts = maybe_add_doc_type_from_view(DesignDoc, Options), kzs_view:get_results_count(kzs_plan:plan(DbName, Opts), DbName, DesignDoc, Options). --spec maybe_create_view(ne_binary(), map(), ne_binary(), view_options()) -> get_results_return(). +-spec maybe_create_view(kz_term:ne_binary(), map(), kz_term:ne_binary(), view_options()) -> get_results_return(). maybe_create_view(DbName, Plan, DesignDoc, Options) -> case props:get_value('view_json', Options) of 'undefined' -> {'error', 'not_found'}; @@ -1264,10 +1264,10 @@ maybe_create_view(DbName, Plan, DesignDoc, Options) -> kzs_view:get_results(Plan, DbName, DesignDoc, Options) end. --spec get_result_keys(ne_binary(), ne_binary()) -> - {'ok', ne_binaries() | [ne_binaries()]} | data_error(). --spec get_result_keys(ne_binary(), ne_binary(), view_options()) -> - {'ok', ne_binaries() | [ne_binaries()]} | data_error(). +-spec get_result_keys(kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binaries() | [kz_term:ne_binaries()]} | data_error(). +-spec get_result_keys(kz_term:ne_binary(), kz_term:ne_binary(), view_options()) -> + {'ok', kz_term:ne_binaries() | [kz_term:ne_binaries()]} | data_error(). get_result_keys(DbName, DesignDoc) -> get_result_keys(DbName, DesignDoc, []). get_result_keys(DbName, DesignDoc, Options) -> @@ -1284,10 +1284,10 @@ get_result_keys(JObjs) -> || JObj <- JObjs ]. --spec get_result_ids(ne_binary(), ne_binary()) -> - {'ok', ne_binaries()} | data_error(). --spec get_result_ids(ne_binary(), ne_binary(), view_options()) -> - {'ok', ne_binaries()} | data_error(). +-spec get_result_ids(kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binaries()} | data_error(). +-spec get_result_ids(kz_term:ne_binary(), kz_term:ne_binary(), view_options()) -> + {'ok', kz_term:ne_binaries()} | data_error(). get_result_ids(DbName, DesignDoc) -> get_result_ids(DbName, DesignDoc, []). get_result_ids(DbName, DesignDoc, Options) -> @@ -1298,7 +1298,7 @@ get_result_ids(DbName, DesignDoc, Options) -> {'error', _} = Error -> Error end. --spec get_result_ids(kz_json:objects()) -> ne_binaries(). +-spec get_result_ids(kz_json:objects()) -> kz_term:ne_binaries(). get_result_ids(JObjs) -> [kz_doc:id(JObj) || JObj <- JObjs]. @@ -1313,7 +1313,7 @@ get_result_ids(JObjs) -> %% - otherwise `{error, multiple_results}' is returned. %% @end %%-------------------------------------------------------------------- --spec get_single_result(ne_binary(), ne_binary(), view_options()) -> +-spec get_single_result(kz_term:ne_binary(), kz_term:ne_binary(), view_options()) -> {'ok', kz_json:object()} | {'error', 'multiple_results'} | data_error(). @@ -1329,7 +1329,7 @@ get_single_result(DbName, DesignDoc, Options) -> {'error', _}=E -> E end. --spec get_result_doc(ne_binary(), ne_binary(), ne_binary()) -> +-spec get_result_doc(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', 'multiple_results'} | data_error(). @@ -1344,7 +1344,7 @@ get_result_doc(DbName, DesignDoc, Key) -> {'error', _}=E -> E end. --spec get_result_docs(ne_binary(), ne_binary(), ne_binaries()) -> +-spec get_result_docs(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binaries()) -> {'ok', kz_json:objects()} | data_error(). get_result_docs(DbName, DesignDoc, Keys) -> @@ -1357,13 +1357,13 @@ get_result_docs(DbName, DesignDoc, Keys) -> {'error', _}=E -> E end. --spec get_uuid() -> ne_binary(). --spec get_uuid(pos_integer()) -> ne_binary(). +-spec get_uuid() -> kz_term:ne_binary(). +-spec get_uuid(pos_integer()) -> kz_term:ne_binary(). get_uuid() -> get_uuid(?UUID_SIZE). get_uuid(N) -> kz_binary:rand_hex(N). --spec get_uuids(pos_integer()) -> ne_binaries(). --spec get_uuids(pos_integer(), pos_integer()) -> ne_binaries(). +-spec get_uuids(pos_integer()) -> kz_term:ne_binaries(). +-spec get_uuids(pos_integer(), pos_integer()) -> kz_term:ne_binaries(). get_uuids(Count) -> get_uuids(Count, ?UUID_SIZE). get_uuids(Count, Size) -> [get_uuid(Size) || _ <- lists:seq(1, Count)]. @@ -1399,8 +1399,8 @@ change_notice() -> %% handle a crash appropriately/gracefully this is a quick solution... %% @end %%-------------------------------------------------------------------- --spec maybe_convert_dbname(text()) -> - {'ok', ne_binary()} | +-spec maybe_convert_dbname(kz_term:text()) -> + {'ok', kz_term:ne_binary()} | {'error', 'invalid_db_name'}. maybe_convert_dbname(DbName) -> case kz_term:is_empty(DbName) of @@ -1408,10 +1408,10 @@ maybe_convert_dbname(DbName) -> 'false' -> {'ok', kz_term:to_binary(DbName)} end. --spec copy_doc(ne_binary(), docid(), ne_binary(), kz_proplist()) -> +-spec copy_doc(kz_term:ne_binary(), docid(), kz_term:ne_binary(), kz_term:proplist()) -> {'ok', kz_json:object()} | data_error(). --spec copy_doc(ne_binary(), docid(), ne_binary(), docid(), kz_proplist()) -> +-spec copy_doc(kz_term:ne_binary(), docid(), kz_term:ne_binary(), docid(), kz_term:proplist()) -> {'ok', kz_json:object()} | data_error(). copy_doc(FromDB, FromId, ToDB, Options) -> @@ -1431,10 +1431,10 @@ copy_doc(FromDB, FromId, ToDB, ToId, Options) -> }, kzs_doc:copy_doc(Src, Dst, CopySpec, Options). --spec move_doc(ne_binary(), docid(), ne_binary(), kz_proplist()) -> +-spec move_doc(kz_term:ne_binary(), docid(), kz_term:ne_binary(), kz_term:proplist()) -> {'ok', kz_json:object()} | data_error(). --spec move_doc(ne_binary(), docid(), ne_binary(), docid(), kz_proplist()) -> +-spec move_doc(kz_term:ne_binary(), docid(), kz_term:ne_binary(), docid(), kz_term:proplist()) -> {'ok', kz_json:object()} | data_error(). move_doc(FromDB, FromId, ToDB, Options) -> @@ -1480,27 +1480,27 @@ max_bulk_read(ViewOptions) -> UpperBound = min(AskedFor, max_bulk_read()), max(UpperBound, 1). --spec db_classification(text()) -> db_classification(). +-spec db_classification(kz_term:text()) -> db_classification(). db_classification(DBName) -> kzs_util:db_classification(DBName). -spec format_error(any()) -> any(). format_error(Error) -> kzs_server:format_error(Error). --spec maybe_add_doc_type(ne_binary(), view_options()) -> view_options(). +-spec maybe_add_doc_type(kz_term:ne_binary(), view_options()) -> view_options(). maybe_add_doc_type(DocType, Options) -> case props:get_value('doc_type', Options) of 'undefined' -> [{'doc_type', DocType} | Options]; _ -> Options end. --spec maybe_add_doc_type_from_view(ne_binary(), view_options()) -> view_options(). +-spec maybe_add_doc_type_from_view(kz_term:ne_binary(), view_options()) -> view_options(). maybe_add_doc_type_from_view(ViewName, Options) -> case props:get_value('doc_type', Options) of 'undefined' -> add_doc_type_from_view(ViewName, Options); _ -> Options end. --spec add_doc_type_from_view(ne_binary(), view_options()) -> view_options(). +-spec add_doc_type_from_view(kz_term:ne_binary(), view_options()) -> view_options(). add_doc_type_from_view(View, Options) -> case binary:split(View, <<"/">>, ['global']) of [ViewType, ViewName] -> @@ -1519,26 +1519,26 @@ init_dbs() -> revise_docs_from_folder(?KZ_DATA_DB, 'kazoo_data', <<"views">>), Result. --spec register_views(ne_binary() | db_classification(), views_listing()) -> 'ok'. +-spec register_views(kz_term:ne_binary() | db_classification(), views_listing()) -> 'ok'. register_views(Classification, Views) -> App = kz_util:calling_app(), register_views(Classification, kz_term:to_atom(App, 'true'), Views). --spec register_views(ne_binary() | db_classification(), atom(), views_listing()) -> 'ok'. +-spec register_views(kz_term:ne_binary() | db_classification(), atom(), views_listing()) -> 'ok'. register_views(_Classification, _App, []) -> 'ok'; register_views(Classification, App, [View | Other]) -> _ = register_view(Classification, App, View), register_views(Classification, App, Other). --spec register_view(ne_binary() | db_classification(), view_listing()) -> +-spec register_view(kz_term:ne_binary() | db_classification(), view_listing()) -> {'ok', kz_json:object()} | data_error(). register_view(Classification, View) -> App = kz_util:calling_app(), register_view(Classification, kz_term:to_atom(App, 'true'), View). --spec register_view(ne_binary() | db_classification(), atom(), view_listing() | string() | ne_binary()) -> +-spec register_view(kz_term:ne_binary() | db_classification(), atom(), view_listing() | string() | kz_term:ne_binary()) -> {'ok', kz_json:object()} | data_error(). register_view(Classification, App, {<<"_design/", Name/binary>>, View}) -> @@ -1556,20 +1556,20 @@ register_view(Classification, App, {<<"_design/", Name/binary>>, View}) -> register_view(Classification, App, ViewName) -> register_view(Classification, App, kzs_util:get_view_json(App, ViewName)). --spec register_views_from_folder(ne_binary() | db_classification()) -> 'ok'. +-spec register_views_from_folder(kz_term:ne_binary() | db_classification()) -> 'ok'. register_views_from_folder(Classification) -> register_views_from_folder(Classification, kz_term:to_atom(kz_util:calling_app(), 'true')). --spec register_views_from_folder(ne_binary() | db_classification(), atom()) -> 'ok'. +-spec register_views_from_folder(kz_term:ne_binary() | db_classification(), atom()) -> 'ok'. register_views_from_folder(Classification, App) -> register_views_from_folder(Classification, App, "views"). --spec register_views_from_folder(ne_binary() | db_classification(), atom(), ne_binary() | nonempty_string()) -> 'ok'. +-spec register_views_from_folder(kz_term:ne_binary() | db_classification(), atom(), kz_term:ne_binary() | nonempty_string()) -> 'ok'. register_views_from_folder(Classification, App, Folder) -> Views = kzs_util:get_views_json(App, Folder), register_views(Classification, App, Views). --spec refresh_views(ne_binary()) -> boolean() | {'error', 'invalid_db_name'}. +-spec refresh_views(kz_term:ne_binary()) -> boolean() | {'error', 'invalid_db_name'}. refresh_views(DbName) when ?VALID_DBNAME(DbName) -> suppress_change_notice(), Classification = kz_term:to_binary(kzs_util:db_classification(DbName)), diff --git a/core/kazoo_data/src/kzs_attachments.erl b/core/kazoo_data/src/kzs_attachments.erl index e4d5c9e1aca..eeaeb08fd1a 100644 --- a/core/kazoo_data/src/kzs_attachments.erl +++ b/core/kazoo_data/src/kzs_attachments.erl @@ -20,7 +20,7 @@ -define(KEY_STUB_ATTACHMENTS, <<"pvt_attachments">>). %% Attachment-related functions ------------------------------------------------ --spec fetch_attachment(map(), ne_binary(), ne_binary(), ne_binary()) -> +-spec fetch_attachment(map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', binary()} | data_error(). fetch_attachment(#{}=Server, DbName, DocId, AName) -> @@ -51,7 +51,7 @@ do_fetch_attachment_from_handler([{Handler, HandlerProps}], {Module, ModuleProps DiffModule -> DiffModule:fetch_attachment(HandlerProps, DbName, DocId, AName) end. --spec stream_attachment(map(), ne_binary(), ne_binary(), ne_binary(), pid()) -> +-spec stream_attachment(map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), pid()) -> {'ok', reference()} | data_error(). stream_attachment(#{}=Server, DbName, DocId, AName, Caller) -> @@ -112,9 +112,9 @@ relay_stream_attachment(Caller, Ref, Bin) -> ,'server' := {module(), db()} }. --spec put_attachment(att_map(), ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_proplist()) -> +-spec put_attachment(att_map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> {'ok', kz_json:object()} | - {'ok', kz_json:object(), kz_proplist()} | + {'ok', kz_json:object(), kz_term:proplist()} | data_error(). put_attachment(#{att_handler := {Handler, Params}}=Map @@ -144,10 +144,10 @@ attachment_handler_jobj(Handler, Props) -> JObj = kz_json:from_list(props:get_value('attachment', Props, [])), kz_json:set_value(kz_term:to_binary(Handler), JObj, kz_json:new()). --spec handle_put_attachment(att_map(), kz_json:object(), ne_binary(), ne_binary(), ne_binary(), ne_binary() - , kz_proplist(), kz_proplist()) -> +-spec handle_put_attachment(att_map(), kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary() + , kz_term:proplist(), kz_term:proplist()) -> {'ok', kz_json:object()} | - {'ok', kz_json:object(), kz_proplist()} | + {'ok', kz_json:object(), kz_term:proplist()} | data_error(). handle_put_attachment(#{att_post_handler := 'stub' @@ -162,7 +162,7 @@ handle_put_attachment(#{att_post_handler := 'external'}=Map, Att, DbName, DocId, {'error', _}=E -> E end. --spec external_attachment(att_map(), ne_binary(), kz_json:object(), kz_json:object(), Props) -> +-spec external_attachment(att_map(), kz_term:ne_binary(), kz_json:object(), kz_json:object(), Props) -> {'ok', kz_json:object(), Props} | data_error(). external_attachment(Map, DbName, JObj, Att, Props) -> @@ -172,15 +172,15 @@ external_attachment(Map, DbName, JObj, Att, Props) -> Error -> Error end. --spec delete_attachment(map(), ne_binary(), ne_binary(), ne_binary(), kz_proplist()) -> +-spec delete_attachment(map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> {'ok', kz_json:object()} | data_error(). delete_attachment(#{server := {App, Conn}}, DbName, DocId, AName, Options) -> kzs_cache:flush_cache_doc(DbName, DocId), App:delete_attachment(Conn, DbName, DocId, AName, Options). --spec attachment_url(map(), ne_binary(), ne_binary(), ne_binary(), api_atom(), kz_proplist()) -> - ne_binary() | +-spec attachment_url(map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_atom(), kz_term:proplist()) -> + kz_term:ne_binary() | {'proxy', tuple()}. attachment_url(#{att_proxy := 'true'}, DbName, DocId, AttachmentId, 'undefined', Options) -> {'proxy', {DbName, DocId, AttachmentId, Options}}; diff --git a/core/kazoo_data/src/kzs_cache.erl b/core/kazoo_data/src/kzs_cache.erl index 02a39c86e9f..96b1f0a449e 100644 --- a/core/kazoo_data/src/kzs_cache.erl +++ b/core/kazoo_data/src/kzs_cache.erl @@ -41,7 +41,7 @@ ,{<<"system_data">>, 'infinity'} ])). --spec open_cache_doc(text(), ne_binary(), kz_proplist()) -> +-spec open_cache_doc(kz_term:text(), kz_term:ne_binary(), kz_term:proplist()) -> {'ok', kz_json:object()} | data_error() | {'error', 'not_found'}. @@ -55,14 +55,14 @@ open_cache_doc(DbName, DocId, Options) -> R end. --spec maybe_cache(ne_binary(), ne_binary(), kz_proplist(), data_error() | {'ok', kz_json:object()}) -> +-spec maybe_cache(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist(), data_error() | {'ok', kz_json:object()}) -> 'ok'. maybe_cache(DbName, DocId, Options, {'error', _}=E) -> maybe_cache_failure(DbName, DocId, Options, E); maybe_cache(DbName, DocId, _, {'ok', JObj}) -> add_to_doc_cache(DbName, DocId, JObj). --spec open_cache_doc(map(), text(), ne_binary(), kz_proplist()) -> +-spec open_cache_doc(map(), kz_term:text(), kz_term:ne_binary(), kz_term:proplist()) -> {'ok', kz_json:object()} | data_error() | {'error', 'not_found'}. @@ -76,7 +76,7 @@ open_cache_doc(Server, DbName, DocId, Options) -> R end. --spec open_cache_docs(text(), ne_binaries(), kz_proplist()) -> +-spec open_cache_docs(kz_term:text(), kz_term:ne_binaries(), kz_term:proplist()) -> {'ok', kz_json:objects()} | data_error(). open_cache_docs(DbName, DocIds, Options) -> @@ -101,10 +101,10 @@ fetch_locals(DbName, DocIds) -> end, lists:foldl(F, {[], []}, DocIds). --type doc_returned() :: {ne_binary(), ok, kz_json:object()} | - {ne_binary(), error, ne_binary()}. +-type doc_returned() :: {kz_term:ne_binary(), ok, kz_json:object()} | + {kz_term:ne_binary(), error, kz_term:ne_binary()}. -type docs_returned() :: [doc_returned()]. --spec disassemble_jobjs(ne_binary(), kz_proplist(), kz_json:objects()) -> docs_returned(). +-spec disassemble_jobjs(kz_term:ne_binary(), kz_term:proplist(), kz_json:objects()) -> docs_returned(). disassemble_jobjs(DbName, Options, JObjs) -> [case kz_json:get_json_value(<<"doc">>, JObj) of 'undefined' -> @@ -120,7 +120,7 @@ disassemble_jobjs(DbName, Options, JObjs) -> DocId <- [kz_json:get_ne_value(<<"key">>, JObj)] ]. --spec assemble_jobjs(ne_binaries(), docs_returned(), docs_returned()) -> kz_json:objects(). +-spec assemble_jobjs(kz_term:ne_binaries(), docs_returned(), docs_returned()) -> kz_json:objects(). assemble_jobjs(DocIds, Cached, DocsReturned) -> JObjs1 = [to_nonbulk_format(Returned) || Returned <- Cached], JObjs2 = [to_nonbulk_format(Returned) || Returned <- DocsReturned], @@ -138,12 +138,12 @@ to_nonbulk_format({DocId, error, Reason}) -> ,{<<"error">>, kz_term:to_atom(Reason, true)} ]). --spec remove_cache_options(kz_proplist()) -> kz_proplist(). +-spec remove_cache_options(kz_term:proplist()) -> kz_term:proplist(). remove_cache_options(Options) -> props:delete_keys(['cache_failures'], Options). --spec maybe_cache_failure(ne_binary(), ne_binary(), kz_proplist(), data_error()) -> 'ok'. --spec maybe_cache_failure(ne_binary(), ne_binary(), kz_proplist(), data_error(), atoms()) -> 'ok'. +-spec maybe_cache_failure(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist(), data_error()) -> 'ok'. +-spec maybe_cache_failure(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist(), data_error(), kz_term:atoms()) -> 'ok'. maybe_cache_failure(DbName, DocId, Options, {'error', _}=Error) -> case props:get_value('cache_failures', Options) of ErrorCodes when is_list(ErrorCodes) -> @@ -158,7 +158,7 @@ maybe_cache_failure(DbName, DocId, _Options, {'error', ErrorCode}=Error, ErrorCo andalso add_to_doc_cache(DbName, DocId, Error), 'ok'. --spec add_to_doc_cache(ne_binary(), ne_binary(), kz_json:object() | data_error()) -> 'ok'. +-spec add_to_doc_cache(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object() | data_error()) -> 'ok'. add_to_doc_cache(DbName, DocId, CacheValue) -> kz_cache:erase_local(?CACHE_NAME, {?MODULE, DbName, DocId}), CacheProps = [{'origin', {'db', DbName, DocId}} @@ -171,7 +171,7 @@ add_to_doc_cache(DbName, DocId, CacheValue) -> kz_cache:store_local(?CACHE_NAME, {?MODULE, DbName, DocId}, CacheValue, CacheProps) end. --spec cache_if_not_media(kz_proplist(), ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec cache_if_not_media(kz_term:proplist(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. cache_if_not_media(CacheProps, DbName, DocId, CacheValue) -> %% NOTE: this is currently necessary because when a http_put is issued to %% freeswitch and the media is uploaded it goes directly to bigcouch @@ -191,7 +191,7 @@ cache_if_not_media(CacheProps, DbName, DocId, CacheValue) -> ) end. --spec expires_policy_value(ne_binary(), kz_json:object() | data_error()) -> kz_timeout(). +-spec expires_policy_value(kz_term:ne_binary(), kz_json:object() | data_error()) -> timeout(). expires_policy_value(_DbName, {'error', _}) -> ?DEFAULT_CACHE_PERIOD; expires_policy_value(DbName, CacheValue) -> @@ -199,7 +199,7 @@ expires_policy_value(DbName, CacheValue) -> Type = kz_doc:type(CacheValue, <<"no_type">>), expires_policy_value(DbName, Classification, Type). --spec expires_policy_value(ne_binary(), ne_binary(), ne_binary()) -> kz_timeout(). +-spec expires_policy_value(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> timeout(). expires_policy_value(<<"system_config">>, _, _) -> 'infinity'; expires_policy_value(<<"system_data">>, _, _) -> 'infinity'; expires_policy_value(DbName, Classification, Type) -> @@ -216,13 +216,13 @@ expires_policy_value(DbName, Classification, Type) -> Timeout -> kz_term:to_integer(Timeout) end. --spec flush_cache_doc(ne_binary() | db(), ne_binary() | kz_json:object()) -> 'ok'. +-spec flush_cache_doc(kz_term:ne_binary() | db(), kz_term:ne_binary() | kz_json:object()) -> 'ok'. flush_cache_doc(#db{name=Name}, Doc) -> flush_cache_doc(#db{name=Name}, Doc, []); flush_cache_doc(Db, Doc) when is_binary(Db) -> flush_cache_doc(Db, Doc, []). --spec flush_cache_doc(ne_binary() | db(), ne_binary() | kz_json:object(), kz_proplist()) -> 'ok'. +-spec flush_cache_doc(kz_term:ne_binary() | db(), kz_term:ne_binary() | kz_json:object(), kz_term:proplist()) -> 'ok'. flush_cache_doc(#db{name=Name}, Doc, Options) -> flush_cache_doc(kz_term:to_binary(Name), Doc, Options); flush_cache_doc(DbName, DocId, _Options) when is_binary(DocId) -> @@ -233,7 +233,7 @@ flush_cache_doc(DbName, Doc, Options) -> -spec flush_cache_docs() -> 'ok'. flush_cache_docs() -> kz_cache:flush_local(?CACHE_NAME). --spec flush_cache_docs(ne_binary() | db()) -> 'ok'. +-spec flush_cache_docs(kz_term:ne_binary() | db()) -> 'ok'. flush_cache_docs(#db{name=Name}) -> flush_cache_docs(kz_term:to_binary(Name)); flush_cache_docs(DbName) -> @@ -245,11 +245,11 @@ flush_cache_docs(DbName) -> _ = kz_cache:filter_local(?CACHE_NAME, Filter), 'ok'. --spec flush_cache_docs(ne_binary() | db(), ne_binaries() | kz_json:objects()) -> 'ok'. +-spec flush_cache_docs(kz_term:ne_binary() | db(), kz_term:ne_binaries() | kz_json:objects()) -> 'ok'. flush_cache_docs(Db, Docs) -> flush_cache_docs(Db, Docs, []). --spec flush_cache_docs(ne_binary() | db(), ne_binaries() | kz_json:objects(), kz_proplist()) -> 'ok'. +-spec flush_cache_docs(kz_term:ne_binary() | db(), kz_term:ne_binaries() | kz_json:objects(), kz_term:proplist()) -> 'ok'. flush_cache_docs(Db, Docs, Options) -> _ = [flush_cache_doc(Db, Doc, Options) || Doc <- Docs diff --git a/core/kazoo_data/src/kzs_db.erl b/core/kazoo_data/src/kzs_db.erl index ad0ab8b9852..a4be12c5ad8 100644 --- a/core/kazoo_data/src/kzs_db.erl +++ b/core/kazoo_data/src/kzs_db.erl @@ -27,22 +27,22 @@ -include("kz_data.hrl"). %%% DB-related functions --------------------------------------------- --spec db_compact(map(), ne_binary()) -> boolean(). +-spec db_compact(map(), kz_term:ne_binary()) -> boolean(). db_compact(#{server := {App, Conn}}, DbName) -> App:db_compact(Conn, DbName). --spec db_create(map(), ne_binary()) -> boolean(). +-spec db_create(map(), kz_term:ne_binary()) -> boolean(). db_create(Server, DbName) -> db_create(Server, DbName, []). --spec db_create(map(), ne_binary(), db_create_options()) -> boolean(). +-spec db_create(map(), kz_term:ne_binary(), db_create_options()) -> boolean(). db_create(#{}=Map, DbName, Options) -> %%TODO storage policy do_db_create(Map, DbName, Options) andalso db_create_others(Map, DbName, Options) andalso kzs_publish:publish_db(DbName, 'created'). --spec db_create_others(map(), ne_binary(), db_create_options()) -> boolean(). +-spec db_create_others(map(), kz_term:ne_binary(), db_create_options()) -> boolean(). db_create_others(#{}=Map, DbName, Options) -> EnsureOthers = props:get_value('ensure_other_dbs', Options, 'false'), case do_db_create_others(Map, DbName, Options) of @@ -50,27 +50,27 @@ db_create_others(#{}=Map, DbName, Options) -> _ -> 'true' end. --spec do_db_create_others(map(), ne_binary(), db_create_options()) -> boolean(). +-spec do_db_create_others(map(), kz_term:ne_binary(), db_create_options()) -> boolean(). do_db_create_others(Map, DbName, Options) -> Others = maps:get('others', Map, []), lists:all(fun({_Tag, M1}) -> do_db_create(#{server => M1}, DbName, Options) end, Others). --spec do_db_create(map(), ne_binary(), db_create_options()) -> boolean(). +-spec do_db_create(map(), kz_term:ne_binary(), db_create_options()) -> boolean(). do_db_create(#{server := {App, Conn}}, DbName, Options) -> case App:db_exists(Conn, DbName) of 'false' -> App:db_create(Conn, DbName, Options); 'true' -> 'true' end. --spec db_delete(map(), ne_binary(), db_delete_options()) -> boolean(). +-spec db_delete(map(), kz_term:ne_binary(), db_delete_options()) -> boolean(). db_delete(#{}=Map, DbName, Options) -> do_db_delete(Map, DbName) andalso db_delete_others(Map, DbName, Options) andalso kzs_publish:publish_db(DbName, 'deleted'). --spec db_delete_others(map(), ne_binary(), db_delete_options()) -> boolean(). +-spec db_delete_others(map(), kz_term:ne_binary(), db_delete_options()) -> boolean(). db_delete_others(#{}=Map, DbName, Options) -> EnsureOthers = props:get_value('ensure_other_dbs', Options, 'false'), case do_db_delete_others(Map, DbName) of @@ -78,24 +78,24 @@ db_delete_others(#{}=Map, DbName, Options) -> _ -> 'true' end. --spec do_db_delete_others(map(), ne_binary()) -> boolean(). +-spec do_db_delete_others(map(), kz_term:ne_binary()) -> boolean(). do_db_delete_others(Map, DbName) -> Others = maps:get('others', Map, []), lists:all(fun({_Tag, M1}) -> do_db_delete(#{server => M1}, DbName) end, Others). --spec do_db_delete(map(), ne_binary()) -> boolean(). +-spec do_db_delete(map(), kz_term:ne_binary()) -> boolean(). do_db_delete(#{server := {App, Conn}}, DbName) -> App:db_delete(Conn, DbName). --spec db_replicate(map(), kz_json:object() | kz_proplist()) -> +-spec db_replicate(map(), kz_json:object() | kz_term:proplist()) -> {'ok', kz_json:object()} | data_error(). db_replicate(#{server := {App, Conn}}, Prop) -> App:db_replicate(Conn,Prop). --spec db_view_cleanup(map(), ne_binary()) -> boolean(). +-spec db_view_cleanup(map(), kz_term:ne_binary()) -> boolean(). db_view_cleanup(#{}=Map, DbName) -> Others = maps:get('others', Map, []), do_db_view_cleanup(Map, DbName) @@ -103,17 +103,17 @@ db_view_cleanup(#{}=Map, DbName) -> do_db_view_cleanup(#{server => M1}, DbName) end, Others). --spec do_db_view_cleanup(map(), ne_binary()) -> boolean(). +-spec do_db_view_cleanup(map(), kz_term:ne_binary()) -> boolean(). do_db_view_cleanup(#{server := {App, Conn}}, DbName) -> App:db_view_cleanup(Conn, DbName). --spec db_info(map()) -> {'ok', ne_binaries()} |data_error(). +-spec db_info(map()) -> {'ok', kz_term:ne_binaries()} |data_error(). db_info(#{server := {App, Conn}}) -> App:db_info(Conn). --spec db_info(map(), ne_binary()) -> {'ok', kz_json:object()} | data_error(). +-spec db_info(map(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | data_error(). db_info(#{server := {App, Conn}}, DbName) -> App:db_info(Conn, DbName). --spec db_exists(map(), ne_binary()) -> boolean(). +-spec db_exists(map(), kz_term:ne_binary()) -> boolean(). db_exists(#{server := {App, Conn}}=Server, DbName) -> case kz_cache:fetch_local(?KAZOO_DATA_PLAN_CACHE, {'database', {App, Conn}, DbName}) of {'ok', Exists} -> Exists; @@ -124,14 +124,14 @@ db_exists(#{server := {App, Conn}}=Server, DbName) -> end end. --spec maybe_cache_db_exists(boolean(), map(), ne_binary()) -> boolean(). +-spec maybe_cache_db_exists(boolean(), map(), kz_term:ne_binary()) -> boolean(). maybe_cache_db_exists('false', _, _) -> 'false'; maybe_cache_db_exists('true', #{server := {App, Conn}}, DbName) -> Props = [{'origin', {'db', DbName}}], kz_cache:store_local(?KAZOO_DATA_PLAN_CACHE, {'database', {App, Conn}, DbName}, 'true', Props), 'true'. --spec db_exists_all(map(), ne_binary()) -> boolean(). +-spec db_exists_all(map(), kz_term:ne_binary()) -> boolean(). db_exists_all(Map, DbName) -> case kz_cache:fetch_local(?KAZOO_DATA_PLAN_CACHE, {'database', DbName}) of {'ok', Exists} -> Exists; @@ -139,26 +139,26 @@ db_exists_all(Map, DbName) -> andalso db_exists_others(DbName, maps:get('others', Map, [])) end. --spec db_exists_others(ne_binary(), list()) -> boolean(). +-spec db_exists_others(kz_term:ne_binary(), list()) -> boolean(). db_exists_others(_, []) -> 'true'; db_exists_others(DbName, Others) -> lists:all(fun({_Tag, M}) -> db_exists(#{server => M}, DbName) end, Others). --spec db_archive(map(), ne_binary(), ne_binary()) -> 'ok' | data_error(). +-spec db_archive(map(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | data_error(). db_archive(#{server := {App, Conn}}=Server, DbName, Filename) -> case db_exists(Server, DbName) of 'true' -> App:db_archive(Conn, DbName, Filename); 'false' -> 'ok' end. --spec db_import(map(), ne_binary(), ne_binary()) -> 'ok' | data_error(). +-spec db_import(map(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | data_error(). db_import(#{server := {App, Conn}}=Server, DbName, Filename) -> case db_exists(Server, DbName) of 'true' -> App:db_import(Conn, DbName, Filename); 'false' -> 'ok' end. --spec db_list(map(), view_options()) -> {'ok', ne_binaries()} | data_error(). +-spec db_list(map(), view_options()) -> {'ok', kz_term:ne_binaries()} | data_error(). db_list(#{server := {App, Conn}}=Map, Options) -> db_list_all(App:db_list(Conn, Options), Options, maps:get('others', Map, [])). @@ -171,7 +171,7 @@ db_list_all_fold({_Tag, Server}, {Options, DBs}) -> {'ok', DBList} = db_list(Server, Options), {Options, lists:usort(DBs ++ DBList)}. --spec db_view_update(map(), ne_binary(), views_listing(), boolean()) -> boolean(). +-spec db_view_update(map(), kz_term:ne_binary(), views_listing(), boolean()) -> boolean(). db_view_update(#{}=Map, DbName, Views, Remove) -> Others = maps:get('others', Map, []), do_db_view_update(Map, DbName, Views, Remove) @@ -181,7 +181,7 @@ db_view_update(#{}=Map, DbName, Views, Remove) -> ,Others ). --spec do_db_view_update(map(), ne_binary(), views_listing(), boolean()) -> boolean(). +-spec do_db_view_update(map(), kz_term:ne_binary(), views_listing(), boolean()) -> boolean(). do_db_view_update(#{server := {App, Conn}}=Server, Db, NewViews, Remove) -> case kzs_view:all_design_docs(Server, Db, ['include_docs']) of {'ok', JObjs} -> @@ -198,7 +198,7 @@ do_db_view_update(#{server := {App, Conn}}=Server, Db, NewViews, Remove) -> end end. --spec add_update_remove_views(map(), ne_binary(), views_listing(), views_listing(), boolean()) -> 'true'. +-spec add_update_remove_views(map(), kz_term:ne_binary(), views_listing(), views_listing(), boolean()) -> 'true'. add_update_remove_views(Server, Db, CurrentViews, NewViews, ShouldRemoveDangling) -> Current = sets:from_list([Id || {Id, _} <- CurrentViews]), New = sets:from_list([Id || {Id, _} <- NewViews]), @@ -220,7 +220,7 @@ add_update_remove_views(Server, Db, CurrentViews, NewViews, ShouldRemoveDangling orelse (length(Add) > 0 andalso length(Conflicts) < length(Add)). --spec add_views(map(), ne_binary(), ne_binaries(), views_listing()) -> api_ne_binaries(). +-spec add_views(map(), kz_term:ne_binary(), kz_term:ne_binaries(), views_listing()) -> kz_term:api_ne_binaries(). add_views(Server, Db, Add, NewViews) -> Views = [props:get_value(Id, NewViews) || Id <- Add], {'ok', JObjs} = kzs_doc:save_docs(Server, Db, Views, []), @@ -229,7 +229,7 @@ add_views(Server, Db, Add, NewViews) -> <<"conflict">> =:= kz_json:get_value(<<"error">>, JObj) ]. --spec update_views(map(), ne_binary(), ne_binaries(), views_listing(), views_listing()) -> {integer(), api_ne_binaries()}. +-spec update_views(map(), kz_term:ne_binary(), kz_term:ne_binaries(), views_listing(), views_listing()) -> {integer(), kz_term:api_ne_binaries()}. update_views(Server, Db, Update, CurrentViews, NewViews) -> Views = lists:flatten( [kz_doc:set_revision(NewView, kz_doc:revision(CurrentView)) @@ -245,7 +245,7 @@ update_views(Server, Db, Update, CurrentViews, NewViews) -> ], {length(Views), Errors}. --spec should_update(ne_binary(), kz_json:object(), kz_json:object()) -> boolean(). +-spec should_update(kz_term:ne_binary(), kz_json:object(), kz_json:object()) -> boolean(). should_update(_Id, _, undefined) -> lager:warning("view ~p does not exist to update", [_Id]), false; @@ -260,25 +260,25 @@ should_update(_Id, NewView, OldView) -> true end. --spec correct_view_errors(map(), ne_binary(), ne_binaries(), views_listing()) -> integer(). +-spec correct_view_errors(map(), kz_term:ne_binary(), kz_term:ne_binaries(), views_listing()) -> integer(). correct_view_errors(Server, Db, Errors, NewViews) -> Views = [props:get_value(Id, NewViews) || Id <- Errors], correct_view_errors(Server, Db, Views), length(Views). --spec correct_view_errors(map(), ne_binary(), kz_json:objects()) -> 'true'. +-spec correct_view_errors(map(), kz_term:ne_binary(), kz_json:objects()) -> 'true'. correct_view_errors(_, _, []) -> 'true'; correct_view_errors(Server, Db, [View|Views]) -> lager:debug("ensuring view ~s is saved to ~s", [kz_doc:id(View), Db]), _ = kzs_doc:ensure_saved(Server, Db, View, []), correct_view_errors(Server, Db, Views). --spec delete_views(map(), ne_binary(), ne_binaries(), views_listing()) -> 'true'. +-spec delete_views(map(), kz_term:ne_binary(), kz_term:ne_binaries(), views_listing()) -> 'true'. delete_views(Server, Db, Delete, CurrentViews) -> Views = [props:get_value(Id, CurrentViews) || Id <- Delete], delete_views(Server, Db, Views). --spec delete_views(map(), ne_binary(), kz_json:objects()) -> 'true'. +-spec delete_views(map(), kz_term:ne_binary(), kz_json:objects()) -> 'true'. delete_views(_, _, []) -> 'true'; delete_views(Server, Db, [View|Views]) -> lager:debug("deleting view ~s from ~s", [kz_doc:id(View), Db]), diff --git a/core/kazoo_data/src/kzs_doc.erl b/core/kazoo_data/src/kzs_doc.erl index d04e37687f5..8f1af90b334 100644 --- a/core/kazoo_data/src/kzs_doc.erl +++ b/core/kazoo_data/src/kzs_doc.erl @@ -22,7 +22,7 @@ -include("kz_data.hrl"). --type copy_function() :: fun((map(), ne_binary(), kz_json:object(), kz_proplist()) -> +-type copy_function() :: fun((map(), kz_term:ne_binary(), kz_json:object(), kz_term:proplist()) -> {'ok', kz_json:object()} | data_error()). -export_type([copy_function/0]). -define(COPY_DOC_OVERRIDE_PROPERTY, 'override_existing_document'). @@ -30,13 +30,13 @@ %% Document related functions -------------------------------------------------- --spec open_doc(map(), ne_binary(), ne_binary(), kz_proplist()) -> +-spec open_doc(map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> {'ok', kz_json:object()} | data_error(). open_doc(#{server := {App, Conn}}, DbName, DocId, Options) -> App:open_doc(Conn, DbName, DocId, Options). --spec save_doc(map(), ne_binary(), kz_json:object(), kz_proplist()) -> +-spec save_doc(map(), kz_term:ne_binary(), kz_json:object(), kz_term:proplist()) -> {'ok', kz_json:object()} | data_error(). save_doc(#{server := {App, Conn}}, DbName, Doc, Options) -> @@ -51,7 +51,7 @@ save_doc(#{server := {App, Conn}}, DbName, Doc, Options) -> end. --spec save_docs(map(), ne_binary(), kz_json:objects(), kz_proplist()) -> +-spec save_docs(map(), kz_term:ne_binary(), kz_json:objects(), kz_term:proplist()) -> {'ok', kz_json:objects()} | data_error(). save_docs(#{server := {App, Conn}}, DbName, Docs, Options) -> @@ -65,13 +65,13 @@ save_docs(#{server := {App, Conn}}, DbName, Docs, Options) -> _Ex:Er -> {'error', {_Ex, Er}} end. --spec lookup_doc_rev(map(), ne_binary(), ne_binary()) -> - {'ok', ne_binary()} | +-spec lookup_doc_rev(map(), kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', kz_term:ne_binary()} | data_error(). lookup_doc_rev(#{server := {App, Conn}}, DbName, DocId) -> App:lookup_doc_rev(Conn, DbName, DocId). --spec ensure_saved(map(), ne_binary(), kz_json:object(), kz_proplist()) -> +-spec ensure_saved(map(), kz_term:ne_binary(), kz_json:object(), kz_term:proplist()) -> {'ok', kz_json:object()} | data_error(). ensure_saved(#{server := {App, Conn}}=Map, DbName, Doc, Options) -> @@ -100,7 +100,7 @@ maybe_ensure_saved_others(<<"_design", _/binary>>, Map, DbName, Doc, Options) -> maybe_ensure_saved_others(_, _, _, _, _) -> 'ok'. --spec del_doc(map(), ne_binary(), kz_json:object() | ne_binary(), kz_proplist()) -> +-spec del_doc(map(), kz_term:ne_binary(), kz_json:object() | kz_term:ne_binary(), kz_term:proplist()) -> {'ok', kz_json:object()} | data_error(). del_doc(Server, DbName, ?NE_BINARY=DocId, Options) -> @@ -122,7 +122,7 @@ del_doc(#{server := {App, Conn}}=Server, DbName, Doc, Options) -> failed end. --spec del_docs(map(), ne_binary(), kz_json:objects() | ne_binaries(), kz_proplist()) -> +-spec del_docs(map(), kz_term:ne_binary(), kz_json:objects() | kz_term:ne_binaries(), kz_term:proplist()) -> {'ok', kz_json:objects()} | data_error(). del_docs(#{server := {App, Conn}}=Server, DbName, Docs, Options) -> @@ -137,7 +137,7 @@ del_docs(#{server := {App, Conn}}=Server, DbName, Docs, Options) -> _Ex:Er -> {'error', {_Ex, Er}} end. --spec prepare_doc_for_del(map(), ne_binary(), kz_json:object() | ne_binary()) -> +-spec prepare_doc_for_del(map(), kz_term:ne_binary(), kz_json:object() | kz_term:ne_binary()) -> kz_json:object(). prepare_doc_for_del(Server, Db, ?NE_BINARY=DocId) -> prepare_doc_for_del(Server, Db, kz_json:from_list([{<<"_id">>, DocId}])); @@ -158,8 +158,8 @@ prepare_doc_for_del(Server, DbName, Doc) -> | kzs_publish:publish_fields(Doc) ]). --spec prepare_doc_for_save(ne_binary(), kz_json:object()) -> {kz_json:object(), kz_json:object()}. --spec prepare_doc_for_save(ne_binary(), kz_json:object(), boolean()) -> {kz_json:object(), kz_json:object()}. +-spec prepare_doc_for_save(kz_term:ne_binary(), kz_json:object()) -> {kz_json:object(), kz_json:object()}. +-spec prepare_doc_for_save(kz_term:ne_binary(), kz_json:object(), boolean()) -> {kz_json:object(), kz_json:object()}. prepare_doc_for_save(Db, JObj) -> Doc = kz_json:delete_key(<<"id">>, JObj), prepare_doc_for_save(Db, Doc, kz_term:is_empty(kz_doc:id(Doc))). @@ -198,14 +198,14 @@ maybe_set_docid(Doc) -> default_copy_function('true') -> fun ensure_saved/4; default_copy_function('false') -> fun save_doc/4. --spec copy_doc(map(), map(), copy_doc(), kz_proplist()) -> +-spec copy_doc(map(), map(), copy_doc(), kz_term:proplist()) -> {'ok', kz_json:object()} | data_error(). copy_doc(Src, Dst, CopySpec, Options) -> SaveFun = default_copy_function(props:is_defined(?COPY_DOC_OVERRIDE_PROPERTY, Options)), copy_doc(Src, Dst, CopySpec, SaveFun, props:delete(?COPY_DOC_OVERRIDE_PROPERTY, Options)). --spec copy_doc(map(), map(), copy_doc(), copy_function(), kz_proplist()) -> +-spec copy_doc(map(), map(), copy_doc(), copy_function(), kz_term:proplist()) -> {'ok', kz_json:object()} | data_error(). copy_doc(Src, Dst, CopySpec, CopyFun, Opts) -> @@ -238,7 +238,7 @@ copy_transform('undefined', _SourceDoc, DestinationDoc) -> copy_transform(Fun, SourceDoc, DestinationDoc) -> Fun(SourceDoc, DestinationDoc). --spec copy_attachments(map(), map(), copy_doc(), {kz_json:json_terms(), kz_json:path()}, ne_binary()) -> +-spec copy_attachments(map(), map(), copy_doc(), {kz_json:json_terms(), kz_json:path()}, kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. copy_attachments(_Src, Dst, CopySpec, {[], []}, _) -> @@ -268,12 +268,12 @@ copy_attachments(Src, Dst, CopySpec, {[JObj | JObjs], [Key | Keys]}, Rev) -> Error -> Error end. --spec maybe_set_account_db(api_binary(), ne_binary(), ne_binary()) -> kz_proplist(). +-spec maybe_set_account_db(kz_term:api_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:proplist(). maybe_set_account_db(DB, DB, DestDbName) -> [{<<"pvt_account_db">>, DestDbName}]; maybe_set_account_db(_1, _, _) -> []. --spec move_doc(map(), map(), copy_doc(), kz_proplist()) -> +-spec move_doc(map(), map(), copy_doc(), kz_term:proplist()) -> {'ok', kz_json:object()} | data_error(). move_doc(Src, Dst, CopySpec, Options) -> diff --git a/core/kazoo_data/src/kzs_plan.erl b/core/kazoo_data/src/kzs_plan.erl index 75606e44f39..82c105dba98 100644 --- a/core/kazoo_data/src/kzs_plan.erl +++ b/core/kazoo_data/src/kzs_plan.erl @@ -34,11 +34,11 @@ flush() -> plan() -> system_dataplan(). --spec plan(ne_binary()) -> map(). +-spec plan(kz_term:ne_binary()) -> map(). plan(DbName) -> get_dataplan(DbName). --spec plan(ne_binary(), atom() | ne_binary() | view_options() | kz_json:object()) -> map(). +-spec plan(kz_term:ne_binary(), atom() | kz_term:ne_binary() | view_options() | kz_json:object()) -> map(). plan(DbName, DocType) when is_binary(DocType) -> plan(DbName, DocType, 'undefined'); plan(DbName, Props) when is_list(Props) -> @@ -54,7 +54,7 @@ plan(DbName, DocType) when is_atom(DocType) -> plan(DbName, kz_term:to_binary(DocType)). --spec plan(ne_binary(), api_binary(), api_binary()) -> map(). +-spec plan(kz_term:ne_binary(), kz_term:api_binary(), kz_term:api_binary()) -> map(). plan(DbName, 'undefined', 'undefined') -> get_dataplan(DbName); plan(DbName, DocType, 'undefined') -> @@ -74,7 +74,7 @@ get_dataplan(DBName) -> Else -> system_dataplan(DBName, Else) end. --spec get_dataplan(ne_binary(), api_ne_binary()) -> map(). +-spec get_dataplan(kz_term:ne_binary(), kz_term:api_ne_binary()) -> map(). get_dataplan(DBName, 'undefined') -> get_dataplan(DBName); get_dataplan(DBName, DocType) -> @@ -155,7 +155,7 @@ dataplan_connections(Map, Index) -> || {_, #{<<"connection">> := C}} <- maps:to_list(Map) ]. --spec dataplan_match(ne_binary(), map(), api_binary()) -> map(). +-spec dataplan_match(kz_term:ne_binary(), map(), kz_term:api_binary()) -> map(). dataplan_match(Classification, Plan, AccountId) -> #{<<"plan">> := #{Classification := #{<<"connection">> := CCon ,<<"attachments">> := CAtt @@ -199,8 +199,8 @@ dataplan_match(Classification, Plan, AccountId) -> } end. --spec dataplan_type_match(ne_binary(), ne_binary(), map()) -> map(). --spec dataplan_type_match(ne_binary(), ne_binary(), map(), api_binary()) -> map(). +-spec dataplan_type_match(kz_term:ne_binary(), kz_term:ne_binary(), map()) -> map(). +-spec dataplan_type_match(kz_term:ne_binary(), kz_term:ne_binary(), map(), kz_term:api_binary()) -> map(). dataplan_type_match(Classification, DocType, Plan) -> dataplan_type_match(Classification, DocType, Plan, 'undefined'). @@ -252,11 +252,11 @@ att_post_handler(#{}) -> 'external'. -type fetch_dataplan_ret() :: {list(), kz_json:object()}. --spec fetch_simple_dataplan(ne_binary()) -> fetch_dataplan_ret(). +-spec fetch_simple_dataplan(kz_term:ne_binary()) -> fetch_dataplan_ret(). fetch_simple_dataplan(Id) -> {[Id], fetch_dataplan(Id)}. --spec fetch_account_dataplan(ne_binary()) -> fetch_dataplan_ret(). +-spec fetch_account_dataplan(kz_term:ne_binary()) -> fetch_dataplan_ret(). fetch_account_dataplan(AccountId) -> SystemJObj = fetch_dataplan(?SYSTEM_DATAPLAN), JObj = fetch_dataplan(AccountId), @@ -272,7 +272,7 @@ fetch_account_dataplan(AccountId) -> {Keys, MergedJObj} end. --spec fetch_storage_dataplan({ne_binary(), ne_binary()}) -> fetch_dataplan_ret(). +-spec fetch_storage_dataplan({kz_term:ne_binary(), kz_term:ne_binary()}) -> fetch_dataplan_ret(). fetch_storage_dataplan({AccountId, StorageId}) -> {Keys, AccountPlan} = fetch_account_dataplan(AccountId), MergedJObj = kz_json:merge_recursive(AccountPlan, fetch_dataplan(StorageId)), @@ -296,7 +296,7 @@ fetch_cached_dataplan(Key, Fun) -> Plan end. --spec fetch_dataplan(ne_binary()) -> kz_json:object(). +-spec fetch_dataplan(kz_term:ne_binary()) -> kz_json:object(). fetch_dataplan(Id) -> case kz_datamgr:open_cache_doc(?KZ_DATA_DB, Id, ['cache_failures']) of {'ok', JObj} -> JObj; @@ -307,7 +307,7 @@ fetch_dataplan(Id) -> {'error', _} -> kz_json:new() end. --spec fetch_dataplan_from_file(ne_binary()) -> kz_json:object(). +-spec fetch_dataplan_from_file(kz_term:ne_binary()) -> kz_json:object(). fetch_dataplan_from_file(Id) -> JObj = kz_json:load_fixture_from_file(?APP, ?DATAPLAN_FILE_LOCATION, [Id, ".json"]), _ = kzs_cache:add_to_doc_cache(?KZ_DATA_DB, Id, JObj), @@ -317,7 +317,7 @@ fetch_dataplan_from_file(Id) -> default_dataplan() -> fetch_dataplan_from_file(?SYSTEM_DATAPLAN). --spec maybe_start_connection(atom() | ne_binary(), map()) -> {atom(), server()}. +-spec maybe_start_connection(atom() | kz_term:ne_binary(), map()) -> {atom(), server()}. maybe_start_connection(Connection, Params) when is_binary(Connection) -> maybe_start_connection(kz_term:to_atom(Connection, 'true'), Params); diff --git a/core/kazoo_data/src/kzs_publish.erl b/core/kazoo_data/src/kzs_publish.erl index f8c11c3c0d3..315de4797b7 100644 --- a/core/kazoo_data/src/kzs_publish.erl +++ b/core/kazoo_data/src/kzs_publish.erl @@ -18,7 +18,7 @@ -include("kz_data.hrl"). -include_lib("kazoo_amqp/include/kapi_conf.hrl"). --spec maybe_publish_docs(ne_binary(), kz_json:objects(), kz_json:objects()) -> 'ok'. +-spec maybe_publish_docs(kz_term:ne_binary(), kz_json:objects(), kz_json:objects()) -> 'ok'. -ifdef(TEST). maybe_publish_docs(_, _, _) -> 'ok'. -else. @@ -28,7 +28,7 @@ maybe_publish_docs(Db, Docs, JObjs) -> andalso publish_docs(Db, Docs, JObjs), kzs_cache:flush_cache_docs(Db, JObjs). --spec publish_docs(ne_binary(), kz_json:objects(), kz_json:objects()) -> 'ok'. +-spec publish_docs(kz_term:ne_binary(), kz_json:objects(), kz_json:objects()) -> 'ok'. publish_docs(Db, Docs, JObjs) -> _ = kz_util:spawn( fun() -> @@ -40,7 +40,7 @@ publish_docs(Db, Docs, JObjs) -> 'ok'. -endif. --spec maybe_publish_doc(ne_binary(), kz_json:object(), kz_json:object()) -> 'ok'. +-spec maybe_publish_doc(kz_term:ne_binary(), kz_json:object(), kz_json:object()) -> 'ok'. -ifdef(TEST). maybe_publish_doc(_, _, _) -> 'ok'. -else. @@ -52,7 +52,7 @@ maybe_publish_doc(Db, Doc, JObj) -> kzs_cache:flush_cache_doc(Db, JObj). -endif. --spec publish_db(ne_binary(), kapi_conf:action()) -> boolean(). +-spec publish_db(kz_term:ne_binary(), kapi_conf:action()) -> boolean(). -ifdef(TEST). publish_db(_, _) -> 'true'. -else. @@ -69,13 +69,13 @@ should_publish_doc(Doc) -> _Else -> 'true' end. --spec should_publish_db_changes(ne_binary()) -> boolean(). +-spec should_publish_db_changes(kz_term:ne_binary()) -> boolean(). should_publish_db_changes(DbName) -> Key = <<"publish_", (kz_term:to_binary(kzs_util:db_classification(DbName)))/binary, "_changes">>, kazoo_data_config:get_is_true(Key, 'true'). -endif. --spec publish_doc(ne_binary(), kz_json:object(), kz_json:object()) -> 'ok'. +-spec publish_doc(kz_term:ne_binary(), kz_json:object(), kz_json:object()) -> 'ok'. publish_doc(DbName, Doc, JObj) -> case kz_doc:is_soft_deleted(Doc) orelse kz_doc:is_deleted(Doc) @@ -90,7 +90,7 @@ publish_doc(DbName, Doc, JObj) -> end. -ifndef(TEST). --spec do_publish_db(ne_binary(), kapi_conf:action()) -> 'ok'. +-spec do_publish_db(kz_term:ne_binary(), kapi_conf:action()) -> 'ok'. do_publish_db(DbName, Action) -> Props = [{<<"Type">>, 'database'} @@ -106,7 +106,7 @@ do_publish_db(DbName, Action) -> kz_amqp_worker:cast(Props, Fun). -endif. --spec publish_fields(kz_json:object()) -> kz_proplist(). +-spec publish_fields(kz_json:object()) -> kz_term:proplist(). -spec publish_fields(kz_json:object(), kz_json:object()) -> kz_json:object(). publish_fields(Doc) -> [{Key, V} || @@ -117,7 +117,7 @@ publish_fields(Doc) -> publish_fields(Doc, JObj) -> kz_json:set_values(publish_fields(Doc), JObj). --spec publish(kapi_conf:action(), ne_binary(), kz_json:object()) -> 'ok'. +-spec publish(kapi_conf:action(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. publish(Action, Db, Doc) -> Type = kz_doc:type(Doc), Id = kz_doc:id(Doc), @@ -146,20 +146,20 @@ publish(Action, Db, Doc) -> Fun = fun(P) -> kapi_conf:publish_doc_update(Action, Db, Type, Id, P) end, kz_amqp_worker:cast(Props, Fun). --spec doc_change_event_name(kapi_conf:action(), boolean()) -> ne_binary(). +-spec doc_change_event_name(kapi_conf:action(), boolean()) -> kz_term:ne_binary(). doc_change_event_name(_Action, 'true') -> ?DOC_DELETED; doc_change_event_name(Action, 'false') -> <<"doc_", (kz_term:to_binary(Action))/binary>>. --spec doc_acct_id(ne_binary(), kz_json:object()) -> ne_binary(). +-spec doc_acct_id(kz_term:ne_binary(), kz_json:object()) -> kz_term:ne_binary(). doc_acct_id(Db, Doc) -> case kz_doc:account_id(Doc) of ?MATCH_ACCOUNT_RAW(AccountId) -> AccountId; _ -> maybe_account_id_from_db(kzs_util:db_classification(Db), Db) end. --spec maybe_account_id_from_db(atom(), ne_binary()) -> api_binary(). +-spec maybe_account_id_from_db(atom(), kz_term:ne_binary()) -> kz_term:api_binary(). maybe_account_id_from_db('account', Db) -> kz_util:format_account_id(Db); maybe_account_id_from_db('modb', Db) -> diff --git a/core/kazoo_data/src/kzs_server.erl b/core/kazoo_data/src/kzs_server.erl index afd086c9d3f..0b20d68457f 100644 --- a/core/kazoo_data/src/kzs_server.erl +++ b/core/kazoo_data/src/kzs_server.erl @@ -22,15 +22,15 @@ server_info(#{server := {App, Conn}}) -> App:server_info(Conn); server_info({App, Conn}) -> App:server_info(Conn). --spec server_url(map() | server()) -> ne_binary(). +-spec server_url(map() | server()) -> kz_term:ne_binary(). server_url(#{server := {App, Conn}}) -> App:server_url(Conn); server_url({App, Conn}) -> App:server_url(Conn). --spec db_url(map() | server(), ne_binary()) -> ne_binary(). +-spec db_url(map() | server(), kz_term:ne_binary()) -> kz_term:ne_binary(). db_url(#{server := {App, Conn}}, DbName) -> App:db_url(Conn, DbName); db_url({App, Conn}, DbName) -> App:db_url(Conn, DbName). --spec get_db(map() | server(), ne_binary()) -> db(). +-spec get_db(map() | server(), kz_term:ne_binary()) -> db(). get_db(#{server := {App, Conn}}, DbName) -> Db = App:get_db(Conn, DbName), #db{app=App, server=Conn, db=Db, name=DbName}; diff --git a/core/kazoo_data/src/kzs_util.erl b/core/kazoo_data/src/kzs_util.erl index 99c2c648bc7..64a130c7cda 100644 --- a/core/kazoo_data/src/kzs_util.erl +++ b/core/kazoo_data/src/kzs_util.erl @@ -22,7 +22,7 @@ %% @doc %% @end %%------------------------------------------------------------------------------ --spec db_classification(text()) -> db_classification(). +-spec db_classification(kz_term:text()) -> db_classification(). db_classification(Db) when not is_binary(Db) -> db_classification(kz_term:to_binary(Db)); db_classification(<<"_users">>) -> 'external'; @@ -93,7 +93,7 @@ db_classification(_Database) -> %% @doc %% @end %%------------------------------------------------------------------------------ --spec db_priority(text()) -> non_neg_integer(). +-spec db_priority(kz_term:text()) -> non_neg_integer(). db_priority(Db) when not is_binary(Db) -> db_priority(kz_term:to_binary(Db)); db_priority(?KZ_CONFIG_DB) -> 0; @@ -143,12 +143,12 @@ get_views_json(App, Folder) -> {?NE_BINARY,_}=ViewListing <- [catch get_view_json(File)] ]. --spec get_view_json(atom(), text()) -> kz_datamgr:view_listing(). +-spec get_view_json(atom(), kz_term:text()) -> kz_datamgr:view_listing(). get_view_json(App, File) -> Path = filename:join([code:priv_dir(App), "couchdb", File]), get_view_json(Path). --spec get_view_json(text()) -> kz_datamgr:view_listing(). +-spec get_view_json(kz_term:text()) -> kz_datamgr:view_listing(). get_view_json(Path) -> lager:debug("fetching view from ~s", [Path]), {'ok', Bin} = file:read_file(Path), diff --git a/core/kazoo_data/src/kzs_view.erl b/core/kazoo_data/src/kzs_view.erl index 4bfa163347a..0fb99b228ba 100644 --- a/core/kazoo_data/src/kzs_view.erl +++ b/core/kazoo_data/src/kzs_view.erl @@ -21,25 +21,25 @@ -include("kz_data.hrl"). %%% View-related functions ----------------------------------------------------- --spec design_compact(map(), ne_binary(), ne_binary()) -> boolean(). +-spec design_compact(map(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). design_compact(#{server := {App, Conn}}, DbName, Design) -> App:design_compact(Conn, DbName, Design). --spec design_info(map(), ne_binary(), ne_binary()) -> {'ok', kz_json:object()} | data_error(). +-spec design_info(map(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | data_error(). design_info(#{server := {App, Conn}}, DBName, Design) -> App:design_info(Conn, DBName, Design). --spec all_design_docs(map(), ne_binary(), view_options()) -> +-spec all_design_docs(map(), kz_term:ne_binary(), view_options()) -> {'ok', kz_json:objects()} | data_error(). all_design_docs(#{server := {App, Conn}}, DBName, Options) -> App:all_design_docs(Conn, DBName, Options). --spec all_docs(map(), ne_binary(), view_options()) -> +-spec all_docs(map(), kz_term:ne_binary(), view_options()) -> {'ok', kz_json:objects()} | data_error(). all_docs(#{server := {App, Conn}}, DbName, Options) -> App:all_docs(Conn, DbName, Options). --spec get_results(map(), ne_binary(), ne_binary(), view_options()) -> +-spec get_results(map(), kz_term:ne_binary(), kz_term:ne_binary(), view_options()) -> {'ok', kz_json:objects() | kz_json:path()} | data_error(). get_results(#{server := {App, Conn}}, DbName, DesignDoc, ViewOptions) -> @@ -49,13 +49,13 @@ get_results(#{server := {App, Conn}}, DbName, DesignDoc, ViewOptions) -> %% Need to see how to get couchbeam to return the "rows" property instead of the result %% list; that would be better, but for not, setting the view's "reduce" to the _count %% function will suffice (provided a reduce isn't already defined). --spec get_results_count(map(), ne_binary(), ne_binary(), view_options()) -> +-spec get_results_count(map(), kz_term:ne_binary(), kz_term:ne_binary(), view_options()) -> {'ok', integer()} | data_error(). get_results_count(#{server := {App, Conn}}, DbName, DesignDoc, ViewOptions) -> App:get_results_count(Conn, DbName, DesignDoc, ViewOptions). --spec doc_type_from_view(ne_binary(), ne_binary()) -> ne_binary(). +-spec doc_type_from_view(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). doc_type_from_view(<<"faxes">>, _ViewName) -> <<"fax">>; doc_type_from_view(<<"cdrs">>, _ViewName) -> <<"cdr">>; doc_type_from_view(<<"recordings">>, _ViewName) -> <<"call_recording">>; diff --git a/core/kazoo_documents/src/kz_account.erl b/core/kazoo_documents/src/kz_account.erl index 1273511d684..d416035be1e 100644 --- a/core/kazoo_documents/src/kz_account.erl +++ b/core/kazoo_documents/src/kz_account.erl @@ -84,11 +84,11 @@ -type doc() :: kz_json:object(). -export_type([doc/0]). --spec get_inherited_value(api_binary(), fun()) -> any(). +-spec get_inherited_value(kz_term:api_binary(), fun()) -> any(). get_inherited_value(Account, ValueFun) -> get_inherited_value(Account, ValueFun, 'undefined'). --spec get_inherited_value(api_binary(), fun(), any()) -> any(). +-spec get_inherited_value(kz_term:api_binary(), fun(), any()) -> any(). get_inherited_value('undefined', _ValueFun, Default) -> Default; @@ -99,14 +99,14 @@ get_inherited_value(Account, ValueFun, Default) -> Value -> Value end. --spec check_account(api_binary(), fun()) -> any(). +-spec check_account(kz_term:api_binary(), fun()) -> any(). check_account(Account, ValueFun) -> case fetch(Account) of {'error', _Err} -> 'undefined'; {'ok', JObj} -> ValueFun(JObj) end. --spec check_reseller(api_binary(), fun(), any()) -> any(). +-spec check_reseller(kz_term:api_binary(), fun(), any()) -> any(). check_reseller(Account, ValueFun, Default) -> Reseller = kz_services:find_reseller_id(Account), case check_account(Reseller, ValueFun) of @@ -128,7 +128,7 @@ new() -> %% @doc %% @end %%-------------------------------------------------------------------- --spec type() -> ne_binary(). +-spec type() -> kz_term:ne_binary(). type() -> <<"account">>. %%-------------------------------------------------------------------- @@ -136,7 +136,7 @@ type() -> <<"account">>. %% @doc %% @end %%-------------------------------------------------------------------- --spec id(doc()) -> api_binary(). +-spec id(doc()) -> kz_term:api_binary(). id(JObj) -> kz_doc:id(JObj). @@ -145,15 +145,15 @@ id(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec fetch(api_ne_binary()) -> {'ok', doc()} | - {'error', any()}. +-spec fetch(kz_term:api_ne_binary()) -> {'ok', doc()} | + {'error', any()}. fetch('undefined') -> {'error', 'invalid_db_name'}; fetch(Account=?NE_BINARY) -> fetch(Account, 'account'). --spec fetch(api_ne_binary(), 'account' | 'accounts') -> {'ok', doc()} | - {'error', any()}. +-spec fetch(kz_term:api_ne_binary(), 'account' | 'accounts') -> {'ok', doc()} | + {'error', any()}. fetch('undefined', _) -> {'error', 'invalid_db_name'}; fetch(Account, 'account') -> @@ -163,7 +163,7 @@ fetch(Account, 'account') -> fetch(AccountId, 'accounts') -> open_cache_doc(?KZ_ACCOUNTS_DB, AccountId). --spec open_cache_doc(ne_binary(), ne_binary()) -> {'ok', doc()} | {'error', any()}. +-spec open_cache_doc(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', doc()} | {'error', any()}. open_cache_doc(Db, AccountId) -> kz_datamgr:open_cache_doc(Db, AccountId, [{cache_failures,false}]). @@ -172,7 +172,7 @@ open_cache_doc(Db, AccountId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec fetch_name(ne_binary()) -> api_ne_binary(). +-spec fetch_name(kz_term:ne_binary()) -> kz_term:api_ne_binary(). fetch_name(Account) -> case fetch(Account) of {ok, JObj} -> name(JObj); @@ -181,8 +181,8 @@ fetch_name(Account) -> undefined end. --spec name(doc()) -> api_ne_binary(). --spec name(doc(), Default) -> ne_binary() | Default. +-spec name(doc()) -> kz_term:api_ne_binary(). +-spec name(doc(), Default) -> kz_term:ne_binary() | Default. name(JObj) -> name(JObj, 'undefined'). name(JObj, Default) -> @@ -193,7 +193,7 @@ name(JObj, Default) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec set_name(doc(), ne_binary()) -> doc(). +-spec set_name(doc(), kz_term:ne_binary()) -> doc(). set_name(JObj, Name) -> kz_json:set_value(?NAME, Name, JObj). @@ -202,7 +202,7 @@ set_name(JObj, Name) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec fetch_realm(ne_binary()) -> api_ne_binary(). +-spec fetch_realm(kz_term:ne_binary()) -> kz_term:api_ne_binary(). fetch_realm(Account) -> case fetch(Account) of {ok, JObj} -> realm(JObj); @@ -216,8 +216,8 @@ fetch_realm(Account) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec realm(doc()) -> api_ne_binary(). --spec realm(doc(), Default) -> ne_binary() | Default. +-spec realm(doc()) -> kz_term:api_ne_binary(). +-spec realm(doc(), Default) -> kz_term:ne_binary() | Default. realm(JObj) -> realm(JObj, 'undefined'). realm(JObj, Default) -> @@ -228,7 +228,7 @@ realm(JObj, Default) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec set_realm(doc(), ne_binary()) -> doc(). +-spec set_realm(doc(), kz_term:ne_binary()) -> doc(). set_realm(JObj, Realm) -> kz_json:set_value(?REALM, Realm, JObj). @@ -237,8 +237,8 @@ set_realm(JObj, Realm) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec language(doc()) -> api_ne_binary(). --spec language(doc(), Default) -> ne_binary() | Default. +-spec language(doc()) -> kz_term:api_ne_binary(). +-spec language(doc(), Default) -> kz_term:ne_binary() | Default. language(JObj) -> language(JObj, 'undefined'). language(JObj, Default) -> @@ -249,7 +249,7 @@ language(JObj, Default) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec set_language(doc(), ne_binary()) -> doc(). +-spec set_language(doc(), kz_term:ne_binary()) -> doc(). set_language(JObj, Language) -> kz_json:set_value(?LANGUAGE, Language, JObj). @@ -258,7 +258,7 @@ set_language(JObj, Language) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec timezone(api_ne_binary() | doc()) -> ne_binary(). +-spec timezone(kz_term:api_ne_binary() | doc()) -> kz_term:ne_binary(). timezone('undefined') -> default_timezone(); timezone(AccountId) when is_binary(AccountId) -> case fetch(AccountId) of @@ -270,7 +270,7 @@ timezone(AccountId) when is_binary(AccountId) -> timezone(JObj) -> timezone(JObj, 'undefined'). --spec timezone(api_ne_binary() | doc(), Default) -> ne_binary() | Default. +-spec timezone(kz_term:api_ne_binary() | doc(), Default) -> kz_term:ne_binary() | Default. timezone('undefined', 'undefined') -> default_timezone(); timezone('undefined', <<"inherit">>) -> %% UI-1808 @@ -294,12 +294,12 @@ timezone(JObj, Default) -> TZ -> TZ end. --spec parent_timezone(ne_binary(), api_ne_binary()) -> ne_binary(). +-spec parent_timezone(kz_term:ne_binary(), kz_term:api_ne_binary()) -> kz_term:ne_binary(). parent_timezone(AccountId, AccountId) -> default_timezone(); parent_timezone(_AccountId, 'undefined') -> default_timezone(); parent_timezone(_AccountId, ParentId) -> timezone(ParentId). --spec default_timezone() -> ne_binary(). +-spec default_timezone() -> kz_term:ne_binary(). default_timezone() -> kapps_config:get_ne_binary(<<"accounts">>, <<"default_timezone">>, <<"America/Los_Angeles">>). @@ -308,11 +308,11 @@ default_timezone() -> %% @doc %% @end %%-------------------------------------------------------------------- --spec set_timezone(doc(), ne_binary()) -> doc(). +-spec set_timezone(doc(), kz_term:ne_binary()) -> doc(). set_timezone(JObj, Timezone) -> kz_json:set_value(?TIMEZONE, Timezone, JObj). --spec home_zone(ne_binary() | doc()) -> api_binary(). +-spec home_zone(kz_term:ne_binary() | doc()) -> kz_term:api_binary(). home_zone(AccountId) when is_binary(AccountId) -> case fetch(AccountId) of {'error', _R} -> 'undefined'; @@ -322,7 +322,7 @@ home_zone(AccountId) when is_binary(AccountId) -> home_zone(JObj) -> home_zone(JObj, 'undefined'). --spec home_zone(ne_binary() | doc(), api_binary()) -> api_binary(). +-spec home_zone(kz_term:ne_binary() | doc(), kz_term:api_binary()) -> kz_term:api_binary(). home_zone(AccountId, Default) when is_binary(AccountId) -> case fetch(AccountId) of {'error', _R} -> Default; @@ -332,7 +332,7 @@ home_zone(AccountId, Default) when is_binary(AccountId) -> home_zone(JObj, Default) -> kz_json:get_value(?HOME_ZONE, JObj, Default). --spec set_home_zone(doc(), api_binary()) -> doc(). +-spec set_home_zone(doc(), kz_term:api_binary()) -> doc(). set_home_zone(JObj, Zone) -> kz_json:set_value(?HOME_ZONE, Zone, JObj). @@ -341,12 +341,12 @@ set_home_zone(JObj, Zone) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec low_balance_threshold(ne_binary() | doc()) -> api_float(). +-spec low_balance_threshold(kz_term:ne_binary() | doc()) -> kz_term:api_float(). low_balance_threshold(Thing) -> Default = kapps_config:get_float(<<"notify.low_balance">>, <<"threshold">>, 5.00), low_balance_threshold(Thing, Default). --spec low_balance_threshold(ne_binary() | doc(), Default) -> float() | Default. +-spec low_balance_threshold(kz_term:ne_binary() | doc(), Default) -> float() | Default. low_balance_threshold(AccountId, Default) when is_binary(AccountId) -> case fetch(AccountId) of {'error', _R} -> low_balance_threshold(kz_json:new(), Default); @@ -405,7 +405,7 @@ low_balance_enabled_exists(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec low_balance_tstamp(doc()) -> api_number(). +-spec low_balance_tstamp(doc()) -> kz_term:api_number(). low_balance_tstamp(JObj) -> kz_json:get_integer_value(?LOW_BALANCE_TSTAMP, JObj). @@ -427,7 +427,7 @@ remove_low_balance_tstamp(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec topup_threshold(doc()) -> api_float(). +-spec topup_threshold(doc()) -> kz_term:api_float(). topup_threshold(JObj) -> topup_threshold(JObj, 'undefined'). @@ -471,7 +471,7 @@ set_initial_call_sent(JObj, Sent) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec parent_account_id(doc()) -> api_binary(). +-spec parent_account_id(doc()) -> kz_term:api_binary(). parent_account_id(JObj) -> case tree(JObj) of [] -> 'undefined'; @@ -483,7 +483,7 @@ parent_account_id(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_parent_account(ne_binary()) -> {'ok', doc()} | {'error', any()}. +-spec get_parent_account(kz_term:ne_binary()) -> {'ok', doc()} | {'error', any()}. get_parent_account(AccountId) -> case get_parent_account_id(AccountId) of 'undefined' -> {'error', 'not_found'}; @@ -496,7 +496,7 @@ get_parent_account(AccountId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_parent_account_id(ne_binary()) -> api_binary(). +-spec get_parent_account_id(kz_term:ne_binary()) -> kz_term:api_binary(). get_parent_account_id(AccountId) -> case fetch(AccountId) of {'ok', JObj} -> parent_account_id(JObj); @@ -510,8 +510,8 @@ get_parent_account_id(AccountId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec tree(doc()) -> ne_binaries(). --spec tree(doc(), Default) -> ne_binaries() | Default. +-spec tree(doc()) -> kz_term:ne_binaries(). +-spec tree(doc(), Default) -> kz_term:ne_binaries() | Default. tree(JObj) -> tree(JObj, []). tree(JObj, Default) -> @@ -522,7 +522,7 @@ tree(JObj, Default) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec set_tree(doc(), ne_binaries()) -> doc(). +-spec set_tree(doc(), kz_term:ne_binaries()) -> doc(). set_tree(JObj, Tree) -> kz_json:set_value(?TREE, Tree, JObj). @@ -531,7 +531,7 @@ set_tree(JObj, Tree) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec notification_preference(doc()) -> api_binary(). +-spec notification_preference(doc()) -> kz_term:api_binary(). notification_preference(JObj) -> Pref = notification_preference(JObj, [ ?NOTIFY_PREF @@ -545,7 +545,7 @@ notification_preference(JObj) -> _Default -> <<"notify">> end. --spec notification_preference(doc(), list()) -> api_binary(). +-spec notification_preference(doc(), list()) -> kz_term:api_binary(). notification_preference(_JObj, []) -> 'undefined'; @@ -562,7 +562,7 @@ notification_preference(JObj, [H|T]) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec set_notification_preference(doc(), ne_binary()) -> doc(). +-spec set_notification_preference(doc(), kz_term:ne_binary()) -> doc(). set_notification_preference(JObj, Pref) -> kz_json:set_value(?NOTIFY_PREF, Pref, JObj). @@ -598,7 +598,7 @@ disable(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec api_key(doc()) -> api_binary(). +-spec api_key(doc()) -> kz_term:api_binary(). api_key(JObj) -> kz_json:get_value(?API_KEY, JObj). @@ -607,7 +607,7 @@ api_key(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec set_api_key(doc(), ne_binary()) -> doc(). +-spec set_api_key(doc(), kz_term:ne_binary()) -> doc(). set_api_key(JObj, ApiKey) -> kz_json:set_value(?API_KEY, ApiKey, JObj). @@ -642,7 +642,7 @@ allow_number_additions(JObj) -> set_allow_number_additions(JObj, IsAllowed) -> kz_json:set_value(?ALLOW_NUMBER_ADDITIONS, kz_term:is_true(IsAllowed), JObj). --spec trial_expiration(doc()) -> api_integer(). +-spec trial_expiration(doc()) -> kz_term:api_integer(). -spec trial_expiration(doc(), Default) -> integer() | Default. trial_expiration(JObj) -> trial_expiration(JObj, 'undefined'). @@ -655,7 +655,7 @@ trial_expiration(JObj, Default) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec set_trial_expiration(doc(), gregorian_seconds()) -> doc(). +-spec set_trial_expiration(doc(), kz_time:gregorian_seconds()) -> doc(). set_trial_expiration(JObj, Expiration) -> JObj1 = kz_json:delete_key(?KEY_TRIAL_ACCOUNT, JObj), kz_json:set_value(?KEY_TRIAL_EXPIRATION, Expiration, JObj1). @@ -666,7 +666,7 @@ set_trial_expiration(JObj, Expiration) -> %% @end %%-------------------------------------------------------------------- -spec trial_time_left(doc()) -> integer(). --spec trial_time_left(doc(), gregorian_seconds()) -> integer(). +-spec trial_time_left(doc(), kz_time:gregorian_seconds()) -> integer(). trial_time_left(JObj) -> trial_time_left(JObj, kz_time:now_s()). trial_time_left(JObj, Now) -> @@ -681,7 +681,7 @@ trial_time_left(JObj, Now) -> %% @end %%-------------------------------------------------------------------- -spec trial_has_expired(doc()) -> boolean(). --spec trial_has_expired(doc(), gregorian_seconds()) -> boolean(). +-spec trial_has_expired(doc(), kz_time:gregorian_seconds()) -> boolean(). trial_has_expired(JObj) -> trial_has_expired(JObj, kz_time:now_s()). trial_has_expired(JObj, Now) -> @@ -693,7 +693,7 @@ trial_has_expired(JObj, Now) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec is_expired(doc()) -> 'false' | {'true', gregorian_seconds()}. +-spec is_expired(doc()) -> 'false' | {'true', kz_time:gregorian_seconds()}. is_expired(JObj) -> case trial_has_expired(JObj) of 'false' -> 'false'; @@ -751,7 +751,7 @@ reseller_id(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec set_reseller_id(doc(), ne_binary()) -> doc(). +-spec set_reseller_id(doc(), kz_term:ne_binary()) -> doc(). set_reseller_id(JObj, ResellerId) -> kz_json:set_value(?RESELLER_ID, ResellerId, JObj). @@ -760,14 +760,14 @@ set_reseller_id(JObj, ResellerId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec dial_plan(doc()) -> api_object(). +-spec dial_plan(doc()) -> kz_term:api_object(). -spec dial_plan(doc(), Default) -> kz_json:object() | Default. dial_plan(JObj) -> dial_plan(JObj, 'undefined'). dial_plan(JObj, Default) -> kz_json:get_json_value(?KEY_DIAL_PLAN, JObj, Default). --spec fax_settings(doc() | ne_binary()) -> doc(). +-spec fax_settings(doc() | kz_term:ne_binary()) -> doc(). fax_settings(AccountId) when is_binary(AccountId) -> case fetch(AccountId) of @@ -781,8 +781,8 @@ fax_settings(JObj) -> _ -> FaxSettings end. --spec preflow_id(doc()) -> api_ne_binary(). --spec preflow_id(doc(), Default) -> ne_binary() | Default. +-spec preflow_id(doc()) -> kz_term:api_ne_binary(). +-spec preflow_id(doc(), Default) -> kz_term:ne_binary() | Default. preflow_id(Doc) -> preflow_id(Doc, 'undefined'). diff --git a/core/kazoo_documents/src/kz_attachment.erl b/core/kazoo_documents/src/kz_attachment.erl index aeb9d3cda2e..7858faa2233 100644 --- a/core/kazoo_documents/src/kz_attachment.erl +++ b/core/kazoo_documents/src/kz_attachment.erl @@ -17,7 +17,7 @@ %% @doc %% @end %%-------------------------------------------------------------------- --spec decode_base64(ne_binary()) -> {api_binary(), ne_binary()}. +-spec decode_base64(kz_term:ne_binary()) -> {kz_term:api_binary(), kz_term:ne_binary()}. decode_base64(Base64) -> case binary:split(Base64, <<",">>) of %% http://tools.ietf.org/html/rfc4648 @@ -30,7 +30,7 @@ decode_base64(Base64) -> {'undefined', corrected_base64_decode(Base64)} end. --spec get_content_type(ne_binary()) -> api_binary(). +-spec get_content_type(kz_term:ne_binary()) -> kz_term:api_binary(). get_content_type(MediaType) -> get_content_type(MediaType, kz_binary:truncate_left(MediaType, 6)). @@ -46,7 +46,7 @@ get_content_type(MediaType, _) -> {'error', 'badarg'} end. --spec corrected_base64_decode(ne_binary()) -> ne_binary(). +-spec corrected_base64_decode(kz_term:ne_binary()) -> kz_term:ne_binary(). corrected_base64_decode(Base64) when byte_size(Base64) rem 4 =:= 3 -> base64:decode(<>, JObj, Default). --spec call_id(doc()) -> api_binary(). +-spec call_id(doc()) -> kz_term:api_binary(). call_id(JObj) -> kz_json:get_ne_binary_value(<<"Call-ID">>, JObj). --spec other_leg_call_id(doc()) -> api_binary(). +-spec other_leg_call_id(doc()) -> kz_term:api_binary(). other_leg_call_id(JObj) -> kz_json:get_ne_binary_value(<<"Other-Leg-Call-ID">>, JObj). --spec other_leg_destination_number(doc()) -> api_binary(). --spec other_leg_destination_number(doc(), Default) -> ne_binary() | Default. +-spec other_leg_destination_number(doc()) -> kz_term:api_binary(). +-spec other_leg_destination_number(doc(), Default) -> kz_term:ne_binary() | Default. other_leg_destination_number(JObj) -> other_leg_destination_number(JObj, 'undefined'). other_leg_destination_number(JObj, Default) -> kz_json:get_ne_binary_value(<<"Other-Leg-Destination-Number">>, JObj, Default). --spec replaced_by(doc()) -> api_binary(). +-spec replaced_by(doc()) -> kz_term:api_binary(). replaced_by(JObj) -> kz_json:get_ne_binary_value(<<"Replaced-By">>, JObj). --spec channel_name(doc()) -> api_ne_binary(). +-spec channel_name(doc()) -> kz_term:api_ne_binary(). channel_name(JObj) -> kz_json:get_ne_binary_value(<<"Channel-Name">>, JObj). --spec custom_channel_vars(doc()) -> api_object(). +-spec custom_channel_vars(doc()) -> kz_term:api_object(). -spec custom_channel_vars(doc(), Default) -> kz_json:object() | Default. custom_channel_vars(JObj) -> custom_channel_vars(JObj, 'undefined'). @@ -91,16 +91,16 @@ custom_channel_vars(JObj, Default) -> kz_json:get_json_value(<<"Custom-Channel-Vars">>, JObj, Default). -spec custom_channel_var(doc(), kz_json:path()) -> - api_binary(). + kz_term:api_binary(). -spec custom_channel_var(doc(), kz_json:path(), Default) -> - ne_binary() | Default. + kz_term:ne_binary() | Default. custom_channel_var(JObj, Key) -> custom_channel_var(JObj, Key, 'undefined'). custom_channel_var(JObj, Key, Default) -> kz_json:get_ne_binary_value([<<"Custom-Channel-Vars">>, Key], JObj, Default). --spec custom_application_vars(doc()) -> api_object(). +-spec custom_application_vars(doc()) -> kz_term:api_object(). -spec custom_application_vars(doc(), Default) -> kz_json:object() | Default. custom_application_vars(JObj) -> custom_application_vars(JObj, 'undefined'). @@ -109,24 +109,24 @@ custom_application_vars(JObj, Default) -> kz_json:get_json_value(<<"Custom-Application-Vars">>, JObj, Default). -spec custom_application_var(doc(), kz_json:path()) -> - api_binary(). + kz_term:api_binary(). -spec custom_application_var(doc(), kz_json:path(), Default) -> - ne_binary() | Default. + kz_term:ne_binary() | Default. custom_application_var(JObj, Key) -> custom_application_var(JObj, Key, 'undefined'). custom_application_var(JObj, Key, Default) -> kz_json:get_ne_binary_value([<<"Custom-Application-Vars">>, Key], JObj, Default). --spec custom_sip_headers(doc()) -> api_object(). +-spec custom_sip_headers(doc()) -> kz_term:api_object(). custom_sip_headers(JObj) -> kz_json:get_json_value(<<"Custom-SIP-Headers">>, JObj). --spec authorizing_id(doc()) -> api_binary(). +-spec authorizing_id(doc()) -> kz_term:api_binary(). authorizing_id(JObj) -> custom_channel_var(JObj, <<"Authorizing-ID">>). --spec authorizing_type(doc()) -> api_binary(). +-spec authorizing_type(doc()) -> kz_term:api_binary(). authorizing_type(JObj) -> custom_channel_var(JObj, <<"Authorizing-Type">>). @@ -136,34 +136,34 @@ is_authorized(JObj) -> custom_channel_var(JObj, <<"Channel-Authorized">>) ). --spec dtmf_digit(doc()) -> api_binary(). +-spec dtmf_digit(doc()) -> kz_term:api_binary(). dtmf_digit(JObj) -> kz_json:get_ne_binary_value(<<"DTMF-Digit">>, JObj). --spec event_name(doc()) -> api_binary(). +-spec event_name(doc()) -> kz_term:api_binary(). event_name(JObj) -> kz_json:get_ne_binary_value(<<"Event-Name">>, JObj). --spec hangup_cause(doc()) -> api_binary(). --spec hangup_cause(doc(), Default) -> ne_binary() | Default. +-spec hangup_cause(doc()) -> kz_term:api_binary(). +-spec hangup_cause(doc(), Default) -> kz_term:ne_binary() | Default. hangup_cause(JObj) -> hangup_cause(JObj, 'undefined'). hangup_cause(JObj, Default) -> kz_json:get_ne_binary_value(<<"Hangup-Cause">>, JObj, Default). --spec hangup_code(doc()) -> api_binary(). +-spec hangup_code(doc()) -> kz_term:api_binary(). hangup_code(JObj) -> kz_json:get_ne_binary_value(<<"Hangup-Code">>, JObj). --spec disposition(doc()) -> api_binary(). +-spec disposition(doc()) -> kz_term:api_binary(). disposition(JObj) -> kz_json:get_ne_binary_value(<<"Disposition">>, JObj). --spec application_name(doc()) -> api_binary(). +-spec application_name(doc()) -> kz_term:api_binary(). application_name(JObj) -> kz_json:get_ne_binary_value(<<"Application-Name">>, JObj). --spec application_event(doc()) -> api_binary(). +-spec application_event(doc()) -> kz_term:api_binary(). application_event(JObj) -> kz_json:get_ne_binary_value(<<"Application-Event">>, JObj). @@ -171,46 +171,46 @@ application_event(JObj) -> application_data(JObj) -> kz_json:get_json_value(<<"Application-Data">>, JObj, kz_json:new()). --spec application_response(doc()) -> api_binary(). +-spec application_response(doc()) -> kz_term:api_binary(). application_response(JObj) -> kz_json:get_ne_binary_value(<<"Application-Response">>, JObj). --spec response_message(doc()) -> api_binary(). +-spec response_message(doc()) -> kz_term:api_binary(). response_message(JObj) -> kz_json:get_ne_binary_value(<<"Response-Message">>, JObj). --spec response_code(doc()) -> api_binary(). +-spec response_code(doc()) -> kz_term:api_binary(). response_code(JObj) -> kz_json:get_ne_binary_value(<<"Response-Code">>, JObj). --spec account_id(doc()) -> api_binary(). --spec account_id(doc(), Default) -> ne_binary() | Default. +-spec account_id(doc()) -> kz_term:api_binary(). +-spec account_id(doc(), Default) -> kz_term:ne_binary() | Default. account_id(JObj) -> account_id(JObj, 'undefined'). account_id(JObj, Default) -> custom_channel_var(JObj, <<"Account-ID">>, Default). --spec owner_id(doc()) -> api_binary(). +-spec owner_id(doc()) -> kz_term:api_binary(). owner_id(JObj) -> custom_channel_var(JObj, <<"Owner-ID">>). --spec timestamp(doc()) -> api_integer(). +-spec timestamp(doc()) -> kz_term:api_integer(). timestamp(JObj) -> kz_json:get_integer_value(<<"Timestamp">>, JObj). --spec ringing_seconds(doc()) -> api_integer(). +-spec ringing_seconds(doc()) -> kz_term:api_integer(). ringing_seconds(JObj) -> kz_json:get_integer_value(<<"Ringing-Seconds">>, JObj). --spec billing_seconds(doc()) -> api_integer(). +-spec billing_seconds(doc()) -> kz_term:api_integer(). billing_seconds(JObj) -> kz_json:get_integer_value(<<"Billing-Seconds">>, JObj). --spec duration_seconds(doc()) -> api_integer(). +-spec duration_seconds(doc()) -> kz_term:api_integer(). duration_seconds(JObj) -> kz_json:get_integer_value(<<"Duration-Seconds">>, JObj). --spec is_call_forwarded(doc()) -> api_boolean(). +-spec is_call_forwarded(doc()) -> kz_term:api_boolean(). -spec is_call_forwarded(doc(), Default) -> boolean() | Default. is_call_forwarded(JObj) -> is_call_forwarded(JObj, 'undefined'). @@ -221,38 +221,38 @@ is_call_forwarded(JObj, Default) -> IsForwarded -> kz_term:is_true(IsForwarded) end. --spec error_message(doc()) -> api_ne_binary(). +-spec error_message(doc()) -> kz_term:api_ne_binary(). error_message(JObj) -> kz_json:get_ne_binary_value(<<"Error-Message">>, JObj). --spec switch_nodename(doc()) -> api_ne_binary(). +-spec switch_nodename(doc()) -> kz_term:api_ne_binary(). switch_nodename(JObj) -> kz_json:get_ne_binary_value(<<"Switch-Nodename">>, JObj). --spec caller_id_name(doc()) -> api_ne_binary(). +-spec caller_id_name(doc()) -> kz_term:api_ne_binary(). caller_id_name(JObj) -> kz_json:get_ne_binary_value(<<"Caller-ID-Name">>, JObj). --spec caller_id_number(doc()) -> api_ne_binary(). +-spec caller_id_number(doc()) -> kz_term:api_ne_binary(). caller_id_number(JObj) -> kz_json:get_ne_binary_value(<<"Caller-ID-Number">>, JObj). --spec callee_id_name(doc()) -> api_ne_binary(). +-spec callee_id_name(doc()) -> kz_term:api_ne_binary(). callee_id_name(JObj) -> kz_json:get_ne_binary_value(<<"Callee-ID-Name">>, JObj). --spec callee_id_number(doc()) -> api_ne_binary(). +-spec callee_id_number(doc()) -> kz_term:api_ne_binary(). callee_id_number(JObj) -> kz_json:get_ne_binary_value(<<"Callee-ID-Number">>, JObj). --spec caller_id(doc()) -> {api_ne_binary(), api_ne_binary()}. +-spec caller_id(doc()) -> {kz_term:api_ne_binary(), kz_term:api_ne_binary()}. caller_id(JObj) -> {caller_id_number(JObj), caller_id_name(JObj)}. --spec callee_id(doc()) -> {api_ne_binary(), api_ne_binary()}. +-spec callee_id(doc()) -> {kz_term:api_ne_binary(), kz_term:api_ne_binary()}. callee_id(JObj) -> {callee_id_number(JObj), callee_id_name(JObj)}. --spec recording_length(doc()) -> api_integer(). +-spec recording_length(doc()) -> kz_term:api_integer(). recording_length(JObj) -> kz_json:get_integer_value(<<"Length">>, JObj). diff --git a/core/kazoo_documents/src/kz_custom_sip_headers.erl b/core/kazoo_documents/src/kz_custom_sip_headers.erl index fdf593e031d..74c1c58db04 100644 --- a/core/kazoo_documents/src/kz_custom_sip_headers.erl +++ b/core/kazoo_documents/src/kz_custom_sip_headers.erl @@ -11,7 +11,7 @@ -define(IN, <<"in">>). -define(OUT, <<"out">>). --spec inbound(kz_json:object()) -> api_object(). +-spec inbound(kz_json:object()) -> kz_term:api_object(). -spec inbound(kz_json:object(), Default) -> kz_json:object() | Default. inbound(CSH) -> inbound(CSH, 'undefined'). @@ -41,12 +41,12 @@ outbound_header(DeviceJObj, Name) -> outbound_header(DeviceJObj, Name, Default) -> kz_json:get_ne_value(Name, outbound(DeviceJObj), Default). --spec filter_csh({ne_binary(), any()}) -> boolean(). +-spec filter_csh({kz_term:ne_binary(), any()}) -> boolean(). filter_csh({<<"in">>, _}) -> 'false'; filter_csh({<<"out">>, _}) -> 'false'; filter_csh(_) -> 'true'. --spec outbound(kz_json:object()) -> api_object(). +-spec outbound(kz_json:object()) -> kz_term:api_object(). -spec outbound(kz_json:object(), Default) -> kz_json:object() | Default. outbound(CSH) -> outbound(CSH, 'undefined'). diff --git a/core/kazoo_documents/src/kz_device.erl b/core/kazoo_documents/src/kz_device.erl index 75062f147d7..7b519b5602c 100644 --- a/core/kazoo_documents/src/kz_device.erl +++ b/core/kazoo_documents/src/kz_device.erl @@ -80,8 +80,8 @@ -define(STATIC_FLAGS, <<"static">>). -define(DYNAMIC_FLAGS, <<"dynamic">>). --spec fetch(api_ne_binary(), api_ne_binary()) -> {'ok', doc()} | - {'error', any()}. +-spec fetch(kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> {'ok', doc()} | + {'error', any()}. fetch(Account=?NE_BINARY, DeviceId=?NE_BINARY) -> AccountDb = kz_util:format_account_db(Account), kz_datamgr:open_cache_doc(AccountDb, DeviceId, [{cache_failures,false}]); @@ -96,56 +96,56 @@ new() -> is_device(Doc) -> kz_doc:type(Doc) =:= type(). --spec sip_username(doc()) -> api_binary(). --spec sip_username(doc(), Default) -> ne_binary() | Default. +-spec sip_username(doc()) -> kz_term:api_binary(). +-spec sip_username(doc(), Default) -> kz_term:ne_binary() | Default. sip_username(DeviceJObj) -> sip_username(DeviceJObj, 'undefined'). sip_username(DeviceJObj, Default) -> kz_json:get_value(?USERNAME, DeviceJObj, Default). --spec sip_password(doc()) -> api_binary(). --spec sip_password(doc(), Default) -> ne_binary() | Default. +-spec sip_password(doc()) -> kz_term:api_binary(). +-spec sip_password(doc(), Default) -> kz_term:ne_binary() | Default. sip_password(DeviceJObj) -> sip_password(DeviceJObj, 'undefined'). sip_password(DeviceJObj, Default) -> kz_json:get_value(?PASSWORD, DeviceJObj, Default). --spec sip_method(doc()) -> api_binary(). --spec sip_method(doc(), Default) -> ne_binary() | Default. +-spec sip_method(doc()) -> kz_term:api_binary(). +-spec sip_method(doc(), Default) -> kz_term:ne_binary() | Default. sip_method(DeviceJObj) -> sip_method(DeviceJObj, 'undefined'). sip_method(DeviceJObj, Default) -> kz_json:get_value(?METHOD, DeviceJObj, Default). --spec sip_realm(doc()) -> api_binary(). --spec sip_realm(doc(), Default) -> ne_binary() | Default. +-spec sip_realm(doc()) -> kz_term:api_binary(). +-spec sip_realm(doc(), Default) -> kz_term:ne_binary() | Default. sip_realm(DeviceJObj) -> sip_realm(DeviceJObj, 'undefined'). sip_realm(DeviceJObj, Default) -> kz_json:get_value(?REALM, DeviceJObj, Default). --spec sip_ip(doc()) -> api_binary(). --spec sip_ip(doc(), Default) -> ne_binary() | Default. +-spec sip_ip(doc()) -> kz_term:api_binary(). +-spec sip_ip(doc(), Default) -> kz_term:ne_binary() | Default. sip_ip(DeviceJObj) -> sip_ip(DeviceJObj, 'undefined'). sip_ip(DeviceJObj, Default) -> kz_json:get_value(?IP, DeviceJObj, Default). --spec sip_invite_format(doc()) -> api_binary(). --spec sip_invite_format(doc(), Default) -> ne_binary() | Default. +-spec sip_invite_format(doc()) -> kz_term:api_binary(). +-spec sip_invite_format(doc(), Default) -> kz_term:ne_binary() | Default. sip_invite_format(DeviceJObj) -> sip_invite_format(DeviceJObj, 'undefined'). sip_invite_format(DeviceJObj, Default) -> kz_json:get_value(?INVITE_FORMAT, DeviceJObj, Default). --spec sip_route(doc()) -> api_binary(). --spec sip_route(doc(), Default) -> ne_binary() | Default. +-spec sip_route(doc()) -> kz_term:api_binary(). +-spec sip_route(doc(), Default) -> kz_term:ne_binary() | Default. sip_route(DeviceJObj) -> sip_route(DeviceJObj, 'undefined'). @@ -160,7 +160,7 @@ custom_sip_headers(DeviceJObj) -> set_custom_sip_headers(DeviceJObj, CSH) -> kz_json:set_value(?CUSTOM_SIP_HEADERS, CSH, DeviceJObj). --spec custom_sip_headers_inbound(doc()) -> api_object(). +-spec custom_sip_headers_inbound(doc()) -> kz_term:api_object(). -spec custom_sip_headers_inbound(doc(), Default) -> kz_json:object() | Default. custom_sip_headers_inbound(DeviceJObj) -> custom_sip_headers_inbound(DeviceJObj, 'undefined'). @@ -185,7 +185,7 @@ custom_sip_header_outbound(DeviceJObj, Name, Default) -> CSH = custom_sip_headers(DeviceJObj), kz_custom_sip_headers:outbound_header(CSH, Name, Default). --spec custom_sip_headers_outbound(doc()) -> api_object(). +-spec custom_sip_headers_outbound(doc()) -> kz_term:api_object(). -spec custom_sip_headers_outbound(doc(), Default) -> kz_json:object() | Default. custom_sip_headers_outbound(DeviceJObj) -> custom_sip_headers_outbound(DeviceJObj, 'undefined'). @@ -194,7 +194,7 @@ custom_sip_headers_outbound(DeviceJObj, Default) -> CSH = custom_sip_headers(DeviceJObj), kz_custom_sip_headers:outbound(CSH, Default). --spec sip_settings(doc()) -> api_object(). +-spec sip_settings(doc()) -> kz_term:api_object(). -spec sip_settings(doc(), Default) -> kz_json:object() | Default. sip_settings(DeviceJObj) -> sip_settings(DeviceJObj, 'undefined'). @@ -202,31 +202,31 @@ sip_settings(DeviceJObj) -> sip_settings(DeviceJObj, Default) -> kz_json:get_value(?SIP, DeviceJObj, Default). --spec set_sip_username(doc(), ne_binary()) -> doc(). +-spec set_sip_username(doc(), kz_term:ne_binary()) -> doc(). set_sip_username(DeviceJObj, Username) -> kz_json:set_value(?USERNAME, Username, DeviceJObj). --spec set_sip_password(doc(), ne_binary()) -> doc(). +-spec set_sip_password(doc(), kz_term:ne_binary()) -> doc(). set_sip_password(DeviceJObj, Password) -> kz_json:set_value(?PASSWORD, Password, DeviceJObj). --spec set_sip_method(doc(), ne_binary()) -> doc(). +-spec set_sip_method(doc(), kz_term:ne_binary()) -> doc(). set_sip_method(DeviceJObj, Method) -> kz_json:set_value(?METHOD, Method, DeviceJObj). --spec set_sip_realm(doc(), ne_binary()) -> doc(). +-spec set_sip_realm(doc(), kz_term:ne_binary()) -> doc(). set_sip_realm(DeviceJObj, Realm) -> kz_json:set_value(?REALM, Realm, DeviceJObj). --spec set_sip_ip(doc(), ne_binary()) -> doc(). +-spec set_sip_ip(doc(), kz_term:ne_binary()) -> doc(). set_sip_ip(DeviceJObj, Ip) -> kz_json:set_value(?IP, Ip, DeviceJObj). --spec set_sip_invite_format(doc(), ne_binary()) -> doc(). +-spec set_sip_invite_format(doc(), kz_term:ne_binary()) -> doc(). set_sip_invite_format(DeviceJObj, InviteFormat) -> kz_json:set_value(?INVITE_FORMAT, InviteFormat, DeviceJObj). --spec set_sip_route(doc(), ne_binary()) -> doc(). +-spec set_sip_route(doc(), kz_term:ne_binary()) -> doc(). set_sip_route(DeviceJObj, Route) -> kz_json:set_value(?ROUTE, Route, DeviceJObj). @@ -246,75 +246,75 @@ set_custom_sip_headers_outbound(Device, Headers) -> set_sip_settings(DeviceJObj, SipJObj) -> kz_json:set_value(?SIP, SipJObj, DeviceJObj). --spec presence_id(doc()) -> api_binary(). --spec presence_id(doc(), Default) -> ne_binary() | Default. +-spec presence_id(doc()) -> kz_term:api_binary(). +-spec presence_id(doc(), Default) -> kz_term:ne_binary() | Default. presence_id(DeviceJObj) -> presence_id(DeviceJObj, sip_username(DeviceJObj)). presence_id(DeviceJObj, Default) -> kz_json:get_binary_value(?PRESENCE_ID, DeviceJObj, Default). --spec set_presence_id(doc(), ne_binary()) -> doc(). +-spec set_presence_id(doc(), kz_term:ne_binary()) -> doc(). set_presence_id(DeviceJObj, Id) -> kz_json:set_value(?PRESENCE_ID ,kz_term:to_binary(Id) ,DeviceJObj ). --spec name(doc()) -> api_binary(). --spec name(doc(), Default) -> ne_binary() | Default. +-spec name(doc()) -> kz_term:api_binary(). +-spec name(doc(), Default) -> kz_term:ne_binary() | Default. name(DeviceJObj) -> name(DeviceJObj, 'undefined'). name(DeviceJObj, Default) -> kz_json:get_value(?NAME, DeviceJObj, Default). --spec set_name(doc(), ne_binary()) -> doc(). +-spec set_name(doc(), kz_term:ne_binary()) -> doc(). set_name(DeviceJObj, Name) -> kz_json:set_value(?NAME, Name, DeviceJObj). --spec mac_address(doc()) -> api_binary(). --spec mac_address(doc(), Default) -> ne_binary() | Default. +-spec mac_address(doc()) -> kz_term:api_binary(). +-spec mac_address(doc(), Default) -> kz_term:ne_binary() | Default. mac_address(DeviceJObj) -> mac_address(DeviceJObj, 'undefined'). mac_address(DeviceJObj, Default) -> kz_json:get_value(?MAC_ADDRESS, DeviceJObj, Default). --spec set_mac_address(doc(), ne_binary()) -> doc(). +-spec set_mac_address(doc(), kz_term:ne_binary()) -> doc(). set_mac_address(DeviceJObj, MacAddress) -> kz_json:set_value(?MAC_ADDRESS, MacAddress, DeviceJObj). --spec language(doc()) -> api_binary(). --spec language(doc(), Default) -> ne_binary() | Default. +-spec language(doc()) -> kz_term:api_binary(). +-spec language(doc(), Default) -> kz_term:ne_binary() | Default. language(DeviceJObj) -> language(DeviceJObj, 'undefined'). language(DeviceJObj, Default) -> kz_json:get_ne_value(?LANGUAGE, DeviceJObj, Default). --spec set_language(doc(), ne_binary()) -> doc(). +-spec set_language(doc(), kz_term:ne_binary()) -> doc(). set_language(DeviceJObj, Language) -> kz_json:set_value(?LANGUAGE, Language, DeviceJObj). --spec device_type(doc()) -> api_binary(). --spec device_type(doc(), Default) -> ne_binary() | Default. +-spec device_type(doc()) -> kz_term:api_binary(). +-spec device_type(doc(), Default) -> kz_term:ne_binary() | Default. device_type(DeviceJObj) -> device_type(DeviceJObj, 'undefined'). device_type(DeviceJObj, Default) -> kz_json:get_value(?DEVICE_TYPE, DeviceJObj, Default). --spec set_device_type(doc(), ne_binary()) -> doc(). +-spec set_device_type(doc(), kz_term:ne_binary()) -> doc(). set_device_type(DeviceJObj, MacAddress) -> kz_json:set_value(?DEVICE_TYPE, MacAddress, DeviceJObj). --spec type() -> ne_binary(). +-spec type() -> kz_term:ne_binary(). type() -> <<"device">>. --spec owner_id(doc()) -> api_binary(). --spec owner_id(doc(), Default) -> ne_binary() | Default. +-spec owner_id(doc()) -> kz_term:api_binary(). +-spec owner_id(doc(), Default) -> kz_term:ne_binary() | Default. owner_id(DeviceJObj) -> owner_id(DeviceJObj, 'undefined'). owner_id(DeviceJObj, Default) -> kz_json:get_value(?KEY_OWNER_ID, DeviceJObj, Default). --spec set_owner_id(doc(), ne_binary()) -> doc(). +-spec set_owner_id(doc(), kz_term:ne_binary()) -> doc(). set_owner_id(DeviceJObj, OwnerId) -> kz_json:set_value(?KEY_OWNER_ID, OwnerId, DeviceJObj). @@ -330,11 +330,11 @@ enabled(DeviceJObj, Default) -> set_enabled(DeviceJObj, Enabled) -> kz_json:set_value(?ENABLED, Enabled, DeviceJObj). --spec timezone(doc()) -> ne_binary(). +-spec timezone(doc()) -> kz_term:ne_binary(). timezone(Box) -> timezone(Box, 'undefined'). --spec timezone(doc(), Default) -> ne_binary() | Default. +-spec timezone(doc(), Default) -> kz_term:ne_binary() | Default. timezone(Box, Default) -> case kz_json:get_value(?KEY_TIMEZONE, Box) of 'undefined' -> owner_timezone(Box, Default); @@ -342,7 +342,7 @@ timezone(Box, Default) -> TZ -> TZ end. --spec owner_timezone(doc(), Default) -> ne_binary() | Default. +-spec owner_timezone(doc(), Default) -> kz_term:ne_binary() | Default. owner_timezone(Box, Default) -> case kzd_user:fetch(kz_doc:account_db(Box), owner_id(Box)) of {'ok', OwnerJObj} -> kzd_user:timezone(OwnerJObj, Default); @@ -371,7 +371,7 @@ outbound_flags(JObj) -> 'true' -> OutboundFlags end. --spec set_outbound_flags(kz_json:object(), kz_json:object() | ne_binaries()) -> kz_json:object(). +-spec set_outbound_flags(kz_json:object(), kz_json:object() | kz_term:ne_binaries()) -> kz_json:object(). set_outbound_flags(JObj, Flags) when is_list(Flags) -> OutboundFlags = outbound_flags(JObj), UpdatedFlags = kz_json:set_value(?STATIC_FLAGS, Flags, OutboundFlags), @@ -379,7 +379,7 @@ set_outbound_flags(JObj, Flags) when is_list(Flags) -> set_outbound_flags(JObj, Flags) -> kz_json:set_value(?OUTBOUND_FLAGS, Flags, JObj). --spec set_outbound_flags(kz_json:object(), ne_binaries()|undefined, ne_binaries()|undefined) -> kz_json:object(). +-spec set_outbound_flags(kz_json:object(), kz_term:ne_binaries()|undefined, kz_term:ne_binaries()|undefined) -> kz_json:object(). set_outbound_flags(JObj, 'undefined', DynamicFlags) -> set_outbound_flags(JObj, [], DynamicFlags); set_outbound_flags(JObj, StaticFlags, 'undefined') -> @@ -390,12 +390,12 @@ set_outbound_flags(JObj, StaticFlags, DynamicFlags) when is_list(StaticFlags), i ]), kz_json:set_value(?OUTBOUND_FLAGS, Flags, JObj). --spec outbound_static_flags(kz_json:object()) -> ne_binaries(). +-spec outbound_static_flags(kz_json:object()) -> kz_term:ne_binaries(). outbound_static_flags(JObj) -> OutboundFlags = outbound_flags(JObj), kz_json:get_list_value(?STATIC_FLAGS, OutboundFlags, []). --spec set_outbound_static_flags(kz_json:object(), ne_binaries()) -> kz_json:object(). +-spec set_outbound_static_flags(kz_json:object(), kz_term:ne_binaries()) -> kz_json:object(). set_outbound_static_flags(JObj, Flags) when is_list(Flags) -> OutboundFlags = kz_json:get_ne_value(?OUTBOUND_FLAGS, JObj, []), %% Backward compatibilty with an array of static flags @@ -406,12 +406,12 @@ set_outbound_static_flags(JObj, Flags) when is_list(Flags) -> kz_json:set_value(?OUTBOUND_FLAGS, Updates, JObj) end. --spec outbound_dynamic_flags(kz_json:object()) -> ne_binaries(). +-spec outbound_dynamic_flags(kz_json:object()) -> kz_term:ne_binaries(). outbound_dynamic_flags(JObj) -> OutboundFlags = outbound_flags(JObj), kz_json:get_list_value(?DYNAMIC_FLAGS, OutboundFlags, []). --spec set_outbound_dynamic_flags(kz_json:object(), ne_binaries()) -> kz_json:object(). +-spec set_outbound_dynamic_flags(kz_json:object(), kz_term:ne_binaries()) -> kz_json:object(). set_outbound_dynamic_flags(JObj, Flags) when is_list(Flags) -> OutboundFlags = kz_json:get_ne_value(?OUTBOUND_FLAGS, JObj, []), %% Backward compatibilty with an array of static flags diff --git a/core/kazoo_documents/src/kz_notification.erl b/core/kazoo_documents/src/kz_notification.erl index afb2d46232b..34a2ba2e8bb 100644 --- a/core/kazoo_documents/src/kz_notification.erl +++ b/core/kazoo_documents/src/kz_notification.erl @@ -47,33 +47,33 @@ -define(EMAIL_TYPE, <<"type">>). -define(PVT_TYPE, <<"notification">>). --spec id(doc()) -> api_binary(). +-spec id(doc()) -> kz_term:api_binary(). id(JObj) -> kz_doc:id(JObj). --spec db_id(doc() | ne_binary()) -> api_binary(). +-spec db_id(doc() | kz_term:ne_binary()) -> kz_term:api_binary(). db_id(<<_/binary>> = Id) -> maybe_add_prefix(Id); db_id(JObj) -> maybe_add_prefix(id(JObj)). --spec resp_id(doc() | ne_binary()) -> api_binary(). +-spec resp_id(doc() | kz_term:ne_binary()) -> kz_term:api_binary(). resp_id(<<_/binary>> = Id) -> maybe_rm_prefix(Id); resp_id(JObj) -> maybe_rm_prefix(id(JObj)). -define(ID_PREFIX, "notification."). --spec maybe_add_prefix(api_binary()) -> api_binary(). +-spec maybe_add_prefix(kz_term:api_binary()) -> kz_term:api_binary(). maybe_add_prefix('undefined') -> 'undefined'; maybe_add_prefix(<> = Id) -> Id; maybe_add_prefix(Id) -> <>. --spec maybe_rm_prefix(api_binary()) -> api_binary(). +-spec maybe_rm_prefix(kz_term:api_binary()) -> kz_term:api_binary(). maybe_rm_prefix('undefined') -> 'undefined'; maybe_rm_prefix(<>) -> Id; maybe_rm_prefix(Id) -> Id. --spec macros(doc()) -> api_object(). +-spec macros(doc()) -> kz_term:api_object(). macros(JObj) -> kz_json:get_value(?MACROS, JObj). @@ -89,31 +89,31 @@ macro(JObj, Key) -> set_macro(JObj, Key, Value) -> kz_json:set_value([?MACROS, Key], Value, JObj). --spec subject(doc()) -> api_binary(). +-spec subject(doc()) -> kz_term:api_binary(). subject(JObj) -> kz_json:get_value(?SUBJECT, JObj). --spec set_subject(doc(), ne_binary()) -> doc(). +-spec set_subject(doc(), kz_term:ne_binary()) -> doc(). set_subject(JObj, Subject) -> kz_json:set_value(?SUBJECT, Subject, JObj). --spec category(doc()) -> api_binary(). +-spec category(doc()) -> kz_term:api_binary(). category(JObj) -> kz_json:get_value(?CATEGORY, JObj). --spec set_category(doc(), ne_binary()) -> doc(). +-spec set_category(doc(), kz_term:ne_binary()) -> doc(). set_category(JObj, Category) -> kz_json:set_value(?CATEGORY, Category, JObj). --spec name(doc()) -> api_binary(). +-spec name(doc()) -> kz_term:api_binary(). name(JObj) -> kz_json:get_value(?NAME, JObj). --spec set_name(doc(), ne_binary()) -> doc(). +-spec set_name(doc(), kz_term:ne_binary()) -> doc(). set_name(JObj, Name) -> kz_json:set_value(?NAME, Name, JObj). --spec to(doc()) -> api_object(). +-spec to(doc()) -> kz_term:api_object(). to(JObj) -> kz_json:get_value(?TO, JObj). @@ -121,15 +121,15 @@ to(JObj) -> set_to(JObj, To) -> kz_json:set_value(?TO, To, JObj). --spec to_email_addresses(doc()) -> api_binaries(). +-spec to_email_addresses(doc()) -> kz_term:api_binaries(). to_email_addresses(JObj) -> kz_json:get_value([?TO, ?EMAIL_ADDRESSES], JObj). --spec to_email_type(doc()) -> api_binary(). +-spec to_email_type(doc()) -> kz_term:api_binary(). to_email_type(JObj) -> kz_json:get_value([?TO, ?EMAIL_TYPE], JObj). --spec cc(doc()) -> api_object(). +-spec cc(doc()) -> kz_term:api_object(). cc(JObj) -> kz_json:get_value(?CC, JObj). @@ -137,15 +137,15 @@ cc(JObj) -> set_cc(JObj, Cc) -> kz_json:set_value(?CC, Cc, JObj). --spec cc_email_addresses(doc()) -> api_binaries(). +-spec cc_email_addresses(doc()) -> kz_term:api_binaries(). cc_email_addresses(JObj) -> kz_json:get_value([?CC, ?EMAIL_ADDRESSES], JObj). --spec cc_email_type(doc()) -> api_binary(). +-spec cc_email_type(doc()) -> kz_term:api_binary(). cc_email_type(JObj) -> kz_json:get_value([?CC, ?EMAIL_TYPE], JObj). --spec bcc(doc()) -> api_object(). +-spec bcc(doc()) -> kz_term:api_object(). bcc(JObj) -> kz_json:get_value(?BCC, JObj). @@ -153,32 +153,32 @@ bcc(JObj) -> set_bcc(JObj, Bcc) -> kz_json:set_value(?BCC, Bcc, JObj). --spec bcc_email_addresses(doc()) -> api_binaries(). +-spec bcc_email_addresses(doc()) -> kz_term:api_binaries(). bcc_email_addresses(JObj) -> kz_json:get_value([?BCC, ?EMAIL_ADDRESSES], JObj). --spec bcc_email_type(doc()) -> api_binary(). +-spec bcc_email_type(doc()) -> kz_term:api_binary(). bcc_email_type(JObj) -> kz_json:get_value([?BCC, ?EMAIL_TYPE], JObj). --spec from(doc()) -> api_binary(). +-spec from(doc()) -> kz_term:api_binary(). from(JObj) -> kz_json:get_value(?FROM, JObj). --spec set_from(doc(), ne_binary()) -> doc(). +-spec set_from(doc(), kz_term:ne_binary()) -> doc(). set_from(JObj, From) -> kz_json:set_value(?FROM, From, JObj). --spec reply_to(doc()) -> api_binary(). +-spec reply_to(doc()) -> kz_term:api_binary(). reply_to(JObj) -> kz_json:get_value(?REPLY_TO, JObj). --spec set_reply_to(doc(), ne_binary()) -> doc(). +-spec set_reply_to(doc(), kz_term:ne_binary()) -> doc(). set_reply_to(JObj, ReplyTo) -> kz_json:set_value(?REPLY_TO, ReplyTo, JObj). -spec set_base_properties(doc()) -> doc(). --spec set_base_properties(doc(), api_binary()) -> doc(). +-spec set_base_properties(doc(), kz_term:api_binary()) -> doc(). set_base_properties(JObj) -> set_base_properties(JObj, id(JObj)). @@ -187,8 +187,8 @@ set_base_properties(JObj, Id) -> ,{<<"_id">>, db_id(Id)} ], JObj). --spec pvt_type() -> ne_binary(). --spec pvt_type(doc()) -> ne_binary(). +-spec pvt_type() -> kz_term:ne_binary(). +-spec pvt_type(doc()) -> kz_term:ne_binary(). pvt_type() -> ?PVT_TYPE. pvt_type(JObj) -> kz_doc:type(JObj, ?PVT_TYPE). diff --git a/core/kazoo_documents/src/kz_whitelabel.erl b/core/kazoo_documents/src/kz_whitelabel.erl index e5a11d2c2ea..62277b33bd6 100644 --- a/core/kazoo_documents/src/kz_whitelabel.erl +++ b/core/kazoo_documents/src/kz_whitelabel.erl @@ -26,7 +26,7 @@ -include("kz_documents.hrl"). --spec fetch(api_binary()) -> {'ok', kz_json:object()} | {'error', any()}. +-spec fetch(kz_term:api_binary()) -> {'ok', kz_json:object()} | {'error', any()}. fetch('undefined') -> {'error', 'account_id_undefined'}; fetch(Account) -> @@ -37,18 +37,18 @@ fetch(Account) -> port_hide(JObj) -> kz_json:is_true(?PORT_HIDE, JObj). --spec port_email(kz_json:object()) -> api_binary(). +-spec port_email(kz_json:object()) -> kz_term:api_binary(). port_email(JObj) -> kz_json:get_ne_binary_value(?PORT_EMAIL, JObj). --spec port_authority(kz_json:object()) -> api_binary(). +-spec port_authority(kz_json:object()) -> kz_term:api_binary(). port_authority(JObj) -> kz_json:get_ne_binary_value(?PORT_AUTHORITY, JObj). --spec port_loa(kz_json:object()) -> api_binary(). +-spec port_loa(kz_json:object()) -> kz_term:api_binary(). port_loa(JObj) -> kz_json:get_ne_binary_value(?PORT_LOA, JObj). --spec port_resporg(kz_json:object()) -> api_binary(). +-spec port_resporg(kz_json:object()) -> kz_term:api_binary(). port_resporg(JObj) -> kz_json:get_ne_binary_value(?PORT_RESPORG, JObj). diff --git a/core/kazoo_documents/src/kzd_agent.erl b/core/kazoo_documents/src/kzd_agent.erl index 35382f1a429..6ecc9966fd3 100644 --- a/core/kazoo_documents/src/kzd_agent.erl +++ b/core/kazoo_documents/src/kzd_agent.erl @@ -15,11 +15,11 @@ ,maybe_rm_queue/2, maybe_rm_queue/3 ]). --spec maybe_add_queue(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec maybe_add_queue(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). maybe_add_queue(AgentJObj, QueueId) -> maybe_add_queue(AgentJObj, QueueId, AgentJObj). --spec maybe_add_queue(kz_json:object(), ne_binary(), Default) -> kz_json:object() | Default. +-spec maybe_add_queue(kz_json:object(), kz_term:ne_binary(), Default) -> kz_json:object() | Default. maybe_add_queue(AgentJObj, QueueId, WhenExists) -> Qs = kz_json:get_value(<<"queues">>, AgentJObj, []), case lists:member(QueueId, Qs) of @@ -27,11 +27,11 @@ maybe_add_queue(AgentJObj, QueueId, WhenExists) -> 'true' -> WhenExists end. --spec maybe_rm_queue(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec maybe_rm_queue(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). maybe_rm_queue(AgentJObj, QueueId) -> maybe_rm_queue(AgentJObj, QueueId, AgentJObj). --spec maybe_rm_queue(kz_json:object(), ne_binary(), Default) -> kz_json:object() | Default. +-spec maybe_rm_queue(kz_json:object(), kz_term:ne_binary(), Default) -> kz_json:object() | Default. maybe_rm_queue(AgentJObj, QueueId, WhenNotExists) -> Qs = kz_json:get_value(<<"queues">>, AgentJObj, []), case lists:member(QueueId, Qs) of diff --git a/core/kazoo_documents/src/kzd_alert.erl b/core/kazoo_documents/src/kzd_alert.erl index 8d035d6ec9b..50ffe4fd181 100644 --- a/core/kazoo_documents/src/kzd_alert.erl +++ b/core/kazoo_documents/src/kzd_alert.erl @@ -56,7 +56,7 @@ new() -> %% @doc %% @end %%-------------------------------------------------------------------- --spec type() -> ne_binary(). +-spec type() -> kz_term:ne_binary(). type() -> ?PVT_TYPE. %%-------------------------------------------------------------------- @@ -64,7 +64,7 @@ type() -> ?PVT_TYPE. %% @doc %% @end %%-------------------------------------------------------------------- --spec id(doc()) -> api_binary(). +-spec id(doc()) -> kz_term:api_binary(). id(JObj) -> kz_doc:id(JObj). @@ -73,8 +73,8 @@ id(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec fetch(api_binary()) -> {'ok', doc()} | - {'error', any()}. +-spec fetch(kz_term:api_binary()) -> {'ok', doc()} | + {'error', any()}. fetch('undefined') -> {'error', 'invalid_db_name'}; fetch(<<_/binary>> = AlertId) -> @@ -85,9 +85,9 @@ fetch(<<_/binary>> = AlertId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec title() -> ne_binary(). --spec title(doc()) -> api_binary(). --spec title(doc(), Default) -> ne_binary() | Default. +-spec title() -> kz_term:ne_binary(). +-spec title(doc()) -> kz_term:api_binary(). +-spec title(doc(), Default) -> kz_term:ne_binary() | Default. title() -> ?TITLE. @@ -97,7 +97,7 @@ title(JObj) -> title(JObj, Default) -> kz_json:get_value(?TITLE, JObj, Default). --spec set_title(doc(), ne_binary()) -> doc(). +-spec set_title(doc(), kz_term:ne_binary()) -> doc(). set_title(JObj, Title) -> kz_json:set_value(?TITLE, Title, JObj). @@ -106,9 +106,9 @@ set_title(JObj, Title) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec category() -> ne_binary(). --spec category(doc()) -> api_binary(). --spec category(doc(), Default) -> ne_binary() | Default. +-spec category() -> kz_term:ne_binary(). +-spec category(doc()) -> kz_term:api_binary(). +-spec category(doc(), Default) -> kz_term:ne_binary() | Default. category() -> ?CATEGORY. @@ -118,7 +118,7 @@ category(JObj) -> category(JObj, Default) -> kz_json:get_value(?CATEGORY, JObj, Default). --spec set_category(doc(), ne_binary()) -> doc(). +-spec set_category(doc(), kz_term:ne_binary()) -> doc(). set_category(JObj, Category) -> kz_json:set_value(?CATEGORY, Category, JObj). @@ -127,9 +127,9 @@ set_category(JObj, Category) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec message() -> ne_binary(). --spec message(doc()) -> api_binary(). --spec message(doc(), Default) -> ne_binary() | Default. +-spec message() -> kz_term:ne_binary(). +-spec message(doc()) -> kz_term:api_binary(). +-spec message(doc(), Default) -> kz_term:ne_binary() | Default. message() -> ?MESSAGE. @@ -139,7 +139,7 @@ message(JObj) -> message(JObj, Default) -> kz_json:get_value(?MESSAGE, JObj, Default). --spec set_message(doc(), ne_binary()) -> doc(). +-spec set_message(doc(), kz_term:ne_binary()) -> doc(). set_message(JObj, Message) -> kz_json:set_value(?MESSAGE, Message, JObj). @@ -148,7 +148,7 @@ set_message(JObj, Message) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec metadata() -> ne_binary(). +-spec metadata() -> kz_term:ne_binary(). -spec metadata(doc()) -> kz_json:object(). -spec metadata(doc(), Default) -> kz_json:object() | Default. metadata() -> @@ -169,9 +169,9 @@ set_metadata(JObj, Metadata) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec level() -> ne_binary(). --spec level(doc()) -> api_binary(). --spec level(doc(), Default) -> ne_binary() | Default. +-spec level() -> kz_term:ne_binary(). +-spec level(doc()) -> kz_term:api_binary(). +-spec level(doc(), Default) -> kz_term:ne_binary() | Default. level() -> ?LEVEL. @@ -181,7 +181,7 @@ level(JObj) -> level(JObj, Default) -> kz_json:get_value(?LEVEL, JObj, Default). --spec set_level(doc(), ne_binary()) -> doc(). +-spec set_level(doc(), kz_term:ne_binary()) -> doc(). set_level(JObj, Level) -> kz_json:set_value(?LEVEL, Level, JObj). @@ -190,7 +190,7 @@ set_level(JObj, Level) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec from() -> ne_binary(). +-spec from() -> kz_term:ne_binary(). -spec from(doc()) -> kz_json:objects(). -spec from(doc(), Default) -> kz_json:objects() | Default. from() -> @@ -211,7 +211,7 @@ set_from(JObj, From) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec to() -> ne_binary(). +-spec to() -> kz_term:ne_binary(). -spec to(doc()) -> kz_json:objects(). -spec to(doc(), Default) -> kz_json:objects() | Default. to() -> @@ -232,7 +232,7 @@ set_to(JObj, To) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec expiration_date() -> ne_binary(). +-spec expiration_date() -> kz_term:ne_binary(). -spec expiration_date(doc()) -> kz_json:object(). -spec expiration_date(doc(), Default) -> kz_json:object() | Default. expiration_date() -> diff --git a/core/kazoo_documents/src/kzd_app.erl b/core/kazoo_documents/src/kzd_app.erl index ec0b4307318..ed90531b0bc 100644 --- a/core/kazoo_documents/src/kzd_app.erl +++ b/core/kazoo_documents/src/kzd_app.erl @@ -60,7 +60,7 @@ %% @doc %% @end %%-------------------------------------------------------------------- --spec fetch(api_binary(), api_binary()) -> {'ok', kz_json:object()} | {'error', any()}. +-spec fetch(kz_term:api_binary(), kz_term:api_binary()) -> {'ok', kz_json:object()} | {'error', any()}. fetch('undefined', _) -> {'error', 'account_id_undefined'}; fetch(_, 'undefined') -> @@ -73,7 +73,7 @@ fetch(Account, Id) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec id(kz_json:object()) -> ne_binary(). +-spec id(kz_json:object()) -> kz_term:ne_binary(). id(JObj) -> kz_doc:id(JObj). @@ -99,7 +99,7 @@ unpublish(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec name(kz_json:object()) -> api_binary(). +-spec name(kz_json:object()) -> kz_term:api_binary(). name(JObj) -> kz_json:get_ne_binary_value(?NAME, JObj). @@ -108,7 +108,7 @@ name(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec i18n(kz_json:object()) -> api_object(). +-spec i18n(kz_json:object()) -> kz_term:api_object(). i18n(JObj) -> kz_json:get_json_value(?I18N, JObj). @@ -117,7 +117,7 @@ i18n(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec tags(kz_json:object()) -> ne_binaries(). +-spec tags(kz_json:object()) -> kz_term:ne_binaries(). tags(JObj) -> kz_json:get_list_value(?TAGS, JObj, []). @@ -126,7 +126,7 @@ tags(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec icon(kz_json:object()) -> api_binary(). +-spec icon(kz_json:object()) -> kz_term:api_binary(). icon(JObj) -> kz_json:get_ne_binary_value(?ICON, JObj). @@ -135,7 +135,7 @@ icon(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec api_url(kz_json:object()) -> api_binary(). +-spec api_url(kz_json:object()) -> kz_term:api_binary(). api_url(JObj) -> kz_json:get_ne_binary_value(?API_URL, JObj). @@ -144,7 +144,7 @@ api_url(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec source_url(kz_json:object()) -> api_binary(). +-spec source_url(kz_json:object()) -> kz_term:api_binary(). source_url(JObj) -> kz_json:get_ne_binary_value(?SOURCE_URL, JObj). @@ -153,7 +153,7 @@ source_url(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec author(kz_json:object()) -> api_binary(). +-spec author(kz_json:object()) -> kz_term:api_binary(). author(JObj) -> kz_json:get_ne_binary_value(?AUTHOR, JObj). @@ -162,7 +162,7 @@ author(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec version(kz_json:object()) -> ne_binary(). +-spec version(kz_json:object()) -> kz_term:ne_binary(). version(JObj) -> kz_json:get_ne_binary_value(?VERSION, JObj). @@ -171,7 +171,7 @@ version(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec license(kz_json:object()) -> ne_binary(). +-spec license(kz_json:object()) -> kz_term:ne_binary(). license(JObj) -> kz_json:get_ne_binary_value(?LICENSE, JObj). @@ -180,7 +180,7 @@ license(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec price(kz_json:object()) -> api_float(). +-spec price(kz_json:object()) -> kz_term:api_float(). price(JObj) -> kz_json:get_float_value(?PRICE, JObj). @@ -189,7 +189,7 @@ price(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec phase(kz_json:object()) -> api_binary(). +-spec phase(kz_json:object()) -> kz_term:api_binary(). phase(JObj) -> kz_json:get_ne_binary_value(?PHASE, JObj). @@ -198,7 +198,7 @@ phase(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec screenshots(kz_json:object()) -> ne_binaries(). +-spec screenshots(kz_json:object()) -> kz_term:ne_binaries(). screenshots(JObj) -> kz_json:get_list_value(?SCREENSHOTS, JObj, []). @@ -216,7 +216,7 @@ urls(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec account_id(kz_json:object()) -> ne_binary(). +-spec account_id(kz_json:object()) -> kz_term:ne_binary(). account_id(JObj) -> kz_doc:account_id(JObj). @@ -234,11 +234,11 @@ users(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec allowed_users(kz_json:object()) -> api_binary(). +-spec allowed_users(kz_json:object()) -> kz_term:api_binary(). allowed_users(JObj) -> allowed_users(JObj, 'undefined'). --spec allowed_users(kz_json:object(), Default) -> ne_binary() | Default. +-spec allowed_users(kz_json:object(), Default) -> kz_term:ne_binary() | Default. allowed_users(JObj, Default) -> kz_json:get_value(?ALLOWED_USERS, JObj, Default). diff --git a/core/kazoo_documents/src/kzd_apps_store.erl b/core/kazoo_documents/src/kzd_apps_store.erl index ff4964454a3..5c1570621c1 100644 --- a/core/kazoo_documents/src/kzd_apps_store.erl +++ b/core/kazoo_documents/src/kzd_apps_store.erl @@ -24,7 +24,7 @@ %% @doc %% @end %%-------------------------------------------------------------------- --spec fetch(api_binary()) -> {'ok', kz_json:object()} | {'error', any()}. +-spec fetch(kz_term:api_binary()) -> {'ok', kz_json:object()} | {'error', any()}. fetch('undefined') -> {'error', 'account_id_undefined'}; fetch(Account) -> @@ -36,7 +36,7 @@ fetch(Account) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec new(ne_binary()) -> kz_json:object(). +-spec new(kz_term:ne_binary()) -> kz_json:object(). new(Account) -> Routines = [ fun(JObj) -> kz_doc:set_id(JObj, ?ID) end @@ -60,7 +60,7 @@ new(Account) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec id() -> ne_binary(). +-spec id() -> kz_term:ne_binary(). id() -> ?ID. %%-------------------------------------------------------------------- @@ -86,8 +86,8 @@ set_apps(JObj, Data) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec blacklist(kz_json:object()) -> ne_binaries(). --spec blacklist(kz_json:object(), Default) -> ne_binaries() | Default. +-spec blacklist(kz_json:object()) -> kz_term:ne_binaries(). +-spec blacklist(kz_json:object(), Default) -> kz_term:ne_binaries() | Default. blacklist(JObj) -> kz_json:get_value(?BLACKLIST, JObj, []). diff --git a/core/kazoo_documents/src/kzd_audit_log.erl b/core/kazoo_documents/src/kzd_audit_log.erl index b423d3538fe..af810cfbc92 100644 --- a/core/kazoo_documents/src/kzd_audit_log.erl +++ b/core/kazoo_documents/src/kzd_audit_log.erl @@ -53,51 +53,51 @@ audit_account_ids(JObj) -> kz_json:get_keys(?KEY_AUDIT, JObj). --spec audit_account_id(doc(), ne_binary()) -> api_object(). --spec audit_account_id(doc(), ne_binary(), Default) -> kz_json:object() | Default. +-spec audit_account_id(doc(), kz_term:ne_binary()) -> kz_term:api_object(). +-spec audit_account_id(doc(), kz_term:ne_binary(), Default) -> kz_json:object() | Default. audit_account_id(JObj, AccountId) -> audit_account_id(JObj, AccountId, 'undefined'). audit_account_id(JObj, AccountId, Default) -> kz_json:get_json_value([?KEY_AUDIT, AccountId], JObj, Default). --spec audit_account_quantities(doc(), ne_binary()) -> api_object(). +-spec audit_account_quantities(doc(), kz_term:ne_binary()) -> kz_term:api_object(). audit_account_quantities(JObj, AccountId) -> kz_json:get_json_value([?KEY_AUDIT, AccountId, ?KEY_ACCOUNT_QUANTITIES], JObj). --spec audit_cascase_quantities(doc(), ne_binary()) -> api_object(). +-spec audit_cascase_quantities(doc(), kz_term:ne_binary()) -> kz_term:api_object(). audit_cascase_quantities(JObj, AccountId) -> kz_json:get_json_value([?KEY_AUDIT, AccountId, ?KEY_CASCADE_QUANTITIES], JObj). --spec audit_account_name(doc(), ne_binary()) -> api_binary(). +-spec audit_account_name(doc(), kz_term:ne_binary()) -> kz_term:api_binary(). audit_account_name(JObj, AccountId) -> kz_json:get_value([?KEY_AUDIT, AccountId, ?KEY_ACCOUNT_NAME], JObj). --spec tree(doc()) -> ne_binaries(). +-spec tree(doc()) -> kz_term:ne_binaries(). tree(JObj) -> kz_json:get_value(?KEY_TREE, JObj). --spec authenticating_user(doc()) -> api_object(). +-spec authenticating_user(doc()) -> kz_term:api_object(). authenticating_user(JObj) -> kz_json:get_json_value(?KEY_AUTHENTICATING_USER, JObj). --spec authenticating_user_first_name(doc()) -> api_binary(). +-spec authenticating_user_first_name(doc()) -> kz_term:api_binary(). authenticating_user_first_name(JObj) -> kz_json:get_value([?KEY_AUTHENTICATING_USER, ?KEY_FIRST_NAME], JObj). --spec authenticating_user_last_name(doc()) -> api_binary(). +-spec authenticating_user_last_name(doc()) -> kz_term:api_binary(). authenticating_user_last_name(JObj) -> kz_json:get_value([?KEY_AUTHENTICATING_USER, ?KEY_LAST_NAME], JObj). --spec authenticating_user_account_id(doc()) -> api_binary(). +-spec authenticating_user_account_id(doc()) -> kz_term:api_binary(). authenticating_user_account_id(JObj) -> kz_json:get_value([?KEY_AUTHENTICATING_USER, ?KEY_ACCOUNT_ID], JObj). --spec authenticating_user_account_name(doc()) -> api_binary(). +-spec authenticating_user_account_name(doc()) -> kz_term:api_binary(). authenticating_user_account_name(JObj) -> kz_json:get_value([?KEY_AUTHENTICATING_USER, ?KEY_ACCOUNT_NAME], JObj). --spec type() -> ne_binary(). --spec type(doc()) -> api_binary(). +-spec type() -> kz_term:ne_binary(). +-spec type(doc()) -> kz_term:api_binary(). type() -> ?PVT_TYPE. type(JObj) -> kz_doc:type(JObj). @@ -106,7 +106,7 @@ type(JObj) -> kz_doc:type(JObj). new() -> kz_doc:update_pvt_parameters(kz_json:new(), 'undefined', [{'type', ?PVT_TYPE}]). --spec set_tree(doc(), ne_binaries()) -> doc(). +-spec set_tree(doc(), kz_term:ne_binaries()) -> doc(). set_tree(JObj, Tree) -> kz_json:set_value(?KEY_TREE, Tree, JObj). @@ -114,15 +114,15 @@ set_tree(JObj, Tree) -> set_authenticating_user(JObj, User) -> kz_json:set_value(?KEY_AUTHENTICATING_USER, User, JObj). --spec set_audit_account(doc(), ne_binary(), kz_json:object()) -> doc(). +-spec set_audit_account(doc(), kz_term:ne_binary(), kz_json:object()) -> doc(). set_audit_account(JObj, AccountId, AuditJObj) -> OldAudit = audit_account_id(JObj, AccountId, kz_json:new()), NewAudit = kz_json:merge(OldAudit, AuditJObj), kz_json:set_value([?KEY_AUDIT, AccountId], NewAudit, JObj). -spec save(kz_services:services(), doc()) -> 'ok'. --spec save(kz_services:services(), doc(), ne_binary()) -> 'ok'. --spec save(kz_services:services(), doc(), ne_binary(), ne_binary()) -> 'ok'. +-spec save(kz_services:services(), doc(), kz_term:ne_binary()) -> 'ok'. +-spec save(kz_services:services(), doc(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. save(Services, AuditLog) -> case kz_services:have_quantities_changed(Services) of 'true' -> @@ -144,7 +144,7 @@ save(Services, AuditLog, MasterAccountId, AccountId) -> UpdatedLog = save_audit_log(Services, AuditLog, AccountId), maybe_save_audit_log_to_reseller(Services, UpdatedLog, MasterAccountId, AccountId, JObj). --spec maybe_save_audit_log_to_reseller(kz_services:services(), doc(), ne_binary(), ne_binary(), kzd_services:doc()) -> 'ok'. +-spec maybe_save_audit_log_to_reseller(kz_services:services(), doc(), kz_term:ne_binary(), kz_term:ne_binary(), kzd_services:doc()) -> 'ok'. maybe_save_audit_log_to_reseller(Services, AuditLog, MasterAccountId, AccountId, JObj) -> case kzd_services:reseller_id(JObj) of MasterAccountId -> @@ -157,8 +157,8 @@ maybe_save_audit_log_to_reseller(Services, AuditLog, MasterAccountId, AccountId, save(ResellerServices, AuditLog1, MasterAccountId) end. --spec maybe_save_master_audit_log(kz_services:services(), doc(), ne_binary()) -> 'ok'. --spec maybe_save_master_audit_log(kz_services:services(), doc(), ne_binary(), boolean()) -> 'ok'. +-spec maybe_save_master_audit_log(kz_services:services(), doc(), kz_term:ne_binary()) -> 'ok'. +-spec maybe_save_master_audit_log(kz_services:services(), doc(), kz_term:ne_binary(), boolean()) -> 'ok'. maybe_save_master_audit_log(Services, AuditLog, MasterAccountId) -> maybe_save_master_audit_log(Services, AuditLog, MasterAccountId ,kapps_config:get_is_true(<<"services">>, <<"should_save_master_audit_logs">>, 'false') @@ -170,7 +170,7 @@ maybe_save_master_audit_log(Services, AuditLog, MasterAccountId, 'true') -> save_audit_log(Services, AuditLog, MasterAccountId), lager:debug("reached master account, saved audit log"). --spec save_audit_log(kz_services:services(), doc(), ne_binary()) -> doc(). +-spec save_audit_log(kz_services:services(), doc(), kz_term:ne_binary()) -> doc(). save_audit_log(Services, AuditLog, ResellerId) -> AuditLog1 = update_audit_log(Services, AuditLog), case audit_account_ids(AuditLog1) of diff --git a/core/kazoo_documents/src/kzd_box_message.erl b/core/kazoo_documents/src/kzd_box_message.erl index e2a35a47c11..3fcdacba8d9 100644 --- a/core/kazoo_documents/src/kzd_box_message.erl +++ b/core/kazoo_documents/src/kzd_box_message.erl @@ -89,7 +89,7 @@ %% we are moving the message to MODB. %% @end %%-------------------------------------------------------------------- --spec new(ne_binary(), kz_proplist()) -> doc(). +-spec new(kz_term:ne_binary(), kz_term:proplist()) -> doc(). new(AccountId, Props) -> UtcSeconds = props:get_integer_value(<<"Message-Timestamp">>, Props, kz_time:now_s()), Timestamp = props:get_integer_value(<<"Document-Timestamp">>, Props, UtcSeconds), @@ -127,7 +127,7 @@ new(AccountId, Props) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec create_message_name(ne_binary(), api_binary(), gregorian_seconds()) -> ne_binary(). +-spec create_message_name(kz_term:ne_binary(), kz_term:api_binary(), kz_time:gregorian_seconds()) -> kz_term:ne_binary(). create_message_name(BoxNum, 'undefined', UtcSeconds) -> create_message_name(BoxNum, kz_account:default_timezone(), UtcSeconds); create_message_name(BoxNum, Timezone, UtcSeconds) -> @@ -142,7 +142,7 @@ create_message_name(BoxNum, Timezone, UtcSeconds) -> message_name(BoxNum, LocalDateTime, "") end. --spec message_name(ne_binary(), kz_datetime(), string()) -> ne_binary(). +-spec message_name(kz_term:ne_binary(), kz_time:datetime(), string()) -> kz_term:ne_binary(). message_name(BoxNum, {{Y,M,D},{H,I,S}}, TZ) -> list_to_binary(["mailbox ", BoxNum, " message " ,kz_term:to_binary(M), "-" @@ -158,7 +158,7 @@ message_name(BoxNum, {{Y,M,D},{H,I,S}}, TZ) -> %% @doc Build message metadata %% @end %%-------------------------------------------------------------------- --spec build_metadata_object(pos_integer(), kapps_call:call(), ne_binary(), ne_binary(), ne_binary(), gregorian_seconds()) -> +-spec build_metadata_object(pos_integer(), kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_time:gregorian_seconds()) -> doc(). build_metadata_object(Length, Call, MediaId, CIDNumber, CIDName, Timestamp) -> kz_json:from_list( @@ -173,7 +173,7 @@ build_metadata_object(Length, Call, MediaId, CIDNumber, CIDName, Timestamp) -> ,{?KEY_MEDIA_ID, MediaId} ]). --spec get_msg_id(kz_json:object()) -> api_ne_binary(). +-spec get_msg_id(kz_json:object()) -> kz_term:api_ne_binary(). get_msg_id(JObj) -> Paths = [<<"_id">> ,<<"media_id">> @@ -186,10 +186,10 @@ get_msg_id(JObj) -> %% @doc Accessors methods %% @end %%-------------------------------------------------------------------- --spec type() -> ne_binary(). +-spec type() -> kz_term:ne_binary(). type() -> ?PVT_TYPE. --spec folder(doc()) -> api_ne_binary(). +-spec folder(doc()) -> kz_term:api_ne_binary(). folder(Metadata) -> folder(Metadata, 'undefined'). @@ -197,7 +197,7 @@ folder(Metadata) -> folder(Metadata, Default) -> kz_json:get_first_defined([[?KEY_METADATA, ?VM_KEY_FOLDER], ?VM_KEY_FOLDER], Metadata, Default). --spec set_folder(api_ne_binary(), doc()) -> doc(). +-spec set_folder(kz_term:api_ne_binary(), doc()) -> doc(). set_folder(Folder, Metadata) -> kz_json:set_value(?VM_KEY_FOLDER, Folder, Metadata). @@ -234,35 +234,35 @@ apply_folder(Folder, Doc) -> Metadata = set_folder(Folder, metadata(Doc)), set_metadata(Metadata, Doc). --spec message_history(doc()) -> ne_binaries(). +-spec message_history(doc()) -> kz_term:ne_binaries(). message_history(JObj) -> kz_json:get_value(?KEY_HISTORY, JObj, []). --spec add_message_history(ne_binary(), doc()) -> doc(). +-spec add_message_history(kz_term:ne_binary(), doc()) -> doc(). add_message_history(History, JObj) -> kz_json:set_value(?KEY_HISTORY, message_history(JObj) ++ [History], JObj). --spec message_name(doc()) -> api_binary(). +-spec message_name(doc()) -> kz_term:api_binary(). message_name(JObj) -> message_name(JObj, 'undefined'). --spec message_name(doc(), Default) -> api_binary() | Default. +-spec message_name(doc(), Default) -> kz_term:api_binary() | Default. message_name(JObj, Default) -> kz_json:get_value(?KEY_NAME, JObj, Default). --spec set_message_name(api_binary(), doc()) -> doc(). +-spec set_message_name(kz_term:api_binary(), doc()) -> doc(). set_message_name(Name, JObj) -> kz_json:set_value(?KEY_NAME, Name, JObj). --spec media_id(doc()) -> api_binary(). +-spec media_id(doc()) -> kz_term:api_binary(). media_id(Metadata) -> kz_json:get_value(?KEY_MEDIA_ID, Metadata). --spec set_media_id(ne_binary(), doc()) -> doc(). +-spec set_media_id(kz_term:ne_binary(), doc()) -> doc(). set_media_id(MediaId, Metadata) -> kz_json:set_value(?KEY_MEDIA_ID, MediaId, Metadata). --spec update_media_id(ne_binary(), doc()) -> doc(). +-spec update_media_id(kz_term:ne_binary(), doc()) -> doc(). update_media_id(MediaId, JObj) -> Metadata = set_media_id(MediaId, metadata(JObj)), set_metadata(Metadata, JObj). @@ -279,15 +279,15 @@ metadata(JObj, Default) -> set_metadata(Metadata, JObj) -> kz_json:set_value(?KEY_METADATA, Metadata, JObj). --spec to_sip(doc()) -> api_binary(). +-spec to_sip(doc()) -> kz_term:api_binary(). to_sip(JObj) -> to_sip(JObj, 'undefined'). --spec to_sip(doc(), Default) -> api_binary() | Default. +-spec to_sip(doc(), Default) -> kz_term:api_binary() | Default. to_sip(JObj, Default) -> kz_json:get_first_defined([[?KEY_METADATA, ?KEY_META_TO], ?KEY_META_TO], JObj, Default). --spec set_to_sip(api_binary(), doc()) -> doc(). +-spec set_to_sip(kz_term:api_binary(), doc()) -> doc(). set_to_sip(To, Metadata) -> kz_json:set_value(?KEY_META_TO, To, Metadata). @@ -295,11 +295,11 @@ set_to_sip(To, Metadata) -> utc_seconds(JObj) -> kz_json:get_integer_value(?KEY_UTC_SEC, JObj, 0). --spec source_id(doc()) -> api_ne_binary(). +-spec source_id(doc()) -> kz_term:api_ne_binary(). source_id(JObj) -> kz_json:get_ne_binary_value(?KEY_SOURCE_ID, JObj). --spec set_source_id(api_ne_binary(), doc()) -> doc(). +-spec set_source_id(kz_term:api_ne_binary(), doc()) -> doc(). set_source_id(SourceId, JObj) -> kz_json:set_value(?KEY_SOURCE_ID, SourceId, JObj). @@ -308,7 +308,7 @@ set_source_id(SourceId, JObj) -> %% @doc Filter messages based on specific folder %% @end %%-------------------------------------------------------------------- --spec filter_folder(kz_json:objects(), ne_binary()) -> kz_json:objects(). +-spec filter_folder(kz_json:objects(), kz_term:ne_binary()) -> kz_json:objects(). filter_folder(Messages, Folder) -> [M || M <- Messages, folder(M) =:= Folder]. @@ -317,7 +317,7 @@ filter_folder(Messages, Folder) -> %% @doc Count message list in specific folder(s) %% @end %%-------------------------------------------------------------------- --spec count_folder(kz_json:objects(), ne_binary() | ne_binaries()) -> non_neg_integer(). +-spec count_folder(kz_json:objects(), kz_term:ne_binary() | kz_term:ne_binaries()) -> non_neg_integer(). count_folder(Messages, Folders) when is_list(Folders) -> lists:sum([1 || Message <- Messages, begin @@ -347,7 +347,7 @@ change_message_name(NBoxJ, MsgJObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec change_to_sip_field(ne_binary(), doc(), doc()) -> doc(). +-spec change_to_sip_field(kz_term:ne_binary(), doc(), doc()) -> doc(). change_to_sip_field(AccountId, NBoxJ, MsgJObj) -> Realm = kz_account:fetch_realm(AccountId), BoxNum = kzd_voicemail_box:mailbox_number(NBoxJ), diff --git a/core/kazoo_documents/src/kzd_call_recording.erl b/core/kazoo_documents/src/kzd_call_recording.erl index d27c6dd1d3c..e880e3b36b9 100644 --- a/core/kazoo_documents/src/kzd_call_recording.erl +++ b/core/kazoo_documents/src/kzd_call_recording.erl @@ -42,44 +42,44 @@ new() -> kz_doc:set_type(kz_json_schema:default_object(?SCHEMA), type()). --spec type() -> ne_binary(). --spec type(doc()) -> ne_binary(). +-spec type() -> kz_term:ne_binary(). +-spec type(doc()) -> kz_term:ne_binary(). type() -> ?PVT_TYPE. type(Doc) -> kz_doc:type(Doc, ?PVT_TYPE). --spec name(doc()) -> ne_binary(). +-spec name(doc()) -> kz_term:ne_binary(). name(Doc) -> kz_json:get_ne_binary_value(<<"name">>, Doc). --spec description(doc()) -> ne_binary(). +-spec description(doc()) -> kz_term:ne_binary(). description(Doc) -> kz_json:get_ne_binary_value(<<"description">>, Doc). --spec content_type(doc()) -> ne_binary(). +-spec content_type(doc()) -> kz_term:ne_binary(). content_type(Doc) -> kz_json:get_ne_binary_value(<<"content_type">>, Doc). --spec media_type(doc()) -> ne_binary(). +-spec media_type(doc()) -> kz_term:ne_binary(). media_type(Doc) -> kz_json:get_ne_binary_value(<<"media_type">>, Doc). --spec media_source(doc()) -> ne_binary(). +-spec media_source(doc()) -> kz_term:ne_binary(). media_source(Doc) -> kz_json:get_ne_binary_value(<<"media_source">>, Doc). --spec source_type(doc()) -> ne_binary(). +-spec source_type(doc()) -> kz_term:ne_binary(). source_type(Doc) -> kz_json:get_ne_binary_value(<<"source_type">>, Doc). --spec from(doc()) -> ne_binary(). +-spec from(doc()) -> kz_term:ne_binary(). from(Doc) -> kz_json:get_ne_binary_value(<<"from">>, Doc). --spec to(doc()) -> ne_binary(). +-spec to(doc()) -> kz_term:ne_binary(). to(Doc) -> kz_json:get_ne_binary_value(<<"to">>, Doc). --spec request(doc()) -> ne_binary(). +-spec request(doc()) -> kz_term:ne_binary(). request(Doc) -> kz_json:get_ne_binary_value(<<"request">>, Doc). --spec direction(doc()) -> ne_binary(). +-spec direction(doc()) -> kz_term:ne_binary(). direction(Doc) -> kz_json:get_ne_binary_value(<<"direction">>, Doc). --spec start(doc()) -> gregorian_seconds(). +-spec start(doc()) -> kz_time:gregorian_seconds(). start(Doc) -> kz_json:get_integer_value(<<"start">>, Doc). -spec duration(doc()) -> non_neg_integer(). @@ -88,34 +88,34 @@ duration(Doc) -> kz_json:get_integer_value(<<"duration">>, Doc). -spec duration_ms(doc()) -> non_neg_integer(). duration_ms(Doc) -> kz_json:get_integer_value(<<"duration_ms">>, Doc). --spec caller_id_number(doc()) -> ne_binary(). +-spec caller_id_number(doc()) -> kz_term:ne_binary(). caller_id_number(Doc) -> kz_json:get_ne_binary_value(<<"caller_id_number">>, Doc). --spec caller_id_name(doc()) -> ne_binary(). +-spec caller_id_name(doc()) -> kz_term:ne_binary(). caller_id_name(Doc) -> kz_json:get_ne_binary_value(<<"caller_id_name">>, Doc). --spec callee_id_number(doc()) -> ne_binary(). +-spec callee_id_number(doc()) -> kz_term:ne_binary(). callee_id_number(Doc) -> kz_json:get_ne_binary_value(<<"callee_id_number">>, Doc). --spec callee_id_name(doc()) -> ne_binary(). +-spec callee_id_name(doc()) -> kz_term:ne_binary(). callee_id_name(Doc) -> kz_json:get_ne_binary_value(<<"callee_id_name">>, Doc). --spec call_id(doc()) -> ne_binary(). +-spec call_id(doc()) -> kz_term:ne_binary(). call_id(Doc) -> kz_json:get_ne_binary_value(<<"call_id">>, Doc). --spec owner_id(doc()) -> ne_binary(). +-spec owner_id(doc()) -> kz_term:ne_binary(). owner_id(Doc) -> kz_json:get_ne_binary_value(<<"owner_id">>, Doc). --spec url(doc()) -> ne_binary(). +-spec url(doc()) -> kz_term:ne_binary(). url(Doc) -> kz_json:get_ne_binary_value(<<"url">>, Doc). --spec cdr_id(doc()) -> ne_binary(). +-spec cdr_id(doc()) -> kz_term:ne_binary(). cdr_id(Doc) -> kz_json:get_ne_binary_value(<<"cdr_id">>, Doc). --spec interaction_id(doc()) -> ne_binary(). +-spec interaction_id(doc()) -> kz_term:ne_binary(). interaction_id(Doc) -> kz_json:get_ne_binary_value(<<"interaction_id">>, Doc). --spec origin(doc()) -> ne_binary(). +-spec origin(doc()) -> kz_term:ne_binary(). origin(Doc) -> kz_json:get_ne_binary_value(<<"origin">>, Doc). -spec custom_channel_vars(doc()) -> kz_json:object(). diff --git a/core/kazoo_documents/src/kzd_callflow.erl b/core/kazoo_documents/src/kzd_callflow.erl index 5ad34ba03cb..d96acdc18b2 100644 --- a/core/kazoo_documents/src/kzd_callflow.erl +++ b/core/kazoo_documents/src/kzd_callflow.erl @@ -49,7 +49,7 @@ new() -> %% %% @end %%-------------------------------------------------------------------- --spec type() -> ne_binary(). +-spec type() -> kz_term:ne_binary(). type() -> ?PVT_TYPE. %%-------------------------------------------------------------------- @@ -58,11 +58,11 @@ type() -> ?PVT_TYPE. %% %% @end %%-------------------------------------------------------------------- --spec numbers(doc()) -> ne_binaries(). +-spec numbers(doc()) -> kz_term:ne_binaries(). numbers(Doc) -> kz_json:get_value(?NUMBERS, Doc, []). --spec set_numbers(doc(), ne_binaries()) -> doc(). +-spec set_numbers(doc(), kz_term:ne_binaries()) -> doc(). set_numbers(Doc, Numbers) -> kz_json:set_value(?NUMBERS, Numbers, Doc). @@ -72,11 +72,11 @@ set_numbers(Doc, Numbers) -> %% %% @end %%-------------------------------------------------------------------- --spec patterns(doc()) -> ne_binaries(). +-spec patterns(doc()) -> kz_term:ne_binaries(). patterns(Doc) -> kz_json:get_value(?PATTERNS, Doc, []). --spec set_patterns(doc(), ne_binaries()) -> doc(). +-spec set_patterns(doc(), kz_term:ne_binaries()) -> doc(). set_patterns(Doc, Patterns) -> kz_json:set_value(?PATTERNS, Patterns, Doc). @@ -96,7 +96,7 @@ is_feature_code(Doc) -> %% %% @end %%-------------------------------------------------------------------- --spec flow(doc()) -> api_object(). +-spec flow(doc()) -> kz_term:api_object(). -spec flow(doc(), Default) -> kz_json:object() | Default. flow(Doc) -> flow(Doc, 'undefined'). @@ -143,7 +143,7 @@ validate_flow(Doc) -> end. -endif. --spec prepend_preflow(doc(), ne_binary()) -> doc(). +-spec prepend_preflow(doc(), kz_term:ne_binary()) -> doc(). prepend_preflow(Callflow, PreflowId) -> AmendedFlow = kz_json:from_list([{<<"module">>, <<"callflow">>} diff --git a/core/kazoo_documents/src/kzd_conference.erl b/core/kazoo_documents/src/kzd_conference.erl index c6b0d638a8f..a61e4ad9108 100644 --- a/core/kazoo_documents/src/kzd_conference.erl +++ b/core/kazoo_documents/src/kzd_conference.erl @@ -28,5 +28,5 @@ new() -> %% %% @end %%-------------------------------------------------------------------- --spec type() -> ne_binary(). +-spec type() -> kz_term:ne_binary(). type() -> ?PVT_TYPE. diff --git a/core/kazoo_documents/src/kzd_domains.erl b/core/kazoo_documents/src/kzd_domains.erl index b07fff03125..aa9c1b89a99 100644 --- a/core/kazoo_documents/src/kzd_domains.erl +++ b/core/kazoo_documents/src/kzd_domains.erl @@ -72,26 +72,26 @@ new() -> default() -> kz_json:load_fixture_from_file(?APP, "fixtures", "domains.json"). --spec cname(doc()) -> api_object(). +-spec cname(doc()) -> kz_term:api_object(). -spec cname(doc(), Default) -> kz_json:object() | Default. cname(Domains) -> cname(Domains, 'undefined'). cname(Domains, Default) -> kz_json:get_json_value(?KEY_CNAME, Domains, Default). --spec cname_hosts(doc()) -> ne_binaries(). +-spec cname_hosts(doc()) -> kz_term:ne_binaries(). cname_hosts(Domains) -> kz_json:get_keys(?KEY_CNAME, Domains). --spec cname_host(doc(), ne_binary()) -> api_object(). --spec cname_host(doc(), ne_binary(), Default) -> kz_json:object() | Default. +-spec cname_host(doc(), kz_term:ne_binary()) -> kz_term:api_object(). +-spec cname_host(doc(), kz_term:ne_binary(), Default) -> kz_json:object() | Default. cname_host(Domains, Host) -> cname_host(Domains, Host, 'undefined'). cname_host(Domains, Host, Default) -> kz_json:get_value([?KEY_CNAME, Host], Domains, Default). --spec cname_host_mappings(doc(), ne_binary()) -> ne_binaries(). --spec cname_host_mappings(doc(), ne_binary(), Default) -> ne_binaries() | Default. +-spec cname_host_mappings(doc(), kz_term:ne_binary()) -> kz_term:ne_binaries(). +-spec cname_host_mappings(doc(), kz_term:ne_binary(), Default) -> kz_term:ne_binaries() | Default. cname_host_mappings(Domains, Host) -> cname_host_mappings(Domains, Host, []). @@ -102,30 +102,30 @@ cname_host_mappings(Domains, Host, Default) -> set_cname(Domains, CNAME) -> kz_json:set_value(?KEY_CNAME, CNAME, Domains). --spec add_cname_host(doc(), ne_binary(), kz_json:object()) -> doc(). +-spec add_cname_host(doc(), kz_term:ne_binary(), kz_json:object()) -> doc(). add_cname_host(Domains, Host, Settings) -> kz_json:set_value([?KEY_CNAME, Host], Settings, Domains). --spec a_record(doc()) -> api_object(). +-spec a_record(doc()) -> kz_term:api_object(). -spec a_record(doc(), Default) -> kz_json:object() | Default. a_record(Domains) -> a_record(Domains, 'undefined'). a_record(Domains, Default) -> kz_json:get_json_value(?KEY_A_RECORD, Domains, Default). --spec a_record_hosts(doc()) -> ne_binaries(). +-spec a_record_hosts(doc()) -> kz_term:ne_binaries(). a_record_hosts(Domains) -> kz_json:get_keys(?KEY_A_RECORD, Domains). --spec a_record_host(doc(), ne_binary()) -> api_object(). --spec a_record_host(doc(), ne_binary(), Default) -> kz_json:object() | Default. +-spec a_record_host(doc(), kz_term:ne_binary()) -> kz_term:api_object(). +-spec a_record_host(doc(), kz_term:ne_binary(), Default) -> kz_json:object() | Default. a_record_host(Domains, Host) -> a_record_host(Domains, Host, 'undefined'). a_record_host(Domains, Host, Default) -> kz_json:get_value([?KEY_A_RECORD, Host], Domains, Default). --spec a_record_host_mappings(doc(), ne_binary()) -> ne_binaries(). --spec a_record_host_mappings(doc(), ne_binary(), Default) -> ne_binaries() | Default. +-spec a_record_host_mappings(doc(), kz_term:ne_binary()) -> kz_term:ne_binaries(). +-spec a_record_host_mappings(doc(), kz_term:ne_binary(), Default) -> kz_term:ne_binaries() | Default. a_record_host_mappings(Domains, Host) -> a_record_host_mappings(Domains, Host, []). @@ -136,30 +136,30 @@ a_record_host_mappings(Domains, Host, Default) -> set_a_record(Domains, A_RECORD) -> kz_json:set_value(?KEY_A_RECORD, A_RECORD, Domains). --spec add_a_record_host(doc(), ne_binary(), kz_json:object()) -> doc(). +-spec add_a_record_host(doc(), kz_term:ne_binary(), kz_json:object()) -> doc(). add_a_record_host(Domains, Host, Settings) -> kz_json:set_value([?KEY_A_RECORD, Host], Settings, Domains). --spec naptr(doc()) -> api_object(). +-spec naptr(doc()) -> kz_term:api_object(). -spec naptr(doc(), Default) -> kz_json:object() | Default. naptr(Domains) -> naptr(Domains, 'undefined'). naptr(Domains, Default) -> kz_json:get_json_value(?KEY_NAPTR, Domains, Default). --spec naptr_hosts(doc()) -> ne_binaries(). +-spec naptr_hosts(doc()) -> kz_term:ne_binaries(). naptr_hosts(Domains) -> kz_json:get_keys(?KEY_NAPTR, Domains). --spec naptr_host(doc(), ne_binary()) -> api_object(). --spec naptr_host(doc(), ne_binary(), Default) -> kz_json:object() | Default. +-spec naptr_host(doc(), kz_term:ne_binary()) -> kz_term:api_object(). +-spec naptr_host(doc(), kz_term:ne_binary(), Default) -> kz_json:object() | Default. naptr_host(Domains, Host) -> naptr_host(Domains, Host, 'undefined'). naptr_host(Domains, Host, Default) -> kz_json:get_value([?KEY_NAPTR, Host], Domains, Default). --spec naptr_host_mappings(doc(), ne_binary()) -> ne_binaries(). --spec naptr_host_mappings(doc(), ne_binary(), Default) -> ne_binaries() | Default. +-spec naptr_host_mappings(doc(), kz_term:ne_binary()) -> kz_term:ne_binaries(). +-spec naptr_host_mappings(doc(), kz_term:ne_binary(), Default) -> kz_term:ne_binaries() | Default. naptr_host_mappings(Domains, Host) -> naptr_host_mappings(Domains, Host, []). @@ -170,30 +170,30 @@ naptr_host_mappings(Domains, Host, Default) -> set_naptr(Domains, NAPTR) -> kz_json:set_value(?KEY_NAPTR, NAPTR, Domains). --spec add_naptr_host(doc(), ne_binary(), kz_json:object()) -> doc(). +-spec add_naptr_host(doc(), kz_term:ne_binary(), kz_json:object()) -> doc(). add_naptr_host(Domains, Host, Settings) -> kz_json:set_value([?KEY_NAPTR, Host], Settings, Domains). --spec srv(doc()) -> api_object(). +-spec srv(doc()) -> kz_term:api_object(). -spec srv(doc(), Default) -> kz_json:object() | Default. srv(Domains) -> srv(Domains, 'undefined'). srv(Domains, Default) -> kz_json:get_json_value(?KEY_SRV, Domains, Default). --spec srv_hosts(doc()) -> ne_binaries(). +-spec srv_hosts(doc()) -> kz_term:ne_binaries(). srv_hosts(Domains) -> kz_json:get_keys(?KEY_SRV, Domains). --spec srv_host(doc(), ne_binary()) -> api_object(). --spec srv_host(doc(), ne_binary(), Default) -> kz_json:object() | Default. +-spec srv_host(doc(), kz_term:ne_binary()) -> kz_term:api_object(). +-spec srv_host(doc(), kz_term:ne_binary(), Default) -> kz_json:object() | Default. srv_host(Domains, Host) -> srv_host(Domains, Host, 'undefined'). srv_host(Domains, Host, Default) -> kz_json:get_value([?KEY_SRV, Host], Domains, Default). --spec srv_host_mappings(doc(), ne_binary()) -> ne_binaries(). --spec srv_host_mappings(doc(), ne_binary(), Default) -> ne_binaries() | Default. +-spec srv_host_mappings(doc(), kz_term:ne_binary()) -> kz_term:ne_binaries(). +-spec srv_host_mappings(doc(), kz_term:ne_binary(), Default) -> kz_term:ne_binaries() | Default. srv_host_mappings(Domains, Host) -> srv_host_mappings(Domains, Host, []). @@ -204,14 +204,14 @@ srv_host_mappings(Domains, Host, Default) -> set_srv(Domains, SRV) -> kz_json:set_value(?KEY_SRV, SRV, Domains). --spec add_srv_host(doc(), ne_binary(), kz_json:object()) -> doc(). +-spec add_srv_host(doc(), kz_term:ne_binary(), kz_json:object()) -> doc(). add_srv_host(Domains, Host, Settings) -> kz_json:set_value([?KEY_SRV, Host], Settings, Domains). -spec save(doc()) -> {'ok', doc()} | {'error', any()}. --spec save(doc(), api_object()) -> {'ok', doc()} | - {'error', any()}. +-spec save(doc(), kz_term:api_object()) -> {'ok', doc()} | + {'error', any()}. save(Domains) -> save(Domains, 'undefined'). save(Domains, PvtFields) -> @@ -222,8 +222,8 @@ save(Domains, PvtFields) -> {'error', Errors} end. --spec try_save(doc(), api_object()) -> {'ok', doc()} | - {'error', any()}. +-spec try_save(doc(), kz_term:api_object()) -> {'ok', doc()} | + {'error', any()}. try_save(Domains, PvtFields) -> case kapps_config:update_default(<<"whitelabel">> ,<<"domains">> @@ -256,7 +256,7 @@ is_valid(Domains, {'ok', SchemaJObj}) -> {'false', Errors} end. --spec format(doc(), ne_binary()) -> doc(). +-spec format(doc(), kz_term:ne_binary()) -> doc(). format(Domains, WhitelabelDomain) -> kz_json:map(fun(DomainType, DomainConfig) -> format_domain_type(DomainType, DomainConfig, WhitelabelDomain) @@ -264,8 +264,8 @@ format(Domains, WhitelabelDomain) -> ,Domains ). --spec format_domain_type(ne_binary(), kz_json:object(), ne_binary()) -> - {ne_binary(), kz_json:object()}. +-spec format_domain_type(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> + {kz_term:ne_binary(), kz_json:object()}. format_domain_type(DomainType, DomainConfig, WhitelabelDomain) -> {DomainType ,kz_json:map(fun(Host, HostConfig) -> @@ -275,14 +275,14 @@ format_domain_type(DomainType, DomainConfig, WhitelabelDomain) -> ) }. --spec format_host_config(ne_binary(), kz_json:object(), ne_binary()) -> - {ne_binary(), kz_json:object()}. +-spec format_host_config(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> + {kz_term:ne_binary(), kz_json:object()}. format_host_config(Host, HostConfig, WhitelabelDomain) -> {format_host(Host, WhitelabelDomain) ,format_host_mappings(HostConfig, WhitelabelDomain) }. --spec format_host_mappings(kz_json:object(), ne_binary()) -> +-spec format_host_mappings(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). format_host_mappings(HostConfig, WhitelabelDomain) -> Mappings = @@ -291,18 +291,18 @@ format_host_mappings(HostConfig, WhitelabelDomain) -> ], kz_json:set_value(?KEY_MAPPINGS, Mappings, HostConfig). --spec format_host(ne_binary(), ne_binary()) -> ne_binary(). +-spec format_host(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). format_host(DomainHost, WhitelabelDomain) -> binary:replace(DomainHost, ?DOMAIN_PLACEHOLDER, WhitelabelDomain). --spec format_mapping(ne_binary(), ne_binary()) -> ne_binary(). +-spec format_mapping(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). format_mapping(Mapping, WhitelabelDomain) -> binary:replace(Mapping, ?DOMAIN_PLACEHOLDER, WhitelabelDomain). --spec mappings(kz_json:object()) -> ne_binaries(). +-spec mappings(kz_json:object()) -> kz_term:ne_binaries(). mappings(JObj) -> kz_json:get_value(?KEY_MAPPINGS, JObj). --spec name(kz_json:object()) -> api_binary(). +-spec name(kz_json:object()) -> kz_term:api_binary(). name(JObj) -> kz_json:get_value(?KEY_NAME, JObj). diff --git a/core/kazoo_documents/src/kzd_fax.erl b/core/kazoo_documents/src/kzd_fax.erl index a52e5c4d296..6c266f44f71 100644 --- a/core/kazoo_documents/src/kzd_fax.erl +++ b/core/kazoo_documents/src/kzd_fax.erl @@ -66,67 +66,67 @@ new() -> kz_json:from_list([{<<"pvt_type">>, type()}]). --spec type() -> ne_binary(). +-spec type() -> kz_term:ne_binary(). type() -> ?PVT_TYPE. --spec owner_id(doc()) -> api_binary(). --spec owner_id(doc(), Default) -> ne_binary() | Default. +-spec owner_id(doc()) -> kz_term:api_binary(). +-spec owner_id(doc(), Default) -> kz_term:ne_binary() | Default. owner_id(FaxDoc) -> owner_id(FaxDoc, 'undefined'). owner_id(FaxDoc, Default) -> kz_json:get_value(?KEY_OWNER_ID, FaxDoc, Default). --spec faxbox_id(doc()) -> api_binary(). --spec faxbox_id(doc(), Default) -> ne_binary() | Default. +-spec faxbox_id(doc()) -> kz_term:api_binary(). +-spec faxbox_id(doc(), Default) -> kz_term:ne_binary() | Default. faxbox_id(FaxDoc) -> faxbox_id(FaxDoc, 'undefined'). faxbox_id(FaxDoc, Default) -> kz_json:get_value(?KEY_FAXBOX_ID, FaxDoc, Default). --spec timezone(doc()) -> api_binary(). --spec timezone(doc(), Default) -> ne_binary() | Default. +-spec timezone(doc()) -> kz_term:api_binary(). +-spec timezone(doc(), Default) -> kz_term:ne_binary() | Default. timezone(FaxDoc) -> timezone(FaxDoc, 'undefined'). timezone(FaxDoc, Default) -> kz_json:get_value(?KEY_TIMEZONE, FaxDoc, Default). --spec retries(doc()) -> api_integer(). +-spec retries(doc()) -> kz_term:api_integer(). -spec retries(doc(), Default) -> integer() | Default. retries(FaxDoc) -> retries(FaxDoc, 'undefined'). retries(FaxDoc, Default) -> kz_json:get_integer_value(?KEY_RETRIES, FaxDoc, Default). --spec attempts(doc()) -> api_integer(). +-spec attempts(doc()) -> kz_term:api_integer(). -spec attempts(doc(), Default) -> integer() | Default. attempts(FaxDoc) -> attempts(FaxDoc, 'undefined'). attempts(FaxDoc, Default) -> kz_json:get_integer_value(?KEY_ATTEMPTS, FaxDoc, Default). --spec from_number(doc()) -> api_binary(). --spec from_number(doc(), Default) -> api_binary() | Default. +-spec from_number(doc()) -> kz_term:api_binary(). +-spec from_number(doc(), Default) -> kz_term:api_binary() | Default. from_number(FaxDoc) -> from_number(FaxDoc, 'undefined'). from_number(FaxDoc, Default) -> kz_json:get_value(?KEY_FROM_NUMBER, FaxDoc, Default). --spec to_number(doc()) -> api_binary(). --spec to_number(doc(), Default) -> api_binary() | Default. +-spec to_number(doc()) -> kz_term:api_binary(). +-spec to_number(doc(), Default) -> kz_term:api_binary() | Default. to_number(FaxDoc) -> to_number(FaxDoc, 'undefined'). to_number(FaxDoc, Default) -> kz_json:get_value(?KEY_TO_NUMBER, FaxDoc, Default). --spec from_name(doc()) -> api_binary(). --spec from_name(doc(), Default) -> api_binary() | Default. +-spec from_name(doc()) -> kz_term:api_binary(). +-spec from_name(doc(), Default) -> kz_term:api_binary() | Default. from_name(FaxDoc) -> from_name(FaxDoc, 'undefined'). from_name(FaxDoc, Default) -> kz_json:get_value(?KEY_FROM_NAME, FaxDoc, Default). --spec to_name(doc()) -> api_binary(). --spec to_name(doc(), Default) -> api_binary() | Default. +-spec to_name(doc()) -> kz_term:api_binary(). +-spec to_name(doc(), Default) -> kz_term:api_binary() | Default. to_name(FaxDoc) -> to_name(FaxDoc, 'undefined'). to_name(FaxDoc, Default) -> @@ -136,8 +136,8 @@ to_name(FaxDoc, Default) -> notifications(FaxDoc) -> kz_json:get_value(?KEY_NOTIFICATIONS, FaxDoc, kz_json:new()). --spec folder(doc()) -> api_binary(). --spec folder(doc(), Default) -> api_binary() | Default. +-spec folder(doc()) -> kz_term:api_binary(). +-spec folder(doc(), Default) -> kz_term:api_binary() | Default. folder(FaxDoc) -> folder(FaxDoc, 'undefined'). folder(FaxDoc, Default) -> @@ -151,15 +151,15 @@ document(FaxDoc) -> document_url(FaxDoc) -> kz_json:get_value(?KEY_DOCUMENT_URL, FaxDoc). --spec identity_name(doc()) -> api_binary(). --spec identity_name(doc(), Default) -> api_binary() | Default. +-spec identity_name(doc()) -> kz_term:api_binary(). +-spec identity_name(doc(), Default) -> kz_term:api_binary() | Default. identity_name(FaxDoc) -> identity_name(FaxDoc, 'undefined'). identity_name(FaxDoc, Default) -> kz_json:get_value(?KEY_IDENTITY_NAME, FaxDoc, Default). --spec identity_number(doc()) -> api_binary(). --spec identity_number(doc(), Default) -> api_binary() | Default. +-spec identity_number(doc()) -> kz_term:api_binary(). +-spec identity_number(doc(), Default) -> kz_term:api_binary() | Default. identity_number(FaxDoc) -> identity_number(FaxDoc, 'undefined'). identity_number(FaxDoc, Default) -> @@ -177,35 +177,35 @@ rx_result(FaxDoc) -> result(FaxDoc) -> kz_json:get_first_defined([?KEY_RX_RESULT, ?KEY_TX_RESULT], FaxDoc, kz_json:new()). --spec job_node(doc()) -> api_binary(). --spec job_node(doc(), Default) -> api_binary() | Default. +-spec job_node(doc()) -> kz_term:api_binary(). +-spec job_node(doc(), Default) -> kz_term:api_binary() | Default. job_node(FaxDoc) -> job_node(FaxDoc, 'undefined'). job_node(FaxDoc, Default) -> kz_json:get_value(?KEY_JOB_NODE, FaxDoc, Default). --spec job_status(doc()) -> api_binary(). --spec job_status(doc(), Default) -> api_binary() | Default. +-spec job_status(doc()) -> kz_term:api_binary(). +-spec job_status(doc(), Default) -> kz_term:api_binary() | Default. job_status(FaxDoc) -> job_status(FaxDoc, 'undefined'). job_status(FaxDoc, Default) -> kz_json:get_value(?KEY_JOB_STATUS, FaxDoc, Default). --spec size(doc()) -> api_integer(). +-spec size(doc()) -> kz_term:api_integer(). -spec size(doc(), Default) -> integer() | Default. size(FaxDoc) -> size(FaxDoc, 'undefined'). size(FaxDoc, Default) -> kz_json:get_integer_value(?KEY_SIZE, FaxDoc, Default). --spec pages(doc()) -> api_integer(). +-spec pages(doc()) -> kz_term:api_integer(). -spec pages(doc(), Default) -> integer() | Default. pages(FaxDoc) -> pages(FaxDoc, 'undefined'). pages(FaxDoc, Default) -> kz_json:get_integer_value(?KEY_PAGES, FaxDoc, Default). --spec retry_after(doc()) -> api_integer(). +-spec retry_after(doc()) -> kz_term:api_integer(). -spec retry_after(doc(), Default) -> integer() | Default. retry_after(FaxDoc) -> retry_after(FaxDoc, 'undefined'). diff --git a/core/kazoo_documents/src/kzd_fax_box.erl b/core/kazoo_documents/src/kzd_fax_box.erl index 22ee32659aa..81f04a2c95b 100644 --- a/core/kazoo_documents/src/kzd_fax_box.erl +++ b/core/kazoo_documents/src/kzd_fax_box.erl @@ -30,21 +30,21 @@ new() -> kz_json:from_list([{<<"pvt_type">>, type()}]). --spec type() -> ne_binary(). +-spec type() -> kz_term:ne_binary(). type() -> ?PVT_TYPE. --spec owner_id(doc()) -> api_binary(). --spec owner_id(doc(), Default) -> ne_binary() | Default. +-spec owner_id(doc()) -> kz_term:api_binary(). +-spec owner_id(doc(), Default) -> kz_term:ne_binary() | Default. owner_id(Box) -> owner_id(Box, 'undefined'). owner_id(Box, Default) -> kz_json:get_value(?KEY_OWNER_ID, Box, Default). --spec timezone(doc()) -> ne_binary(). +-spec timezone(doc()) -> kz_term:ne_binary(). timezone(Box) -> timezone(Box, 'undefined'). --spec timezone(doc(), Default) -> ne_binary() | Default. +-spec timezone(doc(), Default) -> kz_term:ne_binary() | Default. timezone(Box, Default) -> case kz_json:get_value(?KEY_TIMEZONE, Box) of 'undefined' -> owner_timezone(Box, Default); @@ -52,14 +52,14 @@ timezone(Box, Default) -> TZ -> TZ end. --spec owner_timezone(doc(), Default) -> ne_binary() | Default. +-spec owner_timezone(doc(), Default) -> kz_term:ne_binary() | Default. owner_timezone(Box, Default) -> case kzd_user:fetch(kz_doc:account_db(Box), owner_id(Box)) of {'ok', OwnerJObj} -> kzd_user:timezone(OwnerJObj, Default); {'error', _} -> kz_account:timezone(kz_doc:account_id(Box), Default) end. --spec retries(doc()) -> api_integer(). +-spec retries(doc()) -> kz_term:api_integer(). -spec retries(doc(), Default) -> integer() | Default. retries(Box) -> retries(Box, 'undefined'). diff --git a/core/kazoo_documents/src/kzd_freeswitch.erl b/core/kazoo_documents/src/kzd_freeswitch.erl index 516e6b29f14..96699c7800a 100644 --- a/core/kazoo_documents/src/kzd_freeswitch.erl +++ b/core/kazoo_documents/src/kzd_freeswitch.erl @@ -55,15 +55,15 @@ -include("kz_documents.hrl"). --type data() :: kz_proplist(). +-type data() :: kz_term:proplist(). -export_type([data/0]). -define(CHANNEL_VAR_PREFIX, "ecallmgr_"). -define(CCV(Key), <<"variable_", ?CHANNEL_VAR_PREFIX, Key/binary>>). -define(CCV_HEADER(Key), <<"variable_sip_h_X-", ?CHANNEL_VAR_PREFIX, Key/binary>>). --spec caller_id_name(data()) -> api_binary(). --spec caller_id_name(data(), Default) -> ne_binary() | Default. +-spec caller_id_name(data()) -> kz_term:api_binary(). +-spec caller_id_name(data(), Default) -> kz_term:ne_binary() | Default. caller_id_name(Props) -> caller_id_name(Props, 'undefined'). caller_id_name(Props, Default) -> @@ -75,8 +75,8 @@ caller_id_name(Props, Default) -> ,Default ). --spec caller_id_number(data()) -> api_binary(). --spec caller_id_number(data(), Default) -> ne_binary() | Default. +-spec caller_id_number(data()) -> kz_term:api_binary(). +-spec caller_id_number(data(), Default) -> kz_term:ne_binary() | Default. caller_id_number(Props) -> caller_id_number(Props, 'undefined'). caller_id_number(Props, Default) -> @@ -88,8 +88,8 @@ caller_id_number(Props, Default) -> ,Default ). --spec callee_id_name(data()) -> api_binary(). --spec callee_id_name(data(), Default) -> ne_binary() | Default. +-spec callee_id_name(data()) -> kz_term:api_binary(). +-spec callee_id_name(data(), Default) -> kz_term:ne_binary() | Default. callee_id_name(Props) -> callee_id_name(Props, 'undefined'). callee_id_name(Props, Default) -> @@ -101,8 +101,8 @@ callee_id_name(Props, Default) -> ,Default ). --spec callee_id_number(data()) -> api_binary(). --spec callee_id_number(data(), Default) -> ne_binary() | Default. +-spec callee_id_number(data()) -> kz_term:api_binary(). +-spec callee_id_number(data(), Default) -> kz_term:ne_binary() | Default. callee_id_number(Props) -> callee_id_number(Props, 'undefined'). callee_id_number(Props, Default) -> @@ -114,7 +114,7 @@ callee_id_number(Props, Default) -> ,Default ). --spec dialed_number(data()) -> api_binary(). +-spec dialed_number(data()) -> kz_term:api_binary(). dialed_number(Props) -> props:get_first_defined([<<"variable_destination_number">> ,<<"Caller-Destination-Number">> @@ -122,7 +122,7 @@ dialed_number(Props) -> ,Props ). --spec call_id(data()) -> api_binary(). +-spec call_id(data()) -> kz_term:api_binary(). call_id(Props) -> props:get_first_defined([<<"Caller-Unique-ID">> ,<<"Unique-ID">> @@ -133,15 +133,15 @@ call_id(Props) -> ,?RESIGNING_UUID ], Props). --spec other_leg_call_id(data()) -> api_binary(). +-spec other_leg_call_id(data()) -> kz_term:api_binary(). other_leg_call_id(Props) -> props:get_value(<<"Other-Leg-Unique-ID">>, Props). --spec original_call_direction(data()) -> api_binary(). +-spec original_call_direction(data()) -> kz_term:api_binary(). original_call_direction(Props) -> props:get_value(<<"Call-Direction">>, Props). --spec call_direction(data()) -> api_binary(). +-spec call_direction(data()) -> kz_term:api_binary(). call_direction(Props) -> props:get_first_defined([<<"Application-Logical-Direction">> ,?CCV(<<"Application-Logical-Direction">>) @@ -150,23 +150,23 @@ call_direction(Props) -> ,Props ). --spec resource_type(data()) -> api_binary(). --spec resource_type(data(), Default) -> ne_binary() | Default. +-spec resource_type(data()) -> kz_term:api_binary(). +-spec resource_type(data(), Default) -> kz_term:ne_binary() | Default. resource_type(Props) -> resource_type(Props, 'undefined'). resource_type(Props, Default) -> props:get_value(<<"Resource-Type">>, Props, Default). --spec channel_authorized(data()) -> api_binary(). +-spec channel_authorized(data()) -> kz_term:api_binary(). channel_authorized(Props) -> ccv(Props, <<"Channel-Authorized">>). --spec outbound_flags(data()) -> api_binary() | ne_binaries(). +-spec outbound_flags(data()) -> kz_term:api_binary() | kz_term:ne_binaries(). outbound_flags(Props) -> ccv(Props, <<"Outbound-Flags">>). --spec hunt_destination_number(data()) -> api_binary(). +-spec hunt_destination_number(data()) -> kz_term:api_binary(). hunt_destination_number(Props) -> props:get_value(<<"Hunt-Destination-Number">>, Props). @@ -178,51 +178,51 @@ is_channel_recovering(Props) -> is_channel_recovering(Props, Default) -> props:is_true(<<"variable_recovered">>, Props, Default). --spec is_consuming_global_resource(data()) -> api_boolean(). --spec is_consuming_global_resource(data(), api_boolean()) -> api_boolean(). +-spec is_consuming_global_resource(data()) -> kz_term:api_boolean(). +-spec is_consuming_global_resource(data(), kz_term:api_boolean()) -> kz_term:api_boolean(). is_consuming_global_resource(Props) -> is_consuming_global_resource(Props, 'undefined'). is_consuming_global_resource(Props, Default) -> kz_term:is_true(ccv(Props, <<"Global-Resource">>, Default)). --spec resource_id(data()) -> api_binary(). +-spec resource_id(data()) -> kz_term:api_binary(). resource_id(Props) -> ccv(Props, <<"Resource-ID">>). --spec authorizing_id(data()) -> api_binary(). +-spec authorizing_id(data()) -> kz_term:api_binary(). authorizing_id(Props) -> ccv(Props, <<"Authorizing-ID">>). --spec authorizing_type(data()) -> api_binary(). +-spec authorizing_type(data()) -> kz_term:api_binary(). authorizing_type(Props) -> ccv(Props, <<"Authorizing-Type">>). --spec account_id(data()) -> api_binary(). +-spec account_id(data()) -> kz_term:api_binary(). account_id(Props) -> ccv(Props, <<"Account-ID">>). --spec account_billing(data()) -> api_binary(). +-spec account_billing(data()) -> kz_term:api_binary(). account_billing(Props) -> ccv(Props, <<"Account-Billing">>). --spec account_trunk_usage(data()) -> api_binary(). +-spec account_trunk_usage(data()) -> kz_term:api_binary(). account_trunk_usage(Props) -> ccv(Props, <<"Account-Trunk-Usage">>). --spec reseller_id(data()) -> api_binary(). +-spec reseller_id(data()) -> kz_term:api_binary(). reseller_id(Props) -> ccv(Props, <<"Reseller-ID">>). --spec reseller_billing(data()) -> api_binary(). +-spec reseller_billing(data()) -> kz_term:api_binary(). reseller_billing(Props) -> ccv(Props, <<"Reseller-Billing">>). --spec reseller_trunk_usage(data()) -> api_binary(). +-spec reseller_trunk_usage(data()) -> kz_term:api_binary(). reseller_trunk_usage(Props) -> ccv(Props, <<"Reseller-Trunk-Usage">>). --spec to_did(data()) -> api_binary(). +-spec to_did(data()) -> kz_term:api_binary(). to_did(Props) -> props:get_first_defined([?CCV(<<"E164-Destination">>) ,?CCV(<<"Original-Number">>) @@ -231,27 +231,27 @@ to_did(Props) -> ,Props ). --spec ccv(data(), ne_binary()) -> api_binary() | ne_binaries(). +-spec ccv(data(), kz_term:ne_binary()) -> kz_term:api_binary() | kz_term:ne_binaries(). ccv(Props, Key) -> ccv(Props, Key, 'undefined'). --spec ccv(data(), ne_binary(), Default) -> ne_binary() | ne_binaries() | Default. +-spec ccv(data(), kz_term:ne_binary(), Default) -> kz_term:ne_binary() | kz_term:ne_binaries() | Default. ccv(Props, Key, Default) -> props:get_value(Key, ccvs(Props), Default). --spec hangup_code(data()) -> api_binary(). +-spec hangup_code(data()) -> kz_term:api_binary(). hangup_code(Props) -> props:get_first_defined([<<"variable_proto_specific_hangup_cause">> ,<<"variable_last_bridge_proto_specific_hangup_cause">> ], Props). --spec disposition(data()) -> api_binary(). +-spec disposition(data()) -> kz_term:api_binary(). disposition(Props) -> props:get_first_defined([<<"variable_originate_disposition">> ,<<"variable_endpoint_disposition">> ], Props). --spec hangup_cause(data()) -> api_binary(). +-spec hangup_cause(data()) -> kz_term:api_binary(). hangup_cause(Props) -> case props:get_value(<<"variable_current_application">>, Props) of <<"bridge">> -> @@ -266,35 +266,35 @@ hangup_cause(Props) -> ], Props) end. --spec transfer_history(data()) -> api_binary() | kz_proplist(). +-spec transfer_history(data()) -> kz_term:api_binary() | kz_term:proplist(). transfer_history(Props) -> props:get_value(<<"variable_transfer_history">>, Props). --spec transfer_source(data()) -> api_binary() | kz_proplist(). +-spec transfer_source(data()) -> kz_term:api_binary() | kz_term:proplist(). transfer_source(Props) -> props:get_value(<<"variable_transfer_source">>, Props). --spec raw_application_name(data()) -> api_binary(). +-spec raw_application_name(data()) -> kz_term:api_binary(). raw_application_name(Props) -> props:get_first_defined([<<"Application">> ,<<"kazoo_application_name">> ,<<"Event-Subclass">> ], Props). --spec application_name(data()) -> api_binary(). +-spec application_name(data()) -> kz_term:api_binary(). application_name(Props) -> props:get_first_defined([<<"kazoo_application_name">> ,<<"Application">> ,<<"Event-Subclass">> ], Props). --spec event_name(data()) -> api_binary(). +-spec event_name(data()) -> kz_term:api_binary(). event_name(Props) -> props:get_first_defined([<<"kazoo_event_name">> ,<<"Event-Name">> ], Props). --spec from_network_ip(data()) -> api_binary(). +-spec from_network_ip(data()) -> kz_term:api_binary(). from_network_ip(Props) -> props:get_first_defined([<<"variable_sip_h_X-AUTH-IP">> ,<<"variable_sip_received_ip">> @@ -302,7 +302,7 @@ from_network_ip(Props) -> ,Props ). --spec from_network_port(data()) -> api_binary(). +-spec from_network_port(data()) -> kz_term:api_binary(). from_network_port(Props) -> props:get_first_defined([<<"variable_sip_h_X-AUTH-PORT">> ,<<"variable_sip_received_port">> @@ -310,7 +310,7 @@ from_network_port(Props) -> ,Props ). --spec user_agent(data()) -> api_binary(). +-spec user_agent(data()) -> kz_term:api_binary(). user_agent(Props) -> props:get_first_defined([<<"variable_sip_user_agent">> ,<<"sip_user_agent">> @@ -318,7 +318,7 @@ user_agent(Props) -> ,Props ). --spec loopback_leg_name(data()) -> api_binary(). +-spec loopback_leg_name(data()) -> kz_term:api_binary(). loopback_leg_name(Props) -> props:get_value(<<"variable_loopback_leg">>, Props). @@ -326,32 +326,32 @@ loopback_leg_name(Props) -> is_loopback(Props) -> props:get_value(<<"variable_loopback_leg">>, Props) =/= 'undefined'. --spec loopback_other_leg(data()) -> api_binary(). +-spec loopback_other_leg(data()) -> kz_term:api_binary(). loopback_other_leg(Props) -> props:get_value(<<"variable_other_loopback_leg_uuid">>, Props). --spec media_recorder(data()) -> api_binary(). +-spec media_recorder(data()) -> kz_term:api_binary(). media_recorder(Props) -> ccv(Props, <<"Media-Recorder">>). --spec presence_id(data()) -> api_binary(). +-spec presence_id(data()) -> kz_term:api_binary(). presence_id(Props) -> props:get_first_defined([<<"Channel-Presence-ID">> ,<<"variable_presence_id">> ], Props). --spec presence_direction(data()) -> api_binary(). +-spec presence_direction(data()) -> kz_term:api_binary(). presence_direction(Props) -> props:get_value(<<"Presence-Call-Direction">>, Props). --spec channel_var_map({ne_binary(), ne_binary()}) -> {ne_binary(), ne_binary() | ne_binaries()}. +-spec channel_var_map({kz_term:ne_binary(), kz_term:ne_binary()}) -> {kz_term:ne_binary(), kz_term:ne_binary() | kz_term:ne_binaries()}. channel_var_map({Key, <<"ARRAY::", Serialized/binary>>}) -> {Key, binary:split(Serialized, <<"|:">>, ['global'])}; channel_var_map({Key, Other}) -> {Key, Other}. %% Extract custom channel variables to include in the event --spec ccvs(kz_proplist()) -> kz_proplist(). --spec custom_channel_vars(kz_proplist(), kz_proplist()) -> kz_proplist(). --spec custom_channel_vars_fold({ne_binary(), ne_binary()}, kz_proplist()) -> kz_proplist(). +-spec ccvs(kz_term:proplist()) -> kz_term:proplist(). +-spec custom_channel_vars(kz_term:proplist(), kz_term:proplist()) -> kz_term:proplist(). +-spec custom_channel_vars_fold({kz_term:ne_binary(), kz_term:ne_binary()}, kz_term:proplist()) -> kz_term:proplist(). ccvs(Props) -> lists:map(fun channel_var_map/1, custom_channel_vars(Props, [])). @@ -359,7 +359,7 @@ custom_channel_vars(Props, Initial) -> CCVs = lists:foldl(fun custom_channel_vars_fold/2, Initial, Props), maybe_update_referred_ccv(Props, channel_vars_sort(CCVs)). --spec channel_vars_sort(kz_proplist()) -> kz_proplist(). +-spec channel_vars_sort(kz_term:proplist()) -> kz_term:proplist(). channel_vars_sort(ChannelVars) -> lists:usort(fun channel_var_sort/2, ChannelVars). @@ -382,7 +382,7 @@ custom_channel_vars_fold({<<"X-", ?CHANNEL_VAR_PREFIX, Key/binary>>, V}, Acc) -> end; custom_channel_vars_fold(_, Acc) -> Acc. --spec maybe_update_referred_ccv(kz_proplist(), kz_proplist()) -> kz_proplist(). +-spec maybe_update_referred_ccv(kz_term:proplist(), kz_term:proplist()) -> kz_term:proplist(). maybe_update_referred_ccv(Props, CCVs) -> ReferredBy = props:get_value(<<"variable_sip_h_Referred-By">>, Props), ReferTo = props:get_value(<<"variable_sip_refer_to">>, Props), @@ -390,7 +390,7 @@ maybe_update_referred_ccv(Props, CCVs) -> ,update_referred_to_ccv(ReferTo, CCVs) ). --spec update_referred_by_ccv(api_binary(), kz_proplist()) -> kz_proplist(). +-spec update_referred_by_ccv(kz_term:api_binary(), kz_term:proplist()) -> kz_term:proplist(). update_referred_by_ccv('undefined', CCVs) -> props:delete(<<"Referred-By">>, CCVs); update_referred_by_ccv(ReferredBy, CCVs) -> props:set_value(<<"Referred-By">> @@ -398,7 +398,7 @@ update_referred_by_ccv(ReferredBy, CCVs) -> ,CCVs ). --spec update_referred_to_ccv(api_binary(), kz_proplist()) -> kz_proplist(). +-spec update_referred_to_ccv(kz_term:api_binary(), kz_term:proplist()) -> kz_term:proplist(). update_referred_to_ccv('undefined', CCVs) -> props:delete(<<"Referred-To">>, CCVs); update_referred_to_ccv(ReferredTo, CCVs) -> props:set_value(<<"Referred-To">> @@ -406,42 +406,42 @@ update_referred_to_ccv(ReferredTo, CCVs) -> ,CCVs ). --spec from_tag(data()) -> api_binary(). +-spec from_tag(data()) -> kz_term:api_binary(). from_tag(Props) -> props:get_value(<<"variable_sip_from_tag">>, Props). --spec to_tag(data()) -> api_binary(). +-spec to_tag(data()) -> kz_term:api_binary(). to_tag(Props) -> props:get_value(<<"variable_sip_to_tag">>, Props). --spec origination_call_id(data()) -> api_binary(). +-spec origination_call_id(data()) -> kz_term:api_binary(). origination_call_id(Props) -> props:get_value(<<"variable_sip_origination_call_id">>, Props). --spec conference_name(data()) -> api_ne_binary(). +-spec conference_name(data()) -> kz_term:api_ne_binary(). conference_name(Props) -> props:get_ne_binary_value(<<"Conference-Name">>, Props). --spec conference_profile_name(data()) -> api_ne_binary(). +-spec conference_profile_name(data()) -> kz_term:api_ne_binary(). conference_profile_name(Props) -> props:get_ne_binary_value(<<"Conference-Profile-Name">>, Props). --spec conference_uuid(data()) -> api_ne_binary(). +-spec conference_uuid(data()) -> kz_term:api_ne_binary(). conference_uuid(Props) -> props:get_ne_binary_value(<<"Conference-Unique-ID">>, Props). --spec join_time(data()) -> gregorian_seconds(). --spec join_time(data(), Default) -> gregorian_seconds() | Default. +-spec join_time(data()) -> kz_time:gregorian_seconds(). +-spec join_time(data(), Default) -> kz_time:gregorian_seconds() | Default. join_time(Props) -> join_time(Props, kz_time:now_s()). join_time(Props, Default) -> props:get_integer_value(<<"Join-Time">>, Props, Default). --spec core_uuid(data()) -> api_binary(). +-spec core_uuid(data()) -> kz_term:api_binary(). core_uuid(Props) -> props:get_value(<<"Core-UUID">>, Props). --spec fetch_uuid(data()) -> api_binary(). +-spec fetch_uuid(data()) -> kz_term:api_binary(). fetch_uuid(Props) -> props:get_first_defined([<<"Fetch-UUID">> ,<<"variable_Fetch-UUID">> @@ -449,7 +449,7 @@ fetch_uuid(Props) -> ,Props ). --spec fetch_winning_pid(data()) -> api_binary(). +-spec fetch_winning_pid(data()) -> kz_term:api_binary(). fetch_winning_pid(Props) -> props:get_first_defined([<<"Fetch-Winning-PID">> ,<<"variable_Fetch-Winning-PID">> @@ -457,7 +457,7 @@ fetch_winning_pid(Props) -> ,Props ). --spec switch_url(data()) -> api_binary(). +-spec switch_url(data()) -> kz_term:api_binary(). switch_url(Props) -> case props:get_first_defined([<<"Switch-URL">>, <<"variable_Switch-URL">>], Props) of 'undefined' -> props:get_first_defined([<<"variable_sofia_profile_url">> @@ -466,7 +466,7 @@ switch_url(Props) -> SwitchURL -> SwitchURL end. --spec switch_uri(data()) -> api_binary(). +-spec switch_uri(data()) -> kz_term:api_binary(). switch_uri(Props) -> case props:get_first_defined([<<"Switch-URI">>, <<"variable_Switch-URI">>], Props) of 'undefined' -> case switch_url(Props) of @@ -483,8 +483,8 @@ switch_uri(Props) -> switch_nodename(Props) -> props:get_atom_value(<<"Switch-Nodename">>, Props). --spec hostname(data()) -> api_ne_binary(). --spec hostname(data(), Default) -> ne_binary() | Default. +-spec hostname(data()) -> kz_term:api_ne_binary(). +-spec hostname(data(), Default) -> kz_term:ne_binary() | Default. hostname(Props) -> hostname(Props, 'undefined'). hostname(Props, Default) -> diff --git a/core/kazoo_documents/src/kzd_item_plan.erl b/core/kazoo_documents/src/kzd_item_plan.erl index c896848b9ab..c92e74c7eb2 100644 --- a/core/kazoo_documents/src/kzd_item_plan.erl +++ b/core/kazoo_documents/src/kzd_item_plan.erl @@ -26,7 +26,7 @@ -include("kz_documents.hrl"). -type doc() :: kz_json:object(). --type api_doc() :: api_object(). +-type api_doc() :: kz_term:api_object(). -export_type([doc/0 ,api_doc/0 ]). @@ -70,15 +70,15 @@ rates(ItemPlan) -> rates(ItemPlan, Default) -> kz_json:get_json_value(?RATES, ItemPlan, Default). --spec rate(doc()) -> api_float(). +-spec rate(doc()) -> kz_term:api_float(). -spec rate(doc(), Default) -> float() | Default. rate(ItemPlan) -> rate(ItemPlan, 'undefined'). rate(ItemPlan, Default) -> kz_json:get_float_value(?RATE, ItemPlan, Default). --spec exceptions(doc()) -> ne_binaries(). --spec exceptions(doc(), Default) -> ne_binaries() | Default. +-spec exceptions(doc()) -> kz_term:ne_binaries(). +-spec exceptions(doc(), Default) -> kz_term:ne_binaries() | Default. exceptions(ItemPlan) -> exceptions(ItemPlan, []). exceptions(ItemPlan, Default) -> @@ -91,14 +91,14 @@ should_cascade(ItemPlan) -> should_cascade(ItemPlan, Default) -> kz_json:is_true(?CASCADE, ItemPlan, Default). --spec masquerade_as(doc()) -> api_binary(). --spec masquerade_as(doc(), Default) -> ne_binary() | Default. +-spec masquerade_as(doc()) -> kz_term:api_binary(). +-spec masquerade_as(doc(), Default) -> kz_term:ne_binary() | Default. masquerade_as(ItemPlan) -> masquerade_as(ItemPlan, 'undefined'). masquerade_as(ItemPlan, Default) -> kz_json:get_value(?MASQUERADE, ItemPlan, Default). --spec name(doc()) -> api_binary(). +-spec name(doc()) -> kz_term:api_binary(). name(ItemPlan) -> case kz_json:get_value(?NAME, ItemPlan) of 'undefined' -> masquerade_as(ItemPlan); @@ -112,14 +112,14 @@ discounts(ItemPlan) -> discounts(ItemPlan, Default) -> kz_json:get_json_value(?DISCOUNTS, ItemPlan, Default). --spec single_discount(doc()) -> api_object(). +-spec single_discount(doc()) -> kz_term:api_object(). -spec single_discount(doc(), Default) -> kz_json:object() | Default. single_discount(ItemPlan) -> single_discount(ItemPlan, 'undefined'). single_discount(ItemPlan, Default) -> kz_json:get_json_value([?DISCOUNTS, ?SINGLE], ItemPlan, Default). --spec cumulative_discount(doc()) -> api_object(). +-spec cumulative_discount(doc()) -> kz_term:api_object(). -spec cumulative_discount(doc(), Default) -> kz_json:object() | Default. cumulative_discount(ItemPlan) -> cumulative_discount(ItemPlan, 'undefined'). diff --git a/core/kazoo_documents/src/kzd_media.erl b/core/kazoo_documents/src/kzd_media.erl index c08f626ca7a..0a4f5ceea8a 100644 --- a/core/kazoo_documents/src/kzd_media.erl +++ b/core/kazoo_documents/src/kzd_media.erl @@ -29,11 +29,11 @@ new() -> kz_json:from_list([{<<"pvt_type">>, type()}]). --spec type() -> ne_binary(). +-spec type() -> kz_term:ne_binary(). type() -> ?PVT_TYPE. --spec prompt_id(doc()) -> api_ne_binary(). --spec prompt_id(doc(), Default) -> ne_binary() | Default. +-spec prompt_id(doc()) -> kz_term:api_ne_binary(). +-spec prompt_id(doc(), Default) -> kz_term:ne_binary() | Default. prompt_id(Doc) -> prompt_id(Doc, 'undefined'). prompt_id(Doc, Default) -> @@ -43,15 +43,15 @@ prompt_id(Doc, Default) -> is_prompt(Doc) -> prompt_id(Doc) =/= 'undefined'. --spec language(doc()) -> api_ne_binary(). --spec language(doc(), Default) -> ne_binary() | Default. +-spec language(doc()) -> kz_term:api_ne_binary(). +-spec language(doc(), Default) -> kz_term:ne_binary() | Default. language(Doc) -> language(Doc, 'undefined'). language(Doc, Default) -> kz_json:get_ne_binary_value(?LANGUAGE, Doc, Default). --spec content_type(doc()) -> api_ne_binary(). --spec content_type(doc(), Default) -> ne_binary() | Default. +-spec content_type(doc()) -> kz_term:api_ne_binary(). +-spec content_type(doc(), Default) -> kz_term:ne_binary() | Default. content_type(Doc) -> content_type(Doc, 'undefined'). content_type(Doc, Default) -> diff --git a/core/kazoo_documents/src/kzd_metaflow.erl b/core/kazoo_documents/src/kzd_metaflow.erl index fd38e6c8064..10e8ae1d3ba 100644 --- a/core/kazoo_documents/src/kzd_metaflow.erl +++ b/core/kazoo_documents/src/kzd_metaflow.erl @@ -20,31 +20,31 @@ new() -> kz_json_schema:default_object(?SCHEMA). --spec binding_digit(doc()) -> ne_binary(). --spec binding_digit(doc(), Default) -> ne_binary() | Default. +-spec binding_digit(doc()) -> kz_term:ne_binary(). +-spec binding_digit(doc(), Default) -> kz_term:ne_binary() | Default. binding_digit(Doc) -> binding_digit(Doc, <<"*">>). binding_digit(Doc, Default) -> kz_json:get_ne_binary_value(<<"binding_digit">>, Doc, Default). --spec digit_timeout(doc()) -> api_integer(). +-spec digit_timeout(doc()) -> kz_term:api_integer(). -spec digit_timeout(doc(), Default) -> non_neg_integer() | Default. digit_timeout(Doc) -> digit_timeout(Doc, 0). digit_timeout(Doc, Default) -> kz_json:get_integer_value(<<"digit_timeout">>, Doc, Default). --spec listen_on(doc()) -> api_ne_binary(). --spec listen_on(doc(), Default) -> ne_binary() | Default. +-spec listen_on(doc()) -> kz_term:api_ne_binary(). +-spec listen_on(doc(), Default) -> kz_term:ne_binary() | Default. listen_on(Doc) -> listen_on(Doc, 'undefined'). listen_on(Doc, Default) -> kz_json:get_ne_binary_value(<<"listen_on">>, Doc, Default). --spec numbers(doc()) -> api_object(). +-spec numbers(doc()) -> kz_term:api_object(). numbers(Doc) -> kz_json:get_json_value(<<"numbers">>, Doc). --spec patterns(doc()) -> api_object(). +-spec patterns(doc()) -> kz_term:api_object(). patterns(Doc) -> kz_json:get_json_value(<<"patterns">>, Doc). diff --git a/core/kazoo_documents/src/kzd_rate.erl b/core/kazoo_documents/src/kzd_rate.erl index 5d16a4ef356..79e969bae46 100644 --- a/core/kazoo_documents/src/kzd_rate.erl +++ b/core/kazoo_documents/src/kzd_rate.erl @@ -64,7 +64,7 @@ maybe_fix_direction(Rate) -> end. -spec ensure_id(doc()) -> doc(). --spec ensure_id(doc(), api_ne_binary()) -> doc(). +-spec ensure_id(doc(), kz_term:api_ne_binary()) -> doc(). ensure_id(Rate) -> ensure_id(Rate, kz_json:get_ne_binary_value(<<"_id">>, Rate)). @@ -155,54 +155,54 @@ private_cost(Rate, Default) -> set_private_cost(Rate, Cost) when is_float(Cost) -> kz_json:set_value(<<"pvt_internal_rate_cost">>, Cost, Rate). --spec version(doc()) -> api_ne_binary(). --spec version(doc(), Default) -> ne_binary() | Default. +-spec version(doc()) -> kz_term:api_ne_binary(). +-spec version(doc(), Default) -> kz_term:ne_binary() | Default. version(Rate) -> version(Rate, 'undefined'). version(Rate, Default) -> kz_json:get_ne_binary_value(<<"rate_version">>, Rate, Default). --spec prefix(doc()) -> api_ne_binary(). --spec prefix(doc(), Default) -> ne_binary() | Default. +-spec prefix(doc()) -> kz_term:api_ne_binary(). +-spec prefix(doc(), Default) -> kz_term:ne_binary() | Default. prefix(Rate) -> prefix(Rate, 'undefined'). prefix(Rate, Default) -> kz_json:get_ne_binary_value(<<"prefix">>, Rate, Default). --spec set_prefix(doc(), ne_binary()) -> doc(). +-spec set_prefix(doc(), kz_term:ne_binary()) -> doc(). set_prefix(Rate, Prefix) when is_binary(Prefix) -> kz_json:set_value(<<"prefix">>, Prefix, Rate). --spec name(doc()) -> api_ne_binary(). --spec name(doc(), Default) -> ne_binary() | Default. +-spec name(doc()) -> kz_term:api_ne_binary(). +-spec name(doc(), Default) -> kz_term:ne_binary() | Default. name(Rate) -> name(Rate, 'undefined'). name(Rate, Default) -> kz_json:get_ne_binary_value(<<"rate_name">>, Rate, Default). --spec set_name(doc(), ne_binary()) -> doc(). +-spec set_name(doc(), kz_term:ne_binary()) -> doc(). set_name(Rate, ?NE_BINARY = Name) -> kz_json:set_value(<<"rate_name">>, Name, Rate). --spec ratedeck(doc()) -> api_ne_binary(). --spec ratedeck(doc(), Default) -> ne_binary() | Default. +-spec ratedeck(doc()) -> kz_term:api_ne_binary(). +-spec ratedeck(doc(), Default) -> kz_term:ne_binary() | Default. ratedeck(Rate) -> ratedeck(Rate, 'undefined'). ratedeck(Rate, Default) -> kz_json:get_ne_binary_value(<<"ratedeck_id">>, Rate, Default). --spec set_ratedeck(doc(), ne_binary()) -> doc(). +-spec set_ratedeck(doc(), kz_term:ne_binary()) -> doc(). set_ratedeck(Rate, Deck) -> kz_json:set_value(<<"ratedeck_id">>, Deck, Rate). --spec description(doc()) -> api_ne_binary(). --spec description(doc(), Default) -> ne_binary() | Default. +-spec description(doc()) -> kz_term:api_ne_binary(). +-spec description(doc(), Default) -> kz_term:ne_binary() | Default. description(Rate) -> description(Rate, 'undefined'). description(Rate, Default) -> kz_json:get_ne_binary_value(<<"description">>, Rate, Default). --spec set_description(doc(), ne_binary()) -> doc(). +-spec set_description(doc(), kz_term:ne_binary()) -> doc(). set_description(Rate, Description) when is_binary(Description) -> kz_json:set_value(<<"description">>, Description, Rate). @@ -220,14 +220,14 @@ weight(Rate, Default) -> set_weight(Rate, Weight) when is_integer(Weight) -> kz_json:set_value(<<"weight">>, constrain_weight(Weight), Rate). --spec constrain_weight(text() | integer()) -> weight_range(). +-spec constrain_weight(kz_term:text() | integer()) -> weight_range(). constrain_weight(X) when not is_integer(X) -> constrain_weight(kz_term:to_integer(X)); constrain_weight(X) when X =< 0 -> 1; constrain_weight(X) when X >= 100 -> 100; constrain_weight(X) -> X. --spec direction(doc()) -> ne_binaries(). --spec direction(doc(), ne_binaries()) -> ne_binaries(). +-spec direction(doc()) -> kz_term:ne_binaries(). +-spec direction(doc(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). -define(BOTH_DIRECTIONS, [<<"inbound">>, <<"outbound">>]). direction(Rate) -> @@ -240,72 +240,72 @@ direction(Rate, Default) -> Directions when is_list(Directions) -> Directions end. --spec set_direction(doc(), ne_binary() | ne_binaries()) -> doc(). +-spec set_direction(doc(), kz_term:ne_binary() | kz_term:ne_binaries()) -> doc(). set_direction(Rate, Directions) when is_list(Directions) -> kz_json:set_value(<<"direction">>, Directions, Rate); set_direction(Rate, Direction) when is_binary(Direction) -> set_direction(Rate, [Direction]). --spec options(doc()) -> ne_binaries(). --spec options(doc(), ne_binaries()) -> ne_binaries(). +-spec options(doc()) -> kz_term:ne_binaries(). +-spec options(doc(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). options(Rate) -> options(Rate, []). options(Rate, Default) -> kz_json:get_list_value(<<"options">>, Rate, Default). --spec set_options(doc(), ne_binaries()) -> doc(). +-spec set_options(doc(), kz_term:ne_binaries()) -> doc(). set_options(Rate, Options) when is_list(Options) -> kz_json:set_value(<<"options">>, Options, Rate). --spec routes(doc()) -> ne_binaries(). --spec routes(doc(), ne_binaries()) -> ne_binaries(). +-spec routes(doc()) -> kz_term:ne_binaries(). +-spec routes(doc(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). routes(Rate) -> routes(Rate, []). routes(Rate, Default) -> kz_json:get_list_value(<<"routes">>, Rate, Default). --spec set_routes(doc(), ne_binaries()) -> doc(). +-spec set_routes(doc(), kz_term:ne_binaries()) -> doc(). set_routes(Rate, Routes) when is_list(Routes) -> kz_json:set_value(<<"routes">>, Routes, Rate). --spec account_id(doc()) -> api_ne_binary(). --spec account_id(doc(), Default) -> ne_binary() | Default. +-spec account_id(doc()) -> kz_term:api_ne_binary(). +-spec account_id(doc(), Default) -> kz_term:ne_binary() | Default. account_id(Rate) -> account_id(Rate, 'undefined'). account_id(Rate, Default) -> kz_json:get_ne_binary_value(<<"account_id">>, Rate, Default). --spec iso_country_code(doc()) -> api_ne_binary(). --spec iso_country_code(doc(), Default) -> ne_binary() | Default. +-spec iso_country_code(doc()) -> kz_term:api_ne_binary(). +-spec iso_country_code(doc(), Default) -> kz_term:ne_binary() | Default. iso_country_code(Rate) -> iso_country_code(Rate, 'undefined'). iso_country_code(Rate, Default) -> kz_json:get_ne_binary_value(<<"iso_country_code">>, Rate, Default). --spec set_iso_country_code(doc(), ne_binary()) -> doc(). +-spec set_iso_country_code(doc(), kz_term:ne_binary()) -> doc(). set_iso_country_code(Rate, Code) when is_binary(Code) -> kz_json:set_value(<<"iso_country_code">>, Code, Rate). --spec type() -> ne_binary(). --spec type(doc()) -> ne_binary(). +-spec type() -> kz_term:ne_binary(). +-spec type(doc()) -> kz_term:ne_binary(). -spec set_type(doc()) -> doc(). type() -> <<"rate">>. type(Doc) -> kz_doc:type(Doc, type()). set_type(Doc) -> kz_doc:set_type(Doc, type()). --spec carrier(doc()) -> ne_binary(). --spec carrier(doc(), Default) -> ne_binary() | Default. +-spec carrier(doc()) -> kz_term:ne_binary(). +-spec carrier(doc(), Default) -> kz_term:ne_binary() | Default. carrier(Rate) -> carrier(Rate, <<"default">>). carrier(Rate, Default) -> kz_json:get_ne_binary_value(<<"pvt_carrier">>, Rate, Default). --spec set_carrier(doc(), ne_binary()) -> doc(). +-spec set_carrier(doc(), kz_term:ne_binary()) -> doc(). set_carrier(Rate, Carrier) when is_binary(Carrier) -> kz_json:set_value(<<"pvt_carrier">>, Carrier, Rate). --spec rate_suffix(doc()) -> ne_binary(). --spec rate_suffix(doc(), Default) -> ne_binary() | Default. +-spec rate_suffix(doc()) -> kz_term:ne_binary(). +-spec rate_suffix(doc(), Default) -> kz_term:ne_binary() | Default. rate_suffix(Rate) -> rate_suffix(Rate, 'undefined'). rate_suffix(Rate, Default) -> diff --git a/core/kazoo_documents/src/kzd_ratedeck.erl b/core/kazoo_documents/src/kzd_ratedeck.erl index 386d6eaaa3a..580c77586ee 100644 --- a/core/kazoo_documents/src/kzd_ratedeck.erl +++ b/core/kazoo_documents/src/kzd_ratedeck.erl @@ -24,21 +24,21 @@ -type doc() :: kz_json:object(). -export_type([doc/0]). --spec id() -> ne_binary(). +-spec id() -> kz_term:ne_binary(). id() -> <<"ratedeck">>. --spec name(doc()) -> api_ne_binary(). +-spec name(doc()) -> kz_term:api_ne_binary(). name(Doc) -> kz_json:get_ne_binary_value(<<"name">>, Doc). --spec database_name(doc()) -> api_ne_binary(). +-spec database_name(doc()) -> kz_term:api_ne_binary(). database_name(Doc) -> case name(Doc) of 'undefined' -> ?KZ_RATES_DB; Name -> format_ratedeck_db(Name) end. --spec format_ratedeck_db(ne_binary()) -> ne_binary(). +-spec format_ratedeck_db(kz_term:ne_binary()) -> kz_term:ne_binary(). format_ratedeck_db(?KZ_RATES_DB) -> ?KZ_RATES_DB; format_ratedeck_db(?MATCH_RATEDECK_DB_ENCODED(_)=Db) -> Db; format_ratedeck_db(?MATCH_RATEDECK_DB_encoded(_)=Db) -> Db; @@ -46,7 +46,7 @@ format_ratedeck_db(?MATCH_RATEDECK_DB_UNENCODED(RatedeckId)) -> ?ENCODE_RATEDECK format_ratedeck_db(<<_/binary>> = RatedeckId) -> ?ENCODE_RATEDECK_DB(kz_http_util:urlencode(RatedeckId)). --spec format_ratedeck_id(ne_binary()) -> ne_binary(). +-spec format_ratedeck_id(kz_term:ne_binary()) -> kz_term:ne_binary(). format_ratedeck_id(?KZ_RATES_DB) -> ?KZ_RATES_DB; format_ratedeck_id(?MATCH_RATEDECK_DB_ENCODED(Id)) -> kz_http_util:urldecode(Id); format_ratedeck_id(?MATCH_RATEDECK_DB_encoded(Id)) -> kz_http_util:urldecode(Id); diff --git a/core/kazoo_documents/src/kzd_resource.erl b/core/kazoo_documents/src/kzd_resource.erl index 68cc18a5257..44fad0cb4c5 100644 --- a/core/kazoo_documents/src/kzd_resource.erl +++ b/core/kazoo_documents/src/kzd_resource.erl @@ -20,22 +20,22 @@ new() -> kz_doc:set_type(kz_json_schema:default_object(?SCHEMA), type()). --spec type() -> ne_binary(). --spec type(doc()) -> ne_binary(). +-spec type() -> kz_term:ne_binary(). +-spec type(doc()) -> kz_term:ne_binary(). type() -> ?PVT_TYPE. type(Doc) -> kz_doc:type(Doc, ?PVT_TYPE). --spec flat_rate_whitelist(doc()) -> api_ne_binary(). --spec flat_rate_whitelist(doc(), Default) -> ne_binary() | Default. +-spec flat_rate_whitelist(doc()) -> kz_term:api_ne_binary(). +-spec flat_rate_whitelist(doc(), Default) -> kz_term:ne_binary() | Default. flat_rate_whitelist(Doc) -> flat_rate_whitelist(Doc, 'undefined'). flat_rate_whitelist(Doc, Default) -> kz_json:get_ne_binary_value(<<"flat_rate_whitelist">>, Doc, Default). --spec flat_rate_blacklist(doc()) -> api_ne_binary(). --spec flat_rate_blacklist(doc(), Default) -> ne_binary() | Default. +-spec flat_rate_blacklist(doc()) -> kz_term:api_ne_binary(). +-spec flat_rate_blacklist(doc(), Default) -> kz_term:ne_binary() | Default. flat_rate_blacklist(Doc) -> flat_rate_blacklist(Doc, 'undefined'). flat_rate_blacklist(Doc, Default) -> diff --git a/core/kazoo_documents/src/kzd_schema.erl b/core/kazoo_documents/src/kzd_schema.erl index 4090fd5a7d6..495136cba5b 100644 --- a/core/kazoo_documents/src/kzd_schema.erl +++ b/core/kazoo_documents/src/kzd_schema.erl @@ -18,7 +18,7 @@ -define(SCHEMA_KEYWORDS_MAXLENGTH, <<"maxLength">>). %%% Load schema --spec find_schema(ne_binary()) -> api_object(). +-spec find_schema(kz_term:ne_binary()) -> kz_term:api_object(). find_schema(<<_/binary>> = Schema) -> case kz_json_schema:load(Schema) of {'ok', SchemaJObj} -> SchemaJObj; @@ -29,7 +29,7 @@ find_schema(<<_/binary>> = Schema) -> %%% Meta keywords %%% =================== --spec properties(kz_json:path(), ne_binary()) -> kz_json:object(). +-spec properties(kz_json:path(), kz_term:ne_binary()) -> kz_json:object(). properties(Key, Schema) -> case find_schema(Schema) of 'undefined' -> @@ -41,7 +41,7 @@ properties(Key, Schema) -> %%% Keywords %%% ================================== %% String --spec max_length(kz_json:path(), ne_binary()) -> api_integer(). +-spec max_length(kz_json:path(), kz_term:ne_binary()) -> kz_term:api_integer(). max_length(Key, Schema) -> Properties = properties(Key, Schema), kz_json:get_integer_value(?SCHEMA_KEYWORDS_MAXLENGTH, Properties). diff --git a/core/kazoo_documents/src/kzd_schema_caller_id.erl b/core/kazoo_documents/src/kzd_schema_caller_id.erl index 9fbbe39454d..4e72e2cd80e 100644 --- a/core/kazoo_documents/src/kzd_schema_caller_id.erl +++ b/core/kazoo_documents/src/kzd_schema_caller_id.erl @@ -16,6 +16,6 @@ -define(SCHEMA_PATH_PATTERN(K1, K2), [<<"properties">>, K1, <<"properties">>, K2]). -define(SCHEMA_EXTERNAL_NAME, ?SCHEMA_PATH_PATTERN(<<"external">>, <<"name">>)). --spec external_name_max_length() -> api_integer(). +-spec external_name_max_length() -> kz_term:api_integer(). external_name_max_length() -> kzd_schema:max_length(?SCHEMA_EXTERNAL_NAME, ?SCHEMA_NAME). diff --git a/core/kazoo_documents/src/kzd_service_plan.erl b/core/kazoo_documents/src/kzd_service_plan.erl index c13aceb18c1..4f402b01a3a 100644 --- a/core/kazoo_documents/src/kzd_service_plan.erl +++ b/core/kazoo_documents/src/kzd_service_plan.erl @@ -39,7 +39,7 @@ -type doc() :: kz_json:object(). -type docs() :: [doc()]. --type api_doc() :: api_object(). +-type api_doc() :: kz_term:api_object(). -export_type([doc/0 ,api_doc/0 ,docs/0 @@ -54,14 +54,14 @@ new() -> kz_doc:set_type(kz_json:new(), type()). --spec type() -> ne_binary(). +-spec type() -> kz_term:ne_binary(). type() -> <<"service_plan">>. --spec all_items_key() -> ne_binary(). +-spec all_items_key() -> kz_term:ne_binary(). all_items_key() -> ?ALL. --spec account_id(doc()) -> api_binary(). --spec account_id(doc(), Default) -> ne_binary() | Default. +-spec account_id(doc()) -> kz_term:api_binary(). +-spec account_id(doc(), Default) -> kz_term:ne_binary() | Default. account_id(Plan) -> account_id(Plan, 'undefined'). account_id(Plan, Default) -> @@ -78,8 +78,8 @@ overrides(Plan, Default) -> merge_overrides(Plan, Overrides) -> kz_json:merge(Plan, kz_json:from_list([{?PLAN, Overrides}])). --spec item_activation_charge(doc(), ne_binary(), ne_binary()) -> float(). --spec item_activation_charge(doc(), ne_binary(), ne_binary(), Default) -> float() | Default. +-spec item_activation_charge(doc(), kz_term:ne_binary(), kz_term:ne_binary()) -> float(). +-spec item_activation_charge(doc(), kz_term:ne_binary(), kz_term:ne_binary(), Default) -> float() | Default. item_activation_charge(Plan, Category, Item) -> item_activation_charge(Plan, Category, Item, 0.0). item_activation_charge(Plan, Category, Item, Default) -> @@ -87,29 +87,29 @@ item_activation_charge(Plan, Category, Item, Default) -> ItemConfig = kz_json:get_json_value(Path, Plan, kz_json:new()), kzd_item_plan:activation_charge(ItemConfig, Default). --spec category_activation_charge(doc(), ne_binary()) -> float(). --spec category_activation_charge(doc(), ne_binary(), Default) -> float() | Default. +-spec category_activation_charge(doc(), kz_term:ne_binary()) -> float(). +-spec category_activation_charge(doc(), kz_term:ne_binary(), Default) -> float() | Default. category_activation_charge(Plan, Category) -> category_activation_charge(Plan, Category, 0.0). category_activation_charge(Plan, Category, Default) -> item_activation_charge(Plan, Category, ?ALL, Default). --spec categories(doc()) -> ne_binaries(). +-spec categories(doc()) -> kz_term:ne_binaries(). categories(Plan) -> kz_json:get_keys(?PLAN, Plan). --spec category(doc(), ne_binary()) -> api_object(). --spec category(doc(), ne_binary(), Default) -> api_object() | Default. +-spec category(doc(), kz_term:ne_binary()) -> kz_term:api_object(). +-spec category(doc(), kz_term:ne_binary(), Default) -> kz_term:api_object() | Default. category(Plan, CategoryId) -> category(Plan, CategoryId, 'undefined'). category(Plan, CategoryId, Default) -> kz_json:get_json_value([?PLAN, CategoryId], Plan, Default). --spec items(doc(), ne_binary()) -> ne_binaries(). +-spec items(doc(), kz_term:ne_binary()) -> kz_term:ne_binaries(). items(Plan, Category) -> kz_json:get_keys([?PLAN, Category], Plan). --spec item(doc(), ne_binary(), ne_binary()) -> api_object(). +-spec item(doc(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_object(). item(Plan, CategoryId, ItemId) -> kz_json:get_json_value([?PLAN, CategoryId, ItemId], Plan). @@ -117,16 +117,16 @@ item(Plan, CategoryId, ItemId) -> bookkeepers(Plan) -> kz_json:get_json_value(?BOOKKEEPERS, Plan, kz_json:new()). --spec bookkeeper_ids(doc()) -> ne_binaries(). +-spec bookkeeper_ids(doc()) -> kz_term:ne_binaries(). bookkeeper_ids(Plan) -> kz_json:get_keys(?BOOKKEEPERS, Plan). --spec bookkeeper(doc(), ne_binary()) -> kz_json:object(). +-spec bookkeeper(doc(), kz_term:ne_binary()) -> kz_json:object(). bookkeeper(Plan, BookkeeperId) -> kz_json:get_json_value(BookkeeperId, bookkeepers(Plan), kz_json:new()). --spec item_minimum(doc(), ne_binary(), ne_binary()) -> integer(). --spec item_minimum(doc(), ne_binary(), ne_binary(), Default) -> integer() | Default. +-spec item_minimum(doc(), kz_term:ne_binary(), kz_term:ne_binary()) -> integer(). +-spec item_minimum(doc(), kz_term:ne_binary(), kz_term:ne_binary(), Default) -> integer() | Default. item_minimum(Plan, CategoryId, ItemId) -> item_minimum(Plan, CategoryId, ItemId, 0). item_minimum(Plan, CategoryId, ItemId, Default) -> @@ -138,7 +138,7 @@ item_minimum(Plan, CategoryId, ItemId, Default) -> ,Default ). --spec item_name(doc(), ne_binary(), ne_binary()) -> ne_binary(). +-spec item_name(doc(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). item_name(Plan, CategoryId, ItemId) -> kzd_item_plan:name( kz_json:get_json_value( @@ -148,10 +148,10 @@ item_name(Plan, CategoryId, ItemId) -> ) ). --spec item_exceptions(doc(), ne_binary(), ne_binary()) -> - ne_binaries(). --spec item_exceptions(doc(), ne_binary(), ne_binary(), ne_binaries()) -> - ne_binaries(). +-spec item_exceptions(doc(), kz_term:ne_binary(), kz_term:ne_binary()) -> + kz_term:ne_binaries(). +-spec item_exceptions(doc(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binaries()) -> + kz_term:ne_binaries(). item_exceptions(Plan, CategoryId, ItemId) -> item_exceptions(Plan, CategoryId, ItemId, []). item_exceptions(Plan, CategoryId, ItemId, Default) -> @@ -161,15 +161,15 @@ item_exceptions(Plan, CategoryId, ItemId, Default) -> ), kzd_item_plan:exceptions(Item, Default). --spec item_plan(doc(), ne_binary(), ne_binary()) -> kz_json:object(). --spec item_plan(doc(), ne_binary(), ne_binary(), Default) -> kz_json:object() | Default. +-spec item_plan(doc(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). +-spec item_plan(doc(), kz_term:ne_binary(), kz_term:ne_binary(), Default) -> kz_json:object() | Default. item_plan(Plan, CategoryId, ItemId) -> item_plan(Plan, CategoryId, ItemId, kz_json:new()). item_plan(Plan, CategoryId, ItemId, Default) -> kz_json:get_json_value([?PLAN, CategoryId, ItemId], Plan, Default). --spec category_plan(doc(), ne_binary()) -> kz_json:object(). --spec category_plan(doc(), ne_binary(), Default) -> kz_json:object() | Default. +-spec category_plan(doc(), kz_term:ne_binary()) -> kz_json:object(). +-spec category_plan(doc(), kz_term:ne_binary(), Default) -> kz_json:object() | Default. category_plan(Plan, CategoryId) -> category_plan(Plan, CategoryId, kz_json:new()). category_plan(Plan, CategoryId, Default) -> @@ -186,8 +186,8 @@ plan(Plan, Default) -> set_plan(Plan, P) -> kz_json:set_value(?PLAN, P, Plan). --spec grouping_category(doc()) -> api_ne_binary(). --spec grouping_category(doc(), Default) -> ne_binary() | Default. +-spec grouping_category(doc()) -> kz_term:api_ne_binary(). +-spec grouping_category(doc(), Default) -> kz_term:ne_binary() | Default. grouping_category(ServicePlan) -> grouping_category(ServicePlan, 'undefined'). grouping_category(ServicePlan, Default) -> diff --git a/core/kazoo_documents/src/kzd_services.erl b/core/kazoo_documents/src/kzd_services.erl index 3725f4284c1..00cfa6b91a9 100644 --- a/core/kazoo_documents/src/kzd_services.erl +++ b/core/kazoo_documents/src/kzd_services.erl @@ -64,14 +64,14 @@ -define(REASON, <<"pvt_status_reason">>). -define(REASON_CODE, <<"pvt_status_reason_code">>). --spec billing_id(doc()) -> api_binary(). --spec billing_id(doc(), Default) -> ne_binary() | Default. +-spec billing_id(doc()) -> kz_term:api_binary(). +-spec billing_id(doc(), Default) -> kz_term:ne_binary() | Default. billing_id(JObj) -> billing_id(JObj, kz_doc:account_id(JObj)). billing_id(JObj, Default) -> kz_json:get_value(?BILLING_ID, JObj, Default). --spec set_billing_id(doc(), api_binary()) -> doc(). +-spec set_billing_id(doc(), kz_term:api_binary()) -> doc(). set_billing_id(JObj, BillingId) -> kz_json:set_value(?BILLING_ID, BillingId, JObj). @@ -82,8 +82,8 @@ is_reseller(JObj) -> is_reseller(JObj, Default) -> kz_json:is_true(?IS_RESELLER, JObj, Default). --spec reseller_id(doc()) -> api_binary(). --spec reseller_id(doc(), Default) -> ne_binary() | Default. +-spec reseller_id(doc()) -> kz_term:api_binary(). +-spec reseller_id(doc(), Default) -> kz_term:ne_binary() | Default. reseller_id(JObj) -> reseller_id(JObj, 'undefined'). reseller_id(JObj, Default) -> @@ -103,44 +103,44 @@ is_deleted(JObj) -> is_deleted(JObj, Default) -> kz_json:is_true(?IS_DELETED, JObj, Default). --spec status(doc()) -> ne_binary(). --spec status(doc(), Default) -> ne_binary() | Default. +-spec status(doc()) -> kz_term:ne_binary(). +-spec status(doc(), Default) -> kz_term:ne_binary() | Default. status(JObj) -> status(JObj, status_good()). status(JObj, Default) -> kz_json:get_value(?STATUS, JObj, Default). --spec tree(doc()) -> ne_binaries(). --spec tree(doc(), Default) -> ne_binaries() | Default. +-spec tree(doc()) -> kz_term:ne_binaries(). +-spec tree(doc(), Default) -> kz_term:ne_binaries() | Default. tree(JObj) -> tree(JObj, []). tree(JObj, Default) -> kz_json:get_value(?TREE, JObj, Default). --spec reason(doc()) -> ne_binaries(). --spec reason(doc(), Default) -> ne_binaries() | Default. +-spec reason(doc()) -> kz_term:ne_binaries(). +-spec reason(doc(), Default) -> kz_term:ne_binaries() | Default. reason(JObj) -> reason(JObj, 'undefined'). reason(JObj, Default) -> kz_json:get_value(?REASON, JObj, Default). --spec reason_code(doc()) -> ne_binaries(). --spec reason_code(doc(), Default) -> ne_binaries() | Default. +-spec reason_code(doc()) -> kz_term:ne_binaries(). +-spec reason_code(doc(), Default) -> kz_term:ne_binaries() | Default. reason_code(JObj) -> reason_code(JObj, 'undefined'). reason_code(JObj, Default) -> kz_json:get_value(?REASON_CODE, JObj, Default). --spec type() -> ne_binary(). --spec type(kz_json:object()) -> ne_binary(). +-spec type() -> kz_term:ne_binary(). +-spec type(kz_json:object()) -> kz_term:ne_binary(). type() -> <<"service">>. type(JObj) -> kz_doc:type(JObj, type()). --spec status_good() -> ne_binary(). +-spec status_good() -> kz_term:ne_binary(). status_good() -> <<"good_standing">>. --spec status_delinquent() -> ne_binary(). +-spec status_delinquent() -> kz_term:ne_binary(). status_delinquent() -> <<"delinquent">>. -spec plans(doc()) -> kz_json:object(). @@ -150,26 +150,26 @@ plans(JObj) -> plans(JObj, Default) -> kz_json:get_json_value(?PLANS, JObj, Default). --spec plan_ids(doc()) -> ne_binaries(). +-spec plan_ids(doc()) -> kz_term:ne_binaries(). plan_ids(JObj) -> kz_json:get_keys(?PLANS, JObj). --spec plan(doc(), ne_binary()) -> kz_json:object(). --spec plan(doc(), ne_binary(), Default) -> kz_json:object() | Default. +-spec plan(doc(), kz_term:ne_binary()) -> kz_json:object(). +-spec plan(doc(), kz_term:ne_binary(), Default) -> kz_json:object() | Default. plan(JObj, PlanId) -> plan(JObj, PlanId, kz_json:new()). plan(JObj, PlanId, Default) -> kz_json:get_json_value([?PLANS, PlanId], JObj, Default). --spec plan_account_id(doc(), ne_binary()) -> api_binary(). --spec plan_account_id(doc(), ne_binary(), Default) -> api_binary() | Default. +-spec plan_account_id(doc(), kz_term:ne_binary()) -> kz_term:api_binary(). +-spec plan_account_id(doc(), kz_term:ne_binary(), Default) -> kz_term:api_binary() | Default. plan_account_id(JObj, PlanId) -> plan_account_id(JObj, PlanId, 'undefined'). plan_account_id(JObj, PlanId, Default) -> kzd_service_plan:account_id(plan(JObj, PlanId), Default). --spec plan_overrides(doc(), ne_binary()) -> kz_json:object(). --spec plan_overrides(doc(), ne_binary(), Default) -> kz_json:object() | Default. +-spec plan_overrides(doc(), kz_term:ne_binary()) -> kz_json:object(). +-spec plan_overrides(doc(), kz_term:ne_binary(), Default) -> kz_json:object() | Default. plan_overrides(JObj, PlanId) -> plan_overrides(JObj, PlanId, kz_json:new()). plan_overrides(JObj, PlanId, Default) -> @@ -182,15 +182,15 @@ quantities(JObj) -> quantities(JObj, Default) -> kz_json:get_json_value(?QUANTITIES, JObj, Default). --spec category_quantities(doc(), ne_binary()) -> kz_json:object(). --spec category_quantities(doc(), ne_binary(), Default) -> kz_json:object() | Default. +-spec category_quantities(doc(), kz_term:ne_binary()) -> kz_json:object(). +-spec category_quantities(doc(), kz_term:ne_binary(), Default) -> kz_json:object() | Default. category_quantities(JObj, CategoryId) -> category_quantities(JObj, CategoryId, kz_json:new()). category_quantities(JObj, CategoryId, Default) -> kz_json:get_json_value([?QUANTITIES, CategoryId], JObj, Default). --spec item_quantity(doc(), ne_binary(), ne_binary()) -> integer(). --spec item_quantity(doc(), ne_binary(), ne_binary(), Default) -> integer() | Default. +-spec item_quantity(doc(), kz_term:ne_binary(), kz_term:ne_binary()) -> integer(). +-spec item_quantity(doc(), kz_term:ne_binary(), kz_term:ne_binary(), Default) -> integer() | Default. item_quantity(JObj, CategoryId, ItemId) -> item_quantity(JObj, CategoryId, ItemId, 0). item_quantity(JObj, CategoryId, ItemId, Default) -> @@ -207,7 +207,7 @@ transactions(JObj, Default) -> set_is_reseller(JObj, IsReseller) -> kz_json:set_value(?IS_RESELLER, IsReseller, JObj). --spec set_reseller_id(doc(), api_binary()) -> doc(). +-spec set_reseller_id(doc(), kz_term:api_binary()) -> doc(). set_reseller_id(JObj, ResellerId) -> kz_json:set_value(?RESELLER_ID, ResellerId, JObj). @@ -215,15 +215,15 @@ set_reseller_id(JObj, ResellerId) -> set_is_dirty(JObj, IsDirty) -> kz_json:set_value(?IS_DIRTY, IsDirty, JObj). --spec set_status(doc(), api_binary()) -> doc(). +-spec set_status(doc(), kz_term:api_binary()) -> doc(). set_status(JObj, Status) -> kz_json:set_value(?STATUS, Status, JObj). --spec set_tree(doc(), ne_binaries()) -> doc(). +-spec set_tree(doc(), kz_term:ne_binaries()) -> doc(). set_tree(JObj, Tree) -> kz_json:set_value(?TREE, Tree, JObj). --spec set_reason(doc(), ne_binary()) -> doc(). +-spec set_reason(doc(), kz_term:ne_binary()) -> doc(). set_reason(JObj, Reason) -> kz_json:set_value(?REASON, Reason, JObj). @@ -239,7 +239,7 @@ set_type(JObj) -> set_plans(JObj, Plans) -> kz_json:set_value(?PLANS, Plans, JObj). --spec set_plan(doc(), ne_binary(), api_object()) -> doc(). +-spec set_plan(doc(), kz_term:ne_binary(), kz_term:api_object()) -> doc(). set_plan(JObj, PlanId, 'undefined') -> kz_json:delete_key([?PLANS, PlanId], JObj); set_plan(JObj, PlanId, Plan) -> diff --git a/core/kazoo_documents/src/kzd_skel.erl b/core/kazoo_documents/src/kzd_skel.erl index f6ccbe31a37..3b20862d2e6 100644 --- a/core/kazoo_documents/src/kzd_skel.erl +++ b/core/kazoo_documents/src/kzd_skel.erl @@ -17,8 +17,8 @@ new() -> kz_doc:set_type(kz_json_schema:default_object(?SCHEMA), type()). --spec type() -> ne_binary(). --spec type(doc()) -> ne_binary(). +-spec type() -> kz_term:ne_binary(). +-spec type(doc()) -> kz_term:ne_binary(). type() -> ?PVT_TYPE. type(Doc) -> diff --git a/core/kazoo_documents/src/kzd_task.erl b/core/kazoo_documents/src/kzd_task.erl index 1cc0c7982c0..212e1a547d3 100644 --- a/core/kazoo_documents/src/kzd_task.erl +++ b/core/kazoo_documents/src/kzd_task.erl @@ -37,7 +37,7 @@ %% @doc %% @end %%-------------------------------------------------------------------- --spec fetch(ne_binary(), kz_tasks:id()) -> +-spec fetch(kz_term:ne_binary(), kz_tasks:id()) -> {ok, kz_json:object()} | {error, any()}. fetch(Account, TaskId) -> @@ -53,7 +53,7 @@ fetch(Account, TaskId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec id(doc()) -> ne_binary(). +-spec id(doc()) -> kz_term:ne_binary(). id(JObj) -> kz_doc:id(JObj). @@ -62,65 +62,65 @@ id(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec type() -> ne_binary(). +-spec type() -> kz_term:ne_binary(). type() -> <<"task">>. %% @public --spec node(doc()) -> ne_binary() | 'undefined'. +-spec node(doc()) -> kz_term:ne_binary() | 'undefined'. node(Doc) -> kz_json:get_ne_binary_value(?PVT_WORKER_NODE, Doc). %% @public --spec account_id(doc()) -> ne_binary(). +-spec account_id(doc()) -> kz_term:ne_binary(). account_id(Doc) -> kz_json:get_ne_binary_value(?PVT_ACCOUNT_ID, Doc). %% @public --spec auth_account_id(doc()) -> ne_binary(). +-spec auth_account_id(doc()) -> kz_term:ne_binary(). auth_account_id(Doc) -> kz_json:get_ne_binary_value(?PVT_AUTH_ACCOUNT_ID, Doc). %% @public --spec category(doc()) -> ne_binary(). +-spec category(doc()) -> kz_term:ne_binary(). category(Doc) -> kz_json:get_ne_binary_value(?PVT_CATEGORY, Doc). %% @public --spec action(doc()) -> ne_binary(). +-spec action(doc()) -> kz_term:ne_binary(). action(Doc) -> kz_json:get_ne_binary_value(?PVT_ACTION, Doc). %% @public --spec status(doc()) -> ne_binary(). +-spec status(doc()) -> kz_term:ne_binary(). status(Doc) -> kz_json:get_ne_binary_value(?PVT_STATUS, Doc). %% @public --spec file_name(doc()) -> ne_binary(). +-spec file_name(doc()) -> kz_term:ne_binary(). file_name(Doc) -> kz_json:get_ne_binary_value(?PVT_FILENAME, Doc). %% @public --spec start_timestamp(doc()) -> api_seconds(). +-spec start_timestamp(doc()) -> kz_time:api_seconds(). start_timestamp(Doc) -> kz_json:get_integer_value(?PVT_STARTED_AT, Doc). %% @public --spec end_timestamp(doc()) -> api_seconds(). +-spec end_timestamp(doc()) -> kz_time:api_seconds(). end_timestamp(Doc) -> kz_json:get_integer_value(?PVT_FINISHED_AT, Doc). %% @public --spec total_count(doc()) -> api_pos_integer(). +-spec total_count(doc()) -> kz_term:api_pos_integer(). total_count(Doc) -> kz_json:get_integer_value(?PVT_TOTAL_ROWS, Doc). %% @public --spec failure_count(doc()) -> api_non_neg_integer(). +-spec failure_count(doc()) -> kz_term:api_non_neg_integer(). failure_count(Doc) -> kz_json:get_integer_value(?PVT_TOTAL_ROWS_FAILED, Doc). %% @public --spec success_count(doc()) -> api_non_neg_integer(). +-spec success_count(doc()) -> kz_term:api_non_neg_integer(). success_count(Doc) -> kz_json:get_integer_value(?PVT_TOTAL_ROWS_SUCCEEDED, Doc). diff --git a/core/kazoo_documents/src/kzd_user.erl b/core/kazoo_documents/src/kzd_user.erl index ea453c00264..fedab8a3caf 100644 --- a/core/kazoo_documents/src/kzd_user.erl +++ b/core/kazoo_documents/src/kzd_user.erl @@ -44,16 +44,16 @@ -define(KEY_CALL_RESTRICTIONS, <<"call_restriction">>). -define(KEY_CALL_RESTRICTION_ACTION, <<"action">>). --spec fetch(api_ne_binary(), api_ne_binary()) -> {'ok', doc()} | - {'error', any()}. +-spec fetch(kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> {'ok', doc()} | + {'error', any()}. fetch(Account=?NE_BINARY, UserId=?NE_BINARY) -> AccountDb = kz_util:format_account_db(Account), kz_datamgr:open_cache_doc(AccountDb, UserId, [{cache_failures,false}]); fetch(_, _) -> {'error', 'invalid_parameters'}. --spec email(doc()) -> api_binary(). --spec email(doc(), Default) -> ne_binary() | Default. +-spec email(doc()) -> kz_term:api_binary(). +-spec email(doc(), Default) -> kz_term:ne_binary() | Default. email(User) -> email(User, 'undefined'). email(User, Default) -> @@ -106,7 +106,7 @@ vcard_escape_chars(Val) -> Val1 = re:replace(Val, "(:|;|,)", "\\\\&", Opts), re:replace(Val1, "\n", "\\\\n", Opts). --spec vcard_fields_acc(vcard_field(), [{ne_binary(), binary()}]) -> [{ne_binary(), binary()}]. +-spec vcard_fields_acc(vcard_field(), [{kz_term:ne_binary(), binary()}]) -> [{kz_term:ne_binary(), binary()}]. vcard_fields_acc({_, Val}, Acc) when Val =:= 'undefined'; Val =:= []; Val =:= <<>> -> Acc; @@ -122,24 +122,24 @@ vcard_fields_acc([X | Rest], Acc) -> vcard_fields_acc([], Acc) -> Acc. --spec vcard_normalize_val(binary() | {char(), binaries()}) -> binary(). +-spec vcard_normalize_val(binary() | {char(), kz_term:binaries()}) -> binary(). vcard_normalize_val({Separator, Vals}) when is_list(Vals) -> kz_binary:join([vcard_escape_chars(X) || X <- Vals, not kz_term:is_empty(X)], Separator); vcard_normalize_val(Val) when is_binary(Val) -> vcard_escape_chars(Val). --spec vcard_normalize_type(list() | {ne_binary(), ne_binary()} | ne_binary()) -> ne_binary(). +-spec vcard_normalize_type(list() | {kz_term:ne_binary(), kz_term:ne_binary()} | kz_term:ne_binary()) -> kz_term:ne_binary(). vcard_normalize_type(T) when is_list(T) -> kz_binary:join([vcard_normalize_type(X) || X <- T], <<";">>); vcard_normalize_type({T, V}) -> kz_binary:join([T, V], <<"=">>); vcard_normalize_type(T) -> T. --type vcard_val() :: binary() | {char(), binaries()} | 'undefined'. --type vcard_type_token() :: ne_binary() | {ne_binary(), ne_binary()}. +-type vcard_val() :: binary() | {char(), kz_term:binaries()} | 'undefined'. +-type vcard_type_token() :: kz_term:ne_binary() | {kz_term:ne_binary(), kz_term:ne_binary()}. -type vcard_type() :: [vcard_type_token()] | vcard_type_token(). -type vcard_field_token() :: {vcard_type(), vcard_val()}. -type vcard_field() :: vcard_field_token() | [vcard_field_token()]. --spec card_field(ne_binary(), kz_json:object()) -> vcard_field(). +-spec card_field(kz_term:ne_binary(), kz_json:object()) -> vcard_field(). card_field(Key = <<"BEGIN">>, _) -> {Key, <<"VCARD">>}; card_field(Key = <<"VERSION">>, _) -> @@ -199,10 +199,10 @@ card_field(Key = <<"TZ">>, JObj) -> card_field(Key = <<"NICKNAME">>, JObj) -> {Key, {$,, kz_json:get_value(<<"nicknames">>, JObj, [])}}. --spec content_type_to_type(ne_binary()) -> ne_binary(). +-spec content_type_to_type(kz_term:ne_binary()) -> kz_term:ne_binary(). content_type_to_type(<<"image/jpeg">>) -> <<"JPEG">>. --spec vcard_field_divide_by_length(binary(), binaries()) -> binaries(). +-spec vcard_field_divide_by_length(binary(), kz_term:binaries()) -> kz_term:binaries(). vcard_field_divide_by_length(<>, Acc) -> [Row | Acc]; vcard_field_divide_by_length(<>, Acc) -> @@ -210,7 +210,7 @@ vcard_field_divide_by_length(<>, Acc) -> vcard_field_divide_by_length(Row, Acc) -> [Row | Acc]. --spec normalize_address(kz_json:object()) -> {ne_binary(), binary()}. +-spec normalize_address(kz_json:object()) -> {kz_term:ne_binary(), binary()}. normalize_address(JObj) -> Types = case kz_json:get_value(<<"types">>, JObj) of 'undefined' -> [<<"intl">>, <<"postal">>, <<"parcel">>, <<"work">>]; @@ -219,11 +219,11 @@ normalize_address(JObj) -> Address = kz_json:get_value(<<"address">>, JObj), {kz_binary:join(Types, <<",">>), Address}. --spec timezone(kz_json:object()) -> api_binary(). +-spec timezone(kz_json:object()) -> kz_term:api_binary(). timezone(JObj) -> timezone(JObj, 'undefined'). --spec timezone(kz_json:object(), Default) -> ne_binary() | Default. +-spec timezone(kz_json:object(), Default) -> kz_term:ne_binary() | Default. timezone(JObj, Default) -> case kz_json:get_value(?KEY_TIMEZONE, JObj, Default) of 'undefined' -> kz_account:timezone(kz_doc:account_id(JObj)); @@ -231,14 +231,14 @@ timezone(JObj, Default) -> TZ -> TZ end. --spec presence_id(doc()) -> api_binary(). --spec presence_id(doc(), Default) -> ne_binary() | Default. +-spec presence_id(doc()) -> kz_term:api_binary(). +-spec presence_id(doc(), Default) -> kz_term:ne_binary() | Default. presence_id(UserJObj) -> presence_id(UserJObj, 'undefined'). presence_id(UserJObj, Default) -> kz_json:get_binary_value(?KEY_PRESENCE_ID, UserJObj, Default). --spec set_presence_id(doc(), ne_binary()) -> doc(). +-spec set_presence_id(doc(), kz_term:ne_binary()) -> doc(). set_presence_id(UserJObj, Id) -> kz_json:set_value(?KEY_PRESENCE_ID ,kz_term:to_binary(Id) @@ -260,7 +260,7 @@ enable(JObj) -> disable(JObj) -> kz_json:set_value(?KEY_IS_ENABLED, 'false', JObj). --spec type() -> ne_binary(). +-spec type() -> kz_term:ne_binary(). type() -> <<"user">>. -spec devices(doc()) -> kz_device:docs(). @@ -280,12 +280,12 @@ devices(UserJObj) -> end. --spec is_account_admin(api_object()) -> boolean(). +-spec is_account_admin(kz_term:api_object()) -> boolean(). is_account_admin('undefined') -> 'false'; is_account_admin(Doc) -> priv_level(Doc) =:= <<"admin">>. --spec is_account_admin(api_binary(), api_binary()) -> boolean(). +-spec is_account_admin(kz_term:api_binary(), kz_term:api_binary()) -> boolean(). is_account_admin('undefined', _) -> 'false'; is_account_admin(_, 'undefined') -> 'false'; is_account_admin(Account, UserId) -> @@ -306,51 +306,51 @@ fax_settings(JObj) -> AccountFaxSettings = kz_account:fax_settings(kz_doc:account_id(JObj)), kz_json:merge_jobjs(UserFaxSettings, AccountFaxSettings). --spec name(doc()) -> ne_binary(). +-spec name(doc()) -> kz_term:ne_binary(). name(Doc) -> <<(first_name(Doc, <<>>))/binary ," " ,(last_name(Doc, <<>>))/binary >>. --spec first_name(doc()) -> api_binary(). --spec first_name(doc(), Default) -> ne_binary() | Default. +-spec first_name(doc()) -> kz_term:api_binary(). +-spec first_name(doc(), Default) -> kz_term:ne_binary() | Default. first_name(Doc) -> first_name(Doc, 'undefined'). first_name(Doc, Default) -> kz_json:get_binary_value(?KEY_FIRST_NAME, Doc, Default). --spec last_name(doc()) -> api_binary(). --spec last_name(doc(), Default) -> ne_binary() | Default. +-spec last_name(doc()) -> kz_term:api_binary(). +-spec last_name(doc(), Default) -> kz_term:ne_binary() | Default. last_name(Doc) -> last_name(Doc, 'undefined'). last_name(Doc, Default) -> kz_json:get_binary_value(?KEY_LAST_NAME, Doc, Default). --spec priv_level(doc()) -> api_binary(). --spec priv_level(doc(), Default) -> ne_binary() | Default. +-spec priv_level(doc()) -> kz_term:api_binary(). +-spec priv_level(doc(), Default) -> kz_term:ne_binary() | Default. priv_level(Doc) -> priv_level(Doc, <<"user">>). priv_level(Doc, Default) -> kz_json:get_binary_value(?KEY_PRIV_LEVEL, Doc, Default). --spec set_priv_level(ne_binary(), doc()) -> doc(). +-spec set_priv_level(kz_term:ne_binary(), doc()) -> doc(). set_priv_level(<<"user">>=LVL, Doc) -> kz_json:set_value(?KEY_PRIV_LEVEL, LVL, Doc); set_priv_level(<<"admin">>=LVL, Doc) -> kz_json:set_value(?KEY_PRIV_LEVEL, LVL, Doc). --spec call_restrictions(doc()) -> api_object(). +-spec call_restrictions(doc()) -> kz_term:api_object(). -spec call_restrictions(doc(), Default) -> kz_json:object() | Default. call_restrictions(Doc) -> call_restrictions(Doc, 'undefined'). call_restrictions(Doc, Default) -> kz_json:get_json_value(?KEY_CALL_RESTRICTIONS, Doc, Default). --spec classifier_restriction(doc(), ne_binary()) -> api_ne_binary(). --spec classifier_restriction(doc(), ne_binary(), Default) -> ne_binary() | Default. +-spec classifier_restriction(doc(), kz_term:ne_binary()) -> kz_term:api_ne_binary(). +-spec classifier_restriction(doc(), kz_term:ne_binary(), Default) -> kz_term:ne_binary() | Default. classifier_restriction(Doc, Classifier) -> classifier_restriction(Doc, Classifier, 'undefined'). classifier_restriction(Doc, Classifier, Default) -> @@ -362,7 +362,7 @@ classifier_restriction(Doc, Classifier, Default) -> ,Default ). --spec set_classifier_restriction(doc(), ne_binary(), ne_binary()) -> doc(). +-spec set_classifier_restriction(doc(), kz_term:ne_binary(), kz_term:ne_binary()) -> doc(). set_classifier_restriction(Doc, Classifier, Action) -> kz_json:set_value([?KEY_CALL_RESTRICTIONS ,Classifier diff --git a/core/kazoo_documents/src/kzd_voicemail_box.erl b/core/kazoo_documents/src/kzd_voicemail_box.erl index ef7ece33b74..277e3125e3c 100644 --- a/core/kazoo_documents/src/kzd_voicemail_box.erl +++ b/core/kazoo_documents/src/kzd_voicemail_box.erl @@ -56,11 +56,11 @@ new() -> kz_json:from_list([{<<"pvt_type">>, type()}]). --spec type() -> ne_binary(). +-spec type() -> kz_term:ne_binary(). type() -> ?PVT_TYPE. --spec notification_emails(doc()) -> ne_binaries(). --spec notification_emails(doc(), Default) -> ne_binaries() | Default. +-spec notification_emails(doc()) -> kz_term:ne_binaries(). +-spec notification_emails(doc(), Default) -> kz_term:ne_binaries() | Default. notification_emails(Box) -> notification_emails(Box, []). notification_emails(Box, Default) -> @@ -74,24 +74,24 @@ notification_emails(Box, Default) -> Emails -> Emails end. --spec set_notification_emails(doc(), api_binaries()) -> doc(). +-spec set_notification_emails(doc(), kz_term:api_binaries()) -> doc(). set_notification_emails(Box, 'undefined') -> kz_json:delete_key(?KEY_NOTIFY_EMAILS, Box); set_notification_emails(Box, Emails) -> kz_json:set_value(?KEY_NOTIFY_EMAILS, Emails, Box). --spec owner_id(doc()) -> api_binary(). --spec owner_id(doc(), Default) -> ne_binary() | Default. +-spec owner_id(doc()) -> kz_term:api_binary(). +-spec owner_id(doc(), Default) -> kz_term:ne_binary() | Default. owner_id(Box) -> owner_id(Box, 'undefined'). owner_id(Box, Default) -> kz_json:get_value(?KEY_OWNER_ID, Box, Default). --spec timezone(doc()) -> ne_binary(). +-spec timezone(doc()) -> kz_term:ne_binary(). timezone(Box) -> timezone(Box, 'undefined'). --spec timezone(doc(), Default) -> ne_binary() | Default. +-spec timezone(doc(), Default) -> kz_term:ne_binary() | Default. timezone(Box, Default) -> case kz_json:get_value(?KEY_TIMEZONE, Box) of 'undefined' -> owner_timezone(Box, Default); @@ -99,7 +99,7 @@ timezone(Box, Default) -> TZ -> TZ end. --spec owner_timezone(doc(), Default) -> ne_binary() | Default. +-spec owner_timezone(doc(), Default) -> kz_term:ne_binary() | Default. owner_timezone(Box, Default) -> case kzd_user:fetch(kz_doc:account_db(Box), owner_id(Box)) of {'ok', OwnerJObj} -> kzd_user:timezone(OwnerJObj, Default); @@ -120,15 +120,15 @@ skip_greeting(Box) -> skip_greeting(Box, Default) -> kz_json:is_true(?KEY_SKIP_GREETING, Box, Default). --spec pin(doc()) -> api_binary(). --spec pin(doc(), Default) -> ne_binary() | Default. +-spec pin(doc()) -> kz_term:api_binary(). +-spec pin(doc(), Default) -> kz_term:ne_binary() | Default. pin(Box) -> pin(Box, 'undefined'). pin(Box, Default) -> kz_json:get_binary_value(?KEY_PIN, Box, Default). --spec mailbox_number(doc()) -> api_binary(). --spec mailbox_number(doc(), Default) -> ne_binary() | Default. +-spec mailbox_number(doc()) -> kz_term:api_binary(). +-spec mailbox_number(doc(), Default) -> kz_term:ne_binary() | Default. mailbox_number(Box) -> mailbox_number(Box, 'undefined'). mailbox_number(Box, Default) -> @@ -155,7 +155,7 @@ is_setup(Box) -> is_setup(Box, Default) -> kz_json:is_true(?KEY_IS_SETUP, Box, Default). --spec media_extension(doc()) -> ne_binary(). +-spec media_extension(doc()) -> kz_term:ne_binary(). media_extension(Box) -> AccountId = kz_doc:account_id(Box), kz_json:get_ne_binary_value(<<"media_extension">>, Box, ?ACCOUNT_VM_EXTENSION(AccountId)). diff --git a/core/kazoo_documents/src/kzd_webhook.erl b/core/kazoo_documents/src/kzd_webhook.erl index beea0cfce3e..7886e70a078 100644 --- a/core/kazoo_documents/src/kzd_webhook.erl +++ b/core/kazoo_documents/src/kzd_webhook.erl @@ -60,7 +60,7 @@ enable(Hook) -> ). -spec disable(doc()) -> doc(). --spec disable(doc(), api_binary()) -> doc(). +-spec disable(doc(), kz_term:api_binary()) -> doc(). disable(Hook) -> disable(Hook, 'undefined'). disable(Hook, Reason) -> @@ -72,8 +72,8 @@ disable(Hook, Reason) -> ,Hook ). --spec disabled_message(doc()) -> api_binary(). --spec disabled_message(doc(), Default) -> ne_binary() | Default. +-spec disabled_message(doc()) -> kz_term:api_binary(). +-spec disabled_message(doc(), Default) -> kz_term:ne_binary() | Default. disabled_message(Hook) -> disabled_message(Hook, 'undefined'). disabled_message(Hook, Default) -> @@ -84,43 +84,43 @@ is_auto_disabled(Hook) -> is_enabled(Hook) =:= 'false' andalso disabled_message(Hook) =/= 'undefined'. --spec type() -> ne_binary(). --spec type(doc()) -> api_binary(). +-spec type() -> kz_term:ne_binary(). +-spec type(doc()) -> kz_term:api_binary(). type() -> ?TYPE. type(Hook) -> kz_doc:type(Hook). --spec name(doc()) -> api_binary(). --spec name(doc(), Default) -> ne_binary() | Default. +-spec name(doc()) -> kz_term:api_binary(). +-spec name(doc(), Default) -> kz_term:ne_binary() | Default. name(Hook) -> name(Hook, 'undefined'). name(Hook, Default) -> kz_json:get_value(?NAME, Hook, Default). --spec set_name(doc(), ne_binary()) -> doc(). +-spec set_name(doc(), kz_term:ne_binary()) -> doc(). set_name(Hook, Name) -> kz_json:set_value(?NAME, Name, Hook). --spec uri(doc()) -> api_binary(). --spec uri(doc(), Default) -> ne_binary() | Default. +-spec uri(doc()) -> kz_term:api_binary(). +-spec uri(doc(), Default) -> kz_term:ne_binary() | Default. uri(Hook) -> uri(Hook, 'undefined'). uri(Hook, Default) -> kz_json:get_value(?URI, Hook, Default). --spec set_uri(doc(), ne_binary()) -> doc(). +-spec set_uri(doc(), kz_term:ne_binary()) -> doc(). set_uri(Hook, Uri) -> kz_json:set_value(?URI, Uri, Hook). --spec event(doc()) -> api_binary(). --spec event(doc(), Default) -> ne_binary() | Default. +-spec event(doc()) -> kz_term:api_binary(). +-spec event(doc(), Default) -> kz_term:ne_binary() | Default. event(Hook) -> event(Hook, 'undefined'). event(Hook, Default) -> kz_json:get_value(?EVENT, Hook, Default). --spec set_event(doc(), ne_binary()) -> doc(). +-spec set_event(doc(), kz_term:ne_binary()) -> doc(). set_event(Hook, Event) -> kz_json:set_value(?EVENT, Event, Hook). @@ -136,13 +136,13 @@ verb(Hook, Default) -> Verb -> safe_verbs(kz_term:to_lower_binary(Verb), Default) end. --spec safe_verbs(api_binary(), http_verb() | Default) -> +-spec safe_verbs(kz_term:api_binary(), http_verb() | Default) -> http_verb() | Default. safe_verbs(<<"get">>, _Default) -> <<"get">>; safe_verbs(<<"post">>, _Default) -> <<"post">>; safe_verbs(_Verb, Default) -> Default. --spec set_verb(doc(), ne_binary() | http_verb()) -> doc(). +-spec set_verb(doc(), kz_term:ne_binary() | http_verb()) -> doc(). set_verb(Hook, <<_/binary>> = Verb) -> kz_json:set_value(?VERB, safe_verbs(Verb, <<"get">>), Hook); set_verb(Hook, Verb) when Verb =:= 'get' @@ -170,25 +170,25 @@ constrain_retries(N) when is_integer(N) -> N. set_retries(Hook, Retries) when is_integer(Retries) -> kz_json:set_value(?RETRIES, constrain_retries(Retries), Hook). --spec custom_data(doc()) -> api_object(). +-spec custom_data(doc()) -> kz_term:api_object(). -spec custom_data(doc(), Default) -> kz_json:object() | Default. custom_data(Hook) -> custom_data(Hook, 'undefined'). custom_data(Hook, Default) -> kz_json:get_ne_json_value(?CUSTOM_DATA, Hook, Default). --spec set_custom_data(doc(), api_object()) -> doc(). +-spec set_custom_data(doc(), kz_term:api_object()) -> doc(). set_custom_data(Hook, Custom) -> kz_json:set_value(?CUSTOM_DATA, Custom, Hook). --spec modifiers(doc()) -> api_object(). +-spec modifiers(doc()) -> kz_term:api_object(). -spec modifiers(doc(), Default) -> kz_json:object() | Default. modifiers(Hook) -> modifiers(Hook, 'undefined'). modifiers(Hook, Default) -> kz_json:get_ne_json_value(?MODIFIERS, Hook, Default). --spec set_modifiers(doc(), api_object()) -> doc(). +-spec set_modifiers(doc(), kz_term:api_object()) -> doc(). set_modifiers(Hook, Modifiers) -> kz_json:set_value(?MODIFIERS, Modifiers, Hook). diff --git a/core/kazoo_endpoint/src/kazoo_endpoint_app.erl b/core/kazoo_endpoint/src/kazoo_endpoint_app.erl index e96ac0d7406..636478bc11e 100644 --- a/core/kazoo_endpoint/src/kazoo_endpoint_app.erl +++ b/core/kazoo_endpoint/src/kazoo_endpoint_app.erl @@ -21,7 +21,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> kazoo_endpoint_sup:start_link(). diff --git a/core/kazoo_endpoint/src/kazoo_endpoint_sup.erl b/core/kazoo_endpoint/src/kazoo_endpoint_sup.erl index effeaca3e03..8b81a555209 100644 --- a/core/kazoo_endpoint/src/kazoo_endpoint_sup.erl +++ b/core/kazoo_endpoint/src/kazoo_endpoint_sup.erl @@ -41,7 +41,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -58,7 +58,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/core/kazoo_endpoint/src/kz_attributes.erl b/core/kazoo_endpoint/src/kz_attributes.erl index d01de6ba845..f2a8a1fedf4 100644 --- a/core/kazoo_endpoint/src/kz_attributes.erl +++ b/core/kazoo_endpoint/src/kz_attributes.erl @@ -29,7 +29,7 @@ -include("kazoo_endpoint.hrl"). --type cid() :: {api_binary(), api_binary()}. +-type cid() :: {kz_term:api_binary(), kz_term:api_binary()}. %%----------------------------------------------------------------------------- %% @public @@ -52,7 +52,7 @@ temporal_rules(Call) -> %% @end %%----------------------------------------------------------------------------- -spec groups(kapps_call:call()) -> kz_json:objects(). --spec groups(kapps_call:call(), kz_proplist()) -> kz_json:objects(). +-spec groups(kapps_call:call(), kz_term:proplist()) -> kz_json:objects(). groups(Call) -> groups(Call, []). groups(Call, ViewOptions) -> @@ -67,7 +67,7 @@ groups(Call, ViewOptions) -> %% @doc %% @end %%----------------------------------------------------------------------------- --spec caller_id_type(kapps_call:call()) -> ne_binary(). +-spec caller_id_type(kapps_call:call()) -> kz_term:ne_binary(). caller_id_type(Call) -> case kapps_call:inception(Call) of 'undefined' -> <<"internal">>; @@ -78,7 +78,7 @@ caller_id_type(Call) -> caller_id(Call) -> caller_id(caller_id_type(Call), Call). --spec caller_id(ne_binary(), kapps_call:call()) -> cid(). +-spec caller_id(kz_term:ne_binary(), kapps_call:call()) -> cid(). caller_id(Attribute, Call) -> CCVs = kapps_call:custom_channel_vars(Call), Inception = kapps_call:inception(Call), @@ -97,7 +97,7 @@ caller_id(Attribute, Call) -> maybe_get_dynamic_cid('true', Attribute, Call) end. --spec maybe_get_dynamic_cid(boolean(), ne_binary(), kapps_call:call()) -> cid(). +-spec maybe_get_dynamic_cid(boolean(), kz_term:ne_binary(), kapps_call:call()) -> cid(). maybe_get_dynamic_cid(Validate, Attribute, Call) -> case kapps_call:kvs_fetch('dynamic_cid', Call) of 'undefined' -> maybe_get_endpoint_cid(Validate, Attribute, Call); @@ -109,7 +109,7 @@ maybe_get_dynamic_cid(Validate, Attribute, Call) -> maybe_normalize_cid(DynamicCID, 'undefined', Validate, Attribute, Call) end. --spec maybe_get_endpoint_cid(boolean(), ne_binary(), kapps_call:call()) -> cid(). +-spec maybe_get_endpoint_cid(boolean(), kz_term:ne_binary(), kapps_call:call()) -> cid(). maybe_get_endpoint_cid(Validate, Attribute, Call) -> case kz_endpoint:get(Call) of {'error', _R} -> @@ -123,7 +123,7 @@ maybe_get_endpoint_cid(Validate, Attribute, Call) -> maybe_use_presence_number(Number, Name, JObj, Validate, Attribute, Call1) end. --spec maybe_add_originals_to_kvs(api_ne_binary(), api_ne_binary(), kapps_call:call()) -> kapps_call:call(). +-spec maybe_add_originals_to_kvs(kz_term:api_ne_binary(), kz_term:api_ne_binary(), kapps_call:call()) -> kapps_call:call(). maybe_add_originals_to_kvs('undefined', 'undefined', Call) -> Call; maybe_add_originals_to_kvs('undefined', ?NE_BINARY=Name, Call) -> kapps_call:exec([fun(C) -> kapps_call:kvs_store('original_cid_name', Name, C) end], Call); @@ -135,7 +135,7 @@ maybe_add_originals_to_kvs(Number, Name, Call) -> ], kapps_call:exec(Updates, Call). --spec log_configured_endpoint_cid(ne_binary(), api_binary(), api_binary()) -> 'ok'. +-spec log_configured_endpoint_cid(kz_term:ne_binary(), kz_term:api_binary(), kz_term:api_binary()) -> 'ok'. log_configured_endpoint_cid(Attribute, 'undefined', 'undefined') -> lager:debug("endpoint not configured with an ~s caller id", [Attribute]); log_configured_endpoint_cid(Attribute, Name, 'undefined') -> @@ -145,7 +145,7 @@ log_configured_endpoint_cid(Attribute, 'undefined', Number) -> log_configured_endpoint_cid(Attribute, Name, Number) -> lager:debug("endpoint configured with ~s caller id <~s> ~s", [Attribute, Name, Number]). --spec maybe_use_presence_number(api_binary(), api_binary(), kz_json:object(), boolean(), ne_binary(), kapps_call:call()) -> cid(). +-spec maybe_use_presence_number(kz_term:api_binary(), kz_term:api_binary(), kz_json:object(), boolean(), kz_term:ne_binary(), kapps_call:call()) -> cid(). maybe_use_presence_number('undefined', Name, Endpoint, Validate, <<"internal">> = Attribute, Call) -> case maybe_get_presence_number(Endpoint, Call) of 'undefined' -> @@ -157,7 +157,7 @@ maybe_use_presence_number('undefined', Name, Endpoint, Validate, <<"internal">> maybe_use_presence_number(Number, Name, Endpoint, Validate, Attribute, Call) -> maybe_format_cid_number(Number, Name, Endpoint, Validate, Attribute, Call). --spec maybe_format_cid_number(api_binary(), api_binary(), kz_json:object(), boolean(), ne_binary(), kapps_call:call()) -> cid(). +-spec maybe_format_cid_number(kz_term:api_binary(), kz_term:api_binary(), kz_json:object(), boolean(), kz_term:ne_binary(), kapps_call:call()) -> cid(). maybe_format_cid_number('undefined', Name, Endpoint, Validate, Attribute, Call) -> Number = kapps_call:caller_id_number(Call), Format = kz_json:get_ne_value([<<"caller_id_options">>, <<"format">>], Endpoint), @@ -168,7 +168,7 @@ maybe_format_cid_number(Number, Name, Endpoint, Validate, Attribute, Call) -> Formatted = kapps_call:maybe_format_caller_id_str(Number, Format), maybe_normalize_cid(Formatted, Name, Validate, Attribute, Call). --spec maybe_normalize_cid(api_binary(), api_binary(), boolean(), ne_binary(), kapps_call:call()) -> cid(). +-spec maybe_normalize_cid(kz_term:api_binary(), kz_term:api_binary(), boolean(), kz_term:ne_binary(), kapps_call:call()) -> cid(). maybe_normalize_cid('undefined', Name, Validate, Attribute, Call) -> Number = kapps_call:caller_id_number(Call), lager:debug("replacing empty caller id number with SIP caller id number ~s", [Number]), @@ -180,7 +180,7 @@ maybe_normalize_cid(Number, 'undefined', Validate, Attribute, Call) -> maybe_normalize_cid(Number, Name, Validate, Attribute, Call) -> maybe_prefix_cid_number(kz_term:to_binary(Number), Name, Validate, Attribute, Call). --spec maybe_prefix_cid_number(ne_binary(), ne_binary(), boolean(), ne_binary(), kapps_call:call()) -> cid(). +-spec maybe_prefix_cid_number(kz_term:ne_binary(), kz_term:ne_binary(), boolean(), kz_term:ne_binary(), kapps_call:call()) -> cid(). maybe_prefix_cid_number(Number, Name, Validate, Attribute, Call) -> OrigNumber = kapps_call:kvs_fetch('original_cid_number', Number, Call), case kapps_call:kvs_fetch('prepend_cid_number', Call) of @@ -191,7 +191,7 @@ maybe_prefix_cid_number(Number, Name, Validate, Attribute, Call) -> maybe_prefix_cid_name(Prefixed, Name, Validate, Attribute, Call) end. --spec maybe_prefix_cid_name(ne_binary(), ne_binary(), boolean(), ne_binary(), kapps_call:call()) -> cid(). +-spec maybe_prefix_cid_name(kz_term:ne_binary(), kz_term:ne_binary(), boolean(), kz_term:ne_binary(), kapps_call:call()) -> cid(). maybe_prefix_cid_name(Number, Name, Validate, Attribute, Call) -> OrigName = kapps_call:kvs_fetch('original_cid_name', Name, Call), case kapps_call:kvs_fetch('prepend_cid_name', Call) of @@ -202,7 +202,7 @@ maybe_prefix_cid_name(Number, Name, Validate, Attribute, Call) -> maybe_rewrite_cid_number(Number, Prefixed, Validate, Attribute, Call) end. --spec maybe_rewrite_cid_number(ne_binary(), ne_binary(), boolean(), ne_binary(), kapps_call:call()) -> cid(). +-spec maybe_rewrite_cid_number(kz_term:ne_binary(), kz_term:ne_binary(), boolean(), kz_term:ne_binary(), kapps_call:call()) -> cid(). maybe_rewrite_cid_number(Number, Name, Validate, Attribute, Call) -> case kapps_call:kvs_fetch('rewrite_cid_number', Call) of 'undefined' -> maybe_rewrite_cid_name(Number, Name, Validate, Attribute, Call); @@ -211,7 +211,7 @@ maybe_rewrite_cid_number(Number, Name, Validate, Attribute, Call) -> maybe_rewrite_cid_name(NewNumber, Name, Validate, Attribute, Call) end. --spec maybe_rewrite_cid_name(ne_binary(), ne_binary(), boolean(), ne_binary(), kapps_call:call()) -> cid(). +-spec maybe_rewrite_cid_name(kz_term:ne_binary(), kz_term:ne_binary(), boolean(), kz_term:ne_binary(), kapps_call:call()) -> cid(). maybe_rewrite_cid_name(Number, Name, Validate, Attribute, Call) -> case kapps_call:kvs_fetch('rewrite_cid_name', Call) of 'undefined' -> maybe_ensure_cid_valid(Number, Name, Validate, Attribute, Call); @@ -220,7 +220,7 @@ maybe_rewrite_cid_name(Number, Name, Validate, Attribute, Call) -> maybe_ensure_cid_valid(Number, NewName, Validate, Attribute, Call) end. --spec maybe_ensure_cid_valid(ne_binary(), ne_binary(), boolean(), ne_binary(), kapps_call:call()) -> cid(). +-spec maybe_ensure_cid_valid(kz_term:ne_binary(), kz_term:ne_binary(), boolean(), kz_term:ne_binary(), kapps_call:call()) -> cid(). maybe_ensure_cid_valid(Number, Name, 'true', <<"emergency">>, _Call) -> lager:info("determined emergency caller id is <~s> ~s", [Name, Number]), {Number, Name}; @@ -235,7 +235,7 @@ maybe_ensure_cid_valid(Number, Name, _, Attribute, _Call) -> lager:info("determined ~s caller id is <~s> ~s", [Attribute, Name, Number]), {Number, Name}. --spec ensure_valid_caller_id(ne_binary(), ne_binary(), kapps_call:call()) -> cid(). +-spec ensure_valid_caller_id(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> cid(). ensure_valid_caller_id(Number, Name, Call) -> case is_valid_caller_id(Number, Call) of 'true' -> @@ -255,14 +255,14 @@ get_account_external_cid(Call) -> maybe_get_account_cid(Number, Name, Call). --spec maybe_get_account_cid(ne_binary(), ne_binary(), kapps_call:call()) -> cid(). +-spec maybe_get_account_cid(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call()) -> cid(). maybe_get_account_cid(Number, Name, Call) -> case kz_account:fetch(kapps_call:account_id(Call)) of {'error', _} -> maybe_get_assigned_number(Number, Name, Call); {'ok', JObj} -> maybe_get_account_external_number(Number, Name, JObj, Call) end. --spec maybe_get_account_external_number(ne_binary(), ne_binary(), kz_json:object(), kapps_call:call()) -> cid(). +-spec maybe_get_account_external_number(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), kapps_call:call()) -> cid(). maybe_get_account_external_number(Number, Name, Account, Call) -> External = kz_json:get_ne_value([<<"caller_id">>, <<"external">>, <<"number">>], Account), case is_valid_caller_id(External, Call) of @@ -273,7 +273,7 @@ maybe_get_account_external_number(Number, Name, Account, Call) -> maybe_get_account_default_number(Number, Name, Account, Call) end. --spec maybe_get_account_default_number(ne_binary(), ne_binary(), kz_json:object(), kapps_call:call()) -> cid(). +-spec maybe_get_account_default_number(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), kapps_call:call()) -> cid(). maybe_get_account_default_number(Number, Name, Account, Call) -> Default = kz_json:get_ne_value([<<"caller_id">>, <<"default">>, <<"number">>], Account), case is_valid_caller_id(Default, Call) of @@ -284,7 +284,7 @@ maybe_get_account_default_number(Number, Name, Account, Call) -> maybe_get_assigned_number(Number, Name, Call) end. --spec maybe_get_assigned_number(api_ne_binary(), api_ne_binary(), api_ne_binary()|kapps_call:call()) -> cid(). +-spec maybe_get_assigned_number(kz_term:api_ne_binary(), kz_term:api_ne_binary(), kz_term:api_ne_binary()|kapps_call:call()) -> cid(). maybe_get_assigned_number(CandidateNumber, Name, ?MATCH_ACCOUNT_ENCODED(_)=AccountDb) -> AccountId = kz_util:format_account_id(AccountDb), case knm_numbers:account_listing(AccountDb) of @@ -306,7 +306,7 @@ maybe_get_assigned_number(CandidateNumber, Name, Call) -> AccountDb = kapps_call:account_db(Call), maybe_get_assigned_number(CandidateNumber, Name, AccountDb). --spec maybe_get_assigned_numbers(ne_binary(), ne_binaries(), ne_binary()) -> cid(). +-spec maybe_get_assigned_numbers(kz_term:ne_binary(), kz_term:ne_binaries(), kz_term:ne_binary()) -> cid(). maybe_get_assigned_numbers(AccountId, [], Name) -> Number = default_cid_number(AccountId), lager:info("failed to find any in-service numbers, using default <~s> ~s", [Name, Number]), @@ -317,7 +317,7 @@ maybe_get_assigned_numbers(_AccountId, [Number|_], Name) -> lager:info("using first assigned number caller id <~s> ~s", [Name, Number]), {Number, Name}. --spec is_valid_caller_id(api_binary(), kapps_call:call()) -> boolean(). +-spec is_valid_caller_id(kz_term:api_binary(), kapps_call:call()) -> boolean(). is_valid_caller_id('undefined', _) -> 'false'; is_valid_caller_id(Number, Call) -> AccountId = kapps_call:account_id(Call), @@ -326,7 +326,7 @@ is_valid_caller_id(Number, Call) -> _Else -> 'false' end. --spec maybe_get_presence_number(kz_json:object(), kapps_call:call()) -> api_binary(). +-spec maybe_get_presence_number(kz_json:object(), kapps_call:call()) -> kz_term:api_binary(). maybe_get_presence_number(Endpoint, Call) -> case presence_id(Endpoint, Call, 'undefined') of 'undefined' -> 'undefined'; @@ -342,7 +342,7 @@ maybe_get_presence_number(Endpoint, Call) -> %% @doc %% @end %%----------------------------------------------------------------------------- --spec callee_id(api_binary() | kz_json:object(), kapps_call:call()) -> cid(). +-spec callee_id(kz_term:api_binary() | kz_json:object(), kapps_call:call()) -> cid(). callee_id(EndpointId, Call) when is_binary(EndpointId) -> case kz_endpoint:get(EndpointId, Call) of {'ok', Endpoint} -> callee_id(Endpoint, Call); @@ -355,7 +355,7 @@ callee_id(Endpoint, Call) -> Name = get_cid_or_default(Attribute, <<"name">>, Endpoint), maybe_normalize_callee(Number, Name, Endpoint, Call). --spec maybe_normalize_callee(api_binary(), api_binary(), kz_json:object(), kapps_call:call()) -> cid(). +-spec maybe_normalize_callee(kz_term:api_binary(), kz_term:api_binary(), kz_json:object(), kapps_call:call()) -> cid(). maybe_normalize_callee('undefined', Name, Endpoint, Call) -> maybe_normalize_callee(kapps_call:request_user(Call), Name, Endpoint, Call); maybe_normalize_callee(Number, 'undefined', Endpoint, Call) -> @@ -364,7 +364,7 @@ maybe_normalize_callee(Number, Name, _, _) -> lager:info("callee id <~s> ~s", [Name, Number]), {Number, Name}. --spec determine_callee_attribute(kapps_call:call()) -> ne_binary(). +-spec determine_callee_attribute(kapps_call:call()) -> kz_term:ne_binary(). determine_callee_attribute(Call) -> case kapps_call:inception(Call) =/= 'undefined' of 'true' -> <<"external">>; @@ -376,8 +376,8 @@ determine_callee_attribute(Call) -> %% @doc %% @end %%----------------------------------------------------------------------------- --spec moh_attributes(ne_binary(), kapps_call:call()) -> api_binary(). --spec moh_attributes(api_binary() | kz_json:object(), ne_binary(), kapps_call:call()) -> api_binary(). +-spec moh_attributes(kz_term:ne_binary(), kapps_call:call()) -> kz_term:api_binary(). +-spec moh_attributes(kz_term:api_binary() | kz_json:object(), kz_term:ne_binary(), kapps_call:call()) -> kz_term:api_binary(). moh_attributes(Attribute, Call) -> case kz_endpoint:get(Call) of @@ -399,7 +399,7 @@ moh_attributes(Endpoint, Attribute, Call) -> Value = kz_json:get_ne_value([<<"music_on_hold">>, Attribute], Endpoint), maybe_normalize_moh_attribute(Value, Attribute, Call). --spec maybe_normalize_moh_attribute(api_binary(), ne_binary(), kapps_call:call()) -> api_binary(). +-spec maybe_normalize_moh_attribute(kz_term:api_binary(), kz_term:ne_binary(), kapps_call:call()) -> kz_term:api_binary(). maybe_normalize_moh_attribute('undefined', _, _) -> 'undefined'; maybe_normalize_moh_attribute(Value, <<"media_id">>, Call) -> MediaId = kz_media_util:media_path(Value, kapps_call:account_id(Call)), @@ -414,8 +414,8 @@ maybe_normalize_moh_attribute(Value, Attribute, _) -> %% @doc %% @end %%----------------------------------------------------------------------------- --spec owner_id(kapps_call:call()) -> api_ne_binary(). --spec owner_id(api_ne_binary(), kapps_call:call()) -> api_ne_binary(). +-spec owner_id(kapps_call:call()) -> kz_term:api_ne_binary(). +-spec owner_id(kz_term:api_ne_binary(), kapps_call:call()) -> kz_term:api_ne_binary(). owner_id(Call) -> case kz_endpoint:get(Call) of @@ -445,7 +445,7 @@ owner_id(ObjectId, Call) -> 'undefined' end. --spec owner_ids(api_binary(), kapps_call:call()) -> ne_binaries(). +-spec owner_ids(kz_term:api_binary(), kapps_call:call()) -> kz_term:ne_binaries(). owner_ids('undefined', _Call) -> []; owner_ids(ObjectId, Call) -> AccountDb = kapps_call:account_db(Call), @@ -466,11 +466,11 @@ owner_ids(ObjectId, Call) -> %% This function will return the precense id for the endpoint %% @end %%-------------------------------------------------------------------- --spec presence_id(kapps_call:call()) -> api_binary(). +-spec presence_id(kapps_call:call()) -> kz_term:api_binary(). presence_id(Call) -> presence_id(kapps_call:authorizing_id(Call), Call). --spec presence_id(api_binary() | kz_json:object(), kapps_call:call()) -> api_binary(). +-spec presence_id(kz_term:api_binary() | kz_json:object(), kapps_call:call()) -> kz_term:api_binary(). presence_id(EndpointId, Call) when is_binary(EndpointId) -> case kz_endpoint:get(EndpointId, Call) of {'ok', Endpoint} -> presence_id(Endpoint, Call); @@ -480,7 +480,7 @@ presence_id(Endpoint, Call) -> Username = kz_device:sip_username(Endpoint, kapps_call:request_user(Call)), presence_id(Endpoint, Call, Username). --spec presence_id(kz_json:object(), kapps_call:call(), Default) -> ne_binary() | Default. +-spec presence_id(kz_json:object(), kapps_call:call(), Default) -> kz_term:ne_binary() | Default. presence_id(Endpoint, Call, Default) -> PresenceId = kz_device:presence_id(Endpoint, Default), case kz_term:is_empty(PresenceId) of @@ -488,7 +488,7 @@ presence_id(Endpoint, Call, Default) -> 'false' -> maybe_fix_presence_id_realm(PresenceId, Endpoint, Call) end. --spec maybe_fix_presence_id_realm(ne_binary(), kz_json:object(), kapps_call:call()) -> api_ne_binary(). +-spec maybe_fix_presence_id_realm(kz_term:ne_binary(), kz_json:object(), kapps_call:call()) -> kz_term:api_ne_binary(). maybe_fix_presence_id_realm('undefined', _Endpoint, _Call) -> 'undefined'; maybe_fix_presence_id_realm(PresenceId, Endpoint, Call) -> case binary:match(PresenceId, <<"@">>) of @@ -506,8 +506,8 @@ maybe_fix_presence_id_realm(PresenceId, Endpoint, Call) -> %% @doc %% @end %%----------------------------------------------------------------------------- --spec owned_by(api_binary(), kapps_call:call()) -> api_binaries(). --spec owned_by(api_binary() | api_binaries(), ne_binary(), kapps_call:call()) -> api_binaries(). +-spec owned_by(kz_term:api_binary(), kapps_call:call()) -> kz_term:api_binaries(). +-spec owned_by(kz_term:api_binary() | kz_term:api_binaries(), kz_term:ne_binary(), kapps_call:call()) -> kz_term:api_binaries(). owned_by('undefined', _) -> []; owned_by(OwnerId, Call) -> @@ -529,8 +529,8 @@ owned_by([_|_]=OwnerIds, Type, Call) -> owned_by(OwnerId, Type, Call) -> owned_by_query([{'key', [OwnerId, Type]}], Call). --spec owned_by_docs(api_binary(), kapps_call:call()) -> api_objects(). --spec owned_by_docs(api_binary() | api_binaries(), ne_binary(), kapps_call:call()) -> api_objects(). +-spec owned_by_docs(kz_term:api_binary(), kapps_call:call()) -> kz_term:api_objects(). +-spec owned_by_docs(kz_term:api_binary() | kz_term:api_binaries(), kz_term:ne_binary(), kapps_call:call()) -> kz_term:api_objects(). owned_by_docs('undefined', _) -> []; owned_by_docs(OwnerId, Call) -> @@ -553,8 +553,8 @@ owned_by_docs([_|_]=OwnerIds, Type, Call) -> owned_by_docs(OwnerId, Type, Call) -> owned_by_query([{'key', [OwnerId, Type]}, 'include_docs'], Call, <<"doc">>). --spec owned_by_query(list(), kapps_call:call()) -> api_binaries(). --spec owned_by_query(list(), kapps_call:call(), ne_binary()) -> api_binaries(). +-spec owned_by_query(list(), kapps_call:call()) -> kz_term:api_binaries(). +-spec owned_by_query(list(), kapps_call:call(), kz_term:ne_binary()) -> kz_term:api_binaries(). owned_by_query(ViewOptions, Call) -> owned_by_query(ViewOptions, Call, <<"value">>). owned_by_query(ViewOptions, Call, ViewKey) -> @@ -571,7 +571,7 @@ owned_by_query(ViewOptions, Call, ViewKey) -> %% @doc %% @end %%----------------------------------------------------------------------------- --spec get_flags(ne_binary(), kapps_call:call()) -> ne_binaries() | undefined. +-spec get_flags(kz_term:ne_binary(), kapps_call:call()) -> kz_term:ne_binaries() | undefined. get_flags(ApplicationName, Call) -> Routines = [fun maybe_get_endpoint_static_flags/3 ,fun get_account_static_flags/3 @@ -583,8 +583,8 @@ get_flags(ApplicationName, Call) -> Flags = lists:foldl(fun(F, A) -> F(ApplicationName, Call, A) end, [], Routines), sets:to_list(sets:from_list(Flags)). --spec maybe_get_endpoint_static_flags(ne_binary(), kapps_call:call(), ne_binaries()) -> - ne_binaries(). +-spec maybe_get_endpoint_static_flags(kz_term:ne_binary(), kapps_call:call(), kz_term:ne_binaries()) -> + kz_term:ne_binaries(). maybe_get_endpoint_static_flags(_, Call, Flags) -> case kz_endpoint:get(Call) of {'error', _R} -> Flags; @@ -592,13 +592,13 @@ maybe_get_endpoint_static_flags(_, Call, Flags) -> get_endpoint_static_flags(Flags, Endpoint) end. --spec get_endpoint_static_flags(ne_binaries(), kz_json:object()) -> - ne_binaries(). +-spec get_endpoint_static_flags(kz_term:ne_binaries(), kz_json:object()) -> + kz_term:ne_binaries(). get_endpoint_static_flags(Flags, Endpoint) -> kz_device:outbound_static_flags(Endpoint) ++ Flags. --spec get_account_static_flags(ne_binary(), kapps_call:call(), ne_binaries()) -> - ne_binaries(). +-spec get_account_static_flags(kz_term:ne_binary(), kapps_call:call(), kz_term:ne_binaries()) -> + kz_term:ne_binaries(). get_account_static_flags(_, Call, Flags) -> AccountId = kapps_call:account_id(Call), case kz_account:fetch(AccountId) of @@ -608,8 +608,8 @@ get_account_static_flags(_, Call, Flags) -> Flags end. --spec get_config_static_flags(ne_binary(), kapps_call:call(), ne_binaries()) -> - ne_binaries(). +-spec get_config_static_flags(kz_term:ne_binary(), kapps_call:call(), kz_term:ne_binaries()) -> + kz_term:ne_binaries(). get_config_static_flags(ApplicationName, Call, Flags) -> kapps_account_config:get_ne_binaries(kapps_call:account_id(Call) ,ApplicationName @@ -618,24 +618,24 @@ get_config_static_flags(ApplicationName, Call, Flags) -> ) ++ Flags. --spec maybe_get_endpoint_dynamic_flags(ne_binary(), kapps_call:call(), ne_binaries()) -> - ne_binaries(). +-spec maybe_get_endpoint_dynamic_flags(kz_term:ne_binary(), kapps_call:call(), kz_term:ne_binaries()) -> + kz_term:ne_binaries(). maybe_get_endpoint_dynamic_flags(_, Call, Flags) -> case kz_endpoint:get(Call) of {'error', _} -> Flags; {'ok', Endpoint} -> get_endpoint_dynamic_flags(Call, Flags, Endpoint) end. --spec get_endpoint_dynamic_flags(kapps_call:call(), ne_binaries(), kz_json:object()) -> - ne_binaries(). +-spec get_endpoint_dynamic_flags(kapps_call:call(), kz_term:ne_binaries(), kz_json:object()) -> + kz_term:ne_binaries(). get_endpoint_dynamic_flags(Call, Flags, Endpoint) -> case kz_device:outbound_dynamic_flags(Endpoint) of [] -> Flags; DynamicFlags -> process_dynamic_flags(DynamicFlags, Flags, Call) end. --spec get_account_dynamic_flags(ne_binary(), kapps_call:call(), ne_binaries()) -> - ne_binaries(). +-spec get_account_dynamic_flags(kz_term:ne_binary(), kapps_call:call(), kz_term:ne_binaries()) -> + kz_term:ne_binaries(). get_account_dynamic_flags(_, Call, Flags) -> AccountId = kapps_call:account_id(Call), case kz_account:fetch(AccountId) of @@ -646,8 +646,8 @@ get_account_dynamic_flags(_, Call, Flags) -> Flags end. --spec get_config_dynamic_flags(kz_json:object(), kapps_call:call(), ne_binaries()) -> - ne_binaries(). +-spec get_config_dynamic_flags(kz_json:object(), kapps_call:call(), kz_term:ne_binaries()) -> + kz_term:ne_binaries(). get_config_dynamic_flags(ApplicationName, Call, Flags) -> DynamicFlags = kapps_account_config:get_ne_binaries(kapps_call:account_id(Call) ,ApplicationName @@ -661,12 +661,12 @@ get_config_dynamic_flags(ApplicationName, Call, Flags) -> %% @doc %% @end %%----------------------------------------------------------------------------- --spec process_dynamic_flags(ne_binaries(), kapps_call:call()) -> ne_binaries(). +-spec process_dynamic_flags(kz_term:ne_binaries(), kapps_call:call()) -> kz_term:ne_binaries(). process_dynamic_flags(DynamicFlags, Call) -> process_dynamic_flags(DynamicFlags, [], Call). --spec process_dynamic_flags(ne_binaries(), ne_binaries(), kapps_call:call()) -> - ne_binaries(). +-spec process_dynamic_flags(kz_term:ne_binaries(), kz_term:ne_binaries(), kapps_call:call()) -> + kz_term:ne_binaries(). process_dynamic_flags([], Flags, _) -> Flags; process_dynamic_flags([<<"zone">>|DynamicFlags], Flags, Call) -> Zone = kz_term:to_binary(kz_nodes:local_zone()), @@ -690,7 +690,7 @@ process_dynamic_flags([DynamicFlag|DynamicFlags], Flags, Call) -> process_dynamic_flags(DynamicFlags, [Flag|Flags], Call) end. --spec is_flag_exported(ne_binary()) -> boolean(). +-spec is_flag_exported(kz_term:ne_binary()) -> boolean(). is_flag_exported(Flag) -> is_flag_exported(kz_term:to_binary(Flag), kapps_call:module_info('exports')). @@ -705,14 +705,14 @@ is_flag_exported(Flag, [_|Funs]) -> is_flag_exported(Flag, Funs). %% @doc %% @end %%----------------------------------------------------------------------------- --spec default_cid_number(ne_binary()) -> ne_binary(). +-spec default_cid_number(kz_term:ne_binary()) -> kz_term:ne_binary(). default_cid_number(AccountId) -> kapps_config:get_ne_binary(?CONFIG_CAT ,<<"default_caller_id_number">> ,kz_privacy:anonymous_caller_id_number(AccountId) ). --spec default_cid_name(kz_json:object(), kapps_call:call()) -> ne_binary(). +-spec default_cid_name(kz_json:object(), kapps_call:call()) -> kz_term:ne_binary(). default_cid_name('undefined', Call) -> AccountId = kapps_call:account_id(Call), kapps_config:get_ne_binary(?CONFIG_CAT @@ -723,7 +723,7 @@ default_cid_name(<<_/binary>> = Name, _Call) -> Name; default_cid_name(Endpoint, Call) -> default_cid_name(kz_json:get_ne_value(<<"name">>, Endpoint), Call). --spec get_cid_or_default(ne_binary(), ne_binary(), kz_json:object()) -> api_ne_binary(). +-spec get_cid_or_default(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> kz_term:api_ne_binary(). get_cid_or_default(<<"emergency">>, Property, Endpoint) -> case kz_json:get_first_defined([[<<"caller_id">>, <<"emergency">>, Property] ,[<<"caller_id">>, <<"external">>, Property] diff --git a/core/kazoo_endpoint/src/kz_endpoint.erl b/core/kazoo_endpoint/src/kz_endpoint.erl index 977f6f7ebe5..5f15228cb9e 100644 --- a/core/kazoo_endpoint/src/kz_endpoint.erl +++ b/core/kazoo_endpoint/src/kz_endpoint.erl @@ -85,7 +85,7 @@ -define(RECORDING_ARGS(Call, Data), [kapps_call:clear_helpers(Call), Data]). --type sms_route() :: {binary(), kz_proplist()}. +-type sms_route() :: {binary(), kz_term:proplist()}. -type sms_routes() :: [sms_route(), ...]. -type api_std_return() :: {'ok', kz_json:object()} | @@ -99,7 +99,7 @@ %% @end %%-------------------------------------------------------------------- -spec get(kapps_call:call()) -> api_std_return(). --spec get(api_binary(), ne_binary() | kapps_call:call()) -> api_std_return(). +-spec get(kz_term:api_binary(), kz_term:ne_binary() | kapps_call:call()) -> api_std_return(). get(Call) -> get(kapps_call:authorizing_id(Call), Call). @@ -116,7 +116,7 @@ get(EndpointId, AccountDb) when is_binary(AccountDb) -> get(EndpointId, Call) -> get(EndpointId, kapps_call:account_db(Call)). --spec maybe_fetch_endpoint(ne_binary(), ne_binary()) -> +-spec maybe_fetch_endpoint(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. maybe_fetch_endpoint(EndpointId, AccountDb) -> @@ -128,7 +128,7 @@ maybe_fetch_endpoint(EndpointId, AccountDb) -> E end. --spec check_endpoint_type(kz_json:object(), ne_binary(), ne_binary()) -> +-spec check_endpoint_type(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. check_endpoint_type(JObj, EndpointId, AccountDb) -> @@ -142,12 +142,12 @@ check_endpoint_type(JObj, EndpointId, AccountDb) -> check_endpoint_enabled(JObj, EndpointId, AccountDb, EndpointType) end. --spec endpoint_type_as(api_binary()) -> api_binary(). +-spec endpoint_type_as(kz_term:api_binary()) -> kz_term:api_binary(). endpoint_type_as(<<"click2call">>) -> <<"device">>; endpoint_type_as(<<"conference">>) -> <<"device">>; endpoint_type_as(Type) -> Type. --spec check_endpoint_enabled(kz_json:object(), ne_binary(), ne_binary(), ne_binary()) -> +-spec check_endpoint_enabled(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. check_endpoint_enabled(JObj, EndpointId, AccountDb, EndpointType) -> @@ -166,7 +166,7 @@ check_endpoint_enabled(JObj, EndpointId, AccountDb, EndpointType) -> cache_store_endpoint(JObj, EndpointId, AccountDb, EndpointType) end. --spec is_endpoint_enabled(kz_json:object(), ne_binary()) -> boolean(). +-spec is_endpoint_enabled(kz_json:object(), kz_term:ne_binary()) -> boolean(). is_endpoint_enabled(JObj, <<"account">>) -> kz_account:is_enabled(JObj); is_endpoint_enabled(JObj, <<"user">>) -> @@ -176,7 +176,7 @@ is_endpoint_enabled(JObj, <<"device">>) -> is_endpoint_enabled(JObj, _) -> kz_json:is_true(<<"enabled">>, JObj, 'true'). --spec cache_store_endpoint(kz_json:object(), ne_binary(), ne_binary(), ne_binary()) -> +-spec cache_store_endpoint(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()}. cache_store_endpoint(JObj, EndpointId, AccountDb, EndpointType) -> Endpoint = kz_json:set_value(<<"Endpoint-ID">>, EndpointId, merge_attributes(JObj, EndpointType)), @@ -184,7 +184,7 @@ cache_store_endpoint(JObj, EndpointId, AccountDb, EndpointType) -> catch kz_cache:store_local(?CACHE_NAME, {?MODULE, AccountDb, EndpointId}, Endpoint, CacheProps), {'ok', Endpoint}. --spec cache_origin(kz_json:object(), ne_binary(), ne_binary()) -> list(). +-spec cache_origin(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> list(). cache_origin(JObj, EndpointId, AccountDb) -> Routines = [fun(P) -> [{'db', AccountDb, EndpointId} | P] end ,fun(P) -> @@ -197,14 +197,14 @@ cache_origin(JObj, EndpointId, AccountDb) -> ], lists:foldl(fun(F, P) -> F(P) end, [], Routines). --spec maybe_cached_owner_id(kz_proplist(), kz_json:object(), ne_binary()) -> kz_proplist(). +-spec maybe_cached_owner_id(kz_term:proplist(), kz_json:object(), kz_term:ne_binary()) -> kz_term:proplist(). maybe_cached_owner_id(Props, JObj, AccountDb) -> case kz_json:get_ne_binary_value(<<"owner_id">>, JObj) of 'undefined' -> Props; OwnerId -> [{'db', AccountDb, OwnerId}|Props] end. --spec maybe_cached_hotdesk_ids(kz_proplist(), kz_json:object(), ne_binary()) -> kz_proplist(). +-spec maybe_cached_hotdesk_ids(kz_term:proplist(), kz_json:object(), kz_term:ne_binary()) -> kz_term:proplist(). maybe_cached_hotdesk_ids(Props, JObj, AccountDb) -> case kz_json:get_keys([<<"hotdesk">>, <<"users">>], JObj) of [] -> Props; @@ -225,8 +225,8 @@ maybe_format_endpoint(Endpoint, 'false') -> lager:debug("formatted as ~p", [Formatted]), Formatted. --spec merge_attributes(kz_json:object(), ne_binary()) -> kz_json:object(). --spec merge_attributes(kz_json:object(), ne_binary(), ne_binaries()) -> kz_json:object(). +-spec merge_attributes(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). +-spec merge_attributes(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binaries()) -> kz_json:object(). merge_attributes(Endpoint, Type) -> merge_attributes(Endpoint, Type, attributes_keys()). @@ -270,7 +270,7 @@ merge_attributes(Endpoint, Type, _Keys) -> lager:debug("unhandled endpoint type on merge attributes : ~p : ~p", [Type, Endpoint]), kz_json:new(). --spec merge_attributes(ne_binaries(), api_object(), api_object(), api_object()) -> +-spec merge_attributes(kz_term:ne_binaries(), kz_term:api_object(), kz_term:api_object(), kz_term:api_object()) -> kz_json:object(). merge_attributes(Keys, AccountDoc, EndpointDoc, OwnerDoc) -> lists:foldl(fun(Key, EP) -> @@ -280,7 +280,7 @@ merge_attributes(Keys, AccountDoc, EndpointDoc, OwnerDoc) -> ,Keys ). --spec merge_attribute(ne_binary(), api_object(), api_object(), api_object()) -> kz_json:object(). +-spec merge_attribute(kz_term:ne_binary(), kz_term:api_object(), kz_term:api_object(), kz_term:api_object()) -> kz_json:object(). merge_attribute(?ATTR_LOWER_KEY, _Account, Endpoint, Owner) -> FullKey = [?ATTR_LOWER_KEY, ?ATTR_UPPER_KEY], OwnerAttr = kz_json:get_integer_value(FullKey, Owner, 5), @@ -375,7 +375,7 @@ merge_attribute(Key, Account, Endpoint, Owner) -> ), kz_json:set_value(Key, Merged, Endpoint). --spec merge_attribute_caller_id(api_object(), api_object(), api_object(), api_object()) -> api_object(). +-spec merge_attribute_caller_id(kz_term:api_object(), kz_term:api_object(), kz_term:api_object(), kz_term:api_object()) -> kz_term:api_object(). merge_attribute_caller_id(AccountJObj, AccountJAttr, UserJAttr, EndpointJAttr) -> Merging = case kz_json:is_true(<<"prefer_device_caller_id">>, AccountJObj, 'false') of @@ -395,21 +395,21 @@ merge_call_recording(JObj) -> F2 = fun(K, V, Acc) -> merge_call_recording(K, V, Acc, AnyNets) end, kz_json:foldl(F2, JObj1, JObj1). --spec merge_call_recording(ne_binary(), kz_json:object(), kz_json:object()) -> kz_json:object(). +-spec merge_call_recording(kz_term:ne_binary(), kz_json:object(), kz_json:object()) -> kz_json:object(). merge_call_recording(K, JObj, ToMerge) -> case kz_json:get_json_value(K, JObj) of 'undefined' -> kz_json:set_value(K, ToMerge, JObj); V -> kz_json:set_value(K, kz_json:merge(ToMerge, V), JObj) end. --spec merge_call_recording(ne_binary(), kz_json:object(), kz_json:object(), ne_binaries()) -> kz_json:object(). +-spec merge_call_recording(kz_term:ne_binary(), kz_json:object(), kz_json:object(), kz_term:ne_binaries()) -> kz_json:object(). merge_call_recording(K, JObj, Acc, List) -> Any = kz_json:get_json_value(<<"any">>, JObj, kz_json:from_list([{<<"enabled">>, false}])), Fun = fun(K1, V1) -> merge_call_recording(K1, V1, Any) end, kz_json:set_value(K, lists:foldl(Fun, kz_json:delete_key(<<"any">>, JObj), List), Acc). --spec get_account_record_call_properties(api_object()) -> kz_json:object(). +-spec get_account_record_call_properties(kz_term:api_object()) -> kz_json:object(). get_account_record_call_properties(JObj) -> kz_json:foldl(fun(K, V, Acc) -> kz_json:set_value(K, merge_call_recording(V), Acc) @@ -428,7 +428,7 @@ get_endpoint_record_call_properties(JObj) -> kz_json:from_list([{<<"endpoint">>, merge_call_recording(RecordCall)}]) end. --spec get_endpoint_record_call_properties(api_object(), kz_json:object()) -> api_object(). +-spec get_endpoint_record_call_properties(kz_term:api_object(), kz_json:object()) -> kz_term:api_object(). get_endpoint_record_call_properties('undefined', JObj) -> Legacy = get_record_call_properties(JObj), case kz_json:is_true(<<"record_call">>, Legacy) of @@ -463,7 +463,7 @@ get_record_call_properties(JObj) -> end end. --spec merge_value(ne_binary(), api_object(), kz_json:object(), api_object()) -> +-spec merge_value(kz_term:ne_binary(), kz_term:api_object(), kz_json:object(), kz_term:api_object()) -> kz_json:object(). merge_value(Key, Account, Endpoint, Owner) -> case kz_json:find(Key, [Owner, Endpoint, Account], 'undefined') of @@ -486,7 +486,7 @@ caller_id_owner_attr(Owner) -> _Else -> OwnerAttr end. --spec merge_call_restrictions(ne_binaries(), kz_json:object(), kz_json:object(), kz_json:object()) -> +-spec merge_call_restrictions(kz_term:ne_binaries(), kz_json:object(), kz_json:object(), kz_json:object()) -> kz_json:object(). merge_call_restrictions([], _, Endpoint, _) -> Endpoint; merge_call_restrictions([Classifier|Classifiers], Account, Endpoint, Owner) -> @@ -511,7 +511,7 @@ merge_call_restrictions([Classifier|Classifiers], Account, Endpoint, Owner) -> merge_call_restrictions(Classifiers, Account, Endpoint, Owner) end. --spec get_user(ne_binary(), api_binary() | kz_json:object()) -> kz_json:object(). +-spec get_user(kz_term:ne_binary(), kz_term:api_binary() | kz_json:object()) -> kz_json:object(). get_user(_AccountDb, 'undefined') -> kz_json:new(); get_user(AccountDb, OwnerId) when is_binary(OwnerId) -> case kzd_user:fetch(AccountDb, OwnerId) of @@ -531,7 +531,7 @@ get_user(AccountDb, Endpoint) -> fix_user_restrictions(UserJObj) end. --spec get_users(ne_binary(), ne_binaries()) -> kzd_user:docs(). +-spec get_users(kz_term:ne_binary(), kz_term:ne_binaries()) -> kzd_user:docs(). get_users(AccountDb, OwnerIds) -> %% Bulk fetch to fill the cache _ = kz_datamgr:open_cache_docs(AccountDb, OwnerIds), @@ -592,11 +592,11 @@ singlfy_user_restrictions(UserJObjs, AccJObj) -> ,kz_json:get_keys(knm_converters:available_classifiers()) ). --spec do_all_restrict(ne_binary(), kzd_user:doc()) -> boolean(). +-spec do_all_restrict(kz_term:ne_binary(), kzd_user:doc()) -> boolean(). do_all_restrict(Classifier, UserJObj) -> <<"deny">> =:= kzd_user:classifier_restriction(UserJObj, Classifier). --spec create_endpoint_name(api_binary(), api_binary(), api_binary(), api_binary()) -> api_binary(). +-spec create_endpoint_name(kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary(), kz_term:api_binary()) -> kz_term:api_binary(). create_endpoint_name('undefined', 'undefined', 'undefined', Account) -> Account; create_endpoint_name('undefined', 'undefined', Endpoint, _) -> Endpoint; create_endpoint_name(First, 'undefined', _, _) -> First; @@ -609,8 +609,8 @@ create_endpoint_name(First, Last, _, _) -> <>. %% Flush the callflow cache %% @end %%-------------------------------------------------------------------- --spec flush_account(ne_binary()) -> 'ok'. --spec flush(ne_binary(), ne_binary()) -> 'ok'. +-spec flush_account(kz_term:ne_binary()) -> 'ok'. +-spec flush(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. flush_account(AccountDb) -> ToRemove = kz_cache:filter_local(?CACHE_NAME, fun({?MODULE, Db, _Id}, _Value) -> @@ -655,10 +655,10 @@ flush(Db, Id) -> | 'invalid_endpoint_id' | 'not_found' | 'owner_called_self' | 'do_not_disturb' | 'no_resource_type'. --spec build(api_ne_binary() | kz_json:object(), kapps_call:call()) -> +-spec build(kz_term:api_ne_binary() | kz_json:object(), kapps_call:call()) -> {'ok', kz_json:objects()} | {'error', build_errors()}. --spec build(api_ne_binary() | kz_json:object(), api_object(), kapps_call:call()) -> +-spec build(kz_term:api_ne_binary() | kz_json:object(), kz_term:api_object(), kapps_call:call()) -> {'ok', kz_json:objects()} | {'error', build_errors()}. @@ -726,7 +726,7 @@ should_create_endpoint_fold(_Routine, Error) -> Error. -spec maybe_missing_resource_type(kz_json:object(), kz_json:object(), kapps_call:call()) -> 'ok' | {'error', 'no_resource_type'}. --spec maybe_missing_resource_type(api_binary()) -> +-spec maybe_missing_resource_type(kz_term:api_binary()) -> 'ok' | {'error', 'no_resource_type'}. maybe_missing_resource_type(_Endpoint, _Properties, Call) -> @@ -744,7 +744,7 @@ maybe_missing_resource_type(_) -> 'ok'. maybe_owner_called_self(Endpoint, Properties, Call) -> maybe_owner_called_self(Endpoint, Properties, kapps_call:resource_type(Call), Call). --spec maybe_owner_called_self(kz_json:object(), kz_json:object(), api_binary(), kapps_call:call()) -> +-spec maybe_owner_called_self(kz_json:object(), kz_json:object(), kz_term:api_binary(), kapps_call:call()) -> 'ok' | {'error', 'owner_called_self'}. maybe_owner_called_self(Endpoint, Properties, <<"audio">>, Call) -> @@ -784,7 +784,7 @@ maybe_owner_called_self(Endpoint, Properties, <<"sms">>, Call) -> maybe_endpoint_called_self(Endpoint, Properties, Call) -> maybe_endpoint_called_self(Endpoint, Properties, kapps_call:resource_type(Call), Call). --spec maybe_endpoint_called_self(kz_json:object(), kz_json:object(), api_binary(), kapps_call:call()) -> +-spec maybe_endpoint_called_self(kz_json:object(), kz_json:object(), kz_term:api_binary(), kapps_call:call()) -> 'ok' | {'error', 'endpoint_called_self'}. maybe_endpoint_called_self(Endpoint, Properties, <<"audio">>, Call) -> @@ -877,7 +877,7 @@ create_endpoints(Endpoint, Properties, Call) -> end. -spec maybe_start_metaflows(kapps_call:call(), kz_json:objects()) -> 'ok'. --spec maybe_start_metaflows(kapps_call:call(), kz_json:objects(), api_binary()) -> 'ok'. +-spec maybe_start_metaflows(kapps_call:call(), kz_json:objects(), kz_term:api_binary()) -> 'ok'. maybe_start_metaflows(Call, Endpoints) -> maybe_start_metaflows(Call, Endpoints, kapps_call:call_id_direct(Call)). @@ -972,8 +972,8 @@ is_call_forward_enabled(Endpoint, Properties) -> orelse (not lists:member(Source, ?NON_DIRECT_MODULES)) ). --spec maybe_create_endpoint(ne_binary(), kz_json:object(), kz_json:object(), kapps_call:call()) -> - kz_json:object() | {'error', ne_binary()}. +-spec maybe_create_endpoint(kz_term:ne_binary(), kz_json:object(), kz_json:object(), kapps_call:call()) -> + kz_json:object() | {'error', kz_term:ne_binary()}. maybe_create_endpoint(<<"sip">>, Endpoint, Properties, Call) -> lager:info("building a SIP endpoint"), create_sip_endpoint(Endpoint, Properties, Call); @@ -988,7 +988,7 @@ maybe_create_endpoint(UnknownType, _, _, _) -> -spec maybe_create_mobile_endpoint(kz_json:object(), kz_json:object(), kapps_call:call()) -> kz_json:object() | - {'error', ne_binary()}. + {'error', kz_term:ne_binary()}. maybe_create_mobile_endpoint(Endpoint, Properties, Call) -> case kapps_config:get_is_true(?MOBILE_CONFIG_CAT, <<"create_sip_endpoint">>, 'false') of 'true' -> @@ -998,7 +998,7 @@ maybe_create_mobile_endpoint(Endpoint, Properties, Call) -> create_mobile_endpoint(Endpoint, Properties, Call) end. --spec get_endpoint_type(kz_json:object()) -> ne_binary(). +-spec get_endpoint_type(kz_json:object()) -> kz_term:ne_binary(). get_endpoint_type(Endpoint) -> Type = kz_json:get_first_defined([<<"endpoint_type">> ,<<"device_type">> @@ -1010,7 +1010,7 @@ get_endpoint_type(Endpoint) -> Else -> Else end. --spec convert_endpoint_type(ne_binary()) -> api_binary(). +-spec convert_endpoint_type(kz_term:ne_binary()) -> kz_term:api_binary(). convert_endpoint_type(<<"sip_", _/binary>>) -> <<"sip">>; convert_endpoint_type(<<"smartphone">>) -> <<"sip">>; convert_endpoint_type(<<"softphone">>) -> <<"sip">>; @@ -1021,7 +1021,7 @@ convert_endpoint_type(<<"skype">>) -> <<"skype">>; convert_endpoint_type(<<"mobile">>) -> <<"mobile">>; convert_endpoint_type(_Else) -> 'undefined'. --spec maybe_guess_endpoint_type(kz_json:object()) -> ne_binary(). +-spec maybe_guess_endpoint_type(kz_json:object()) -> kz_term:ne_binary(). maybe_guess_endpoint_type(Endpoint) -> case kapps_config:get_is_true(?CONFIG_CAT, <<"restrict_to_known_types">>, 'false') of 'false' -> guess_endpoint_type(Endpoint); @@ -1030,7 +1030,7 @@ maybe_guess_endpoint_type(Endpoint) -> <<"unknown">> end. --spec guess_endpoint_type(kz_json:object()) -> ne_binary(). +-spec guess_endpoint_type(kz_json:object()) -> kz_term:ne_binary(). guess_endpoint_type(Endpoint) -> guess_endpoint_type(Endpoint ,[<<"mobile">> @@ -1039,7 +1039,7 @@ guess_endpoint_type(Endpoint) -> ] ). --spec guess_endpoint_type(kz_json:object(), ne_binaries()) -> ne_binary(). +-spec guess_endpoint_type(kz_json:object(), kz_term:ne_binaries()) -> kz_term:ne_binary(). guess_endpoint_type(Endpoint, [Type|Types]) -> case kz_json:get_ne_value(Type, Endpoint) of 'undefined' -> guess_endpoint_type(Endpoint, Types); @@ -1059,10 +1059,10 @@ guess_endpoint_type(Endpoint, []) -> %% device) and the properties of this endpoint in the callflow. %% @end %%-------------------------------------------------------------------- --record(clid, {caller_number :: api_binary() - ,caller_name :: api_binary() - ,callee_name :: api_binary() - ,callee_number :: api_binary() +-record(clid, {caller_number :: kz_term:api_binary() + ,caller_name :: kz_term:api_binary() + ,callee_name :: kz_term:api_binary() + ,callee_number :: kz_term:api_binary() }). -type clid() :: #clid{}. @@ -1155,7 +1155,7 @@ create_sip_endpoint(Endpoint, Properties, #clid{}=Clid, Call) -> ])), maybe_format_endpoint(SIPEndpoint, kz_term:is_empty(kz_json:get_json_value(<<"formatters">>, Endpoint))). --spec maybe_get_t38(kz_json:object(), kapps_call:call()) -> kz_proplist(). +-spec maybe_get_t38(kz_json:object(), kapps_call:call()) -> kz_term:proplist(). maybe_get_t38(Endpoint, Call) -> Opt = case ?MODULE:get(Call) of @@ -1171,7 +1171,7 @@ maybe_get_t38(Endpoint, Call) -> ) end. --spec maybe_build_failover(kz_json:object(), clid(), kapps_call:call()) -> api_object(). +-spec maybe_build_failover(kz_json:object(), clid(), kapps_call:call()) -> kz_term:api_object(). maybe_build_failover(Endpoint, Clid, Call) -> CallForward = kz_json:get_value(<<"call_forward">>, Endpoint), Number = kz_json:get_value(<<"number">>, CallForward), @@ -1182,7 +1182,7 @@ maybe_build_failover(Endpoint, Clid, Call) -> 'true' -> create_call_fwd_endpoint(Endpoint, kz_json:new(), Call) end. --spec maybe_build_push_failover(kz_json:object(), clid(), kapps_call:call()) -> api_object(). +-spec maybe_build_push_failover(kz_json:object(), clid(), kapps_call:call()) -> kz_term:api_object(). maybe_build_push_failover(Endpoint, Clid, Call) -> PushJObj = push_properties(Endpoint), case kz_json:is_empty(PushJObj) of @@ -1190,7 +1190,7 @@ maybe_build_push_failover(Endpoint, Clid, Call) -> 'false' -> build_push_failover(Endpoint, Clid, PushJObj, Call) end. --spec build_push_failover(kz_json:object(), clid(), kz_json:object(), kapps_call:call()) -> api_object(). +-spec build_push_failover(kz_json:object(), clid(), kz_json:object(), kapps_call:call()) -> kz_term:api_object(). build_push_failover(Endpoint, Clid, PushJObj, Call) -> lager:debug("building push failover"), SIPJObj = kz_json:get_value(<<"sip">>, Endpoint), @@ -1250,7 +1250,7 @@ push_headers(PushJObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_sip_transport(kz_json:object()) -> api_binary(). +-spec get_sip_transport(kz_json:object()) -> kz_term:api_binary(). get_sip_transport(SIPJObj) -> case validate_sip_transport(kz_json:get_value(<<"transport">>, SIPJObj)) of 'undefined' -> @@ -1258,7 +1258,7 @@ get_sip_transport(SIPJObj) -> Transport -> Transport end. --spec validate_sip_transport(any()) -> api_binary(). +-spec validate_sip_transport(any()) -> kz_term:api_binary(). validate_sip_transport(<<"tcp">>) -> <<"tcp">>; validate_sip_transport(<<"udp">>) -> <<"udp">>; validate_sip_transport(<<"tls">>) -> <<"tls">>; @@ -1270,7 +1270,7 @@ validate_sip_transport(_) -> 'undefined'. %% @doc %% @end %%-------------------------------------------------------------------- --spec get_custom_sip_interface(kz_json:object()) -> api_ne_binary(). +-spec get_custom_sip_interface(kz_json:object()) -> kz_term:api_ne_binary(). get_custom_sip_interface(JObj) -> case kz_json:get_value(<<"custom_sip_interface">>, JObj) of 'undefined' -> @@ -1352,7 +1352,7 @@ create_call_fwd_endpoint(Endpoint, Properties, Call) -> %%-------------------------------------------------------------------- -spec create_mobile_endpoint(kz_json:object(), kz_json:object(), kapps_call:call()) -> kz_json:object() | - {'error', ne_binary()}. + {'error', kz_term:ne_binary()}. create_mobile_endpoint(Endpoint, Properties, Call) -> case kapps_call:resource_type(Call) of ?RESOURCE_TYPE_SMS -> create_mobile_sms_endpoint(Endpoint, Properties, Call); @@ -1361,7 +1361,7 @@ create_mobile_endpoint(Endpoint, Properties, Call) -> -spec create_mobile_audio_endpoint(kz_json:object(), kz_json:object(), kapps_call:call()) -> kz_json:object() | - {'error', ne_binary()}. + {'error', kz_term:ne_binary()}. create_mobile_audio_endpoint(Endpoint, Properties, Call) -> case maybe_build_mobile_route(Endpoint) of {'error', _R}=Error -> @@ -1387,7 +1387,7 @@ create_mobile_audio_endpoint(Endpoint, Properties, Call) -> end. -spec maybe_build_mobile_route(kz_json:object()) -> - ne_binary() | + kz_term:ne_binary() | {'error', 'mdn_missing'}. maybe_build_mobile_route(Endpoint) -> case kz_json:get_ne_value([<<"mobile">>, <<"mdn">>], Endpoint) of @@ -1397,8 +1397,8 @@ maybe_build_mobile_route(Endpoint) -> MDN -> build_mobile_route(MDN) end. --spec build_mobile_route(ne_binary()) -> - ne_binary() | +-spec build_mobile_route(kz_term:ne_binary()) -> + kz_term:ne_binary() | {'error', 'invalid_mdn'}. build_mobile_route(MDN) -> Regex = kapps_config:get_binary(?MOBILE_CONFIG_CAT, <<"formatter">>, ?DEFAULT_MOBILE_FORMATER), @@ -1418,7 +1418,7 @@ build_mobile_route(MDN) -> maybe_add_mobile_path(Route) end. --spec maybe_add_mobile_path(ne_binary()) -> ne_binary(). +-spec maybe_add_mobile_path(kz_term:ne_binary()) -> kz_term:ne_binary(). maybe_add_mobile_path(Route) -> Path = kapps_config:get_binary(?MOBILE_CONFIG_CAT, <<"path">>, ?DEFAULT_MOBILE_PATH), case kz_term:is_empty(Path) of @@ -1451,7 +1451,7 @@ generate_sip_headers(Endpoint, Acc, Call) -> ], lists:foldr(fun(F, JObj) -> F(JObj) end, Acc, HeaderFuns). --spec maybe_add_diversion(kz_json:object(), kz_json:object(), api_binary(), kapps_call:call()) -> kz_json:object(). +-spec maybe_add_diversion(kz_json:object(), kz_json:object(), kz_term:api_binary(), kapps_call:call()) -> kz_json:object(). maybe_add_diversion(JObj, Endpoint, _Inception, Call) -> ShouldAddDiversion = kapps_call:authorizing_id(Call) =:= 'undefined' andalso kz_json:is_true([<<"call_forward">>, <<"keep_caller_id">>], Endpoint, 'false') @@ -1493,11 +1493,11 @@ maybe_add_alert_info(JObj, Endpoint, Call) -> Ringtone -> set_alert_info(Ringtone, JObj) end. --spec set_alert_info(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec set_alert_info(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). set_alert_info(Info, JObj) -> kz_json:set_value(<<"Alert-Info">>, Info, JObj). --spec maybe_add_alert_info_from_endpoint(kz_json:object(), kz_json:object(), api_binary()) -> kz_json:object(). +-spec maybe_add_alert_info_from_endpoint(kz_json:object(), kz_json:object(), kz_term:api_binary()) -> kz_json:object(). maybe_add_alert_info_from_endpoint(JObj, Endpoint, 'undefined') -> case kz_json:get_value([<<"ringtones">>, <<"internal">>], Endpoint) of 'undefined' -> JObj; @@ -1521,7 +1521,7 @@ maybe_add_invite_format(JObj, _Endpoint, _Call, Format) -> kz_json:set_value(<<"X-KAZOO-INVITE-FORMAT">>, Format, JObj). -spec maybe_add_aor(kz_json:object(), kz_json:object(), kapps_call:call()) -> kz_json:object(). --spec maybe_add_aor(kz_json:object(), kz_json:object(), api_binary(), ne_binary()) -> kz_json:object(). +-spec maybe_add_aor(kz_json:object(), kz_json:object(), kz_term:api_binary(), kz_term:ne_binary()) -> kz_json:object(). maybe_add_aor(JObj, Endpoint, Call) -> Realm = kz_device:sip_realm(Endpoint, kapps_call:account_realm(Call)), Username = kz_device:sip_username(Endpoint), @@ -1540,7 +1540,7 @@ maybe_add_aor(JObj, _, Username, Realm) -> %% @end %%-------------------------------------------------------------------- -spec generate_ccvs(kz_json:object(), kapps_call:call()) -> kz_json:object(). --spec generate_ccvs(kz_json:object(), kapps_call:call(), api_object()) -> kz_json:object(). +-spec generate_ccvs(kz_json:object(), kapps_call:call(), kz_term:api_object()) -> kz_json:object(). generate_ccvs(Endpoint, Call) -> generate_ccvs(Endpoint, Call, 'undefined'). @@ -1565,7 +1565,7 @@ generate_ccvs(Endpoint, Call, CallFwd) -> {_Endpoint, _Call, _CallFwd, CCVs} = lists:foldr(fun(F, Acc) -> F(Acc) end, Acc0, CCVFuns), CCVs. --type ccv_acc() :: {kz_json:object(), kapps_call:call(), api_object(), kz_json:object()}. +-type ccv_acc() :: {kz_json:object(), kapps_call:call(), kz_term:api_object(), kz_json:object()}. -spec maybe_set_webrtc(ccv_acc()) -> ccv_acc(). maybe_set_webrtc({Endpoint, Call, CallFwd, CCVs} = Acc) -> @@ -1643,7 +1643,7 @@ maybe_rtcp_mux({Endpoint, Call, CallFwd, CCVs} = Acc) -> RTCP_MUX -> {Endpoint, Call, CallFwd, kz_json:set_value(<<"RTCP-MUX">>, RTCP_MUX, CCVs)} end. --spec bowout_settings(boolean()) -> kz_proplist(). +-spec bowout_settings(boolean()) -> kz_term:proplist(). bowout_settings('true') -> [{<<"Simplify-Loopback">>, <<"true">>} ,{<<"Loopback-Bowout">>, <<"true">>} @@ -1701,7 +1701,7 @@ maybe_set_encryption_flags({Endpoint, Call, CallFwd, CCVs}) -> ,encryption_method_map(CCVs, Endpoint) }. --spec encryption_method_map(api_object(), api_binaries() | kz_json:object()) -> api_object(). +-spec encryption_method_map(kz_term:api_object(), kz_term:api_binaries() | kz_json:object()) -> kz_term:api_object(). encryption_method_map(CCVs, []) -> CCVs; encryption_method_map(CCVs, [Method|Methods]) -> case props:get_value(Method, ?ENCRYPTION_MAP, []) of @@ -1736,18 +1736,18 @@ maybe_set_call_waiting({Endpoint, Call, CallFwd, CCVs}) -> end }. --spec get_invite_format(kz_json:object()) -> ne_binary(). +-spec get_invite_format(kz_json:object()) -> kz_term:ne_binary(). get_invite_format(SIPJObj) -> kz_json:get_ne_binary_value(<<"invite_format">>, SIPJObj, <<"username">>). --spec get_to_did(kz_json:object(), kapps_call:call()) -> api_binary(). +-spec get_to_did(kz_json:object(), kapps_call:call()) -> kz_term:api_binary(). get_to_did(Endpoint, Call) -> kz_json:get_value([<<"sip">>, <<"number">>] ,Endpoint ,kapps_call:request_user(Call) ). --spec get_to_user(kz_json:object(), kz_json:object()) -> api_binary(). +-spec get_to_user(kz_json:object(), kz_json:object()) -> kz_term:api_binary(). get_to_user(SIPJObj, Properties) -> case kz_json:get_ne_binary_value(<<"static_invite">>, Properties) of 'undefined' -> @@ -1758,50 +1758,50 @@ get_to_user(SIPJObj, Properties) -> To -> To end. --spec get_to_username(kz_json:object()) -> api_binary(). +-spec get_to_username(kz_json:object()) -> kz_term:api_binary(). get_to_username(SIPJObj) -> kz_json:get_ne_binary_value(<<"username">>, SIPJObj). --spec get_timeout(kz_json:object()) -> api_binary(). +-spec get_timeout(kz_json:object()) -> kz_term:api_binary(). get_timeout(JObj) -> case kz_json:get_integer_value(<<"timeout">>, JObj, 0) of Timeout when Timeout > 0 -> kz_term:to_binary(Timeout); _Else -> 'undefined' end. --spec get_delay(kz_json:object()) -> api_binary(). +-spec get_delay(kz_json:object()) -> kz_term:api_binary(). get_delay(JObj) -> case kz_json:get_integer_value(<<"delay">>, JObj, 0) of Delay when Delay > 0 -> kz_term:to_binary(Delay); _Else -> 'undefined' end. --spec get_outbound_flags(kz_json:object()) -> api_binary(). +-spec get_outbound_flags(kz_json:object()) -> kz_term:api_binary(). get_outbound_flags(JObj) -> kz_json:get_ne_value(<<"outbound_flags">>, JObj). --spec get_progress_timeout(kz_json:object()) -> api_binary(). +-spec get_progress_timeout(kz_json:object()) -> kz_term:api_binary(). get_progress_timeout(JObj) -> case kz_json:get_integer_value([<<"media">>, <<"progress_timeout">>], JObj, 0) of Timeout when Timeout > 0 -> kz_term:to_binary(Timeout); _Else -> 'undefined' end. --spec get_ignore_early_media(kz_json:object()) -> api_binary(). +-spec get_ignore_early_media(kz_json:object()) -> kz_term:api_binary(). get_ignore_early_media(JObj) -> case kz_json:is_true([<<"media">>, <<"ignore_early_media">>], JObj) of 'true' -> <<"true">>; 'false' -> 'undefined' end. --spec get_bypass_media(kz_json:object()) -> api_binary(). +-spec get_bypass_media(kz_json:object()) -> kz_term:api_binary(). get_bypass_media(JObj) -> case kz_json:is_true([<<"media">>, <<"bypass_media">>], JObj) of 'true' -> <<"true">>; 'false' -> 'undefined' end. --spec get_codecs(kz_json:object()) -> 'undefined' | ne_binaries(). +-spec get_codecs(kz_json:object()) -> 'undefined' | kz_term:ne_binaries(). get_codecs(JObj) -> case kz_json:get_value([<<"media">>, <<"audio">>, <<"codecs">>], JObj, []) ++ kz_json:get_value([<<"media">>, <<"video">>, <<"codecs">>], JObj, []) @@ -1827,7 +1827,7 @@ is_sms(Call) -> -spec create_mobile_sms_endpoint(kz_json:object(), kz_json:object(), kapps_call:call()) -> kz_json:object() | - {'error', ne_binary()}. + {'error', kz_term:ne_binary()}. create_mobile_sms_endpoint(Endpoint, Properties, Call) -> case maybe_build_mobile_sms_route(Endpoint) of {'error', _R}=Error -> @@ -1851,7 +1851,7 @@ create_mobile_sms_endpoint(Endpoint, Properties, Call) -> kz_json:from_list(EP) end. --spec create_mobile_sms_endpoint_failover(kz_proplist(), sms_routes()) -> kz_proplist(). +-spec create_mobile_sms_endpoint_failover(kz_term:proplist(), sms_routes()) -> kz_term:proplist(). create_mobile_sms_endpoint_failover(Endpoint, []) -> Endpoint; create_mobile_sms_endpoint_failover(Endpoint, [{Route, Options} | Failover]) -> EP = props:set_values([{<<"Route">>, Route} @@ -1865,7 +1865,7 @@ create_mobile_sms_endpoint_failover(Endpoint, [{Route, Options} | Failover]) -> ). -spec maybe_build_mobile_sms_route(kz_json:object()) -> - ne_binary() | + kz_term:ne_binary() | {'error', 'mdn_missing'}. maybe_build_mobile_sms_route(Endpoint) -> case kz_json:get_ne_value([<<"mobile">>, <<"mdn">>], Endpoint) of @@ -1875,15 +1875,15 @@ maybe_build_mobile_sms_route(Endpoint) -> MDN -> build_mobile_sms_route(MDN) end. --spec build_mobile_sms_route(ne_binary()) -> - {ne_binary(), sms_routes()} | +-spec build_mobile_sms_route(kz_term:ne_binary()) -> + {kz_term:ne_binary(), sms_routes()} | {'error', 'invalid_mdn'}. build_mobile_sms_route(MDN) -> Type = kapps_config:get_ne_binary(?MOBILE_CONFIG_CAT, <<"sms_interface">>, ?DEFAULT_MOBILE_SMS_INTERFACE), build_mobile_sms_route(Type, MDN). --spec build_mobile_sms_route(ne_binary(), ne_binary()) -> - {ne_binary(), sms_routes()} | +-spec build_mobile_sms_route(kz_term:ne_binary(), kz_term:ne_binary()) -> + {kz_term:ne_binary(), sms_routes()} | {'error', 'invalid_mdn'}. build_mobile_sms_route(<<"sip">>, MDN) -> {<<"sip">>, [{build_mobile_route(MDN), 'undefined'}]}; @@ -1891,12 +1891,12 @@ build_mobile_sms_route(<<"amqp">>, _MDN) -> Connections = kapps_config:get_json(?MOBILE_CONFIG_CAT, [<<"sms">>, <<"connections">>], ?DEFAULT_MOBILE_AMQP_CONNECTIONS), {<<"amqp">>, kz_json:foldl(fun build_mobile_sms_amqp_route/3 , [], Connections)}. --spec build_mobile_sms_amqp_route(kz_json:path(), kz_json:json_term(), kz_proplist()) -> sms_routes(). +-spec build_mobile_sms_amqp_route(kz_json:path(), kz_json:json_term(), kz_term:proplist()) -> sms_routes(). build_mobile_sms_amqp_route(K, JObj, Acc) -> Broker = kz_json:get_value(<<"broker">>, JObj), Acc ++ [{Broker, [{<<"Broker-Name">>, K} | build_mobile_sms_amqp_route_options(JObj)]}]. --spec build_mobile_sms_amqp_route_options(kz_json:object()) -> kz_proplist(). +-spec build_mobile_sms_amqp_route_options(kz_json:object()) -> kz_term:proplist(). build_mobile_sms_amqp_route_options(JObj) -> [{<<"Route-ID">>, kz_json:get_ne_binary_value(<<"route">>, JObj, ?DEFAULT_MOBILE_SMS_ROUTE)} ,{<<"Exchange-ID">>, kz_json:get_ne_binary_value(<<"exchange">>, JObj, ?DEFAULT_MOBILE_SMS_EXCHANGE)} @@ -1910,11 +1910,11 @@ build_mobile_sms_amqp_route_options(JObj) -> %% Get the sip realm %% @end %%-------------------------------------------------------------------- --spec get_sip_realm(kz_json:object(), ne_binary()) -> api_binary(). +-spec get_sip_realm(kz_json:object(), kz_term:ne_binary()) -> kz_term:api_binary(). get_sip_realm(SIPJObj, AccountId) -> get_sip_realm(SIPJObj, AccountId, 'undefined'). --spec get_sip_realm(kz_json:object(), ne_binary(), Default) -> Default | ne_binary(). +-spec get_sip_realm(kz_json:object(), kz_term:ne_binary(), Default) -> Default | kz_term:ne_binary(). get_sip_realm(SIPJObj, AccountId, Default) -> case kz_device:sip_realm(SIPJObj) of 'undefined' -> @@ -1934,7 +1934,7 @@ get_sip_realm(SIPJObj, AccountId, Default) -> %% @end %%-------------------------------------------------------------------- -spec endpoint_actions(kz_json:object(), kapps_call:call()) -> kz_json:object(). --spec endpoint_actions(kz_json:object(), kapps_call:call(), api_object()) -> kz_json:object(). +-spec endpoint_actions(kz_json:object(), kapps_call:call(), kz_term:api_object()) -> kz_json:object(). endpoint_actions(Endpoint, Call) -> endpoint_actions(Endpoint, Call, 'undefined'). @@ -1946,7 +1946,7 @@ endpoint_actions(Endpoint, Call, CallFwd) -> {_Endpoint, _Call, _CallFwd, Actions} = lists:foldr(fun(F, Acc) -> F(Acc) end, Acc0, Funs), Actions. --type actions_acc() :: {kz_json:object(), kapps_call:call(), api_object(), kz_json:object()}. +-type actions_acc() :: {kz_json:object(), kapps_call:call(), kz_term:api_object(), kz_json:object()}. -spec maybe_record_endpoint(actions_acc()) -> actions_acc(). maybe_record_endpoint({Endpoint, Call, CallFwd, Actions} = Acc) -> @@ -1971,11 +1971,11 @@ maybe_record_endpoint({Endpoint, Call, CallFwd, Actions} = Acc) -> -type mwi_update_return() :: 'missing_account_db' | 'missing_owner_id'. --spec unsolicited_owner_mwi_update(api_binary(), api_binary()) -> +-spec unsolicited_owner_mwi_update(kz_term:api_binary(), kz_term:api_binary()) -> 'ok' | {'error', mwi_update_return()} | kz_datamgr:data_error(). --spec unsolicited_owner_mwi_update(ne_binary(), ne_binary(), boolean()) -> +-spec unsolicited_owner_mwi_update(kz_term:ne_binary(), kz_term:ne_binary(), boolean()) -> 'ok' | {'error', mwi_update_return()} | kz_datamgr:data_error(). @@ -2005,7 +2005,7 @@ unsolicited_owner_mwi_update(AccountDb, OwnerId, 'true') -> E end. --spec maybe_send_mwi_update(kz_json:object(), ne_binary(), integer(), integer()) -> 'ok'. +-spec maybe_send_mwi_update(kz_json:object(), kz_term:ne_binary(), integer(), integer()) -> 'ok'. maybe_send_mwi_update(JObj, AccountId, New, Saved) -> J = kz_json:get_value(<<"doc">>, JObj), Username = kz_device:sip_username(J), @@ -2021,9 +2021,9 @@ maybe_send_mwi_update(JObj, AccountId, New, Saved) -> 'false' -> 'ok' end. --spec unsolicited_endpoint_mwi_update(api_binary(), api_binary()) -> +-spec unsolicited_endpoint_mwi_update(kz_term:api_binary(), kz_term:api_binary()) -> 'ok' | {'error', any()}. --spec unsolicited_endpoint_mwi_update(ne_binary(), ne_binary(), boolean()) -> +-spec unsolicited_endpoint_mwi_update(kz_term:ne_binary(), kz_term:ne_binary(), boolean()) -> 'ok' | {'error', any()}. unsolicited_endpoint_mwi_update('undefined', _) -> @@ -2043,9 +2043,9 @@ unsolicited_endpoint_mwi_update(AccountDb, EndpointId, 'true') -> {'ok', JObj} -> maybe_send_endpoint_mwi_update(AccountDb, JObj) end. --spec maybe_send_endpoint_mwi_update(ne_binary(), kz_json:object()) -> +-spec maybe_send_endpoint_mwi_update(kz_term:ne_binary(), kz_json:object()) -> 'ok' | {'error', 'not_appropriate'}. --spec maybe_send_endpoint_mwi_update(ne_binary(), kz_json:object(), boolean()) -> +-spec maybe_send_endpoint_mwi_update(kz_term:ne_binary(), kz_json:object(), boolean()) -> 'ok' | {'error', 'not_appropriate'}. maybe_send_endpoint_mwi_update(AccountDb, JObj) -> @@ -2075,11 +2075,11 @@ maybe_send_endpoint_mwi_update(AccountDb, JObj, 'true') -> %% @end %%-------------------------------------------------------------------- -type vm_count() :: non_neg_integer(). --spec send_mwi_update(vm_count(), vm_count(), ne_binary(), ne_binary()) -> 'ok'. +-spec send_mwi_update(vm_count(), vm_count(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. send_mwi_update(New, Saved, Username, Realm) -> send_mwi_update(New, Saved, Username, Realm, kz_json:new()). --spec send_mwi_update(vm_count(), vm_count(), ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec send_mwi_update(vm_count(), vm_count(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. send_mwi_update(New, Saved, Username, Realm, JObj) -> Command = [{<<"To">>, <>} ,{<<"Messages-New">>, New} @@ -2091,12 +2091,12 @@ send_mwi_update(New, Saved, Username, Realm, JObj) -> kapps_util:amqp_pool_send(Command, fun kapi_presence:publish_unsolicited_mwi_update/1). --spec is_unsolicited_mwi_enabled(ne_binary()) -> boolean(). +-spec is_unsolicited_mwi_enabled(kz_term:ne_binary()) -> boolean(). is_unsolicited_mwi_enabled(AccountId) -> kapps_config:get_is_true(<<"callflow">>, ?MWI_SEND_UNSOLICITATED_UPDATES, 'true') andalso kz_term:is_true(kapps_account_config:get(AccountId, <<"callflow">>, ?MWI_SEND_UNSOLICITATED_UPDATES, 'true')). --spec vm_count_by_owner(ne_binary(), api_binary()) -> {non_neg_integer(), non_neg_integer()}. +-spec vm_count_by_owner(kz_term:ne_binary(), kz_term:api_binary()) -> {non_neg_integer(), non_neg_integer()}. vm_count_by_owner(_AccountDb, 'undefined') -> {0, 0}; vm_count_by_owner(<<_/binary>> = AccountDb, <<_/binary>> = OwnerId) -> kvm_messages:count_by_owner(AccountDb, OwnerId). @@ -2107,11 +2107,11 @@ vm_count_by_owner(<<_/binary>> = AccountDb, <<_/binary>> = OwnerId) -> %% %% @end %%-------------------------------------------------------------------- --spec get_endpoint_owner(kz_json:object()) -> api_ne_binary(). +-spec get_endpoint_owner(kz_json:object()) -> kz_term:api_ne_binary(). get_endpoint_owner(JObj) -> maybe_get_endpoint_hotdesk_owner(JObj). --spec maybe_get_endpoint_hotdesk_owner(kz_json:object()) -> api_ne_binary(). +-spec maybe_get_endpoint_hotdesk_owner(kz_json:object()) -> kz_term:api_ne_binary(). maybe_get_endpoint_hotdesk_owner(JObj) -> case kz_json:get_keys([<<"hotdesk">>, <<"users">>], JObj) of [] -> maybe_get_endpoint_assigned_owner(JObj); @@ -2119,6 +2119,6 @@ maybe_get_endpoint_hotdesk_owner(JObj) -> [_|_] -> 'undefined' end. --spec maybe_get_endpoint_assigned_owner(kz_json:object()) -> api_ne_binary(). +-spec maybe_get_endpoint_assigned_owner(kz_json:object()) -> kz_term:api_ne_binary(). maybe_get_endpoint_assigned_owner(JObj) -> kz_json:get_ne_binary_value(<<"owner_id">>, JObj). diff --git a/core/kazoo_endpoint/src/kz_endpoint_recording.erl b/core/kazoo_endpoint/src/kz_endpoint_recording.erl index ec9e47476f8..09d8a67ecda 100644 --- a/core/kazoo_endpoint/src/kz_endpoint_recording.erl +++ b/core/kazoo_endpoint/src/kz_endpoint_recording.erl @@ -36,7 +36,7 @@ -type store_url() :: 'false' | {'true', 'local'} | - {'true', 'other', ne_binary()}. + {'true', 'other', kz_term:ne_binary()}. -type state() :: map(). @@ -66,7 +66,7 @@ -define(CHECK_CHANNEL_STATUS_TIMEOUT, 5 * ?MILLISECONDS_IN_SECOND). -define(RECORDING_ID_KEY, <<"media_name">>). --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER ,[{'bindings', ?BINDINGS} @@ -83,7 +83,7 @@ get_response_media(JObj) -> Filename = kz_call_event:application_response(JObj), {filename:dirname(Filename), filename:basename(Filename)}. --spec handle_call_event(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_call_event(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_call_event(JObj, Props) -> kz_util:put_callid(JObj), Pid = props:get_value('server', Props), @@ -114,7 +114,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -128,7 +128,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). %% handle_cast({'record_start', JObj}, State) -> %% kz_util:put_callid(JObj), %% lager:debug("RECORD START : ~p", [JObj]), @@ -184,7 +184,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> lager:debug("unhandled message: ~p", [_Info]), {'noreply', State}. @@ -197,7 +197,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. @@ -232,7 +232,7 @@ code_change(_OldVsn, State, _Extra) -> %%% Internal functions %%%=================================================================== --spec get_timelimit(api_object() | integer()) -> pos_integer(). +-spec get_timelimit(kz_term:api_object() | integer()) -> pos_integer(). get_timelimit('undefined') -> kz_media_util:max_recording_time_limit(); get_timelimit(TL) when is_integer(TL) -> @@ -245,14 +245,14 @@ get_timelimit(TL) when is_integer(TL) -> get_timelimit(Data) -> get_timelimit(kz_json:get_integer_value(<<"time_limit">>, Data)). --spec get_format(api_ne_binary()) -> ne_binary(). +-spec get_format(kz_term:api_ne_binary()) -> kz_term:ne_binary(). get_format('undefined') -> kz_media_config:call_recording_extension(); get_format(<<"mp3">> = MP3) -> MP3; get_format(<<"mp4">> = MP4) -> MP4; get_format(<<"wav">> = WAV) -> WAV; get_format(_) -> get_format('undefined'). --spec store_recording_meta(map()) -> ne_binary() | {'error', any()}. +-spec store_recording_meta(map()) -> kz_term:ne_binary() | {'error', any()}. store_recording_meta(#{media := {_, MediaName} ,doc_db := Db ,doc_id := DocId @@ -306,7 +306,7 @@ store_recording_meta(#{media := {_, MediaName} {'error', _}= Err -> Err end. --spec maybe_store_recording_meta(map()) -> ne_binary() | {'error', any()}. +-spec maybe_store_recording_meta(map()) -> kz_term:ne_binary() | {'error', any()}. maybe_store_recording_meta(#{doc_db := Db ,doc_id := DocId }=State) -> @@ -315,14 +315,14 @@ maybe_store_recording_meta(#{doc_db := Db _ -> store_recording_meta(State) end. --spec get_media_name(ne_binary(), api_ne_binary()) -> ne_binary(). +-spec get_media_name(kz_term:ne_binary(), kz_term:api_ne_binary()) -> kz_term:ne_binary(). get_media_name(Name, Ext) -> case filename:extension(Name) of Ext -> Name; _ -> <> end. --spec store_url(map(), ne_binary()) -> ne_binary(). +-spec store_url(map(), kz_term:ne_binary()) -> kz_term:ne_binary(). store_url(#{doc_db := Db ,doc_id := MediaId ,media := {_,MediaName} @@ -348,12 +348,12 @@ store_url(#{doc_db := Db Options = [{'plan_override', Handler}], kz_media_url:store(Db, {<<"call_recording">>, MediaId}, MediaName, Options). --spec handler_fields(ne_binary(), state()) -> list(). +-spec handler_fields(kz_term:ne_binary(), state()) -> list(). handler_fields(Url, State) -> {Protocol, _, _, _, _} = kz_http_util:urlsplit(Url), handler_fields_for_protocol(Protocol, Url, State). --spec handler_fields_for_protocol(ne_binary(), ne_binary(), state()) -> list(). +-spec handler_fields_for_protocol(kz_term:ne_binary(), kz_term:ne_binary(), state()) -> list(). handler_fields_for_protocol(<<"ftp", _/binary>>, _Url, #{extension:=Ext}) -> [<<"call_recording_">> ,{field, <<"call_id">>} @@ -384,18 +384,18 @@ handler_fields_for_protocol(<<"http", _/binary>>, Url, #{account_id:=AccountId ,AccountId ]. --spec check_url(ne_binary()) -> {binary(), ne_binary()}. +-spec check_url(kz_term:ne_binary()) -> {binary(), kz_term:ne_binary()}. check_url(Url) -> case kz_http_util:urlsplit(Url) of {_, _, _, <<>>, _} -> {<<>>, <<"?">>}; {_, _, _, Params, _} -> {check_url_query(Params), <<"&">>} end. --spec check_url_query(ne_binary()) -> binary(). +-spec check_url_query(kz_term:ne_binary()) -> binary(). check_url_query(Query) -> check_url_param(lists:last(binary:split(Query, <<"&">>, [global]))). --spec check_url_param(ne_binary()) -> binary(). +-spec check_url_param(kz_term:ne_binary()) -> binary(). check_url_param(Param) -> case binary:split(Param, <<"=">>) of [_] -> <<"=">>; @@ -403,7 +403,7 @@ check_url_param(Param) -> _ -> <<"&recording=">> end. --spec handler_from_url(ne_binary()) -> 'kz_att_ftp' | 'kz_att_http' | 'undefined'. +-spec handler_from_url(kz_term:ne_binary()) -> 'kz_att_ftp' | 'kz_att_http' | 'undefined'. handler_from_url(Url) -> case kz_http_util:urlsplit(Url) of {<<"ftp">>, _, _, _, _} -> 'kz_att_ftp'; @@ -413,7 +413,7 @@ handler_from_url(Url) -> _ -> 'undefined' end. --spec should_store_recording(ne_binary(), api_binary()) -> store_url(). +-spec should_store_recording(kz_term:ne_binary(), kz_term:api_binary()) -> store_url(). should_store_recording(AccountId, Url) -> case kz_term:is_empty(Url) of 'true' -> maybe_storage_plan(AccountId); @@ -426,7 +426,7 @@ should_store_recording(AccountId, Url) -> end end. --spec maybe_storage_plan(ne_binary()) -> store_url(). +-spec maybe_storage_plan(kz_term:ne_binary()) -> store_url(). maybe_storage_plan(AccountId) -> AccountDb = kz_util:format_account_mod_id(AccountId), Plan = kzs_plan:get_dataplan(AccountDb, <<"call_recording">>), @@ -456,7 +456,7 @@ save_recording(#{media := Media}=Store) -> store_recording(Media, StoreUrl, Store) end. --spec store_recording({ne_binary(), ne_binary()}, ne_binary() | function(), map()) -> 'ok'. +-spec store_recording({kz_term:ne_binary(), kz_term:ne_binary()}, kz_term:ne_binary() | function(), map()) -> 'ok'. store_recording({DirName, MediaName}, StoreUrl, #{event := JObj} = Map) -> Node = kz_call_event:switch_nodename(JObj), Filename = filename:join(DirName, MediaName), @@ -465,7 +465,7 @@ store_recording({DirName, MediaName}, StoreUrl, #{event := JObj} = Map) -> 'ok' -> 'ok' end. --spec record_call_command(ne_binary(), ne_binary(), kz_json:object(), kapps_call:call()) -> kz_json:object(). +-spec record_call_command(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), kapps_call:call()) -> kz_json:object(). record_call_command(EndpointId, Inception, Data, Call) -> Format = get_format(kz_json:get_ne_binary_value(<<"format">>, Data)), TimeLimit = get_timelimit(kz_json:get_integer_value(<<"time_limit">>, Data)), diff --git a/core/kazoo_endpoint/src/kz_endpoints.erl b/core/kazoo_endpoint/src/kz_endpoints.erl index 7649a182792..252d48e2260 100644 --- a/core/kazoo_endpoint/src/kz_endpoints.erl +++ b/core/kazoo_endpoint/src/kz_endpoints.erl @@ -14,7 +14,7 @@ -include("kazoo_endpoint.hrl"). --spec by_owner_id(ne_binary(), kz_json:object(), kapps_call:call()) -> +-spec by_owner_id(kz_term:ne_binary(), kz_json:object(), kapps_call:call()) -> kz_json:objects(). by_owner_id(OwnerId, Data, Call) -> lists:foldr(fun(EndpointId, Acc) -> @@ -27,7 +27,7 @@ by_owner_id(OwnerId, Data, Call) -> ,kz_attributes:owned_by(OwnerId, <<"device">>, Call) ). --spec ignore_early_media(kz_json:objects()) -> api_binary(). +-spec ignore_early_media(kz_json:objects()) -> kz_term:api_binary(). ignore_early_media(Endpoints) -> case lists:any(fun(Endpoint) -> kz_json:is_true(<<"Ignore-Early-Media">>, Endpoint) diff --git a/core/kazoo_endpoint/src/kz_formatters.erl b/core/kazoo_endpoint/src/kz_formatters.erl index 5f3c66b0d86..3c4451e5dd1 100644 --- a/core/kazoo_endpoint/src/kz_formatters.erl +++ b/core/kazoo_endpoint/src/kz_formatters.erl @@ -35,7 +35,7 @@ maybe_format_sip_headers(JObj, MetaFormatters, Direction) -> ,<<"Custom-SIP-Headers">> ). --spec maybe_format_sub_object(kz_json:object(), kz_json:object(), direction(), ne_binary()) -> +-spec maybe_format_sub_object(kz_json:object(), kz_json:object(), direction(), kz_term:ne_binary()) -> kz_json:object(). maybe_format_sub_object(JObj, MetaFormatters, Direction, SubKey) -> case kz_json:get_json_value(SubKey, JObj) of @@ -68,7 +68,7 @@ format_request(JObj, MetaFormatters, Direction) -> ,MetaFormatters ). --spec request_keys(kz_json:object()) -> kz_proplist(). +-spec request_keys(kz_json:object()) -> kz_term:proplist(). request_keys(JObj) -> [{kz_json:normalize_key(K), K} || K <- kz_json:get_keys(kz_api:remove_defaults(JObj)) @@ -91,7 +91,7 @@ is_formatter_applicable(Formatter, Direction) -> _Direction -> 'false' end. --spec maybe_apply_formatters_fold(kz_json:object(), kz_json:path(), ne_binary(), kz_json:objects()) -> +-spec maybe_apply_formatters_fold(kz_json:object(), kz_json:path(), kz_term:ne_binary(), kz_json:objects()) -> kz_json:object(). maybe_apply_formatters_fold(JObj, _JObjKeys, _MetaKey, []) -> JObj; maybe_apply_formatters_fold(JObj, JObjKeys, MetaKey, [_|_]=Formatters) -> @@ -100,11 +100,11 @@ maybe_apply_formatters_fold(JObj, JObjKeys, MetaKey, [_|_]=Formatters) -> JObjKey -> maybe_apply_formatters(JObj, JObjKey, Formatters) end. --spec maybe_apply_formatters(kz_json:object(), ne_binary(), kz_json:objects()) -> +-spec maybe_apply_formatters(kz_json:object(), kz_term:ne_binary(), kz_json:objects()) -> kz_json:object(). --spec maybe_apply_formatters(kz_json:object(), ne_binary(), kz_json:json_term(), kz_json:objects()) -> +-spec maybe_apply_formatters(kz_json:object(), kz_term:ne_binary(), kz_json:json_term(), kz_json:objects()) -> kz_json:object(). --spec maybe_apply_formatters(kz_json:object(), ne_binary(), ne_binary(), ne_binary(), kz_json:objects()) -> +-spec maybe_apply_formatters(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:objects()) -> kz_json:object(). maybe_apply_formatters(JObj, <<"Request">> = RequestKey, Formatters) -> [RequestUser, RequestRealm] = binary:split(kz_json:get_value(<<"Request">>, JObj), <<"@">>), @@ -128,10 +128,10 @@ maybe_apply_formatters(JObj, Key, Value, [_|_]=Formatters) -> apply_formatter_funs(JObj, Key, Value, Formatters, Funs). -type ffun_return() :: kz_json:object() | 'false'. --type formatter_fun_4() :: fun((kz_json:object(), ne_binary(), kz_json:json_term(), kz_json:object()) -> ffun_return()). +-type formatter_fun_4() :: fun((kz_json:object(), kz_term:ne_binary(), kz_json:json_term(), kz_json:object()) -> ffun_return()). -type formatter_funs_4() :: [formatter_fun_4()]. --spec apply_formatter_funs(kz_json:object(), ne_binary(), kz_json:json_term(), kz_json:objects(), formatter_funs_4()) -> +-spec apply_formatter_funs(kz_json:object(), kz_term:ne_binary(), kz_json:json_term(), kz_json:objects(), formatter_funs_4()) -> kz_json:object(). apply_formatter_funs(JObj, Key, Value, [_|Formatters], []) -> maybe_apply_formatters(JObj, Key, Value, Formatters); @@ -141,7 +141,7 @@ apply_formatter_funs(JObj, Key, Value, [Formatter|_]=Formatters, [F|Fs]) -> Modified -> Modified end. --spec maybe_strip(kz_json:object(), ne_binary(), kz_json:json_term(), kz_json:object()) -> +-spec maybe_strip(kz_json:object(), kz_term:ne_binary(), kz_json:json_term(), kz_json:object()) -> ffun_return(). maybe_strip(JObj, Key, _Value, Formatter) -> case should_strip_key(Formatter) of @@ -151,7 +151,7 @@ maybe_strip(JObj, Key, _Value, Formatter) -> kz_json:delete_key(Key, JObj) end. --spec maybe_replace(kz_json:object(), ne_binary(), kz_json:json_term(), kz_json:object()) -> +-spec maybe_replace(kz_json:object(), kz_term:ne_binary(), kz_json:json_term(), kz_json:object()) -> ffun_return(). maybe_replace(JObj, Key, _Value, Formatter) -> case kz_json:get_value(<<"value">>, Formatter) of @@ -159,7 +159,7 @@ maybe_replace(JObj, Key, _Value, Formatter) -> Replace -> kz_json:set_value(Key, Replace, JObj) end. --spec maybe_match_invite_format(kz_json:object(), ne_binary(), kz_json:json_term(), kz_json:object()) -> +-spec maybe_match_invite_format(kz_json:object(), kz_term:ne_binary(), kz_json:json_term(), kz_json:object()) -> ffun_return(). maybe_match_invite_format(JObj, Key, Value, Formatter) -> case maybe_match_invite_format(JObj, Formatter) of @@ -169,7 +169,7 @@ maybe_match_invite_format(JObj, Key, Value, Formatter) -> match_invite_format(JObj, Key, Value) end. --spec match_invite_format(kz_json:object(), ne_binary(), kz_json:json_term()) -> +-spec match_invite_format(kz_json:object(), kz_term:ne_binary(), kz_json:json_term()) -> kz_json:object(). match_invite_format(JObj, <<"Diversions">> = Key, [<<_/binary>> = Value|_]) -> match_invite_format(JObj, Key, kzsip_diversion:from_binary(Value)); @@ -188,7 +188,7 @@ match_invite_format(JObj, Key, Value) -> should_strip_key(Formatter) -> kz_json:is_true(<<"strip">>, Formatter, 'false'). --spec maybe_match(kz_json:object(), ne_binary(), kz_json:json_term(), kz_json:object()) -> +-spec maybe_match(kz_json:object(), kz_term:ne_binary(), kz_json:json_term(), kz_json:object()) -> ffun_return(). maybe_match(JObj, <<"Diversions">> = Key, [<<_/binary>> = Value|_], Formatter) -> maybe_match(JObj, Key, kzsip_diversion:from_binary(Value), Formatter); @@ -219,10 +219,10 @@ maybe_apply_formatters(JObj, Key, User, Realm, Formatters) -> ], apply_formatter_funs(JObj, Key, User, Realm, Formatters, Funs). --type formatter_fun_5() :: fun((kz_json:object(), ne_binary(), ne_binary(), ne_binary(), kz_json:object()) -> ffun_return()). +-type formatter_fun_5() :: fun((kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> ffun_return()). -type formatter_funs_5() :: [formatter_fun_5()]. --spec apply_formatter_funs(kz_json:object(), ne_binary(), ne_binary(), ne_binary(), kz_json:objects(), formatter_funs_5()) -> +-spec apply_formatter_funs(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:objects(), formatter_funs_5()) -> kz_json:object(). apply_formatter_funs(JObj, Key, User, Realm, [_|Formatters], []) -> maybe_apply_formatters(JObj, Key, User, Realm, Formatters); @@ -232,7 +232,7 @@ apply_formatter_funs(JObj, Key, User, Realm, [Formatter|_]=Formatters, [F|Fs]) - Modified -> Modified end. --spec maybe_strip(kz_json:object(), ne_binary(), ne_binary(), ne_binary(), kz_json:object()) -> +-spec maybe_strip(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> ffun_return(). maybe_strip(JObj, Key, _User, _Realm, Formatter) -> case should_strip_key(Formatter) of @@ -242,7 +242,7 @@ maybe_strip(JObj, Key, _User, _Realm, Formatter) -> kz_json:delete_key(Key, JObj) end. --spec maybe_replace(kz_json:object(), ne_binary(), ne_binary(), ne_binary(), kz_json:object()) -> +-spec maybe_replace(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> ffun_return(). maybe_replace(JObj, Key, _User, Realm, Formatter) -> case kz_json:get_value(<<"value">>, Formatter) of @@ -250,7 +250,7 @@ maybe_replace(JObj, Key, _User, Realm, Formatter) -> Replace -> kz_json:set_value(Key, <>, JObj) end. --spec maybe_match_invite_format(kz_json:object(), ne_binary(), ne_binary(), ne_binary(), kz_json:object()) -> +-spec maybe_match_invite_format(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> ffun_return(). maybe_match_invite_format(JObj, Key, User, Realm, Formatter) -> case maybe_match_invite_format(JObj, Formatter) of @@ -276,7 +276,7 @@ maybe_match_invite_format(JObj, Formatter) -> <<"1npan">> -> 'true' end. --spec match_invite_format(kz_json:object(), ne_binary(), ne_binary(), ne_binary()) -> +-spec match_invite_format(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). match_invite_format(JObj, Key, User, Realm) -> FormatFun = invite_format_fun(JObj), @@ -286,7 +286,7 @@ match_invite_format(JObj, Key, User, Realm) -> ). -spec invite_format_fun(kz_json:object()) -> - fun((ne_binary()) -> ne_binary()). + fun((kz_term:ne_binary()) -> kz_term:ne_binary()). invite_format_fun(JObj) -> case kz_json:get_ne_binary_value(<<"Invite-Format">>, JObj) of <<"e164">> -> fun knm_converters:normalize/1; @@ -294,7 +294,7 @@ invite_format_fun(JObj) -> <<"npan">> -> fun knm_converters:to_npan/1 end. --spec maybe_match(kz_json:object(), ne_binary(), ne_binary(), ne_binary(), kz_json:object()) -> +-spec maybe_match(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> ffun_return(). maybe_match(JObj, Key, User, Realm, Formatter) -> case maybe_match(kz_json:get_ne_binary_value(<<"regex">>, Formatter), User) of @@ -302,7 +302,7 @@ maybe_match(JObj, Key, User, Realm, Formatter) -> 'nomatch' -> 'false' end. --spec maybe_match(api_binary(), ne_binary()) -> +-spec maybe_match(kz_term:api_binary(), kz_term:ne_binary()) -> {'match', binary()} | 'nomatch'. maybe_match('undefined', _Value) -> 'nomatch'; @@ -318,9 +318,9 @@ maybe_match(Regex, Value) -> 'nomatch' -> 'nomatch' end. --spec apply_formatter(kz_json:object(), ne_binary(), ne_binary(), kz_json:object()) -> +-spec apply_formatter(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). --spec apply_formatter(kz_json:object(), ne_binary(), ne_binary(), ne_binary(), kz_json:object()) -> +-spec apply_formatter(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). apply_formatter(Captured, Formatter) -> list_to_binary([kz_json:get_binary_value(<<"prefix">>, Formatter, <<>>) diff --git a/core/kazoo_endpoint/src/kz_privacy.erl b/core/kazoo_endpoint/src/kz_privacy.erl index 527d1175d64..978b6ec8f6e 100644 --- a/core/kazoo_endpoint/src/kz_privacy.erl +++ b/core/kazoo_endpoint/src/kz_privacy.erl @@ -37,8 +37,8 @@ -define(CALLER_PRIVACY_NAME, <<"Caller-Privacy-Hide-Name">>). -define(CALLER_PRIVACY_NUMBER, <<"Caller-Privacy-Hide-Number">>). --type cid_name() :: api_binary(). --type cid_number() :: api_binary(). +-type cid_name() :: kz_term:api_binary(). +-type cid_number() :: kz_term:api_binary(). -type cid() :: {cid_name(), cid_number()}. %%-------------------------------------------------------------------- @@ -49,7 +49,7 @@ %% caller id or both or bot hiding at all. %% @end %%-------------------------------------------------------------------- --spec maybe_cid_privacy(kz_proplist() | kz_json:object(), cid()) -> cid(). +-spec maybe_cid_privacy(kz_term:proplist() | kz_json:object(), cid()) -> cid(). maybe_cid_privacy(Props, Default) when is_list(Props) -> maybe_cid_privacy(kz_json:from_list(Props), Default); maybe_cid_privacy(JObj, Default) -> @@ -62,7 +62,7 @@ maybe_cid_privacy(JObj, Default) -> maybe_anonymize_cid(PrivacyMode, HideMode, JObj, Default) end. --spec flags(kz_proplist() | kz_json:object()) -> kz_proplist(). +-spec flags(kz_term:proplist() | kz_json:object()) -> kz_term:proplist(). flags(Props) when is_list(Props) -> flags(kz_json:from_list(Props)); flags(JObj) -> @@ -71,7 +71,7 @@ flags(JObj) -> ,{?CALLER_PRIVACY_NUMBER, caller_privacy_number(JObj)} ]. --spec has_flags(kz_proplist() | kz_json:object()) -> boolean(). +-spec has_flags(kz_term:proplist() | kz_json:object()) -> boolean(). has_flags(Props) when is_list(Props) -> has_flags(kz_json:from_list(Props)); has_flags(JObj) -> @@ -129,21 +129,21 @@ is_anonymous(JObj) -> %% Default anonymous Caller IDs from System wide config, or Account %% @end %%-------------------------------------------------------------------- --spec anonymous_caller_id_name() -> ne_binary(). +-spec anonymous_caller_id_name() -> kz_term:ne_binary(). anonymous_caller_id_name() -> kapps_config:get_binary(?PRIVACY_CAT, ?KEY_ANON_NAME, ?ANON_NAME). --spec anonymous_caller_id_name(api_binary()) -> ne_binary(). +-spec anonymous_caller_id_name(kz_term:api_binary()) -> kz_term:ne_binary(). anonymous_caller_id_name('undefined') -> anonymous_caller_id_name(); anonymous_caller_id_name(AccountId) -> kapps_account_config:get_global(AccountId, ?PRIVACY_CAT, ?KEY_ANON_NAME, ?ANON_NAME). --spec anonymous_caller_id_number() -> ne_binary(). +-spec anonymous_caller_id_number() -> kz_term:ne_binary(). anonymous_caller_id_number() -> kapps_config:get_binary(?PRIVACY_CAT, ?KEY_ANON_NUMBER, ?ANON_NUMBER). --spec anonymous_caller_id_number(api_binary()) -> ne_binary(). +-spec anonymous_caller_id_number(kz_term:api_binary()) -> kz_term:ne_binary(). anonymous_caller_id_number('undefined') -> anonymous_caller_id_number(); anonymous_caller_id_number(AccountId) -> @@ -155,12 +155,12 @@ anonymous_caller_id_number(AccountId) -> %% Checks for screen bits and caller id hide parameters %% @end %%-------------------------------------------------------------------- --spec caller_privacy_mode(kz_json:object()) -> ne_binary() | 'false'. +-spec caller_privacy_mode(kz_json:object()) -> kz_term:ne_binary() | 'false'. caller_privacy_mode(JObj) -> caller_screen_bit(JObj) andalso caller_privacy_mode(caller_privacy_name(JObj), caller_privacy_number(JObj)). --spec caller_privacy_mode(boolean(), boolean()) -> ne_binary(). +-spec caller_privacy_mode(boolean(), boolean()) -> kz_term:ne_binary(). caller_privacy_mode('true', 'true') -> ?HIDE_BOTH; caller_privacy_mode('true', 'false') -> ?HIDE_NAME; caller_privacy_mode('false', 'true') -> ?HIDE_NUMBER; @@ -172,7 +172,7 @@ caller_privacy_mode('false', 'false') -> ?NO_HIDE_MODE. %% Make some/all/no part of caller id anonymous base on system config %% @end %%-------------------------------------------------------------------- --spec maybe_anonymize_cid(api_binary(), ne_binary(), kz_json:object(), cid()) -> cid(). +-spec maybe_anonymize_cid(kz_term:api_binary(), kz_term:ne_binary(), kz_json:object(), cid()) -> cid(). maybe_anonymize_cid('undefined', HideMode, JObj, Default) -> maybe_anonymize_cid(get_default_privacy_mode(JObj), HideMode, JObj, Default); maybe_anonymize_cid(?NO_HIDE_MODE, _, _, Default) -> @@ -187,7 +187,7 @@ maybe_anonymize_cid(PrivacyMode, HideMode, JObj, Default) -> AccountId = get_value(<<"Account-ID">>, JObj), anonymize_cid(AccountId, Default, Mode). --spec hide_mode(ne_binary(), ne_binary()) -> ne_binary(). +-spec hide_mode(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). hide_mode(?HIDE_NAME, ?HIDE_NAME) -> lager:info("overriding caller id name to maintain privacy"), ?HIDE_NAME; @@ -201,7 +201,7 @@ hide_mode(?HIDE_NUMBER, _HideMode) -> lager:debug("ignoring ccv's caller privacy hide name, just overriding caller id number: ~s", [_HideMode]), ?HIDE_NUMBER. --spec anonymize_cid(ne_binary(), cid(), ne_binary()) -> cid(). +-spec anonymize_cid(kz_term:ne_binary(), cid(), kz_term:ne_binary()) -> cid(). anonymize_cid(_AccountId, Default, ?NO_HIDE_MODE) -> Default; anonymize_cid(AccountId, _Default, ?HIDE_BOTH) -> @@ -220,7 +220,7 @@ anonymize_cid(AccountId, {Name, _}, ?HIDE_NUMBER) -> %% legacy anonymizer setting on account's document %% @end %%-------------------------------------------------------------------- --spec get_default_privacy_mode(kz_json:object()) -> ne_binary(). +-spec get_default_privacy_mode(kz_json:object()) -> kz_term:ne_binary(). get_default_privacy_mode(JObj) -> AccountId = get_value(<<"Account-ID">>, JObj, get_master_account()), case get_legacy_anonymizer(kz_account:fetch(AccountId)) of @@ -235,12 +235,12 @@ get_default_privacy_mode(JObj) -> end. -spec get_legacy_anonymizer({'ok', kz_json:object()} | {'error', any()}) -> - api_ne_binary(). + kz_term:api_ne_binary(). get_legacy_anonymizer({'error', _}) -> 'undefined'; get_legacy_anonymizer({'ok', JObj}) -> kz_json:get_ne_binary_value(?KEY_LEGACY_ANONYMIZER, JObj). --spec get_master_account() -> api_binary(). +-spec get_master_account() -> kz_term:api_binary(). get_master_account() -> case kapps_util:get_master_account_id() of {'ok', AccountId} -> AccountId; @@ -269,7 +269,7 @@ caller_privacy_number(JObj) -> kz_term:is_true(get_value(?CALLER_PRIVACY_NUMBER, %% (a common way to make caller id number anonymous) %% @end %%-------------------------------------------------------------------- --spec is_zero(api_ne_binary()) -> boolean(). +-spec is_zero(kz_term:api_ne_binary()) -> boolean(). is_zero(?NE_BINARY=Number) -> case re:run(erlang:binary_to_list(Number), "^\\+?00+\$", ['global']) of {'match', _} -> 'true'; @@ -283,11 +283,11 @@ is_zero(_) -> 'false'. %% Get Key from JObj, if not found look into CCV %% @end %%-------------------------------------------------------------------- --spec get_value(ne_binary(), kz_json:object()) -> any(). +-spec get_value(kz_term:ne_binary(), kz_json:object()) -> any(). get_value(Key, JObj) -> get_value(Key, JObj, 'undefined'). --spec get_value(ne_binary(), kz_json:object(), any()) -> any(). +-spec get_value(kz_term:ne_binary(), kz_json:object(), any()) -> any(). get_value(Key, JObj, Default) -> case kz_json:get_first_defined([Key, ?CCV(Key)], JObj) of 'undefined' -> Default; diff --git a/core/kazoo_etsmgr/src/kazoo_etsmgr_srv.erl b/core/kazoo_etsmgr/src/kazoo_etsmgr_srv.erl index f0906526ea9..95be920ea52 100644 --- a/core/kazoo_etsmgr/src/kazoo_etsmgr_srv.erl +++ b/core/kazoo_etsmgr/src/kazoo_etsmgr_srv.erl @@ -48,9 +48,9 @@ ]). -record(state, {table_id :: atom() - ,give_away_pid :: api_pid() + ,give_away_pid :: kz_term:api_pid() ,find_me_fun :: find_me_fun() | undefined - ,find_me_pid_ref :: api_pid_ref() + ,find_me_pid_ref :: kz_term:api_pid_ref() ,gift_data :: any() }). -type state() :: #state{}. @@ -62,12 +62,12 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(start_args()) -> startlink_ret(). +-spec start_link(start_args()) -> kz_types:startlink_ret(). start_link(Opts) -> 'true' = valid_options(Opts), gen_server:start_link(?SERVER, [Opts], []). --spec start_link(atom(), start_args()) -> startlink_ret(). +-spec start_link(atom(), start_args()) -> kz_types:startlink_ret(). start_link(Name, Opts) -> 'true' = valid_options(Opts), gen_server:start_link({'local', Name}, ?MODULE, [Opts], []). @@ -140,7 +140,7 @@ opt_gift_data(Opts) -> props:get_value('gift_data', Opts, 'ok'). %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> lager:debug("unhandled call: ~p", [_Request]), {'reply', {'error', 'not_implemented'}, State}. @@ -155,7 +155,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'begin', TableId, TableOptions}, #state{gift_data=GiftData}=State) -> TID = ets:new(TableId, TableOptions), @@ -177,7 +177,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'EXIT', Pid, 'killed'}, #state{give_away_pid=Pid}=State) -> lager:debug("ets mgr ~p killed", [Pid]), {'noreply', State#state{give_away_pid='undefined'}}; diff --git a/core/kazoo_fixturedb/src/kazoo_fixturedb.erl b/core/kazoo_fixturedb/src/kazoo_fixturedb.erl index 9cabc0cfe02..824c6d82972 100644 --- a/core/kazoo_fixturedb/src/kazoo_fixturedb.erl +++ b/core/kazoo_fixturedb/src/kazoo_fixturedb.erl @@ -74,15 +74,15 @@ format_error(Error) -> %%% Connection operations %%%=================================================================== --spec get_db(server_map(), ne_binary()) -> map(). +-spec get_db(server_map(), kz_term:ne_binary()) -> map(). get_db(Server, DbName) -> kz_fixturedb_server:get_db(Server, DbName). --spec server_url(server_map()) -> ne_binary(). +-spec server_url(server_map()) -> kz_term:ne_binary(). server_url(Server) -> kz_fixturedb_server:server_url(Server). --spec db_url(server_map(), ne_binary()) -> ne_binary(). +-spec db_url(server_map(), kz_term:ne_binary()) -> kz_term:ne_binary(). db_url(Server, DbName) -> kz_fixturedb_server:db_url(Server, DbName). @@ -94,35 +94,35 @@ server_info(Server) -> %%% DB operations %%%=================================================================== --spec db_create(server_map(), ne_binary(), kz_data:options()) -> boolean(). +-spec db_create(server_map(), kz_term:ne_binary(), kz_data:options()) -> boolean(). db_create(Server, DbName, Options) -> kz_fixturedb_db:db_create(Server, DbName, Options). --spec db_delete(server_map(), ne_binary()) -> boolean(). +-spec db_delete(server_map(), kz_term:ne_binary()) -> boolean(). db_delete(Server, DbName) -> kz_fixturedb_db:db_delete(Server, DbName). --spec db_view_cleanup(server_map(), ne_binary()) -> boolean(). +-spec db_view_cleanup(server_map(), kz_term:ne_binary()) -> boolean(). db_view_cleanup(Server, DbName) -> kz_fixturedb_db:db_view_cleanup(Server, DbName). --spec db_info(server_map()) -> {ok, ne_binaries()}. +-spec db_info(server_map()) -> {ok, kz_term:ne_binaries()}. db_info(Server) -> kz_fixturedb_db:db_info(Server). --spec db_info(server_map(), ne_binary()) -> docs_resp(). +-spec db_info(server_map(), kz_term:ne_binary()) -> docs_resp(). db_info(Server, DbName) -> kz_fixturedb_db:db_info(Server, DbName). --spec db_exists(server_map(), ne_binary()) -> boolean(). +-spec db_exists(server_map(), kz_term:ne_binary()) -> boolean(). db_exists(Server, DbName) -> kz_fixturedb_db:db_exists(Server, DbName). --spec db_archive(server_map(), ne_binary(), ne_binary()) -> ok. +-spec db_archive(server_map(), kz_term:ne_binary(), kz_term:ne_binary()) -> ok. db_archive(_, _, _) -> ok. --spec db_list(server_map(), kz_data:options()) -> {'ok', ne_binaries()}. +-spec db_list(server_map(), kz_data:options()) -> {'ok', kz_term:ne_binaries()}. db_list(Server, Options) -> kz_fixturedb_db:db_list(Server, Options). @@ -130,31 +130,31 @@ db_list(Server, Options) -> %%% Document operations %%%=================================================================== --spec open_doc(server_map(), ne_binary(), ne_binary(), kz_data:options()) -> doc_resp(). +-spec open_doc(server_map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> doc_resp(). open_doc(Server, DbName, DocId, Options) -> kz_fixturedb_doc:open_doc(Server, DbName, DocId, Options). --spec lookup_doc_rev(server_map(), ne_binary(), ne_binary()) -> {ok, ne_binary()} | fixture_error(). +-spec lookup_doc_rev(server_map(), kz_term:ne_binary(), kz_term:ne_binary()) -> {ok, kz_term:ne_binary()} | fixture_error(). lookup_doc_rev(Server, DbName, DocId) -> kz_fixturedb_doc:lookup_doc_rev(Server, DbName, DocId). --spec save_doc(server_map(), ne_binary(), kz_data:document(), kz_data:options()) -> doc_resp(). +-spec save_doc(server_map(), kz_term:ne_binary(), kz_data:document(), kz_data:options()) -> doc_resp(). save_doc(Server, DbName, Doc, Options) -> kz_fixturedb_doc:save_doc(Server, DbName, Doc, Options). --spec save_docs(server_map(), ne_binary(), kz_data:documents(), kz_data:options()) -> docs_resp(). +-spec save_docs(server_map(), kz_term:ne_binary(), kz_data:documents(), kz_data:options()) -> docs_resp(). save_docs(Server, DbName, Docs, Options) -> kz_fixturedb_doc:save_docs(Server, DbName, Docs, Options). --spec del_doc(server_map(), ne_binary(), kz_data:document(), kz_data:options()) -> docs_resp(). +-spec del_doc(server_map(), kz_term:ne_binary(), kz_data:document(), kz_data:options()) -> docs_resp(). del_doc(Server, DbName, Doc, Options) -> kz_fixturedb_doc:del_doc(Server, DbName, Doc, Options). --spec del_docs(server_map(), ne_binary(), kz_data:documents(), kz_data:options()) -> docs_resp(). +-spec del_docs(server_map(), kz_term:ne_binary(), kz_data:documents(), kz_data:options()) -> docs_resp(). del_docs(Server, DbName, Docs, Options) -> kz_fixturedb_doc:del_docs(Server, DbName, Docs, Options). --spec ensure_saved(server_map(), ne_binary(), kz_data:document(), kz_data:options()) -> doc_resp(). +-spec ensure_saved(server_map(), kz_term:ne_binary(), kz_data:document(), kz_data:options()) -> doc_resp(). ensure_saved(Server, DbName, Doc, Options) -> kz_fixturedb_doc:ensure_saved(Server, DbName, Doc, Options). @@ -162,23 +162,23 @@ ensure_saved(Server, DbName, Doc, Options) -> %%% Attachment-related %%%=================================================================== --spec fetch_attachment(server_map(), ne_binary(), ne_binary(), ne_binary()) -> {ok, binary()} | fixture_error(). +-spec fetch_attachment(server_map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {ok, binary()} | fixture_error(). fetch_attachment(Server, DbName, DocId, AName) -> kz_fixturedb_attachments:fetch_attachment(Server, DbName, DocId, AName). --spec stream_attachment(server_map(), ne_binary(), ne_binary(), ne_binary(), pid()) -> {ok, reference()} | fixture_error(). +-spec stream_attachment(server_map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), pid()) -> {ok, reference()} | fixture_error(). stream_attachment(Server, DbName, DocId, AName, Caller) -> kz_fixturedb_attachments:stream_attachment(Server, DbName, DocId, AName, Caller). --spec put_attachment(server_map(), ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_data:options()) -> doc_resp(). +-spec put_attachment(server_map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> doc_resp(). put_attachment(Server, DbName, DocId, AName, Contents, Options) -> kz_fixturedb_attachments:put_attachment(Server, DbName, DocId, AName, Contents, Options). --spec delete_attachment(server_map(), ne_binary(), ne_binary(), ne_binary(), kz_data:options()) -> docs_resp(). +-spec delete_attachment(server_map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> docs_resp(). delete_attachment(Server, DbName, DocId, AName, Options) -> kz_fixturedb_attachments:delete_attachment(Server, DbName, DocId, AName, Options). --spec attachment_url(server_map(), ne_binary(), ne_binary(), ne_binary(), kz_data:options()) -> ne_binary(). +-spec attachment_url(server_map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> kz_term:ne_binary(). attachment_url(Server, DbName, DocId, AName, Options) -> kz_fixturedb_attachments:attachment_url(Server, DbName, DocId, AName, Options). @@ -186,22 +186,22 @@ attachment_url(Server, DbName, DocId, AName, Options) -> %%% View-related %%%=================================================================== --spec design_info(server_map(), ne_binary(), ne_binary()) -> doc_resp(). +-spec design_info(server_map(), kz_term:ne_binary(), kz_term:ne_binary()) -> doc_resp(). design_info(Server, DbName, Design) -> kz_fixturedb_view:design_info(Server, DbName, Design). --spec all_design_docs(server_map(), ne_binary(), kz_data:options()) -> docs_resp(). +-spec all_design_docs(server_map(), kz_term:ne_binary(), kz_data:options()) -> docs_resp(). all_design_docs(Server, DbName, Options) -> kz_fixturedb_view:all_design_docs(Server, DbName, Options). --spec get_results(server_map(), ne_binary(), ne_binary(), kz_data:options()) -> docs_resp(). +-spec get_results(server_map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> docs_resp(). get_results(Server, DbName, Design, Options) -> kz_fixturedb_view:get_results(Server, DbName, Design, Options). --spec get_results_count(server_map(), ne_binary(), ne_binary(), kz_data:options()) -> {ok, non_neg_integer()} | fixture_error(). +-spec get_results_count(server_map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> {ok, non_neg_integer()} | fixture_error(). get_results_count(Server, DbName, Design, Options) -> kz_fixturedb_view:get_results_count(Server, DbName, Design, Options). --spec all_docs(server_map(), ne_binary(), kz_data:options()) -> docs_resp(). +-spec all_docs(server_map(), kz_term:ne_binary(), kz_data:options()) -> docs_resp(). all_docs(Server, DbName, Options) -> kz_fixturedb_view:all_docs(Server, DbName, Options). diff --git a/core/kazoo_fixturedb/src/kazoo_fixturedb_app.erl b/core/kazoo_fixturedb/src/kazoo_fixturedb_app.erl index 29dd93b823f..18e4963d75f 100644 --- a/core/kazoo_fixturedb/src/kazoo_fixturedb_app.erl +++ b/core/kazoo_fixturedb/src/kazoo_fixturedb_app.erl @@ -22,7 +22,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_StartType, _StartArgs) -> kazoo_fixturedb_sup:start_link(). diff --git a/core/kazoo_fixturedb/src/kazoo_fixturedb_sup.erl b/core/kazoo_fixturedb/src/kazoo_fixturedb_sup.erl index b8ff8085a1f..9d12e576660 100644 --- a/core/kazoo_fixturedb/src/kazoo_fixturedb_sup.erl +++ b/core/kazoo_fixturedb/src/kazoo_fixturedb_sup.erl @@ -27,7 +27,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -44,7 +44,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, diff --git a/core/kazoo_fixturedb/src/kz_fixturedb.hrl b/core/kazoo_fixturedb/src/kz_fixturedb.hrl index 94083180df0..b3b800c3957 100644 --- a/core/kazoo_fixturedb/src/kz_fixturedb.hrl +++ b/core/kazoo_fixturedb/src/kz_fixturedb.hrl @@ -6,16 +6,16 @@ -include_lib("kazoo/include/kz_system_config.hrl"). -type server_options() :: #{test_app => atom() - ,test_db => ne_binary() + ,test_db => kz_term:ne_binary() ,test_db_subdir => atom() }. --type server_map() :: #{url => text() +-type server_map() :: #{url => kz_term:text() ,options => server_options() }. -type db_map() :: #{server => server_map() - ,name => ne_binary() + ,name => kz_term:ne_binary() }. -type fixture_errors() :: not_found | timeout | diff --git a/core/kazoo_fixturedb/src/kz_fixturedb_attachments.erl b/core/kazoo_fixturedb/src/kz_fixturedb_attachments.erl index 81d418a597b..326e4e476a9 100644 --- a/core/kazoo_fixturedb/src/kz_fixturedb_attachments.erl +++ b/core/kazoo_fixturedb/src/kz_fixturedb_attachments.erl @@ -21,29 +21,29 @@ %%% Attachment-related %%%=================================================================== --spec fetch_attachment(server_map(), ne_binary(), ne_binary(), ne_binary()) -> {ok, binary()} | fixture_error(). +-spec fetch_attachment(server_map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {ok, binary()} | fixture_error(). fetch_attachment(Server, DbName, DocId, AName) -> Db = kz_fixturedb_server:get_db(Server, DbName), kz_fixturedb_util:open_attachment(Db, DocId, AName). --spec stream_attachment(server_map(), ne_binary(), ne_binary(), ne_binary(), pid()) -> {ok, reference()} | fixture_error(). +-spec stream_attachment(server_map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), pid()) -> {ok, reference()} | fixture_error(). stream_attachment(Server, DbName, DocId, AName, Caller) -> AttResult = fetch_attachment(Server, DbName, DocId, AName), Ref = erlang:make_ref(), kz_util:spawn(fun relay_stream_attachment/3, [Caller, Ref, AttResult]), {ok, Ref}. --spec put_attachment(server_map(), ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_data:options()) -> doc_resp(). +-spec put_attachment(server_map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> doc_resp(). put_attachment(Server, DbName, DocId, AName, Contents, Options) -> Doc = kz_fixturedb_doc:open_doc(Server, DbName, DocId, Options), prepare_att_doc(Doc, AName, Contents, Options). --spec delete_attachment(server_map(), ne_binary(), ne_binary(), ne_binary(), kz_data:options()) -> docs_resp(). +-spec delete_attachment(server_map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> docs_resp(). delete_attachment(Server, DbName, DocId, _AName, Options) -> Doc = kz_fixturedb_doc:open_doc(Server, DbName, DocId, Options), del_att_response(Doc). --spec attachment_url(server_map(), ne_binary(), ne_binary(), ne_binary(), kz_data:options()) -> ne_binary(). +-spec attachment_url(server_map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> kz_term:ne_binary(). attachment_url(Server, DbName, DocId, AName, _Options) -> Db = kz_fixturedb_server:get_db(Server, DbName), kz_fixturedb_util:att_path(Db, DocId, AName). @@ -56,7 +56,7 @@ attachment_url(Server, DbName, DocId, AName, _Options) -> relay_stream_attachment(Caller, Ref, AttResult) -> Caller ! {Ref, AttResult}. --spec prepare_att_doc(doc_resp(), ne_binary(), ne_binary(), kz_data:options()) -> doc_resp(). +-spec prepare_att_doc(doc_resp(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> doc_resp(). prepare_att_doc({ok, Doc}, AName, Contents, Options) -> JObj = kz_fixturedb_util:update_revision(Doc), [RevPos|_] = kz_doc:revision(JObj), diff --git a/core/kazoo_fixturedb/src/kz_fixturedb_db.erl b/core/kazoo_fixturedb/src/kz_fixturedb_db.erl index 2b11013dffe..1a1580068f3 100644 --- a/core/kazoo_fixturedb/src/kz_fixturedb_db.erl +++ b/core/kazoo_fixturedb/src/kz_fixturedb_db.erl @@ -23,41 +23,41 @@ %%% DB operations %%%=================================================================== --spec db_create(server_map(), ne_binary(), kz_data:options()) -> boolean(). +-spec db_create(server_map(), kz_term:ne_binary(), kz_data:options()) -> boolean(). db_create(_Server, _DbName, _Options) -> 'true'. --spec db_delete(server_map(), ne_binary()) -> boolean(). +-spec db_delete(server_map(), kz_term:ne_binary()) -> boolean(). db_delete(_Server, _DbName) -> 'true'. --spec db_view_cleanup(server_map(), ne_binary()) -> boolean(). +-spec db_view_cleanup(server_map(), kz_term:ne_binary()) -> boolean(). db_view_cleanup(_Server, _DbName) -> 'true'. --spec db_info(server_map()) -> {'ok', ne_binaries()}. +-spec db_info(server_map()) -> {'ok', kz_term:ne_binaries()}. db_info(#{url := ServerUrl}=Server) -> #{url := AppUrl} = kz_fixturedb_server:get_app_connection(Server), {ok, get_dbs_list(ServerUrl, AppUrl)}. --spec db_info(server_map(), ne_binary()) -> docs_resp(). +-spec db_info(server_map(), kz_term:ne_binary()) -> docs_resp(). db_info(Server, DbName) -> case db_exists(Server, DbName) of 'false' -> {'error', 'not_found'}; 'true' -> {'ok', kz_json:from_list([{<<"db_name">>, DbName}])} end. --spec db_exists(server_map(), ne_binary()) -> boolean(). +-spec db_exists(server_map(), kz_term:ne_binary()) -> boolean(). db_exists(Server, DbName) -> #{url := Url} = kz_fixturedb_server:maybe_use_app_connection(Server, DbName), filelib:is_dir(kz_term:to_list(Url)). --spec db_archive(server_map(), ne_binary(), ne_binary()) -> 'ok'. +-spec db_archive(server_map(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. db_archive(_, _, _) -> 'ok'. --spec db_list(server_map(), kz_data:options()) -> {'ok', ne_binaries()}. +-spec db_list(server_map(), kz_data:options()) -> {'ok', kz_term:ne_binaries()}. db_list(Server, _Options) -> db_info(Server). @@ -65,7 +65,7 @@ db_list(Server, _Options) -> %%% Internal functions %%%=================================================================== --spec get_dbs_list(ne_binary(), ne_binary()) -> ne_binaries(). +-spec get_dbs_list(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binaries(). get_dbs_list(ServerUrl, ServerUrl) -> [kz_term:to_binary(Db) || Db <- get_dbs_list(ServerUrl)]; get_dbs_list(ServerUrl, AppUrl) -> @@ -73,6 +73,6 @@ get_dbs_list(ServerUrl, AppUrl) -> || Db <- get_dbs_list(ServerUrl) ++ get_dbs_list(AppUrl) ]). --spec get_dbs_list(ne_binary()) -> [string()]. +-spec get_dbs_list(kz_term:ne_binary()) -> [string()]. get_dbs_list(Url) -> filelib:wildcard(kz_term:to_list(Url) ++ "/*"). diff --git a/core/kazoo_fixturedb/src/kz_fixturedb_doc.erl b/core/kazoo_fixturedb/src/kz_fixturedb_doc.erl index 42aed38ffd3..e5c8537204a 100644 --- a/core/kazoo_fixturedb/src/kz_fixturedb_doc.erl +++ b/core/kazoo_fixturedb/src/kz_fixturedb_doc.erl @@ -23,7 +23,7 @@ %%% Document operations %%%=================================================================== --spec open_doc(server_map(), ne_binary(), api_ne_binary(), kz_data:options()) -> doc_resp(). +-spec open_doc(server_map(), kz_term:ne_binary(), kz_term:api_ne_binary(), kz_data:options()) -> doc_resp(). open_doc(Server, DbName, DocId, _Options) -> Db = kz_fixturedb_server:get_db(Server, DbName), case kz_term:is_empty(DocId) of @@ -31,14 +31,14 @@ open_doc(Server, DbName, DocId, _Options) -> 'false' -> kz_fixturedb_util:open_json(Db, DocId) end. --spec lookup_doc_rev(server_map(), ne_binary(), ne_binary()) -> {ok, ne_binary()} | fixture_error(). +-spec lookup_doc_rev(server_map(), kz_term:ne_binary(), kz_term:ne_binary()) -> {ok, kz_term:ne_binary()} | fixture_error(). lookup_doc_rev(Server, DbName, DocId) -> case open_doc(Server, DbName, DocId, []) of {'ok', Doc} -> {'ok', kz_doc:revision(Doc)}; {'error', _}=Error -> Error end. --spec save_doc(server_map(), ne_binary(), kz_data:document(), kz_data:options()) -> doc_resp(). +-spec save_doc(server_map(), kz_term:ne_binary(), kz_data:document(), kz_data:options()) -> doc_resp(). save_doc(Server, DbName, Doc, Options) when not is_list(Doc) -> case open_doc(Server, DbName, kz_doc:id(Doc), Options) of {'ok', JObj} -> @@ -57,7 +57,7 @@ save_doc(Server, DbName, Doc, Options) when not is_list(Doc) -> end end. --spec save_docs(server_map(), ne_binary(), kz_data:documents(), kz_data:options()) -> docs_resp(). +-spec save_docs(server_map(), kz_term:ne_binary(), kz_data:documents(), kz_data:options()) -> docs_resp(). save_docs(Server, DbName, Docs, Options) -> case kz_fixturedb_db:db_exists(Server, DbName) of 'false' -> {'error', 'not_found'}; @@ -65,15 +65,15 @@ save_docs(Server, DbName, Docs, Options) -> {'ok', [perform_save_doc(Server, DbName, Doc, Options) || Doc <- Docs]} end. --spec del_doc(server_map(), ne_binary(), kz_data:document(), kz_data:options()) -> {'ok', kz_json:objects()}. +-spec del_doc(server_map(), kz_term:ne_binary(), kz_data:document(), kz_data:options()) -> {'ok', kz_json:objects()}. del_doc(Server, DbName, Doc, Options) -> del_docs(Server, DbName, [Doc], Options). --spec del_docs(server_map(), ne_binary(), kz_data:documents(), kz_data:options()) -> {'ok', kz_json:objects()}. +-spec del_docs(server_map(), kz_term:ne_binary(), kz_data:documents(), kz_data:options()) -> {'ok', kz_json:objects()}. del_docs(Server, DbName, Docs, Options) -> {'ok', [perform_save_doc(Server, DbName, Doc, Options) || Doc <- Docs]}. --spec ensure_saved(server_map(), ne_binary(), kz_data:document(), kz_data:options()) -> doc_resp(). +-spec ensure_saved(server_map(), kz_term:ne_binary(), kz_data:document(), kz_data:options()) -> doc_resp(). ensure_saved(Server, DbName, Doc, Options) -> case save_doc(Server, DbName, Doc, Options) of {'ok', _}=OK -> OK; @@ -89,7 +89,7 @@ ensure_saved(Server, DbName, Doc, Options) -> %%% Internal functions %%%=================================================================== --spec perform_save_doc(server_map(), ne_binary(), kz_json:object(), kz_data:options()) -> +-spec perform_save_doc(server_map(), kz_term:ne_binary(), kz_json:object(), kz_data:options()) -> kz_json:object(). perform_save_doc(Server, DbName, JObj, Options) -> prepare_bulk_save_response(save_doc(Server, DbName, JObj, Options), JObj). diff --git a/core/kazoo_fixturedb/src/kz_fixturedb_server.erl b/core/kazoo_fixturedb/src/kz_fixturedb_server.erl index 0ecac34d229..492291a7eaa 100644 --- a/core/kazoo_fixturedb/src/kz_fixturedb_server.erl +++ b/core/kazoo_fixturedb/src/kz_fixturedb_server.erl @@ -41,16 +41,16 @@ new_connection(Map) -> %%% Connection operations %%%=================================================================== --spec get_db(server_map(), ne_binary()) -> map(). +-spec get_db(server_map(), kz_term:ne_binary()) -> map(). get_db(Server, DbName) -> ConnToUse = maybe_use_app_connection(Server, DbName), #{server => ConnToUse, name => DbName}. --spec server_url(server_map()) -> ne_binary(). +-spec server_url(server_map()) -> kz_term:ne_binary(). server_url(#{url := Url}) -> Url. --spec db_url(server_map(), ne_binary()) -> ne_binary(). +-spec db_url(server_map(), kz_term:ne_binary()) -> kz_term:ne_binary(). db_url(Server, DbName) -> #{url := Url} = maybe_use_app_connection(Server, DbName), <<(kz_term:to_binary(Url))/binary, "/", DbName/binary>>. @@ -78,7 +78,7 @@ get_app_connection(#{options := Options}=Server) -> set_app_connection(Server, AppName) end. --spec maybe_use_app_connection(server_map(), ne_binary()) -> server_map(). +-spec maybe_use_app_connection(server_map(), kz_term:ne_binary()) -> server_map(). maybe_use_app_connection(#{options := Options}=Server, DbName) -> case {maps:get(test_app, Options, 'unedfined') ,maps:get(test_db, Options, 'unedfined') diff --git a/core/kazoo_fixturedb/src/kz_fixturedb_util.erl b/core/kazoo_fixturedb/src/kz_fixturedb_util.erl index 2f63a332a60..7d92677fa7d 100644 --- a/core/kazoo_fixturedb/src/kz_fixturedb_util.erl +++ b/core/kazoo_fixturedb/src/kz_fixturedb_util.erl @@ -49,34 +49,34 @@ format_error(Other) -> Other. %%% API %%%=================================================================== --spec open_json(db_map(), ne_binary()) -> doc_resp(). +-spec open_json(db_map(), kz_term:ne_binary()) -> doc_resp(). open_json(Db, DocId) -> read_json(doc_path(Db, DocId)). --spec open_attachment(db_map(), ne_binary(), ne_binary()) -> {ok, binary()} | {error, not_found}. +-spec open_attachment(db_map(), kz_term:ne_binary(), kz_term:ne_binary()) -> {ok, binary()} | {error, not_found}. open_attachment(Db, DocId, AName) -> read_file(att_path(Db, DocId, AName)). --spec open_view(db_map(), ne_binary(), kz_data:options()) -> docs_resp(). +-spec open_view(db_map(), kz_term:ne_binary(), kz_data:options()) -> docs_resp(). open_view(Db, Design, Options) -> %% ?LOG_DEBUG("~nDb ~p~n Design ~p~n Options ~p~n Path ~p~n" %% ,[Db, Design, Options, view_path(Db, Design, Options)]), read_json(view_path(Db, Design, Options)). --spec doc_path(db_map(), ne_binary()) -> file:filename_all(). +-spec doc_path(db_map(), kz_term:ne_binary()) -> file:filename_all(). doc_path(#{server := #{url := Url}, name := DbName}, DocId) -> filename:join(kz_term:to_list(Url) ++ "/" ++ kz_term:to_list(DbName) ,["docs/", http_uri:encode(kz_term:to_list(DocId)), ".json"] ). --spec att_path(db_map(), ne_binary(), ne_binary()) -> file:filename_all(). +-spec att_path(db_map(), kz_term:ne_binary(), kz_term:ne_binary()) -> file:filename_all(). att_path(#{server := #{url := Url}, name := DbName}, DocId, AName) -> AttName = kz_binary:hexencode(crypto:hash(md5, <>)), filename:join(kz_term:to_list(Url) ++ "/" ++ kz_term:to_list(DbName) ,["docs/", kz_term:to_list(AttName), ".att"] ). --spec view_path(db_map(), ne_binary(), kz_data:options()) -> file:filename_all(). +-spec view_path(db_map(), kz_term:ne_binary(), kz_data:options()) -> file:filename_all(). view_path(#{server := #{url := Url}, name := DbName}, Design, Options) -> filename:join(kz_term:to_list(Url) ++ "/" ++ kz_term:to_list(DbName) ,["views/", encode_query_filename(Design, Options)] @@ -85,15 +85,15 @@ view_path(#{server := #{url := Url}, name := DbName}, Design, Options) -> %% @doc %% The idea is to encode file name based on view options so you can %% write JSON file specifically for each of your view queries --spec encode_query_filename(ne_binary(), kz_data:options()) -> text(). +-spec encode_query_filename(kz_term:ne_binary(), kz_data:options()) -> kz_term:text(). encode_query_filename(Design, Options) -> encode_query_options(Design, ?DANGEROUS_VIEW_OPTS, Options, []). --spec docs_dir(db_map()) -> text(). +-spec docs_dir(db_map()) -> kz_term:text(). docs_dir(#{server := #{url := Url}, name := DbName}) -> kz_term:to_list(<>). --spec views_dir(db_map()) -> text(). +-spec views_dir(db_map()) -> kz_term:text(). views_dir(#{server := #{url := Url}, name := DbName}) -> kz_term:to_list(<>). @@ -120,39 +120,39 @@ update_revision(JObj) -> %%% Handy functions to use from shell to managing files %%%=================================================================== --spec get_doc_path(ne_binary(), ne_binary()) -> file:filename_all(). +-spec get_doc_path(kz_term:ne_binary(), kz_term:ne_binary()) -> file:filename_all(). get_doc_path(DbName, DocId) -> Plan = kzs_plan:plan(DbName), get_doc_path(Plan, DbName, DocId). --spec get_doc_path(map(), ne_binary(), ne_binary()) -> file:filename_all(). +-spec get_doc_path(map(), kz_term:ne_binary(), kz_term:ne_binary()) -> file:filename_all(). get_doc_path(#{server := {_, Conn}}=_Plan, DbName, DocId) -> doc_path(kz_fixturedb_server:get_db(Conn, DbName), DocId). --spec get_att_path(ne_binary(), ne_binary(), ne_binary()) -> file:filename_all(). +-spec get_att_path(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> file:filename_all(). get_att_path(DbName, DocId, AName) -> Plan = kzs_plan:plan(DbName), get_att_path(Plan, DbName, DocId, AName). --spec get_att_path(map(), ne_binary(), ne_binary(), ne_binary()) -> file:filename_all(). +-spec get_att_path(map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> file:filename_all(). get_att_path(#{server := {_, Conn}}=_Plan, DbName, DocId, AName) -> att_path(kz_fixturedb_server:get_db(Conn, DbName), DocId, AName). --spec get_view_path(ne_binary(), ne_binary(), kz_proplist()) -> file:filename_all(). +-spec get_view_path(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> file:filename_all(). get_view_path(DbName, Design, Options) -> Plan = kzs_plan:plan(DbName), get_view_path(Plan, DbName, Design, Options). --spec get_view_path(map(), ne_binary(), ne_binary(), kz_proplist()) -> file:filename_all(). +-spec get_view_path(map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> file:filename_all(). get_view_path(#{server := {_, Conn}}=_Plan, DbName, Design, Options) -> view_path(kz_fixturedb_server:get_db(Conn, DbName), Design, Options). --spec add_att_path_to_index(ne_binary(), ne_binary(), ne_binary()) -> {ok, binary()} | {error, any()}. +-spec add_att_path_to_index(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {ok, binary()} | {error, any()}. add_att_path_to_index(DbName, DocId, AName) -> Plan = kzs_plan:plan(DbName), add_att_path_to_index(Plan, DbName, DocId, AName). --spec add_att_path_to_index(map(), ne_binary(), ne_binary(), ne_binary()) -> {ok, binary()} | {error, any()}. +-spec add_att_path_to_index(map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {ok, binary()} | {error, any()}. add_att_path_to_index(#{server := {_, Conn}}=_Plan, DbName, DocId, AName) -> #{server := #{url := Url}} = Db = kz_fixturedb_server:get_db(Conn, DbName), AttPath = att_path(Db, DocId, AName), @@ -164,12 +164,12 @@ add_att_path_to_index(#{server := {_, Conn}}=_Plan, DbName, DocId, AName) -> false -> write_append_file(IndexPath, <
>) end. --spec add_view_path_to_index(ne_binary(), ne_binary(), kz_proplist()) -> {ok, binary()} | {error, any()}. +-spec add_view_path_to_index(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> {ok, binary()} | {error, any()}. add_view_path_to_index(DbName, Design, Options) -> Plan = kzs_plan:plan(DbName), add_view_path_to_index(Plan, DbName, Design, Options). --spec add_view_path_to_index(map(), ne_binary(), ne_binary(), kz_proplist()) -> {ok, binary()} | {error, any()}. +-spec add_view_path_to_index(map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> {ok, binary()} | {error, any()}. add_view_path_to_index(#{server := {_, Conn}}=_Plan, DbName, Design, Options) -> #{server := #{url := Url}} = Db = kz_fixturedb_server:get_db(Conn, DbName), ViewPath = view_path(Db, Design, Options), @@ -181,11 +181,11 @@ add_view_path_to_index(#{server := {_, Conn}}=_Plan, DbName, Design, Options) -> false -> write_append_file(IndexPath, <
>) end. --spec index_file_path(text(), ne_binary(), ne_binary()) -> text(). +-spec index_file_path(kz_term:text(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:text(). index_file_path(Mode, Url, DbName) -> kz_term:to_list(Url) ++ "/" ++ kz_term:to_list(DbName) ++ "/" ++ Mode ++ "-index.csv". --spec index_has_header(text()) -> boolean(). +-spec index_has_header(kz_term:text()) -> boolean(). index_has_header(Path) -> case file:read_file(Path) of {ok, <<>>} -> false; @@ -199,7 +199,7 @@ update_pvt_doc_hash() -> _ = [update_pvt_doc_hash(Path) || Path <- Paths], ok. --spec update_pvt_doc_hash(text() | ne_binary()) -> ok | {error, any()}. +-spec update_pvt_doc_hash(kz_term:text() | kz_term:ne_binary()) -> ok | {error, any()}. update_pvt_doc_hash(Path) -> case read_json(Path) of {ok, JObj} -> @@ -233,7 +233,7 @@ write_append_file(Path, Contents) -> {error, _}=Error -> Error end. --spec encode_query_options(ne_binary(), list(), kz_data:options(), list()) -> text(). +-spec encode_query_options(kz_term:ne_binary(), list(), kz_data:options(), list()) -> kz_term:text(). encode_query_options(Design, [], _, []) -> DesignView = design_view(Design), kz_term:to_list(<>); @@ -248,7 +248,7 @@ encode_query_options(Design, [Key|Keys], Options, Acc) -> Value -> encode_query_options(Design, Keys, Options, ["&", Key, "=", Value | Acc]) end. --spec design_view(ne_binary()) -> ne_binary(). +-spec design_view(kz_term:ne_binary()) -> kz_term:ne_binary(). design_view(Design) -> case binary:split(Design, <<"/">>) of [DesignName] -> DesignName; diff --git a/core/kazoo_fixturedb/src/kz_fixturedb_view.erl b/core/kazoo_fixturedb/src/kz_fixturedb_view.erl index 8a878e61c2f..5008b045583 100644 --- a/core/kazoo_fixturedb/src/kz_fixturedb_view.erl +++ b/core/kazoo_fixturedb/src/kz_fixturedb_view.erl @@ -21,11 +21,11 @@ %%% View-related %%%=================================================================== --spec design_info(server_map(), ne_binary(), ne_binary()) -> doc_resp(). +-spec design_info(server_map(), kz_term:ne_binary(), kz_term:ne_binary()) -> doc_resp(). design_info(_Server, _DbName, Design) -> {ok, kz_json:from_list([{<<"name">>, Design}])}. --spec all_design_docs(server_map(), ne_binary(), kz_data:options()) -> docs_resp(). +-spec all_design_docs(server_map(), kz_term:ne_binary(), kz_data:options()) -> docs_resp(). all_design_docs(Server, DbName, _Options) -> Db = kz_fixturedb_server:get_db(Server, DbName), Path = kz_fixturedb_util:docs_dir(Db), @@ -39,7 +39,7 @@ all_design_docs(Server, DbName, _Options) -> {ok, [kz_http_util:urldecode(kz_term:to_binary(filename:basename(D))) || D <- DesignDocs]} end. --spec get_results(server_map(), ne_binary(), ne_binary(), kz_data:options()) -> docs_resp(). +-spec get_results(server_map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> docs_resp(). get_results(Server, DbName, Design, Options) -> Db = kz_fixturedb_server:get_db(Server, DbName), %%props:get_first_defined(?DANGEROUS_VIEW_OPTS, Options) =/= undefined @@ -49,14 +49,14 @@ get_results(Server, DbName, Design, Options) -> {error, _} -> {error, invalid_view_name} end. --spec get_results_count(server_map(), ne_binary(), ne_binary(), kz_data:options()) -> {ok, non_neg_integer()} | fixture_error(). +-spec get_results_count(server_map(), kz_term:ne_binary(), kz_term:ne_binary(), kz_data:options()) -> {ok, non_neg_integer()} | fixture_error(). get_results_count(Server, DbName, Design, Options) -> case get_results(Server, DbName, Design, Options) of {ok, JObjs} -> {ok, erlang:length(JObjs)}; {error, _}=Error -> Error end. --spec all_docs(server_map(), ne_binary(), kz_data:options()) -> docs_resp(). +-spec all_docs(server_map(), kz_term:ne_binary(), kz_data:options()) -> docs_resp(). all_docs(Server, DbName, Options) -> get_results(Server, DbName, <<"all_docs">>, Options). @@ -64,7 +64,7 @@ all_docs(Server, DbName, Options) -> %%% Internal functions %%%=================================================================== --spec prepare_view_result(server_map(), ne_binary(), kz_json:objects(), kz_data:options()) -> kz_json:objects(). +-spec prepare_view_result(server_map(), kz_term:ne_binary(), kz_json:objects(), kz_data:options()) -> kz_json:objects(). prepare_view_result(Server, DbName, Result, Options) -> case props:get_value(include_docs, Options, false) of false -> sort_and_limit(Result, Options); @@ -84,7 +84,7 @@ sort_and_limit(Result, Options) -> true -> limit_result(lists:reverse(Result), Limit) end. --spec limit_result(kz_json:objects(), api_integer()) -> kz_json:objects(). +-spec limit_result(kz_json:objects(), kz_term:api_integer()) -> kz_json:objects(). limit_result(Result, Limit) when is_integer(Limit), Limit > 0 -> try lists:split(Limit, Result) of diff --git a/core/kazoo_globals/src/kazoo_globals_app.erl b/core/kazoo_globals/src/kazoo_globals_app.erl index 96596c0df63..cbb16658c33 100644 --- a/core/kazoo_globals/src/kazoo_globals_app.erl +++ b/core/kazoo_globals/src/kazoo_globals_app.erl @@ -14,7 +14,7 @@ -export([start/2, stop/1]). -export([start/0]). --spec start() -> {'ok', atoms()}. +-spec start() -> {'ok', kz_term:atoms()}. start() -> {'ok', _Apps} = application:ensure_all_started('kazoo_globals'). @@ -22,7 +22,7 @@ start() -> %% @public %% @doc Implement the application start behaviour --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_StartType, _StartArgs) -> kazoo_globals_sup:start_link(). diff --git a/core/kazoo_globals/src/kazoo_globals_init.erl b/core/kazoo_globals/src/kazoo_globals_init.erl index 6921dd74655..e2238637756 100644 --- a/core/kazoo_globals/src/kazoo_globals_init.erl +++ b/core/kazoo_globals/src/kazoo_globals_init.erl @@ -12,7 +12,7 @@ -include("kazoo_globals.hrl"). --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> wait_for_globals('false'). diff --git a/core/kazoo_globals/src/kazoo_globals_sup.erl b/core/kazoo_globals/src/kazoo_globals_sup.erl index e2ccdfc151d..f3c9f644006 100644 --- a/core/kazoo_globals/src/kazoo_globals_sup.erl +++ b/core/kazoo_globals/src/kazoo_globals_sup.erl @@ -40,7 +40,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -57,7 +57,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> kz_util:set_startup(), RestartStrategy = 'one_for_one', diff --git a/core/kazoo_globals/src/kz_global.erl b/core/kazoo_globals/src/kz_global.erl index f8550fe1b2a..23170adf78e 100644 --- a/core/kazoo_globals/src/kz_global.erl +++ b/core/kazoo_globals/src/kz_global.erl @@ -44,10 +44,10 @@ -record(kz_global, {node = node() :: atom() | '_' ,zone :: atom() | '_' - ,pid :: api_pid() | '$2' | '_' + ,pid :: kz_term:api_pid() | '$2' | '_' ,server :: any() | '_' ,name :: name() | '$1' | '_' - ,monitor :: api_reference() | '_' + ,monitor :: kz_term:api_reference() | '_' ,state = 'none' :: kapi_globals:state() | '_' | '$1' ,timestamp = new_timestamp() :: integer() | '_' }). @@ -69,15 +69,15 @@ from_jobj(JObj, Zone) -> ,timestamp = kapi_globals:timestamp(JObj) }. --spec new_global(name(), pid(), atom(), ne_binary()) -> global(). +-spec new_global(name(), pid(), atom(), kz_term:ne_binary()) -> global(). new_global(Name, Pid, Zone, Queue) -> new_global(Name, Pid, Zone, Queue, 'local'). --spec new_global(name(), pid(), atom(), ne_binary(), atom()) -> global(). +-spec new_global(name(), pid(), atom(), kz_term:ne_binary(), atom()) -> global(). new_global(Name, Pid, Zone, Queue, State) -> new_global(Name, Pid, Zone, Queue, State, new_timestamp()). --spec new_global(name(), pid(), atom(), ne_binary(), atom(), integer()) -> global(). +-spec new_global(name(), pid(), atom(), kz_term:ne_binary(), atom(), integer()) -> global(). new_global(Name, Pid, Zone, Queue, State, Timestamp) -> #kz_global{node = node() ,zone = Zone @@ -88,7 +88,7 @@ new_global(Name, Pid, Zone, Queue, State, Timestamp) -> ,timestamp=Timestamp }. --spec update_with_pid_ref(global(), pid_ref()) -> global(). +-spec update_with_pid_ref(global(), kz_term:pid_ref()) -> global(). -spec update_with_pid_ref(global(), pid(), reference()) -> global(). update_with_pid_ref(Global, {Pid, Ref}) -> update_with_pid_ref(Global, Pid, Ref). @@ -106,7 +106,7 @@ all_names(Table) -> MatchSpec = [{#kz_global{name = '$1', _ = '_'} ,[],['$1']}], ets:select(Table, MatchSpec). --spec stats(ets:tab()) -> kz_proplist(). +-spec stats(ets:tab()) -> kz_term:proplist(). stats(Table) -> MatchSpec = [{#kz_global{state = '$1', _ = '_'} ,[],['$1']}], lists:foldl(fun(State, Props) -> @@ -150,7 +150,7 @@ pid(#kz_global{pid=Pid}) -> Pid. -spec zone(global()) -> atom(). zone(#kz_global{zone=Zone}) -> Zone. --spec server(global()) -> api_binary(). +-spec server(global()) -> kz_term:api_binary(). server(#kz_global{server=Queue}) -> Queue. -spec node(global()) -> atom(). diff --git a/core/kazoo_globals/src/kz_global_proxies_sup.erl b/core/kazoo_globals/src/kz_global_proxies_sup.erl index 493fb6cc70f..bd8614ed59e 100644 --- a/core/kazoo_globals/src/kz_global_proxies_sup.erl +++ b/core/kazoo_globals/src/kz_global_proxies_sup.erl @@ -32,15 +32,15 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec new(kz_global:global()) -> sup_startchild_ret(). +-spec new(kz_global:global()) -> kz_types:sup_startchild_ret(). new(Global) -> supervisor:start_child(?SERVER, [Global]). --spec workers() -> pids(). +-spec workers() -> kz_term:pids(). workers() -> [Pid || {_, Pid, 'worker', [_]} <- supervisor:which_children(?SERVER)]. @@ -57,7 +57,7 @@ workers() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 0, diff --git a/core/kazoo_globals/src/kz_global_proxy.erl b/core/kazoo_globals/src/kz_global_proxy.erl index aeccf3702dd..654c8ed3993 100644 --- a/core/kazoo_globals/src/kz_global_proxy.erl +++ b/core/kazoo_globals/src/kz_global_proxy.erl @@ -26,7 +26,7 @@ -type state() :: any(). --spec start_link(any()) -> startlink_ret(). +-spec start_link(any()) -> kz_types:startlink_ret(). start_link(Global) -> gen_server:start_link(?MODULE, [Global], []). @@ -46,11 +46,11 @@ send(Pid, Message) -> init([Global]) -> {'ok', Global}. --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(Request, _From, Global) -> {'reply', amqp_call(Global, Request), Global}. --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'$proxy_stop', Reason}, Global) -> gen_server:call('kz_globals', {'delete_remote', self()}), {'stop', Reason, Global}; @@ -59,7 +59,7 @@ handle_cast(Message, Global) -> amqp_send(Global, {'$gen_cast', Message}), {'noreply', Global}. --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(Message, Global) -> lager:debug("relaying msg: ~p", [Message]), amqp_send(Global, Message), diff --git a/core/kazoo_globals/src/kz_globals.erl b/core/kazoo_globals/src/kz_globals.erl index 397ed092e13..e5d76ec9124 100644 --- a/core/kazoo_globals/src/kz_globals.erl +++ b/core/kazoo_globals/src/kz_globals.erl @@ -92,8 +92,8 @@ -define(TAB_NAME, 'kazoo_global_names'). -record(state, {zone = 'local' :: atom() - ,zones = [] :: kz_proplist() - ,queue :: api_binary() + ,zones = [] :: kz_term:proplist() + ,queue :: kz_term:api_binary() ,node = node() :: atom() ,is_consuming = 'false' :: boolean() ,has_ets = 'false' :: boolean() @@ -107,7 +107,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link({'local', ?SERVER} ,?MODULE @@ -137,7 +137,7 @@ send(Name, Msg) -> kz_global:pid(Global) end. --spec whereis_name(kz_global:name()) -> api_pid(). +-spec whereis_name(kz_global:name()) -> kz_term:api_pid(). whereis_name(Name) -> gen_listener:call(?SERVER, {'whereis_name', Name}, ?MILLISECONDS_IN_DAY). @@ -167,7 +167,7 @@ register_name(Name, Pid) -> registered() -> kz_global:all_names(?TAB_NAME). --spec stats() -> kz_proplist(). +-spec stats() -> kz_term:proplist(). stats() -> case kz_global:stats(?TAB_NAME) of [] -> [{'total', 0}]; @@ -202,7 +202,7 @@ table_options() -> ['set' -spec gift_data() -> 'ok'. gift_data() -> 'ok'. --spec find_me() -> api_pid(). +-spec find_me() -> kz_term:api_pid(). find_me() -> whereis(?SERVER). @@ -246,7 +246,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), globals_state()) -> handle_call_ret_state(globals_state()). +-spec handle_call(any(), kz_term:pid_ref(), globals_state()) -> kz_types:handle_call_ret_state(globals_state()). handle_call('flush', _From, State) -> ets:delete_all_objects(?TAB_NAME), lager:debug("flushed table"), @@ -301,7 +301,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), globals_state()) -> handle_cast_ret_state(globals_state()). +-spec handle_cast(any(), globals_state()) -> kz_types:handle_cast_ret_state(globals_state()). handle_cast({'amqp_delete', Global, 'undefined'}, State) -> kz_global_proxy:stop(kz_global:pid(Global)), {'noreply', State}; @@ -352,7 +352,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), globals_state()) -> handle_info_ret_state(globals_state()). +-spec handle_info(any(), globals_state()) -> kz_types:handle_info_ret_state(globals_state()). handle_info({'DOWN', Ref, 'process', Pid, Reason}, State) -> lager:debug("monitor ~p detected process ~p exited with reason ~p", [Ref, Pid, Reason]), erlang:demonitor(Ref, ['flush']), @@ -377,7 +377,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(JObj, State) -> case kz_api:node(JObj) =:= kz_term:to_binary(node()) of 'true' -> 'ignore'; @@ -645,7 +645,7 @@ amqp_query(Name, From) -> end end. --spec handle_amqp_call(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_amqp_call(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_amqp_call(JObj, _Props) -> case where(kapi_globals:name(JObj)) of 'undefined' -> 'ok'; @@ -683,7 +683,7 @@ amqp_reply(JObj, Result) -> Publisher = fun(P) -> kapi_globals:publish_reply(ServerId, P) end, kz_amqp_worker:cast(Payload, Publisher). --spec handle_amqp_send(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_amqp_send(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_amqp_send(JObj, _Props) -> case where(kapi_globals:name(JObj)) of 'undefined' -> 'ok'; @@ -701,7 +701,7 @@ maybe_handle_local_send(_JObj, _Global, 'true', 'false') -> 'ok'; maybe_handle_local_send(JObj, Global, 'true', 'true') -> kz_global_proxy:send(kz_global:pid(Global), kapi_globals:message(JObj)). --spec handle_amqp_query(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_amqp_query(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_amqp_query(JObj, _Props) -> case where(kapi_globals:name(JObj)) of 'undefined' -> amqp_query_empty_reply(JObj); @@ -744,7 +744,7 @@ amqp_query_reply(JObj, Global) -> Publisher = fun(P) -> kapi_globals:publish_query_resp(ServerId, P) end, kz_amqp_worker:cast(Payload, Publisher). --spec handle_amqp_register(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_amqp_register(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_amqp_register(JObj, _Props) -> lager:debug("checking amqp register ~p: ~p", [kapi_globals:state(JObj), JObj]), handle_amqp_register_state(JObj, kapi_globals:state(JObj)). @@ -797,7 +797,7 @@ amqp_register_reply(JObj, Global) -> ), kz_amqp_worker:cast(Payload, Publisher). --spec handle_amqp_unregister(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_amqp_unregister(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_amqp_unregister(JObj, _Props) -> case where(kapi_globals:name(JObj)) of 'undefined' -> 'ok'; diff --git a/core/kazoo_globals/src/kz_nodes.erl b/core/kazoo_globals/src/kz_nodes.erl index a51e63f7996..0bfeac2de6d 100644 --- a/core/kazoo_globals/src/kz_nodes.erl +++ b/core/kazoo_globals/src/kz_nodes.erl @@ -44,11 +44,11 @@ ]). -type request_info() :: {'app', atom()} | - {'media_servers', [{ne_binary(), kz_json:object()}]} | + {'media_servers', [{kz_term:ne_binary(), kz_json:object()}]} | {'channels', non_neg_integer()} | {'conferences', non_neg_integer()} | {'registrations', non_neg_integer()} | - {'info', whapp_info()}. + {'info', kz_types:whapp_info()}. -type request_acc() :: [request_info()]. -export_type([request_acc/0]). @@ -91,11 +91,11 @@ ,notify_new = sets:new() :: sets:set() ,notify_expire = sets:new() :: sets:set() ,node = node() :: atom() - ,md5 :: ne_binary() + ,md5 :: kz_term:ne_binary() ,zone = 'local' :: atom() - ,version :: ne_binary() - ,zones = [] :: kz_proplist() - ,me = 'undefined' :: kz_node() | 'undefined' + ,version :: kz_term:ne_binary() + ,zones = [] :: kz_term:proplist() + ,me = 'undefined' :: kz_types:kz_node() | 'undefined' }). -type nodes_state() :: #state{}. @@ -106,7 +106,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link({'local', ?SERVER} ,?MODULE @@ -130,7 +130,7 @@ is_up(Node) -> [_] -> 'true' end. --spec node_to_json(text() | kz_node()) -> kz_json:object(). +-spec node_to_json(kz_term:text() | kz_types:kz_node()) -> kz_json:object(). node_to_json(NodeName) when is_atom(NodeName) -> [#kz_node{}=Node] = ets:lookup(?MODULE, NodeName), node_to_json(Node); @@ -169,11 +169,11 @@ globals_scope() -> }], length(ets:select(?MODULE, MatchSpec)). --spec whapp_count(text()) -> integer(). +-spec whapp_count(kz_term:text()) -> integer(). whapp_count(Whapp) -> whapp_count(Whapp, 'false'). --spec whapp_count(text(), text() | boolean() | 'remote') -> integer(). +-spec whapp_count(kz_term:text(), kz_term:text() | boolean() | 'remote') -> integer(). whapp_count(Whapp, Arg) when not is_atom(Arg) -> whapp_count(Whapp, kz_term:to_atom(Arg, 'true')); whapp_count(Whapp, 'false') -> @@ -210,7 +210,7 @@ whapp_count(Whapp, Unhandled) -> lager:debug("invalid parameters ~p ~p", [Whapp, Unhandled]), 0. --spec determine_whapp_count(ne_binary(), ets:match_spec()) -> non_neg_integer(). +-spec determine_whapp_count(kz_term:ne_binary(), ets:match_spec()) -> non_neg_integer(). determine_whapp_count(Whapp, MatchSpec) -> lists:foldl(fun(Whapps, Acc) when is_list(Whapps) -> determine_whapp_count_fold(Whapps, Acc, Whapp) @@ -219,14 +219,14 @@ determine_whapp_count(Whapp, MatchSpec) -> ,ets:select(?MODULE, MatchSpec) ). --spec determine_whapp_count_fold(kapps_info(), non_neg_integer(), ne_binary()) -> non_neg_integer(). +-spec determine_whapp_count_fold(kz_types:kapps_info(), non_neg_integer(), kz_term:ne_binary()) -> non_neg_integer(). determine_whapp_count_fold(Whapps, Acc, Whapp) -> case props:is_defined(Whapp, Whapps) of 'true' -> Acc + 1; 'false' -> Acc end. --spec whapp_zones(text()) -> list(). +-spec whapp_zones(kz_term:text()) -> list(). whapp_zones(Whapp) -> MatchSpec = [{#kz_node{kapps='$1' ,zone='$2' @@ -237,7 +237,7 @@ whapp_zones(Whapp) -> }], determine_whapp_zones(kz_term:to_binary(Whapp), MatchSpec). --spec determine_whapp_zones(ne_binary(), ets:match_spec()) -> list(). +-spec determine_whapp_zones(kz_term:ne_binary(), ets:match_spec()) -> list(). determine_whapp_zones(Whapp, MatchSpec) -> {Whapp, Zones, _} = lists:foldl(fun determine_whapp_zones_fold/2 @@ -246,13 +246,13 @@ determine_whapp_zones(Whapp, MatchSpec) -> ), Zones. --spec whapp_zone_count(text()) -> integer(). +-spec whapp_zone_count(kz_term:text()) -> integer(). whapp_zone_count(Whapp) -> length(whapp_zones(Whapp)). -type fold_zones_acc() :: {atom(), list(), non_neg_integer()}. --spec determine_whapp_zones_fold({atom(), kapps_info()}, fold_zones_acc()) -> fold_zones_acc(). +-spec determine_whapp_zones_fold({atom(), kz_types:kapps_info()}, fold_zones_acc()) -> fold_zones_acc(). determine_whapp_zones_fold({Zone, Whapps}, {Whapp, Zones, C}=Acc) -> case props:is_defined(Whapp, Whapps) andalso not lists:member(Zone, Zones) @@ -272,16 +272,16 @@ status() -> 'no_return' end. --spec compare_nodes(kz_node(), kz_node()) -> boolean(). +-spec compare_nodes(kz_types:kz_node(), kz_types:kz_node()) -> boolean(). compare_nodes(#kz_node{node = N1}, #kz_node{node = N2}) -> N1 > N2. --spec print_status(kz_nodes(), atom()) -> 'no_return'. +-spec print_status(kz_types:kz_nodes(), atom()) -> 'no_return'. print_status(Nodes, Zone) -> F = fun (Node) -> print_node_status(Node, Zone) end, lists:foreach(F, Nodes), 'no_return'. --spec print_node_status(kz_node(), atom()) -> 'ok'. +-spec print_node_status(kz_types:kz_node(), atom()) -> 'ok'. print_node_status(#kz_node{zone=NodeZone ,node=N ,md5=MD5 @@ -326,25 +326,25 @@ print_node_status(#kz_node{zone=NodeZone io:format("~n"). --spec maybe_print_md5(api_binary()) -> 'ok'. +-spec maybe_print_md5(kz_term:api_binary()) -> 'ok'. maybe_print_md5('undefined') -> 'ok'; maybe_print_md5(MD5) -> io:format(?SIMPLE_ROW_STR, [<<"md5">>, MD5]). --spec maybe_print_zone(ne_binary(), ne_binary()) -> 'ok'. +-spec maybe_print_zone(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. maybe_print_zone(Zone, Zone) when Zone =/= <<"local">> -> io:format(?SIMPLE_ROW_STR, [<<"Zone">>, <>]); maybe_print_zone(NodeZone, _Zone) -> io:format(?SIMPLE_ROW_STR, [<<"Zone">>, NodeZone]). --spec maybe_print_globals(kz_proplist()) -> 'ok'. +-spec maybe_print_globals(kz_term:proplist()) -> 'ok'. maybe_print_globals([]) -> 'ok'; maybe_print_globals(Globals) -> io:format(?HEADER_COL ++ ":", [<<"Globals">>]), lists:foreach(fun({K,V}) -> io:format(" ~s (~B)",[K, V]) end, Globals), io:format("~n"). --spec maybe_print_kapps(kz_proplist()) -> 'ok'. +-spec maybe_print_kapps(kz_term:proplist()) -> 'ok'. maybe_print_kapps(Whapps) -> case lists:sort(fun compare_apps/2, Whapps) of []-> 'ok'; @@ -356,7 +356,7 @@ maybe_print_kapps(Whapps) -> -spec compare_apps({binary(), any()}, {binary(), any()}) -> boolean(). compare_apps({K1,_}, {K2,_}) -> K1 < K2. --spec maybe_print_roles(kz_proplist()) -> 'ok'. +-spec maybe_print_roles(kz_term:proplist()) -> 'ok'. maybe_print_roles(Roles) -> case lists:sort(fun compare_apps/2, Roles) of []-> 'ok'; @@ -366,7 +366,7 @@ maybe_print_roles(Roles) -> lists:foreach(fun print_role/1, SortedRoles) end. --spec print_role({ne_binary(), kz_json:object()}) -> 'ok'. +-spec print_role({kz_term:ne_binary(), kz_json:object()}) -> 'ok'. print_role({<<"Dispatcher">>, Data}) -> Groups = kz_json:get_json_value(<<"Groups">>, Data, kz_json:new()), Keys = lists:sort(kz_json:get_keys(Groups)), @@ -380,7 +380,7 @@ print_role({<<"Registrar">>, Data}) -> io:format(?SIMPLE_ROW_NUM, [<<"Registrations">>, kz_json:get_integer_value(<<"Registrations">>, Data, 0)]); print_role(_) -> 'ok'. --spec print_dispatcher({ne_binary(), kz_json:object()}) -> 'ok'. +-spec print_dispatcher({kz_term:ne_binary(), kz_json:object()}) -> 'ok'. print_dispatcher({Group, Data})-> io:format(?HEADER_COL ": ", [<<"Dispatcher ", Group/binary>>]), Sets = kz_json:get_keys(Data), @@ -391,20 +391,20 @@ print_dispatcher({Group, Data})-> end, Sets), simple_list(M, 0). --spec print_presence({ne_binary(), kz_json:object()}) -> 'ok'. +-spec print_presence({kz_term:ne_binary(), kz_json:object()}) -> 'ok'. print_presence({Group, Data}) -> io:format(?HEADER_COL ": ", [Group]), simple_list(format_presence_data(Data)). --spec format_presence_data(kz_json:object()) -> ne_binaries(). +-spec format_presence_data(kz_json:object()) -> kz_term:ne_binaries(). format_presence_data(Data) -> kz_json:foldl(fun format_presence_data/3, [], Data). --spec format_presence_data(ne_binary(), term(), ne_binaries()) -> ne_binaries(). +-spec format_presence_data(kz_term:ne_binary(), term(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). format_presence_data(K, V, Acc) -> [<> | Acc]. --spec maybe_print_media_servers(kz_node()) -> 'ok'. +-spec maybe_print_media_servers(kz_types:kz_node()) -> 'ok'. maybe_print_media_servers(#kz_node{media_servers=MediaServers ,registrations=Registrations ,channels=Channels @@ -422,11 +422,11 @@ maybe_print_media_servers(#kz_node{media_servers=MediaServers lists:foreach(fun print_media_server/1, Servers) end. --spec print_media_server(media_server()) -> 'ok'. +-spec print_media_server(kz_types:media_server()) -> 'ok'. print_media_server(Server) -> print_media_server(Server, ?MEDIA_SERVERS_LINE). --spec print_media_server(media_server(), string()) -> 'ok'. +-spec print_media_server(kz_types:media_server(), string()) -> 'ok'. print_media_server({Name, JObj}, Format) -> io:format(lists:flatten([Format, ?MEDIA_SERVERS_DETAIL, "~n"]) ,[Name @@ -435,7 +435,7 @@ print_media_server({Name, JObj}, Format) -> ) ]). --spec maybe_print_node_info(api_object()) -> 'ok'. +-spec maybe_print_node_info(kz_term:api_object()) -> 'ok'. maybe_print_node_info('undefined') -> 'ok'; maybe_print_node_info(NodeInfo) -> io:format(?HEADER_COL ++ ": ", [<<"Node Info">>]), @@ -443,18 +443,18 @@ maybe_print_node_info(NodeInfo) -> print_node_info(First), lists:foreach(fun print_each_node_info/1, Rest). --spec print_each_node_info({ne_binary(), ne_binary() | integer()}) -> 'ok'. +-spec print_each_node_info({kz_term:ne_binary(), kz_term:ne_binary() | integer()}) -> 'ok'. print_each_node_info(KV) -> io:format(?HEADER_COL " ", [<<>>]), print_node_info(KV). --spec print_node_info({ne_binary(), ne_binary() | integer()}) -> 'ok'. +-spec print_node_info({kz_term:ne_binary(), kz_term:ne_binary() | integer()}) -> 'ok'. print_node_info({K, ?NE_BINARY = V}) -> io:format("~s: ~s~n", [K, V]); print_node_info({K, V}) when is_integer(V) -> io:format("~s: ~B~n", [K, V]). --spec status_list(kapps_info(), 0..4) -> 'ok'. +-spec status_list(kz_types:kapps_info(), 0..4) -> 'ok'. status_list([], _) -> io:format("~n", []); status_list(Whapps, Column) when Column > 3 -> io:format("~n" ++ ?HEADER_COL ++ " ", [""]), @@ -474,8 +474,8 @@ status_list([{Whapp, #whapp_info{startup=Started,roles=Roles}}|Whapps], _Column) io:format("~s", [kz_binary:join(Roles, <<" , ">>)]), status_list(Whapps, 4). --spec simple_list(ne_binaries()) -> 'ok'. --spec simple_list(ne_binaries(), 0..5) -> 'ok'. +-spec simple_list(kz_term:ne_binaries()) -> 'ok'. +-spec simple_list(kz_term:ne_binaries(), 0..5) -> 'ok'. simple_list(List) -> simple_list(List, 0). @@ -507,7 +507,7 @@ notify_expire() -> notify_expire(Pid) -> gen_listener:cast(?SERVER, {'notify_expire', Pid}). --spec handle_advertise(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_advertise(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_advertise(JObj, Props) -> 'true' = kapi_nodes:advertise_v(JObj), @@ -576,7 +576,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), nodes_state()) -> handle_call_ret_state(nodes_state()). +-spec handle_call(any(), kz_term:pid_ref(), nodes_state()) -> kz_types:handle_call_ret_state(nodes_state()). handle_call({'print_status', Nodes}, _From, State) -> print_status(Nodes, State), {'reply', 'ok', State}; @@ -595,7 +595,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), nodes_state()) -> handle_cast_ret_state(nodes_state()). +-spec handle_cast(any(), nodes_state()) -> kz_types:handle_cast_ret_state(nodes_state()). handle_cast({'notify_new', Pid}, #state{notify_new=Set}=State) -> _ = erlang:monitor('process', Pid), {'noreply', State#state{notify_new=sets:add_element(Pid, Set)}}; @@ -631,7 +631,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), nodes_state()) -> handle_info_ret_state(nodes_state()). +-spec handle_info(any(), nodes_state()) -> kz_types:handle_info_ret_state(nodes_state()). handle_info('expire_nodes', #state{node=ThisNode, tab=Tab}=State) -> Now = kz_time:now_ms(), FindSpec = [{#kz_node{node='$1' @@ -754,7 +754,7 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec create_node('undefined' | 5000..15000, nodes_state()) -> kz_node(). +-spec create_node('undefined' | 5000..15000, nodes_state()) -> kz_types:kz_node(). create_node(Heartbeat, #state{zone=Zone ,version=Version ,md5=MD5 @@ -771,11 +771,11 @@ create_node(Heartbeat, #state{zone=Zone ,node_info=node_info() }). --spec normalize_amqp_uri(ne_binary()) -> ne_binary(). +-spec normalize_amqp_uri(kz_term:ne_binary()) -> kz_term:ne_binary(). normalize_amqp_uri(URI) -> kz_term:to_binary(amqp_uri:remove_credentials(kz_term:to_list(URI))). --spec add_kapps_data(kz_node()) -> kz_node(). +-spec add_kapps_data(kz_types:kz_node()) -> kz_types:kz_node(). add_kapps_data(Node) -> lists:foldl(fun kapp_data/2, Node, kapps_controller:list_apps()). @@ -784,7 +784,7 @@ request(Acc) -> App = props:get_value('app', Acc), [{'info', get_whapp_info(App)} | Acc]. --spec kapp_data(atom(), kz_node()) -> kz_node(). +-spec kapp_data(atom(), kz_types:kz_node()) -> kz_types:kz_node(). kapp_data(App, Node) -> kapp_data(App, Node, kz_nodes_bindings:request(App)). @@ -804,12 +804,12 @@ kapp_data(App ,registrations=props:get_integer_value('registrations', RequestAcc, 0) + Registrations }. --spec maybe_add_info(atom(), 'undefined' | whapp_info(), kapps_info()) -> kapps_info(). +-spec maybe_add_info(atom(), 'undefined' | kz_types:whapp_info(), kz_types:kapps_info()) -> kz_types:kapps_info(). maybe_add_info(_App, 'undefined', Kapps) -> Kapps; maybe_add_info(App, AppInfo, Kapps) -> [{kz_term:to_binary(App), AppInfo} | Kapps]. --spec get_whapp_info(atom() | pid() | kz_proplist() | 'undefined') -> whapp_info(). +-spec get_whapp_info(atom() | pid() | kz_term:proplist() | 'undefined') -> kz_types:whapp_info(). get_whapp_info('undefined') -> #whapp_info{}; get_whapp_info(Whapp) when is_atom(Whapp) -> try @@ -833,14 +833,14 @@ get_whapp_info(_Arg) -> lager:debug("can't get info for ~p", [_Arg]), #whapp_info{}. --spec get_whapp_process_info(kz_proplist() | 'undefined') -> whapp_info(). +-spec get_whapp_process_info(kz_term:proplist() | 'undefined') -> kz_types:whapp_info(). get_whapp_process_info('undefined') -> #whapp_info{}; get_whapp_process_info([]) -> #whapp_info{}; get_whapp_process_info(PInfo) -> Startup = props:get_value('$startup', props:get_value('dictionary', PInfo, [])), #whapp_info{startup=Startup}. --spec advertise_payload(kz_node()) -> kz_proplist(). +-spec advertise_payload(kz_types:kz_node()) -> kz_term:proplist(). advertise_payload(#kz_node{expires=Expires ,kapps=Whapps ,media_servers=MediaServers @@ -873,18 +873,18 @@ advertise_payload(#kz_node{expires=Expires | kz_api:default_headers(?APP_NAME, ?APP_VERSION) ]). --spec media_servers_to_json(media_servers()) -> kz_json:object(). +-spec media_servers_to_json(kz_types:media_servers()) -> kz_json:object(). media_servers_to_json([]) -> 'undefined'; media_servers_to_json(Servers) -> kz_json:from_list(Servers). --spec media_servers_from_json(kz_json:object()) -> media_servers(). +-spec media_servers_from_json(kz_json:object()) -> kz_types:media_servers(). media_servers_from_json(Servers) -> [{Key, kz_json:get_value(Key, Servers)} || Key <- kz_json:get_keys(Servers) ]. --spec from_json(kz_json:object(), nodes_state()) -> kz_node(). +-spec from_json(kz_json:object(), nodes_state()) -> kz_types:kz_node(). from_json(JObj, State) -> Node = kz_json:get_value(<<"Node">>, JObj), #kz_node{node=kz_term:to_atom(Node, 'true') @@ -906,10 +906,10 @@ from_json(JObj, State) -> ,roles=kz_json:to_proplist(kz_json:get_json_value(<<"Roles">>, JObj, kz_json:new())) }. --spec kapps_from_json(api_terms()) -> kapps_info(). --spec whapp_from_json(binary(), kz_json:object()) -> {binary(), whapp_info()}. --spec whapp_info_from_json(ne_binary(), kz_json:object()) -> whapp_info(). --spec whapp_info_from_json(ne_binary(), whapp_info(), {kz_json:json_terms(), kz_json:keys()}) -> whapp_info(). +-spec kapps_from_json(kz_term:api_terms()) -> kz_types:kapps_info(). +-spec whapp_from_json(binary(), kz_json:object()) -> {binary(), kz_types:whapp_info()}. +-spec whapp_info_from_json(kz_term:ne_binary(), kz_json:object()) -> kz_types:whapp_info(). +-spec whapp_info_from_json(kz_term:ne_binary(), kz_types:whapp_info(), {kz_json:json_terms(), kz_json:keys()}) -> kz_types:whapp_info(). kapps_from_json(Whapps) when is_list(Whapps) -> [{Whapp, #whapp_info{}} || Whapp <- Whapps]; @@ -933,9 +933,9 @@ whapp_info_from_json(Key, Info, {[V | V1], [<<"Startup">> | K1]}) -> whapp_info_from_json(Key, Info, {[_V | V1], [_K | K1]}) -> whapp_info_from_json(Key, Info, {V1, K1}). --spec kapps_to_json(kapps_info()) -> kz_json:object(). --spec whapp_to_json({ne_binary(), whapp_info()}) -> {ne_binary(), kz_json:object()}. --spec whapp_info_to_json(whapp_info()) -> kz_json:object(). +-spec kapps_to_json(kz_types:kapps_info()) -> kz_json:object(). +-spec whapp_to_json({kz_term:ne_binary(), kz_types:whapp_info()}) -> {kz_term:ne_binary(), kz_json:object()}. +-spec whapp_info_to_json(kz_types:whapp_info()) -> kz_json:object(). kapps_to_json(Whapps) -> List = [whapp_to_json(Whapp) || Whapp <- Whapps], @@ -975,14 +975,14 @@ get_zone(JObj, #state{zones=Zones, zone=LocalZone}) -> -spec local_zone() -> atom(). local_zone() -> kz_config:zone(). --spec get_amqp_broker(api_binary() | kz_json:object()) -> api_binary(). +-spec get_amqp_broker(kz_term:api_binary() | kz_json:object()) -> kz_term:api_binary(). get_amqp_broker('undefined') -> normalize_amqp_uri(kz_amqp_connections:primary_broker()); get_amqp_broker(Broker) when is_binary(Broker) -> normalize_amqp_uri(Broker); get_amqp_broker(JObj) -> get_amqp_broker(kz_json:get_ne_value(<<"AMQP-Broker">>, JObj)). --spec notify_expire(kz_nodes(), nodes_state() | pids()) -> 'ok'. +-spec notify_expire(kz_types:kz_nodes(), nodes_state() | kz_term:pids()) -> 'ok'. notify_expire([], _) -> 'ok'; notify_expire(_, []) -> 'ok'; notify_expire(Nodes, #state{notify_expire=Set}) -> @@ -994,7 +994,7 @@ notify_expire([#kz_node{node=NodeName}=Node|Nodes], Pids) -> ], notify_expire(Nodes, Pids). --spec notify_new(kz_node(), nodes_state() | pids()) -> 'ok'. +-spec notify_new(kz_types:kz_node(), nodes_state() | kz_term:pids()) -> 'ok'. notify_new(Node, #state{notify_new=Set}) -> notify_new(Node, sets:to_list(Set)); notify_new(#kz_node{node=NodeName}=Node, Pids) -> @@ -1004,11 +1004,11 @@ notify_new(#kz_node{node=NodeName}=Node, Pids) -> ], 'ok'. --spec whapp_oldest_node(text()) -> api_integer(). +-spec whapp_oldest_node(kz_term:text()) -> kz_term:api_integer(). whapp_oldest_node(Whapp) -> whapp_oldest_node(Whapp, 'false'). --spec whapp_oldest_node(text(), text() | boolean() | atom()) -> api_integer(). +-spec whapp_oldest_node(kz_term:text(), kz_term:text() | boolean() | atom()) -> kz_term:api_integer(). whapp_oldest_node(Whapp, Federated) when is_binary(Federated) -> whapp_oldest_node(Whapp, kz_term:is_true(Federated)); @@ -1036,7 +1036,7 @@ whapp_oldest_node(Whapp, Zone) }], determine_whapp_oldest_node(kz_term:to_binary(Whapp), MatchSpec). --spec determine_whapp_oldest_node(ne_binary(), ets:match_spec()) -> +-spec determine_whapp_oldest_node(kz_term:ne_binary(), ets:match_spec()) -> 'undefined' | node(). determine_whapp_oldest_node(Whapp, MatchSpec) -> case oldest_whapp_node(Whapp, MatchSpec) of @@ -1045,9 +1045,9 @@ determine_whapp_oldest_node(Whapp, MatchSpec) -> end. -type oldest_whapp_node() :: 'undefined' | - {node(), gregorian_seconds()}. + {node(), kz_time:gregorian_seconds()}. --spec oldest_whapp_node(ne_binary(), ets:match_spec()) -> +-spec oldest_whapp_node(kz_term:ne_binary(), ets:match_spec()) -> oldest_whapp_node(). oldest_whapp_node(Whapp, MatchSpec) -> lists:foldl(fun({Whapps, _Node}=Info, Acc) when is_list(Whapps) -> @@ -1057,7 +1057,7 @@ oldest_whapp_node(Whapp, MatchSpec) -> ,ets:select(?MODULE, MatchSpec) ). --spec determine_whapp_oldest_node_fold({kapps_info(), node()}, oldest_whapp_node(), ne_binary()) -> +-spec determine_whapp_oldest_node_fold({kz_types:kapps_info(), node()}, oldest_whapp_node(), kz_term:ne_binary()) -> oldest_whapp_node(). determine_whapp_oldest_node_fold({Whapps, Node}, 'undefined', Whapp) -> case props:get_value(Whapp, Whapps) of @@ -1073,7 +1073,7 @@ determine_whapp_oldest_node_fold({Whapps, Node}, {_, Startup}=Acc, Whapp) -> _ -> Acc end. --spec maybe_add_zone(kz_node(), nodes_state()) -> nodes_state(). +-spec maybe_add_zone(kz_types:kz_node(), nodes_state()) -> nodes_state(). maybe_add_zone(#kz_node{zone='undefined'}, #state{}=State) -> State; maybe_add_zone(#kz_node{zone=Zone, broker=B}, #state{zones=Zones}=State) -> Broker = normalize_amqp_uri(B), @@ -1086,12 +1086,12 @@ maybe_add_zone(#kz_node{zone=Zone, broker=B}, #state{zones=Zones}=State) -> node_info() -> kz_json:from_list(pool_states()). --spec pool_states() -> kz_proplist(). +-spec pool_states() -> kz_term:proplist(). pool_states() -> lists:keysort(1, [pool_state(Pool) || {Pool, _Pid} <- kz_amqp_sup:pools()]). --spec pool_state(atom()) -> {ne_binary(), ne_binary()}. --spec pool_state(atom(), atom(), integer(), integer(), integer()) -> {ne_binary(), ne_binary()}. +-spec pool_state(atom()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. +-spec pool_state(atom(), atom(), integer(), integer(), integer()) -> {kz_term:ne_binary(), kz_term:ne_binary()}. pool_state(Name) -> {PoolState, Workers, OverFlow, Monitors} = poolboy:status(Name), pool_state(Name, PoolState, Workers, OverFlow, Monitors). @@ -1103,7 +1103,7 @@ pool_state(Name, State, Workers, Overflow, Monitors) -> ) }. --spec node_encoded() -> ne_binary(). +-spec node_encoded() -> kz_term:ne_binary(). node_encoded() -> case application:get_env(?APP_NAME_ATOM, 'node_encoded') of 'undefined' -> @@ -1113,11 +1113,11 @@ node_encoded() -> {'ok', Encoded} -> Encoded end. --spec whapp_role_count(text(), text()) -> integer(). +-spec whapp_role_count(kz_term:text(), kz_term:text()) -> integer(). whapp_role_count(Whapp, Role) -> whapp_role_count(Whapp, Role, 'false'). --spec whapp_role_count(text(), text(), text() | boolean() | 'remote') -> integer(). +-spec whapp_role_count(kz_term:text(), kz_term:text(), kz_term:text() | boolean() | 'remote') -> integer(). whapp_role_count(Whapp, Role, Arg) when not is_atom(Arg) -> whapp_role_count(Whapp, Role, kz_term:to_atom(Arg, 'true')); whapp_role_count(Whapp, Role, 'false') -> @@ -1154,7 +1154,7 @@ whapp_role_count(Whapp, Role, Unhandled) -> lager:debug("invalid parameters ~p , ~p , ~p", [Whapp, Role, Unhandled]), 0. --spec determine_whapp_role_count(ne_binary(), ne_binary(), ets:match_spec()) -> non_neg_integer(). +-spec determine_whapp_role_count(kz_term:ne_binary(), kz_term:ne_binary(), ets:match_spec()) -> non_neg_integer(). determine_whapp_role_count(Whapp, Role, MatchSpec) -> lists:foldl(fun(Whapps, Acc) when is_list(Whapps) -> determine_whapp_role_count_fold(Whapps, Role, Acc, Whapp) @@ -1163,7 +1163,7 @@ determine_whapp_role_count(Whapp, Role, MatchSpec) -> ,ets:select(?MODULE, MatchSpec) ). --spec determine_whapp_role_count_fold(kapps_info(), ne_binary(), non_neg_integer(), ne_binary()) -> non_neg_integer(). +-spec determine_whapp_role_count_fold(kz_types:kapps_info(), kz_term:ne_binary(), non_neg_integer(), kz_term:ne_binary()) -> non_neg_integer(). determine_whapp_role_count_fold(Whapps, Role, Acc, Whapp) -> case props:is_defined(Whapp, Whapps) andalso lists:member(Role, (props:get_value(Whapp, Whapps))#whapp_info.roles) @@ -1172,11 +1172,11 @@ determine_whapp_role_count_fold(Whapps, Role, Acc, Whapp) -> 'false' -> Acc end. --spec node_role_count(text()) -> integer(). +-spec node_role_count(kz_term:text()) -> integer(). node_role_count(Role) -> node_role_count(Role, 'false'). --spec node_role_count(text(), text() | boolean() | 'remote') -> integer(). +-spec node_role_count(kz_term:text(), kz_term:text() | boolean() | 'remote') -> integer(). node_role_count(Role, Arg) when not is_atom(Arg) -> node_role_count(Role, kz_term:to_atom(Arg, 'true')); node_role_count(Role, 'false') -> @@ -1213,7 +1213,7 @@ node_role_count(Role, Unhandled) -> lager:debug("invalid parameters ~p , ~p , ~p", [Role, Unhandled]), 0. --spec determine_node_role_count(ne_binary(), ets:match_spec()) -> non_neg_integer(). +-spec determine_node_role_count(kz_term:ne_binary(), ets:match_spec()) -> non_neg_integer(). determine_node_role_count(Role, MatchSpec) -> lists:foldl(fun(Roles, Acc) when is_list(Roles) -> determine_node_role_count_fold(Roles, Acc, Role) @@ -1222,7 +1222,7 @@ determine_node_role_count(Role, MatchSpec) -> ,ets:select(?MODULE, MatchSpec) ). --spec determine_node_role_count_fold(kz_proplist(), non_neg_integer(), ne_binary()) -> non_neg_integer(). +-spec determine_node_role_count_fold(kz_term:proplist(), non_neg_integer(), kz_term:ne_binary()) -> non_neg_integer(). determine_node_role_count_fold(Roles, Acc, Role) -> case props:is_defined(Role, Roles) of 'true' -> Acc + 1; diff --git a/core/kazoo_ips/src/kazoo_ips_maintenance.erl b/core/kazoo_ips/src/kazoo_ips_maintenance.erl index 3547d1bb750..99855908f6f 100644 --- a/core/kazoo_ips/src/kazoo_ips_maintenance.erl +++ b/core/kazoo_ips/src/kazoo_ips_maintenance.erl @@ -48,7 +48,7 @@ add() -> io:format("Please use: sup kazoo_ips_maintenance add ~n", []), 'no_return'. --spec add(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec add(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. add(IPAddress, Zone, Host) -> case kz_ip:create(IPAddress, Zone, Host) of {'ok', _IP} -> @@ -70,7 +70,7 @@ assign() -> io:format("Please use: sup kazoo_ips_maintenance assign ~n", []), 'no_return'. --spec assign(ne_binary(), ne_binary()) -> 'no_return'. +-spec assign(kz_term:ne_binary(), kz_term:ne_binary()) -> 'no_return'. assign(IP, Account) -> case kz_account:fetch(Account) of {'ok', _} -> do_assignment(Account, IP); @@ -79,7 +79,7 @@ assign(IP, Account) -> end, 'no_return'. --spec do_assignment(ne_binary(), ne_binary()) -> 'ok'. +-spec do_assignment(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. do_assignment(Account, IP) -> case kz_ip:assign(Account, IP) of {'ok', _} -> @@ -99,7 +99,7 @@ release() -> io:format("Please use: sup kazoo_ips_maintenance release ~n", []), 'no_return'. --spec release(ne_binary()) -> 'no_return'. +-spec release(kz_term:ne_binary()) -> 'no_return'. release(IP) -> _ = case kz_ip:release(IP) of {'ok', _} -> @@ -120,7 +120,7 @@ delete() -> io:format("Please use: sup kazoo_ips_maintenance delete ~n", []), 'no_return'. --spec delete(ne_binary()) -> 'no_return'. +-spec delete(kz_term:ne_binary()) -> 'no_return'. delete(IP) -> _ = case kz_ip:delete(IP) of {'ok', _} -> @@ -139,7 +139,7 @@ delete(IP) -> -spec summary() -> 'no_return'. summary() -> summary('undefined'). --spec summary(api_binary()) -> 'no_return'. +-spec summary(kz_term:api_binary()) -> 'no_return'. summary(Host) -> _ = case kz_ips:summary(Host) of {'ok', []} -> diff --git a/core/kazoo_ips/src/kz_ip.erl b/core/kazoo_ips/src/kz_ip.erl index 74a60f5d83d..0619686aee4 100644 --- a/core/kazoo_ips/src/kz_ip.erl +++ b/core/kazoo_ips/src/kz_ip.erl @@ -53,7 +53,7 @@ from_json(JObj) -> JObj. %% %% @end %%-------------------------------------------------------------------- --spec create(ne_binary(), ne_binary(), ne_binary()) -> +-spec create(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', ip()} | {'error', any()}. create(IP, Zone, Host) -> @@ -90,7 +90,7 @@ create(IP, Zone, Host) -> %% %% @end %%-------------------------------------------------------------------- --spec fetch(ne_binary()) -> +-spec fetch(kz_term:ne_binary()) -> {'ok', ip()} | {'error', any()}. fetch(IP) -> @@ -109,7 +109,7 @@ fetch(IP) -> %% %% @end %%-------------------------------------------------------------------- --spec assign(ne_binary(), ne_binary() | ip()) -> +-spec assign(kz_term:ne_binary(), kz_term:ne_binary() | ip()) -> {'ok', ip()} | {'error', any()}. assign(Account, <<_/binary>> = RawIP) -> @@ -138,7 +138,7 @@ assign(Account, IPDoc) -> %% %% @end %%-------------------------------------------------------------------- --spec release(ne_binary() | ip()) -> +-spec release(kz_term:ne_binary() | ip()) -> {'ok', ip()} | {'error', any()}. release(<<_/binary>> = Ip) -> @@ -161,7 +161,7 @@ release(IP) -> %% %% @end %%-------------------------------------------------------------------- --spec delete(ne_binary() | ip()) -> +-spec delete(kz_term:ne_binary() | ip()) -> {'ok', ip()} | {'error', any()}. delete(<<_/binary>> = IP) -> @@ -179,7 +179,7 @@ delete(IP) -> %% %% @end %%-------------------------------------------------------------------- --spec ip(ip()) -> ne_binary(). +-spec ip(ip()) -> kz_term:ne_binary(). ip(IP) -> kz_doc:id(IP). %%-------------------------------------------------------------------- @@ -188,7 +188,7 @@ ip(IP) -> kz_doc:id(IP). %% %% @end %%-------------------------------------------------------------------- --spec zone(ip()) -> ne_binary(). +-spec zone(ip()) -> kz_term:ne_binary(). zone(IP) -> kz_json:get_value(<<"pvt_zone">>, IP). %%-------------------------------------------------------------------- @@ -197,7 +197,7 @@ zone(IP) -> kz_json:get_value(<<"pvt_zone">>, IP). %% %% @end %%-------------------------------------------------------------------- --spec modified(ip()) -> api_integer(). +-spec modified(ip()) -> kz_term:api_integer(). modified(IP) -> kz_doc:modified(IP). %%-------------------------------------------------------------------- @@ -206,7 +206,7 @@ modified(IP) -> kz_doc:modified(IP). %% %% @end %%-------------------------------------------------------------------- --spec created(ip()) -> api_integer(). +-spec created(ip()) -> kz_term:api_integer(). created(IP) -> kz_doc:created(IP). %%-------------------------------------------------------------------- @@ -215,7 +215,7 @@ created(IP) -> kz_doc:created(IP). %% %% @end %%-------------------------------------------------------------------- --spec host(ip()) -> ne_binary(). +-spec host(ip()) -> kz_term:ne_binary(). host(IP) -> kz_json:get_value(<<"pvt_host">>, IP). %%-------------------------------------------------------------------- @@ -224,7 +224,7 @@ host(IP) -> kz_json:get_value(<<"pvt_host">>, IP). %% %% @end %%-------------------------------------------------------------------- --spec assigned_to(ip()) -> ne_binary(). +-spec assigned_to(ip()) -> kz_term:ne_binary(). assigned_to(IP) -> kz_json:get_value(<<"pvt_assigned_to">>, IP). %%-------------------------------------------------------------------- @@ -243,7 +243,7 @@ is_dedicated_ip(IP) -> %% %% @end %%-------------------------------------------------------------------- --spec is_available(ip() | ne_binary()) -> boolean() | {'error', any()}. +-spec is_available(ip() | kz_term:ne_binary()) -> boolean() | {'error', any()}. is_available(Ip) when is_binary(Ip) -> case fetch(Ip) of {'ok', IP} -> is_available(IP); diff --git a/core/kazoo_ips/src/kz_ips.erl b/core/kazoo_ips/src/kz_ips.erl index 853d1a77f59..06969317035 100644 --- a/core/kazoo_ips/src/kz_ips.erl +++ b/core/kazoo_ips/src/kz_ips.erl @@ -26,7 +26,7 @@ %%-------------------------------------------------------------------- -spec available() -> {'ok', kz_json:objects()} | {'error', any()}. --spec available(api_binary()) -> +-spec available(kz_term:api_binary()) -> {'ok', kz_json:objects()} | {'error', any()}. @@ -34,7 +34,7 @@ available() -> available('undefined'). available(Zone) -> available(Zone, 1). --spec available(api_binary(), non_neg_integer()) -> +-spec available(kz_term:api_binary(), non_neg_integer()) -> {'ok', kz_json:objects()} | {'error', any()}. available(Zone, Quantity) -> @@ -63,7 +63,7 @@ available(Zone, Quantity) -> %% %% @end %%-------------------------------------------------------------------- --spec assigned(ne_binary()) -> +-spec assigned(kz_term:ne_binary()) -> {'ok', kz_json:objects()} | {'error', any()}. assigned(Account) -> @@ -88,7 +88,7 @@ sort_assigned(IPs) -> ZoneName = get_zone_name(), sort_assigned(kz_term:shuffle_list(IPs), ZoneName, []). --spec sort_assigned(kz_json:objects(), ne_binary(), kz_json:objects()) -> kz_json:objects(). +-spec sort_assigned(kz_json:objects(), kz_term:ne_binary(), kz_json:objects()) -> kz_json:objects(). sort_assigned([], _, Sorted) -> Sorted; sort_assigned([IP|IPs], ZoneName, Sorted) -> case kz_json:get_value(<<"zone">>, IP) =:= ZoneName of @@ -96,7 +96,7 @@ sort_assigned([IP|IPs], ZoneName, Sorted) -> 'false' -> sort_assigned(IPs, ZoneName, Sorted ++ [IP]) end. --spec get_zone_name() -> ne_binary(). +-spec get_zone_name() -> kz_term:ne_binary(). get_zone_name() -> LocalZone = kz_term:to_binary(kz_nodes:local_zone()), NameMap = kapps_config:get_json(?CONFIG_CAT, <<"zone_name_map">>, kz_json:new()), @@ -109,7 +109,7 @@ get_zone_name() -> %% @end %%-------------------------------------------------------------------- -spec zones() -> - {'ok', ne_binaries()} | + {'ok', kz_term:ne_binaries()} | {'error', any()}. zones() -> ViewOptions = ['group' @@ -138,7 +138,7 @@ zones() -> %% @end %%-------------------------------------------------------------------- -spec hosts() -> - {'ok', ne_binaries()} | + {'ok', kz_term:ne_binaries()} | {'error', any()}. hosts() -> ViewOptions = ['group' @@ -166,7 +166,7 @@ hosts() -> %% %% @end %%-------------------------------------------------------------------- --spec summary(api_binary()) -> +-spec summary(kz_term:api_binary()) -> {'ok', kz_json:objects()} | {'error', any()}. summary(Host) -> diff --git a/core/kazoo_ledgers/src/kazoo_ledger.erl b/core/kazoo_ledgers/src/kazoo_ledger.erl index 24ca7b0f15c..2f513c2a040 100644 --- a/core/kazoo_ledgers/src/kazoo_ledger.erl +++ b/core/kazoo_ledgers/src/kazoo_ledger.erl @@ -56,7 +56,7 @@ save(Ledger) -> LedgerId = account_id(Ledger), save(Ledger, LedgerId). --spec save(ledger(), ne_binary()) -> {'ok', ledger()} | {'error', any()}. +-spec save(ledger(), kz_term:ne_binary()) -> {'ok', ledger()} | {'error', any()}. save(Ledger, LedgerId) -> Props = [{<<"pvt_type">>, ?PVT_TYPE} ,{<<"pvt_modified">>, kz_time:now_s()} @@ -65,7 +65,7 @@ save(Ledger, LedgerId) -> ], kazoo_modb:save_doc(LedgerId, kz_json:set_values(Props, Ledger)). --spec maybe_add_id(ledger()) -> kz_proplist(). +-spec maybe_add_id(ledger()) -> kz_term:proplist(). maybe_add_id(Ledger) -> case kz_doc:id(Ledger) of 'undefined' -> @@ -80,7 +80,7 @@ maybe_add_id(Ledger) -> _ -> [] end. --spec create_hash(ledger()) -> ne_binary(). +-spec create_hash(ledger()) -> kz_term:ne_binary(). create_hash(Ledger) -> Props = [{<<"source">>, source(Ledger)} ,{<<"account">>, account(Ledger)} @@ -96,11 +96,11 @@ create_hash(Ledger) -> %% %% @end %%-------------------------------------------------------------------- --spec type(ledger()) -> ne_binary(). +-spec type(ledger()) -> kz_term:ne_binary(). type(Ledger) -> kz_json:get_ne_binary_value(?PVT_LEDGER_TYPE, Ledger). --spec set_type(ledger(), ne_binary()) -> ledger(). +-spec set_type(ledger(), kz_term:ne_binary()) -> ledger(). set_type(L, Type) -> kz_json:set_value(?PVT_LEDGER_TYPE, Type, L). @@ -124,11 +124,11 @@ set_amount(L, Amount) -> %% %% @end %%-------------------------------------------------------------------- --spec description(ledger()) -> ne_binary(). +-spec description(ledger()) -> kz_term:ne_binary(). description(Ledger) -> kz_json:get_ne_binary_value(?DESC, Ledger). --spec set_description(ledger(), ne_binary()) -> ledger(). +-spec set_description(ledger(), kz_term:ne_binary()) -> ledger(). set_description(L, Desc) -> kz_json:set_value(?DESC, Desc, L). @@ -148,11 +148,11 @@ source(Ledger) -> %% %% @end %%-------------------------------------------------------------------- --spec source_service(ledger()) -> ne_binary(). +-spec source_service(ledger()) -> kz_term:ne_binary(). source_service(Ledger) -> kz_json:get_ne_binary_value(?SRC_SERVICE, Ledger). --spec set_source_service(ledger(), ne_binary()) -> ledger(). +-spec set_source_service(ledger(), kz_term:ne_binary()) -> ledger(). set_source_service(L, Service) -> kz_json:set_value(?SRC_SERVICE, Service, L). @@ -162,11 +162,11 @@ set_source_service(L, Service) -> %% %% @end %%-------------------------------------------------------------------- --spec source_id(ledger()) -> ne_binary(). +-spec source_id(ledger()) -> kz_term:ne_binary(). source_id(Ledger) -> kz_json:get_ne_binary_value(?SRC_ID, Ledger). --spec set_source_id(ledger(), ne_binary()) -> ledger(). +-spec set_source_id(ledger(), kz_term:ne_binary()) -> ledger(). set_source_id(L, Id) -> kz_json:set_value(?SRC_ID, Id, L). @@ -186,11 +186,11 @@ usage(Ledger) -> %% %% @end %%-------------------------------------------------------------------- --spec usage_type(ledger()) -> ne_binary(). +-spec usage_type(ledger()) -> kz_term:ne_binary(). usage_type(Ledger) -> kz_json:get_ne_binary_value(?USAGE_TYPE, Ledger). --spec set_usage_type(ledger(), ne_binary()) -> ledger(). +-spec set_usage_type(ledger(), kz_term:ne_binary()) -> ledger(). set_usage_type(L, Type) -> kz_json:set_value(?USAGE_TYPE, Type, L). @@ -214,11 +214,11 @@ set_usage_quantity(L, Quantity) -> %% %% @end %%-------------------------------------------------------------------- --spec usage_unit(ledger()) -> ne_binary(). +-spec usage_unit(ledger()) -> kz_term:ne_binary(). usage_unit(Ledger) -> kz_json:get_ne_binary_value(?USAGE_UNIT, Ledger). --spec set_usage_unit(ledger(), ne_binary()) -> ledger(). +-spec set_usage_unit(ledger(), kz_term:ne_binary()) -> ledger(). set_usage_unit(L, Unit) -> kz_json:set_value(?USAGE_UNIT, Unit, L). @@ -276,11 +276,11 @@ account(Ledger) -> %% %% @end %%-------------------------------------------------------------------- --spec account_id(ledger()) -> ne_binary(). +-spec account_id(ledger()) -> kz_term:ne_binary(). account_id(Ledger) -> kz_json:get_ne_binary_value(?ACCOUNT_ID, Ledger). --spec set_account_id(ledger(), ne_binary()) -> ledger(). +-spec set_account_id(ledger(), kz_term:ne_binary()) -> ledger(). set_account_id(L, Start) -> kz_json:set_value(?ACCOUNT_ID, Start, L). @@ -290,11 +290,11 @@ set_account_id(L, Start) -> %% %% @end %%-------------------------------------------------------------------- --spec account_name(ledger()) -> ne_binary(). +-spec account_name(ledger()) -> kz_term:ne_binary(). account_name(Ledger) -> kz_json:get_ne_binary_value(?ACCOUNT_NAME, Ledger). --spec set_account_name(ledger(), ne_binary()) -> ledger(). +-spec set_account_name(ledger(), kz_term:ne_binary()) -> ledger(). set_account_name(L, End) -> kz_json:set_value(?ACCOUNT_NAME, End, L). @@ -308,7 +308,7 @@ set_account_name(L, End) -> metadata(Ledger) -> kz_json:get_value(?METADATA, Ledger). --spec metadata(ledger(), ne_binary() | ne_binaries()) -> ledger(). +-spec metadata(ledger(), kz_term:ne_binary() | kz_term:ne_binaries()) -> ledger(). metadata(Ledger, Key) when is_binary(Key)-> kz_json:get_value(?METADATA_KEY(Key), Ledger); @@ -316,14 +316,14 @@ metadata(Ledger, Keys) when is_list(Keys)-> kz_json:get_value(?METADATA_KEYS(Keys), Ledger). --spec set_metadata(ledger(), kz_json:object() | kz_proplist()) -> ledger(). +-spec set_metadata(ledger(), kz_json:object() | kz_term:proplist()) -> ledger(). set_metadata(Ledger, List) when is_list(List) -> kz_json:set_values([{?METADATA_KEY(K), V} || {K,V} <- List], Ledger); set_metadata(Ledger, JObj) -> kz_json:set_value(?METADATA, JObj, Ledger). --spec set_metadata(ledger(), ne_binary(), kz_json:json_term()) -> ledger(). +-spec set_metadata(ledger(), kz_term:ne_binary(), kz_json:json_term()) -> ledger(). set_metadata(Ledger, Key, Value) -> kz_json:set_value(?METADATA_KEY(Key), Value, Ledger). diff --git a/core/kazoo_ledgers/src/kz_ledger.erl b/core/kazoo_ledgers/src/kz_ledger.erl index d9c772a2d35..6d2344b2d21 100644 --- a/core/kazoo_ledgers/src/kz_ledger.erl +++ b/core/kazoo_ledgers/src/kz_ledger.erl @@ -26,7 +26,7 @@ %% %% @end %%-------------------------------------------------------------------- --spec get(ne_binary(), ne_binary()) -> +-spec get(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', integer()} | {'error', any()}. get(Account, Name) -> @@ -49,22 +49,22 @@ get(Account, Name) -> credit(Ledger) -> credit(kazoo_ledger:account_id(Ledger), Ledger). --spec credit(ne_binary(), ledger()) -> save_return(). +-spec credit(kz_term:ne_binary(), ledger()) -> save_return(). credit(LedgerId, Ledger) -> create(LedgerId, ?CREDIT, Ledger). --spec credit(ne_binary(), ne_binary() - ,ne_binary(), kz_proplist()) -> save_return(). +-spec credit(kz_term:ne_binary(), kz_term:ne_binary() + ,kz_term:ne_binary(), kz_term:proplist()) -> save_return(). credit(LedgerId, SrcService, SrcId, Usage) -> credit(LedgerId, SrcService, SrcId, Usage, []). --spec credit(ne_binary(), ne_binary(), ne_binary() - ,kz_proplist(), kz_proplist()) -> save_return(). +-spec credit(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary() + ,kz_term:proplist(), kz_term:proplist()) -> save_return(). credit(LedgerId, SrcService, SrcId, Usage, Props) -> credit(LedgerId, SrcService, SrcId, Usage, Props, LedgerId). --spec credit(ne_binary(), ne_binary(), ne_binary() - ,kz_proplist(), kz_proplist(), ne_binary()) -> save_return(). +-spec credit(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary() + ,kz_term:proplist(), kz_term:proplist(), kz_term:ne_binary()) -> save_return(). credit(LedgerId, SrcService, SrcId, Usage, Props, AccountId) -> create(LedgerId, ?CREDIT, SrcService, SrcId, Usage, Props, AccountId). @@ -78,22 +78,22 @@ credit(LedgerId, SrcService, SrcId, Usage, Props, AccountId) -> debit(Ledger) -> debit(kazoo_ledger:account_id(Ledger), Ledger). --spec debit(ne_binary(), ledger()) -> save_return(). +-spec debit(kz_term:ne_binary(), ledger()) -> save_return(). debit(LedgerId, Ledger) -> create(LedgerId, ?DEBIT, Ledger). --spec debit(ne_binary(), ne_binary() - ,ne_binary(), kz_proplist()) -> save_return(). +-spec debit(kz_term:ne_binary(), kz_term:ne_binary() + ,kz_term:ne_binary(), kz_term:proplist()) -> save_return(). debit(LedgerId, SrcService, SrcId, Usage) -> debit(LedgerId, SrcService, SrcId, Usage, []). --spec debit(ne_binary(), ne_binary(), ne_binary() - ,kz_proplist(), kz_proplist()) -> save_return(). +-spec debit(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary() + ,kz_term:proplist(), kz_term:proplist()) -> save_return(). debit(LedgerId, SrcService, SrcId, Usage, Props) -> debit(LedgerId, SrcService, SrcId, Usage, Props, LedgerId). --spec debit(ne_binary(), ne_binary(), ne_binary() - ,kz_proplist(), kz_proplist(), ne_binary()) -> save_return(). +-spec debit(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary() + ,kz_term:proplist(), kz_term:proplist(), kz_term:ne_binary()) -> save_return(). debit(LedgerId, SrcService, SrcId, Usage, Props, AccountId) -> create(LedgerId, ?DEBIT, SrcService, SrcId, Usage, Props, AccountId). @@ -107,8 +107,8 @@ debit(LedgerId, SrcService, SrcId, Usage, Props, AccountId) -> %% %% @end %%-------------------------------------------------------------------- --spec create(ne_binary(), ne_binary(), ne_binary(), ne_binary() - ,kz_proplist(), kz_proplist(),ne_binary()) -> save_return(). +-spec create(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary() + ,kz_term:proplist(), kz_term:proplist(),kz_term:ne_binary()) -> save_return(). create(LedgerId, Type, SrcService, SrcId, Usage, Props, AccountId) -> Routines = [{fun kazoo_ledger:set_source_service/2, SrcService} ,{fun kazoo_ledger:set_source_id/2, SrcId} @@ -118,7 +118,7 @@ create(LedgerId, Type, SrcService, SrcId, Usage, Props, AccountId) -> ], create(LedgerId, Type, lists:foldl(fun apply_routine/2, kazoo_ledger:new(), Routines)). --spec create(ne_binary(), ne_binary(), ledger()) -> save_return(). +-spec create(kz_term:ne_binary(), kz_term:ne_binary(), ledger()) -> save_return(). create(LedgerId, Type, Ledger) -> Routines = [{fun kazoo_ledger:set_type/2, Type} ,{fun kazoo_ledger:save/2, LedgerId} @@ -131,7 +131,7 @@ create(LedgerId, Type, Ledger) -> %% %% @end %%-------------------------------------------------------------------- --spec set_account(ledger(), ne_binary()) -> ledger(). +-spec set_account(ledger(), kz_term:ne_binary()) -> ledger(). set_account(Ledger, Account) -> AccountId = kz_util:format_account_id(Account, 'raw'), Routines = [{fun kazoo_ledger:set_account_id/2, AccountId} @@ -145,7 +145,7 @@ set_account(Ledger, Account) -> %% %% @end %%-------------------------------------------------------------------- --spec set_usage(ledger(), kz_proplist()) -> ledger(). +-spec set_usage(ledger(), kz_term:proplist()) -> ledger(). set_usage(Ledger, []) -> Ledger; set_usage(Ledger, [{<<"type">>, Val}|Usage]) -> set_usage(kazoo_ledger:set_usage_type(Ledger, Val), Usage); @@ -162,7 +162,7 @@ set_usage(Ledger, [_|Usage]) -> %% %% @end %%-------------------------------------------------------------------- --spec set_extra(ledger(), kz_proplist()) -> ledger(). +-spec set_extra(ledger(), kz_term:proplist()) -> ledger(). set_extra(Ledger, []) -> Ledger; set_extra(Ledger, [{<<"amount">>, Val}|Props]) -> set_extra(kazoo_ledger:set_amount(Ledger, Val), Props); diff --git a/core/kazoo_ledgers/src/kz_ledgers.erl b/core/kazoo_ledgers/src/kz_ledgers.erl index d0a1be61d19..6ef8e12f1cf 100644 --- a/core/kazoo_ledgers/src/kz_ledgers.erl +++ b/core/kazoo_ledgers/src/kz_ledgers.erl @@ -28,10 +28,10 @@ %% %% @end %%-------------------------------------------------------------------- --spec get(ne_binary()) -> {'ok', kz_json:object()} | - {'error', atom()}. --spec get(ne_binary(), api_seconds(), api_seconds()) -> {'ok', kz_json:object()} | - {'error', atom()}. +-spec get(kz_term:ne_binary()) -> {'ok', kz_json:object()} | + {'error', atom()}. +-spec get(kz_term:ne_binary(), kz_time:api_seconds(), kz_time:api_seconds()) -> {'ok', kz_json:object()} | + {'error', atom()}. get(Account) -> get(Account, undefined, undefined). @@ -70,6 +70,6 @@ get(Account, CreatedFrom, CreatedTo) throw:_R -> {error, _R} end. --spec available_ledgers(api_binary()) -> kz_json:objects(). +-spec available_ledgers(kz_term:api_binary()) -> kz_json:objects(). available_ledgers(AccountId) -> kapps_account_config:get_global(AccountId, <<"ledgers">>, <<"registered_ledgers">>, ?DEFAULT_AVIALABLE_LEDGERS). diff --git a/core/kazoo_maintenance/src/kapps_config_maint_listener.erl b/core/kazoo_maintenance/src/kapps_config_maint_listener.erl index cfd21114efc..aa10338aa15 100644 --- a/core/kazoo_maintenance/src/kapps_config_maint_listener.erl +++ b/core/kazoo_maintenance/src/kapps_config_maint_listener.erl @@ -47,7 +47,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER ,[{'bindings', ?BINDINGS} @@ -60,7 +60,7 @@ start_link() -> ,[] ). --spec handle_req(kapi_maintenance:req(), kz_proplist()) -> 'ok'. +-spec handle_req(kapi_maintenance:req(), kz_term:proplist()) -> 'ok'. handle_req(MaintJObj, _Props) -> 'true' = kapi_maintenance:req_v(MaintJObj), @@ -86,7 +86,7 @@ send_resp(MaintJObj, Created) -> code('true') -> 200; code('false') -> 500. --spec message(boolean()) -> ne_binary(). +-spec message(boolean()) -> kz_term:ne_binary(). message('true') -> <<"Created ", (?KZ_CONFIG_DB)/binary>>; message('false') -> <<"Did not create ", (?KZ_CONFIG_DB)/binary>>. @@ -117,7 +117,7 @@ init([]) -> %% {stop, Reason, Reply, State} | %% {stop, Reason, State} %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -128,7 +128,7 @@ handle_call(_Request, _From, State) -> %% {noreply, State, Timeout} | %% {stop, Reason, State} %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _QueueNAme}}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'is_consuming', _IsConsuming}}, State) -> @@ -143,7 +143,7 @@ handle_cast(_Msg, State) -> %% {noreply, State, Timeout} | %% {stop, Reason, State} %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -152,7 +152,7 @@ handle_info(_Info, State) -> %% @doc Allows listener to pass options to handlers %% @spec handle_event(JObj, State) -> {reply, Options} %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. @@ -200,7 +200,7 @@ cleanup_invalid_notify_docs([JObj|JObjs]) -> _ = maybe_remove_invalid_notify_doc(kz_doc:type(Doc), Id, Doc), cleanup_invalid_notify_docs(JObjs). --spec maybe_remove_invalid_notify_doc(ne_binary(), ne_binary(), kz_json:object()) -> 'ok'. +-spec maybe_remove_invalid_notify_doc(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> 'ok'. maybe_remove_invalid_notify_doc(<<"notification">>, <<"notification", _/binary>>, _) -> 'ok'; maybe_remove_invalid_notify_doc(<<"notification">>, _, JObj) -> _ = kz_datamgr:del_doc(?KZ_CONFIG_DB, JObj), @@ -217,7 +217,7 @@ delete_system_media_references() -> {'error', 'not_found'} -> 'ok' end. --spec delete_system_media_references(ne_binary(), kz_json:object()) -> 'ok'. +-spec delete_system_media_references(kz_term:ne_binary(), kz_json:object()) -> 'ok'. delete_system_media_references(DocId, CallResponsesDoc) -> TheKey = <<"default">>, Default = kz_json:get_value(TheKey, CallResponsesDoc), @@ -281,7 +281,7 @@ deprecate_timezone_for_default_timezone(Nodes, AccountsConfig) -> -spec deprecate_timezone_for_node(kz_json:key(), kz_json:object()) -> kz_json:object(). --spec deprecate_timezone_for_node(kz_json:key(), kz_json:object(), api_ne_binary(), api_ne_binary()) -> +-spec deprecate_timezone_for_node(kz_json:key(), kz_json:object(), kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> kz_json:object(). deprecate_timezone_for_node(Node, AccountsConfig) -> Timezone = kz_json:get_value([Node, <<"timezone">>], AccountsConfig), diff --git a/core/kazoo_maintenance/src/kazoo_maintenance_app.erl b/core/kazoo_maintenance/src/kazoo_maintenance_app.erl index 59383ed070d..61195f47ce5 100644 --- a/core/kazoo_maintenance/src/kazoo_maintenance_app.erl +++ b/core/kazoo_maintenance/src/kazoo_maintenance_app.erl @@ -21,7 +21,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_StartType, _StartArgs) -> kapi_maintenance:declare_exchanges(), kazoo_maintenance_sup:start_link(). diff --git a/core/kazoo_maintenance/src/kazoo_maintenance_sup.erl b/core/kazoo_maintenance/src/kazoo_maintenance_sup.erl index afcc1e1e315..2741bfab630 100644 --- a/core/kazoo_maintenance/src/kazoo_maintenance_sup.erl +++ b/core/kazoo_maintenance/src/kazoo_maintenance_sup.erl @@ -29,7 +29,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -46,7 +46,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 25, diff --git a/core/kazoo_maintenance/src/kazoo_oauth_maint_listener.erl b/core/kazoo_maintenance/src/kazoo_oauth_maint_listener.erl index f45545db341..643e040ff15 100644 --- a/core/kazoo_maintenance/src/kazoo_oauth_maint_listener.erl +++ b/core/kazoo_maintenance/src/kazoo_oauth_maint_listener.erl @@ -48,7 +48,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER ,[{'bindings', ?BINDINGS} @@ -61,7 +61,7 @@ start_link() -> ,[] ). --spec handle_req(kapi_maintenance:req(), kz_proplist()) -> 'ok'. +-spec handle_req(kapi_maintenance:req(), kz_term:proplist()) -> 'ok'. handle_req(MaintJObj, _Props) -> 'true' = kapi_maintenance:req_v(MaintJObj), Created = kz_datamgr:db_create(?KZ_OAUTH_DB), @@ -81,7 +81,7 @@ send_resp(MaintJObj, Created) -> code('true') -> 200; code('false') -> 500. --spec message(boolean()) -> ne_binary(). +-spec message(boolean()) -> kz_term:ne_binary(). message('true') -> <<"Created ", (?KZ_OAUTH_DB)/binary>>; message('false') -> <<"Did not create ", (?KZ_OAUTH_DB)/binary>>. @@ -112,7 +112,7 @@ init([]) -> %% {stop, Reason, Reply, State} | %% {stop, Reason, State} %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -123,7 +123,7 @@ handle_call(_Request, _From, State) -> %% {noreply, State, Timeout} | %% {stop, Reason, State} %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _QueueNAme}}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'is_consuming', _IsConsuming}}, State) -> @@ -138,7 +138,7 @@ handle_cast(_Msg, State) -> %% {noreply, State, Timeout} | %% {stop, Reason, State} %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -147,7 +147,7 @@ handle_info(_Info, State) -> %% @doc Allows listener to pass options to handlers %% @spec handle_event(JObj, State) -> {reply, Options} %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/core/kazoo_maintenance/src/skel_maint_listener.erl b/core/kazoo_maintenance/src/skel_maint_listener.erl index 4f3c9ef0f0b..2719e02b18f 100644 --- a/core/kazoo_maintenance/src/skel_maint_listener.erl +++ b/core/kazoo_maintenance/src/skel_maint_listener.erl @@ -48,7 +48,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link(?SERVER ,[{'bindings', ?BINDINGS} @@ -61,7 +61,7 @@ start_link() -> ,[] ). --spec handle_req(kapi_maintenance:req(), kz_proplist()) -> 'ok'. +-spec handle_req(kapi_maintenance:req(), kz_term:proplist()) -> 'ok'. handle_req(MaintJObj, _Props) -> 'true' = kapi_maintenance:req_v(MaintJObj), send_resp(MaintJObj). @@ -102,7 +102,7 @@ init([]) -> %% {stop, Reason, Reply, State} | %% {stop, Reason, State} %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call(_Request, _From, State) -> {'reply', {'error', 'not_implemented'}, State}. @@ -113,7 +113,7 @@ handle_call(_Request, _From, State) -> %% {noreply, State, Timeout} | %% {stop, Reason, State} %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener', {'created_queue', _QueueNAme}}, State) -> {'noreply', State}; handle_cast({'gen_listener', {'is_consuming', _IsConsuming}}, State) -> @@ -128,7 +128,7 @@ handle_cast(_Msg, State) -> %% {noreply, State, Timeout} | %% {stop, Reason, State} %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State}. @@ -137,7 +137,7 @@ handle_info(_Info, State) -> %% @doc Allows listener to pass options to handlers %% @spec handle_event(JObj, State) -> {reply, Options} %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. diff --git a/core/kazoo_media/src/kazoo_media.hrl b/core/kazoo_media/src/kazoo_media.hrl index 7755dd9585f..5551088eeb3 100644 --- a/core/kazoo_media/src/kazoo_media.hrl +++ b/core/kazoo_media/src/kazoo_media.hrl @@ -49,10 +49,10 @@ ,{<<"record_min_sec">>, 0} ]). --record(media_store_path, {db :: ne_binary() - ,id :: ne_binary() - ,att :: ne_binary() - ,opt = [] :: kz_proplist() +-record(media_store_path, {db :: kz_term:ne_binary() + ,id :: kz_term:ne_binary() + ,att :: kz_term:ne_binary() + ,opt = [] :: kz_term:proplist() }). -type media_store_path() :: #media_store_path{}. diff --git a/core/kazoo_media/src/kazoo_media_app.erl b/core/kazoo_media/src/kazoo_media_app.erl index 5ffdf2c28e8..68166aed007 100644 --- a/core/kazoo_media/src/kazoo_media_app.erl +++ b/core/kazoo_media/src/kazoo_media_app.erl @@ -17,7 +17,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> kazoo_media_sup:start_link(). diff --git a/core/kazoo_media/src/kazoo_media_init.erl b/core/kazoo_media/src/kazoo_media_init.erl index 5cf310b9070..ff688bf9a9b 100644 --- a/core/kazoo_media/src/kazoo_media_init.erl +++ b/core/kazoo_media/src/kazoo_media_init.erl @@ -16,7 +16,7 @@ %% @public %% @doc Starts the app for inclusion in a supervisor tree %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> case kapps_config:get_is_true(?CONFIG_CAT, <<"fix_media_names">>, 'true') of 'true' -> diff --git a/core/kazoo_media/src/kazoo_media_maintenance.erl b/core/kazoo_media/src/kazoo_media_maintenance.erl index a4d238e894c..c1371186785 100644 --- a/core/kazoo_media/src/kazoo_media_maintenance.erl +++ b/core/kazoo_media/src/kazoo_media_maintenance.erl @@ -35,7 +35,7 @@ migrate_prompts() -> io:format("Now updating existing system_media docs to be internationalizable!~n", []), 'no_return'. --spec set_account_language(ne_binary(), ne_binary()) -> 'ok'. +-spec set_account_language(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. set_account_language(Account, Language) -> AccountId = kz_util:format_account_id(Account, 'raw'), OldLang = kz_media_util:prompt_language(AccountId), @@ -55,7 +55,7 @@ set_account_language(Account, Language) -> end. -spec import_prompts(file:filename_all()) -> 'ok'. --spec import_prompts(file:filename_all(), text()) -> 'ok'. +-spec import_prompts(file:filename_all(), kz_term:text()) -> 'ok'. import_prompts(DirPath) -> import_prompts(DirPath, kz_media_util:default_prompt_language()). @@ -72,7 +72,7 @@ import_prompts(DirPath, Lang) -> end end. --spec import_files(file:filename_all(), ne_binary(), [file:filename_all()]) -> 'ok'. +-spec import_files(file:filename_all(), kz_term:ne_binary(), [file:filename_all()]) -> 'ok'. import_files(Path, Lang, Files) -> io:format("importing prompts from '~s' with language '~s'~n", [Path, Lang]), case import_prompts_from_files(Files, Lang) of @@ -83,7 +83,7 @@ import_files(Path, Lang, Files) -> 'ok' end. --spec import_prompts_from_files([file:filename_all()], ne_binary()) -> +-spec import_prompts_from_files([file:filename_all()], kz_term:ne_binary()) -> [{file:filename_all(), {'error', _}}]. import_prompts_from_files(Files, Lang) -> [{File, Err} @@ -92,8 +92,8 @@ import_prompts_from_files(Files, Lang) -> ]. -spec import_prompt(file:filename_all()) -> 'ok' | {'error', any()}. --spec import_prompt(file:filename_all(), text()) -> 'ok' | {'error', any()}. --spec import_prompt(file:filename_all(), text(), ne_binary()) -> 'ok' | {'error', any()}. +-spec import_prompt(file:filename_all(), kz_term:text()) -> 'ok' | {'error', any()}. +-spec import_prompt(file:filename_all(), kz_term:text(), kz_term:ne_binary()) -> 'ok' | {'error', any()}. import_prompt(Path) -> import_prompt(Path, kz_media_util:default_prompt_language()). @@ -138,7 +138,7 @@ import_prompt(Path0, Lang0, Contents) -> Error end. --spec media_meta_doc(file:filename_all(), ne_binary(), pos_integer()) -> +-spec media_meta_doc(file:filename_all(), kz_term:ne_binary(), pos_integer()) -> kz_json:object(). media_meta_doc(Path, Lang, ContentLength) -> MediaDoc = base_media_doc(Path, Lang, ContentLength), @@ -149,7 +149,7 @@ media_meta_doc(Path, Lang, ContentLength) -> ] ). --spec base_media_doc(file:filename_all(), ne_binary(), pos_integer()) -> +-spec base_media_doc(file:filename_all(), kz_term:ne_binary(), pos_integer()) -> kz_json:object(). base_media_doc(Path, Lang, ContentLength) -> PromptName = prompt_name_from_path(Path), @@ -171,24 +171,24 @@ base_media_doc(Path, Lang, ContentLength) -> ] ). --spec prompt_name_from_path(file:filename_all()) -> ne_binary(). +-spec prompt_name_from_path(file:filename_all()) -> kz_term:ne_binary(). prompt_name_from_path(Path) -> Extension = filename:extension(Path), kz_term:to_binary(filename:basename(Path, Extension)). --spec content_type_from_path(file:filename_all()) -> ne_binary(). +-spec content_type_from_path(file:filename_all()) -> kz_term:ne_binary(). content_type_from_path(Path) -> {Category, Type, _} = cow_mimetypes:all(Path), filename:join([Category, Type]). --spec media_description(ne_binary(), ne_binary()) -> ne_binary(). +-spec media_description(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). media_description(PromptName, Lang) -> <<"System prompt in ", Lang/binary, " for ", PromptName/binary>>. --spec upload_prompt(ne_binary(), ne_binary(), ne_binary(), kz_proplist()) -> +-spec upload_prompt(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok' | {'error', any()}. --spec upload_prompt(ne_binary(), ne_binary(), ne_binary(), kz_proplist(), non_neg_integer()) -> +-spec upload_prompt(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist(), non_neg_integer()) -> 'ok' | {'error', any()}. upload_prompt(ID, AttachmentName, Contents, Options) -> @@ -209,7 +209,7 @@ upload_prompt(ID, AttachmentName, Contents, Options, Retries) -> maybe_cleanup_metadoc(ID, E) end. --spec maybe_cleanup_metadoc(ne_binary(), any()) -> {'error', any()}. +-spec maybe_cleanup_metadoc(kz_term:ne_binary(), any()) -> {'error', any()}. maybe_cleanup_metadoc(ID, E) -> io:format(" deleting metadata from ~s~n", [?KZ_MEDIA_DB]), case kz_datamgr:del_doc(?KZ_MEDIA_DB, ID) of @@ -221,7 +221,7 @@ maybe_cleanup_metadoc(ID, E) -> Error end. --spec maybe_retry_upload(ne_binary(), ne_binary(), ne_binary(), kz_proplist(), non_neg_integer()) -> +-spec maybe_retry_upload(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist(), non_neg_integer()) -> 'ok' | {'error', any()}. maybe_retry_upload(ID, AttachmentName, Contents, Options, Retries) -> @@ -253,8 +253,8 @@ refresh() -> ), 'ok'. --spec maybe_migrate_system_config(ne_binary()) -> 'ok'. --spec maybe_migrate_system_config(ne_binary(), boolean()) -> 'ok'. +-spec maybe_migrate_system_config(kz_term:ne_binary()) -> 'ok'. +-spec maybe_migrate_system_config(kz_term:ne_binary(), boolean()) -> 'ok'. maybe_migrate_system_config(ConfigId) -> maybe_migrate_system_config(ConfigId, 'false'). @@ -266,7 +266,7 @@ maybe_migrate_system_config(ConfigId, DeleteAfter) -> maybe_delete_system_config(ConfigId, DeleteAfter) end. --spec maybe_delete_system_config(ne_binary(), boolean()) -> 'ok'. +-spec maybe_delete_system_config(kz_term:ne_binary(), boolean()) -> 'ok'. maybe_delete_system_config(_ConfigId, 'false') -> 'ok'; maybe_delete_system_config(ConfigId, 'true') -> {'ok', _} = kz_datamgr:del_doc(?KZ_CONFIG_DB, ConfigId), @@ -292,7 +292,7 @@ get_media_config_doc() -> {'ok', kz_json:from_list([{<<"_id">>, ?CONFIG_CAT}])} end. --spec migrate_system_config_fold(ne_binary(), kz_json:json_term(), kz_json:object()) -> +-spec migrate_system_config_fold(kz_term:ne_binary(), kz_json:json_term(), kz_json:object()) -> kz_json:object(). migrate_system_config_fold(<<"default">> = Node, Settings, MediaJObj) -> io:format("migrating node '~s' settings~n", [Node]), @@ -307,7 +307,7 @@ migrate_system_config_fold(Node, Settings, MediaJObj) -> MediaJObj end. --spec migrate_node_config(ne_binary(), kz_json:object(), kz_json:object(), kz_proplist()) -> kz_json:object(). +-spec migrate_node_config(kz_term:ne_binary(), kz_json:object(), kz_json:object(), kz_term:proplist()) -> kz_json:object(). migrate_node_config(_Node, _Settings, MediaJObj, []) -> MediaJObj; migrate_node_config(Node, Settings, MediaJObj, [{K, V} | KVs]) -> case kz_json:get_value(K, Settings) of @@ -320,14 +320,14 @@ migrate_node_config(Node, Settings, MediaJObj, [{K, V} | KVs]) -> migrate_node_config(Node, Settings, set_node_value(Node, K, NodeV, MediaJObj), KVs) end. --spec set_node_value(ne_binary(), kz_json:path(), ne_binary(), kz_json:object()) -> +-spec set_node_value(kz_term:ne_binary(), kz_json:path(), kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). set_node_value(Node, <<_/binary>> = K, V, MediaJObj) -> set_node_value(Node, [K], V, MediaJObj); set_node_value(Node, K, V, MediaJObj) -> kz_json:set_value([Node | K], V, MediaJObj). --spec maybe_update_media_config(ne_binary(), kz_json:path(), api_binary(), kz_json:object()) -> +-spec maybe_update_media_config(kz_term:ne_binary(), kz_json:path(), kz_term:api_binary(), kz_json:object()) -> kz_json:object(). maybe_update_media_config(_Node, _K, 'undefined', MediaJObj) -> io:format(" no value to set for ~p~n", [_K]), @@ -366,12 +366,12 @@ remove_empty_system_media([JObj|JObjs]) -> 'false' -> remove_empty_system_media(JObjs) end. --spec remove_empty_media_docs(ne_binary()) -> 'ok'. +-spec remove_empty_media_docs(kz_term:ne_binary()) -> 'ok'. remove_empty_media_docs(AccountId) -> AccountDb = kz_util:format_account_id(AccountId, 'encoded'), remove_empty_media_docs(AccountId, AccountDb). --spec remove_empty_media_docs(ne_binary(), ne_binary()) -> 'ok'. +-spec remove_empty_media_docs(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. remove_empty_media_docs(AccountId, AccountDb) -> case kz_datamgr:get_results(AccountDb, <<"media/crossbar_listing">>, ['include_docs']) of {'ok', []} -> @@ -387,19 +387,19 @@ remove_empty_media_docs(AccountId, AccountDb) -> io:format("error looking up media docs in account ~s: ~p~n", [AccountId, _E]) end. --spec media_doc_filename(ne_binary(), non_neg_integer()) -> file:name(). +-spec media_doc_filename(kz_term:ne_binary(), non_neg_integer()) -> file:name(). media_doc_filename(AccountId, Timestamp) -> Path = ["/tmp/empty_media_", AccountId, "_", kz_term:to_binary(Timestamp), ".json"], binary_to_list(list_to_binary(Path)). --spec remove_empty_media_docs(ne_binary(), ne_binary(), file:io_device(), kz_json:objects()) -> 'ok'. +-spec remove_empty_media_docs(kz_term:ne_binary(), kz_term:ne_binary(), file:io_device(), kz_json:objects()) -> 'ok'. remove_empty_media_docs(AccountId, _AccountDb, _Filename, []) -> io:format("finished cleaning up empty media docs for account ~s~n", [AccountId]); remove_empty_media_docs(AccountId, AccountDb, File, [Media|MediaDocs]) -> maybe_remove_media_doc(AccountDb, File, kz_json:get_value(<<"doc">>, Media)), remove_empty_media_docs(AccountId, AccountDb, File, MediaDocs). --spec maybe_remove_media_doc(ne_binary(), file:io_device(), kz_json:object()) -> 'ok'. +-spec maybe_remove_media_doc(kz_term:ne_binary(), file:io_device(), kz_json:object()) -> 'ok'. maybe_remove_media_doc(AccountDb, File, MediaJObj) -> DocId = kz_doc:id(MediaJObj), case kz_doc:attachments(MediaJObj) of @@ -412,7 +412,7 @@ maybe_remove_media_doc(AccountDb, File, MediaJObj) -> io:format("media doc ~s has attachments, leaving alone~n", [kz_doc:id(MediaJObj)]) end. --spec remove_media_doc(ne_binary(), kz_json:object()) -> 'ok'. +-spec remove_media_doc(kz_term:ne_binary(), kz_json:object()) -> 'ok'. remove_media_doc(AccountDb, MediaJObj) -> {'ok', _Doc} = kz_datamgr:del_doc(AccountDb, MediaJObj), io:format("removed media doc ~s~n", [kz_doc:id(MediaJObj)]). diff --git a/core/kazoo_media/src/kazoo_media_sup.erl b/core/kazoo_media/src/kazoo_media_sup.erl index a093bb0adce..5bf84c2137a 100644 --- a/core/kazoo_media/src/kazoo_media_sup.erl +++ b/core/kazoo_media/src/kazoo_media_sup.erl @@ -38,7 +38,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -55,7 +55,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, diff --git a/core/kazoo_media/src/kz_media_cache_sup.erl b/core/kazoo_media/src/kz_media_cache_sup.erl index 2fbcdae3c17..cc7b8810ccd 100644 --- a/core/kazoo_media/src/kz_media_cache_sup.erl +++ b/core/kazoo_media/src/kz_media_cache_sup.erl @@ -33,11 +33,11 @@ %%-------------------------------------------------------------------- %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec find_file_server(ne_binary(), ne_binary(), ne_binary()) -> +-spec find_file_server(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', pid()} | {'error', 'no_file_server'}. find_file_server(Id, Doc, Attachment) -> @@ -47,7 +47,7 @@ find_file_server(Id, Doc, Attachment) -> [P] -> {'ok', P} end. --spec start_file_server(ne_binary(), ne_binary(), ne_binary()) -> +-spec start_file_server(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', pid()} | {'error', any()}. start_file_server(Id, Doc, Attachment) -> @@ -72,7 +72,7 @@ find_tts_server(Id) -> [P] -> {'ok', P} end. --spec find_tts_server(ne_binary(), kz_json:object()) -> +-spec find_tts_server(kz_term:ne_binary(), kz_json:object()) -> {'ok', pid()} | {'error', any()}. find_tts_server(Id, JObj) -> @@ -98,7 +98,7 @@ find_tts_server(Id, JObj) -> %% restart strategy, maximum restart frequency and child %% specifications. %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 10, diff --git a/core/kazoo_media/src/kz_media_config.erl b/core/kazoo_media/src/kz_media_config.erl index 70d23031971..daa23639e3b 100644 --- a/core/kazoo_media/src/kz_media_config.erl +++ b/core/kazoo_media/src/kz_media_config.erl @@ -12,14 +12,14 @@ record_min_sec() -> kapps_config:get_integer(?CONFIG_CAT, <<"record_min_sec">>, 0). --spec storage_retry_times(ne_binary()) -> pos_integer(). +-spec storage_retry_times(kz_term:ne_binary()) -> pos_integer(). storage_retry_times(AccountId) -> kapps_account_config:get_global(AccountId, ?CONFIG_CAT ,[<<"call_recording">>, <<"storage_retry_times">>] ,5 ). --spec call_recording_extension() -> ne_binary(). +-spec call_recording_extension() -> kz_term:ne_binary(). call_recording_extension() -> kapps_config:get_ne_binary(?CONFIG_CAT, [<<"call_recording">>, <<"extension">>], <<"mp3">>). diff --git a/core/kazoo_media/src/kz_media_doc.erl b/core/kazoo_media/src/kz_media_doc.erl index 50a923a8296..3b4bc275ad5 100644 --- a/core/kazoo_media/src/kz_media_doc.erl +++ b/core/kazoo_media/src/kz_media_doc.erl @@ -12,6 +12,6 @@ -include("kazoo_media.hrl"). --spec single_attachment_url(ne_binary(), ne_binary(), ne_binary()) -> ne_binary(). +-spec single_attachment_url(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). single_attachment_url(AccountDb, MediaId, AttachmentName) -> kz_datamgr:attachment_url(AccountDb, MediaId, AttachmentName). diff --git a/core/kazoo_media/src/kz_media_file.erl b/core/kazoo_media/src/kz_media_file.erl index a01e20d56f2..c180445d4c6 100644 --- a/core/kazoo_media/src/kz_media_file.erl +++ b/core/kazoo_media/src/kz_media_file.erl @@ -12,11 +12,11 @@ -include("kazoo_media.hrl"). --type build_uri_args() :: [ne_binary() | kz_proplist() | atom()]. --type build_uri() :: build_uri_args() | ne_binary() | media_store_path(). +-type build_uri_args() :: [kz_term:ne_binary() | kz_term:proplist() | atom()]. +-type build_uri() :: build_uri_args() | kz_term:ne_binary() | media_store_path(). -spec get_uri(build_uri(), kz_json:object()) -> - ne_binary() | + kz_term:ne_binary() | {'error', 'not_found'} | {'error', 'no_data'} | {'error', 'no_stream_strategy'}. @@ -35,7 +35,7 @@ get_uri(Paths, JObj) -> {'ok', #media_store_path{}=Store} -> maybe_proxy(JObj, Store) end. --spec maybe_prepare_proxy(ne_binary(), media_store_path()) -> 'ok' | 'error'. +-spec maybe_prepare_proxy(kz_term:ne_binary(), media_store_path()) -> 'ok' | 'error'. maybe_prepare_proxy(<<"single">>, Store) -> prepare_proxy(Store); maybe_prepare_proxy(<<"continuous">>, Store) -> prepare_proxy(Store); maybe_prepare_proxy(_, _ ) -> 'ok'. @@ -50,7 +50,7 @@ prepare_proxy(#media_store_path{db = Db 'false' -> lager:debug("existing file server for ~s/~s/~s", [Db, Id, Attachment]) end. --spec start_media_file_cache(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec start_media_file_cache(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. start_media_file_cache(Db, Id, Attachment) -> case kz_media_cache_sup:start_file_server(Db, Id, Attachment) of {'ok', _FileServer} -> @@ -61,7 +61,7 @@ start_media_file_cache(Db, Id, Attachment) -> end. -spec maybe_proxy(kz_json:object(), media_store_path()) -> - ne_binary() | {'error', 'no_stream_strategy'}. + kz_term:ne_binary() | {'error', 'no_stream_strategy'}. maybe_proxy(JObj, #media_store_path{db = Db ,id = Id ,att = Attachment @@ -76,7 +76,7 @@ maybe_proxy(JObj, #media_store_path{db = Db end. -spec proxy_uri(kz_json:object(), media_store_path()) -> - ne_binary() | {'error', 'no_stream_strategy'}. + kz_term:ne_binary() | {'error', 'no_stream_strategy'}. proxy_uri(JObj, #media_store_path{db = Db ,id = Id ,att = Attachment @@ -101,7 +101,7 @@ proxy_uri(JObj, #media_store_path{db = Db ,"/", File/binary >>. --spec find_attachment(build_uri_args() | ne_binary()) -> +-spec find_attachment(build_uri_args() | kz_term:ne_binary()) -> {'ok', media_store_path()} | {'error', 'not_found'}. find_attachment(Media) when is_binary(Media) -> @@ -152,11 +152,11 @@ find_attachment([Db, Id, Attachment, Options]) -> } }. --spec maybe_find_attachment(ne_binary(), ne_binary()) -> - {'ok', {ne_binary(), ne_binary(), ne_binary()}} | +-spec maybe_find_attachment(kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', {kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()}} | {'error', 'not_found' | 'no_data'}. --spec maybe_find_attachment(ne_binary(), ne_binary(), kz_json:object()) -> - {'ok', {ne_binary(), ne_binary(), ne_binary()}} | +-spec maybe_find_attachment(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> + {'ok', {kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()}} | {'error', 'not_found' | 'no_data'}. maybe_find_attachment(?MEDIA_DB = Db, Id) -> maybe_find_attachment_in_db(Db, Id); @@ -164,8 +164,8 @@ maybe_find_attachment(Db, Id) -> AccountDb = kz_util:format_account_id(Db, 'encoded'), maybe_find_attachment_in_db(AccountDb, Id). --spec maybe_find_attachment_in_db(ne_binary(), ne_binary()) -> - {'ok', {ne_binary(), ne_binary(), ne_binary()}} | +-spec maybe_find_attachment_in_db(kz_term:ne_binary(), kz_term:ne_binary()) -> + {'ok', {kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()}} | {'error', 'not_found' | 'no_data'}. maybe_find_attachment_in_db(Db, Id) -> case kz_datamgr:open_cache_doc(Db, Id, [{'cache_failures', ['not_found']}]) of diff --git a/core/kazoo_media/src/kz_media_file_cache.erl b/core/kazoo_media/src/kz_media_file_cache.erl index e472d16779e..554294e507d 100644 --- a/core/kazoo_media/src/kz_media_file_cache.erl +++ b/core/kazoo_media/src/kz_media_file_cache.erl @@ -32,9 +32,9 @@ -define(TIMEOUT_LIFETIME, 600 * ?MILLISECONDS_IN_SECOND). -define(TIMEOUT_MESSAGE, {'$kz_media_file_cache', 'file_timeout'}). --record(state, {db :: ne_binary() - ,doc :: ne_binary() - ,attach :: ne_binary() +-record(state, {db :: kz_term:ne_binary() + ,doc :: kz_term:ne_binary() + ,attach :: kz_term:ne_binary() ,meta :: kz_json:object() ,contents = <<>> :: binary() ,stream_ref :: reference() @@ -51,7 +51,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(ne_binary(), ne_binary(), ne_binary()) -> startlink_ret(). +-spec start_link(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_types:startlink_ret(). start_link(Db, Id, Attachment) -> gen_server:start_link(?SERVER, [Db, Id, Attachment, get('callid')], []). @@ -85,7 +85,7 @@ init([Db, Id, Attachment, CallId]) -> end, maybe_start_file_cache(Db, Id, Attachment). --spec maybe_start_file_cache(ne_binary(), ne_binary(), ne_binary()) -> +-spec maybe_start_file_cache(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'stop', _} | {'ok', state()}. maybe_start_file_cache(Db, Id, Attachment) -> @@ -126,7 +126,7 @@ maybe_start_file_cache(Db, Id, Attachment) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call('single', _From, #state{meta=Meta ,contents=Contents ,status='ready' @@ -165,7 +165,7 @@ handle_call('continuous', _From, #state{meta=Meta %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> {'noreply', State}. @@ -179,7 +179,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'timeout', TRef, ?TIMEOUT_MESSAGE}, #state{timer_ref=TRef}=State) -> lager:debug("timeout expired, going down"), {'stop', 'normal', State}; diff --git a/core/kazoo_media/src/kz_media_map.erl b/core/kazoo_media/src/kz_media_map.erl index 08918ecd8d9..417fed284a1 100644 --- a/core/kazoo_media/src/kz_media_map.erl +++ b/core/kazoo_media/src/kz_media_map.erl @@ -50,9 +50,9 @@ -define(QUEUE_OPTIONS, []). -define(CONSUME_OPTIONS, []). --record(media_map, {id :: ne_binary() %% account/prompt-id - ,account_id :: ne_binary() - ,prompt_id :: ne_binary() +-record(media_map, {id :: kz_term:ne_binary() %% account/prompt-id + ,account_id :: kz_term:ne_binary() + ,prompt_id :: kz_term:ne_binary() ,languages = kz_json:new() :: kz_json:object() %% {"lang1":"path1", "lang2":"path2"} }). -type media_map() :: #media_map{}. @@ -64,7 +64,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_listener:start_link({'local', ?SERVER} ,?MODULE @@ -81,7 +81,7 @@ start_link() -> flush() -> gen_listener:cast(?MODULE, 'flush'). --spec prompt_path(ne_binary(), ne_binary(), ne_binary()) -> api_binary(). +-spec prompt_path(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_binary(). prompt_path(AccountId, PromptId, L) -> Language = kz_term:to_lower_binary(L), #media_map{languages=Langs} = get_map(AccountId, PromptId), @@ -100,19 +100,19 @@ prompt_path(AccountId, PromptId, L) -> Path -> Path end. --spec default_prompt_path(ne_binary(), ne_binary()) -> api_binary(). +-spec default_prompt_path(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_binary(). default_prompt_path(PromptId, Language) -> #media_map{languages=Langs} = get_map(PromptId), lager:debug("checking default langs ~p", [default_language_keys(Language)]), kz_json:get_first_defined(default_language_keys(Language), Langs). --spec handle_media_doc(kz_json:object(), kz_proplist()) -> 'ok'. +-spec handle_media_doc(kz_json:object(), kz_term:proplist()) -> 'ok'. handle_media_doc(JObj, _Props) -> 'true' = kapi_conf:doc_update_v(JObj), handle_media_doc_change(JObj, kz_json:get_value(<<"Event-Name">>, JObj)). --spec handle_media_doc_change(kz_json:object(), ne_binary()) -> 'ok'. +-spec handle_media_doc_change(kz_json:object(), kz_term:ne_binary()) -> 'ok'. handle_media_doc_change(JObj, ?DOC_DELETED) -> MediaId = kz_json:get_value(<<"ID">>, JObj), PromptId = extract_prompt_id(MediaId), @@ -123,7 +123,7 @@ handle_media_doc_change(JObj, _Change) -> {'ok', Doc} = kz_datamgr:open_doc(Db, kz_json:get_value(<<"ID">>, JObj)), gen_listener:cast(?MODULE, {'add_mapping', Db, Doc}). --spec extract_prompt_id(ne_binary()) -> ne_binary(). +-spec extract_prompt_id(kz_term:ne_binary()) -> kz_term:ne_binary(). extract_prompt_id(<<_Lang:5/binary, "%2F", PromptId/binary>>) -> PromptId; extract_prompt_id(<<_Lang:2/binary, "%2F", PromptId/binary>>) -> @@ -134,7 +134,7 @@ extract_prompt_id(MediaId) -> -spec table_id() -> ?MODULE. table_id() -> ?MODULE. --spec table_options() -> kz_proplist(). +-spec table_options() -> kz_term:proplist(). table_options() -> ['set' ,'protected' @@ -142,7 +142,7 @@ table_options() -> ,'named_table' ]. --spec find_me_function() -> api_pid(). +-spec find_me_function() -> kz_term:api_pid(). find_me_function() -> whereis(?SERVER). -spec gift_data() -> 'ok'. @@ -181,7 +181,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call({'add_mapping', ?KZ_MEDIA_DB, JObj}, _From, State) -> _ = maybe_add_prompt(?KZ_MEDIA_DB, JObj), {'reply', 'ok', State}; @@ -213,7 +213,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('flush', State) -> ets:delete_all_objects(table_id()), lager:debug("flushed all media mappings"), @@ -252,7 +252,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'ETS-TRANSFER', _TableId, _From, _GiftData}, State) -> lager:debug("recv control of ~p from ~p", [_TableId, _From]), _ = kz_util:spawn(fun init_map/0), @@ -268,7 +268,7 @@ handle_info(_Info, State) -> %% @spec handle_event(JObj, State) -> {reply, Options} %% @end %%-------------------------------------------------------------------- --spec handle_event(kz_json:object(), kz_proplist()) -> gen_listener:handle_event_return(). +-spec handle_event(kz_json:object(), kz_term:proplist()) -> gen_listener:handle_event_return(). handle_event(_JObj, _State) -> {'reply', []}. @@ -303,9 +303,9 @@ code_change(_OldVsn, State, _Extra) -> %%% Internal functions %%%=================================================================== -spec init_map() -> 'ok'. --spec init_map(ne_binary()) -> 'ok'. --spec init_map(ne_binary(), ne_binary(), binary(), pos_integer(), fun()) -> 'ok'. --spec init_map(ne_binary(), ne_binary(), binary(), pos_integer(), fun(), kz_json:objects()) -> 'ok'. +-spec init_map(kz_term:ne_binary()) -> 'ok'. +-spec init_map(kz_term:ne_binary(), kz_term:ne_binary(), binary(), pos_integer(), fun()) -> 'ok'. +-spec init_map(kz_term:ne_binary(), kz_term:ne_binary(), binary(), pos_integer(), fun(), kz_json:objects()) -> 'ok'. init_map() -> init_map(?KZ_MEDIA_DB). @@ -339,8 +339,8 @@ init_map(Db, View, _StartKey, Limit, SendFun, ViewResults) -> lager:debug("added the last of the view results from ~s", [View]) end. --spec add_mapping(ne_binary(), fun(), kz_json:objects()) -> 'ok'. --spec add_mapping(ne_binary(), fun(), kz_json:objects(), pid()) -> 'ok'. +-spec add_mapping(kz_term:ne_binary(), fun(), kz_json:objects()) -> 'ok'. +-spec add_mapping(kz_term:ne_binary(), fun(), kz_json:objects(), pid()) -> 'ok'. add_mapping(Db, SendFun, JObjs) -> add_mapping(Db, SendFun, JObjs, whereis(?MODULE)). @@ -355,8 +355,8 @@ add_mapping(Db, SendFun, JObjs, Srv) -> _ = [SendFun(Srv, {'add_mapping', AccountId, kz_json:get_value(<<"doc">>, JObj)}) || JObj <- JObjs], 'ok'. --spec maybe_add_prompt(ne_binary(), kz_json:object()) -> 'ok'. --spec maybe_add_prompt(ne_binary(), kz_json:object(), api_binary()) -> 'ok'. +-spec maybe_add_prompt(kz_term:ne_binary(), kz_json:object()) -> 'ok'. +-spec maybe_add_prompt(kz_term:ne_binary(), kz_json:object(), kz_term:api_binary()) -> 'ok'. maybe_add_prompt(AccountId, JObj) -> maybe_add_prompt(AccountId ,JObj @@ -411,8 +411,8 @@ insert_map(Map, Srv) when Srv =:= self() -> insert_map(Map, Srv) -> gen_listener:call(Srv, {'insert_map', Map}). --spec get_map(ne_binary()) -> media_map(). --spec get_map(ne_binary(), ne_binary()) -> media_map(). +-spec get_map(kz_term:ne_binary()) -> media_map(). +-spec get_map(kz_term:ne_binary(), kz_term:ne_binary()) -> media_map(). get_map(PromptId) -> get_map(?KZ_MEDIA_DB, PromptId). @@ -437,7 +437,7 @@ get_map(AccountId, PromptId) -> [Map] -> Map end. --spec init_account_map(ne_binary(), ne_binary()) -> 'true'. +-spec init_account_map(kz_term:ne_binary(), kz_term:ne_binary()) -> 'true'. init_account_map(AccountId, PromptId) -> SystemMap = get_map(PromptId), MapId = mapping_id(AccountId, PromptId), @@ -457,7 +457,7 @@ new_map(Map, Srv) when Srv =:= self() -> new_map(Map, Srv) -> 'true' = gen_listener:call(Srv, {'new_map', Map}). --spec load_account_map(ne_binary(), ne_binary()) -> media_map(). +-spec load_account_map(kz_term:ne_binary(), kz_term:ne_binary()) -> media_map(). load_account_map(AccountId, PromptId) -> lager:debug("attempting to load account map for ~s/~s", [AccountId, PromptId]), @@ -480,9 +480,9 @@ load_account_map(AccountId, PromptId) -> end, get_map(AccountId, PromptId). --spec default_language_keys(ne_binary()) -> ne_binaries(). --spec language_keys(ne_binary()) -> ne_binaries(). --spec language_keys(ne_binary(), ne_binaries()) -> ne_binaries(). +-spec default_language_keys(kz_term:ne_binary()) -> kz_term:ne_binaries(). +-spec language_keys(kz_term:ne_binary()) -> kz_term:ne_binaries(). +-spec language_keys(kz_term:ne_binary(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). default_language_keys(Language) -> DefaultLanguage = kz_media_util:default_prompt_language(), language_keys(Language) ++ [DefaultLanguage]. @@ -499,7 +499,7 @@ language_keys(<> = Lang, Acc) -> language_keys(Lang, Acc) -> lists:reverse([Lang | Acc]). --spec mapping_id(ne_binary(), ne_binary()) -> ne_binary(). +-spec mapping_id(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). mapping_id(AccountId, PromptId) -> list_to_binary([AccountId, "/", PromptId]). diff --git a/core/kazoo_media/src/kz_media_proxy.erl b/core/kazoo_media/src/kz_media_proxy.erl index 3edeb00dd1c..be3c3a53183 100644 --- a/core/kazoo_media/src/kz_media_proxy.erl +++ b/core/kazoo_media/src/kz_media_proxy.erl @@ -14,7 +14,7 @@ -include("kazoo_media.hrl"). --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> kz_util:put_callid(?DEFAULT_LOG_SYSTEM_ID), diff --git a/core/kazoo_media/src/kz_media_proxy_util.erl b/core/kazoo_media/src/kz_media_proxy_util.erl index 02f07c3a73a..1e4d2237fff 100644 --- a/core/kazoo_media/src/kz_media_proxy_util.erl +++ b/core/kazoo_media/src/kz_media_proxy_util.erl @@ -17,7 +17,7 @@ -include("kazoo_media.hrl"). --type shout_header() :: {non_neg_integer(), ne_binary()}. +-type shout_header() :: {non_neg_integer(), kz_term:ne_binary()}. -export_type([shout_header/0]). -spec stream_body(cowboy_req:req(), pos_integer(), binary(), shout_header() | 'undefined', boolean()) -> 'ok'. @@ -73,7 +73,7 @@ the_header({K, H}) -> _ -> <<0>> end. --spec get_shout_header(ne_binary(), ne_binary()) -> shout_header(). +-spec get_shout_header(kz_term:ne_binary(), kz_term:ne_binary()) -> shout_header(). get_shout_header(MediaName, Url) -> Bin = list_to_binary(["StreamTitle='",MediaName ,"';StreamUrl='",Url,"';" @@ -83,13 +83,13 @@ get_shout_header(MediaName, Url) -> Extra = lists:duplicate(NPad, 0), {0, list_to_binary([Nblocks, Bin, Extra])}. --spec resp_headers(ne_binary()) -> cowboy:http_headers(). +-spec resp_headers(kz_term:ne_binary()) -> cowboy:http_headers(). resp_headers(ContentType) -> #{<<"content-type">> => ContentType ,<<"server">> => list_to_binary([?APP_NAME, "/", ?APP_VERSION]) }. --spec resp_headers(pos_integer(), ne_binary(), binary(), binary()) -> cowboy:http_headers(). +-spec resp_headers(pos_integer(), kz_term:ne_binary(), binary(), binary()) -> cowboy:http_headers(). resp_headers(ChunkSize, ContentType, MediaName, Url) -> #{<<"content-type">> => ContentType ,<<"icy-br">> => <<"8">> diff --git a/core/kazoo_media/src/kz_media_store_proxy.erl b/core/kazoo_media/src/kz_media_store_proxy.erl index e2b3d1d08e4..74ab7439a77 100644 --- a/core/kazoo_media/src/kz_media_store_proxy.erl +++ b/core/kazoo_media/src/kz_media_store_proxy.erl @@ -26,7 +26,7 @@ -type validate_request_ret() :: {'ok', media_store_path()} | {'error', integer()}. -type handler_return() :: {'ok', cowboy_req:req(), 'ok' | state()}. --spec init(cowboy_req:req(), kz_proplist()) -> handler_return(). +-spec init(cowboy_req:req(), kz_term:proplist()) -> handler_return(). init(Req, _Opts) -> kz_util:put_callid(kz_binary:rand_hex(16)), case authenticate(Req) of @@ -54,7 +54,7 @@ maybe_basic_authentication(Req) -> maybe_basic_authentication(Username, Password) end. --spec maybe_basic_authentication(ne_binary(), ne_binary()) -> boolean(). +-spec maybe_basic_authentication(kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). maybe_basic_authentication(Username, Password) -> AuthUsername = kapps_config:get_binary(?CONFIG_CAT, <<"proxy_username">>, <<>>), AuthPassword = kapps_config:get_binary(?CONFIG_CAT, <<"proxy_password">>, <<>>), @@ -70,7 +70,7 @@ maybe_acl_authentication(Req) -> Ip = kz_network_utils:iptuple_to_binary(IpTuple), maybe_acl_authentication(ACLs, Ip). --spec maybe_acl_authentication(ne_binaries(), ne_binary()) -> boolean(). +-spec maybe_acl_authentication(kz_term:ne_binaries(), kz_term:ne_binary()) -> boolean(). maybe_acl_authentication([], Ip) -> lager:debug("ip address ~s can not be authenticated via ACLs", [Ip]), 'false'; @@ -83,7 +83,7 @@ maybe_acl_authentication([ACL|ACLs], Ip) -> maybe_acl_authentication(ACLs, Ip) end. --spec credentials(cowboy_req:req()) -> {api_binary(), api_binary(), cowboy_req:req()}. +-spec credentials(cowboy_req:req()) -> {kz_term:api_binary(), kz_term:api_binary(), cowboy_req:req()}. credentials(Req) -> case cowboy_req:header(<<"authorization">>, Req) of 'undefined' -> @@ -93,7 +93,7 @@ credentials(Req) -> {Username, Password, Req} end. --spec credentials_from_header(ne_binary()) -> {api_binary(), api_binary()}. +-spec credentials_from_header(kz_term:ne_binary()) -> {kz_term:api_binary(), kz_term:api_binary()}. credentials_from_header(AuthorizationHeader) -> case binary:split(AuthorizationHeader, <<$\s>>) of [<<"Basic">>, EncodedCredentials] -> @@ -102,7 +102,7 @@ credentials_from_header(AuthorizationHeader) -> {'undefined', 'undefined'} end. --spec decoded_credentials(ne_binary()) -> {api_binary(), api_binary()}. +-spec decoded_credentials(kz_term:ne_binary()) -> {kz_term:api_binary(), kz_term:api_binary()}. decoded_credentials(EncodedCredentials) -> DecodedCredentials = base64:decode(EncodedCredentials), case binary:split(DecodedCredentials, <<$:>>) of @@ -118,7 +118,7 @@ unauthorized(Req0) -> Req2 = cowboy_req:set_resp_body(unauthorized_body(), Req1), cowboy_req:reply(401, Req2). --spec unauthorized_body() -> ne_binary(). +-spec unauthorized_body() -> kz_term:ne_binary(). unauthorized_body() -> <<" reply_error(500, Req) end. --spec decode_url(ne_binary()) -> media_store_path() | 'error'. +-spec decode_url(kz_term:ne_binary()) -> media_store_path() | 'error'. decode_url(Url) -> try binary_to_term(base64:decode(kz_util:uri_decode(Url))) of {Db, Id, Attachment, Options} -> @@ -234,12 +234,12 @@ is_appropriate_extension(#media_store_path{att=Attachment}=Path) -> {'error', 415} end. --spec add_content_type(media_store_path(), ne_binary()) -> media_store_path(). +-spec add_content_type(media_store_path(), kz_term:ne_binary()) -> media_store_path(). add_content_type(#media_store_path{opt=Options}= Path, CT) -> NewOptions = props:set_value('content_type', kz_term:to_list(CT), Options), Path#media_store_path{opt=NewOptions}. --spec ensure_extension_present(media_store_path(), ne_binary()) -> validate_request_ret(). +-spec ensure_extension_present(media_store_path(), kz_term:ne_binary()) -> validate_request_ret(). ensure_extension_present(#media_store_path{att=Attachment}=Path, CT) -> case kz_term:is_empty(filename:extension(Attachment)) andalso kz_mime:to_extension(CT) @@ -264,7 +264,7 @@ store(#state{filename=Filename, media=Path}=State, Req) -> reply_error(500, State, Req) end. --spec store(media_store_path(), ne_binary(), state(), cowboy_req:req()) -> {'ok', cowboy_req:req(), state()}. +-spec store(media_store_path(), kz_term:ne_binary(), state(), cowboy_req:req()) -> {'ok', cowboy_req:req(), state()}. store(#media_store_path{db=Db ,id=Id ,att=Attachment @@ -283,7 +283,7 @@ store(#media_store_path{db=Db {'ok', failure(Reason, Req0), State} end. --spec success(kz_json:object(), kz_proplist(), cowboy_req:req()) -> cowboy_req:req(). +-spec success(kz_json:object(), kz_term:proplist(), cowboy_req:req()) -> cowboy_req:req(). success(JObj, Props, Req0) -> Body = io_lib:format("~s~n", [kz_json:encode(kz_json:set_value(<<"ok">>, 'true', JObj))]), Req1 = cowboy_req:set_resp_body(Body, Req0), diff --git a/core/kazoo_media/src/kz_media_tts.erl b/core/kazoo_media/src/kz_media_tts.erl index 312b4bceb21..07b813368e6 100644 --- a/core/kazoo_media/src/kz_media_tts.erl +++ b/core/kazoo_media/src/kz_media_tts.erl @@ -12,7 +12,7 @@ -include("kazoo_media.hrl"). --spec get_uri(ne_binary(), kz_json:object()) -> ne_binary(). +-spec get_uri(kz_term:ne_binary(), kz_json:object()) -> kz_term:ne_binary(). get_uri(Id, JObj) -> {'ok', _TTSServer} = kz_media_cache_sup:find_tts_server(Id, JObj), diff --git a/core/kazoo_media/src/kz_media_tts_cache.erl b/core/kazoo_media/src/kz_media_tts_cache.erl index decee570f93..747677bb68b 100644 --- a/core/kazoo_media/src/kz_media_tts_cache.erl +++ b/core/kazoo_media/src/kz_media_tts_cache.erl @@ -34,14 +34,14 @@ -define(TIMEOUT_MESSAGE, {'$kz_media_tts_cache', 'tts_timeout'}). --record(state, {text :: api_ne_binary() +-record(state, {text :: kz_term:api_ne_binary() ,contents = <<>> :: binary() ,status :: 'streaming' | 'ready' ,kz_http_req_id :: kz_http:req_id() ,reqs :: [{pid(), reference()}] ,meta :: kz_json:object() ,timer_ref :: reference() - ,id :: ne_binary() %% used in publishing doc_deleted + ,id :: kz_term:ne_binary() %% used in publishing doc_deleted }). -type state() :: #state{}. @@ -52,14 +52,14 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(ne_binary(), kz_json:object()) -> startlink_ret(). +-spec start_link(kz_term:ne_binary(), kz_json:object()) -> kz_types:startlink_ret(). start_link(Id, JObj) -> gen_server:start_link(?SERVER, [Id, JObj], []). --spec single(pid()) -> {kz_json:object(), ne_binary()}. +-spec single(pid()) -> {kz_json:object(), kz_term:ne_binary()}. single(Srv) -> gen_server:call(Srv, 'single'). --spec continuous(pid()) -> {kz_json:object(), ne_binary()}. +-spec continuous(pid()) -> {kz_json:object(), kz_term:ne_binary()}. continuous(Srv) -> gen_server:call(Srv, 'continuous'). -spec stop(pid()) -> 'ok'. @@ -110,7 +110,7 @@ init([Id, JObj]) -> ,id = Id }}. --spec get_language(ne_binary()) -> ne_binary(). +-spec get_language(kz_term:ne_binary()) -> kz_term:ne_binary(). get_language(<<"en">>) -> <<"en-us">>; get_language(<>) -> <>; get_language(Language) -> Language. @@ -129,7 +129,7 @@ get_language(Language) -> Language. %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call('single', _From, #state{meta=Meta ,contents=Contents ,status=ready @@ -157,7 +157,7 @@ handle_call('continuous', _From, #state{}=State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('stop', State) -> lager:debug("asked to stop, going down"), {'stop', 'normal', State}; @@ -174,7 +174,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'timeout', TRef, ?TIMEOUT_MESSAGE}, #state{timer_ref=TRef}=State) -> lager:debug("timeout expired, going down"), {'stop', 'normal', State}; @@ -288,7 +288,7 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec kv_to_bin(kz_proplist()) -> kz_proplist(). +-spec kv_to_bin(kz_term:proplist()) -> kz_term:proplist(). kv_to_bin(L) -> [{kz_term:to_binary(K), kz_term:to_binary(V)} || {K,V} <- L]. @@ -301,7 +301,7 @@ stop_timer(Ref) when is_reference(Ref) -> _ = erlang:cancel_timer(Ref), 'ok'. --spec publish_doc_update(ne_binary()) -> 'ok'. +-spec publish_doc_update(kz_term:ne_binary()) -> 'ok'. publish_doc_update(Id) -> API = [{<<"ID">>, Id} diff --git a/core/kazoo_media/src/kz_media_url.erl b/core/kazoo_media/src/kz_media_url.erl index 71a4440d485..a06df1d1ec5 100644 --- a/core/kazoo_media/src/kz_media_url.erl +++ b/core/kazoo_media/src/kz_media_url.erl @@ -15,8 +15,8 @@ -define(STREAM_TYPE_STORE, kz_json:from_list([{<<"Stream-Type">>, <<"store">>}])). --type build_media_url() :: api_binary() | binaries() | kz_json:object(). --type build_media_url_ret() :: ne_binary() | {'error', atom()}. +-type build_media_url() :: kz_term:api_binary() | kz_term:binaries() | kz_json:object(). +-type build_media_url_ret() :: kz_term:ne_binary() | {'error', atom()}. -spec playback(build_media_url()) -> build_media_url_ret(). -spec playback(build_media_url(), kz_json:object()) -> build_media_url_ret(). @@ -54,11 +54,11 @@ playback(Doc, JObj) -> Error -> Error end. --spec store(kz_json:object(), ne_binary()) -> +-spec store(kz_json:object(), kz_term:ne_binary()) -> build_media_url_ret(). --spec store(ne_binary(), kazoo_data:docid(), ne_binary()) -> +-spec store(kz_term:ne_binary(), kazoo_data:docid(), kz_term:ne_binary()) -> build_media_url_ret(). --spec store(ne_binary(), kazoo_data:docid(), ne_binary(), kz_proplist()) -> +-spec store(kz_term:ne_binary(), kazoo_data:docid(), kz_term:ne_binary(), kz_term:proplist()) -> build_media_url_ret(). store(JObj, AName) -> Media = kz_media_util:store_path_from_doc(JObj, AName), diff --git a/core/kazoo_media/src/kz_media_util.erl b/core/kazoo_media/src/kz_media_util.erl index e978abd3dd9..a1f695318e4 100644 --- a/core/kazoo_media/src/kz_media_util.erl +++ b/core/kazoo_media/src/kz_media_util.erl @@ -68,9 +68,9 @@ {'to_args', binary()}. -type normalization_options() :: [normalization_option()]. --spec normalize_media(ne_binary(), ne_binary(), binary()) -> +-spec normalize_media(kz_term:ne_binary(), kz_term:ne_binary(), binary()) -> normalized_media(). --spec normalize_media(ne_binary(), ne_binary(), binary(), normalization_options()) -> +-spec normalize_media(kz_term:ne_binary(), kz_term:ne_binary(), binary(), normalization_options()) -> normalized_media(). normalize_media(FromFormat, FromFormat, FileContents) -> {'ok', FileContents}; @@ -96,14 +96,14 @@ normalize_media(FromFormat, ToFormat, FileContents, Options) -> %% normalized file only, pass the {'output', 'file'} as option. %% @end %%-------------------------------------------------------------------- --spec normalize_media_file(ne_binary(), ne_binary(), file:filename_all()) -> +-spec normalize_media_file(kz_term:ne_binary(), kz_term:ne_binary(), file:filename_all()) -> normalized_media(). normalize_media_file(FromFormat, FromFormat, FromFile) -> {'ok', FromFile}; normalize_media_file(FromFormat, ToFormat, FromFile) -> normalize_media_file(FromFormat, ToFormat, FromFile, default_normalization_options(ToFormat)). --spec default_normalization_options(ne_binary()) -> normalization_options(). +-spec default_normalization_options(kz_term:ne_binary()) -> normalization_options(). default_normalization_options(ToFormat) -> [{'from_args', ?NORMALIZE_SOURCE_ARGS} ,{'to_args', ?NORMALIZE_DEST_ARGS} @@ -112,7 +112,7 @@ default_normalization_options(ToFormat) -> ,{'output', 'binary'} ]. --spec normalize_media_file(ne_binary(), ne_binary(), file:filename_all(), normalization_options()) -> +-spec normalize_media_file(kz_term:ne_binary(), kz_term:ne_binary(), file:filename_all(), normalization_options()) -> normalized_media(). normalize_media_file(FromFormat, ToFormat, FromFile, Options) -> FromArgs = props:get_value('from_args', Options, ?NORMALIZE_SOURCE_ARGS), @@ -147,7 +147,7 @@ return_command_result({'error', _}=Error, _FileName, _) -> Error. %% Run normalizer command %% @end %%-------------------------------------------------------------------- --spec run_command(ne_binary()) -> normalized_media(). +-spec run_command(kz_term:ne_binary()) -> normalized_media(). run_command(Command) -> try os:cmd(binary_to_list(Command)) of Result -> @@ -164,7 +164,7 @@ run_command(Command) -> %% Synthesize a tone, returns as binary or a path to the generated file %% @end %%-------------------------------------------------------------------- --spec synthesize_tone(ne_binary(), ne_binary(), ne_binary()) -> normalized_media(). +-spec synthesize_tone(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> normalized_media(). synthesize_tone(SampleRate, Frequency, Length) -> FileName = tmp_file(<<"wav">>), case synthesize_tone(SampleRate, Frequency, Length, FileName) of @@ -180,7 +180,7 @@ synthesize_tone(SampleRate, Frequency, Length) -> %% Synthesize a tone, returns as binary or a path to the generated file %% @end %%-------------------------------------------------------------------- --spec synthesize_tone(ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> normalized_media(). +-spec synthesize_tone(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> normalized_media(). synthesize_tone(SampleRate, Frequency, Length, FileName) -> Command = iolist_to_binary([?NORMALIZE_EXE ,<<" -r ">>, SampleRate @@ -196,7 +196,7 @@ synthesize_tone(SampleRate, Frequency, Length, FileName) -> %% Detect sample rate of a media file %% @end %%-------------------------------------------------------------------- --spec detect_file_sample_rate(ne_binary()) -> normalized_media(). +-spec detect_file_sample_rate(kz_term:ne_binary()) -> normalized_media(). detect_file_sample_rate(FileName) -> Command = iolist_to_binary([?NORMALIZE_EXE ,<<" --i -r ">> @@ -222,7 +222,7 @@ detect_file_sample_rate(FileName) -> %% Detect media format of a media file %% @end %%-------------------------------------------------------------------- --spec detect_file_format(ne_binary()) -> normalized_media(). +-spec detect_file_format(kz_term:ne_binary()) -> normalized_media(). detect_file_format(FileName) -> Command = iolist_to_binary([?NORMALIZE_EXE ,<<" --i -t ">> @@ -250,14 +250,14 @@ detect_file_format(FileName) -> %% requested sample rate or the default value of 16kHz. %% @end %%-------------------------------------------------------------------- --type join_file() :: {ne_binary(), api_binary(), api_binary()}. +-type join_file() :: {kz_term:ne_binary(), kz_term:api_binary(), kz_term:api_binary()}. -type join_files() :: [join_file()]. --spec join_media_files(ne_binaries()) -> normalized_media(). +-spec join_media_files(kz_term:ne_binaries()) -> normalized_media(). join_media_files(FileNames) -> join_media_files(FileNames, []). --spec join_media_files(ne_binaries(), kz_proplist()) -> normalized_media(). +-spec join_media_files(kz_term:ne_binaries(), kz_term:proplist()) -> normalized_media(). join_media_files(FileNames, Options) -> DetectedOpts = [detect_format_options(F) || F <- FileNames], SampleRate = props:get_value('sample_rate', Options, <<"16000">>), @@ -267,14 +267,14 @@ join_media_files(FileNames, Options) -> {'error', _}=Error -> Error end. --spec maybe_join_media_files(join_files(), kz_proplist(), join_files()) -> normalized_media(). +-spec maybe_join_media_files(join_files(), kz_term:proplist(), join_files()) -> normalized_media(). maybe_join_media_files([], Options, Acc) -> do_join_media_files(Acc, Options); maybe_join_media_files([{_, 'undefined', _}|_], _, _) -> {'error', 'join_media_failed'}; maybe_join_media_files([{_, _, 'undefined'}|_], _, _) -> {'error', 'join_media_failed'}; maybe_join_media_files([F|Files], Options, Acc) -> maybe_join_media_files(Files, Options, [F|Acc]). --spec do_join_media_files(join_files(), kz_proplist()) -> normalized_media(). +-spec do_join_media_files(join_files(), kz_term:proplist()) -> normalized_media(). do_join_media_files(Files, Options) -> SampleRate = props:get_value('sample_rate', Options, <<"16000">>), ToFormat = props:get_value('to_format', Options, ?NORMALIZATION_FORMAT), @@ -303,7 +303,7 @@ do_join_media_files(Files, Options) -> %% copy the files to a temporary place to join them together. %% @end %%-------------------------------------------------------------------- --spec maybe_normalize_copy_files(join_files(), ne_binary(), join_files()) -> +-spec maybe_normalize_copy_files(join_files(), kz_term:ne_binary(), join_files()) -> {'ok', join_files()} | {'error', 'normalization_failed'}. maybe_normalize_copy_files([], _SampleRate, Acc) -> {'ok', Acc}; @@ -338,7 +338,7 @@ maybe_normalize_copy_files([{File, _Other, Format}|Files], SampleRate, Acc) -> %% a tuple of detect options %% @end %%-------------------------------------------------------------------- --spec detect_format_options(ne_binary()) -> join_file(). +-spec detect_format_options(kz_term:ne_binary()) -> join_file(). detect_format_options(File) -> FileSampleRate = detect_file_sample_rate(File), FileFormat = detect_file_format(File), @@ -358,11 +358,11 @@ detect_format_options(File) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec tmp_file(ne_binary()) -> file:filename_all(). +-spec tmp_file(kz_term:ne_binary()) -> file:filename_all(). tmp_file(Ext) -> filename:join(["/tmp", list_to_binary([kz_binary:rand_hex(16), ".", Ext])]). --spec recording_url(ne_binary(), kz_json:object()) -> ne_binary(). +-spec recording_url(kz_term:ne_binary(), kz_json:object()) -> kz_term:ne_binary(). recording_url(CallId, Data) -> %% TODO: look at the URL for {filename}, if present replace it with %% the filename, otherwise continue to append as we do today. @@ -379,8 +379,8 @@ max_recording_time_limit() -> %% Port = kz_couch_connections:get_port(), %% base_url(Host, Port). --spec base_url(text(), text()) -> ne_binary(). --spec base_url(text(), text(), atom()) -> ne_binary(). +-spec base_url(kz_term:text(), kz_term:text()) -> kz_term:ne_binary(). +-spec base_url(kz_term:text(), kz_term:text(), atom()) -> kz_term:ne_binary(). base_url(Host, Port) -> base_url(Host, Port, 'proxy_playback'). @@ -424,13 +424,13 @@ build_url(H, P, User, Pwd) -> ,"@", kz_term:to_binary(H), ":", kz_term:to_binary(P), "/" ]). --spec convert_stream_type(ne_binary()) -> ne_binary(). +-spec convert_stream_type(kz_term:ne_binary()) -> kz_term:ne_binary(). convert_stream_type(<<"extant">>) -> <<"continuous">>; convert_stream_type(<<"store">>) -> <<"store">>; convert_stream_type(_) -> <<"single">>. --spec media_path(api_binary()) -> api_binary(). --spec media_path(api_binary(), api_ne_binary()) -> api_binary(). +-spec media_path(kz_term:api_binary()) -> kz_term:api_binary(). +-spec media_path(kz_term:api_binary(), kz_term:api_ne_binary()) -> kz_term:api_binary(). media_path(Path) -> media_path(Path, 'undefined'). media_path('undefined', _AccountId) -> 'undefined'; @@ -452,8 +452,8 @@ media_path(Path, AccountId) when is_binary(AccountId) -> %% %% @end %%-------------------------------------------------------------------- --spec prompt_path(ne_binary()) -> ne_binary(). --spec prompt_path(api_binary(), ne_binary()) -> ne_binary(). +-spec prompt_path(kz_term:ne_binary()) -> kz_term:ne_binary(). +-spec prompt_path(kz_term:api_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). prompt_path(PromptId) -> prompt_path(?KZ_MEDIA_DB, PromptId). @@ -464,8 +464,8 @@ prompt_path(Db, <<"/system_media/", PromptId/binary>>) -> prompt_path(Db, PromptId) -> kz_binary:join([<<>>, Db, PromptId], <<"/">>). --spec prompt_id(ne_binary()) -> ne_binary(). --spec prompt_id(ne_binary(), api_binary()) -> ne_binary(). +-spec prompt_id(kz_term:ne_binary()) -> kz_term:ne_binary(). +-spec prompt_id(kz_term:ne_binary(), kz_term:api_binary()) -> kz_term:ne_binary(). prompt_id(PromptId) -> prompt_id(PromptId, 'undefined'). prompt_id(<<"/system_media/", PromptId/binary>>, Lang) -> @@ -475,14 +475,14 @@ prompt_id(PromptId, <<>>) -> PromptId; prompt_id(PromptId, Lang) -> filename:join([Lang, PromptId]). --spec get_prompt(ne_binary()) -> - api_ne_binary(). --spec get_prompt(ne_binary(), api_ne_binary()) -> - api_ne_binary(). --spec get_prompt(ne_binary(), api_ne_binary(), api_ne_binary()) -> - api_ne_binary(). --spec get_prompt(ne_binary(), api_ne_binary(), api_ne_binary(), boolean()) -> - api_ne_binary(). +-spec get_prompt(kz_term:ne_binary()) -> + kz_term:api_ne_binary(). +-spec get_prompt(kz_term:ne_binary(), kz_term:api_ne_binary()) -> + kz_term:api_ne_binary(). +-spec get_prompt(kz_term:ne_binary(), kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> + kz_term:api_ne_binary(). +-spec get_prompt(kz_term:ne_binary(), kz_term:api_ne_binary(), kz_term:api_ne_binary(), boolean()) -> + kz_term:api_ne_binary(). get_prompt(Name) -> get_prompt(Name, 'undefined'). @@ -512,10 +512,10 @@ get_prompt(PromptId, Lang, _AccountId, 'false') -> lager:debug("account overrides not enabled; ignoring account prompt for ~s", [PromptId]), kz_binary:join([<<"prompt:/">>, ?KZ_MEDIA_DB, PromptId, Lang], <<"/">>). --spec get_account_prompt(ne_binary(), api_ne_binary(), ne_binary()) -> - api_ne_binary(). --spec get_account_prompt(ne_binary(), api_ne_binary(), ne_binary(), ne_binary()) -> - api_ne_binary(). +-spec get_account_prompt(kz_term:ne_binary(), kz_term:api_ne_binary(), kz_term:ne_binary()) -> + kz_term:api_ne_binary(). +-spec get_account_prompt(kz_term:ne_binary(), kz_term:api_ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> + kz_term:api_ne_binary(). %% tries account default, then system get_account_prompt(Name, 'undefined', AccountId) -> PromptId = prompt_id(Name), @@ -590,7 +590,7 @@ get_account_prompt(Name, Lang, AccountId, OriginalLang) -> {'ok', _} -> prompt_path(AccountId, PromptId) end. --spec lookup_prompt(ne_binary(), ne_binary()) -> +-spec lookup_prompt(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', 'not_found'}. lookup_prompt(Db, Id) -> @@ -609,7 +609,7 @@ prompt_is_usable(Doc) -> 'false' -> {'ok', Doc} end. --spec get_system_prompt(ne_binary(), api_binary()) -> api_binary(). +-spec get_system_prompt(kz_term:ne_binary(), kz_term:api_binary()) -> kz_term:api_binary(). get_system_prompt(Name, 'undefined') -> PromptId = prompt_id(Name), lager:debug("getting system prompt for '~s'", [PromptId]), @@ -651,8 +651,8 @@ get_system_prompt(Name, Lang) -> {'ok', _Prompt} -> prompt_path(PromptId) end. --spec default_prompt_language() -> ne_binary(). --spec default_prompt_language(api_binary()) -> ne_binary(). +-spec default_prompt_language() -> kz_term:ne_binary(). +-spec default_prompt_language(kz_term:api_binary()) -> kz_term:ne_binary(). default_prompt_language() -> default_prompt_language(<<"en-us">>). default_prompt_language(Default) -> @@ -660,12 +660,12 @@ default_prompt_language(Default) -> kapps_config:get_ne_binary(?CONFIG_CAT, ?PROMPT_LANGUAGE_KEY, Default) ). --spec prompt_language(api_binary()) -> ne_binary(). +-spec prompt_language(kz_term:api_binary()) -> kz_term:ne_binary(). prompt_language(?KZ_MEDIA_DB) -> default_prompt_language(); prompt_language(AccountId) -> prompt_language(AccountId, default_prompt_language()). --spec prompt_language(api_binary(), api_binary()) -> ne_binary(). +-spec prompt_language(kz_term:api_binary(), kz_term:api_binary()) -> kz_term:ne_binary(). prompt_language('undefined', Default) -> default_prompt_language(Default); prompt_language(<<_/binary>> = AccountId, 'undefined') -> @@ -692,7 +692,7 @@ store_path_from_doc(JObj) -> [AName | _] -> store_path_from_doc(JObj, AName) end. --spec store_path_from_doc(kz_json:object(), ne_binary()) -> media_store_path(). +-spec store_path_from_doc(kz_json:object(), kz_term:ne_binary()) -> media_store_path(). store_path_from_doc(JObj, AName) -> Opts = [{'doc_type', kz_doc:type(JObj)} ,{'doc_owner', kz_json:get_value(<<"owner_id">>, JObj)} diff --git a/core/kazoo_modb/src/kazoo_modb.erl b/core/kazoo_modb/src/kazoo_modb.erl index 57794c7a0d5..012319dfdd5 100644 --- a/core/kazoo_modb/src/kazoo_modb.erl +++ b/core/kazoo_modb/src/kazoo_modb.erl @@ -26,8 +26,8 @@ -export([get_year_month_sequence/3, get_year_month_sequence/4]). -export([strip_modb_options/1]). --type view_option() :: {'year', kz_year()} | - {'month', kz_month()} | +-type view_option() :: {'year', kz_time:year()} | + {'month', kz_time:month()} | {'create_db', boolean()} | {'allow_old_modb_creation', boolean()} | kz_datamgr:view_option(). @@ -44,10 +44,10 @@ %% @end %%-------------------------------------------------------------------- --spec get_results(ne_binary(), ne_binary(), view_options()) -> +-spec get_results(kz_term:ne_binary(), kz_term:ne_binary(), view_options()) -> {'ok', kz_json:objects()} | {'error', atom()}. --spec get_results(ne_binary(), ne_binary(), view_options(), atom(), non_neg_integer()) -> +-spec get_results(kz_term:ne_binary(), kz_term:ne_binary(), view_options(), atom(), non_neg_integer()) -> {'ok', kz_json:objects()} | {'error', atom()}. get_results(Account, View, ViewOptions) -> @@ -83,7 +83,7 @@ is_modb_option({'ensure_saved', _}) -> 'true'; is_modb_option({'max_retries', _}) -> 'true'; is_modb_option(_) -> 'false'. --spec get_results_missing_db(ne_binary(), ne_binary(), view_options(), integer()) -> +-spec get_results_missing_db(kz_term:ne_binary(), kz_term:ne_binary(), view_options(), integer()) -> {'ok', kz_json:objects()}. get_results_missing_db(Account, View, ViewOptions, Retry) -> AccountMODb = get_modb(Account, ViewOptions), @@ -109,13 +109,13 @@ get_results_missing_db(Account, View, ViewOptions, Retry) -> %% %% @end %%-------------------------------------------------------------------- --spec open_doc(ne_binary(), kazoo_data:docid()) -> +-spec open_doc(kz_term:ne_binary(), kazoo_data:docid()) -> {'ok', kz_json:object()} | {'error', atom()}. --spec open_doc(ne_binary(), kazoo_data:docid(), integer() | view_options()) -> +-spec open_doc(kz_term:ne_binary(), kazoo_data:docid(), integer() | view_options()) -> {'ok', kz_json:object()} | {'error', atom()}. --spec open_doc(ne_binary(), kazoo_data:docid(), kz_year() | ne_binary(), kz_month() | ne_binary()) -> +-spec open_doc(kz_term:ne_binary(), kazoo_data:docid(), kz_time:year() | kz_term:ne_binary(), kz_time:month() | kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', atom()}. open_doc(Account, {_, ?MATCH_MODB_PREFIX(Year,Month,_)} = DocId) -> @@ -141,13 +141,13 @@ open_doc(Account, DocId, Year, Month) -> AccountMODb = get_modb(Account, Year, Month), couch_open(AccountMODb, DocId). --spec couch_open(ne_binary(), kazoo_data:docid()) -> +-spec couch_open(kz_term:ne_binary(), kazoo_data:docid()) -> {'ok', kz_json:object()} | {'error', atom()}. couch_open(AccountMODb, DocId) -> couch_open(AccountMODb, DocId, []). --spec couch_open(ne_binary(), kazoo_data:docid(), kz_proplist()) -> +-spec couch_open(kz_term:ne_binary(), kazoo_data:docid(), kz_term:proplist()) -> {'ok', kz_json:object()} | {'error', atom()}. couch_open(AccountMODb, DocId, Options) -> @@ -163,13 +163,13 @@ couch_open(AccountMODb, DocId, Options) -> %% %% @end %%-------------------------------------------------------------------- --spec save_doc(ne_binary(), kz_json:object()) -> +-spec save_doc(kz_term:ne_binary(), kz_json:object()) -> {'ok', kz_json:object()} | {'error', atom()}. --spec save_doc(ne_binary(), kz_json:object(), kz_now() | gregorian_seconds() | kz_proplist()) -> +-spec save_doc(kz_term:ne_binary(), kz_json:object(), kz_time:now() | kz_time:gregorian_seconds() | kz_term:proplist()) -> {'ok', kz_json:object()} | {'error', atom()}. --spec save_doc(ne_binary(), kz_json:object(), kz_year() | ne_binary() | kz_now(), kz_month() | ne_binary() | kz_proplist()) -> +-spec save_doc(kz_term:ne_binary(), kz_json:object(), kz_time:year() | kz_term:ne_binary() | kz_time:now(), kz_time:month() | kz_term:ne_binary() | kz_term:proplist()) -> {'ok', kz_json:object()} | {'error', atom()}. save_doc(Account, Doc) -> @@ -194,7 +194,7 @@ save_doc(Account, Doc, Year, Month, Options) -> MaxRetries = props:get_integer_value('max_retries', Options, ?MAX_RETRIES), couch_save(AccountMODb, Doc, Options, 'first_try', MaxRetries). --spec couch_save(ne_binary(), kz_json:object(), kz_proplist(), atom(), integer()) -> +-spec couch_save(kz_term:ne_binary(), kz_json:object(), kz_term:proplist(), atom(), integer()) -> {'ok', kz_json:object()} | {'error', atom()}. couch_save(AccountMODb, _Doc, _Options, Reason, Retry) when Retry =< 0 -> @@ -240,20 +240,20 @@ save_fun('true') -> fun kz_datamgr:ensure_saved/3. %% databases! %% @end %%-------------------------------------------------------------------- --spec move_doc(ne_binary(), kazoo_data:docid(), ne_binary(), kazoo_data:docid()) -> +-spec move_doc(kz_term:ne_binary(), kazoo_data:docid(), kz_term:ne_binary(), kazoo_data:docid()) -> {'ok', kz_json:object()} | {'error', atom()}. move_doc(FromDb, FromId, ToDb, ToId) -> move_doc(FromDb, FromId, ToDb, ToId, []). --spec move_doc(ne_binary(), kazoo_data:docid(), ne_binary(), kazoo_data:docid(), kz_proplist()) -> +-spec move_doc(kz_term:ne_binary(), kazoo_data:docid(), kz_term:ne_binary(), kazoo_data:docid(), kz_term:proplist()) -> {'ok', kz_json:object()} | {'error', atom()}. move_doc(FromDb, FromId, ToDb, ToId, Options) -> MaxRetries = props:get_integer_value('max_retries', Options, ?MAX_RETRIES), move_doc(FromDb, FromId, ToDb, ToId, Options, 'first_try', MaxRetries). --spec move_doc(ne_binary(), kazoo_data:docid(), ne_binary(), kazoo_data:docid(), kz_proplist(), atom(), integer()) -> +-spec move_doc(kz_term:ne_binary(), kazoo_data:docid(), kz_term:ne_binary(), kazoo_data:docid(), kz_term:proplist(), atom(), integer()) -> {'ok', kz_json:object()} | {'error', atom()}. move_doc(FromDb, {_, FromId}, ToDb, ToId, Options, Reason, Retry) when Retry =< 0 -> @@ -289,20 +289,20 @@ move_doc(FromDb, FromId, ToDb, ToId, Options, _Reason, Retry) -> %% databases! %% @end %%-------------------------------------------------------------------- --spec copy_doc(ne_binary(), kazoo_data:docid(), ne_binary(), kazoo_data:docid()) -> +-spec copy_doc(kz_term:ne_binary(), kazoo_data:docid(), kz_term:ne_binary(), kazoo_data:docid()) -> {'ok', kz_json:object()} | {'error', atom()}. copy_doc(FromDb, FromId, ToDb, ToId) -> copy_doc(FromDb, FromId, ToDb, ToId, []). --spec copy_doc(ne_binary(), kazoo_data:docid(), ne_binary(), kazoo_data:docid(), kz_proplist()) -> +-spec copy_doc(kz_term:ne_binary(), kazoo_data:docid(), kz_term:ne_binary(), kazoo_data:docid(), kz_term:proplist()) -> {'ok', kz_json:object()} | {'error', atom()}. copy_doc(FromDb, FromId, ToDb, ToId, Options) -> MaxRetries = props:get_integer_value('max_retries', Options, ?MAX_RETRIES), copy_doc(FromDb, FromId, ToDb, ToId, Options, 'first_try', MaxRetries). --spec copy_doc(ne_binary(), kazoo_data:docid(), ne_binary(), kazoo_data:docid(), kz_proplist(), atom(), integer()) -> +-spec copy_doc(kz_term:ne_binary(), kazoo_data:docid(), kz_term:ne_binary(), kazoo_data:docid(), kz_term:proplist(), atom(), integer()) -> {'ok', kz_json:object()} | {'error', atom()}. copy_doc(_FromDb, _FromId, _ToDb, _ToId, _Options, Reason, Retry) when Retry =< 0 -> @@ -327,7 +327,7 @@ copy_doc(FromDb, FromId, ToDb, ToId, Options, _Reason, Retry) -> {'error', _}=Error -> Error end. --spec maybe_create_destination_db(ne_binary(), ne_binary(), ne_binary(), kz_proplist()) -> +-spec maybe_create_destination_db(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> 'source_not_exists' | 'too_old'| boolean(). @@ -357,11 +357,11 @@ maybe_create_destination_db(FromDb, FromId, ToDb, Options) -> %% %% @end %%-------------------------------------------------------------------- --spec get_modb(ne_binary()) -> ne_binary(). --spec get_modb(ne_binary(), view_options() | gregorian_seconds() | kz_now()) -> - ne_binary(). --spec get_modb(ne_binary(), kz_year() | ne_binary(), kz_month() | ne_binary()) -> - ne_binary(). +-spec get_modb(kz_term:ne_binary()) -> kz_term:ne_binary(). +-spec get_modb(kz_term:ne_binary(), view_options() | kz_time:gregorian_seconds() | kz_time:now()) -> + kz_term:ne_binary(). +-spec get_modb(kz_term:ne_binary(), kz_time:year() | kz_term:ne_binary(), kz_time:month() | kz_term:ne_binary()) -> + kz_term:ne_binary(). get_modb(?MATCH_MODB_SUFFIX_RAW(_,_,_) = AccountMODb) -> AccountMODb; get_modb(?MATCH_MODB_SUFFIX_ENCODED(_,_,_) = AccountMODb) -> @@ -406,7 +406,7 @@ get_modb(Account, Year, Month) -> %% %% @end %%-------------------------------------------------------------------- --spec maybe_create_current_modb(ne_binary(), kz_proplist()) -> 'too_old' | boolean(). +-spec maybe_create_current_modb(kz_term:ne_binary(), kz_term:proplist()) -> 'too_old' | boolean(). maybe_create_current_modb(?MATCH_MODB_SUFFIX_RAW(_AccountId, Year, Month) = AccountMODb, Options) -> {Y, M, _} = erlang:date(), ShouldCreateOld = props:get_is_true('allow_old_modb_creation', Options, 'false'), @@ -424,7 +424,7 @@ maybe_create_current_modb(?MATCH_MODB_SUFFIX_ENCODED(_, _, _) = AccountMODb, Opt maybe_create_current_modb(?MATCH_MODB_SUFFIX_UNENCODED(_, _, _) = AccountMODb, Options) -> maybe_create_current_modb(kz_util:format_account_modb(AccountMODb, 'raw'), Options). --spec maybe_create(ne_binary()) -> boolean(). +-spec maybe_create(kz_term:ne_binary()) -> boolean(). maybe_create(?MATCH_MODB_SUFFIX_RAW(AccountId, _, _) = AccountMODb) -> maybe_create(AccountMODb, is_account_deleted(AccountId)); maybe_create(?MATCH_MODB_SUFFIX_ENCODED(_, _, _) = AccountMODb) -> @@ -432,20 +432,20 @@ maybe_create(?MATCH_MODB_SUFFIX_ENCODED(_, _, _) = AccountMODb) -> maybe_create(?MATCH_MODB_SUFFIX_UNENCODED(_, _, _) = AccountMODb) -> maybe_create(kz_util:format_account_modb(AccountMODb, 'raw')). --spec maybe_create(ne_binary(), boolean()) -> boolean(). +-spec maybe_create(kz_term:ne_binary(), boolean()) -> boolean(). maybe_create(?MATCH_MODB_SUFFIX_RAW(_AccountId, _, _) = _AccountMODb, 'true') -> lager:info("account ~s is deleted, not creating modb ~s", [_AccountId, _AccountMODb]), 'false'; maybe_create(AccountMODb, 'false') -> create(AccountMODb). --spec create(ne_binary()) -> boolean(). +-spec create(kz_term:ne_binary()) -> boolean(). create(AccountMODb) -> EncodedMODb = kz_util:format_account_modb(AccountMODb, 'encoded'), IsDbExists = kz_datamgr:db_exists_all(EncodedMODb), do_create(AccountMODb, IsDbExists). --spec do_create(ne_binary(), boolean()) -> boolean(). +-spec do_create(kz_term:ne_binary(), boolean()) -> boolean(). do_create(AccountMODb, 'true') -> lager:info("modb ~p is exists, just refreshing views...", [AccountMODb]), EncodedMODb = kz_util:format_account_modb(AccountMODb, 'encoded'), @@ -463,14 +463,14 @@ do_create(AccountMODb, 'false') -> _ -> 'false' end. --spec is_account_deleted(ne_binary()) -> boolean(). +-spec is_account_deleted(kz_term:ne_binary()) -> boolean(). is_account_deleted(AccountId) -> case kz_datamgr:open_doc(?KZ_ACCOUNTS_DB, AccountId) of {'ok', JObj} -> kz_doc:is_soft_deleted(JObj); {'error', _} -> 'true' end. --spec refresh_views(ne_binary()) -> 'ok'. +-spec refresh_views(kz_term:ne_binary()) -> 'ok'. refresh_views(AccountMODb) -> lager:debug("refresh views on modb ~p", [AccountMODb]), EncodedMODb = kz_util:format_account_modb(AccountMODb, 'encoded'), @@ -483,18 +483,18 @@ refresh_views(AccountMODb) -> %% %% @end %%-------------------------------------------------------------------- --spec run_routines(ne_binary()) -> 'ok'. +-spec run_routines(kz_term:ne_binary()) -> 'ok'. run_routines(AccountMODb) -> Routines = kapps_config:get_ne_binaries(?CONFIG_CAT, <<"routines">>, []), _ = [run_routine(AccountMODb, Routine) || Routine <- Routines], 'ok'. --spec run_routine(ne_binary(), ne_binary()) -> any(). +-spec run_routine(kz_term:ne_binary(), kz_term:ne_binary()) -> any(). run_routine(AccountMODb, Routine) -> Module = kz_term:to_atom(Routine), _ = Module:modb(AccountMODb). --spec add_routine(ne_binary() | atom()) -> 'ok'. +-spec add_routine(kz_term:ne_binary() | atom()) -> 'ok'. add_routine(Module) -> Routine = kz_term:to_binary(Module), Routines = kapps_config:get(?CONFIG_CAT, <<"routines">>, []), @@ -505,11 +505,11 @@ add_routine(Module) -> 'ok' end. --spec add_migrate_routines(ne_binaries(), ne_binary()) -> ne_binaries(). +-spec add_migrate_routines(kz_term:ne_binaries(), kz_term:ne_binary()) -> kz_term:ne_binaries(). add_migrate_routines(Routines, Module) -> lists:usort([Module | migrate_routines(Routines, [])] ++ [<<"wht_util">>]). --spec migrate_routines(ne_binaries(), ne_binaries()) -> ne_binaries(). +-spec migrate_routines(kz_term:ne_binaries(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). migrate_routines([], Acc) -> Acc; migrate_routines([<<"wh_", Rest/binary>> | Rs], Acc) -> migrate_routines(Rs, [<<"kz_", Rest/binary>> | Acc]); @@ -522,7 +522,7 @@ migrate_routines([R | Rs], Acc) -> %% %% @end %%-------------------------------------------------------------------- --spec maybe_archive_modb(ne_binary()) -> 'ok'. +-spec maybe_archive_modb(kz_term:ne_binary()) -> 'ok'. maybe_archive_modb(AccountMODb) -> {Year, Month, _} = erlang:date(), case should_archive(AccountMODb, Year, Month) of @@ -536,7 +536,7 @@ maybe_archive_modb(AccountMODb) -> lager:info("account modb ~s still current enough to keep", [AccountMODb]) end. --spec should_archive(ne_binary(), kz_year(), kz_month()) -> boolean(). +-spec should_archive(kz_term:ne_binary(), kz_time:year(), kz_time:month()) -> boolean(). should_archive(AccountMODb, Year, Month) -> case kazoo_modb_util:split_account_mod(AccountMODb) of {_AccountId, Year, Month} -> 'false'; @@ -555,13 +555,13 @@ should_archive(AccountMODb, Year, Month) -> %% Returns whether AccountMODb has been deleted. %% @end %%-------------------------------------------------------------------- --spec maybe_delete(ne_binary(), [ne_binary()]) -> boolean(). +-spec maybe_delete(kz_term:ne_binary(), [kz_term:ne_binary()]) -> boolean(). maybe_delete(AccountMODb, AccountIds) -> AccountId = kz_util:format_account_id(AccountMODb, 'raw'), IsOrphaned = not lists:member(AccountId, AccountIds), delete_if_orphaned(AccountMODb, IsOrphaned). --spec delete_if_orphaned(ne_binary(), boolean()) -> boolean(). +-spec delete_if_orphaned(kz_term:ne_binary(), boolean()) -> boolean(). delete_if_orphaned(_AccountMODb, 'false') -> 'false'; delete_if_orphaned(AccountMODb, 'true') -> Succeeded = kz_datamgr:db_delete(AccountMODb), @@ -570,10 +570,10 @@ delete_if_orphaned(AccountMODb, 'true') -> %% @public --spec get_range(ne_binary(), gregorian_seconds(), gregorian_seconds()) -> - ne_binaries(). --spec get_range(ne_binary(), ne_binary(), gregorian_seconds(), gregorian_seconds()) -> - ne_binaries(). +-spec get_range(kz_term:ne_binary(), kz_time:gregorian_seconds(), kz_time:gregorian_seconds()) -> + kz_term:ne_binaries(). +-spec get_range(kz_term:ne_binary(), kz_term:ne_binary(), kz_time:gregorian_seconds(), kz_time:gregorian_seconds()) -> + kz_term:ne_binaries(). get_range(AccountId, From, To) -> get_range(<<"any">>, AccountId, From, To). @@ -588,17 +588,17 @@ get_range(Type, AccountId, From, To) -> kz_datamgr:db_exists(MODb, Type) ]. --type year_month_tuple() :: {kz_year(), kz_month()}. +-type year_month_tuple() :: {kz_time:year(), kz_time:month()}. %% @public --spec get_year_month_sequence(ne_binary(), year_month_tuple(), year_month_tuple()) -> - ne_binaries(). +-spec get_year_month_sequence(kz_term:ne_binary(), year_month_tuple(), year_month_tuple()) -> + kz_term:ne_binaries(). get_year_month_sequence(Account, From, To) -> get_year_month_sequence(Account, From, To, []). %% @public --spec get_year_month_sequence(ne_binary(), year_month_tuple(), year_month_tuple(), kz_proplist()) -> - ne_binaries(). +-spec get_year_month_sequence(kz_term:ne_binary(), year_month_tuple(), year_month_tuple(), kz_term:proplist()) -> + kz_term:ne_binaries(). get_year_month_sequence(Account, Tuple, Tuple, Range) -> ToMODbId = fun ({Year,Month}, Acc) -> [get_modb(Account, Year, Month)|Acc] end, lists:foldl(ToMODbId, [], [Tuple|Range]); diff --git a/core/kazoo_modb/src/kazoo_modb_maintenance.erl b/core/kazoo_modb/src/kazoo_modb_maintenance.erl index 98e679c74c4..8dc21efe0bc 100644 --- a/core/kazoo_modb/src/kazoo_modb_maintenance.erl +++ b/core/kazoo_modb/src/kazoo_modb_maintenance.erl @@ -44,9 +44,9 @@ ,{<<"pvt_vsn">>, <<"Version">>} ]). --spec delete_modbs(ne_binary()) -> 'ok' | 'no_return'. --spec delete_modbs(ne_binary(), boolean() | ne_binary()) -> 'ok' | 'no_return'. --spec delete_modbs(ne_binary() | kz_year(), ne_binary() | kz_month(), boolean()) -> 'ok' | 'no_return'. +-spec delete_modbs(kz_term:ne_binary()) -> 'ok' | 'no_return'. +-spec delete_modbs(kz_term:ne_binary(), boolean() | kz_term:ne_binary()) -> 'ok' | 'no_return'. +-spec delete_modbs(kz_term:ne_binary() | kz_time:year(), kz_term:ne_binary() | kz_time:month(), boolean()) -> 'ok' | 'no_return'. delete_modbs(Period) -> delete_modbs(Period, 'true'). @@ -79,18 +79,18 @@ delete_modbs(Year, Month, ShouldArchive) when is_integer(Year), io:format("request to delete future MODBs (~p~p) denied~n", [Year, Month]) end. --spec delete_older_modbs(kz_year(), kz_month(), ne_binaries(), boolean()) -> 'no_return'. +-spec delete_older_modbs(kz_time:year(), kz_time:month(), kz_term:ne_binaries(), boolean()) -> 'no_return'. delete_older_modbs(Year, Month, AccountModbs, ShouldArchive) -> Months = (Year * 12) + Month, _ = [delete_modb(AccountModb, ShouldArchive) || AccountModb <- AccountModbs, should_delete(AccountModb, Months)], 'no_return'. --spec should_delete(ne_binary(), pos_integer()) -> boolean(). +-spec should_delete(kz_term:ne_binary(), pos_integer()) -> boolean(). should_delete(AccountModb, Months) -> {_AccountId, ModYear, ModMonth} = kazoo_modb_util:split_account_mod(AccountModb), ((ModYear * 12) + ModMonth) =< Months. --spec delete_modb(ne_binary(), boolean()) -> 'ok'. +-spec delete_modb(kz_term:ne_binary(), boolean()) -> 'ok'. delete_modb(?MATCH_MODB_SUFFIX_UNENCODED(_,_,_) = AccountModb, ShouldArchive) -> delete_modb(kz_util:format_account_db(AccountModb), ShouldArchive); delete_modb(?MATCH_MODB_SUFFIX_ENCODED(_,_,_) = AccountModb, ShouldArchive) -> @@ -103,13 +103,13 @@ delete_modb(?MATCH_MODB_SUFFIX_ENCODED(_,_,_) = AccountModb, ShouldArchive) -> timer:sleep(5 * ?MILLISECONDS_IN_SECOND). -spec archive_modbs() -> 'no_return'. --spec archive_modbs(text()) -> 'no_return'. +-spec archive_modbs(kz_term:text()) -> 'no_return'. archive_modbs() -> do_archive_modbs(kapps_util:get_all_account_mods(), 'undefined'). archive_modbs(AccountId) -> do_archive_modbs(kapps_util:get_account_mods(AccountId), kz_term:to_binary(AccountId)). --spec do_archive_modbs(ne_binaries(), api_binary()) -> 'no_return'. +-spec do_archive_modbs(kz_term:ne_binaries(), kz_term:api_binary()) -> 'no_return'. do_archive_modbs(MODbs, AccountId) -> kz_util:put_callid(?MODULE), lists:foreach(fun kazoo_modb:maybe_archive_modb/1, MODbs), @@ -123,7 +123,7 @@ current_rollups() -> Accounts = kapps_util:get_all_accounts(), current_rollups(Accounts). --spec current_rollups(ne_binaries()) -> 'ok'. +-spec current_rollups(kz_term:ne_binaries()) -> 'ok'. current_rollups([]) -> 'ok'; current_rollups([Account|Accounts]) -> {Year, Month, _} = erlang:date(), @@ -156,24 +156,24 @@ verify_all_rollups() -> _ = lists:foldr(fun verify_db_rollup/2, {1, Total, [{'all_rollups', 'true'}]}, Accounts), 'ok'. --spec verify_db_rollup(ne_binary(), {pos_integer(), pos_integer(), kz_proplist()}) -> - {pos_integer(), pos_integer(), kz_proplist()}. +-spec verify_db_rollup(kz_term:ne_binary(), {pos_integer(), pos_integer(), kz_term:proplist()}) -> + {pos_integer(), pos_integer(), kz_term:proplist()}. verify_db_rollup(AccountDb, {Current, Total, Options}) -> io:format("verify rollup accounts (~p/~p) '~s'~n" ,[Current, Total, AccountDb]), verify_rollups(AccountDb, Options), {Current+1, Total, Options}. --spec verify_rollups(ne_binary()) -> 'ok'. +-spec verify_rollups(kz_term:ne_binary()) -> 'ok'. verify_rollups(Account) -> verify_rollups(Account, [{'all_rollups', 'true'}]). --spec verify_rollups(ne_binary(), kz_proplist()) -> 'ok'. +-spec verify_rollups(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. verify_rollups(Account, Options) -> {Year, Month, _} = erlang:date(), verify_rollups(Account, Year, Month, Options). --spec verify_rollups(ne_binary(), kz_year(), kz_month(), kz_proplist() | kz_json:object()) -> 'ok'. +-spec verify_rollups(kz_term:ne_binary(), kz_time:year(), kz_time:month(), kz_term:proplist() | kz_json:object()) -> 'ok'. verify_rollups(AccountDb, Year, Month, Options) when is_list(Options) -> AllRollups = props:get_value('all_rollups', Options), AccountId = kz_util:format_account_id(AccountDb, 'raw'), @@ -195,7 +195,7 @@ verify_rollups(AccountDb, Year, Month, JObj) -> PrevBalance = wht_util:previous_balance(AccountDb, PYear, PMonth), verify_rollups(AccountDb, Year, Month, JObj, PrevBalance). --spec verify_rollups(ne_binary(), kz_year(), kz_month(), kz_json:object(), kz_std_return()) -> 'ok'. +-spec verify_rollups(kz_term:ne_binary(), kz_time:year(), kz_time:month(), kz_json:object(), kz_term:std_return()) -> 'ok'. verify_rollups(AccountDb, Year, Month, JObj, {'ok', Balance}) -> AccountId = kz_util:format_account_id(AccountDb, 'raw'), case rollup_balance(JObj) of @@ -212,12 +212,12 @@ verify_rollups(AccountDb, Year, Month, _JObj, {'error', _R}) -> ,[AccountId, Year, Month, _R] ). --spec fix_rollup(ne_binary()) -> 'ok'. +-spec fix_rollup(kz_term:ne_binary()) -> 'ok'. fix_rollup(Account) -> {Year, Month, _} = erlang:date(), fix_rollup(Account, Year, Month). --spec fix_rollup(ne_binary(), kz_year(), kz_month()) -> 'ok'. +-spec fix_rollup(kz_term:ne_binary(), kz_time:year(), kz_time:month()) -> 'ok'. fix_rollup(Account, Year, Month) -> AccountId = kz_util:format_account_id(Account, 'raw'), Y = kz_term:to_integer(Year), @@ -240,14 +240,14 @@ rollup_accounts() -> _ = lists:foldr(fun rollup_account_fold/2, {1, Total}, Accounts), 'ok'. --spec rollup_account_fold(ne_binary(), {pos_integer(), pos_integer()}) -> +-spec rollup_account_fold(kz_term:ne_binary(), {pos_integer(), pos_integer()}) -> {pos_integer(), pos_integer()}. rollup_account_fold(AccountDb, {Current, Total}) -> io:format("rollup accounts (~p/~p) '~s'~n", [Current, Total, AccountDb]), _ = rollup_account(AccountDb), {Current + 1, Total}. --spec rollup_account(ne_binary()) -> 'ok'. +-spec rollup_account(kz_term:ne_binary()) -> 'ok'. rollup_account(Account) -> AccountId = kz_util:format_account_id(Account, 'raw'), case wht_util:current_balance(AccountId) of @@ -256,7 +256,7 @@ rollup_account(Account) -> io:format("failed to get current balance for ~s: ~p~n", [AccountId, _R]) end. --spec rollup_account(ne_binary(), integer()) -> 'ok'. +-spec rollup_account(kz_term:ne_binary(), integer()) -> 'ok'. rollup_account(AccountId, Balance) -> AccountMODb = kazoo_modb:get_modb(AccountId), io:format("rolling up ~p credits to ~s~n", [Balance, AccountMODb]), @@ -270,7 +270,7 @@ rollup_balance(JObj) -> <<"debit">> -> Balance * -1 end. --spec dump_transactions(ne_binary(), ne_binary(), ne_binary()) -> 'no_return' | 'ok'. +-spec dump_transactions(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'no_return' | 'ok'. dump_transactions(Account, Year, Month) -> AccountId = kz_util:format_account_id(Account, 'raw'), View = <<"transactions/by_timestamp">>, @@ -290,7 +290,7 @@ dump_transactions(Account, Year, Month) -> io:format("unable to get transactions for ~s (~p-~p): ~p", [AccountId, Month, Year, _R]) end. --spec fix_value_map(ne_binary(), kz_json:term()) -> kz_json:term(). +-spec fix_value_map(kz_term:ne_binary(), kz_json:term()) -> kz_json:term(). fix_value_map(<<"pvt_amount">> = Key, Value) -> {Key, wht_util:units_to_dollars(Value)}; fix_value_map(<<"pvt_modified">> = Key, Value) -> {Key, kz_time:rfc1036(Value)}; fix_value_map(<<"pvt_created">> = Key, Value) -> {Key, kz_time:rfc1036(Value)}; diff --git a/core/kazoo_modb/src/kazoo_modb_migrate_maintenance.erl b/core/kazoo_modb/src/kazoo_modb_migrate_maintenance.erl index 087ee4b9be5..9dfdeb5bd4b 100644 --- a/core/kazoo_modb/src/kazoo_modb_migrate_maintenance.erl +++ b/core/kazoo_modb/src/kazoo_modb_migrate_maintenance.erl @@ -25,14 +25,14 @@ migrate() -> lists:foldl(fun(A, C) -> migrate_account_fold(A, C, Total) end, 1, AccountIds), 'ok'. --spec migrate_account_fold(ne_binary(), non_neg_integer(), non_neg_integer()) -> non_neg_integer(). +-spec migrate_account_fold(kz_term:ne_binary(), non_neg_integer(), non_neg_integer()) -> non_neg_integer(). migrate_account_fold(AccountId, Current, Total) -> io:format("(~p/~p) migrating items within account '~s'~n", [Current, Total, AccountId]), _ = migrate_account(AccountId), io:format("[~s] finished migrating items~n~n", [AccountId]), Current + 1. --spec migrate_account(ne_binary()) -> 'ok'. +-spec migrate_account(kz_term:ne_binary()) -> 'ok'. migrate_account(Account) -> lists:foreach(fun(Fun) -> Fun(Account) end ,[fun migrate_voicemails/1 @@ -43,11 +43,11 @@ migrate_account(Account) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec get_view_count(ne_binary(), ne_binary()) -> non_neg_integer(). +-spec get_view_count(kz_term:ne_binary(), kz_term:ne_binary()) -> non_neg_integer(). get_view_count(AccountId, View) -> get_view_count(AccountId, View, 2). --spec get_view_count(ne_binary(), ne_binary(), integer()) -> non_neg_integer(). +-spec get_view_count(kz_term:ne_binary(), kz_term:ne_binary(), integer()) -> non_neg_integer(). get_view_count(_AccountId, _View, Retry) when Retry < 0 -> io:format("[~s] failed to fetch view ~s count~n", [_AccountId, _View]), 0; @@ -62,7 +62,7 @@ get_view_count(AccountId, View, Retry) -> get_view_count(AccountDb, View, Retry-1) end. --spec next_skip(non_neg_integer(), non_neg_integer(), kz_proplist()) -> kz_proplist(). +-spec next_skip(non_neg_integer(), non_neg_integer(), kz_term:proplist()) -> kz_term:proplist(). next_skip(0, Skip, ViewOptions) -> props:set_value('skip', Skip, ViewOptions); next_skip(Remaining, Skip, ViewOptions) -> case Remaining < props:get_value(limit, ViewOptions) of @@ -70,7 +70,7 @@ next_skip(Remaining, Skip, ViewOptions) -> false -> props:set_value('skip', Skip, ViewOptions) end. --spec maps_update_with(ne_binary(), fun((any()) -> any()), any(), map()) -> map(). +-spec maps_update_with(kz_term:ne_binary(), fun((any()) -> any()), any(), map()) -> map(). maps_update_with(Key, UpdateFun, Init, Map) -> try maps:get(Key, Map) of OldValue -> maps:put(Key, UpdateFun(OldValue), Map) @@ -81,13 +81,13 @@ maps_update_with(Key, UpdateFun, Init, Map) -> %%%=================================================================== %%% Voicemail Migration %%%=================================================================== --spec migrate_voicemails(ne_binary()) -> 'ok'. +-spec migrate_voicemails(kz_term:ne_binary()) -> 'ok'. migrate_voicemails(Account) -> AccountId = kz_util:format_account_id(Account, 'raw'), Total = get_view_count(AccountId, <<"vmboxes/legacy_msg_by_timestamp">>), migrate_voicemails(AccountId, Total). --spec migrate_voicemails(ne_binary(), non_neg_integer()) -> 'ok'. +-spec migrate_voicemails(kz_term:ne_binary(), non_neg_integer()) -> 'ok'. migrate_voicemails(_AccountId, 0) -> io:format("[~s] no voicemail messages found~n", [_AccountId]); migrate_voicemails(AccountId, Total) -> @@ -101,7 +101,7 @@ migrate_voicemails(AccountId, Total) -> }, migrate_voicemails(AccountId, Stats, [{'limit', Limit}]). --spec migrate_voicemails(ne_binary(), map(), kz_proplist()) -> 'ok'. +-spec migrate_voicemails(kz_term:ne_binary(), map(), kz_term:proplist()) -> 'ok'. migrate_voicemails(AccountId, #{total := Total, processed := Processed, moved := Moved, skip := Skip}=Stats, ViewOptions) -> AccountDb = kz_util:format_account_db(AccountId), case kz_datamgr:get_results(AccountDb, <<"vmboxes/legacy_msg_by_timestamp">>, ViewOptions) of @@ -137,7 +137,7 @@ migrate_voicemails(AccountId, #{total := Total, processed := Processed, moved := io:format("[~s] failed to fetch voicemail messages: ~p~n~n", [AccountId, _R]) end. --spec move_vm_to_modb(ne_binary(), kz_json:object(), map()) -> map(). +-spec move_vm_to_modb(kz_term:ne_binary(), kz_json:object(), map()) -> map(). move_vm_to_modb(AccountId, LegacyVMJObj, #{total := Total ,processed := Processed ,moved := Moved @@ -188,7 +188,7 @@ move_vm_to_modb(AccountId, LegacyVMJObj, #{total := Total } end. --spec transform_vm_doc_funs(ne_binary(), kz_json:object()) -> {ne_binary(), ne_binary(), update_funs()}. +-spec transform_vm_doc_funs(kz_term:ne_binary(), kz_json:object()) -> {kz_term:ne_binary(), kz_term:ne_binary(), update_funs()}. transform_vm_doc_funs(AccountDb, LegacyVMJObj) -> Metadata = kz_json:get_value(<<"metadata">>, LegacyVMJObj), Timestamp = kz_json:get_integer_value(<<"timestamp">>, Metadata), @@ -213,7 +213,7 @@ transform_vm_doc_funs(AccountDb, LegacyVMJObj) -> ] }. --spec update_mailboxes(ne_binary(), map()) -> 'ok'. +-spec update_mailboxes(kz_term:ne_binary(), map()) -> 'ok'. update_mailboxes(AccountId, Map) -> BoxIds = maps:keys(Map), @@ -254,13 +254,13 @@ update_message_array(BoxJObj, ResultSet) -> %%% Voicemail Migration %%%=================================================================== --spec migrate_cdrs(ne_binary()) -> 'ok'. +-spec migrate_cdrs(kz_term:ne_binary()) -> 'ok'. migrate_cdrs(Account) -> AccountId = kz_util:format_account_id(Account, 'raw'), Total = get_view_count(AccountId, <<"cdrs/crossbar_listing">>), migrate_cdrs(AccountId, Total). --spec migrate_cdrs(ne_binary(), non_neg_integer()) -> 'ok'. +-spec migrate_cdrs(kz_term:ne_binary(), non_neg_integer()) -> 'ok'. migrate_cdrs(_AccountId, 0) -> io:format("[~s] no cdrs found~n", [_AccountId]); migrate_cdrs(AccountId, Total) -> @@ -273,7 +273,7 @@ migrate_cdrs(AccountId, Total) -> }, migrate_cdrs(AccountId, Stats, [{'limit', Limit}, include_docs]). --spec migrate_cdrs(ne_binary(), map(), kz_proplist()) -> 'ok'. +-spec migrate_cdrs(kz_term:ne_binary(), map(), kz_term:proplist()) -> 'ok'. migrate_cdrs(AccountId, #{total := Total, processed := Processed, moved := Moved, skip := Skip}=Stats, ViewOptions) -> AccountDb = kz_util:format_account_db(AccountId), case kz_datamgr:get_results(AccountDb, <<"cdrs/crossbar_listing">>, ViewOptions) of @@ -313,12 +313,12 @@ migrate_cdrs(AccountId, #{total := Total, processed := Processed, moved := Moved io:format("[~s] failed to fetch cdrs: ~p~n", [AccountId, _R]) end. --spec move_cdrs_to_modb(ne_binary(), kz_json:objects()) -> ne_binaries(). +-spec move_cdrs_to_modb(kz_term:ne_binary(), kz_json:objects()) -> kz_term:ne_binaries(). move_cdrs_to_modb(AccountId, ViewResults) -> Mapped = map_tranform_cdrs(AccountId, ViewResults, maps:new()), maps:fold(fun do_move_cdrs/3, [], Mapped). --spec map_tranform_cdrs(ne_binary(), kz_json:objects(), map()) -> map(). +-spec map_tranform_cdrs(kz_term:ne_binary(), kz_json:objects(), map()) -> map(). map_tranform_cdrs(_AccountId, [], Map) -> Map; map_tranform_cdrs(AccountId, [VR|VRs], Map) -> AccountDb = kz_util:format_account_db(AccountId), @@ -340,7 +340,7 @@ map_tranform_cdrs(AccountId, [VR|VRs], Map) -> NewMap = maps_update_with(NewDb, fun(Old) -> [NewDoc|Old] end, [NewDoc], Map), map_tranform_cdrs(AccountId, VRs, NewMap). --spec do_move_cdrs(ne_binary(), kz_json:object(), ne_binaries()) -> ne_binaries(). +-spec do_move_cdrs(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). do_move_cdrs(MODB, Docs, MovedAcc) -> _AccountId = kz_util:format_account_id(MODB), case kz_datamgr:save_docs(MODB, Docs) of @@ -350,7 +350,7 @@ do_move_cdrs(MODB, Docs, MovedAcc) -> MovedAcc end. --spec check_for_failure(kz_json:objects(), ne_binaries()) -> ne_binaries(). +-spec check_for_failure(kz_json:objects(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). check_for_failure(JObjs, MovedAcc) -> Fun = fun(J, Acc) -> case kz_json:get_value(<<"error">>, J) of diff --git a/core/kazoo_modb/src/kazoo_modb_util.erl b/core/kazoo_modb/src/kazoo_modb_util.erl index c03eaab164a..75dc675fd06 100644 --- a/core/kazoo_modb/src/kazoo_modb_util.erl +++ b/core/kazoo_modb/src/kazoo_modb_util.erl @@ -16,9 +16,9 @@ ,modb_id/0, modb_id/1, modb_id/2, modb_id/3 ]). --spec prev_year_month(ne_binary()) -> {kz_year(), kz_month()}. --spec prev_year_month(ne_binary() | kz_year(), ne_binary() | kz_month()) -> - {kz_year(), kz_month()}. +-spec prev_year_month(kz_term:ne_binary()) -> {kz_time:year(), kz_time:month()}. +-spec prev_year_month(kz_term:ne_binary() | kz_time:year(), kz_term:ne_binary() | kz_time:month()) -> + {kz_time:year(), kz_time:month()}. prev_year_month(AccountMod) -> {_AccountId, Year, Month} = split_account_mod(AccountMod), prev_year_month(Year, Month). @@ -34,7 +34,7 @@ prev_year_month_bin(Y, M) -> {Year, Month} = prev_year_month(Y, M), {kz_term:to_binary(Year), kz_date:pad_month(Month)}. --spec prev_year_month_mod(ne_binary()) -> ne_binary(). +-spec prev_year_month_mod(kz_term:ne_binary()) -> kz_term:ne_binary(). prev_year_month_mod(?MATCH_MODB_SUFFIX_RAW(AccountId, Year, Month)) -> {PrevYear, PrevMonth} = prev_year_month_bin(Year, Month), ?MATCH_MODB_SUFFIX_RAW(AccountId, PrevYear, PrevMonth); @@ -48,7 +48,7 @@ prev_year_month_mod(?MATCH_MODB_SUFFIX_encoded(A, B, Rest, Year, Month)) -> {PrevYear, PrevMonth} = prev_year_month_bin(Year, Month), ?MATCH_MODB_SUFFIX_encoded(A, B, Rest, PrevYear, PrevMonth). --spec split_account_mod(ne_binary()) -> {ne_binary(), kz_year(), kz_month()}. +-spec split_account_mod(kz_term:ne_binary()) -> {kz_term:ne_binary(), kz_time:year(), kz_time:month()}. split_account_mod(?MATCH_MODB_SUFFIX_RAW(Account,Year,Month)) -> {kz_util:format_account_id(Account, 'raw') ,kz_term:to_integer(Year) @@ -67,14 +67,14 @@ split_account_mod(?MATCH_MODB_SUFFIX_ENCODED(Account,Year,Month)) -> %% @doc %% Equivalent to `modb_id/3` --spec modb_id() -> ne_binary(). +-spec modb_id() -> kz_term:ne_binary(). modb_id() -> {Year, Month, _} = erlang:date(), modb_id(Year, Month, kz_binary:rand_hex(16)). %% @doc %% Equivalent to `modb_id/3` --spec modb_id(non_neg_integer() | ne_binary()) -> ne_binary(). +-spec modb_id(non_neg_integer() | kz_term:ne_binary()) -> kz_term:ne_binary(). modb_id(Timestamp) when is_integer(Timestamp) -> {{Year, Month, _}, _} = calendar:gregorian_seconds_to_datetime(Timestamp), modb_id(Year, Month, kz_binary:rand_hex(16)); @@ -84,13 +84,13 @@ modb_id(Id) when is_binary(Id) -> %% @doc %% Equivalent to `modb_id/3` --spec modb_id(ne_binary() | kz_year(), ne_binary() | kz_month()) -> ne_binary(). +-spec modb_id(kz_term:ne_binary() | kz_time:year(), kz_term:ne_binary() | kz_time:month()) -> kz_term:ne_binary(). modb_id(Year, Month) -> modb_id(Year, Month, kz_binary:rand_hex(16)). %% @doc %% Format a document id prefix with year and month --spec modb_id(ne_binary() | kz_year(), ne_binary() | kz_month(), ne_binary()) -> ne_binary(). +-spec modb_id(kz_term:ne_binary() | kz_time:year(), kz_term:ne_binary() | kz_time:month(), kz_term:ne_binary()) -> kz_term:ne_binary(). modb_id(Year, Month, Id) -> <<(kz_term:to_binary(Year))/binary ,(kz_date:pad_month(Month))/binary diff --git a/core/kazoo_number_manager/src/carriers/knm_bandwidth.erl b/core/kazoo_number_manager/src/carriers/knm_bandwidth.erl index d744fb0ac86..c4545e09d90 100644 --- a/core/kazoo_number_manager/src/carriers/knm_bandwidth.erl +++ b/core/kazoo_number_manager/src/carriers/knm_bandwidth.erl @@ -97,8 +97,8 @@ is_local() -> 'false'. %% Check with carrier if these numbers are registered with it. %% @end %%-------------------------------------------------------------------- --spec check_numbers(ne_binaries()) -> {ok, kz_json:object()} | - {error, any()}. +-spec check_numbers(kz_term:ne_binaries()) -> {ok, kz_json:object()} | + {error, any()}. check_numbers(_Numbers) -> {error, not_implemented}. %%-------------------------------------------------------------------- @@ -108,7 +108,7 @@ check_numbers(_Numbers) -> {error, not_implemented}. %% in a rate center %% @end %%-------------------------------------------------------------------- --spec find_numbers(ne_binary(), pos_integer(), knm_carriers:options()) -> +-spec find_numbers(kz_term:ne_binary(), pos_integer(), knm_carriers:options()) -> {'ok', knm_number:knm_numbers()} | {'error', any()}. find_numbers(<<"+", Rest/binary>>, Quanity, Options) -> @@ -133,7 +133,7 @@ find_numbers(Search, Quanity, Options) -> {'ok', Xml} -> process_numbers_search_resp(Xml, Options) end. --spec process_numbers_search_resp(xml_el(), knm_search:options()) -> +-spec process_numbers_search_resp(kz_types:xml_el(), knm_search:options()) -> {'ok', list()}. process_numbers_search_resp(Xml, Options) -> TelephoneNumbers = "/numberSearchResponse/telephoneNumbers/telephoneNumber", @@ -144,7 +144,7 @@ process_numbers_search_resp(Xml, Options) -> ] }. --spec found_number_to_KNM(xml_el() | xml_els(), ne_binary()) -> tuple(). +-spec found_number_to_KNM(kz_types:xml_el() | kz_types:xml_els(), kz_term:ne_binary()) -> tuple(). found_number_to_KNM(Found, QID) -> JObj = number_search_response_to_json(Found), Num = kz_json:get_value(<<"e164">>, JObj), @@ -241,7 +241,7 @@ should_lookup_cnam() -> 'true'. %% given verb (purchase, search, provision, ect). %% @end %%-------------------------------------------------------------------- --spec make_numbers_request(atom(), kz_proplist()) -> +-spec make_numbers_request(atom(), kz_term:proplist()) -> {'ok', any()} | {'error', any()}. @@ -347,7 +347,7 @@ number_order_response_to_json(Xml) -> %% Convert a number search response XML entity to json %% @end %%-------------------------------------------------------------------- --spec number_search_response_to_json(xml_el() | xml_els()) -> kz_json:object(). +-spec number_search_response_to_json(kz_types:xml_el() | kz_types:xml_els()) -> kz_json:object(). number_search_response_to_json([]) -> kz_json:new(); number_search_response_to_json([Xml]) -> @@ -363,7 +363,7 @@ number_search_response_to_json(Xml) -> ,{<<"rate_center">>, rate_center_to_json(xmerl_xpath:string("rateCenter", Xml))} ]). --spec get_cleaned(kz_deeplist(), xml_el()) -> api_binary(). +-spec get_cleaned(kz_term:deeplist(), kz_types:xml_el()) -> kz_term:api_binary(). get_cleaned(Path, Xml) -> case kz_xml:get_value(Path, Xml) of 'undefined' -> 'undefined'; @@ -395,9 +395,9 @@ rate_center_to_json(Xml) -> %% error text %% @end %%-------------------------------------------------------------------- --spec verify_response(xml_el()) -> - {'ok', xml_el()} | - {'error', api_binary() | ne_binaries()}. +-spec verify_response(kz_types:xml_el()) -> + {'ok', kz_types:xml_el()} | + {'error', kz_term:api_binary() | kz_term:ne_binaries()}. verify_response(Xml) -> case get_cleaned("/*/status/text()", Xml) of <<"success">> -> diff --git a/core/kazoo_number_manager/src/carriers/knm_bandwidth2.erl b/core/kazoo_number_manager/src/carriers/knm_bandwidth2.erl index 211c11c39f3..d454b4ae0c7 100644 --- a/core/kazoo_number_manager/src/carriers/knm_bandwidth2.erl +++ b/core/kazoo_number_manager/src/carriers/knm_bandwidth2.erl @@ -130,8 +130,8 @@ is_number_billable(_Number) -> 'true'. %% Check with carrier if these numbers are registered with it. %% @end %%-------------------------------------------------------------------- --spec check_numbers(ne_binaries()) -> {ok, kz_json:object()} | - {error, any()}. +-spec check_numbers(kz_term:ne_binaries()) -> {ok, kz_json:object()} | + {error, any()}. check_numbers(_Numbers) -> {error, not_implemented}. %%-------------------------------------------------------------------- @@ -141,7 +141,7 @@ check_numbers(_Numbers) -> {error, not_implemented}. %% in a rate center %% @end %%-------------------------------------------------------------------- --spec find_numbers(ne_binary(), pos_integer(), knm_search:options()) -> search_ret(). +-spec find_numbers(kz_term:ne_binary(), pos_integer(), knm_search:options()) -> search_ret(). find_numbers(<<"+", Rest/binary>>, Quantity, Options) -> find_numbers(Rest, Quantity, Options); @@ -178,7 +178,7 @@ find_numbers(Search, Quantity, Options) -> Result = search(Search, Params), process_search_response(Result, Options). --spec process_tollfree_search_response(xml_el(), knm_search:options()) -> {'ok', list()}. +-spec process_tollfree_search_response(kz_types:xml_el(), knm_search:options()) -> {'ok', list()}. process_tollfree_search_response(Result, Options) -> QID = knm_search:query_id(Options), Found = [N @@ -187,7 +187,7 @@ process_tollfree_search_response(Result, Options) -> ], {'ok', Found}. --spec process_search_response(xml_el(), knm_search:options()) -> {'ok', list()}. +-spec process_search_response(kz_types:xml_el(), knm_search:options()) -> {'ok', list()}. process_search_response(Result, Options) -> QID = knm_search:query_id(Options), Found = [N @@ -239,7 +239,7 @@ acquire_number(Number) -> end end. --spec check_order(api_binary(), api_binary(), xml_el(), knm_number:knm_number(), knm_number:knm_number()) -> knm_number:knm_number(). +-spec check_order(kz_term:api_binary(), kz_term:api_binary(), kz_types:xml_el(), knm_number:knm_number(), knm_number:knm_number()) -> knm_number:knm_number(). check_order(OrderId, <<"RECEIVED">>, _Response, PhoneNumber, Number) -> timer:sleep(?BW2_ORDER_POLL_INTERVAL), Url = ["orders/", kz_term:to_list(OrderId)], @@ -271,11 +271,11 @@ check_order(_OrderId, OrderStatus, _Response, PhoneNumber, _Number) -> Num = to_bandwidth2(knm_phone_number:number(PhoneNumber)), knm_errors:by_carrier(?MODULE, Error, Num). --spec to_bandwidth2(ne_binary()) -> ne_binary(). +-spec to_bandwidth2(kz_term:ne_binary()) -> kz_term:ne_binary(). to_bandwidth2(<<"+1", Number/binary>>) -> Number; to_bandwidth2(Number) -> Number. --spec from_bandwidth2(ne_binary()) -> ne_binary(). +-spec from_bandwidth2(kz_term:ne_binary()) -> kz_term:ne_binary(). from_bandwidth2(<<"+", _/binary>> = Number) -> Number; from_bandwidth2(Number) -> <<"+1", Number/binary>>. @@ -298,7 +298,7 @@ sites() -> lists:foreach(fun process_site/1, Sites), io:format("done.~n"). --spec process_site(xml_el()) -> 'ok'. +-spec process_site(kz_types:xml_el()) -> 'ok'. process_site(Site) -> Id = kz_xml:get_value("Id/text()", Site), Name = kz_xml:get_value("Name/text()", Site), @@ -313,7 +313,7 @@ peers(SiteId) -> lists:foreach(fun process_peer/1, Peers), io:format("done.~n"). --spec process_peer(xml_el()) -> 'ok'. +-spec process_peer(kz_types:xml_el()) -> 'ok'. process_peer(Peer) -> Id = kz_xml:get_value("PeerId/text()", Peer), Name = kz_xml:get_value("PeerName/text()", Peer), @@ -328,16 +328,16 @@ url(RelativePath) -> | RelativePath ]). --type api_res() :: {'ok', xml_el()} | {'error', atom()}. +-type api_res() :: {'ok', kz_types:xml_el()} | {'error', atom()}. --spec search(ne_binary(), [nonempty_string()]) -> xml_el(). +-spec search(kz_term:ne_binary(), [nonempty_string()]) -> kz_types:xml_el(). search(Num, Params) -> case api_get(url(["availableNumbers?" | Params])) of {'ok', Results} -> Results; {'error', Reason} -> knm_errors:by_carrier(?MODULE, Reason, Num) end. --spec auth() -> {'basic_auth', {ne_binary(), ne_binary()}}. +-spec auth() -> {'basic_auth', {kz_term:ne_binary(), kz_term:ne_binary()}}. auth() -> {'basic_auth', {?BW2_API_USERNAME, ?BW2_API_PASSWORD}}. @@ -449,7 +449,7 @@ handle_response({'error', _}=E) -> %% Convert a number order response to json %% @end %%-------------------------------------------------------------------- --spec number_order_response_to_json(xml_els() | xml_el()) -> kz_json:object(). +-spec number_order_response_to_json(kz_types:xml_els() | kz_types:xml_el()) -> kz_json:object(). number_order_response_to_json([]) -> kz_json:new(); number_order_response_to_json([Xml]) -> @@ -466,7 +466,7 @@ number_order_response_to_json(Xml) -> ). %% @private --spec search_response_to_KNM(xml_els() | xml_el(), ne_binary()) -> tuple(). +-spec search_response_to_KNM(kz_types:xml_els() | kz_types:xml_el(), kz_term:ne_binary()) -> tuple(). search_response_to_KNM([Xml], QID) -> search_response_to_KNM(Xml, QID); search_response_to_KNM(Xml, QID) -> @@ -479,7 +479,7 @@ search_response_to_KNM(Xml, QID) -> {QID, {Num, ?MODULE, ?NUMBER_STATE_DISCOVERY, JObj}}. %% @private --spec tollfree_search_response_to_KNM(xml_el(), ne_binary()) -> tuple(). +-spec tollfree_search_response_to_KNM(kz_types:xml_el(), kz_term:ne_binary()) -> tuple(). tollfree_search_response_to_KNM(Xml, QID) -> Num = from_bandwidth2(kz_xml:get_value("//TelephoneNumber/text()", Xml)), {QID, {Num, ?MODULE, ?NUMBER_STATE_DISCOVERY, kz_json:new()}}. @@ -490,7 +490,7 @@ tollfree_search_response_to_KNM(Xml, QID) -> %% Convert a rate center XML entity to json %% @end %%-------------------------------------------------------------------- --spec rate_center_to_json(xml_els() | xml_el()) -> kz_json:object(). +-spec rate_center_to_json(kz_types:xml_els() | kz_types:xml_el()) -> kz_json:object(). rate_center_to_json([]) -> kz_json:new(); rate_center_to_json([Xml]) -> @@ -512,8 +512,8 @@ rate_center_to_json(Xml) -> %% error text %% @end %%-------------------------------------------------------------------- --spec verify_response(xml_el()) -> {'ok', xml_el()} | - {'error', any()}. +-spec verify_response(kz_types:xml_el()) -> {'ok', kz_types:xml_el()} | + {'error', any()}. verify_response(Xml) -> NPAPath = "count(//TelephoneNumberDetailList/TelephoneNumberDetail)", TollFreePath = "count(//TelephoneNumberList/TelephoneNumber)", @@ -538,7 +538,7 @@ verify_response(Xml) -> {'error', Reason} end. --spec validate_xpath_value(api_binary() | {atom(), atom(), non_neg_integer()}) -> boolean(). +-spec validate_xpath_value(kz_term:api_binary() | {atom(), atom(), non_neg_integer()}) -> boolean(). validate_xpath_value('undefined') -> 'false'; validate_xpath_value(<<>>) -> 'false'; validate_xpath_value({'xmlObj', 'number', Num}) -> Num > 0; diff --git a/core/kazoo_number_manager/src/carriers/knm_carriers.erl b/core/kazoo_number_manager/src/carriers/knm_carriers.erl index 46daf856524..75ab9f1c36b 100644 --- a/core/kazoo_number_manager/src/carriers/knm_carriers.erl +++ b/core/kazoo_number_manager/src/carriers/knm_carriers.erl @@ -58,24 +58,24 @@ -ifdef(TEST). -type option() :: {'quantity', pos_integer()} | - {'carriers', ne_binaries()} | - {'phonebook_url', ne_binary()} | + {'carriers', kz_term:ne_binaries()} | + {'phonebook_url', kz_term:ne_binary()} | {'tollfree', boolean()} | - {'prefix', ne_binary()} | + {'prefix', kz_term:ne_binary()} | {'country', knm_util:country_iso3166a2()} | {'offset', non_neg_integer()} | {'blocks', boolean()} | - {'account_id', ne_binary()} | - {'reseller_id', ne_binary()}. + {'account_id', kz_term:ne_binary()} | + {'reseller_id', kz_term:ne_binary()}. -else. -type option() :: {'quantity', pos_integer()} | - {'prefix', ne_binary()} | - {'dialcode', ne_binary()} | + {'prefix', kz_term:ne_binary()} | + {'dialcode', kz_term:ne_binary()} | {'country', knm_util:country_iso3166a2()} | {'offset', non_neg_integer()} | {'blocks', boolean()} | - {'account_id', ne_binary()} | - {'reseller_id', ne_binary()}. + {'account_id', kz_term:ne_binary()} | + {'reseller_id', kz_term:ne_binary()}. -endif. -type options() :: [option()]. -export_type([option/0, options/0]). @@ -87,7 +87,7 @@ %% Normalize then query the various providers for available numbers. %% @end %%-------------------------------------------------------------------- --spec check(ne_binaries()) -> kz_json:object(). +-spec check(kz_term:ne_binaries()) -> kz_json:object(). check(Numbers) -> Nums = lists:usort([knm_converters:normalize(Num) || Num <- Numbers]), lager:info("attempting to check ~p ", [Nums]), @@ -120,7 +120,7 @@ check_numbers(Module, Nums) -> %% Create a list of all carrier modules available to a subaccount. %% @end %%-------------------------------------------------------------------- --spec available_carriers(options()) -> atoms(). +-spec available_carriers(options()) -> kz_term:atoms(). -ifdef(TEST). available_carriers(Options) -> case props:get_value('carriers', Options) of @@ -132,7 +132,7 @@ available_carriers(Options) -> get_available_carriers(Options). -endif. --spec get_available_carriers(options()) -> atoms(). +-spec get_available_carriers(options()) -> kz_term:atoms(). get_available_carriers(Options) -> case account_id(Options) =:= undefined orelse reseller_id(Options) =:= undefined @@ -144,11 +144,11 @@ get_available_carriers(Options) -> keep_only_reachable(First ++ (?CARRIER_MODULES(ResellerId) -- First)) end. --spec default_carriers() -> atoms(). +-spec default_carriers() -> kz_term:atoms(). default_carriers() -> keep_only_reachable(?DEFAULT_CARRIER_MODULES). --spec default_carrier() -> ne_binary(). +-spec default_carrier() -> kz_term:ne_binary(). default_carrier() -> ?DEFAULT_CARRIER_MODULE. @@ -158,7 +158,7 @@ default_carrier() -> %% List all carrier modules. %% @end %%-------------------------------------------------------------------- --spec all_modules() -> ne_binaries(). +-spec all_modules() -> kz_term:ne_binaries(). all_modules() -> [<<"knm_bandwidth2">> ,<<"knm_bandwidth">> @@ -182,7 +182,7 @@ all_modules() -> %% Get information on the available carriers %% @end %%-------------------------------------------------------------------- --spec info(api_ne_binary(), api_ne_binary(), api_ne_binary()) -> kz_json:object(). +-spec info(kz_term:api_ne_binary(), kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> kz_json:object(). info(AuthAccountId, AccountId, ResellerId) -> AvailableCarriers = available_carriers([{account_id, AccountId} ,{reseller_id, ResellerId} @@ -210,14 +210,14 @@ info_fold(Module, Info=#{?CARRIER_INFO_MAX_PREFIX := MaxPrefix}) -> Info end. --spec usable_carriers() -> ne_binaries(). +-spec usable_carriers() -> kz_term:ne_binaries(). usable_carriers() -> Modules = all_modules() -- [?CARRIER_RESERVED ,?CARRIER_RESERVED_RESELLER ], [CarrierName || <<"knm_",CarrierName/binary>> <- Modules]. --spec allowed_creation_states(api_ne_binary()) -> ne_binaries(). +-spec allowed_creation_states(kz_term:api_ne_binary()) -> kz_term:ne_binaries(). -ifdef(TEST). allowed_creation_states(AccountId=?RESELLER_ACCOUNT_ID) -> AccountJObj = kz_account:set_allow_number_additions(?RESELLER_ACCOUNT_DOC, true), @@ -252,7 +252,7 @@ acquire(Number) -> DryRun = knm_phone_number:dry_run(PhoneNumber), acquire(Number, Module, DryRun). --spec acquire(knm_number:knm_number(), api_ne_binary(), boolean()) -> +-spec acquire(knm_number:knm_number(), kz_term:api_ne_binary(), boolean()) -> knm_number:knm_number(). acquire(Number, 'undefined', _DryRun) -> knm_errors:carrier_not_specified(Number); @@ -293,14 +293,14 @@ disconnect(Number) -> Number end. --spec prefix(options()) -> ne_binary(). --spec prefix(options(), ne_binary()) -> ne_binary(). +-spec prefix(options()) -> kz_term:ne_binary(). +-spec prefix(options(), kz_term:ne_binary()) -> kz_term:ne_binary(). prefix(Options) -> props:get_ne_binary_value('prefix', Options). prefix(Options, Default) -> props:get_ne_binary_value('prefix', Options, Default). --spec dialcode(options()) -> ne_binary(). +-spec dialcode(options()) -> kz_term:ne_binary(). dialcode(Options) -> props:get_ne_binary_value('dialcode', Options). @@ -321,11 +321,11 @@ offset(Options) -> blocks(Options) -> props:get_value('blocks', Options). --spec account_id(options()) -> api_ne_binary(). +-spec account_id(options()) -> kz_term:api_ne_binary(). account_id(Options) -> props:get_value('account_id', Options). --spec reseller_id(options()) -> api_ne_binary(). +-spec reseller_id(options()) -> kz_term:api_ne_binary(). reseller_id(Options) -> props:get_value('reseller_id', Options). @@ -354,7 +354,7 @@ is_number_billable(PhoneNumber) -> %% Note: a non-local (foreign) carrier module makes HTTP requests. %% @end %%-------------------------------------------------------------------- --spec is_local(ne_binary()) -> boolean(). +-spec is_local(kz_term:ne_binary()) -> boolean(). is_local(Carrier) -> try apply(Carrier, is_local, []) catch @@ -368,7 +368,7 @@ is_local(Carrier) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec apply(module() | ne_binary() | knm_number:knm_number(), atom(), list()) -> any(). +-spec apply(module() | kz_term:ne_binary() | knm_number:knm_number(), atom(), list()) -> any(). apply(Module, FName, Args) when is_atom(Module), Module =/= undefined -> lager:debug("contacting carrier ~s for ~s", [Module, FName]), erlang:apply(Module, FName, Args); @@ -384,7 +384,7 @@ apply(Number, FName, Args) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec keep_only_reachable([ne_binary()]) -> atoms(). +-spec keep_only_reachable([kz_term:ne_binary()]) -> kz_term:atoms(). keep_only_reachable(ModuleNames) -> ?LOG_DEBUG("resolving carrier modules: ~p", [ModuleNames]), [Module diff --git a/core/kazoo_number_manager/src/carriers/knm_inum.erl b/core/kazoo_number_manager/src/carriers/knm_inum.erl index 2e312026997..5b34569b54c 100644 --- a/core/kazoo_number_manager/src/carriers/knm_inum.erl +++ b/core/kazoo_number_manager/src/carriers/knm_inum.erl @@ -54,8 +54,8 @@ is_local() -> 'true'. %% Check with carrier if these numbers are registered with it. %% @end %%-------------------------------------------------------------------- --spec check_numbers(ne_binaries()) -> {ok, kz_json:object()} | - {error, any()}. +-spec check_numbers(kz_term:ne_binaries()) -> {ok, kz_json:object()} | + {error, any()}. check_numbers(_Numbers) -> {error, not_implemented}. %%-------------------------------------------------------------------- @@ -65,7 +65,7 @@ check_numbers(_Numbers) -> {error, not_implemented}. %% in a rate center %% @end %%-------------------------------------------------------------------- --spec find_numbers(ne_binary(), pos_integer(), knm_carriers:options()) -> +-spec find_numbers(kz_term:ne_binary(), pos_integer(), knm_carriers:options()) -> {'ok', knm_number:knm_numbers()} | {'error', any()}. find_numbers(<<"+", _/binary>>=Prefix, Quantity, Options) -> @@ -74,7 +74,7 @@ find_numbers(<<"+", _/binary>>=Prefix, Quantity, Options) -> find_numbers(Prefix, Quantity, Options) -> find_numbers(<<"+",Prefix/binary>>, Quantity, Options). --spec find_numbers_in_account(ne_binary(), pos_integer(), api_ne_binary(), knm_carriers:options()) -> +-spec find_numbers_in_account(kz_term:ne_binary(), pos_integer(), kz_term:api_ne_binary(), knm_carriers:options()) -> {'ok', knm_number:knm_numbers()} | {'error', any()}. find_numbers_in_account(_Prefix, _Quantity, 'undefined', _Options) -> {'ok', []}; @@ -94,7 +94,7 @@ find_numbers_in_account(Prefix, Quantity, AccountId, Options) -> Result -> Result end. --spec do_find_numbers_in_account(ne_binary(), pos_integer(), non_neg_integer(), ne_binary(), ne_binary()) -> +-spec do_find_numbers_in_account(kz_term:ne_binary(), pos_integer(), non_neg_integer(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', knm_number:knm_numbers()} | {'error', any()}. do_find_numbers_in_account(Prefix, Quantity, Offset, AccountId, QID) -> @@ -160,7 +160,7 @@ disconnect_number(Number) -> ,{?PVT_RESERVE_HISTORY, []} ]). --spec generate_numbers(ne_binary(), pos_integer(), non_neg_integer()) -> 'ok'. +-spec generate_numbers(kz_term:ne_binary(), pos_integer(), non_neg_integer()) -> 'ok'. generate_numbers(AccountId, <<"8835100",_/binary>> = Number, Quantity) when byte_size(Number) =:= 15 -> generate_numbers(AccountId, kz_term:to_integer(Number), kz_term:to_integer(Quantity)); @@ -174,8 +174,8 @@ generate_numbers(?MATCH_ACCOUNT_RAW(AccountId), Number, Quantity) generate_numbers(AccountId, Number+1, Quantity-1). --spec save_doc(ne_binary(), ne_binary()) -> {'ok', kz_json:object()} | - {'error', any()}. +-spec save_doc(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | + {'error', any()}. save_doc(AccountId, Number) -> JObj = kz_json:from_list([{<<"_id">>, knm_converters:normalize(Number)} ,{<<"pvt_account_id">>, AccountId} @@ -195,7 +195,7 @@ save_doc(JObj) -> Result -> Result end. --spec update_doc(knm_number:knm_number(), kz_proplist()) -> +-spec update_doc(knm_number:knm_number(), kz_term:proplist()) -> knm_number:knm_number(). update_doc(Number, UpdateProps) -> PhoneNumber = knm_number:phone_number(Number), diff --git a/core/kazoo_number_manager/src/carriers/knm_inventory.erl b/core/kazoo_number_manager/src/carriers/knm_inventory.erl index 2b634a2dcc9..c8f91547497 100644 --- a/core/kazoo_number_manager/src/carriers/knm_inventory.erl +++ b/core/kazoo_number_manager/src/carriers/knm_inventory.erl @@ -50,8 +50,8 @@ is_local() -> 'false'. %% Check with carrier if these numbers are registered with it. %% @end %%-------------------------------------------------------------------- --spec check_numbers(ne_binaries()) -> {ok, kz_json:object()} | - {error, any()}. +-spec check_numbers(kz_term:ne_binaries()) -> {ok, kz_json:object()} | + {error, any()}. check_numbers(_Numbers) -> {error, not_implemented}. %%-------------------------------------------------------------------- @@ -61,7 +61,7 @@ check_numbers(_Numbers) -> {error, not_implemented}. %% in a rate center %% @end %%-------------------------------------------------------------------- --spec find_numbers(ne_binary(), pos_integer(), knm_search:options()) -> +-spec find_numbers(kz_term:ne_binary(), pos_integer(), knm_search:options()) -> {'ok', knm_number:knm_numbers()} | {'error', any()}. find_numbers(Prefix, Quantity, Options) -> @@ -73,7 +73,7 @@ find_numbers(Prefix, Quantity, Options) -> do_find_numbers(Prefix, Quantity, Offset, AccountId, QID) end. --spec do_find_numbers(ne_binary(), pos_integer(), non_neg_integer(), ne_binary(), ne_binary()) -> +-spec do_find_numbers(kz_term:ne_binary(), pos_integer(), non_neg_integer(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', knm_number:knm_numbers()} | {'error', any()}. do_find_numbers(<<"+",_/binary>>=Prefix, Quantity, Offset, AccountId, QID) @@ -103,7 +103,7 @@ do_find_numbers(<<"+",_/binary>>=Prefix, Quantity, Offset, AccountId, QID) do_find_numbers(_, _, _, _, _) -> {'error', 'not_available'}. --spec find_more(ne_binary(), pos_integer(), non_neg_integer(), ne_binary(), non_neg_integer(), ne_binary(), knm_number:knm_numbers()) -> +-spec find_more(kz_term:ne_binary(), pos_integer(), non_neg_integer(), kz_term:ne_binary(), non_neg_integer(), kz_term:ne_binary(), knm_number:knm_numbers()) -> {'ok', knm_number:knm_numbers()}. find_more(Prefix, Quantity, Offset, AccountId, NotEnough, QID, Numbers) when NotEnough < Quantity -> diff --git a/core/kazoo_number_manager/src/carriers/knm_local.erl b/core/kazoo_number_manager/src/carriers/knm_local.erl index ef9e03667a8..dfd0bf0bee5 100644 --- a/core/kazoo_number_manager/src/carriers/knm_local.erl +++ b/core/kazoo_number_manager/src/carriers/knm_local.erl @@ -50,8 +50,8 @@ is_local() -> 'true'. %% Check with carrier if these numbers are registered with it. %% @end %%-------------------------------------------------------------------- --spec check_numbers(ne_binaries()) -> {ok, kz_json:object()} | - {error, any()}. +-spec check_numbers(kz_term:ne_binaries()) -> {ok, kz_json:object()} | + {error, any()}. check_numbers(_Numbers) -> {error, not_implemented}. %%-------------------------------------------------------------------- @@ -61,7 +61,7 @@ check_numbers(_Numbers) -> {error, not_implemented}. %% in a rate center %% @end %%-------------------------------------------------------------------- --spec find_numbers(ne_binary(), pos_integer(), knm_search:options()) -> +-spec find_numbers(kz_term:ne_binary(), pos_integer(), knm_search:options()) -> {'ok', knm_number:knm_numbers()} | {'error', any()}. find_numbers(Prefix, Quantity, Options) -> @@ -73,7 +73,7 @@ find_numbers(Prefix, Quantity, Options) -> do_find_numbers(Prefix, Quantity, Offset, AccountId, QID) end. --spec do_find_numbers(ne_binary(), pos_integer(), non_neg_integer(), ne_binary(), ne_binary()) -> +-spec do_find_numbers(kz_term:ne_binary(), pos_integer(), non_neg_integer(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', knm_number:knm_numbers()} | {'error', any()}. do_find_numbers(<<"+",_/binary>>=Prefix, Quantity, Offset, AccountId, QID) @@ -103,7 +103,7 @@ do_find_numbers(<<"+",_/binary>>=Prefix, Quantity, Offset, AccountId, QID) do_find_numbers(_, _, _, _, _) -> {'error', 'not_available'}. --spec find_more(ne_binary(), pos_integer(), non_neg_integer(), ne_binary(), non_neg_integer(), ne_binary(), knm_number:knm_numbers()) -> +-spec find_more(kz_term:ne_binary(), pos_integer(), non_neg_integer(), kz_term:ne_binary(), non_neg_integer(), kz_term:ne_binary(), knm_number:knm_numbers()) -> {'ok', knm_number:knm_numbers()}. find_more(Prefix, Quantity, Offset, AccountId, NotEnough, QID, Numbers) when NotEnough < Quantity -> diff --git a/core/kazoo_number_manager/src/carriers/knm_managed.erl b/core/kazoo_number_manager/src/carriers/knm_managed.erl index cda7448fb6f..69cd04d4005 100644 --- a/core/kazoo_number_manager/src/carriers/knm_managed.erl +++ b/core/kazoo_number_manager/src/carriers/knm_managed.erl @@ -53,8 +53,8 @@ is_local() -> 'true'. %% Check with carrier if these numbers are registered with it. %% @end %%-------------------------------------------------------------------- --spec check_numbers(ne_binaries()) -> {ok, kz_json:object()} | - {error, any()}. +-spec check_numbers(kz_term:ne_binaries()) -> {ok, kz_json:object()} | + {error, any()}. check_numbers(_Numbers) -> {error, not_implemented}. %%-------------------------------------------------------------------- @@ -64,7 +64,7 @@ check_numbers(_Numbers) -> {error, not_implemented}. %% in a rate center %% @end %%-------------------------------------------------------------------- --spec find_numbers(ne_binary(), pos_integer(), knm_search:options()) -> +-spec find_numbers(kz_term:ne_binary(), pos_integer(), knm_search:options()) -> {'ok', knm_number:knm_numbers()} | {'error', any()}. find_numbers(<<"+", _/binary>>=Prefix, Quantity, Options) -> @@ -73,7 +73,7 @@ find_numbers(<<"+", _/binary>>=Prefix, Quantity, Options) -> find_numbers(Prefix, Quantity, Options) -> find_numbers(<<"+",Prefix/binary>>, Quantity, Options). --spec find_numbers_in_account(ne_binary(), pos_integer(), api_binary(), knm_search:options()) -> +-spec find_numbers_in_account(kz_term:ne_binary(), pos_integer(), kz_term:api_binary(), knm_search:options()) -> {'ok', knm_number:knm_numbers()} | {'error', any()}. find_numbers_in_account(Prefix, Quantity, AccountId, Options) -> @@ -90,7 +90,7 @@ find_numbers_in_account(Prefix, Quantity, AccountId, Options) -> Result -> Result end. --spec do_find_numbers_in_account(ne_binary(), pos_integer(), api_binary(), knm_search:options()) -> +-spec do_find_numbers_in_account(kz_term:ne_binary(), pos_integer(), kz_term:api_binary(), knm_search:options()) -> {'ok', list()} | {'error', any()}. do_find_numbers_in_account(Prefix, Quantity, AccountId, Options) -> @@ -161,7 +161,7 @@ disconnect_number(Number) -> %% ,{?PVT_ASSIGNED_TO, <<>>} ]). --spec generate_numbers(ne_binary(), pos_integer(), non_neg_integer()) -> 'ok'. +-spec generate_numbers(kz_term:ne_binary(), pos_integer(), non_neg_integer()) -> 'ok'. generate_numbers(_AccountId, _Number, 0) -> 'ok'; generate_numbers(?MATCH_ACCOUNT_RAW(AccountId), Number, Quantity) when Quantity > 0 @@ -170,11 +170,11 @@ generate_numbers(?MATCH_ACCOUNT_RAW(AccountId), Number, Quantity) {'ok', _JObj} = save_doc(AccountId, <<"+",(kz_term:to_binary(Number))/binary>>), generate_numbers(AccountId, Number+1, Quantity-1). --spec import_numbers(ne_binary(), ne_binaries()) -> kz_json:object(). +-spec import_numbers(kz_term:ne_binary(), kz_term:ne_binaries()) -> kz_json:object(). import_numbers(AccountId, Numbers) -> import_numbers(AccountId, Numbers, kz_json:new()). --spec import_numbers(ne_binary(), ne_binaries(), kz_json:object()) -> kz_json:object(). +-spec import_numbers(kz_term:ne_binary(), kz_term:ne_binaries(), kz_json:object()) -> kz_json:object(). import_numbers(_AccountId, [], JObj) -> JObj; import_numbers(AccountId, [Number | Numbers], JObj) -> NewJObj = @@ -189,8 +189,8 @@ import_numbers(AccountId, [Number | Numbers], JObj) -> end, import_numbers(AccountId, Numbers, NewJObj). --spec save_doc(ne_binary(), ne_binary()) -> {'ok', kz_json:object()} | - {'error', any()}. +-spec save_doc(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | + {'error', any()}. save_doc(AccountId, Number) -> JObj = kz_json:from_list([{<<"_id">>, knm_converters:normalize(Number)} ,{<<"pvt_account_id">>, AccountId} @@ -210,7 +210,7 @@ save_doc(JObj) -> Result -> Result end. --spec update_doc(knm_number:knm_number(), kz_proplist()) -> +-spec update_doc(knm_number:knm_number(), kz_term:proplist()) -> knm_number:knm_number(). update_doc(Number, UpdateProps) -> PhoneNumber = knm_number:phone_number(Number), diff --git a/core/kazoo_number_manager/src/carriers/knm_mdn.erl b/core/kazoo_number_manager/src/carriers/knm_mdn.erl index 5ec465704ea..7907f009341 100644 --- a/core/kazoo_number_manager/src/carriers/knm_mdn.erl +++ b/core/kazoo_number_manager/src/carriers/knm_mdn.erl @@ -48,8 +48,8 @@ is_local() -> 'false'. %% Check with carrier if these numbers are registered with it. %% @end %%-------------------------------------------------------------------- --spec check_numbers(ne_binaries()) -> {ok, kz_json:object()} | - {error, any()}. +-spec check_numbers(kz_term:ne_binaries()) -> {ok, kz_json:object()} | + {error, any()}. check_numbers(_Numbers) -> {error, not_implemented}. %%-------------------------------------------------------------------- @@ -59,7 +59,7 @@ check_numbers(_Numbers) -> {error, not_implemented}. %% in a rate center %% @end %%-------------------------------------------------------------------- --spec find_numbers(ne_binary(), pos_integer(), knm_carriers:options()) -> +-spec find_numbers(kz_term:ne_binary(), pos_integer(), knm_carriers:options()) -> {'ok', knm_number:knm_numbers()} | {'error', any()}. find_numbers(_Prefix, _Quantity, _Options) -> diff --git a/core/kazoo_number_manager/src/carriers/knm_other.erl b/core/kazoo_number_manager/src/carriers/knm_other.erl index 5a4ce03fcf9..77427f55cb9 100644 --- a/core/kazoo_number_manager/src/carriers/knm_other.erl +++ b/core/kazoo_number_manager/src/carriers/knm_other.erl @@ -89,7 +89,7 @@ is_local() -> 'false'. %% in a rate center %% @end %%-------------------------------------------------------------------- --spec find_numbers(ne_binary(), pos_integer(), knm_search:options()) -> +-spec find_numbers(kz_term:ne_binary(), pos_integer(), knm_search:options()) -> {'ok', list()} | {'bulk', list()} | {'error', any()}. @@ -109,8 +109,8 @@ find_numbers(Prefix, Quantity, Options) -> %% Check with carrier if these numbers are registered with it. %% @end %%-------------------------------------------------------------------- --spec check_numbers(ne_binaries()) -> {'ok', kz_json:object()} | - {'error', any()}. +-spec check_numbers(kz_term:ne_binaries()) -> {'ok', kz_json:object()} | + {'error', any()}. check_numbers(Numbers) -> FormatedNumbers = [knm_converters:to_npan(Number) || Number <- Numbers], case ?PHONEBOOK_URL of @@ -239,7 +239,7 @@ format_check_numbers_success(Body) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_numbers(ne_binary(), ne_binary(), ne_binary(), knm_search:options()) -> +-spec get_numbers(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), knm_search:options()) -> {'ok', list()} | {'error', 'not_available'}. get_numbers(Url, Prefix, Quantity, Options) -> @@ -249,7 +249,7 @@ get_numbers(Url, Prefix, Quantity, Options) -> Results = query_for_numbers(Uri), handle_number_query_results(Results, Options). --spec query_for_numbers(ne_binary()) -> kz_http:http_ret(). +-spec query_for_numbers(kz_term:ne_binary()) -> kz_http:http_ret(). -ifdef(TEST). query_for_numbers(<>=URI) -> ?LOG_DEBUG("number pb url ~s resp: ~s", [URI, kz_json:encode(?NUMBERS_RESPONSE)]), @@ -297,7 +297,7 @@ format_found(QID, DID, CarrierData) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_blocks(ne_binary(), ne_binary(), ne_binary(), knm_search:options()) -> +-spec get_blocks(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), knm_search:options()) -> {'ok', list()} | {'error', 'not_available'}. -ifdef(TEST). diff --git a/core/kazoo_number_manager/src/carriers/knm_reserved.erl b/core/kazoo_number_manager/src/carriers/knm_reserved.erl index e20800b3ca5..5a5a180e7c5 100644 --- a/core/kazoo_number_manager/src/carriers/knm_reserved.erl +++ b/core/kazoo_number_manager/src/carriers/knm_reserved.erl @@ -48,8 +48,8 @@ is_local() -> 'true'. %% Check with carrier if these numbers are registered with it. %% @end %%-------------------------------------------------------------------- --spec check_numbers(ne_binaries()) -> {ok, kz_json:object()} | - {error, any()}. +-spec check_numbers(kz_term:ne_binaries()) -> {ok, kz_json:object()} | + {error, any()}. check_numbers(_Numbers) -> {error, not_implemented}. %%-------------------------------------------------------------------- @@ -59,7 +59,7 @@ check_numbers(_Numbers) -> {error, not_implemented}. %% assigned to an account's reseller account. %% @end %%-------------------------------------------------------------------- --spec find_numbers(ne_binary(), pos_integer(), knm_search:options()) -> +-spec find_numbers(kz_term:ne_binary(), pos_integer(), knm_search:options()) -> {'ok', knm_number:knm_numbers()} | {'error', any()}. find_numbers(Prefix, Quantity, Options) -> @@ -71,7 +71,7 @@ find_numbers(Prefix, Quantity, Options) -> do_find_numbers(Prefix, Quantity, Offset, AccountId, QID) end. --spec do_find_numbers(ne_binary(), pos_integer(), non_neg_integer(), ne_binary(), ne_binary()) -> +-spec do_find_numbers(kz_term:ne_binary(), pos_integer(), non_neg_integer(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', knm_number:knm_numbers()} | {'error', any()}. do_find_numbers(<<"+",_/binary>>=Prefix, Quantity, Offset, AccountId, QID) @@ -97,7 +97,7 @@ do_find_numbers(<<"+",_/binary>>=Prefix, Quantity, Offset, AccountId, QID) do_find_numbers(_, _, _, _, _) -> {'error', 'not_available'}. --spec find_more(ne_binary(), pos_integer(), non_neg_integer(), ne_binary(), non_neg_integer(), ne_binary(), knm_number:knm_numbers()) -> +-spec find_more(kz_term:ne_binary(), pos_integer(), non_neg_integer(), kz_term:ne_binary(), non_neg_integer(), kz_term:ne_binary(), knm_number:knm_numbers()) -> {'ok', knm_number:knm_numbers()}. find_more(Prefix, Quantity, Offset, AccountId, NotEnough, QID, Numbers) when NotEnough < Quantity -> diff --git a/core/kazoo_number_manager/src/carriers/knm_reserved_reseller.erl b/core/kazoo_number_manager/src/carriers/knm_reserved_reseller.erl index f1ec64b1a9f..3d47587793d 100644 --- a/core/kazoo_number_manager/src/carriers/knm_reserved_reseller.erl +++ b/core/kazoo_number_manager/src/carriers/knm_reserved_reseller.erl @@ -48,8 +48,8 @@ is_local() -> 'true'. %% Check with carrier if these numbers are registered with it. %% @end %%-------------------------------------------------------------------- --spec check_numbers(ne_binaries()) -> {ok, kz_json:object()} | - {error, any()}. +-spec check_numbers(kz_term:ne_binaries()) -> {ok, kz_json:object()} | + {error, any()}. check_numbers(_Numbers) -> {error, not_implemented}. %%-------------------------------------------------------------------- @@ -59,7 +59,7 @@ check_numbers(_Numbers) -> {error, not_implemented}. %% assigned to an account's reseller account. %% @end %%-------------------------------------------------------------------- --spec find_numbers(ne_binary(), pos_integer(), knm_search:options()) -> +-spec find_numbers(kz_term:ne_binary(), pos_integer(), knm_search:options()) -> {'ok', knm_number:knm_numbers()} | {'error', any()}. find_numbers(Prefix, Quantity, Options) -> @@ -71,7 +71,7 @@ find_numbers(Prefix, Quantity, Options) -> do_find_numbers(Prefix, Quantity, Offset, knm_carriers:reseller_id(Options), QID) end. --spec do_find_numbers(ne_binary(), pos_integer(), non_neg_integer(), ne_binary(), ne_binary()) -> +-spec do_find_numbers(kz_term:ne_binary(), pos_integer(), non_neg_integer(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', knm_number:knm_numbers()} | {'error', any()}. do_find_numbers(<<"+",_/binary>>=Prefix, Quantity, Offset, AccountId, QID) @@ -97,7 +97,7 @@ do_find_numbers(<<"+",_/binary>>=Prefix, Quantity, Offset, AccountId, QID) do_find_numbers(_, _, _, _, _) -> {'error', 'not_available'}. --spec find_more(ne_binary(), pos_integer(), non_neg_integer(), ne_binary(), non_neg_integer(), ne_binary(), knm_number:knm_numbers()) -> +-spec find_more(kz_term:ne_binary(), pos_integer(), non_neg_integer(), kz_term:ne_binary(), non_neg_integer(), kz_term:ne_binary(), knm_number:knm_numbers()) -> {'ok', knm_number:knm_numbers()}. find_more(Prefix, Quantity, Offset, AccountId, NotEnough, QID, Numbers) when NotEnough < Quantity -> diff --git a/core/kazoo_number_manager/src/carriers/knm_simwood.erl b/core/kazoo_number_manager/src/carriers/knm_simwood.erl index 6d4f7021e66..91ff7443409 100644 --- a/core/kazoo_number_manager/src/carriers/knm_simwood.erl +++ b/core/kazoo_number_manager/src/carriers/knm_simwood.erl @@ -64,8 +64,8 @@ is_local() -> 'false'. %% Check with carrier if these numbers are registered with it. %% @end %%-------------------------------------------------------------------- --spec check_numbers(ne_binaries()) -> {ok, kz_json:object()} | - {error, any()}. +-spec check_numbers(kz_term:ne_binaries()) -> {ok, kz_json:object()} | + {error, any()}. check_numbers(_Numbers) -> {error, not_implemented}. %%-------------------------------------------------------------------- @@ -74,7 +74,7 @@ check_numbers(_Numbers) -> {error, not_implemented}. %% Query Simwood.com for available numbers %% @end %%-------------------------------------------------------------------- --spec find_numbers(ne_binary(), pos_integer(), knm_carriers:options()) -> +-spec find_numbers(kz_term:ne_binary(), pos_integer(), knm_carriers:options()) -> {'ok', knm_number:knm_numbers()}. find_numbers(Prefix, Quantity, Options) -> URL = list_to_binary([?SW_NUMBER_URL, "/", ?SW_ACCOUNT_ID, <<"/available/standard/">>, sw_quantity(Quantity), "?pattern=", Prefix, "*"]), @@ -140,7 +140,7 @@ should_lookup_cnam() -> 'true'. %% @doc %% @end %%-------------------------------------------------------------------- --spec to_simwood(knm_number:knm_number()) -> ne_binary(). +-spec to_simwood(knm_number:knm_number()) -> kz_term:ne_binary(). to_simwood(Number) -> case knm_phone_number:number(knm_number:phone_number(Number)) of <<$+, N/binary>> -> N; @@ -152,7 +152,7 @@ to_simwood(Number) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec query_simwood(ne_binary(), 'get' | 'put' | 'delete') -> +-spec query_simwood(kz_term:ne_binary(), 'get' | 'put' | 'delete') -> {'ok', iolist()} | {'error', 'not_available'}. query_simwood(URL, Verb) -> @@ -177,7 +177,7 @@ query_simwood(URL, Verb) -> %% Simwood number query supports only 1|10|100 search amount %% @end %%-------------------------------------------------------------------- --spec sw_quantity(pos_integer()) -> ne_binary(). +-spec sw_quantity(pos_integer()) -> kz_term:ne_binary(). sw_quantity(Quantity) when Quantity == 1 -> <<"1">>; sw_quantity(Quantity) when Quantity > 1, Quantity =< 10 -> <<"10">>; sw_quantity(_Quantity) -> <<"100">>. diff --git a/core/kazoo_number_manager/src/carriers/knm_telnyx.erl b/core/kazoo_number_manager/src/carriers/knm_telnyx.erl index 66e23d3fabd..d588c1b1c7f 100644 --- a/core/kazoo_number_manager/src/carriers/knm_telnyx.erl +++ b/core/kazoo_number_manager/src/carriers/knm_telnyx.erl @@ -63,8 +63,8 @@ is_number_billable(_Number) -> 'true'. %% Check with carrier if these numbers are registered with it. %% @end %%-------------------------------------------------------------------- --spec check_numbers(ne_binaries()) -> {ok, kz_json:object()} | - {error, any()}. +-spec check_numbers(kz_term:ne_binaries()) -> {ok, kz_json:object()} | + {error, any()}. check_numbers(_Numbers) -> {error, not_implemented}. @@ -74,7 +74,7 @@ check_numbers(_Numbers) -> {error, not_implemented}. %% Query the system for a quantity of available numbers in a rate center %% @end %%-------------------------------------------------------------------- --spec find_numbers(ne_binary(), pos_integer(), knm_search:options()) -> +-spec find_numbers(kz_term:ne_binary(), pos_integer(), knm_search:options()) -> {'ok', knm_number:knm_numbers()}. find_numbers(<<"+1", Prefix:3/binary, _/binary>>, Quantity, Options) when ?IS_US_TOLLFREE(Prefix) -> @@ -153,7 +153,7 @@ should_lookup_cnam() -> 'true'. %%% Internals -type kind() :: 'npa' | 'tollfree' | 'region'. --spec numbers(kind(), pos_integer(), ne_binary(), api_ne_binary()) -> +-spec numbers(kind(), pos_integer(), kz_term:ne_binary(), kz_term:api_ne_binary()) -> kz_json:objects(). numbers(SearchKind, Quantity, Prefix, NXX) -> Descriptor = kz_json:from_list(search_prefix(SearchKind, Prefix, NXX)), diff --git a/core/kazoo_number_manager/src/carriers/knm_vitelity.erl b/core/kazoo_number_manager/src/carriers/knm_vitelity.erl index 14e619d5443..206986fd909 100644 --- a/core/kazoo_number_manager/src/carriers/knm_vitelity.erl +++ b/core/kazoo_number_manager/src/carriers/knm_vitelity.erl @@ -51,8 +51,8 @@ is_local() -> 'false'. %% Check with carrier if these numbers are registered with it. %% @end %%-------------------------------------------------------------------- --spec check_numbers(ne_binaries()) -> {ok, kz_json:object()} | - {error, any()}. +-spec check_numbers(kz_term:ne_binaries()) -> {ok, kz_json:object()} | + {error, any()}. check_numbers(_Numbers) -> {error, not_implemented}. %%-------------------------------------------------------------------- @@ -62,7 +62,7 @@ check_numbers(_Numbers) -> {error, not_implemented}. %% in a rate center %% @end %%-------------------------------------------------------------------- --spec find_numbers(ne_binary(), pos_integer(), knm_carriers:options()) -> +-spec find_numbers(kz_term:ne_binary(), pos_integer(), knm_carriers:options()) -> {'ok', knm_number:knm_numbers()} | {'error', any()}. find_numbers(<<"+1",Prefix/binary>>, Quantity, Options) -> @@ -137,7 +137,7 @@ is_number_billable(_) -> 'true'. %% %% @end %%-------------------------------------------------------------------- --spec classify_and_find(ne_binary(), pos_integer(), knm_carriers:options()) -> +-spec classify_and_find(kz_term:ne_binary(), pos_integer(), knm_carriers:options()) -> {'ok', knm_number:knm_numbers()} | {'error', any()}. classify_and_find(Prefix, Quantity, Options) -> @@ -175,7 +175,7 @@ tollfree_options(Quantity, Options) -> %% %% @end %%-------------------------------------------------------------------- --spec local_options(ne_binary(), knm_carriers:options()) -> +-spec local_options(kz_term:ne_binary(), knm_carriers:options()) -> knm_vitelity_util:query_options(). local_options(Prefix, Options) when byte_size(Prefix) =< 3 -> LocalOptions = [{'qs', [{'npa', Prefix} @@ -213,7 +213,7 @@ local_options(Prefix, Options) -> %% %% @end %%-------------------------------------------------------------------- --spec find(ne_binary(), pos_integer(), knm_carriers:options(), knm_vitelity_util:query_options()) -> +-spec find(kz_term:ne_binary(), pos_integer(), knm_carriers:options(), knm_vitelity_util:query_options()) -> {'ok', knm_number:knm_numbers()} | {'error', any()}. find(Prefix, Quantity, Options, VitelityOptions) -> @@ -239,7 +239,7 @@ to_number(DID, CarrierData, QID) -> %% %% @end %%-------------------------------------------------------------------- --spec query_vitelity(ne_binary(), pos_integer(), knm_vitelity_util:query_options()) -> +-spec query_vitelity(kz_term:ne_binary(), pos_integer(), knm_vitelity_util:query_options()) -> {'ok', kz_json:object()} | {'error', any()}. -ifdef(TEST). @@ -277,7 +277,7 @@ query_vitelity(Prefix, Quantity, QOptions) -> %% %% @end %%-------------------------------------------------------------------- --spec process_xml_resp(ne_binary(), pos_integer(), text()) -> +-spec process_xml_resp(kz_term:ne_binary(), pos_integer(), kz_term:text()) -> {'ok', kz_json:object()} | {'error', any()}. process_xml_resp(Prefix, Quantity, XML_binary) -> @@ -296,7 +296,7 @@ process_xml_resp(Prefix, Quantity, XML_binary) -> %% %% @end %%-------------------------------------------------------------------- --spec process_xml_content_tag(ne_binary(), pos_integer(), xml_el()) -> +-spec process_xml_content_tag(kz_term:ne_binary(), pos_integer(), kz_types:xml_el()) -> {'ok', kz_json:object()} | {'error', any()}. process_xml_content_tag(Prefix, Quantity, #xmlElement{name='content' @@ -317,10 +317,10 @@ process_xml_content_tag(Prefix, Quantity, #xmlElement{name='content' %% %% @end %%-------------------------------------------------------------------- --spec process_xml_numbers(ne_binary(), pos_integer(), 'undefined' | xml_el()) -> +-spec process_xml_numbers(kz_term:ne_binary(), pos_integer(), 'undefined' | kz_types:xml_el()) -> {'ok', kz_json:object()} | {'error', any()}. --spec process_xml_numbers(ne_binary(), pos_integer(), 'undefined' | xml_els(), kz_proplist()) -> +-spec process_xml_numbers(kz_term:ne_binary(), pos_integer(), 'undefined' | kz_types:xml_els(), kz_term:proplist()) -> {'ok', kz_json:object()} | {'error', any()}. process_xml_numbers(_Prefix, _Quantity, 'undefined') -> @@ -356,7 +356,7 @@ process_xml_numbers(Prefix, Quantity, [El|Els], Acc) -> %% %% @end %%-------------------------------------------------------------------- --spec number_matches_prefix(kz_json:object(), ne_binary()) -> boolean(). +-spec number_matches_prefix(kz_json:object(), kz_term:ne_binary()) -> boolean(). number_matches_prefix(JObj, Prefix) -> PrefixLen = byte_size(Prefix), CountryCode = kz_json:get_value(<<"country_code">>, JObj, <<"+1">>), @@ -373,7 +373,7 @@ number_matches_prefix(JObj, Prefix) -> %% %% @end %%-------------------------------------------------------------------- --spec xml_did_to_json(xml_el()) -> kz_json:object(). +-spec xml_did_to_json(kz_types:xml_el()) -> kz_json:object(). xml_did_to_json(#xmlElement{name='did' ,content=[#xmlText{}]=DID }) -> @@ -404,7 +404,7 @@ xml_did_to_json(#xmlElement{name='number' %% %% @end %%-------------------------------------------------------------------- --spec purchase_local_options(ne_binary()) -> knm_vitelity_util:query_options(). +-spec purchase_local_options(kz_term:ne_binary()) -> knm_vitelity_util:query_options(). purchase_local_options(DID) -> [{'qs', [{'did', knm_converters:to_npan(DID)} ,{'cmd', <<"getlocaldid">>} @@ -421,7 +421,7 @@ purchase_local_options(DID) -> %% %% @end %%-------------------------------------------------------------------- --spec purchase_tollfree_options(ne_binary()) -> knm_vitelity_util:query_options(). +-spec purchase_tollfree_options(kz_term:ne_binary()) -> knm_vitelity_util:query_options(). purchase_tollfree_options(DID) -> [{'qs', [{'did', knm_converters:to_npan(DID)} ,{'cmd', <<"gettollfree">>} @@ -458,7 +458,7 @@ query_vitelity(Number, QOptions) -> %% %% @end %%-------------------------------------------------------------------- --spec process_xml_resp(knm_number:knm_number(), text()) -> +-spec process_xml_resp(knm_number:knm_number(), kz_term:text()) -> knm_number:knm_number(). process_xml_resp(Number, XML_binary) -> XML = unicode:characters_to_list(XML_binary), @@ -476,7 +476,7 @@ process_xml_resp(Number, XML_binary) -> %% %% @end %%-------------------------------------------------------------------- --spec process_xml_content_tag(knm_number:knm_number(), xml_el()) -> +-spec process_xml_content_tag(knm_number:knm_number(), kz_types:xml_el()) -> knm_number:knm_number(). process_xml_content_tag(Number, #xmlElement{name='content' ,content=Children @@ -498,7 +498,7 @@ process_xml_content_tag(Number, #xmlElement{name='content' %% %% @end %%-------------------------------------------------------------------- --spec release_did_options(ne_binary()) -> knm_vitelity_util:query_options(). +-spec release_did_options(kz_term:ne_binary()) -> knm_vitelity_util:query_options(). release_did_options(DID) -> [{'qs', [{'did', knm_converters:to_npan(DID)} ,{'cmd', <<"removedid">>} diff --git a/core/kazoo_number_manager/src/carriers/knm_voip_innovations.erl b/core/kazoo_number_manager/src/carriers/knm_voip_innovations.erl index ccf2edeef2e..b7e7c5c9d91 100644 --- a/core/kazoo_number_manager/src/carriers/knm_voip_innovations.erl +++ b/core/kazoo_number_manager/src/carriers/knm_voip_innovations.erl @@ -73,7 +73,7 @@ -define(API_SUCCESS, <<"100">>). --type soap_response() :: {'ok', xml_el()} | {'error', any()}. +-type soap_response() :: {'ok', kz_types:xml_el()} | {'error', any()}. -type to_json_ret() :: {'ok', kz_json:object() | kz_json:objects()} | {'error', any()}. @@ -109,8 +109,8 @@ is_number_billable(_Number) -> 'true'. %% Check with carrier if these numbers are registered with it. %% @end %%-------------------------------------------------------------------- --spec check_numbers(ne_binaries()) -> {ok, kz_json:object()} | - {error, any()}. +-spec check_numbers(kz_term:ne_binaries()) -> {ok, kz_json:object()} | + {error, any()}. check_numbers(_Numbers) -> {error, not_implemented}. @@ -120,7 +120,7 @@ check_numbers(_Numbers) -> {error, not_implemented}. %% Query the system for a quantity of available numbers in a rate center %% @end %%-------------------------------------------------------------------- --spec find_numbers(ne_binary(), pos_integer(), knm_search:options()) -> +-spec find_numbers(kz_term:ne_binary(), pos_integer(), knm_search:options()) -> {'ok', list()} | {'error', any()}. find_numbers(<<"+", Rest/binary>>, Quantity, Options) -> @@ -192,7 +192,7 @@ should_lookup_cnam() -> 'true'. %%% Internals --spec 'remove +1'(ne_binary()) -> ne_binary(). +-spec 'remove +1'(kz_term:ne_binary()) -> kz_term:ne_binary(). 'remove +1'(<<"+", Rest/binary>>) -> 'remove +1'(Rest); 'remove +1'(<<"1", Rest/binary>>) -> @@ -200,7 +200,7 @@ should_lookup_cnam() -> 'true'. 'remove +1'(Else) -> Else. --spec to_numbers(to_json_ret(), ne_binary()) -> +-spec to_numbers(to_json_ret(), kz_term:ne_binary()) -> {'ok', [tuple()]} | {'error', any()}. to_numbers({'error',_R}=Error, _) -> @@ -402,7 +402,7 @@ handle_response({'error', _}=E) -> lager:debug("request error: ~p", [E]), E. --spec verify_response(xml_el()) -> soap_response(). +-spec verify_response(kz_types:xml_el()) -> soap_response(). verify_response(Xml) -> RespCode = kz_xml:get_value("//responseCode/text()", Xml), RespMsg = kz_xml:get_value("//responseMessage/text()", Xml), diff --git a/core/kazoo_number_manager/src/converters/knm_converter_regex.erl b/core/kazoo_number_manager/src/converters/knm_converter_regex.erl index b841a068497..26557ce408c 100644 --- a/core/kazoo_number_manager/src/converters/knm_converter_regex.erl +++ b/core/kazoo_number_manager/src/converters/knm_converter_regex.erl @@ -37,18 +37,18 @@ %% @doc %% @end %%-------------------------------------------------------------------- --spec normalize(ne_binary()) -> - ne_binary(). +-spec normalize(kz_term:ne_binary()) -> + kz_term:ne_binary(). normalize(?NE_BINARY = Num) -> to_e164(Num). --spec normalize(ne_binary(), ne_binary()) -> - ne_binary(). +-spec normalize(kz_term:ne_binary(), kz_term:ne_binary()) -> + kz_term:ne_binary(). normalize(?NE_BINARY = Num, AccountId) -> to_e164(Num, AccountId). --spec normalize(ne_binary(), ne_binary(), kz_json:object()) -> - ne_binary(). +-spec normalize(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> + kz_term:ne_binary(). normalize(?NE_BINARY = Num, AccountId, DialPlan) -> to_e164_from_account_dialplan(Num, AccountId, DialPlan). @@ -57,7 +57,7 @@ normalize(?NE_BINARY = Num, AccountId, DialPlan) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec to_npan(ne_binary()) -> ne_binary(). +-spec to_npan(kz_term:ne_binary()) -> kz_term:ne_binary(). to_npan(Num) -> case re:run(Num, <<"^\\+?1?([2-9][0-9]{2}[2-9][0-9]{6})\$">>, [{'capture', [1], 'binary'}]) of 'nomatch' -> Num; @@ -69,7 +69,7 @@ to_npan(Num) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec to_1npan(ne_binary()) -> ne_binary(). +-spec to_1npan(kz_term:ne_binary()) -> kz_term:ne_binary(). to_1npan(Num) -> case re:run(Num, <<"^\\+?1?([2-9][0-9]{2}[2-9][0-9]{6})\$">>, [{'capture', [1], 'binary'}]) of 'nomatch' -> Num; @@ -85,7 +85,7 @@ to_1npan(Num) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec to_e164(ne_binary()) -> ne_binary(). +-spec to_e164(kz_term:ne_binary()) -> kz_term:ne_binary(). to_e164(<<"+",_/binary>> = N) -> N; to_e164(Number) -> Converters = get_e164_converters(), @@ -102,7 +102,7 @@ to_e164(Number, Account) -> to_e164_from_account(Number, AccountId) end. --spec to_e164_from_account(ne_binary(), ne_binary()) -> ne_binary(). +-spec to_e164_from_account(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). to_e164_from_account(Number, ?NE_BINARY = AccountId) -> Converters = get_e164_converters(AccountId), Regexes = kz_json:get_keys(Converters), @@ -148,7 +148,7 @@ get_e164_converters() -> _:_ -> ?DEFAULT_E164_CONVERTERS end. --spec get_e164_converters(ne_binary()) -> kz_json:object(). +-spec get_e164_converters(kz_term:ne_binary()) -> kz_json:object(). get_e164_converters(AccountId) -> try kapps_account_config:get_global(AccountId ,?KNM_CONFIG_CAT @@ -164,7 +164,7 @@ get_e164_converters(AccountId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec maybe_convert_to_e164(ne_binaries(), kz_json:object(), ne_binary()) -> ne_binary(). +-spec maybe_convert_to_e164(kz_term:ne_binaries(), kz_json:object(), kz_term:ne_binary()) -> kz_term:ne_binary(). maybe_convert_to_e164([], _, Number) -> Number; maybe_convert_to_e164([Regex|Regexs], Converters, Number) -> case re:run(Number, Regex, [{'capture', 'all', 'binary'}]) of diff --git a/core/kazoo_number_manager/src/converters/knm_converters.erl b/core/kazoo_number_manager/src/converters/knm_converters.erl index 8da1516719b..4f23431c866 100644 --- a/core/kazoo_number_manager/src/converters/knm_converters.erl +++ b/core/kazoo_number_manager/src/converters/knm_converters.erl @@ -99,16 +99,16 @@ %% @doc %% @end %%-------------------------------------------------------------------- --spec normalize(ne_binary()) -> ne_binary(); - (ne_binaries()) -> ne_binaries(). +-spec normalize(kz_term:ne_binary()) -> kz_term:ne_binary(); + (kz_term:ne_binaries()) -> kz_term:ne_binaries(). normalize(Num=?NE_BINARY) -> (?CONVERTER_MOD):normalize(Num); normalize(Nums) when is_list(Nums) -> [normalize(Num) || Num <- Nums]. --spec normalize(ne_binary(), api_ne_binary()) -> ne_binary(); - (ne_binaries(), api_ne_binary()) -> ne_binaries(). +-spec normalize(kz_term:ne_binary(), kz_term:api_ne_binary()) -> kz_term:ne_binary(); + (kz_term:ne_binaries(), kz_term:api_ne_binary()) -> kz_term:ne_binaries(). normalize(Num=?NE_BINARY, undefined) -> normalize(Num); normalize(Num=?NE_BINARY, AccountId) -> @@ -120,8 +120,8 @@ normalize(Nums, AccountId) when is_list(Nums) -> [normalize(Num, AccountId) || Num <- Nums]. --spec normalize(ne_binary(), ne_binary(), kz_json:object()) -> ne_binary(); - (ne_binaries(), ne_binary(), kz_json:object()) -> ne_binaries(). +-spec normalize(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> kz_term:ne_binary(); + (kz_term:ne_binaries(), kz_term:ne_binary(), kz_json:object()) -> kz_term:ne_binaries(). normalize(Num=?NE_BINARY, ?MATCH_ACCOUNT_RAW(AccountId), DialPlan) -> (?CONVERTER_MOD):normalize(Num, AccountId, DialPlan); normalize(Nums, ?MATCH_ACCOUNT_RAW(AccountId), DialPlan) @@ -133,7 +133,7 @@ normalize(Nums, ?MATCH_ACCOUNT_RAW(AccountId), DialPlan) %% @doc %% @end %%-------------------------------------------------------------------- --spec is_normalized(ne_binary()) -> boolean(). +-spec is_normalized(kz_term:ne_binary()) -> boolean(). is_normalized(Num) -> normalize(Num) =:= Num. @@ -142,7 +142,7 @@ is_normalized(Num) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec is_npan(ne_binary()) -> boolean(). +-spec is_npan(kz_term:ne_binary()) -> boolean(). is_npan(Num) -> to_npan(Num) =:= Num. @@ -151,7 +151,7 @@ is_npan(Num) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec to_npan(ne_binary()) -> ne_binary(). +-spec to_npan(kz_term:ne_binary()) -> kz_term:ne_binary(). to_npan(Num) -> (?CONVERTER_MOD):to_npan(Num). @@ -160,7 +160,7 @@ to_npan(Num) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec is_1npan(ne_binary()) -> boolean(). +-spec is_1npan(kz_term:ne_binary()) -> boolean(). is_1npan(Num) -> to_1npan(Num) =:= Num. @@ -169,7 +169,7 @@ is_1npan(Num) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec to_1npan(ne_binary()) -> ne_binary(). +-spec to_1npan(kz_term:ne_binary()) -> kz_term:ne_binary(). to_1npan(Num) -> (?CONVERTER_MOD):to_1npan(Num). @@ -177,7 +177,7 @@ to_1npan(Num) -> %% @public %% @doc Given a number determine the database name it belongs to. %%-------------------------------------------------------------------- --spec to_db(<<_:40,_:_*8>>) -> api_binary(). +-spec to_db(<<_:40,_:_*8>>) -> kz_term:api_binary(). to_db(<>) -> kz_http_util:urlencode(<>); to_db(_) -> 'undefined'. @@ -188,7 +188,7 @@ to_db(_) -> 'undefined'. %% Returns `{Reconcilables, NotReconcilables}'. %% @end %%-------------------------------------------------------------------- --spec are_reconcilable(ne_binaries()) -> {ne_binaries(), ne_binaries()}. +-spec are_reconcilable(kz_term:ne_binaries()) -> {kz_term:ne_binaries(), kz_term:ne_binaries()}. are_reconcilable(Nums) -> lists:partition(fun is_reconcilable/1, Nums). @@ -197,12 +197,12 @@ are_reconcilable(Nums) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec is_reconcilable(ne_binary()) -> boolean(). +-spec is_reconcilable(kz_term:ne_binary()) -> boolean(). is_reconcilable(Number) -> Num = normalize(Number), is_reconcilable_by_regex(Num, ?RECONCILE_REGEX). --spec is_reconcilable(ne_binary(), ne_binary()) -> boolean(). +-spec is_reconcilable(kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_reconcilable(Number, AccountId) -> Num = normalize(Number, AccountId), is_reconcilable_by_regex(Num, ?RECONCILE_REGEX(AccountId)). @@ -221,7 +221,7 @@ is_reconcilable_by_regex(Num, Regex) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec classify(ne_binary()) -> api_binary(). +-spec classify(kz_term:ne_binary()) -> kz_term:api_binary(). classify(Number) -> Num = normalize(Number), classify_number(Num, kz_json:to_proplist(?CLASSIFIERS)). @@ -242,7 +242,7 @@ available_classifiers() -> %% %% @end %%-------------------------------------------------------------------- --spec available_converters() -> ne_binaries(). +-spec available_converters() -> kz_term:ne_binaries(). available_converters() -> kapps_config:get_ne_binaries(?KNM_CONFIG_CAT, <<"converters">>, ?DEFAULT_CONVERTERS). @@ -264,7 +264,7 @@ default_converter() -> ?CONVERTER_MOD. %% @doc %% @end %%-------------------------------------------------------------------- --spec classify_number(ne_binary(), kz_proplist() | ne_binary()) -> api_binary(). +-spec classify_number(kz_term:ne_binary(), kz_term:proplist() | kz_term:ne_binary()) -> kz_term:api_binary(). classify_number(Num, []) -> lager:debug("unable to classify number ~s", [Num]), 'undefined'; @@ -281,7 +281,7 @@ classify_number(Num, [{Classification, Classifier}|Classifiers]) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_classifier_regex(ne_binary() | kz_json:object()) -> ne_binary(). +-spec get_classifier_regex(kz_term:ne_binary() | kz_json:object()) -> kz_term:ne_binary(). get_classifier_regex(Classifier) when is_binary(Classifier) -> Classifier; get_classifier_regex(JObj) -> diff --git a/core/kazoo_number_manager/src/kapi_discovery.erl b/core/kazoo_number_manager/src/kapi_discovery.erl index 224648a68e9..1b61bd951fc 100644 --- a/core/kazoo_number_manager/src/kapi_discovery.erl +++ b/core/kazoo_number_manager/src/kapi_discovery.erl @@ -101,7 +101,7 @@ %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec number_req(api_terms()) -> +-spec number_req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. number_req(Prop) when is_list(Prop) -> @@ -111,7 +111,7 @@ number_req(Prop) when is_list(Prop) -> end; number_req(JObj) -> number_req(kz_json:to_proplist(JObj)). --spec number_req_v(api_terms()) -> boolean(). +-spec number_req_v(kz_term:api_terms()) -> boolean(). number_req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?NUMBER_REQ_HEADERS, ?NUMBER_REQ_VALUES, ?NUMBER_REQ_TYPES); number_req_v(JObj) -> number_req_v(kz_json:to_proplist(JObj)). @@ -121,7 +121,7 @@ number_req_v(JObj) -> number_req_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec req(api_terms()) -> +-spec req(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. req(Prop) when is_list(Prop) -> @@ -131,7 +131,7 @@ req(Prop) when is_list(Prop) -> end; req(JObj) -> req(kz_json:to_proplist(JObj)). --spec req_v(api_terms()) -> boolean(). +-spec req_v(kz_term:api_terms()) -> boolean(). req_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?DISCOVERY_REQ_HEADERS, ?DISCOVERY_REQ_VALUES, ?DISCOVERY_REQ_TYPES); req_v(JObj) -> req_v(kz_json:to_proplist(JObj)). @@ -142,7 +142,7 @@ req_v(JObj) -> req_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec resp(api_terms()) -> +-spec resp(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. resp(Prop) when is_list(Prop) -> @@ -152,7 +152,7 @@ resp(Prop) when is_list(Prop) -> end; resp(JObj) -> resp(kz_json:to_proplist(JObj)). --spec resp_v(api_terms()) -> boolean(). +-spec resp_v(kz_term:api_terms()) -> boolean(). resp_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?DISCOVERY_RESP_HEADERS, ?DISCOVERY_RESP_VALUES, ?DISCOVERY_RESP_TYPES); resp_v(JObj) -> resp_v(kz_json:to_proplist(JObj)). @@ -163,7 +163,7 @@ resp_v(JObj) -> resp_v(kz_json:to_proplist(JObj)). %% Takes proplist, creates JSON string or error %% @end %%-------------------------------------------------------------------- --spec flush(api_terms()) -> +-spec flush(kz_term:api_terms()) -> {'ok', iolist()} | {'error', string()}. flush(Prop) when is_list(Prop) -> @@ -173,7 +173,7 @@ flush(Prop) when is_list(Prop) -> end; flush(JObj) -> flush(kz_json:to_proplist(JObj)). --spec flush_v(api_terms()) -> boolean(). +-spec flush_v(kz_term:api_terms()) -> boolean(). flush_v(Prop) when is_list(Prop) -> kz_api:validate(Prop, ?DISCOVERY_FLUSH_HEADERS, ?DISCOVERY_FLUSH_VALUES, ?DISCOVERY_FLUSH_TYPES); flush_v(JObj) -> flush_v(kz_json:to_proplist(JObj)). @@ -182,11 +182,11 @@ flush_v(JObj) -> flush_v(kz_json:to_proplist(JObj)). %% @doc Bind AMQP Queue for routing requests %% @end %%-------------------------------------------------------------------- --spec bind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec bind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. bind_q(Queue, _Props) -> amqp_util:bind_q_to_exchange(Queue, ?DISCOVERY_RK, ?DISCOVERY_EXCHANGE). --spec unbind_q(ne_binary(), kz_proplist()) -> 'ok'. +-spec unbind_q(kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. unbind_q(Queue, _Props) -> amqp_util:unbind_q_from_exchange(Queue, ?DISCOVERY_RK, ?DISCOVERY_EXCHANGE). @@ -199,39 +199,39 @@ unbind_q(Queue, _Props) -> declare_exchanges() -> amqp_util:new_exchange(?DISCOVERY_EXCHANGE, ?DISCOVERY_EXCHANGE_TYPE). --spec publish_flush(api_terms()) -> 'ok'. --spec publish_flush(api_terms(), binary()) -> 'ok'. +-spec publish_flush(kz_term:api_terms()) -> 'ok'. +-spec publish_flush(kz_term:api_terms(), binary()) -> 'ok'. publish_flush(JObj) -> publish_flush(JObj, ?DEFAULT_CONTENT_TYPE). publish_flush(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?DISCOVERY_FLUSH_VALUES, fun flush/1), amqp_util:basic_publish(?DISCOVERY_EXCHANGE, ?DISCOVERY_FLUSH_RK, Payload, ContentType). --spec publish_req(api_terms()) -> 'ok'. --spec publish_req(api_terms(), binary()) -> 'ok'. +-spec publish_req(kz_term:api_terms()) -> 'ok'. +-spec publish_req(kz_term:api_terms(), binary()) -> 'ok'. publish_req(JObj) -> publish_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_req(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?DISCOVERY_REQ_VALUES, fun req/1), amqp_util:basic_publish(?DISCOVERY_EXCHANGE, ?DISCOVERY_REQ_RK, Payload, ContentType). --spec publish_number_req(api_terms()) -> 'ok'. --spec publish_number_req(api_terms(), binary()) -> 'ok'. +-spec publish_number_req(kz_term:api_terms()) -> 'ok'. +-spec publish_number_req(kz_term:api_terms(), binary()) -> 'ok'. publish_number_req(JObj) -> publish_number_req(JObj, ?DEFAULT_CONTENT_TYPE). publish_number_req(Req, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Req, ?NUMBER_REQ_VALUES, fun number_req/1), amqp_util:basic_publish(?DISCOVERY_EXCHANGE, ?NUMBER_REQ_RK, Payload, ContentType). --spec publish_resp(ne_binary(), api_terms()) -> 'ok'. --spec publish_resp(ne_binary(), api_terms(), ne_binary()) -> 'ok'. +-spec publish_resp(kz_term:ne_binary(), kz_term:api_terms()) -> 'ok'. +-spec publish_resp(kz_term:ne_binary(), kz_term:api_terms(), kz_term:ne_binary()) -> 'ok'. publish_resp(RespQ, JObj) -> publish_resp(RespQ, JObj, ?DEFAULT_CONTENT_TYPE). publish_resp(RespQ, Resp, ContentType) -> {'ok', Payload} = kz_api:prepare_api_payload(Resp, ?DISCOVERY_RESP_VALUES, fun resp/1), amqp_util:targeted_publish(RespQ, Payload, ContentType). --spec query_id(kz_json:object() | kz_proplist()) -> ne_binary(). +-spec query_id(kz_json:object() | kz_term:proplist()) -> kz_term:ne_binary(). query_id(Props) when is_list(Props) -> props:get_ne_binary_value(?KEY_QUERY_ID, Props); query_id(JObj) -> @@ -249,10 +249,10 @@ offset(JObj) -> results(JObj) -> kz_json:get_value(?KEY_RESULTS, JObj). --spec prefix(kz_json:object()) -> ne_binary(). +-spec prefix(kz_json:object()) -> kz_term:ne_binary(). prefix(JObj) -> kz_json:get_value(?KEY_PREFIX, JObj). --spec number(kz_json:object()) -> ne_binary(). +-spec number(kz_json:object()) -> kz_term:ne_binary(). number(JObj) -> kz_json:get_value(?KEY_NUMBER, JObj). diff --git a/core/kazoo_number_manager/src/kazoo_number_manager_app.erl b/core/kazoo_number_manager/src/kazoo_number_manager_app.erl index 2e929d8aeb1..d4e1e473b95 100644 --- a/core/kazoo_number_manager/src/kazoo_number_manager_app.erl +++ b/core/kazoo_number_manager/src/kazoo_number_manager_app.erl @@ -18,7 +18,7 @@ %% =================================================================== %% Application callbacks %% =================================================================== --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_StartType, _StartArgs) -> declare_exchanges(), _ = kz_datamgr:register_view('numbers', ?APP, "views/numbers.json"), diff --git a/core/kazoo_number_manager/src/kazoo_number_manager_maintenance.erl b/core/kazoo_number_manager/src/kazoo_number_manager_maintenance.erl index 03304ffbc34..fb03f958260 100644 --- a/core/kazoo_number_manager/src/kazoo_number_manager_maintenance.erl +++ b/core/kazoo_number_manager/src/kazoo_number_manager_maintenance.erl @@ -74,12 +74,12 @@ carrier_module_usage() -> carrier_module_usage(knm_util:get_all_number_dbs(), dict:new()). --spec carrier_module_usage(text()) -> 'ok'. +-spec carrier_module_usage(kz_term:text()) -> 'ok'. carrier_module_usage(Prefix) -> Database = knm_converters:to_db(Prefix), carrier_module_usage([Database], dict:new()). --spec carrier_module_usage(ne_binaries(), dict:dict()) -> 'ok'. +-spec carrier_module_usage(kz_term:ne_binaries(), dict:dict()) -> 'ok'. carrier_module_usage([], Totals) -> io:format("Totals:~n", []), F = fun (Module, Count) -> io:format(" ~s: ~p~n", [Module, Count]) end, @@ -89,14 +89,14 @@ carrier_module_usage([Database|Databases], Totals0) -> Totals1 = get_carrier_module_usage(Database, Totals0), carrier_module_usage(Databases, Totals1). --spec get_carrier_module_usage(ne_binary(), dict:dict()) -> dict:dict(). +-spec get_carrier_module_usage(kz_term:ne_binary(), dict:dict()) -> dict:dict(). get_carrier_module_usage(Database, Totals) -> io:format("~s:~n", [Database]), ViewOptions = ['reduce', 'group'], {'ok', JObjs} = kz_datamgr:get_results(Database, <<"numbers/module_name">>, ViewOptions), log_carrier_module_usage(JObjs, Database, Totals). --spec log_carrier_module_usage(kz_json:objects(), ne_binary(), dict:dict()) -> dict:dict(). +-spec log_carrier_module_usage(kz_json:objects(), kz_term:ne_binary(), dict:dict()) -> dict:dict(). log_carrier_module_usage([], _, Totals) -> Totals; log_carrier_module_usage([JObj|JObjs], Database, Totals0) -> Module = kz_json:get_value(<<"key">>, JObj), @@ -111,16 +111,16 @@ log_carrier_module_usage([JObj|JObjs], Database, Totals0) -> %% %% @end %%-------------------------------------------------------------------- --spec convert_carrier_module(ne_binary(), ne_binary()) -> 'ok'. +-spec convert_carrier_module(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. convert_carrier_module(Source, Target) -> convert_carrier_module_database(Source, Target, knm_util:get_all_number_dbs()). --spec convert_carrier_module(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec convert_carrier_module(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. convert_carrier_module(Source, Target, Prefix) -> Database = knm_converters:to_db(Prefix), convert_carrier_module_database(Source, Target, [Database]). --spec convert_carrier_module_database(ne_binary(), ne_binary(), ne_binaries()) -> 'ok'. +-spec convert_carrier_module_database(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binaries()) -> 'ok'. convert_carrier_module_database(_, _, []) -> 'ok'; convert_carrier_module_database(Source, Target, [Database|Databases]) -> io:format("attempt to convert numbers with carrier module ~s to ~s in database ~s~n" @@ -130,7 +130,7 @@ convert_carrier_module_database(Source, Target, [Database|Databases]) -> convert_carrier_module_numbers([kz_doc:id(JObj) || JObj <- JObjs], Target), convert_carrier_module_database(Source, Target, Databases). --spec convert_carrier_module_numbers(ne_binaries(), ne_binary()) -> 'ok'. +-spec convert_carrier_module_numbers(kz_term:ne_binaries(), kz_term:ne_binary()) -> 'ok'. convert_carrier_module_numbers(Nums, Target) -> case lists:member(Target, knm_carriers:all_modules()) of 'false' -> io:format("Bad carrier module: ~s\n", [Target]); @@ -142,14 +142,14 @@ convert_carrier_module_numbers(Nums, Target) -> print_convert_carrier_failure(Target, TotalLength, KOs) end. --spec print_convert_carrier_success(ne_binary(), non_neg_integer(), ne_binaries()) -> 'ok'. +-spec print_convert_carrier_success(kz_term:ne_binary(), non_neg_integer(), kz_term:ne_binaries()) -> 'ok'. print_convert_carrier_success(_, _, []) -> 'ok'; print_convert_carrier_success(Target, TotalLength, Converted) -> io:format("updated carrier module to ~s for ~b/~b number(s):\n", [Target, length(Converted), TotalLength]), F = fun (N) -> io:format("\t~s\n", [knm_phone_number:number(knm_number:phone_number(N))]) end, lists:foreach(F, Converted). --spec print_convert_carrier_failure(ne_binary(), non_neg_integer(), map()) -> 'ok'. +-spec print_convert_carrier_failure(kz_term:ne_binary(), non_neg_integer(), map()) -> 'ok'. print_convert_carrier_failure(Target, TotalLength, KOs) -> case maps:size(KOs) of 0 -> 'ok'; @@ -160,7 +160,7 @@ print_convert_carrier_failure(Target, TotalLength, KOs) -> 'ok' end. --spec convert_carrier_module_number(ne_binary(), ne_binary()) -> 'ok'. +-spec convert_carrier_module_number(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. convert_carrier_module_number(Num, Target) -> convert_carrier_module_numbers([Num], Target). @@ -175,14 +175,14 @@ refresh_numbers_dbs() -> NumberDbs = knm_util:get_all_number_dbs(), refresh_numbers_dbs(NumberDbs, length(NumberDbs)). --spec refresh_numbers_dbs(ne_binaries(), non_neg_integer()) -> 'ok'. +-spec refresh_numbers_dbs(kz_term:ne_binaries(), non_neg_integer()) -> 'ok'. refresh_numbers_dbs([], _) -> 'ok'; refresh_numbers_dbs([NumberDb|NumberDbs], Total) -> ?SUP_LOG_DEBUG("(~p/~p) updating number db ~s", [length(NumberDbs) + 1, Total, NumberDb]), _ = refresh_numbers_db(NumberDb), refresh_numbers_dbs(NumberDbs, Total). --spec refresh_numbers_db(ne_binary()) -> 'ok'. +-spec refresh_numbers_db(kz_term:ne_binary()) -> 'ok'. refresh_numbers_db(<> = NumberDb) -> {'ok', _} = kz_datamgr:revise_doc_from_file(NumberDb ,'kazoo_number_manager' @@ -198,7 +198,7 @@ refresh_numbers_db(_Thing) -> ?SUP_LOG_DEBUG("skipping badly formed ~s", [_Thing]). %% @public --spec update_number_services_view(ne_binary()) -> no_return. +-spec update_number_services_view(kz_term:ne_binary()) -> no_return. update_number_services_view(?MATCH_ACCOUNT_RAW(AccountId)) -> update_number_services_view(kz_util:format_account_db(AccountId)); update_number_services_view(?MATCH_ACCOUNT_ENCODED(_)=AccountDb) -> @@ -234,8 +234,8 @@ update_number_services_view(?MATCH_ACCOUNT_ENCODED(_)=AccountDb) -> end. %% @public --spec fix_accounts_numbers([ne_binary()]) -> 'ok'. --spec fix_account_numbers(ne_binary()) -> 'ok'. +-spec fix_accounts_numbers([kz_term:ne_binary()]) -> 'ok'. +-spec fix_account_numbers(kz_term:ne_binary()) -> 'ok'. fix_accounts_numbers(Accounts) -> AccountDbs = lists:usort([kz_util:format_account_db(Account) || Account <- Accounts]), _ = purge_discovery(), @@ -285,7 +285,7 @@ fix_account_numbers(Account = ?NE_BINARY) -> log_alien(_AccountDb, _DID) -> ?SUP_LOG_DEBUG("########## found alien [~s] doc: ~s ##########", [_AccountDb, _DID]). --spec fix_number(ne_binary(), ne_binary(), ne_binary()) -> knm_number_return(). +-spec fix_number(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> knm_number_return(). fix_number(Num, AuthBy, AccountDb) -> UsedBy = app_using(knm_converters:normalize(Num), AccountDb), Routines = [{fun knm_phone_number:set_used_by/2, UsedBy} @@ -304,7 +304,7 @@ migrate() -> pforeach(fun migrate/1, kapps_util:get_all_accounts()), migrate_unassigned_numbers(). --spec migrate(ne_binary()) -> 'ok'. +-spec migrate(kz_term:ne_binary()) -> 'ok'. migrate(Account) -> AccountDb = kz_util:format_account_db(Account), fix_account_numbers(AccountDb), @@ -312,13 +312,13 @@ migrate(Account) -> 'ok'. -spec migrate_unassigned_numbers() -> 'ok'. --spec migrate_unassigned_numbers(ne_binary(), integer()) -> 'ok'. +-spec migrate_unassigned_numbers(kz_term:ne_binary(), integer()) -> 'ok'. migrate_unassigned_numbers() -> ?SUP_LOG_DEBUG("********** fixing unassigned numbers **********", []), pforeach(fun migrate_unassigned_numbers/1, knm_util:get_all_number_dbs()), ?SUP_LOG_DEBUG("********** finished fixing unassigned numbers **********", []). --spec migrate_unassigned_numbers(ne_binary()) -> ok. +-spec migrate_unassigned_numbers(kz_term:ne_binary()) -> ok. migrate_unassigned_numbers(<> = NumberDb) -> ?SUP_LOG_DEBUG("########## start fixing ~s ##########", [NumberDb]), migrate_unassigned_numbers(NumberDb, 0), @@ -362,7 +362,7 @@ escape(?NE_BINARY=Bin0) -> <> = Bin, Escaped. --spec number_services_map(ne_binaries(), ne_binaries()) -> ne_binary(). +-spec number_services_map(kz_term:ne_binaries(), kz_term:ne_binaries()) -> kz_term:ne_binary(). number_services_map(Classifications, Regexs) -> iolist_to_binary( ["function(doc) {" @@ -387,7 +387,7 @@ number_services_map(Classifications, Regexs) -> "}" ]). --spec number_services_red() -> ne_binary(). +-spec number_services_red() -> kz_term:ne_binary(). number_services_red() -> iolist_to_binary( ["function(Keys, Values, _Rereduce) {" @@ -438,7 +438,7 @@ pforeach(Fun, Arg1s) ], plists:foreach(Fun, Arg1s, Malt). --spec fix_docs(ne_binary(), ne_binary(), ne_binary()) -> ok. +-spec fix_docs(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> ok. fix_docs(AccountDb, NumberDb, DID) -> Res = kz_datamgr:open_doc(AccountDb, DID), fix_docs(Res, AccountDb, NumberDb, DID). @@ -504,7 +504,7 @@ account_db_from_number_doc(NumDoc) -> AccountId -> kz_util:format_account_db(AccountId) end. --spec fix_unassign_doc(ne_binary()) -> 'ok'. +-spec fix_unassign_doc(kz_term:ne_binary()) -> 'ok'. fix_unassign_doc(DID) -> Setters = [{fun knm_phone_number:set_used_by/2, undefined} ,fun knm_phone_number:remove_denied_features/1 @@ -514,11 +514,11 @@ fix_unassign_doc(DID) -> {error, _R} -> ?SUP_LOG_DEBUG("failed fixing unassigned ~s: ~p", [DID, _R]) end. --type dids() :: gb_sets:set(ne_binary()). --spec get_DIDs(ne_binary(), ne_binary()) -> dids(). +-type dids() :: gb_sets:set(kz_term:ne_binary()). +-spec get_DIDs(kz_term:ne_binary(), kz_term:ne_binary()) -> dids(). get_DIDs(AccountDb, View) -> get_DIDs(AccountDb, View, []). --spec get_DIDs(ne_binary(), ne_binary(), kz_proplist()) -> dids(). +-spec get_DIDs(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> dids(). get_DIDs(AccountDb, View, ViewOptions) -> ?SUP_LOG_DEBUG("[~s] getting numbers from ~s", [AccountDb, View]), case kz_datamgr:get_result_keys(AccountDb, View, ViewOptions) of @@ -537,7 +537,7 @@ get_DIDs_callflow(AccountDb, ViewOptions) -> get_DIDs_trunkstore(AccountDb, ViewOptions) -> get_DIDs(AccountDb, <<"trunkstore/lookup_did">>, ViewOptions). --spec get_DIDs_assigned_to(ne_binary(), ne_binary()) -> dids(). +-spec get_DIDs_assigned_to(kz_term:ne_binary(), kz_term:ne_binary()) -> dids(). get_DIDs_assigned_to(NumberDb, AssignedTo) -> ViewOptions = [{startkey, [AssignedTo]} ,{endkey, [AssignedTo, kz_json:new()]} @@ -568,7 +568,7 @@ cleanse(JObj) -> ). --spec app_using(ne_binary(), ne_binary()) -> api_ne_binary(). +-spec app_using(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_ne_binary(). -ifdef(TEST). app_using(?TEST_OLD7_NUM, ?CHILD_ACCOUNT_DB) -> <<"trunkstore">>; app_using(?NE_BINARY, ?MATCH_ACCOUNT_ENCODED(_)) -> undefined. @@ -577,7 +577,7 @@ app_using(Num, AccountDb) -> app_using(Num, AccountDb, get(callflow_DIDs), get(trunkstore_DIDs)). -type api_dids() :: undefined | dids(). --spec app_using(ne_binary(), ne_binary(), api_dids(), api_dids()) -> api_ne_binary(). +-spec app_using(kz_term:ne_binary(), kz_term:ne_binary(), api_dids(), api_dids()) -> kz_term:api_ne_binary(). app_using(Num, AccountDb, undefined, TrunkstoreNums) -> CallflowNums = get_DIDs_callflow(AccountDb, [{key, Num}]), app_using(Num, AccountDb, CallflowNums, TrunkstoreNums); @@ -595,7 +595,7 @@ app_using(Num, _, CallflowNums, TrunkstoreNums) -> end. -endif. --spec is_assigned_to(ne_binary(), ne_binary(), ne_binary()) -> boolean(). +-spec is_assigned_to(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_assigned_to(AccountDb, DID, AccountId) -> case kz_datamgr:open_doc(AccountDb, DID) of {error, _R} -> @@ -606,14 +606,14 @@ is_assigned_to(AccountDb, DID, AccountId) -> end. --spec generate_numbers(ne_binary(), ne_binary(), pos_integer(), non_neg_integer()) -> 'ok'. +-spec generate_numbers(kz_term:ne_binary(), kz_term:ne_binary(), pos_integer(), non_neg_integer()) -> 'ok'. generate_numbers(Type, AccountId, StartingNumber, Quantity) -> M = kz_term:to_atom(<<"knm_", Type/binary>>, 'true'), M:generate_numbers(AccountId, kz_term:to_integer(StartingNumber), kz_term:to_integer(Quantity)). %% @public --spec delete(ne_binary()) -> 'no_return'. +-spec delete(kz_term:ne_binary()) -> 'no_return'. delete(Num) -> case knm_number:delete(Num, knm_number_options:default()) of {'ok', _} -> io:format("Removed ~s\n", [Num]); @@ -630,7 +630,7 @@ purge_discovery() -> 'no_return'. %% @public --spec purge_deleted(ne_binary()) -> 'no_return'. +-spec purge_deleted(kz_term:ne_binary()) -> 'no_return'. purge_deleted(Prefix) -> purge_number_db(<>, ?NUMBER_STATE_DELETED), 'no_return'. @@ -643,12 +643,12 @@ purge_deleted() -> 'no_return'. %% @public --spec purge_discovery(ne_binary()) -> 'no_return'. +-spec purge_discovery(kz_term:ne_binary()) -> 'no_return'. purge_discovery(Prefix) -> purge_number_db(<>, ?NUMBER_STATE_DISCOVERY), 'no_return'. --spec purge_number_db(ne_binary(), ne_binary()) -> 'ok'. +-spec purge_number_db(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. purge_number_db(NumberDb, State) -> ViewOptions = [{'startkey', [State]} ,{'endkey', [State, kz_json:new()]} @@ -674,7 +674,7 @@ is_feature_valid(Thing) -> lists:member(Thing, ?ALL_KNM_FEATURES). %% @private --spec invalid_feature(ne_binary()) -> no_return. +-spec invalid_feature(kz_term:ne_binary()) -> no_return. invalid_feature(Feature) -> io:format("Feature '~s' is not a known feature.\n", [Feature]), all_features(). @@ -686,12 +686,12 @@ all_features() -> no_return. %% @private --spec list_features(ne_binaries()) -> iodata(). +-spec list_features(kz_term:ne_binaries()) -> iodata(). list_features(Features) -> kz_util:iolist_join($\s, Features). %% @private --spec error_with_number(ne_binary(), any()) -> no_return. +-spec error_with_number(kz_term:ne_binary(), any()) -> no_return. error_with_number(Num, Error) -> Reason = case kz_json:is_json_object(Error) of false -> Error; @@ -701,7 +701,7 @@ error_with_number(Num, Error) -> no_return. %% @private --spec print_feature_permissions(ne_binaries(), ne_binaries()) -> no_return. +-spec print_feature_permissions(kz_term:ne_binaries(), kz_term:ne_binaries()) -> no_return. print_feature_permissions(Allowed, Denied) -> io:format("\tFeatures allowed: ~s\n" "\tFeatures denied: ~s\n" @@ -720,7 +720,7 @@ list_number_feature_permissions(N) -> print_feature_permissions(Allowed, Denied). %% @private --spec edit_feature_permissions_on_number(ne_binary(), fun(), ne_binary()) -> no_return. +-spec edit_feature_permissions_on_number(kz_term:ne_binary(), fun(), kz_term:ne_binary()) -> no_return. edit_feature_permissions_on_number(Num, Fun, Feature) -> case is_feature_valid(Feature) of false -> invalid_feature(Feature); @@ -733,7 +733,7 @@ edit_feature_permissions_on_number(Num, Fun, Feature) -> end. %% @public --spec feature_permissions_on_number(ne_binary()) -> no_return. +-spec feature_permissions_on_number(kz_term:ne_binary()) -> no_return. feature_permissions_on_number(Num) -> case knm_number:get(Num) of {error, Error} -> error_with_number(Num, Error); @@ -741,27 +741,27 @@ feature_permissions_on_number(Num) -> end. %% @public --spec add_allowed_feature_on_number(ne_binary(), ne_binary()) -> no_return. +-spec add_allowed_feature_on_number(kz_term:ne_binary(), kz_term:ne_binary()) -> no_return. add_allowed_feature_on_number(?NE_BINARY=Feature, ?NE_BINARY=Num) -> edit_feature_permissions_on_number(Num, fun knm_phone_number:add_allowed_feature/2, Feature). %% @public --spec remove_allowed_feature_on_number(ne_binary(), ne_binary()) -> no_return. +-spec remove_allowed_feature_on_number(kz_term:ne_binary(), kz_term:ne_binary()) -> no_return. remove_allowed_feature_on_number(?NE_BINARY=Feature, ?NE_BINARY=Num) -> edit_feature_permissions_on_number(Num, fun knm_phone_number:remove_allowed_feature/2, Feature). %% @public --spec add_denied_feature_on_number(ne_binary(), ne_binary()) -> no_return. +-spec add_denied_feature_on_number(kz_term:ne_binary(), kz_term:ne_binary()) -> no_return. add_denied_feature_on_number(?NE_BINARY=Feature, ?NE_BINARY=Num) -> edit_feature_permissions_on_number(Num, fun knm_phone_number:add_denied_feature/2, Feature). %% @public --spec remove_denied_feature_on_number(ne_binary(), ne_binary()) -> no_return. +-spec remove_denied_feature_on_number(kz_term:ne_binary(), kz_term:ne_binary()) -> no_return. remove_denied_feature_on_number(?NE_BINARY=Feature, ?NE_BINARY=Num) -> edit_feature_permissions_on_number(Num, fun knm_phone_number:remove_denied_feature/2, Feature). %% @public --spec feature_permissions_on_reseller_of(ne_binary()) -> no_return. +-spec feature_permissions_on_reseller_of(kz_term:ne_binary()) -> no_return. feature_permissions_on_reseller_of(?MATCH_ACCOUNT_RAW(AccountId)) -> Allowed = empty_list_when_undefined(?FEATURES_ALLOWED_RESELLER(AccountId)), Denied = empty_list_when_undefined(?FEATURES_DENIED_RESELLER(AccountId)), @@ -770,12 +770,12 @@ feature_permissions_on_reseller_of(?MATCH_ACCOUNT_RAW(AccountId)) -> print_feature_permissions(Allowed, Denied). %% @private --spec empty_list_when_undefined(api_list()) -> ne_binaries(). +-spec empty_list_when_undefined(kz_term:api_list()) -> kz_term:ne_binaries(). empty_list_when_undefined(undefined) -> []; empty_list_when_undefined(NeBinaries) -> NeBinaries. %% @private --spec edit_allowed_feature_permissions_on_reseller_of(ne_binary(), fun(), ne_binary()) -> no_return. +-spec edit_allowed_feature_permissions_on_reseller_of(kz_term:ne_binary(), fun(), kz_term:ne_binary()) -> no_return. edit_allowed_feature_permissions_on_reseller_of(AccountId, Fun, Feature) -> case is_feature_valid(Feature) of false -> invalid_feature(Feature); @@ -788,7 +788,7 @@ edit_allowed_feature_permissions_on_reseller_of(AccountId, Fun, Feature) -> end. %% @private --spec edit_denied_feature_permissions_on_reseller_of(ne_binary(), fun(), ne_binary()) -> no_return. +-spec edit_denied_feature_permissions_on_reseller_of(kz_term:ne_binary(), fun(), kz_term:ne_binary()) -> no_return. edit_denied_feature_permissions_on_reseller_of(AccountId, Fun, Feature) -> case is_feature_valid(Feature) of false -> invalid_feature(Feature); @@ -801,24 +801,24 @@ edit_denied_feature_permissions_on_reseller_of(AccountId, Fun, Feature) -> end. %% @public --spec add_allowed_feature_on_reseller_of(ne_binary(), ne_binary()) -> no_return. +-spec add_allowed_feature_on_reseller_of(kz_term:ne_binary(), kz_term:ne_binary()) -> no_return. add_allowed_feature_on_reseller_of(?NE_BINARY=Feature, ?MATCH_ACCOUNT_RAW(AccountId)) -> Cons = fun (AFeature, Features) -> [AFeature|Features] end, edit_allowed_feature_permissions_on_reseller_of(AccountId, Cons, Feature). %% @public --spec remove_allowed_feature_on_reseller_of(ne_binary(), ne_binary()) -> no_return. +-spec remove_allowed_feature_on_reseller_of(kz_term:ne_binary(), kz_term:ne_binary()) -> no_return. remove_allowed_feature_on_reseller_of(?NE_BINARY=Feature, ?MATCH_ACCOUNT_RAW(AccountId)) -> edit_allowed_feature_permissions_on_reseller_of(AccountId, fun lists:delete/2, Feature). %% @public --spec add_denied_feature_on_reseller_of(ne_binary(), ne_binary()) -> no_return. +-spec add_denied_feature_on_reseller_of(kz_term:ne_binary(), kz_term:ne_binary()) -> no_return. add_denied_feature_on_reseller_of(?NE_BINARY=Feature, ?MATCH_ACCOUNT_RAW(AccountId)) -> Cons = fun (AFeature, Features) -> [AFeature|Features] end, edit_denied_feature_permissions_on_reseller_of(AccountId, Cons, Feature). %% @public --spec remove_denied_feature_on_reseller_of(ne_binary(), ne_binary()) -> no_return. +-spec remove_denied_feature_on_reseller_of(kz_term:ne_binary(), kz_term:ne_binary()) -> no_return. remove_denied_feature_on_reseller_of(?NE_BINARY=Feature, ?MATCH_ACCOUNT_RAW(AccountId)) -> edit_denied_feature_permissions_on_reseller_of(AccountId, fun lists:delete/2, Feature). @@ -835,13 +835,13 @@ reset_allowed_features_to_defaults_on_system_config() -> set_features_on_system_config(?DEFAULT_FEATURES_ALLOWED_SYSTEM). %% @private --spec set_features_on_system_config(ne_binaries()) -> no_return. +-spec set_features_on_system_config(kz_term:ne_binaries()) -> no_return. set_features_on_system_config(Features) -> _ = kapps_config:set(?KNM_CONFIG_CAT, ?KEY_FEATURES_ALLOW, lists:usort(Features)), feature_permissions_on_system_config(). %% @private --spec edit_allowed_feature_permissions_on_system_config(fun(), ne_binary()) -> no_return. +-spec edit_allowed_feature_permissions_on_system_config(fun(), kz_term:ne_binary()) -> no_return. edit_allowed_feature_permissions_on_system_config(Fun, Feature) -> case is_feature_valid(Feature) of false -> invalid_feature(Feature); @@ -851,13 +851,13 @@ edit_allowed_feature_permissions_on_system_config(Fun, Feature) -> end. %% @public --spec add_allowed_feature_on_system_config(ne_binary()) -> no_return. +-spec add_allowed_feature_on_system_config(kz_term:ne_binary()) -> no_return. add_allowed_feature_on_system_config(?NE_BINARY=Feature) -> Cons = fun (AFeature, Features) -> [AFeature|Features] end, edit_allowed_feature_permissions_on_system_config(Cons, Feature). %% @public --spec remove_allowed_feature_on_system_config(ne_binary()) -> no_return. +-spec remove_allowed_feature_on_system_config(kz_term:ne_binary()) -> no_return. remove_allowed_feature_on_system_config(?NE_BINARY=Feature) -> edit_allowed_feature_permissions_on_system_config(fun lists:delete/2, Feature). diff --git a/core/kazoo_number_manager/src/kazoo_number_manager_sup.erl b/core/kazoo_number_manager/src/kazoo_number_manager_sup.erl index 44d3d9d8e0f..4a4863d5cc7 100644 --- a/core/kazoo_number_manager/src/kazoo_number_manager_sup.erl +++ b/core/kazoo_number_manager/src/kazoo_number_manager_sup.erl @@ -35,7 +35,7 @@ %% =================================================================== %% API functions %% =================================================================== --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -43,7 +43,7 @@ start_link() -> %% Supervisor callbacks %% =================================================================== --spec init([]) -> sup_init_ret(). +-spec init([]) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, diff --git a/core/kazoo_number_manager/src/knm_config.erl b/core/kazoo_number_manager/src/knm_config.erl index 7fef6560630..5d77d92dd12 100644 --- a/core/kazoo_number_manager/src/knm_config.erl +++ b/core/kazoo_number_manager/src/knm_config.erl @@ -27,11 +27,11 @@ should_age() -> should_permanently_delete() -> kapps_config:get_is_true(?KNM_CONFIG_CAT, <<"should_permanently_delete">>, 'false'). --spec released_state() -> ne_binary(). +-spec released_state() -> kz_term:ne_binary(). released_state() -> kapps_config:get_ne_binary(?KNM_CONFIG_CAT, <<"released_state">>, ?NUMBER_STATE_AVAILABLE). --spec locality_url() -> api_ne_binary(). +-spec locality_url() -> kz_term:api_ne_binary(). locality_url() -> kapps_config:get_ne_binary(?LOCALITY_CONFIG_CAT, <<"url">>, ?DEFAULT_LOCALITY_URL). diff --git a/core/kazoo_number_manager/src/knm_errors.erl b/core/kazoo_number_manager/src/knm_errors.erl index dea3f41e974..73c2a2ab303 100644 --- a/core/kazoo_number_manager/src/knm_errors.erl +++ b/core/kazoo_number_manager/src/knm_errors.erl @@ -38,7 +38,7 @@ -define(CAUSE, <<"cause">>). -define(MESSAGE, <<"message">>). --type reason() :: atom() | ne_binary(). +-type reason() :: atom() | kz_term:ne_binary(). -type error() :: kz_json:object(). -type kn() :: knm_number:knm_number(). @@ -52,7 +52,7 @@ ,thrown_error/0 ]). --spec unspecified(any(), kn() | ne_binary()) -> no_return(). +-spec unspecified(any(), kn() | kz_term:ne_binary()) -> no_return(). unspecified(Error, Number) -> throw({'error', Error, Number}). @@ -60,11 +60,11 @@ unspecified(Error, Number) -> unauthorized() -> throw({'error', 'unauthorized'}). --spec number_exists(ne_binary()) -> no_return(). +-spec number_exists(kz_term:ne_binary()) -> no_return(). number_exists(DID) -> throw({'error', 'number_exists', DID}). --spec invalid_state_transition(kn() | kpn(), api_ne_binary(), ne_binary()) -> no_return(). +-spec invalid_state_transition(kn() | kpn(), kz_term:api_ne_binary(), kz_term:ne_binary()) -> no_return(). invalid_state_transition(Number, undefined, ToState) -> invalid_state_transition(Number, <<"(nothing)">>, ToState); invalid_state_transition(Number, FromState, ToState) -> @@ -75,7 +75,7 @@ invalid_state_transition(Number, FromState, ToState) -> no_change_required(Number) -> throw({'error', 'no_change_required', Number}). --spec service_restriction(kn(), ne_binary()) -> no_return(). +-spec service_restriction(kn(), kz_term:ne_binary()) -> no_return(). service_restriction(Number, Message) -> throw({'error', 'service_restriction', Number, Message}). @@ -87,7 +87,7 @@ carrier_not_specified(Number) -> not_enough_credit(Number, Units) -> throw({'error', 'not_enough_credit', Number, Units}). --spec invalid(kn(), ne_binary()) -> no_return(). +-spec invalid(kn(), kz_term:ne_binary()) -> no_return(). invalid(Number, Reason) -> throw({'error', 'invalid', Number, Reason}). @@ -103,11 +103,11 @@ assign_failure(PhoneNumber, E) -> database_error(E, PhoneNumber) -> throw({'error', 'database_error', PhoneNumber, E}). --spec number_is_porting(ne_binary()) -> no_return(). +-spec number_is_porting(kz_term:ne_binary()) -> no_return(). number_is_porting(Num) -> throw({'error', 'number_is_porting', Num}). --spec by_carrier(module(), ne_binary() | atom(), ne_binary() | kn()) -> no_return(). +-spec by_carrier(module(), kz_term:ne_binary() | atom(), kz_term:ne_binary() | kn()) -> no_return(). by_carrier(Carrier, E, Num) when is_binary(Num) -> throw({'error', 'by_carrier', Num, {Carrier,E}}); by_carrier(Carrier, E, Number) -> @@ -121,9 +121,9 @@ by_carrier(Carrier, E, Number) -> %%-------------------------------------------------------------------- -spec to_json(reason()) -> error(). --spec to_json(reason(), api_ne_binary()) -> +-spec to_json(reason(), kz_term:api_ne_binary()) -> error(). --spec to_json(reason(), api_ne_binary(), api_ne_binary()) -> +-spec to_json(reason(), kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> error(). to_json(Reason)-> to_json(Reason, 'undefined'). @@ -176,7 +176,7 @@ to_json(Reason, _, Cause) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec build_error(integer(), atom(), api_binary(), api_binary()) -> +-spec build_error(integer(), atom(), kz_term:api_binary(), kz_term:api_binary()) -> error(). build_error(Code, Error, Message, Cause) -> kz_json:from_list( @@ -190,18 +190,18 @@ build_error(Code, Error, Message, Cause) -> ] ). --spec code(error()) -> api_integer(). +-spec code(error()) -> kz_term:api_integer(). code(JObj) -> kz_json:get_value(?CODE, JObj). --spec error(error()) -> api_binary(). +-spec error(error()) -> kz_term:api_binary(). error(JObj) -> kz_json:get_value(?ERROR, JObj). --spec cause(error()) -> api_binary(). +-spec cause(error()) -> kz_term:api_binary(). cause(JObj) -> kz_json:get_value(?CAUSE, JObj). --spec message(error()) -> api_binary(). +-spec message(error()) -> kz_term:api_binary(). message(JObj) -> kz_json:get_value(?MESSAGE, JObj). diff --git a/core/kazoo_number_manager/src/knm_gen_carrier.erl b/core/kazoo_number_manager/src/knm_gen_carrier.erl index 404e33e99cd..d29e81ea3b0 100644 --- a/core/kazoo_number_manager/src/knm_gen_carrier.erl +++ b/core/kazoo_number_manager/src/knm_gen_carrier.erl @@ -13,7 +13,7 @@ -include("knm.hrl"). --callback find_numbers(ne_binary(), pos_integer(), knm_carriers:options()) -> +-callback find_numbers(kz_term:ne_binary(), pos_integer(), knm_carriers:options()) -> {'ok', knm_number:knm_numbers()} | {'bulk', knm_number:knm_numbers()} | {'error', any()}. @@ -33,6 +33,6 @@ -callback is_local() -> boolean(). --callback check_numbers(ne_binaries()) -> +-callback check_numbers(kz_term:ne_binaries()) -> {'ok', kz_json:object()} | {'error', any()}. diff --git a/core/kazoo_number_manager/src/knm_locality.erl b/core/kazoo_number_manager/src/knm_locality.erl index 691604dc166..9583dcf9caa 100644 --- a/core/kazoo_number_manager/src/knm_locality.erl +++ b/core/kazoo_number_manager/src/knm_locality.erl @@ -18,8 +18,8 @@ %% @doc %% @end %%-------------------------------------------------------------------- --spec fetch(ne_binaries()) -> {'ok', kz_json:object()} | - {'error', 'lookup_failed' | 'missing_url'}. +-spec fetch(kz_term:ne_binaries()) -> {'ok', kz_json:object()} | + {'error', 'lookup_failed' | 'missing_url'}. fetch(Numbers) when is_list(Numbers)-> case knm_config:locality_url() of 'undefined' -> @@ -35,8 +35,8 @@ fetch(Numbers) when is_list(Numbers)-> %% @doc %% @end %%-------------------------------------------------------------------- --spec prefix(text(), text(), text()) -> {'ok', kz_json:object()} | - {'error', kz_json:object()}. +-spec prefix(kz_term:text(), kz_term:text(), kz_term:text()) -> {'ok', kz_json:object()} | + {'error', kz_json:object()}. prefix(Url, Country, City) -> ReqParam = kz_util:uri_encode(City), Uri = lists:flatten([Url, "/", Country, "/city?pattern=", ReqParam]), @@ -59,7 +59,7 @@ prefix(Url, Country, City) -> %%% Internal functions %%%=================================================================== --spec fetch_req(ne_binaries(), ne_binary()) -> kz_http:http_ret(). +-spec fetch_req(kz_term:ne_binaries(), kz_term:ne_binary()) -> kz_http:http_ret(). fetch_req(Numbers, Url) -> ReqBody = kz_json:from_list([{<<"data">>, Numbers}]), Uri = <>, diff --git a/core/kazoo_number_manager/src/knm_number.erl b/core/kazoo_number_manager/src/knm_number.erl index 116e3038d96..722aff20e4c 100644 --- a/core/kazoo_number_manager/src/knm_number.erl +++ b/core/kazoo_number_manager/src/knm_number.erl @@ -50,7 +50,7 @@ -record(knm_number, {knm_phone_number :: knm_phone_number:knm_phone_number() | 'undefined' ,services :: kz_services:services() | 'undefined' ,transactions = [] :: kz_transaction:transactions() - ,charges = [] :: [{ne_binary(), non_neg_integer()}] + ,charges = [] :: [{kz_term:ne_binary(), non_neg_integer()}] }). -opaque knm_number() :: #knm_number{}. -type knm_numbers() :: [knm_number()]. @@ -64,10 +64,10 @@ -type lookup_error() :: 'not_reconcilable' | 'not_found' | 'unassigned' | - {'not_in_service', ne_binary()} | - {'account_disabled', ne_binary()}. + {'not_in_service', kz_term:ne_binary()} | + {'account_disabled', kz_term:ne_binary()}. --type lookup_account_return() :: {'ok', ne_binary(), knm_number_options:extra_options()} | +-type lookup_account_return() :: {'ok', kz_term:ne_binary(), knm_number_options:extra_options()} | {'error', lookup_error()}. @@ -121,8 +121,8 @@ is_number(_) -> 'false'. %% Note: get/1,2 should not throw, instead returns: {ok,_} | {error,_} | ... %% @end %%-------------------------------------------------------------------- --spec get(ne_binary()) -> knm_number_return(). --spec get(ne_binary(), knm_number_options:options()) -> knm_number_return(). +-spec get(kz_term:ne_binary()) -> knm_number_return(). +-spec get(kz_term:ne_binary(), knm_number_options:options()) -> knm_number_return(). get(Num) -> get(Num, knm_number_options:default()). @@ -139,11 +139,11 @@ get(Num, Options) -> %% Note: `assign_to' number option MUST be set. %% @end %%-------------------------------------------------------------------- --spec create(ne_binary(), knm_number_options:options()) -> knm_number_return(). +-spec create(kz_term:ne_binary(), knm_number_options:options()) -> knm_number_return(). create(Num, Options) -> ?TRY2(create, Num, Options). --spec state_for_create(knm_number_options:options()) -> ne_binary(). +-spec state_for_create(knm_number_options:options()) -> kz_term:ne_binary(). state_for_create(Options) -> case {knm_number_options:state(Options, ?NUMBER_STATE_IN_SERVICE) ,knm_number_options:ported_in(Options) @@ -161,11 +161,11 @@ state_for_create(Options) -> State end. --spec allowed_creation_states(api_ne_binary()) -> ne_binaries(). +-spec allowed_creation_states(kz_term:api_ne_binary()) -> kz_term:ne_binaries(). allowed_creation_states(AuthBy) -> allowed_creation_states([], AuthBy). --spec allowed_creation_states(knm_number_options:options(), api_ne_binary()) -> ne_binaries(). +-spec allowed_creation_states(knm_number_options:options(), kz_term:api_ne_binary()) -> kz_term:ne_binaries(). allowed_creation_states(_, undefined) -> []; allowed_creation_states(Options, AuthBy) -> case {knm_phone_number:is_admin(AuthBy) @@ -203,7 +203,7 @@ ensure_can_load_to_create(PN) -> ,?NUMBER_STATE_PORT_IN ]). --spec ensure_state(knm_phone_number:knm_phone_number(), ne_binaries()) -> true. +-spec ensure_state(knm_phone_number:knm_phone_number(), kz_term:ne_binaries()) -> true. ensure_state(PN, AllowedStates) -> State = knm_phone_number:state(PN), case lists:member(State, AllowedStates) of @@ -220,7 +220,7 @@ ensure_state(PN, AllowedStates) -> %% Fetches then transitions an existing number to the reserved state. %% @end %%-------------------------------------------------------------------- --spec reserve(ne_binary(), knm_number_options:options()) -> knm_number_return(). +-spec reserve(kz_term:ne_binary(), knm_number_options:options()) -> knm_number_return(). reserve(Num, Options) -> ?TRY2(reserve, Num, Options). @@ -236,7 +236,7 @@ ensure_can_create(T0=#{todo := Nums, options := Options}) -> end, lists:foldl(F, T0, Nums). --spec ensure_can_create(ne_binary(), knm_number_options:options()) -> 'true'. +-spec ensure_can_create(kz_term:ne_binary(), knm_number_options:options()) -> 'true'. ensure_can_create(Num, Options) -> ensure_account_can_create(Options, knm_number_options:auth_by(Options)) andalso ensure_number_is_not_porting(Num, Options). @@ -251,7 +251,7 @@ ensure_can_create(Num, Options) -> ). -endif. --spec allow_number_additions(knm_number_options:options(), ne_binary()) -> boolean(). +-spec allow_number_additions(knm_number_options:options(), kz_term:ne_binary()) -> boolean(). allow_number_additions(_Options, ?KNM_DEFAULT_AUTH_BY) -> 'true'; allow_number_additions(_Options, _AccountId) -> @@ -271,7 +271,7 @@ ensure_account_can_create(_, _NotAnAccountId) -> ?LOG_DEBUG("'~p' is not an account id", [_NotAnAccountId]), knm_errors:unauthorized(). --spec ensure_number_is_not_porting(ne_binary(), knm_number_options:options()) -> 'true'. +-spec ensure_number_is_not_porting(kz_term:ne_binary(), knm_number_options:options()) -> 'true'. -ifdef(TEST). ensure_number_is_not_porting(?TEST_CREATE_NUM, _Options) -> 'true'; ensure_number_is_not_porting(?TEST_AVAILABLE_NUM = Num, _Options) -> @@ -293,8 +293,8 @@ ensure_number_is_not_porting(Num, Options) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec move(ne_binary(), ne_binary()) -> knm_number_return(). --spec move(ne_binary(), ne_binary(), knm_number_options:options()) -> knm_number_return(). +-spec move(kz_term:ne_binary(), kz_term:ne_binary()) -> knm_number_return(). +-spec move(kz_term:ne_binary(), kz_term:ne_binary(), knm_number_options:options()) -> knm_number_return(). move(Num, MoveTo) -> move(Num, MoveTo, knm_number_options:default()). @@ -308,8 +308,8 @@ move(Num, MoveTo, Options) -> %% Note: will always result in a phone_number save. %% @end %%-------------------------------------------------------------------- --spec update(ne_binary(), knm_phone_number:set_functions()) -> knm_number_return(). --spec update(ne_binary(), knm_phone_number:set_functions(), knm_number_options:options()) -> +-spec update(kz_term:ne_binary(), knm_phone_number:set_functions()) -> knm_number_return(). +-spec update(kz_term:ne_binary(), knm_phone_number:set_functions(), knm_number_options:options()) -> knm_number_return(). update(Num, Routines) -> update(Num, Routines, knm_number_options:default()). @@ -323,7 +323,7 @@ update(Num, Routines, Options) -> %% Note: option 'assign_to' needs to be set. %% @end %%-------------------------------------------------------------------- --spec reconcile(ne_binary(), knm_number_options:options()) -> knm_number_return(). +-spec reconcile(kz_term:ne_binary(), knm_number_options:options()) -> knm_number_return(). reconcile(DID, Options) -> ?TRY2(reconcile, DID, Options). @@ -332,8 +332,8 @@ reconcile(DID, Options) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec release(ne_binary()) -> knm_number_return(). --spec release(ne_binary(), knm_number_options:options()) -> knm_number_return(). +-spec release(kz_term:ne_binary()) -> knm_number_return(). +-spec release(kz_term:ne_binary(), knm_number_options:options()) -> knm_number_return(). release(Num) -> release(Num, knm_number_options:default()). @@ -347,7 +347,7 @@ release(Num, Options) -> %% Sounds too harsh for you? You are looking for release/1,2. %% @end %%-------------------------------------------------------------------- --spec delete(ne_binary(), knm_number_options:options()) -> knm_number_return(). +-spec delete(kz_term:ne_binary(), knm_number_options:options()) -> knm_number_return(). delete(Num, Options) -> ?TRY2(delete, Num, Options). @@ -356,8 +356,8 @@ delete(Num, Options) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec assign_to_app(ne_binary(), api_ne_binary()) -> knm_number_return(). --spec assign_to_app(ne_binary(), api_ne_binary(), knm_number_options:options()) -> knm_number_return(). +-spec assign_to_app(kz_term:ne_binary(), kz_term:api_ne_binary()) -> knm_number_return(). +-spec assign_to_app(kz_term:ne_binary(), kz_term:api_ne_binary(), knm_number_options:options()) -> knm_number_return(). assign_to_app(Num, App) -> assign_to_app(Num, App, knm_number_options:default()). @@ -369,7 +369,7 @@ assign_to_app(Num, App, Options) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec lookup_account(api_ne_binary()) -> lookup_account_return(). +-spec lookup_account(kz_term:api_ne_binary()) -> lookup_account_return(). -ifdef(TEST). lookup_account(undefined) -> {error, not_reconcilable}; lookup_account(Num) -> @@ -441,14 +441,14 @@ check_account(PN) -> {ok, AssignedTo, Props} end. --spec maybe_fetch_account_from_ports(ne_binary(), {error, any()}) -> lookup_account_return(). +-spec maybe_fetch_account_from_ports(kz_term:ne_binary(), {error, any()}) -> lookup_account_return(). maybe_fetch_account_from_ports(Num, Error) -> case knm_config:should_fetch_account_from_ports() of 'false' -> Error; 'true' -> fetch_account_from_ports(Num, Error) end. --spec fetch_account_from_ports(ne_binary(), {'error', any()}) -> lookup_account_return(). +-spec fetch_account_from_ports(kz_term:ne_binary(), {'error', any()}) -> lookup_account_return(). fetch_account_from_ports(Num, Error) -> case knm_port_request:get(Num) of {error, _E} -> Error; @@ -472,7 +472,7 @@ fetch_account_from_ports(Num, Error) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec feature_prepend(knm_phone_number:knm_phone_number()) -> api_binary(). +-spec feature_prepend(knm_phone_number:knm_phone_number()) -> kz_term:api_binary(). feature_prepend(PhoneNumber) -> Prepend = knm_phone_number:feature(PhoneNumber, ?FEATURE_PREPEND), case kz_json:is_true(?PREPEND_ENABLED, Prepend) of @@ -504,7 +504,7 @@ feature_inbound_cname(PhoneNumber) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec find_early_ringback(knm_phone_number:knm_phone_number()) -> api_binary(). +-spec find_early_ringback(knm_phone_number:knm_phone_number()) -> kz_term:api_binary(). find_early_ringback(PhoneNumber) -> RingBack = knm_phone_number:feature(PhoneNumber, ?FEATURE_RINGBACK), kz_json:get_ne_value(?RINGBACK_EARLY, RingBack). @@ -514,7 +514,7 @@ find_early_ringback(PhoneNumber) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec find_transfer_ringback(knm_phone_number:knm_phone_number()) -> api_binary(). +-spec find_transfer_ringback(knm_phone_number:knm_phone_number()) -> kz_term:api_binary(). find_transfer_ringback(PhoneNumber) -> RingBack = knm_phone_number:feature(PhoneNumber, ?FEATURE_RINGBACK), kz_json:get_ne_value(?RINGBACK_TRANSFER, RingBack). @@ -531,7 +531,7 @@ is_force_outbound(PN) -> ,force_outbound_feature(PN) ). --spec is_force_outbound(ne_binary(), ne_binary(), boolean()) -> boolean(). +-spec is_force_outbound(kz_term:ne_binary(), kz_term:ne_binary(), boolean()) -> boolean(). is_force_outbound(?NUMBER_STATE_PORT_IN, Module, _ForceOutbound) -> knm_config:should_force_port_in_outbound() orelse force_module_outbound(Module); @@ -553,7 +553,7 @@ force_outbound_feature(PN) -> FO -> kz_term:is_true(FO) end. --spec force_module_outbound(ne_binary()) -> boolean(). +-spec force_module_outbound(kz_term:ne_binary()) -> boolean(). force_module_outbound(?CARRIER_LOCAL) -> force_local_outbound(); force_module_outbound(?CARRIER_MDN) -> force_local_outbound(); force_module_outbound(_Mod) -> 'false'. @@ -583,8 +583,8 @@ transactions(#knm_number{transactions=Transactions}) -> Transactions. add_transaction(#knm_number{transactions=Transactions}=Number, Transaction) -> Number#knm_number{transactions=[Transaction|Transactions]}. --spec charges(knm_number(), ne_binary()) -> non_neg_integer(). --spec set_charges(knm_number(), ne_binary(), non_neg_integer()) -> knm_number(). +-spec charges(knm_number(), kz_term:ne_binary()) -> non_neg_integer(). +-spec set_charges(knm_number(), kz_term:ne_binary(), non_neg_integer()) -> knm_number(). charges(#knm_number{charges=Charges}, Key) -> props:get_value(Key, Charges, 0). @@ -611,7 +611,7 @@ attempt(Fun, Args) -> {'error', knm_errors:to_json(Reason, num_to_did(Number), Cause)} end. --spec num_to_did(api_binary() | knm_number() | knm_phone_number:knm_phone_number()) -> api_ne_binary(). +-spec num_to_did(kz_term:api_binary() | knm_number() | knm_phone_number:knm_phone_number()) -> kz_term:api_ne_binary(). num_to_did('undefined') -> 'undefined'; num_to_did(?NE_BINARY = DID) -> DID; num_to_did(#knm_number{}=Number) -> num_to_did(phone_number(Number)); diff --git a/core/kazoo_number_manager/src/knm_number_options.erl b/core/kazoo_number_manager/src/knm_number_options.erl index 0cc8636fe34..900befd300c 100644 --- a/core/kazoo_number_manager/src/knm_number_options.erl +++ b/core/kazoo_number_manager/src/knm_number_options.erl @@ -42,27 +42,27 @@ -include("knm.hrl"). --type option() :: {'assign_to', ne_binary()} | - {'auth_by', ne_binary()} | +-type option() :: {'assign_to', kz_term:ne_binary()} | + {'auth_by', kz_term:ne_binary()} | {'dry_run', boolean()} | {'batch_run', boolean()} | {mdn_run, boolean()} | - {'module_name', ne_binary()} | + {'module_name', kz_term:ne_binary()} | {'ported_in', boolean()} | {'public_fields', kz_json:object()} | - {'state', ne_binary()}. + {'state', kz_term:ne_binary()}. -type options() :: [option()]. --type extra_option() :: {'account_id', ne_binary()} | %%api +-type extra_option() :: {'account_id', kz_term:ne_binary()} | %%api {'force_outbound', boolean()} | {'inbound_cnam', boolean()} | {'local', boolean()} | - {'number', ne_binary()} | %%api + {'number', kz_term:ne_binary()} | %%api {'pending_port', boolean()} | - {'prepend', api_binary()} | %%|false - {'ringback_media', api_binary()} | - {'transfer_media', api_binary()}. + {'prepend', kz_term:api_binary()} | %%|false + {'ringback_media', kz_term:api_binary()} | + {'transfer_media', kz_term:api_binary()}. -type extra_options() :: [extra_option()]. @@ -124,26 +124,26 @@ mdn_run(Options) -> andalso lager:debug("mdn_run-ing btw"), R. --spec assign_to(options()) -> api_binary(). --spec assign_to(options(), Default) -> ne_binary() | Default. +-spec assign_to(options()) -> kz_term:api_binary(). +-spec assign_to(options(), Default) -> kz_term:ne_binary() | Default. assign_to(Options) -> assign_to(Options, 'undefined'). assign_to(Options, Default) -> props:get_binary_value('assign_to', Options, Default). --spec auth_by(options()) -> api_binary(). --spec auth_by(options(), Default) -> ne_binary() | Default. +-spec auth_by(options()) -> kz_term:api_binary(). +-spec auth_by(options(), Default) -> kz_term:ne_binary() | Default. auth_by(Options) -> auth_by(Options, 'undefined'). auth_by(Options, Default) -> props:get_binary_value('auth_by', Options, Default). --spec public_fields(options()) -> api_object(). +-spec public_fields(options()) -> kz_term:api_object(). public_fields(Options) -> props:get_value('public_fields', Options, kz_json:new()). --spec state(options()) -> api_binary(). --spec state(options(), Default) -> ne_binary() | Default. +-spec state(options()) -> kz_term:api_binary(). +-spec state(options(), Default) -> kz_term:ne_binary() | Default. state(Options) -> state(Options, 'undefined'). state(Options, Default) -> @@ -153,7 +153,7 @@ state(Options, Default) -> ported_in(Options) -> props:get_is_true('ported_in', Options, false). --spec module_name(options()) -> ne_binary(). +-spec module_name(options()) -> kz_term:ne_binary(). module_name(Options) -> case props:get_ne_binary_value('module_name', Options) of 'undefined' -> knm_carriers:default_carrier(); @@ -163,11 +163,11 @@ module_name(Options) -> %%-------------------------------------------------------------------- %% Public get/set extra_options() %%-------------------------------------------------------------------- --spec account_id(extra_options()) -> ne_binary(). +-spec account_id(extra_options()) -> kz_term:ne_binary(). account_id(Props) when is_list(Props) -> props:get_ne_binary_value('account_id', Props). --spec set_account_id(extra_options(), ne_binary()) -> extra_options(). +-spec set_account_id(extra_options(), kz_term:ne_binary()) -> extra_options(). set_account_id(Props, AccountId=?MATCH_ACCOUNT_RAW(_)) when is_list(Props) -> props:set_value('account_id', AccountId, Props). @@ -183,15 +183,15 @@ inbound_cnam_enabled(Props) when is_list(Props) -> is_local_number(Props) when is_list(Props) -> props:get_is_true('local', Props). --spec number(extra_options()) -> ne_binary(). +-spec number(extra_options()) -> kz_term:ne_binary(). number(Props) when is_list(Props) -> props:get_ne_binary_value('number', Props). --spec prepend(extra_options()) -> api_binary(). +-spec prepend(extra_options()) -> kz_term:api_binary(). prepend(Props) when is_list(Props) -> props:get_value('prepend', Props). --spec ringback_media_id(extra_options()) -> api_binary(). +-spec ringback_media_id(extra_options()) -> kz_term:api_binary(). ringback_media_id(Props) when is_list(Props) -> props:get_value('ringback_media', Props). @@ -199,7 +199,7 @@ ringback_media_id(Props) when is_list(Props) -> should_force_outbound(Props) when is_list(Props) -> props:get_is_true('force_outbound', Props). --spec transfer_media_id(extra_options()) -> api_binary(). +-spec transfer_media_id(extra_options()) -> kz_term:api_binary(). transfer_media_id(Props) when is_list(Props) -> props:get_value('transfer_media', Props). %%-------------------------------------------------------------------- diff --git a/core/kazoo_number_manager/src/knm_number_states.erl b/core/kazoo_number_manager/src/knm_number_states.erl index 06befcf009f..f6a3d108311 100644 --- a/core/kazoo_number_manager/src/knm_number_states.erl +++ b/core/kazoo_number_manager/src/knm_number_states.erl @@ -32,7 +32,7 @@ to_options_state(T=#{options := Options}) -> ?LOG_DEBUG("attempting to change to state ~s", [TargetState]), change_state(T, TargetState). --spec change_state(t(), ne_binary()) -> t(). +-spec change_state(t(), kz_term:ne_binary()) -> t(). change_state(T, ?NUMBER_STATE_RESERVED) -> knm_numbers:pipe(T ,[fun (T0) -> fail_if_mdn(T0, ?NUMBER_STATE_RESERVED) end @@ -220,8 +220,8 @@ move_to_reserved_state(T) -> move_to_in_service_state(T) -> move_number_to_state(T, ?NUMBER_STATE_IN_SERVICE). --spec move_number_to_state(kn(), ne_binary()) -> kn(); - (t(), ne_binary()) -> t(). +-spec move_number_to_state(kn(), kz_term:ne_binary()) -> kn(); + (t(), kz_term:ne_binary()) -> t(). move_number_to_state(T=#{todo := Ns}, ToState) -> NewNs = [move_number_to_state(N, ToState) || N <- Ns], knm_numbers:ok(NewNs, T); @@ -230,7 +230,7 @@ move_number_to_state(Number, ToState) -> {'ok', PN} = move_phone_number_to_state(PhoneNumber, ToState), knm_number:set_phone_number(Number, PN). --spec move_phone_number_to_state(knm_phone_number:knm_phone_number(), ne_binary()) -> +-spec move_phone_number_to_state(knm_phone_number:knm_phone_number(), kz_term:ne_binary()) -> knm_phone_number_return(). move_phone_number_to_state(PN, ToState=?NUMBER_STATE_AVAILABLE) -> knm_phone_number:setters(PN, [{fun knm_phone_number:set_state/2, ToState}]); @@ -238,7 +238,7 @@ move_phone_number_to_state(PN, ToState) -> AssignedTo = knm_phone_number:assigned_to(PN), move_phone_number_to_state(PN, ToState, AssignedTo). --spec move_phone_number_to_state(knm_phone_number:knm_phone_number(), ne_binary(), api_binary()) -> +-spec move_phone_number_to_state(knm_phone_number:knm_phone_number(), kz_term:ne_binary(), kz_term:api_binary()) -> knm_phone_number_return(). move_phone_number_to_state(PhoneNumber, ToState, 'undefined') -> Setters = @@ -262,7 +262,7 @@ move_phone_number_to_state(PhoneNumber, ToState, AssignedTo, AssignTo) -> %% @private --spec invalid_state_transition(t(), api_ne_binary(), ne_binary()) -> t(). +-spec invalid_state_transition(t(), kz_term:api_ne_binary(), kz_term:ne_binary()) -> t(). invalid_state_transition(T=#{todo := Ns}, FromState, ToState) -> {error,A,B,C} = (catch knm_errors:invalid_state_transition(undefined, FromState, ToState)), Reason = knm_errors:to_json(A, B, C), @@ -298,7 +298,7 @@ is_assigned_to_assignto(N) -> =:= knm_phone_number:assigned_to(PN). %% @private --spec group_by_state(t()) -> [{ne_binary(), knm_numbers:oks()}]. +-spec group_by_state(t()) -> [{kz_term:ne_binary(), knm_numbers:oks()}]. group_by_state(#{todo := Ns}) -> F = fun (N, M) -> State = knm_phone_number:state(knm_number:phone_number(N)), diff --git a/core/kazoo_number_manager/src/knm_numbers.erl b/core/kazoo_number_manager/src/knm_numbers.erl index 9b5789be630..28922448014 100644 --- a/core/kazoo_number_manager/src/knm_numbers.erl +++ b/core/kazoo_number_manager/src/knm_numbers.erl @@ -49,7 +49,7 @@ -include("knm.hrl"). --type num() :: ne_binary(). %%TODO: support ranges? +-type num() :: kz_term:ne_binary(). %%TODO: support ranges? -type nums() :: [num()]. -type ok() :: knm_number:knm_number(). -type oks() :: [ok()]. @@ -92,7 +92,7 @@ -type services() :: kz_services:services() | undefined. -type transaction() :: kz_transaction:transaction(). -type transactions() :: kz_transaction:transactions(). --type charges() :: [{ne_binary(), non_neg_integer()}]. +-type charges() :: [{kz_term:ne_binary(), non_neg_integer()}]. -export_type([options/0 ,plan/0 @@ -126,7 +126,7 @@ todo(#{todo := ToDo}) -> ToDo. %% Set of numbers' assigned_to fields. %% @end %%-------------------------------------------------------------------- --spec assigned_to(t()) -> api_ne_binary(). +-spec assigned_to(t()) -> kz_term:api_ne_binary(). assigned_to(#{todo := Ns}) -> F = fun (N, S) -> case knm_phone_number:assigned_to(knm_number:phone_number(N)) of @@ -145,7 +145,7 @@ assigned_to(#{todo := Ns}) -> %% Set of numbers' prev_assigned_to fields. %% @end %%-------------------------------------------------------------------- --spec prev_assigned_to(t()) -> api_ne_binary(). +-spec prev_assigned_to(t()) -> kz_term:api_ne_binary(). prev_assigned_to(#{todo := Ns}) -> F = fun (N, S) -> case knm_phone_number:prev_assigned_to(knm_number:phone_number(N)) of @@ -193,8 +193,8 @@ charges(#{charges := V}) -> V. charges(V, T) -> T#{charges => V}. %% @public --spec charge(ne_binary(), t()) -> non_neg_integer(). --spec charge(ne_binary(), non_neg_integer(), t()) -> t(). +-spec charge(kz_term:ne_binary(), t()) -> non_neg_integer(). +-spec charge(kz_term:ne_binary(), non_neg_integer(), t()) -> t(). charge(K, #{charges := Vs}) -> props:get_value(K, Vs, 0). charge(K, V, T=#{charges := Vs}) -> T#{charges => [{K, V} | Vs]}. @@ -232,12 +232,12 @@ ko(N, Reason, T) -> %% Note: each number in `Nums' has to be normalized. %% @end %%-------------------------------------------------------------------- --spec get(ne_binaries()) -> ret(). --spec get(ne_binaries(), knm_number_options:options()) -> ret(). +-spec get(kz_term:ne_binaries()) -> ret(). +-spec get(kz_term:ne_binaries(), knm_number_options:options()) -> ret(). get(Nums) -> get(Nums, knm_number_options:default()). get(Nums, Options) -> ret(do_get(Nums, Options)). --spec do_get(ne_binaries(), knm_number_options:options()) -> t(). +-spec do_get(kz_term:ne_binaries(), knm_number_options:options()) -> t(). do_get(Nums, Options) -> {Yes, No} = are_reconcilable(Nums), pipe(new(Options, Yes, No) @@ -245,8 +245,8 @@ do_get(Nums, Options) -> ,fun knm_number:new/1 ]). --spec do_get_pn(ne_binaries(), knm_number_options:options()) -> t_pn(). --spec do_get_pn(ne_binaries(), knm_number_options:options(), reason_t()) -> t_pn(). +-spec do_get_pn(kz_term:ne_binaries(), knm_number_options:options()) -> t_pn(). +-spec do_get_pn(kz_term:ne_binaries(), knm_number_options:options(), reason_t()) -> t_pn(). do_get_pn(Nums, Options) -> {Yes, No} = are_reconcilable(Nums), do(fun knm_phone_number:fetch/1, new(Options, Yes, No)). @@ -293,7 +293,7 @@ from_jobjs(JObjs) -> %% attempt to create them with state in_service. %% @end %%-------------------------------------------------------------------- --spec create(ne_binaries(), knm_number_options:options()) -> ret(). +-spec create(kz_term:ne_binaries(), knm_number_options:options()) -> ret(). create(Nums, Options) -> T0 = pipe(do_get_pn(Nums ,?OPTIONS_FOR_LOAD(Nums, props:delete(state, Options)) @@ -326,8 +326,8 @@ create(Nums, Options) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec move(ne_binaries(), ne_binary()) -> ret(). --spec move(ne_binaries(), ne_binary(), knm_number_options:options()) -> ret(). +-spec move(kz_term:ne_binaries(), kz_term:ne_binary()) -> ret(). +-spec move(kz_term:ne_binaries(), kz_term:ne_binary(), knm_number_options:options()) -> ret(). move(Nums, MoveTo) -> move(Nums, MoveTo, knm_number_options:default()). @@ -347,8 +347,8 @@ move(Nums, ?MATCH_ACCOUNT_RAW(MoveTo), Options0) -> %% Note: will always result in a phone_number save. %% @end %%-------------------------------------------------------------------- --spec update(ne_binaries(), knm_phone_number:set_functions()) -> ret(). --spec update(ne_binaries(), knm_phone_number:set_functions(), knm_number_options:options()) -> ret(). +-spec update(kz_term:ne_binaries(), knm_phone_number:set_functions()) -> ret(). +-spec update(kz_term:ne_binaries(), knm_phone_number:set_functions(), knm_number_options:options()) -> ret(). update(Nums, Routines) -> update(Nums, Routines, knm_number_options:default()). @@ -382,8 +382,8 @@ do_update(T0, Routines) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec release(ne_binaries()) -> ret(). --spec release(ne_binaries(), knm_number_options:options()) -> ret(). +-spec release(kz_term:ne_binaries()) -> ret(). +-spec release(kz_term:ne_binaries(), knm_number_options:options()) -> ret(). release(Nums) -> release(Nums, knm_number_options:default()). @@ -403,7 +403,7 @@ release(Nums, Options) -> %% Sounds too harsh for you? You are looking for release/1,2. %% @end %%-------------------------------------------------------------------- --spec delete(ne_binaries(), knm_number_options:options()) -> ret(). +-spec delete(kz_term:ne_binaries(), knm_number_options:options()) -> ret(). delete(Nums, Options) -> case knm_phone_number:is_admin(knm_number_options:auth_by(Options)) of false -> @@ -422,7 +422,7 @@ delete(Nums, Options) -> %% Note: option 'assign_to' needs to be set. %% @end %%-------------------------------------------------------------------- --spec reconcile(ne_binaries(), knm_number_options:options()) -> ret(). +-spec reconcile(kz_term:ne_binaries(), knm_number_options:options()) -> ret(). reconcile(Nums, Options0) -> Options = [{'auth_by', ?KNM_DEFAULT_AUTH_BY} | Options0], T0 = pipe(do_get(Nums, Options) @@ -440,7 +440,7 @@ reconcile(Nums, Options0) -> %% Fetches then transitions existing numbers to the reserved state. %% @end %%-------------------------------------------------------------------- --spec reserve(ne_binaries(), knm_number_options:options()) -> ret(). +-spec reserve(kz_term:ne_binaries(), knm_number_options:options()) -> ret(). reserve(Nums, Options) -> ret(pipe(do_get(Nums, Options) ,[fun fail_if_assign_to_is_not_an_account_id/1 @@ -452,8 +452,8 @@ reserve(Nums, Options) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec assign_to_app(ne_binaries(), api_ne_binary()) -> ret(). --spec assign_to_app(ne_binaries(), api_ne_binary(), knm_number_options:options()) -> ret(). +-spec assign_to_app(kz_term:ne_binaries(), kz_term:api_ne_binary()) -> ret(). +-spec assign_to_app(kz_term:ne_binaries(), kz_term:api_ne_binary(), knm_number_options:options()) -> ret(). assign_to_app(Nums, App) -> assign_to_app(Nums, App, knm_number_options:default()). @@ -470,7 +470,7 @@ assign_to_app(Nums, App, Options) -> %% @doc Release all of an account's numbers %% @end %%-------------------------------------------------------------------- --spec free(ne_binary()) -> 'ok'. +-spec free(kz_term:ne_binary()) -> 'ok'. free(Account=?NE_BINARY) -> AccountDb = kz_util:format_account_db(Account), {Numbers, _NumbersData} = lists:unzip(account_listing(AccountDb)), @@ -488,7 +488,7 @@ free(Account=?NE_BINARY) -> %% Find an account's phone numbers that have emergency services enabled %% @end %%-------------------------------------------------------------------- --spec emergency_enabled(ne_binary()) -> ne_binaries(). +-spec emergency_enabled(kz_term:ne_binary()) -> kz_term:ne_binaries(). emergency_enabled(AccountId=?MATCH_ACCOUNT_RAW(_)) -> AccountDb = kz_util:format_account_db(AccountId), [Num || {Num, JObj} <- account_listing(AccountDb), @@ -503,7 +503,7 @@ emergency_enabled(AccountId=?MATCH_ACCOUNT_RAW(_)) -> %% Does not go through sub accounts. %% @end %%-------------------------------------------------------------------- --spec account_listing(ne_binary()) -> [{ne_binary(), kz_json:object()}]. +-spec account_listing(kz_term:ne_binary()) -> [{kz_term:ne_binary(), kz_json:object()}]. account_listing(AccountDb=?MATCH_ACCOUNT_ENCODED(_,_,_)) -> case kz_datamgr:get_results(AccountDb, <<"phone_numbers/crossbar_listing">>) of {'ok', []} -> @@ -788,7 +788,7 @@ can_release(T0=#{todo := PNs}) -> end, lists:foldl(F, T0, PNs). --spec can_release(ne_binary(), ne_binary()) -> boolean(). +-spec can_release(kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). can_release(?NUMBER_STATE_RELEASED, _) -> true; can_release(?NUMBER_STATE_RESERVED, _) -> true; can_release(?NUMBER_STATE_PORT_IN, _) -> true; diff --git a/core/kazoo_number_manager/src/knm_phone_number.erl b/core/kazoo_number_manager/src/knm_phone_number.erl index a9a384475da..41cf9696088 100644 --- a/core/kazoo_number_manager/src/knm_phone_number.erl +++ b/core/kazoo_number_manager/src/knm_phone_number.erl @@ -74,31 +74,31 @@ %% Without 'undefined' there, Dialyzer outputs false positives. %% It has trouble infering what is happening in from_json/1's setters. %% And all this is because we need to set is_dirty reliably. --record(knm_phone_number, {number :: api_ne_binary() %%% - ,number_db :: api_ne_binary() %%% - ,rev :: api_ne_binary() - ,assign_to :: api_ne_binary() - ,assigned_to :: api_ne_binary() - ,prev_assigned_to :: api_ne_binary() - ,used_by :: api_ne_binary() - ,features :: api_object() - ,state :: api_ne_binary() %%% - ,reserve_history :: api_ne_binaries() %%% - ,ported_in :: api_boolean() %%% - ,module_name :: api_ne_binary() %%% - ,carrier_data :: api_object() - ,region :: api_ne_binary() - ,auth_by :: api_ne_binary() +-record(knm_phone_number, {number :: kz_term:api_ne_binary() %%% + ,number_db :: kz_term:api_ne_binary() %%% + ,rev :: kz_term:api_ne_binary() + ,assign_to :: kz_term:api_ne_binary() + ,assigned_to :: kz_term:api_ne_binary() + ,prev_assigned_to :: kz_term:api_ne_binary() + ,used_by :: kz_term:api_ne_binary() + ,features :: kz_term:api_object() + ,state :: kz_term:api_ne_binary() %%% + ,reserve_history :: kz_term:api_ne_binaries() %%% + ,ported_in :: kz_term:api_boolean() %%% + ,module_name :: kz_term:api_ne_binary() %%% + ,carrier_data :: kz_term:api_object() + ,region :: kz_term:api_ne_binary() + ,auth_by :: kz_term:api_ne_binary() ,dry_run = 'false' :: boolean() ,batch_run = 'false' :: boolean() ,mdn_run = false :: boolean() - ,locality :: api_object() - ,doc :: api_object() - ,modified :: api_seconds() %%% - ,created :: api_seconds() %%% + ,locality :: kz_term:api_object() + ,doc :: kz_term:api_object() + ,modified :: kz_time:api_seconds() %%% + ,created :: kz_time:api_seconds() %%% ,is_dirty = 'false' :: boolean() - ,features_allowed :: api_ne_binaries() %%% - ,features_denied :: api_ne_binaries() %%% + ,features_allowed :: kz_term:api_ne_binaries() %%% + ,features_denied :: kz_term:api_ne_binaries() %%% }). -opaque knm_phone_number() :: #knm_phone_number{}. @@ -167,18 +167,18 @@ new(T=#{todo := Nums, options := Options}) -> new_setters(Options) -> knm_number_options:to_phone_number_setters(?OPTIONS_FOR_NEW_SETTERS(Options)). --spec do_new(ne_binary(), set_functions()) -> knm_phone_number(). +-spec do_new(kz_term:ne_binary(), set_functions()) -> knm_phone_number(). do_new(DID, Setters) -> {ok, PN} = setters(from_number(DID), Setters), PN. %% @public --spec from_number(ne_binary()) -> knm_phone_number(). +-spec from_number(kz_term:ne_binary()) -> knm_phone_number(). from_number(DID) -> from_json(kz_doc:set_id(kz_json:new(), DID)). %% @public --spec from_number_with_options(ne_binary(), knm_number_options:options()) -> knm_phone_number(). +-spec from_number_with_options(kz_term:ne_binary(), knm_number_options:options()) -> knm_phone_number(). from_number_with_options(DID, Options) -> do_new(DID, new_setters(Options)). @@ -187,9 +187,9 @@ from_number_with_options(DID, Options) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec fetch(ne_binary()) -> knm_phone_number_return(); +-spec fetch(kz_term:ne_binary()) -> knm_phone_number_return(); (knm_numbers:collection()) -> knm_numbers:collection(). --spec fetch(ne_binary(), knm_number_options:options()) -> knm_phone_number_return(). +-spec fetch(kz_term:ne_binary(), knm_number_options:options()) -> knm_phone_number_return(). fetch(?NE_BINARY=Num) -> fetch(Num, knm_number_options:default()); @@ -854,10 +854,10 @@ setters_fold_apply(Fun, Args) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec number(knm_phone_number()) -> ne_binary(). +-spec number(knm_phone_number()) -> kz_term:ne_binary(). number(#knm_phone_number{number=Num}) -> Num. --spec set_number(knm_phone_number(), ne_binary()) -> knm_phone_number(). +-spec set_number(knm_phone_number(), kz_term:ne_binary()) -> knm_phone_number(). set_number(PN, <<"+",_:8,_/binary>>=NormalizedNum) -> NumberDb = knm_converters:to_db(NormalizedNum), case {PN#knm_phone_number.number, PN#knm_phone_number.number_db} of @@ -877,14 +877,14 @@ set_number(PN, <<"+",_:8,_/binary>>=NormalizedNum) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec number_db(knm_phone_number()) -> ne_binary(). +-spec number_db(knm_phone_number()) -> kz_term:ne_binary(). number_db(#knm_phone_number{number_db=NumberDb}) -> NumberDb. %% @private --spec rev(knm_phone_number()) -> api_ne_binary(). +-spec rev(knm_phone_number()) -> kz_term:api_ne_binary(). rev(#knm_phone_number{rev=Rev}) -> Rev. --spec set_rev(knm_phone_number(), ne_binary()) -> knm_phone_number(). +-spec set_rev(knm_phone_number(), kz_term:ne_binary()) -> knm_phone_number(). set_rev(N, ?NE_BINARY=Rev) -> N#knm_phone_number{rev=Rev}. %%-------------------------------------------------------------------- @@ -892,12 +892,12 @@ set_rev(N, ?NE_BINARY=Rev) -> N#knm_phone_number{rev=Rev}. %% @doc %% @end %%-------------------------------------------------------------------- --spec assign_to(knm_phone_number()) -> api_ne_binary(). +-spec assign_to(knm_phone_number()) -> kz_term:api_ne_binary(). assign_to(#knm_phone_number{assign_to=AssignTo}) -> AssignTo. %% This is not stored on number doc --spec set_assign_to(knm_phone_number(), api_ne_binary()) -> knm_phone_number(). +-spec set_assign_to(knm_phone_number(), kz_term:api_ne_binary()) -> knm_phone_number(). set_assign_to(PN=#knm_phone_number{assign_to = V}, V) -> PN; set_assign_to(PN, AssignTo=undefined) -> PN#knm_phone_number{assign_to = AssignTo}; @@ -909,11 +909,11 @@ set_assign_to(PN, AssignTo=?MATCH_ACCOUNT_RAW(_)) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec assigned_to(knm_phone_number()) -> api_ne_binary(). +-spec assigned_to(knm_phone_number()) -> kz_term:api_ne_binary(). assigned_to(#knm_phone_number{assigned_to=AssignedTo}) -> AssignedTo. --spec set_assigned_to(knm_phone_number(), api_ne_binary()) -> knm_phone_number(). +-spec set_assigned_to(knm_phone_number(), kz_term:api_ne_binary()) -> knm_phone_number(). set_assigned_to(PN=#knm_phone_number{assigned_to = V}, V) -> PN; set_assigned_to(PN0, AssignedTo=undefined) -> PN = set_prev_assigned_to(PN0, assigned_to(PN0)), @@ -927,7 +927,7 @@ set_assigned_to(PN0, AssignedTo=?MATCH_ACCOUNT_RAW(_)) -> }). %% This is used only by from_json/1 --spec set_assigned_to(knm_phone_number(), api_ne_binary(), api_ne_binary()) -> knm_phone_number(). +-spec set_assigned_to(knm_phone_number(), kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> knm_phone_number(). set_assigned_to(PN, AssignedTo=undefined, UsedBy=undefined) -> PN#knm_phone_number{assigned_to = AssignedTo ,used_by = UsedBy @@ -950,12 +950,12 @@ set_assigned_to(PN, AssignedTo=?MATCH_ACCOUNT_RAW(_), UsedBy=?NE_BINARY) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec prev_assigned_to(knm_phone_number()) -> api_ne_binary(). +-spec prev_assigned_to(knm_phone_number()) -> kz_term:api_ne_binary(). prev_assigned_to(#knm_phone_number{prev_assigned_to=PrevAssignedTo}) -> PrevAssignedTo. %% Called from set_assigned_to/2 & from_json/1. --spec set_prev_assigned_to(knm_phone_number(), api_ne_binary()) -> knm_phone_number(). +-spec set_prev_assigned_to(knm_phone_number(), kz_term:api_ne_binary()) -> knm_phone_number(). set_prev_assigned_to(PN=#knm_phone_number{prev_assigned_to = undefined} ,PrevAssignedTo=?MATCH_ACCOUNT_RAW(_)) -> PN#knm_phone_number{prev_assigned_to = PrevAssignedTo}; @@ -971,11 +971,11 @@ set_prev_assigned_to(PN, PrevAssignedTo=?MATCH_ACCOUNT_RAW(_)) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec used_by(knm_phone_number()) -> api_ne_binary(). +-spec used_by(knm_phone_number()) -> kz_term:api_ne_binary(). used_by(#knm_phone_number{used_by=UsedBy}) -> UsedBy. %% This is never called from from_json/1. See set_assigned_to/3 --spec set_used_by(knm_phone_number(), api_ne_binary()) -> knm_phone_number(). +-spec set_used_by(knm_phone_number(), kz_term:api_ne_binary()) -> knm_phone_number(). set_used_by(PN=#knm_phone_number{used_by = V}, V) -> PN; set_used_by(PN, UsedBy='undefined') -> lager:debug("unassigning ~s from ~s", [number(PN), PN#knm_phone_number.used_by]), @@ -992,7 +992,7 @@ set_used_by(PN, UsedBy=?NE_BINARY) -> -spec features(knm_phone_number()) -> kz_json:object(). features(#knm_phone_number{features=Features}) -> Features. --spec features_list(knm_phone_number()) -> ne_binaries(). +-spec features_list(knm_phone_number()) -> kz_term:ne_binaries(). features_list(PN) -> lists:usort(kz_json:get_keys(features(PN))). @@ -1010,11 +1010,11 @@ set_features(PN, Features) -> false -> ?DIRTY(PN#knm_phone_number{features = Features}) end. --spec feature(knm_phone_number(), ne_binary()) -> kz_json:api_json_term(). +-spec feature(knm_phone_number(), kz_term:ne_binary()) -> kz_json:api_json_term(). feature(PN, Feature) -> kz_json:get_ne_value(Feature, features(PN)). --spec set_feature(knm_phone_number(), ne_binary(), kz_json:json_term()) -> +-spec set_feature(knm_phone_number(), kz_term:ne_binary(), kz_json:json_term()) -> knm_phone_number(). set_feature(PN0, Feature=?NE_BINARY, Data) -> Features = case PN0#knm_phone_number.features of @@ -1037,7 +1037,7 @@ reset_features(PN) -> set_features(PN, ?DEFAULT_FEATURES). --spec set_features_allowed(knm_phone_number(), ne_binaries()) -> knm_phone_number(). +-spec set_features_allowed(knm_phone_number(), kz_term:ne_binaries()) -> knm_phone_number(). set_features_allowed(PN=#knm_phone_number{features_allowed = undefined}, Features) -> true = lists:all(fun kz_term:is_ne_binary/1, Features), PN#knm_phone_number{features_allowed = Features}; @@ -1048,7 +1048,7 @@ set_features_allowed(PN, Features) -> false -> ?DIRTY(PN#knm_phone_number{features_allowed = Features}) end. --spec set_features_denied(knm_phone_number(), ne_binaries()) -> knm_phone_number(). +-spec set_features_denied(knm_phone_number(), kz_term:ne_binaries()) -> knm_phone_number(). set_features_denied(PN=#knm_phone_number{features_denied = undefined}, Features) -> true = lists:all(fun kz_term:is_ne_binary/1, Features), PN#knm_phone_number{features_denied = Features}; @@ -1059,38 +1059,38 @@ set_features_denied(PN, Features) -> false -> ?DIRTY(PN#knm_phone_number{features_denied = Features}) end. --spec add_allowed_feature(knm_phone_number(), ne_binary()) -> knm_phone_number(). +-spec add_allowed_feature(knm_phone_number(), kz_term:ne_binary()) -> knm_phone_number(). add_allowed_feature(PN=#knm_phone_number{features_allowed = Allowed}, Feature=?NE_BINARY) -> case lists:member(Feature, Allowed) of true -> PN; false -> ?DIRTY(PN#knm_phone_number{features_allowed = [Feature|Allowed]}) end. --spec remove_allowed_feature(knm_phone_number(), ne_binary()) -> knm_phone_number(). +-spec remove_allowed_feature(knm_phone_number(), kz_term:ne_binary()) -> knm_phone_number(). remove_allowed_feature(PN=#knm_phone_number{features_allowed = Allowed}, Feature=?NE_BINARY) -> case lists:member(Feature, Allowed) of false -> PN; true -> ?DIRTY(PN#knm_phone_number{features_allowed = lists:delete(Feature, Allowed)}) end. --spec add_denied_feature(knm_phone_number(), ne_binary()) -> knm_phone_number(). +-spec add_denied_feature(knm_phone_number(), kz_term:ne_binary()) -> knm_phone_number(). add_denied_feature(PN=#knm_phone_number{features_denied = Denied}, Feature=?NE_BINARY) -> case lists:member(Feature, Denied) of true -> PN; false -> ?DIRTY(PN#knm_phone_number{features_denied = [Feature|Denied]}) end. --spec remove_denied_feature(knm_phone_number(), ne_binary()) -> knm_phone_number(). +-spec remove_denied_feature(knm_phone_number(), kz_term:ne_binary()) -> knm_phone_number(). remove_denied_feature(PN=#knm_phone_number{features_denied = Denied}, Feature=?NE_BINARY) -> case lists:member(Feature, Denied) of false -> PN; true -> ?DIRTY(PN#knm_phone_number{features_denied = lists:delete(Feature, Denied)}) end. --spec features_allowed(knm_phone_number()) -> ne_binaries(). +-spec features_allowed(knm_phone_number()) -> kz_term:ne_binaries(). features_allowed(#knm_phone_number{features_allowed = Features}) -> Features. --spec features_denied(knm_phone_number()) -> ne_binaries(). +-spec features_denied(knm_phone_number()) -> kz_term:ne_binaries(). features_denied(#knm_phone_number{features_denied = Features}) -> Features. %%-------------------------------------------------------------------- @@ -1098,10 +1098,10 @@ features_denied(#knm_phone_number{features_denied = Features}) -> Features. %% @doc %% @end %%-------------------------------------------------------------------- --spec state(knm_phone_number()) -> api_ne_binary(). +-spec state(knm_phone_number()) -> kz_term:api_ne_binary(). state(#knm_phone_number{state=State}) -> State. --spec set_state(knm_phone_number(), ne_binary()) -> knm_phone_number(). +-spec set_state(knm_phone_number(), kz_term:ne_binary()) -> knm_phone_number(). set_state(PN=#knm_phone_number{state = V}, V) -> PN; set_state(PN=#knm_phone_number{state = undefined}, State) -> true = is_state(State), @@ -1130,10 +1130,10 @@ is_state(_) -> false. %% @doc %% @end %%-------------------------------------------------------------------- --spec reserve_history(knm_phone_number()) -> ne_binaries(). +-spec reserve_history(knm_phone_number()) -> kz_term:ne_binaries(). reserve_history(#knm_phone_number{reserve_history=History}) -> History. --spec set_reserve_history(knm_phone_number(), ne_binaries()) -> knm_phone_number(). +-spec set_reserve_history(knm_phone_number(), kz_term:ne_binaries()) -> knm_phone_number(). set_reserve_history(PN=#knm_phone_number{reserve_history = V}, V) -> PN; set_reserve_history(PN0=#knm_phone_number{reserve_history = undefined}, History) when is_list(History) -> @@ -1157,7 +1157,7 @@ set_reserve_history(PN0, History) PN1 = PN0#knm_phone_number{reserve_history=?DEFAULT_RESERVE_HISTORY}, lists:foldr(fun add_reserve_history/2, PN1, History). --spec add_reserve_history(api_ne_binary(), knm_phone_number()) -> knm_phone_number(). +-spec add_reserve_history(kz_term:api_ne_binary(), knm_phone_number()) -> knm_phone_number(). add_reserve_history(undefined, PN) -> PN; add_reserve_history(?MATCH_ACCOUNT_RAW(AccountId) ,PN=#knm_phone_number{reserve_history=[AccountId|_]} @@ -1212,10 +1212,10 @@ set_ported_in(PN, Ported) when is_boolean(Ported) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec module_name(knm_phone_number()) -> api_ne_binary(). +-spec module_name(knm_phone_number()) -> kz_term:api_ne_binary(). module_name(#knm_phone_number{module_name = Name}) -> Name. --spec set_module_name(knm_phone_number(), ne_binary()) -> knm_phone_number(). +-spec set_module_name(knm_phone_number(), kz_term:ne_binary()) -> knm_phone_number(). %% knm_bandwidth is deprecated, updating to the new module set_module_name(PN, <<"wnm_", Name/binary>>) -> ?DIRTY(set_module_name(PN, <<"knm_", Name/binary>>)); @@ -1276,7 +1276,7 @@ local_feature(PN) -> -spec carrier_data(knm_phone_number()) -> kz_json:object(). carrier_data(#knm_phone_number{carrier_data=Data}) -> Data. --spec set_carrier_data(knm_phone_number(), api_object()) -> knm_phone_number(). +-spec set_carrier_data(knm_phone_number(), kz_term:api_object()) -> knm_phone_number(). set_carrier_data(PN=#knm_phone_number{carrier_data = undefined}, undefined) -> set_carrier_data(PN, ?DEFAULT_CARRIER_DATA); set_carrier_data(PN=#knm_phone_number{carrier_data = undefined}, Data) -> @@ -1305,10 +1305,10 @@ update_carrier_data(PN=#knm_phone_number{carrier_data = Data}, JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec region(knm_phone_number()) -> api_ne_binary(). +-spec region(knm_phone_number()) -> kz_term:api_ne_binary(). region(#knm_phone_number{region=Region}) -> Region. --spec set_region(knm_phone_number(), api_ne_binary()) -> knm_phone_number(). +-spec set_region(knm_phone_number(), kz_term:api_ne_binary()) -> knm_phone_number(). set_region(PN=#knm_phone_number{region = V}, V) -> PN; set_region(PN=#knm_phone_number{region = undefined}, Region=?NE_BINARY) -> PN#knm_phone_number{region = Region}; @@ -1324,10 +1324,10 @@ set_region(PN, Region=?NE_BINARY) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec auth_by(knm_phone_number()) -> api_ne_binary(). +-spec auth_by(knm_phone_number()) -> kz_term:api_ne_binary(). auth_by(#knm_phone_number{auth_by=AuthBy}) -> AuthBy. --spec set_auth_by(knm_phone_number(), api_ne_binary()) -> knm_phone_number(). +-spec set_auth_by(knm_phone_number(), kz_term:api_ne_binary()) -> knm_phone_number(). set_auth_by(PN, AuthBy='undefined') -> PN#knm_phone_number{auth_by=AuthBy}; set_auth_by(PN, AuthBy=?KNM_DEFAULT_AUTH_BY) -> @@ -1340,7 +1340,7 @@ set_auth_by(PN, ?MATCH_ACCOUNT_RAW(AuthBy)) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec is_admin(knm_phone_number() | api_ne_binary()) -> boolean(). +-spec is_admin(knm_phone_number() | kz_term:api_ne_binary()) -> boolean(). -ifdef(TEST). is_admin(#knm_phone_number{auth_by=AuthBy}) -> is_admin(AuthBy); is_admin(?KNM_DEFAULT_AUTH_BY) -> true; @@ -1480,11 +1480,11 @@ doc_from_public_fields(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec modified(knm_phone_number()) -> gregorian_seconds(). +-spec modified(knm_phone_number()) -> kz_time:gregorian_seconds(). modified(#knm_phone_number{modified = undefined}) -> kz_time:now_s(); modified(#knm_phone_number{modified = Modified}) -> Modified. --spec set_modified(knm_phone_number(), gregorian_seconds()) -> knm_phone_number(). +-spec set_modified(knm_phone_number(), kz_time:gregorian_seconds()) -> knm_phone_number(). set_modified(PN=#knm_phone_number{modified = undefined}, undefined) -> ?DIRTY(PN#knm_phone_number{modified = kz_time:now_s()}); set_modified(PN=#knm_phone_number{modified = V}, V) -> PN; @@ -1497,11 +1497,11 @@ set_modified(PN, Modified) %% @doc %% @end %%-------------------------------------------------------------------- --spec created(knm_phone_number()) -> gregorian_seconds(). +-spec created(knm_phone_number()) -> kz_time:gregorian_seconds(). created(#knm_phone_number{created = undefined}) -> kz_time:now_s(); created(#knm_phone_number{created = Created}) -> Created. --spec set_created(knm_phone_number(), gregorian_seconds()) -> knm_phone_number(). +-spec set_created(knm_phone_number(), kz_time:gregorian_seconds()) -> knm_phone_number(). set_created(PN=#knm_phone_number{created = undefined}, Created) when is_integer(Created), Created > 0 -> PN#knm_phone_number{created = Created}; @@ -1530,14 +1530,14 @@ remove_denied_features(PN) -> {ok, NewPN} = setters(PN, Updates), NewPN. --spec remove_in_private(ne_binary()) -> [kz_json:path()]. +-spec remove_in_private(kz_term:ne_binary()) -> [kz_json:path()]. remove_in_private(Feature) -> case maps:is_key(Feature, private_to_public()) of false -> []; true -> [[Feature]] end. --spec remove_in_public(ne_binary()) -> [kz_json:path()]. +-spec remove_in_public(kz_term:ne_binary()) -> [kz_json:path()]. remove_in_public(Feature) -> maps:get(Feature, private_to_public(), []). @@ -1579,7 +1579,7 @@ private_to_public() -> %% @doc %% @end %%-------------------------------------------------------------------- --spec list_attachments(knm_phone_number(), ne_binary()) -> {'ok', kz_json:object()} | +-spec list_attachments(knm_phone_number(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. list_attachments(PN, AuthBy) -> AssignedTo = assigned_to(PN), @@ -1647,7 +1647,7 @@ is_reserved_from_parent(_) -> false. %%% Internal functions %%%=================================================================== --spec is_admin_or_in_account_hierarchy(ne_binary(), ne_binary()) -> boolean(). +-spec is_admin_or_in_account_hierarchy(kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_admin_or_in_account_hierarchy(AuthBy, AccountId) -> case is_admin(AuthBy) of true -> @@ -1658,7 +1658,7 @@ is_admin_or_in_account_hierarchy(AuthBy, AccountId) -> is_in_account_hierarchy(AuthBy, AccountId) end. --spec is_in_account_hierarchy(ne_binary(), ne_binary()) -> boolean(). +-spec is_in_account_hierarchy(kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). -ifdef(TEST). is_in_account_hierarchy(AccountId, AccountId) -> true; is_in_account_hierarchy(?MASTER_ACCOUNT_ID, ?RESELLER_ACCOUNT_ID) -> true; @@ -1788,9 +1788,9 @@ database_error(NumOrNums, E, T) -> Reason = knm_errors:to_json(A, B, C), knm_numbers:ko(NumOrNums, Reason, T). --spec save_docs(ne_binary(), kz_json:objects()) -> {ok, kz_json:objects()} | +-spec save_docs(kz_term:ne_binary(), kz_json:objects()) -> {ok, kz_json:objects()} | {error, kz_data:data_errors()}. --spec delete_docs(ne_binary(), ne_binaries()) -> {ok, kz_json:objects()} | +-spec delete_docs(kz_term:ne_binary(), kz_term:ne_binaries()) -> {ok, kz_json:objects()} | {error, kz_data:data_errors()}. -ifdef(TEST). mock_docs_return(?NE_BINARY=Id) -> diff --git a/core/kazoo_number_manager/src/knm_port_request.erl b/core/kazoo_number_manager/src/knm_port_request.erl index fbf4ad64fef..954adb62321 100644 --- a/core/kazoo_number_manager/src/knm_port_request.erl +++ b/core/kazoo_number_manager/src/knm_port_request.erl @@ -68,7 +68,7 @@ init() -> %% @doc %% @end %%-------------------------------------------------------------------- --spec current_state(kz_json:object()) -> api_binary(). +-spec current_state(kz_json:object()) -> kz_term:api_binary(). current_state(JObj) -> kz_json:get_value(?PORT_PVT_STATE, JObj, ?PORT_UNCONFIRMED). @@ -95,8 +95,8 @@ public_fields(JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get(ne_binary()) -> {'ok', kz_json:object()} | - {'error', 'not_found'}. +-spec get(kz_term:ne_binary()) -> {'ok', kz_json:object()} | + {'error', 'not_found'}. -ifdef(TEST). get(?TEST_NEW_PORT_NUM) -> {ok, ?TEST_NEW_PORT_REQ}; get(?NE_BINARY) -> {error, not_found}. @@ -117,8 +117,8 @@ get(DID=?NE_BINARY) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec account_active_ports(ne_binary()) -> {'ok', kz_json:objects()} | - {'error', 'not_found'}. +-spec account_active_ports(kz_term:ne_binary()) -> {'ok', kz_json:objects()} | + {'error', 'not_found'}. account_active_ports(AccountId) -> ViewOptions = [{'key', AccountId} ,'include_docs' @@ -136,7 +136,7 @@ account_active_ports(AccountId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec account_has_active_port(ne_binary()) -> boolean(). +-spec account_has_active_port(kz_term:ne_binary()) -> boolean(). account_has_active_port(AccountId) -> case account_active_ports(AccountId) of {'ok', [_|_]} -> 'true'; @@ -176,7 +176,7 @@ normalize_number_map(N, Meta) -> {knm_converters:normalize(N), Meta}. %% @public --spec new(kz_json:object(), ne_binary(), api_ne_binary()) -> kz_json:object(). +-spec new(kz_json:object(), kz_term:ne_binary(), kz_term:api_ne_binary()) -> kz_json:object(). new(PortReq, ?MATCH_ACCOUNT_RAW(AuthAccountId), AuthUserId) -> Normalized = normalize_numbers(PortReq), Metadata = transition_metadata(AuthAccountId, AuthUserId), @@ -230,7 +230,7 @@ transition_to_canceled(JObj, Metadata) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec maybe_transition(kz_json:object(), transition_metadata(), ne_binary()) -> transition_response(). +-spec maybe_transition(kz_json:object(), transition_metadata(), kz_term:ne_binary()) -> transition_response(). maybe_transition(PortReq, Metadata, ?PORT_SUBMITTED) -> transition_to_submitted(PortReq, Metadata); maybe_transition(PortReq, Metadata, ?PORT_PENDING) -> @@ -244,9 +244,9 @@ maybe_transition(PortReq, Metadata, ?PORT_REJECTED) -> maybe_transition(PortReq, Metadata, ?PORT_CANCELED) -> transition_to_canceled(PortReq, Metadata). --spec transition(kz_json:object(), transition_metadata(), ne_binaries(), ne_binary()) -> +-spec transition(kz_json:object(), transition_metadata(), kz_term:ne_binaries(), kz_term:ne_binary()) -> transition_response(). --spec transition(kz_json:object(), transition_metadata(), ne_binaries(), ne_binary(), ne_binary()) -> +-spec transition(kz_json:object(), transition_metadata(), kz_term:ne_binaries(), kz_term:ne_binary(), kz_term:ne_binary()) -> transition_response(). transition(JObj, Metadata, FromStates, ToState) -> transition(JObj, Metadata, FromStates, ToState, current_state(JObj)). @@ -262,7 +262,7 @@ transition(JObj, Metadata, [_FromState | FromStates], ToState, CurrentState) -> lager:debug("skipping from ~s to ~s c ~p", [_FromState, ToState, CurrentState]), transition(JObj, Metadata, FromStates, ToState, CurrentState). --spec successful_transition(kz_json:object(), ne_binary(), ne_binary(), transition_metadata()) -> kz_json:object(). +-spec successful_transition(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary(), transition_metadata()) -> kz_json:object(). successful_transition(JObj, FromState, ToState, Metadata) -> MetadataJObj = transition_metadata_jobj(FromState, ToState, Metadata), NewTransitions = [MetadataJObj | kz_json:get_list_value(?PORT_PVT_TRANSITIONS, JObj, [])], @@ -271,7 +271,7 @@ successful_transition(JObj, FromState, ToState, Metadata) -> ], kz_json:set_values(Values, JObj). --spec transition_metadata_jobj(api_ne_binary(), ne_binary(), transition_metadata()) -> kz_json:object(). +-spec transition_metadata_jobj(kz_term:api_ne_binary(), kz_term:ne_binary(), transition_metadata()) -> kz_json:object(). transition_metadata_jobj(FromState, ToState, #{auth_account_id := AuthAccountId ,auth_account_name := AuthAccountName ,auth_user_id := OptionalUserId @@ -294,7 +294,7 @@ transition_metadata_jobj(FromState, ToState, #{auth_account_id := AuthAccountId ]} ]). --spec maybe_user(api_ne_binary(), api_ne_binary(), api_ne_binary()) -> kz_proplist(). +-spec maybe_user(kz_term:api_ne_binary(), kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> kz_term:proplist(). maybe_user(undefined, _, _) -> []; maybe_user(UserId, OptionalFirstName, OptionalLastName) -> [{<<"user">>, [{<<"id">>, UserId} @@ -304,21 +304,21 @@ maybe_user(UserId, OptionalFirstName, OptionalLastName) -> ]. %% @public --type transition_metadata() :: #{auth_account_id => ne_binary() - ,auth_account_name => api_ne_binary() - ,auth_user_id => api_ne_binary() - ,user_first_name => api_ne_binary() - ,user_last_name => api_ne_binary() - ,optional_reason => api_ne_binary() +-type transition_metadata() :: #{auth_account_id => kz_term:ne_binary() + ,auth_account_name => kz_term:api_ne_binary() + ,auth_user_id => kz_term:api_ne_binary() + ,user_first_name => kz_term:api_ne_binary() + ,user_last_name => kz_term:api_ne_binary() + ,optional_reason => kz_term:api_ne_binary() }. %% @public --spec transition_metadata(ne_binary(), api_ne_binary()) -> transition_metadata(). +-spec transition_metadata(kz_term:ne_binary(), kz_term:api_ne_binary()) -> transition_metadata(). transition_metadata(AuthAccountId, AuthUserId) -> transition_metadata(AuthAccountId, AuthUserId, undefined). %% @public --spec transition_metadata(ne_binary(), api_ne_binary(), api_ne_binary()) -> transition_metadata(). +-spec transition_metadata(kz_term:ne_binary(), kz_term:api_ne_binary(), kz_term:api_ne_binary()) -> transition_metadata(). transition_metadata(?MATCH_ACCOUNT_RAW(AuthAccountId), UserId, Reason) -> OptionalUserId = case UserId of ?NE_BINARY -> UserId; @@ -351,7 +351,7 @@ get_user_name(AuthAccountId, UserId) -> %% @end %%-------------------------------------------------------------------- -spec charge_for_port(kz_json:object()) -> 'ok' | 'error'. --spec charge_for_port(kz_json:object(), ne_binary()) -> 'ok' | 'error'. +-spec charge_for_port(kz_json:object(), kz_term:ne_binary()) -> 'ok' | 'error'. charge_for_port(JObj) -> charge_for_port(JObj, kz_doc:account_id(JObj)). charge_for_port(_JObj, AccountId) -> @@ -365,7 +365,7 @@ charge_for_port(_JObj, AccountId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec assign_to_app(ne_binary(), api_ne_binary(), kz_json:object()) -> +-spec assign_to_app(kz_term:ne_binary(), kz_term:api_ne_binary(), kz_json:object()) -> {'ok', kz_json:object()} | {'error', any()}. assign_to_app(Number, NewApp, JObj) -> @@ -508,7 +508,7 @@ clear_numbers_from_port(PortReq) -> %% @end %%-------------------------------------------------------------------- -spec maybe_send_request(kz_json:object()) -> 'ok'. --spec maybe_send_request(kz_json:object(), api_binary()) -> 'ok'. +-spec maybe_send_request(kz_json:object(), kz_term:api_binary()) -> 'ok'. maybe_send_request(JObj) -> kz_util:put_callid(kz_doc:id(JObj)), AccountId = kz_doc:account_id(JObj), @@ -537,7 +537,7 @@ maybe_send_request(JObj, Url)-> %% @doc %% @end %%-------------------------------------------------------------------- --spec send_request(kz_json:object(), ne_binary()) -> 'error' | 'ok'. +-spec send_request(kz_json:object(), kz_term:ne_binary()) -> 'error' | 'ok'. send_request(JObj, Url) -> Headers = [{"Content-Type", "application/json"} ,{"User-Agent", kz_term:to_list(node())} @@ -571,7 +571,7 @@ send_request(JObj, Url) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec send_attachements(ne_binary(), kz_json:object()) -> 'error' | 'ok'. +-spec send_attachements(kz_term:ne_binary(), kz_json:object()) -> 'error' | 'ok'. send_attachements(Url, JObj) -> try fetch_and_send(Url, JObj) of 'ok' -> 'ok' @@ -584,7 +584,7 @@ send_attachements(Url, JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec fetch_and_send(ne_binary(), kz_json:object()) -> 'ok'. +-spec fetch_and_send(kz_term:ne_binary(), kz_json:object()) -> 'ok'. fetch_and_send(Url, JObj) -> Id = kz_doc:id(JObj), Attachments = kz_doc:attachments(JObj, kz_json:new()), @@ -604,7 +604,7 @@ fetch_and_send(Url, JObj) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec send_attachment(ne_binary(), ne_binary(), ne_binary(), kz_json:object(), binary()) -> +-spec send_attachment(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), binary()) -> 'error' | 'ok'. send_attachment(Url, Id, Name, Options, Attachment) -> ContentType = kz_json:get_value(<<"content_type">>, Options), @@ -668,15 +668,15 @@ prepare_docs_for_migrate(Docs) -> =/= 'undefined' ]. --spec migrate_doc(kz_json:object()) -> api_object(). +-spec migrate_doc(kz_json:object()) -> kz_term:api_object(). migrate_doc(PortRequest) -> case kz_json:get_value(?PORT_PVT_TREE, PortRequest) of 'undefined' -> update_doc(PortRequest); _Tree -> 'undefined' end. --spec update_doc(kz_json:object()) -> api_object(). --spec update_doc(kz_json:object(), api_binary()) -> api_object(). +-spec update_doc(kz_json:object()) -> kz_term:api_object(). +-spec update_doc(kz_json:object(), kz_term:api_binary()) -> kz_term:api_object(). update_doc(PortRequest) -> update_doc(PortRequest, kz_doc:account_id(PortRequest)). diff --git a/core/kazoo_number_manager/src/knm_search.erl b/core/kazoo_number_manager/src/knm_search.erl index 2599642c32f..e0ed8675cf4 100644 --- a/core/kazoo_number_manager/src/knm_search.erl +++ b/core/kazoo_number_manager/src/knm_search.erl @@ -38,14 +38,14 @@ -include("knm.hrl"). -type option() :: {'quantity', pos_integer()} | - {'prefix', ne_binary()} | - {'dialcode', ne_binary()} | + {'prefix', kz_term:ne_binary()} | + {'dialcode', kz_term:ne_binary()} | {'country', knm_util:country_iso3166a2()} | {'offset', non_neg_integer()} | {'blocks', boolean()} | - {'account_id', ne_binary()} | - {'query_id', ne_binary()} | - {'reseller_id', ne_binary()}. + {'account_id', kz_term:ne_binary()} | + {'query_id', kz_term:ne_binary()} | + {'reseller_id', kz_term:ne_binary()}. -type options() :: [option()]. -export_type([option/0, options/0]). @@ -58,7 +58,7 @@ -define(EOT, '$end_of_table'). --type state() :: #{node => ne_binary() +-type state() :: #{node => kz_term:ne_binary() ,cache => ets:tid() | atom() }. @@ -76,7 +76,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). -ifdef(TEST). start_link() -> gen_listener:start_link({'local', ?MODULE} @@ -110,7 +110,7 @@ start_link() -> %% {stop, Reason} %% @end %%-------------------------------------------------------------------- --spec init([]) -> {'ok', state(), kz_timeout()}. +-spec init([]) -> {'ok', state(), timeout()}. init([]) -> State = #{node => kz_term:to_binary(node()) ,cache => ets:new(?ETS_DISCOVERY_CACHE, ?ETS_DISCOVERY_CACHE_OPTIONS) @@ -131,7 +131,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call({'first', Options}, _From, State) -> QueryId = query_id(Options), flush(QueryId), @@ -149,7 +149,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'gen_listener',{'created_queue', Queue}}, State) -> {'noreply', State#{queue => Queue}, ?POLLING_INTERVAL}; handle_cast({'reset_search',QID}, #{cache := Cache} = State) -> @@ -173,7 +173,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, State) -> {'noreply', State, ?POLLING_INTERVAL}. @@ -222,7 +222,7 @@ code_change(_OldVsn, State, _Extra) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec flush(ne_binary()) -> 'ok'. +-spec flush(kz_term:ne_binary()) -> 'ok'. -ifdef(TEST). flush(_QID) -> 'ok'. -else. @@ -279,12 +279,12 @@ first(Options) -> wait_for_search(length(Carriers)), gen_listener:call(?MODULE, {'first', Options}). --spec search_spawn(pid(), atom(), kz_proplist()) -> any(). +-spec search_spawn(pid(), atom(), kz_term:proplist()) -> any(). search_spawn(Pid, Carrier, Options) -> F = fun() -> Pid ! {Carrier, search_carrier(Carrier, Options)} end, kz_util:spawn(F). --spec search_carrier(atom(), kz_proplist()) -> any(). +-spec search_carrier(atom(), kz_term:proplist()) -> any(). search_carrier(Carrier, Options) -> Prefix = normalized_prefix(Options), Quantity = quantity(Options), @@ -343,7 +343,7 @@ next(Options) -> %% @end %%-------------------------------------------------------------------- -ifndef(TEST). --spec create_discovery(ne_binary(), module(), kz_json:object(), knm_carriers:options()) -> knm_number:knm_number(). +-spec create_discovery(kz_term:ne_binary(), module(), kz_json:object(), knm_carriers:options()) -> knm_number:knm_number(). create_discovery(DID=?NE_BINARY, Carrier, Data, Options0) -> Options = [{'state', ?NUMBER_STATE_DISCOVERY} ,{'module_name', kz_term:to_binary(Carrier)} @@ -366,22 +366,22 @@ quantity(Options) -> Quantity = props:get_integer_value('quantity', Options, 1), min(Quantity, ?MAX_SEARCH). --spec prefix(options()) -> ne_binary(). --spec prefix(options(), ne_binary()) -> ne_binary(). +-spec prefix(options()) -> kz_term:ne_binary(). +-spec prefix(options(), kz_term:ne_binary()) -> kz_term:ne_binary(). prefix(Options) -> props:get_ne_binary_value('prefix', Options). prefix(Options, Default) -> props:get_ne_binary_value('prefix', Options, Default). --spec query_options(options()) -> api_object(). --spec query_options(options(), api_object()) -> api_object(). +-spec query_options(options()) -> kz_term:api_object(). +-spec query_options(options(), kz_term:api_object()) -> kz_term:api_object(). query_options(Options) -> props:get_value('query_options', Options). query_options(Options, Default) -> props:get_value('query_options', Options, Default). --spec normalized_prefix(options()) -> ne_binary(). --spec normalized_prefix(options(), ne_binary()) -> ne_binary(). +-spec normalized_prefix(options()) -> kz_term:ne_binary(). +-spec normalized_prefix(options(), kz_term:ne_binary()) -> kz_term:ne_binary(). normalized_prefix(Options) -> JObj = query_options(Options, kz_json:new()), Dialcode = dialcode(Options), @@ -391,7 +391,7 @@ normalized_prefix(Options) -> normalized_prefix(Options, Default) -> props:get_ne_binary_value('normalized_prefix', Options, Default). --spec dialcode(options()) -> ne_binary(). +-spec dialcode(options()) -> kz_term:ne_binary(). dialcode(Options) -> Default = knm_util:prefix_for_country(country(Options)), props:get_ne_binary_value('dialcode', Options, Default). @@ -405,7 +405,7 @@ country(Options) -> ?KNM_DEFAULT_COUNTRY end. --spec query_id(options()) -> api_binary(). +-spec query_id(options()) -> kz_term:api_binary(). query_id(Options) -> props:get_ne_binary_value('query_id', Options). @@ -413,30 +413,30 @@ query_id(Options) -> offset(Options) -> props:get_integer_value('offset', Options, 0). --spec account_id(options()) -> api_ne_binary(). +-spec account_id(options()) -> kz_term:api_ne_binary(). account_id(Options) -> props:get_value('account_id', Options). --spec reseller_id(options()) -> ne_binary(). +-spec reseller_id(options()) -> kz_term:ne_binary(). reseller_id(Options) -> props:get_value('reseller_id', Options). --spec is_local(ne_binary()) -> boolean(). +-spec is_local(kz_term:ne_binary()) -> boolean(). is_local(QID) -> ets:match_object(?ETS_DISCOVERY_CACHE, {QID, '_'}) =/= []. --spec discovery(ne_binary()) -> knm_number:knm_number_return(). +-spec discovery(kz_term:ne_binary()) -> knm_number:knm_number_return(). discovery(Num) -> discovery(Num, []). --spec discovery(ne_binary(), knm_carriers:options()) -> knm_number:knm_number_return(). +-spec discovery(kz_term:ne_binary(), knm_carriers:options()) -> knm_number:knm_number_return(). discovery(Num, Options) -> case local_discovery(Num, Options) of {'ok', _}=OK -> OK; {'error', 'not_found'} -> remote_discovery(Num, Options) end. --spec local_discovery(ne_binary(), knm_carriers:options()) -> knm_number:knm_number_return(). +-spec local_discovery(kz_term:ne_binary(), knm_carriers:options()) -> knm_number:knm_number_return(). -ifdef(TEST). local_discovery(_Num, _Options) -> {'error', 'not_found'}. -else. @@ -448,7 +448,7 @@ local_discovery(Num, Options) -> end. -endif. --spec remote_discovery(ne_binary(), knm_carriers:options()) -> knm_number:knm_number_return(). +-spec remote_discovery(kz_term:ne_binary(), knm_carriers:options()) -> knm_number:knm_number_return(). -ifdef(TEST). remote_discovery(_Num, _Options) -> {'error', 'not_found'}. -else. diff --git a/core/kazoo_number_manager/src/knm_services.erl b/core/kazoo_number_manager/src/knm_services.erl index 2d34d6d24ce..1936204d31d 100644 --- a/core/kazoo_number_manager/src/knm_services.erl +++ b/core/kazoo_number_manager/src/knm_services.erl @@ -29,8 +29,8 @@ %% @doc %% @end %%-------------------------------------------------------------------- --type set_feature() :: {ne_binary(), kz_json:object()}. --spec activate_feature(knm_number:knm_number(), set_feature() | ne_binary()) -> +-type set_feature() :: {kz_term:ne_binary(), kz_json:object()}. +-spec activate_feature(knm_number:knm_number(), set_feature() | kz_term:ne_binary()) -> knm_number:knm_number(). -spec do_activate_feature(knm_number:knm_number(), set_feature()) -> knm_number:knm_number(). @@ -51,7 +51,7 @@ do_activate_feature(Number, FeatureToSet) -> BillingId = kz_services:get_billing_id(Services), activate_feature(Number, FeatureToSet, BillingId, Services). --spec activate_feature(knm_number:knm_number(), set_feature(), ne_binary(), kz_services:services()) -> +-spec activate_feature(knm_number:knm_number(), set_feature(), kz_term:ne_binary(), kz_services:services()) -> knm_number:knm_number(). activate_feature(Number, {Feature,FeatureData}, BillingId, Services) -> Units = kz_service_phone_numbers:feature_activation_charge(Feature, Services), @@ -73,7 +73,7 @@ activate_feature(Number, {Feature,FeatureData}, BillingId, Services) -> knm_number:set_phone_number(N, PN) end. --spec maybe_create_activation_transaction(knm_number:knm_number(), ne_binary(), integer(), number()) -> knm_number:knm_number(). +-spec maybe_create_activation_transaction(knm_number:knm_number(), kz_term:ne_binary(), integer(), number()) -> knm_number:knm_number(). maybe_create_activation_transaction(Number, _Feature, _Units, 0) -> lager:debug("no charges for feature ~s activation", [_Feature]), Number; @@ -89,7 +89,7 @@ maybe_create_activation_transaction(Number, Feature, Units, TotalCharges) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec deactivate_feature(knm_number:knm_number(), ne_binary()) -> knm_number:knm_number(). +-spec deactivate_feature(knm_number:knm_number(), kz_term:ne_binary()) -> knm_number:knm_number(). deactivate_feature(Number, Feature) -> PhoneNumber = knm_number:phone_number(Number), Features = knm_phone_number:features(PhoneNumber), @@ -101,7 +101,7 @@ deactivate_feature(Number, Feature) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec deactivate_features(knm_number:knm_number(), ne_binaries()) -> knm_number:knm_number(). +-spec deactivate_features(knm_number:knm_number(), kz_term:ne_binaries()) -> knm_number:knm_number(). deactivate_features(Number, Features) -> PhoneNumber = knm_number:phone_number(Number), ExistingFeatures = knm_phone_number:features(PhoneNumber), @@ -229,7 +229,7 @@ do_fetch_services(?MATCH_ACCOUNT_RAW(AssignedTo)) -> kz_services:fetch(AssignedT -endif. %% @private --spec create_numbers_transaction(ne_binaries(), pos_integer(), ne_binary(), ne_binary()) -> +-spec create_numbers_transaction(kz_term:ne_binaries(), pos_integer(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_transaction:transaction(). create_numbers_transaction(Nums=[_|_], Units, BillingId, AccountId) -> LedgerId = kz_util:format_account_id(BillingId), @@ -248,7 +248,7 @@ create_numbers_transaction(Nums=[_|_], Units, BillingId, AccountId) -> lists:foldl(fun(F, T) -> F(T) end, T0, Fs). -ifndef(TEST). --spec create_transaction(knm_number:knm_number(), ne_binary(), integer()) -> +-spec create_transaction(knm_number:knm_number(), kz_term:ne_binary(), integer()) -> kz_transaction:transaction(). create_transaction(Number, Feature, Units) -> BillingId = kz_services:get_billing_id(fetch_services(Number)), @@ -268,7 +268,7 @@ create_transaction(Number, Feature, Units) -> lists:foldl(fun(F, T) -> F(T) end, T0, Routines). -endif. --spec set_activation_reason(kz_transaction:transaction(), ne_binary(), ne_binary(), ne_binary()) -> +-spec set_activation_reason(kz_transaction:transaction(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_transaction:transaction(). set_activation_reason(Transaction, LedgerId, LedgerId, Key) -> kz_transaction:set_reason(<>, Transaction); diff --git a/core/kazoo_number_manager/src/knm_telnyx_util.erl b/core/kazoo_number_manager/src/knm_telnyx_util.erl index cfdc86e0629..5e1bd776b04 100644 --- a/core/kazoo_number_manager/src/knm_telnyx_util.erl +++ b/core/kazoo_number_manager/src/knm_telnyx_util.erl @@ -196,7 +196,7 @@ maybe_filter_rates('true', JObj) -> kz_json:set_value(<<"result">>, Results, JObj). -spec maybe_apply_limit(kz_json:object()) -> kz_json:object(). --spec maybe_apply_limit(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec maybe_apply_limit(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). maybe_apply_limit(JObj) -> maybe_apply_limit(maybe_apply_limit(JObj, <<"result">>) ,<<"inexplicit_result">> diff --git a/core/kazoo_number_manager/src/knm_util.erl b/core/kazoo_number_manager/src/knm_util.erl index 1d6c8524a99..e4055152f2c 100644 --- a/core/kazoo_number_manager/src/knm_util.erl +++ b/core/kazoo_number_manager/src/knm_util.erl @@ -21,7 +21,7 @@ -type country_iso3166a2() :: <<_:(8*2)>>. -export_type([country_iso3166a2/0]). --spec get_all_number_dbs() -> ne_binaries(). +-spec get_all_number_dbs() -> kz_term:ne_binaries(). get_all_number_dbs() -> ViewOptions = [{'startkey', <>} ,{'endkey', <>} @@ -29,7 +29,7 @@ get_all_number_dbs() -> {'ok', Dbs} = kz_datamgr:db_list(ViewOptions), [kz_http_util:urlencode(Db) || Db <- Dbs]. --spec pretty_print(api_binary()) -> ne_binary(). +-spec pretty_print(kz_term:api_binary()) -> kz_term:ne_binary(). pretty_print('undefined') -> <<"unknown">>; pretty_print(Number) -> case pretty_print_format(Number) of @@ -38,7 +38,7 @@ pretty_print(Number) -> pretty_print(Format, Number) end. --spec pretty_print(ne_binary(), ne_binary()) -> ne_binary(). +-spec pretty_print(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). pretty_print(Format, Number) -> Num = knm_converters:normalize(Number), pretty_print(Format, Num, <<>>). @@ -69,11 +69,11 @@ pretty_print(<<"*", Format/binary>>, Number, Acc) -> pretty_print(<>, Number, Acc) -> pretty_print(Format, Number, <>). --spec binary_tail(ne_binary()) -> ne_binary(). +-spec binary_tail(kz_term:ne_binary()) -> kz_term:ne_binary(). binary_tail(Binary) -> binary:part(Binary, 1, byte_size(Binary) - 1). --spec binary_head(ne_binary()) -> ne_binary(). +-spec binary_head(kz_term:ne_binary()) -> kz_term:ne_binary(). binary_head(Binary) -> binary:part(Binary, 0, 1). @@ -83,13 +83,13 @@ binary_head(Binary) -> %% %% @end %%-------------------------------------------------------------------- --spec pretty_print_format(ne_binary()) -> api_binary(). +-spec pretty_print_format(kz_term:ne_binary()) -> kz_term:api_binary(). pretty_print_format(Number) -> Classifiers = knm_converters:available_classifiers(), Num = knm_converters:normalize(Number), pretty_print_format(Num, kz_json:to_proplist(Classifiers)). --spec pretty_print_format(ne_binary(), kz_proplist()) -> api_binary(). +-spec pretty_print_format(kz_term:ne_binary(), kz_term:proplist()) -> kz_term:api_binary(). pretty_print_format(Num, []) -> lager:debug("unable to get pretty print format for number ~s", [Num]), maybe_use_us_default(Num); @@ -106,15 +106,15 @@ pretty_print_format(Num, [{Classification, Classifier}|Classifiers]) -> end end. --spec maybe_use_us_default(ne_binary()) -> api_binary(). +-spec maybe_use_us_default(kz_term:ne_binary()) -> kz_term:api_binary(). maybe_use_us_default(<<"+1", _/binary>>) -> lager:debug("using US number default pretty print", []), <<"SS(###) ### - ####">>; maybe_use_us_default(_) -> 'undefined'. --spec get_classifier_regex(ne_binary() | kz_json:object()) -> - ne_binary(). +-spec get_classifier_regex(kz_term:ne_binary() | kz_json:object()) -> + kz_term:ne_binary(). get_classifier_regex(Classifier) when is_binary(Classifier) -> Classifier; get_classifier_regex(JObj) -> @@ -134,6 +134,6 @@ read_fixture({'error', 'enoent'}, F) -> %% TODO %% This should be replaced with a call to elibphonenumber %% when/if we integrate that lib or do it ourselves --spec prefix_for_country(country_iso3166a2()) -> ne_binary(). +-spec prefix_for_country(country_iso3166a2()) -> kz_term:ne_binary(). prefix_for_country(Country) -> knm_iso3166a2_itu:to_itu(kz_term:to_upper_binary(Country)). diff --git a/core/kazoo_number_manager/src/knm_vitelity.hrl b/core/kazoo_number_manager/src/knm_vitelity.hrl index cdde5dc24a6..b41fbd7be2d 100644 --- a/core/kazoo_number_manager/src/knm_vitelity.hrl +++ b/core/kazoo_number_manager/src/knm_vitelity.hrl @@ -17,28 +17,28 @@ -type yes_or_no() :: <<_:16>> | <<_:24>>. -type state_two_letters() :: <<_:16>>. --type qs_option() :: {'did', ne_binary()} | - {'name', ne_binary()} | - {'cmd', ne_binary()} | +-type qs_option() :: {'did', kz_term:ne_binary()} | + {'name', kz_term:ne_binary()} | + {'cmd', kz_term:ne_binary()} | {'xml', yes_or_no()} | - {'routesip', ne_binary()} | - {'npanxx', ne_binary()} | - {'type', ne_binary()} | + {'routesip', kz_term:ne_binary()} | + {'npanxx', kz_term:ne_binary()} | + {'type', kz_term:ne_binary()} | {'withrates', yes_or_no()} | - {'provider', ne_binary()} | + {'provider', kz_term:ne_binary()} | {'cnam', yes_or_no()} | - {'address', ne_binary()} | - {'city', ne_binary()} | + {'address', kz_term:ne_binary()} | + {'city', kz_term:ne_binary()} | {'state', state_two_letters()} | - {'zip', ne_binary() | integer()} | - {'ratecenter', ne_binary()} | + {'zip', kz_term:ne_binary() | integer()} | + {'ratecenter', kz_term:ne_binary()} | {'smsonly', yes_or_no()} | - {'login', ne_binary()} | - {'pass', ne_binary()}. + {'login', kz_term:ne_binary()} | + {'pass', kz_term:ne_binary()}. -type qs_options() :: [qs_option()]. -type query_option() :: {'qs', qs_options()} | - {'uri', ne_binary()}. + {'uri', kz_term:ne_binary()}. -type query_options() :: [query_option()]. -define(KNM_VITELITY_HRL, 'true'). diff --git a/core/kazoo_number_manager/src/knm_vitelity_util.erl b/core/kazoo_number_manager/src/knm_vitelity_util.erl index 1538cf9ec15..f3f8fd87afd 100644 --- a/core/kazoo_number_manager/src/knm_vitelity_util.erl +++ b/core/kazoo_number_manager/src/knm_vitelity_util.erl @@ -41,13 +41,13 @@ ) ). --spec api_uri() -> ne_binary(). +-spec api_uri() -> kz_term:ne_binary(). api_uri() -> ?API_URL. --spec config_cat() -> ne_binary(). +-spec config_cat() -> kz_term:ne_binary(). config_cat() -> ?KNM_VITELITY_CONFIG_CAT. --spec add_options_fold({atom(), api_binary()}, query_options()) -> +-spec add_options_fold({atom(), kz_term:api_binary()}, query_options()) -> query_options(). add_options_fold({_K, 'undefined'}, Options) -> Options; add_options_fold({K, V}, Options) -> @@ -63,7 +63,7 @@ add_options_fold({K, V}, Options) -> end). -endif. --spec get_query_value(ne_binary(), knm_carriers:options()) -> any(). +-spec get_query_value(kz_term:ne_binary(), knm_carriers:options()) -> any(). get_query_value(<<"cnam">>=Key, Options) -> ?QUERY_VALUE(Key, Options); get_query_value(<<"login">>=Key, Options) -> ?QUERY_VALUE(Key, Options); get_query_value(<<"pass">>=Key, Options) -> ?QUERY_VALUE(Key, Options); @@ -72,7 +72,7 @@ get_query_value(<<"type">>=Key, Options) -> ?QUERY_VALUE(Key, Options); get_query_value(<<"withrates">>=Key, Options) -> ?QUERY_VALUE(Key, Options). -spec default_options() -> qs_options(). --spec default_options(kz_proplist()) -> qs_options(). +-spec default_options(kz_term:proplist()) -> qs_options(). default_options() -> default_options([]). default_options(Options) -> @@ -80,7 +80,7 @@ default_options(Options) -> ,{'pass', get_query_value(<<"pass">>, Options)} ]. --spec build_uri(query_options()) -> ne_binary(). +-spec build_uri(query_options()) -> kz_term:ne_binary(). build_uri(Options) -> URI = props:get_value('uri', Options), QS = kz_term:to_binary( @@ -90,43 +90,43 @@ build_uri(Options) -> ))), <>. --spec xml_resp_status_msg(xml_els()) -> api_binary(). +-spec xml_resp_status_msg(kz_types:xml_els()) -> kz_term:api_binary(). xml_resp_status_msg(XmlEls) -> xml_el_to_binary(xml_resp_tag(XmlEls, 'status')). --spec xml_resp_error_msg(xml_els()) -> api_binary(). +-spec xml_resp_error_msg(kz_types:xml_els()) -> kz_term:api_binary(). xml_resp_error_msg(XmlEls) -> xml_el_to_binary(xml_resp_tag(XmlEls, 'error')). --spec xml_resp_response_msg(xml_els()) -> api_binary(). +-spec xml_resp_response_msg(kz_types:xml_els()) -> kz_term:api_binary(). xml_resp_response_msg(XmlEls) -> xml_el_to_binary(xml_resp_tag(XmlEls, 'response')). --spec xml_resp_numbers(xml_els()) -> xml_el() | 'undefined'. +-spec xml_resp_numbers(kz_types:xml_els()) -> kz_types:xml_el() | 'undefined'. xml_resp_numbers(XmlEls) -> xml_resp_tag(XmlEls, 'numbers'). --spec xml_resp_info(xml_els()) -> xml_el() | 'undefined'. +-spec xml_resp_info(kz_types:xml_els()) -> kz_types:xml_el() | 'undefined'. xml_resp_info(XmlEls) -> xml_resp_tag(XmlEls, 'info'). --spec xml_resp_response(xml_els()) -> xml_el() | 'undefined'. +-spec xml_resp_response(kz_types:xml_els()) -> kz_types:xml_el() | 'undefined'. xml_resp_response(XmlEls) -> xml_resp_tag(XmlEls, 'response'). --spec xml_resp_tag(xml_els(), atom()) -> xml_el() | 'undefined'. +-spec xml_resp_tag(kz_types:xml_els(), atom()) -> kz_types:xml_el() | 'undefined'. xml_resp_tag([#xmlElement{name=Name}=El|_], Name) -> El; xml_resp_tag([_|Els], Name) -> xml_resp_tag(Els, Name); xml_resp_tag([], _Name) -> 'undefined'. --spec xml_el_to_binary('undefined' | xml_el()) -> api_binary(). +-spec xml_el_to_binary('undefined' | kz_types:xml_el()) -> kz_term:api_binary(). xml_el_to_binary('undefined') -> 'undefined'; xml_el_to_binary(#xmlElement{content=Content}) -> kz_xml:texts_to_binary(Content). --spec xml_els_to_proplist(xml_els()) -> kz_proplist(). +-spec xml_els_to_proplist(kz_types:xml_els()) -> kz_term:proplist(). xml_els_to_proplist(Els) -> [KV || El <- Els, begin @@ -135,7 +135,7 @@ xml_els_to_proplist(Els) -> end ]. --spec xml_el_to_kv_pair(xml_el()) -> {ne_binary(), api_binary() | kz_json:object()}. +-spec xml_el_to_kv_pair(kz_types:xml_el()) -> {kz_term:ne_binary(), kz_term:api_binary() | kz_json:object()}. xml_el_to_kv_pair(#xmlElement{name='did' ,content=Value }) -> @@ -170,8 +170,8 @@ xml_el_to_kv_pair(#xmlElement{name=Name } end. --spec query_vitelity(ne_binary()) -> - {'ok', text()} | +-spec query_vitelity(kz_term:ne_binary()) -> + {'ok', kz_term:text()} | {'error', any()}. query_vitelity(URI) -> lager:debug("querying ~s", [URI]), @@ -184,7 +184,7 @@ query_vitelity(URI) -> E end. --spec get_short_state(ne_binary()) -> state_two_letters() | 'undefined'. +-spec get_short_state(kz_term:ne_binary()) -> state_two_letters() | 'undefined'. get_short_state(FullState) -> States = [{<<"alabama">>, <<"AL">>} ,{<<"alaska">>, <<"AK">>} @@ -249,7 +249,7 @@ get_short_state(FullState) -> State = kz_term:to_lower_binary(FullState), props:get_value(State, States). --spec get_routesip() -> ne_binary(). +-spec get_routesip() -> kz_term:ne_binary(). -ifdef(TEST). get_routesip() -> <<"1.2.3.4">>. -else. diff --git a/core/kazoo_number_manager/src/providers/knm_cnam_notifier.erl b/core/kazoo_number_manager/src/providers/knm_cnam_notifier.erl index 0609ac8e729..8b1de93bb5a 100644 --- a/core/kazoo_number_manager/src/providers/knm_cnam_notifier.erl +++ b/core/kazoo_number_manager/src/providers/knm_cnam_notifier.erl @@ -23,7 +23,7 @@ %% @end %%-------------------------------------------------------------------- -spec save(knm_number:knm_number()) -> knm_number:knm_number(). --spec save(knm_number:knm_number(), ne_binary()) -> knm_number:knm_number(). +-spec save(knm_number:knm_number(), kz_term:ne_binary()) -> knm_number:knm_number(). save(Number) -> State = knm_phone_number:state(knm_number:phone_number(Number)), save(Number, State). diff --git a/core/kazoo_number_manager/src/providers/knm_dash_e911.erl b/core/kazoo_number_manager/src/providers/knm_dash_e911.erl index 3393726525f..2b4d9620b4e 100644 --- a/core/kazoo_number_manager/src/providers/knm_dash_e911.erl +++ b/core/kazoo_number_manager/src/providers/knm_dash_e911.erl @@ -43,7 +43,7 @@ %%-------------------------------------------------------------------- -spec save(knm_number:knm_number()) -> knm_number:knm_number(). --spec save(knm_number:knm_number(), api_binary()) -> +-spec save(knm_number:knm_number(), kz_term:api_binary()) -> knm_number:knm_number(). save(Number) -> State = knm_phone_number:state(knm_number:phone_number(Number)), @@ -205,8 +205,8 @@ is_valid_location(Location) -> end. %% @private --spec parse_response(xml_el()) -> location_response(). --spec parse_response(ne_binary(), xml_el()) -> location_response(). +-spec parse_response(kz_types:xml_el()) -> location_response(). +-spec parse_response(kz_term:ne_binary(), kz_types:xml_el()) -> location_response(). parse_response(Response) -> StatusCode = kz_xml:get_value("//Location/status/code/text()", Response), parse_response(StatusCode, Response). @@ -228,7 +228,7 @@ parse_response(Else, _) -> %% %% @end %%-------------------------------------------------------------------- --spec add_location(ne_binary(), [xml_location()], ne_binary()) -> +-spec add_location(kz_term:ne_binary(), [xml_location()], kz_term:ne_binary()) -> {'geocoded', kz_json:object()} | {'provisioned', kz_json:object()} | {'error', binary()}. @@ -250,7 +250,7 @@ add_location(Number, Location, CallerName) -> %% %% @end %%-------------------------------------------------------------------- --spec provision_location(ne_binary()) -> api_binary(). +-spec provision_location(kz_term:ne_binary()) -> kz_term:api_binary(). provision_location(LocationId) -> Props = [{'locationid', [kz_term:to_list(LocationId)]}], case emergency_provisioning_request('provisionLocation', Props) of @@ -265,7 +265,7 @@ provision_location(LocationId) -> %% %% @end %%-------------------------------------------------------------------- --spec remove_number(knm_number:knm_number()) -> api_binary(). +-spec remove_number(knm_number:knm_number()) -> kz_term:api_binary(). remove_number(Number) -> Num = knm_phone_number:number(knm_number:phone_number(Number)), lager:debug("removing from upstream '~s'", [Num]), @@ -308,7 +308,7 @@ remove_number(Number) -> -type request_props() :: [request_prop()]. -spec emergency_provisioning_request(atom(), request_props()) -> - {'ok', xml_el()} | + {'ok', kz_types:xml_el()} | {'error', emergency_provisioning_error()}. emergency_provisioning_request(Verb, Props) -> URL = list_to_binary([?EMERG_URL, "/", kz_term:to_lower_binary(Verb)]), @@ -396,7 +396,7 @@ json_address_to_xml_location(JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec location_xml_to_json_address(xml_el() | xml_els()) -> kz_json:object() | kz_json:objects(). +-spec location_xml_to_json_address(kz_types:xml_el() | kz_types:xml_els()) -> kz_json:object() | kz_json:objects(). location_xml_to_json_address([]) -> kz_json:new(); location_xml_to_json_address([Xml]) -> diff --git a/core/kazoo_number_manager/src/providers/knm_failover.erl b/core/kazoo_number_manager/src/providers/knm_failover.erl index 6ad78f14e44..7e7a5bf25ab 100644 --- a/core/kazoo_number_manager/src/providers/knm_failover.erl +++ b/core/kazoo_number_manager/src/providers/knm_failover.erl @@ -24,7 +24,7 @@ %% @end %%-------------------------------------------------------------------- -spec save(knm_number:knm_number()) -> knm_number:knm_number(). --spec save(knm_number:knm_number(), ne_binary()) -> knm_number:knm_number(). +-spec save(knm_number:knm_number(), kz_term:ne_binary()) -> knm_number:knm_number(). save(N) -> save(N, knm_phone_number:state(knm_number:phone_number(N))). diff --git a/core/kazoo_number_manager/src/providers/knm_port_notifier.erl b/core/kazoo_number_manager/src/providers/knm_port_notifier.erl index 83ca6716eae..1b5b5f09bb3 100644 --- a/core/kazoo_number_manager/src/providers/knm_port_notifier.erl +++ b/core/kazoo_number_manager/src/providers/knm_port_notifier.erl @@ -26,7 +26,7 @@ %% @end %%-------------------------------------------------------------------- -spec save(knm_number:knm_number()) -> knm_number:knm_number(). --spec save(knm_number:knm_number(), ne_binary(), ne_binary()) -> knm_number:knm_number(). +-spec save(knm_number:knm_number(), kz_term:ne_binary(), kz_term:ne_binary()) -> knm_number:knm_number(). save(N) -> PN = knm_number:phone_number(N), State = kz_json:get_ne_binary_value(?PVT_STATE, knm_phone_number:doc(PN)), diff --git a/core/kazoo_number_manager/src/providers/knm_prepend.erl b/core/kazoo_number_manager/src/providers/knm_prepend.erl index f58646eb496..b1eaae9b520 100644 --- a/core/kazoo_number_manager/src/providers/knm_prepend.erl +++ b/core/kazoo_number_manager/src/providers/knm_prepend.erl @@ -24,7 +24,7 @@ %% @end %%-------------------------------------------------------------------- -spec save(knm_number:knm_number()) -> knm_number:knm_number(). --spec save(knm_number:knm_number(), ne_binary()) -> knm_number:knm_number(). +-spec save(knm_number:knm_number(), kz_term:ne_binary()) -> knm_number:knm_number(). save(Number) -> State = knm_phone_number:state(knm_number:phone_number(Number)), save(Number, State). diff --git a/core/kazoo_number_manager/src/providers/knm_providers.erl b/core/kazoo_number_manager/src/providers/knm_providers.erl index 12b6c38fd48..577cc67f2ea 100644 --- a/core/kazoo_number_manager/src/providers/knm_providers.erl +++ b/core/kazoo_number_manager/src/providers/knm_providers.erl @@ -36,19 +36,19 @@ -ifdef(TEST). -record(feature_parameters, {is_local = false :: boolean() ,is_admin = false :: boolean() - ,assigned_to :: api_ne_binary() - ,used_by :: api_ne_binary() - ,allowed_features = [] :: ne_binaries() - ,denied_features = [] :: ne_binaries() - ,num :: ne_binary() %% TEST-only + ,assigned_to :: kz_term:api_ne_binary() + ,used_by :: kz_term:api_ne_binary() + ,allowed_features = [] :: kz_term:ne_binaries() + ,denied_features = [] :: kz_term:ne_binaries() + ,num :: kz_term:ne_binary() %% TEST-only }). -else. -record(feature_parameters, {is_local = false :: boolean() ,is_admin = false :: boolean() - ,assigned_to :: api_ne_binary() - ,used_by :: api_ne_binary() - ,allowed_features = [] :: ne_binaries() - ,denied_features = [] :: ne_binaries() + ,assigned_to :: kz_term:api_ne_binary() + ,used_by :: kz_term:api_ne_binary() + ,allowed_features = [] :: kz_term:ne_binaries() + ,denied_features = [] :: kz_term:ne_binaries() }). -endif. -type feature_parameters() :: #feature_parameters{}. @@ -77,11 +77,11 @@ delete(Number) -> %% List features a number is allowed by its reseller to enable. %% @end %%-------------------------------------------------------------------- --spec available_features(knm_phone_number:knm_phone_number()) -> ne_binaries(). +-spec available_features(knm_phone_number:knm_phone_number()) -> kz_term:ne_binaries(). available_features(PhoneNumber) -> list_available_features(feature_parameters(PhoneNumber)). --spec available_features(boolean(), boolean(), api_ne_binary(), api_ne_binary(), ne_binaries(), ne_binaries()) -> ne_binaries(). +-spec available_features(boolean(), boolean(), kz_term:api_ne_binary(), kz_term:api_ne_binary(), kz_term:ne_binaries(), kz_term:ne_binaries()) -> kz_term:ne_binaries(). available_features(IsLocal, IsAdmin, AssignedTo, UsedBy, Allowed, Denied) -> list_available_features(feature_parameters(IsLocal, IsAdmin, AssignedTo, UsedBy, Allowed, Denied)). @@ -91,7 +91,7 @@ available_features(IsLocal, IsAdmin, AssignedTo, UsedBy, Allowed, Denied) -> %% The name of the billable service associated with a feature. %% @end %%-------------------------------------------------------------------- --spec service_name(ne_binary(), ne_binary()) -> ne_binary(). +-spec service_name(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). -ifdef(TEST). service_name(?FEATURE_E911, _AccountId) -> service_name(?E911_PROVIDER(_AccountId)); @@ -114,7 +114,7 @@ service_name(Feature, _) -> %% Util function to get E911 caller name defaults. %% @end %%-------------------------------------------------------------------- --spec e911_caller_name(knm_number:knm_number(), api_ne_binary()) -> ne_binary(). +-spec e911_caller_name(knm_number:knm_number(), kz_term:api_ne_binary()) -> kz_term:ne_binary(). -ifdef(TEST). e911_caller_name(_Number, ?NE_BINARY=Name) -> Name; e911_caller_name(_Number, 'undefined') -> ?E911_NAME_DEFAULT. @@ -132,7 +132,7 @@ e911_caller_name(Number, 'undefined') -> %%% Internal functions %%%=================================================================== --spec service_name(ne_binary()) -> ne_binary(). +-spec service_name(kz_term:ne_binary()) -> kz_term:ne_binary(). service_name(<<"knm_dash_e911">>) -> ?LEGACY_DASH_E911; service_name(<<"knm_telnyx_e911">>) -> ?LEGACY_TELNYX_E911; service_name(<<"knm_vitelity_e911">>) -> ?LEGACY_VITELITY_E911; @@ -141,7 +141,7 @@ service_name(<<"knm_telnyx_cnam">>) -> <<"telnyx_cnam">>; service_name(<<"knm_vitelity_cnam">>) -> <<"vitelity_cnam">>; service_name(Feature) -> Feature. --spec list_available_features(feature_parameters()) -> ne_binaries(). +-spec list_available_features(feature_parameters()) -> kz_term:ne_binaries(). list_available_features(Parameters) -> ?LOG_DEBUG("is admin? ~s", [Parameters#feature_parameters.is_admin]), Allowed = cleanse_features(list_allowed_features(Parameters)), @@ -153,7 +153,7 @@ list_available_features(Parameters) -> ?LOG_DEBUG("available features: ~s", [?PP(Available)]), Available. --spec cleanse_features(ne_binaries()) -> ne_binaries(). +-spec cleanse_features(kz_term:ne_binaries()) -> kz_term:ne_binaries(). cleanse_features(Features) -> lists:usort([legacy_provider_to_feature(Feature) || Feature <- Features]). @@ -187,7 +187,7 @@ feature_parameters(PhoneNumber) -> ). -endif. --spec feature_parameters(boolean(), boolean(), api_ne_binary(), api_ne_binary(), ne_binaries(), ne_binaries()) -> feature_parameters(). +-spec feature_parameters(boolean(), boolean(), kz_term:api_ne_binary(), kz_term:api_ne_binary(), kz_term:ne_binaries(), kz_term:ne_binaries()) -> feature_parameters(). feature_parameters(IsLocal, IsAdmin, AssignedTo, UsedBy, Allowed, Denied) -> #feature_parameters{is_local = IsLocal ,is_admin = IsAdmin @@ -197,14 +197,14 @@ feature_parameters(IsLocal, IsAdmin, AssignedTo, UsedBy, Allowed, Denied) -> ,denied_features = Denied }. --spec list_allowed_features(feature_parameters()) -> ne_binaries(). +-spec list_allowed_features(feature_parameters()) -> kz_term:ne_binaries(). list_allowed_features(Parameters) -> case number_allowed_features(Parameters) of [] -> reseller_allowed_features(Parameters); NumberAllowed -> NumberAllowed end. --spec reseller_allowed_features(feature_parameters()) -> ne_binaries(). +-spec reseller_allowed_features(feature_parameters()) -> kz_term:ne_binaries(). reseller_allowed_features(#feature_parameters{assigned_to = 'undefined'}) -> system_allowed_features(); reseller_allowed_features(#feature_parameters{assigned_to = AccountId}=_Params) -> @@ -215,7 +215,7 @@ reseller_allowed_features(#feature_parameters{assigned_to = AccountId}=_Params) Providers end. --spec system_allowed_features() -> ne_binaries(). +-spec system_allowed_features() -> kz_term:ne_binaries(). system_allowed_features() -> Features = lists:usort( @@ -227,7 +227,7 @@ system_allowed_features() -> ?LOG_DEBUG("allowed features from system config: ~s", [?PP(Features)]), Features. --spec number_allowed_features(feature_parameters()) -> ne_binaries(). +-spec number_allowed_features(feature_parameters()) -> kz_term:ne_binaries(). -ifdef(TEST). number_allowed_features(#feature_parameters{num = ?TEST_OLD5_1_NUM}) -> AllowedFeatures = [?FEATURE_CNAM @@ -266,7 +266,7 @@ number_allowed_features(#feature_parameters{allowed_features = AllowedFeatures}) AllowedFeatures. -endif. --spec list_denied_features(feature_parameters()) -> ne_binaries(). +-spec list_denied_features(feature_parameters()) -> kz_term:ne_binaries(). list_denied_features(Parameters) -> case number_denied_features(Parameters) of [] -> @@ -276,7 +276,7 @@ list_denied_features(Parameters) -> end ++ maybe_deny_admin_only_features(Parameters). --spec reseller_denied_features(feature_parameters()) -> ne_binaries(). +-spec reseller_denied_features(feature_parameters()) -> kz_term:ne_binaries(). reseller_denied_features(#feature_parameters{assigned_to = 'undefined'}) -> ?LOG_DEBUG("denying external features for unassigned number"), ?EXTERNAL_NUMBER_FEATURES; @@ -288,7 +288,7 @@ reseller_denied_features(#feature_parameters{assigned_to = AccountId}=Parameters Providers end. --spec local_denied_features(feature_parameters()) -> ne_binaries(). +-spec local_denied_features(feature_parameters()) -> kz_term:ne_binaries(). local_denied_features(#feature_parameters{is_local = 'false'}) -> []; local_denied_features(#feature_parameters{is_local = 'true'}) -> case ?LOCAL_FEATURE_OVERRIDE of @@ -301,7 +301,7 @@ local_denied_features(#feature_parameters{is_local = 'true'}) -> Features end. --spec used_by_denied_features(feature_parameters()) -> ne_binaries(). +-spec used_by_denied_features(feature_parameters()) -> kz_term:ne_binaries(). used_by_denied_features(#feature_parameters{used_by = <<"trunkstore">>}) -> []; used_by_denied_features(#feature_parameters{used_by = UsedBy}) -> Features = [?FEATURE_FAILOVER @@ -309,7 +309,7 @@ used_by_denied_features(#feature_parameters{used_by = UsedBy}) -> ?LOG_DEBUG("denying external features for number used by ~s: ~s", [UsedBy, ?PP(Features)]), Features. --spec number_denied_features(feature_parameters()) -> ne_binaries(). +-spec number_denied_features(feature_parameters()) -> kz_term:ne_binaries(). -ifdef(TEST). number_denied_features(#feature_parameters{num = ?TEST_TELNYX_NUM}) -> DeniedFeatures = [?FEATURE_PORT @@ -331,14 +331,14 @@ number_denied_features(#feature_parameters{denied_features = DeniedFeatures}) -> DeniedFeatures. -endif. --spec maybe_deny_admin_only_features(feature_parameters()) -> ne_binaries(). +-spec maybe_deny_admin_only_features(feature_parameters()) -> kz_term:ne_binaries(). maybe_deny_admin_only_features(#feature_parameters{is_admin = true}) -> []; maybe_deny_admin_only_features(#feature_parameters{is_admin = false}) -> Features = ?ADMIN_ONLY_FEATURES, ?LOG_DEBUG("allowing admin-only features: ~s", [?PP(Features)]), Features. --spec legacy_provider_to_feature(ne_binary()) -> ne_binary(). +-spec legacy_provider_to_feature(kz_term:ne_binary()) -> kz_term:ne_binary(). legacy_provider_to_feature(<<"wnm_", Rest/binary>>) -> legacy_provider_to_feature(Rest); legacy_provider_to_feature(<<"knm_", Rest/binary>>) -> legacy_provider_to_feature(Rest); legacy_provider_to_feature(<<"cnam_notifier">>) -> ?FEATURE_CNAM; @@ -355,7 +355,7 @@ legacy_provider_to_feature(Else) -> Else. %% @doc %% @end %%-------------------------------------------------------------------- --spec requested_modules(knm_number:knm_number()) -> ne_binaries(). +-spec requested_modules(knm_number:knm_number()) -> kz_term:ne_binaries(). requested_modules(Number) -> PhoneNumber = knm_number:phone_number(Number), AccountId = knm_phone_number:assigned_to(PhoneNumber), @@ -370,20 +370,20 @@ requested_modules(Number) -> Features = (RequestedFeatures ++ ExistingFeatures) -- [?FEATURE_LOCAL], provider_modules(Features, AccountId). --spec allowed_modules(knm_number:knm_number()) -> ne_binaries(). +-spec allowed_modules(knm_number:knm_number()) -> kz_term:ne_binaries(). allowed_modules(Number) -> PhoneNumber = knm_number:phone_number(Number), AccountId = knm_phone_number:assigned_to(PhoneNumber), provider_modules(available_features(PhoneNumber), AccountId). --spec provider_modules(ne_binaries(), api_ne_binary()) -> ne_binaries(). +-spec provider_modules(kz_term:ne_binaries(), kz_term:api_ne_binary()) -> kz_term:ne_binaries(). provider_modules(Features, MaybeAccountId) -> lists:usort( [provider_module(Feature, MaybeAccountId) || Feature <- Features ]). --spec provider_module(ne_binary(), api_ne_binary()) -> ne_binary(). +-spec provider_module(kz_term:ne_binary(), kz_term:api_ne_binary()) -> kz_term:ne_binary(). provider_module(?FEATURE_CNAM, ?MATCH_ACCOUNT_RAW(AccountId)) -> cnam_provider(AccountId); provider_module(?FEATURE_CNAM_INBOUND, AccountId) -> @@ -438,7 +438,7 @@ do_exec(T0=#{todo := Ns}, Action) -> lists:foldl(F, T0, Ns). -spec exec(knm_number:knm_number(), exec_action()) -> knm_number:knm_number(). --spec exec(knm_number:knm_number(), exec_action(), ne_binaries()) -> +-spec exec(knm_number:knm_number(), exec_action(), kz_term:ne_binaries()) -> knm_number:knm_number(). exec(Number, Action=delete) -> @@ -454,7 +454,7 @@ exec(N, Action=save) -> knm_errors:unauthorized() end. --spec maybe_rename_carrier_and_strip_denied(knm_number:knm_number()) -> {knm_number:knm_number(), ne_binaries(), ne_binaries()}. +-spec maybe_rename_carrier_and_strip_denied(knm_number:knm_number()) -> {knm_number:knm_number(), kz_term:ne_binaries(), kz_term:ne_binaries()}. maybe_rename_carrier_and_strip_denied(N) -> {AllowedRequests, DeniedRequests} = split_requests(N), ?LOG_DEBUG("allowing feature providers: ~s", [?PP(AllowedRequests)]), @@ -475,11 +475,11 @@ remove_denied_features(N) -> knm_number:set_phone_number(N, NewPN). %% @public --spec features_denied(knm_phone_number:knm_phone_number()) -> ne_binaries(). +-spec features_denied(knm_phone_number:knm_phone_number()) -> kz_term:ne_binaries(). features_denied(PN) -> cleanse_features(list_denied_features(feature_parameters(PN))). --spec split_requests(knm_number:knm_number()) -> {ne_binaries(), ne_binaries()}. +-spec split_requests(knm_number:knm_number()) -> {kz_term:ne_binaries(), kz_term:ne_binaries()}. split_requests(Number) -> RequestedModules = requested_modules(Number), ?LOG_DEBUG("requested feature providers: ~s", [?PP(RequestedModules)]), @@ -496,7 +496,7 @@ exec(Number, Action, [Provider|Providers]) -> exec(UpdatedNumber, Action, Providers) end. --spec apply_action(knm_number:knm_number(), exec_action(), ne_binary()) -> +-spec apply_action(knm_number:knm_number(), exec_action(), kz_term:ne_binary()) -> {'true', any()} | 'false'. apply_action(Number, Action, Provider) -> case kz_util:try_load_module(Provider) of diff --git a/core/kazoo_number_manager/src/providers/knm_telnyx_cnam.erl b/core/kazoo_number_manager/src/providers/knm_telnyx_cnam.erl index 2c6b3eeed8b..81414c82561 100644 --- a/core/kazoo_number_manager/src/providers/knm_telnyx_cnam.erl +++ b/core/kazoo_number_manager/src/providers/knm_telnyx_cnam.erl @@ -23,7 +23,7 @@ %% @end %%-------------------------------------------------------------------- -spec save(knm_number:knm_number()) -> knm_number:knm_number(). --spec save(knm_number:knm_number(), ne_binary()) -> knm_number:knm_number(). +-spec save(knm_number:knm_number(), kz_term:ne_binary()) -> knm_number:knm_number(). save(Number) -> State = knm_phone_number:state(knm_number:phone_number(Number)), save(Number, State). diff --git a/core/kazoo_number_manager/src/providers/knm_telnyx_e911.erl b/core/kazoo_number_manager/src/providers/knm_telnyx_e911.erl index 313690b600d..999d9fac5eb 100644 --- a/core/kazoo_number_manager/src/providers/knm_telnyx_e911.erl +++ b/core/kazoo_number_manager/src/providers/knm_telnyx_e911.erl @@ -32,7 +32,7 @@ %% @end %%-------------------------------------------------------------------- -spec save(knm_number:knm_number()) -> knm_number:knm_number(). --spec save(knm_number:knm_number(), ne_binary()) -> knm_number:knm_number(). +-spec save(knm_number:knm_number(), kz_term:ne_binary()) -> knm_number:knm_number(). save(Number) -> State = knm_phone_number:state(knm_number:phone_number(Number)), save(Number, State). @@ -126,7 +126,7 @@ maybe_update_e911(Number, 'false') -> %% @private -spec update_e911(knm_number:knm_number(), kz_json:object()) -> {'ok', knm_number:knm_number()} | - {'error', ne_binary()}. + {'error', kz_term:ne_binary()}. update_e911(Number, AddressJObj) -> remove_number_address(Number), case create_address(Number, AddressJObj) of @@ -135,8 +135,8 @@ update_e911(Number, AddressJObj) -> end. -spec create_address(knm_number:knm_number(), kz_json:object()) -> - {'ok', ne_binary()} | - {'error', ne_binary() | any()}. + {'ok', kz_term:ne_binary()} | + {'error', kz_term:ne_binary() | any()}. create_address(Number, AddressJObj) -> Body = e911_address(Number, AddressJObj), try knm_telnyx_util:req('post', ["e911_addresses"], Body) of @@ -157,9 +157,9 @@ create_address(Number, AddressJObj) -> {'error', Reason} end. --spec assign_address(knm_number:knm_number(), ne_binary() | 'null') -> +-spec assign_address(knm_number:knm_number(), kz_term:ne_binary() | 'null') -> {'ok', knm_number:knm_number()} | - {'error', ne_binary()}. + {'error', kz_term:ne_binary()}. assign_address(Number, AddressId) -> IsEnabling = is_binary(AddressId), Body = kz_json:from_list([{<<"e911_enabled">>, IsEnabling} @@ -186,7 +186,7 @@ assign_address(Number, AddressId) -> toogle('true') -> "enable"; toogle('false') -> "disable". --spec set_address_id(knm_number:knm_number(), ne_binary() | 'null') -> knm_number:knm_number(). +-spec set_address_id(knm_number:knm_number(), kz_term:ne_binary() | 'null') -> knm_number:knm_number(). set_address_id(Number, AddressId) -> PN = knm_number:phone_number(Number), Data = kz_json:from_list([{?ADDRESS_ID, AddressId}]), @@ -194,7 +194,7 @@ set_address_id(Number, AddressId) -> knm_number:set_phone_number(Number, NewPN). -spec remove_number(knm_number:knm_number()) -> {'ok', knm_number:knm_number()} | - {'error', ne_binary()}. + {'error', kz_term:ne_binary()}. remove_number(Number) -> CarrierData = knm_phone_number:carrier_data(knm_number:phone_number(Number)), case kz_json:get_ne_binary_value(?ADDRESS_ID, CarrierData) of @@ -215,7 +215,7 @@ remove_number_address(Number) -> 'ok' end. --spec reason(kz_json:object()) -> ne_binary(). +-spec reason(kz_json:object()) -> kz_term:ne_binary(). reason(RepJObj) -> Message = <<"message">>, Reasons = <<"reasons">>, @@ -241,7 +241,7 @@ e911_address(Number, JObj) -> ,{<<"line_2">>, cleanse(kz_json:get_ne_binary_value(?E911_STREET2, JObj))} ])). --spec cleanse(api_ne_binary()) -> api_binary(). +-spec cleanse(kz_term:api_ne_binary()) -> kz_term:api_binary(). cleanse('undefined') -> 'undefined'; cleanse(NEBin) -> Upper = kz_term:to_upper_binary(NEBin), diff --git a/core/kazoo_number_manager/src/providers/knm_vitelity_cnam.erl b/core/kazoo_number_manager/src/providers/knm_vitelity_cnam.erl index a464db9173d..8cee429316b 100644 --- a/core/kazoo_number_manager/src/providers/knm_vitelity_cnam.erl +++ b/core/kazoo_number_manager/src/providers/knm_vitelity_cnam.erl @@ -23,7 +23,7 @@ %% @end %%-------------------------------------------------------------------- -spec save(knm_number:knm_number()) -> knm_number:knm_number(). --spec save(knm_number:knm_number(), ne_binary()) -> knm_number:knm_number(). +-spec save(knm_number:knm_number(), kz_term:ne_binary()) -> knm_number:knm_number(). save(Number) -> State = knm_phone_number:state(knm_number:phone_number(Number)), save(Number, State). @@ -92,7 +92,7 @@ handle_outbound_cnam(Number) -> %% %% @end %%-------------------------------------------------------------------- --spec try_update_outbound_cnam(knm_number:knm_number(), ne_binary()) -> +-spec try_update_outbound_cnam(knm_number:knm_number(), kz_term:ne_binary()) -> knm_number:knm_number(). try_update_outbound_cnam(Number, NewCNAM) -> DID = knm_phone_number:number(knm_number:phone_number(Number)), @@ -113,7 +113,7 @@ try_update_outbound_cnam(Number, NewCNAM) -> %% %% @end %%-------------------------------------------------------------------- --spec outbound_cnam_options(ne_binary(), ne_binary()) -> +-spec outbound_cnam_options(kz_term:ne_binary(), kz_term:ne_binary()) -> knm_vitelity_util:query_options(). outbound_cnam_options(DID, NewCNAM) -> [{'qs', [{'cmd', <<"lidb">>} @@ -131,7 +131,7 @@ outbound_cnam_options(DID, NewCNAM) -> %% %% @end %%-------------------------------------------------------------------- --spec process_outbound_xml_resp(knm_number:knm_number(), ne_binary(), text()) -> +-spec process_outbound_xml_resp(knm_number:knm_number(), kz_term:ne_binary(), kz_term:text()) -> knm_number:knm_number(). process_outbound_xml_resp(Number, FeatureData, XML_binary) -> XML = unicode:characters_to_list(XML_binary), @@ -153,7 +153,7 @@ process_outbound_xml_resp(Number, FeatureData, XML_binary) -> %% %% @end %%-------------------------------------------------------------------- --spec process_outbound_resp(knm_number:knm_number(), ne_binary(), xml_els()) -> +-spec process_outbound_resp(knm_number:knm_number(), kz_term:ne_binary(), kz_types:xml_els()) -> knm_number:knm_number(). process_outbound_resp(Number, FeatureData, Children) -> case knm_vitelity_util:xml_resp_status_msg(Children) of @@ -169,7 +169,7 @@ process_outbound_resp(Number, FeatureData, Children) -> %% %% @end %%-------------------------------------------------------------------- --spec check_outbound_response_tag(knm_number:knm_number(), ne_binary(), xml_els()) -> +-spec check_outbound_response_tag(knm_number:knm_number(), kz_term:ne_binary(), kz_types:xml_els()) -> knm_number:knm_number(). check_outbound_response_tag(Number, NewCNAM, Children) -> case knm_vitelity_util:xml_resp_response_msg(Children) of @@ -238,7 +238,7 @@ remove_inbound_cnam(Number) -> %% %% @end %%-------------------------------------------------------------------- --spec remove_inbound_options(ne_binary()) -> knm_vitelity_util:query_options(). +-spec remove_inbound_options(kz_term:ne_binary()) -> knm_vitelity_util:query_options(). remove_inbound_options(Number) -> [{'qs', [{'did', knm_converters:to_npan(Number)} ,{'cmd', <<"cnamdisable">>} @@ -276,7 +276,7 @@ add_inbound_cnam(Number) -> %% %% @end %%-------------------------------------------------------------------- --spec inbound_options(ne_binary()) -> knm_vitelity_util:query_options(). +-spec inbound_options(kz_term:ne_binary()) -> knm_vitelity_util:query_options(). inbound_options(DID) -> [{'qs', [{'did', knm_converters:to_npan(DID)} ,{'cmd', <<"cnamenable">>} @@ -292,7 +292,7 @@ inbound_options(DID) -> %% %% @end %%-------------------------------------------------------------------- --spec process_xml_resp(knm_number:knm_number(), text()) -> +-spec process_xml_resp(knm_number:knm_number(), kz_term:text()) -> knm_number:knm_number(). process_xml_resp(Number, XML) -> try xmerl_scan:string(XML) of @@ -309,7 +309,7 @@ process_xml_resp(Number, XML) -> %% %% @end %%-------------------------------------------------------------------- --spec process_xml_content_tag(knm_number:knm_number(), xml_el()) -> +-spec process_xml_content_tag(knm_number:knm_number(), kz_types:xml_el()) -> knm_number:knm_number(). process_xml_content_tag(Number, #xmlElement{name='content' ,content=Children diff --git a/core/kazoo_number_manager/src/providers/knm_vitelity_e911.erl b/core/kazoo_number_manager/src/providers/knm_vitelity_e911.erl index c23fbbf4dd5..e02777f95ec 100644 --- a/core/kazoo_number_manager/src/providers/knm_vitelity_e911.erl +++ b/core/kazoo_number_manager/src/providers/knm_vitelity_e911.erl @@ -29,7 +29,7 @@ %% @end %%-------------------------------------------------------------------- -spec save(knm_number:knm_number()) -> knm_number:knm_number(). --spec save(knm_number:knm_number(), ne_binary()) -> knm_number:knm_number(). +-spec save(knm_number:knm_number(), kz_term:ne_binary()) -> knm_number:knm_number(). save(Number) -> State = knm_phone_number:state(knm_number:phone_number(Number)), save(Number, State). @@ -67,7 +67,7 @@ delete(Number) -> %% @end %%-------------------------------------------------------------------- -spec is_valid_location(kz_json:object()) -> {'ok', kz_json:object()} | - {'error', ne_binary()}. + {'error', kz_term:ne_binary()}. is_valid_location(Location) -> URL = knm_vitelity_util:build_uri(location_options(Location)), case knm_vitelity_util:query_vitelity(URL) of @@ -81,7 +81,7 @@ is_valid_location(Location) -> %% %% @end %%-------------------------------------------------------------------- --spec get_location(ne_binary() | knm_number:knm_number()) -> +-spec get_location(kz_term:ne_binary() | knm_number:knm_number()) -> {'ok', kz_json:object()} | {'error', any()}. get_location(?NE_BINARY=DID) -> @@ -159,8 +159,8 @@ maybe_update_e911(Number, 'false') -> %% @end %%-------------------------------------------------------------------- -spec remove_number(knm_number:knm_number()) -> - {'ok', kz_json:object() | ne_binary()} | - {'error', ne_binary()}. + {'ok', kz_json:object() | kz_term:ne_binary()} | + {'error', kz_term:ne_binary()}. remove_number(Number) -> DID = knm_phone_number:number(knm_number:phone_number(Number)), URI = knm_vitelity_util:build_uri(remove_e911_options(DID)), @@ -175,7 +175,7 @@ remove_number(Number) -> %% %% @end %%-------------------------------------------------------------------- --spec remove_e911_options(ne_binary()) -> knm_vitelity_util:query_options(). +-spec remove_e911_options(kz_term:ne_binary()) -> knm_vitelity_util:query_options(). remove_e911_options(DID) -> [{'qs', [{'did', knm_converters:to_npan(DID)} ,{'xml', <<"yes">>} @@ -191,7 +191,7 @@ remove_e911_options(DID) -> %% %% @end %%-------------------------------------------------------------------- --spec get_location_options(ne_binary()) -> knm_vitelity_util:query_options(). +-spec get_location_options(kz_term:ne_binary()) -> knm_vitelity_util:query_options(). get_location_options(DID) -> [{'qs', [{'did', knm_converters:to_npan(DID)} ,{'xml', <<"yes">>} @@ -208,8 +208,8 @@ get_location_options(DID) -> %% @end %%-------------------------------------------------------------------- -spec update_e911(knm_number:knm_number(), kz_json:object()) -> - {'ok', kz_json:object() | ne_binary()} | - {'error', ne_binary()}. + {'ok', kz_json:object() | kz_term:ne_binary()} | + {'error', kz_term:ne_binary()}. update_e911(Number, Address) -> URI = knm_vitelity_util:build_uri(e911_options(Number, Address)), case knm_vitelity_util:query_vitelity(URI) of @@ -252,7 +252,7 @@ e911_options(Number, AddressJObj) -> %% %% @end %%-------------------------------------------------------------------- --spec get_unit(ne_binary()) -> {api_binary(), api_binary()}. +-spec get_unit(kz_term:ne_binary()) -> {kz_term:api_binary(), kz_term:api_binary()}. get_unit(ExtendedAddress) -> case binary:split(ExtendedAddress, <<" ">>) of [UnitType, UnitNumber|_] -> {UnitType, UnitNumber}; @@ -260,7 +260,7 @@ get_unit(ExtendedAddress) -> _ -> {'undefined', 'undefined'} end. --spec get_caller_name(knm_number:knm_number(), kz_json:object()) -> ne_binary(). +-spec get_caller_name(knm_number:knm_number(), kz_json:object()) -> kz_term:ne_binary(). get_caller_name(Number, AddressJObj) -> case kz_json:get_ne_binary_value(?CUSTOMER_NAME, AddressJObj) of ?NE_BINARY=Name -> Name; @@ -301,8 +301,8 @@ location_options(AddressJObj) -> %% %% @end %%-------------------------------------------------------------------- --spec process_xml_resp(text()) -> {'ok', kz_json:object() | ne_binary()} | - {'error', ne_binary()}. +-spec process_xml_resp(kz_term:text()) -> {'ok', kz_json:object() | kz_term:ne_binary()} | + {'error', kz_term:ne_binary()}. process_xml_resp(RespXML_binary) -> RespXML = unicode:characters_to_list( RespXML_binary), try xmerl_scan:string(RespXML) of @@ -319,8 +319,8 @@ process_xml_resp(RespXML_binary) -> %% %% @end %%-------------------------------------------------------------------- --spec process_xml_content_tag(xml_el()) -> {'ok', kz_json:object() | ne_binary()} | - {'error', ne_binary()}. +-spec process_xml_content_tag(kz_types:xml_el()) -> {'ok', kz_json:object() | kz_term:ne_binary()} | + {'error', kz_term:ne_binary()}. process_xml_content_tag(#xmlElement{name='content' ,content=Children }) -> @@ -336,7 +336,7 @@ process_xml_content_tag(#xmlElement{name='content' %% %% @end %%-------------------------------------------------------------------- --spec xml_resp(xml_els()) -> kz_json:object() | ne_binary(). +-spec xml_resp(kz_types:xml_els()) -> kz_json:object() | kz_term:ne_binary(). xml_resp([#xmlElement{name='info' ,content=Content } diff --git a/core/kazoo_oauth/include/kazoo_oauth_types.hrl b/core/kazoo_oauth/include/kazoo_oauth_types.hrl index 91d1bb35df5..37884dc4b41 100644 --- a/core/kazoo_oauth/include/kazoo_oauth_types.hrl +++ b/core/kazoo_oauth/include/kazoo_oauth_types.hrl @@ -4,54 +4,54 @@ -include_lib("kazoo_stdlib/include/kz_types.hrl"). -include_lib("public_key/include/public_key.hrl"). --record(oauth_token, {token :: ne_binary() - ,type :: ne_binary() +-record(oauth_token, {token :: kz_term:ne_binary() + ,type :: kz_term:ne_binary() ,expires :: non_neg_integer() - ,issued :: gregorian_seconds() + ,issued :: kz_time:gregorian_seconds() }). -type oauth_token() :: #oauth_token{}. --record(oauth_refresh_token, {token :: api_binary()}). +-record(oauth_refresh_token, {token :: kz_term:api_binary()}). -type oauth_refresh_token() :: #oauth_refresh_token{}. --record(oauth_provider, {name :: api_binary() - ,auth_url :: api_binary() - ,tokeninfo_url :: api_binary() - ,profile_url :: api_binary() - ,servers :: api_object() - ,scopes :: api_object() +-record(oauth_provider, {name :: kz_term:api_binary() + ,auth_url :: kz_term:api_binary() + ,tokeninfo_url :: kz_term:api_binary() + ,profile_url :: kz_term:api_binary() + ,servers :: kz_term:api_object() + ,scopes :: kz_term:api_object() }). -type oauth_provider() :: #oauth_provider{}. --record(oauth_app, {name :: api_binary() - ,account_id :: api_binary() - ,secret :: api_binary() - ,user_prefix :: api_binary() +-record(oauth_app, {name :: kz_term:api_binary() + ,account_id :: kz_term:api_binary() + ,secret :: kz_term:api_binary() + ,user_prefix :: kz_term:api_binary() ,provider :: oauth_provider() }). -type oauth_app() :: #oauth_app{}. --record(oauth_service_app, {name :: ne_binary() - ,account_id :: ne_binary() - ,email :: ne_binary() - ,public_key_fingerprints :: ne_binary() +-record(oauth_service_app, {name :: kz_term:ne_binary() + ,account_id :: kz_term:ne_binary() + ,email :: kz_term:ne_binary() + ,public_key_fingerprints :: kz_term:ne_binary() ,public_key :: any() ,private_key :: public_key:rsa_private_key() | public_key:dsa_private_key() ,provider :: oauth_provider() }). -type oauth_service_app() :: #oauth_service_app{}. --record(oauth_user, {full_id :: api_binary() - ,app_id :: api_binary() - ,oauth_id :: api_binary() - ,account_id :: api_binary() - ,owner_id :: api_binary() - ,email :: api_binary() - ,verified_email :: api_boolean() - ,access_type :: api_binary() - ,scope :: api_binary() - ,scopes :: api_binaries() - ,refresh_token :: api_binary() +-record(oauth_user, {full_id :: kz_term:api_binary() + ,app_id :: kz_term:api_binary() + ,oauth_id :: kz_term:api_binary() + ,account_id :: kz_term:api_binary() + ,owner_id :: kz_term:api_binary() + ,email :: kz_term:api_binary() + ,verified_email :: kz_term:api_boolean() + ,access_type :: kz_term:api_binary() + ,scope :: kz_term:api_binary() + ,scopes :: kz_term:api_binaries() + ,refresh_token :: kz_term:api_binary() ,app :: oauth_app() }). -type oauth_user() :: #oauth_user{}. diff --git a/core/kazoo_oauth/src/kazoo_oauth_client.erl b/core/kazoo_oauth/src/kazoo_oauth_client.erl index 9b619e8ef7a..1a6ec898ee0 100644 --- a/core/kazoo_oauth/src/kazoo_oauth_client.erl +++ b/core/kazoo_oauth/src/kazoo_oauth_client.erl @@ -11,10 +11,10 @@ %% ==================================================================== -spec authenticate(kz_json:object()) -> {'ok', kz_json:object()} | - {'error', ne_binary()}. --spec authenticate(ne_binary(), ne_binary(), kz_json:object()) -> + {'error', kz_term:ne_binary()}. +-spec authenticate(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> {'ok', kz_json:object()} | - {'error', ne_binary()}. + {'error', kz_term:ne_binary()}. authenticate(JObj) -> case {kz_json:get_value(<<"access_token">>, JObj) ,kz_json:get_value(<<"provider">>, JObj) @@ -65,8 +65,8 @@ maybe_save_oauth_doc(DocId, JObj, TokenObj, App) -> save_oauth_doc(App, DocId, JObj, TokenObj, RefreshTokenObj). --spec get_refresh_token(ne_binary(), ne_binary() | oauth_app() - ,ne_binary(), ne_binary()) -> kz_json:object(). +-spec get_refresh_token(kz_term:ne_binary(), kz_term:ne_binary() | oauth_app() + ,kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). get_refresh_token(<<"offline">>, App, Scope, AuthorizationCode) -> case kazoo_oauth_util:refresh_token(App, Scope, AuthorizationCode, []) of {'ok', Token} -> Token; diff --git a/core/kazoo_oauth/src/kazoo_oauth_maintenance.erl b/core/kazoo_oauth/src/kazoo_oauth_maintenance.erl index f8aa25e3b19..bb9c340ced9 100644 --- a/core/kazoo_oauth/src/kazoo_oauth_maintenance.erl +++ b/core/kazoo_oauth/src/kazoo_oauth_maintenance.erl @@ -14,7 +14,7 @@ %% Internal functions %% ==================================================================== --spec register_oauth_app(ne_binary(), ne_binary(), ne_binary(), ne_binary(), ne_binary()) -> any(). +-spec register_oauth_app(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> any(). register_oauth_app(AccountId, OAuthId, EMail, Secret, Provider) -> Doc = kz_json:from_list([ {<<"_id">>, OAuthId} diff --git a/core/kazoo_oauth/src/kazoo_oauth_service.erl b/core/kazoo_oauth/src/kazoo_oauth_service.erl index 8eb91e63d85..fa7863b1345 100644 --- a/core/kazoo_oauth/src/kazoo_oauth_service.erl +++ b/core/kazoo_oauth/src/kazoo_oauth_service.erl @@ -9,7 +9,7 @@ -export([service_token/2]). --spec service_token(api_binary() | oauth_service_app(), api_binary()) -> api_object(). +-spec service_token(kz_term:api_binary() | oauth_service_app(), kz_term:api_binary()) -> kz_term:api_object(). service_token('undefined', _) -> 'undefined'; service_token(_, 'undefined') -> diff --git a/core/kazoo_oauth/src/kazoo_oauth_util.erl b/core/kazoo_oauth/src/kazoo_oauth_util.erl index c6adb9937c7..3f26457f894 100644 --- a/core/kazoo_oauth/src/kazoo_oauth_util.erl +++ b/core/kazoo_oauth/src/kazoo_oauth_util.erl @@ -17,12 +17,12 @@ -export([jwt/2, jwt/3]). -export([authorization_header/1]). --spec authorization_header(oauth_token()) -> api_binary(). +-spec authorization_header(oauth_token()) -> kz_term:api_binary(). authorization_header(#oauth_token{type=Type,token=Token}) -> <>. --spec get_oauth_provider(ne_binary()) -> {'ok', oauth_provider()} | - {'error', ne_binary()}. +-spec get_oauth_provider(kz_term:ne_binary()) -> {'ok', oauth_provider()} | + {'error', kz_term:ne_binary()}. get_oauth_provider(ProviderId) -> case kz_datamgr:open_doc(?KZ_OAUTH_DB, ProviderId) of {'ok', JObj} -> {'ok', oauth_provider_from_jobj(ProviderId, JObj)}; @@ -38,8 +38,8 @@ oauth_provider_from_jobj(ProviderId, JObj) -> ,scopes= kz_json:get_value(<<"scopes">>, JObj) }. --spec get_oauth_app(ne_binary()) -> {'ok', oauth_provider()} | - {'error', ne_binary()}. +-spec get_oauth_app(kz_term:ne_binary()) -> {'ok', oauth_provider()} | + {'error', kz_term:ne_binary()}. get_oauth_app(AppId) -> case kz_datamgr:open_doc(?KZ_OAUTH_DB, AppId) of {'ok', JObj} -> @@ -58,7 +58,7 @@ oauth_app_from_jobj(AppId, Provider, JObj) -> ,user_prefix = kz_json:get_value(<<"pvt_user_prefix">>, JObj) ,provider = Provider}. --spec get_oauth_service_app(ne_binary()) -> +-spec get_oauth_service_app(kz_term:ne_binary()) -> {'ok', oauth_service_app()} | {'error', any()}. get_oauth_service_app(AppId) -> @@ -112,8 +112,8 @@ pem_to_rsa(PemFileContents) -> [RSAEntry] = public_key:pem_decode(PemFileContents), public_key:pem_entry_decode(RSAEntry). --spec jwt(oauth_service_app(), kz_json:json_term()) -> ne_binary(). --spec jwt(oauth_service_app(), kz_json:json_term(), ne_binary()) -> ne_binary(). +-spec jwt(oauth_service_app(), kz_json:json_term()) -> kz_term:ne_binary(). +-spec jwt(oauth_service_app(), kz_json:json_term(), kz_term:ne_binary()) -> kz_term:ne_binary(). jwt(#oauth_service_app{email=AccountEmail}=App, Scope) -> jwt(App, Scope, AccountEmail). @@ -140,7 +140,7 @@ jwt(#oauth_service_app{private_key=PrivateKey _Verify = public_key:verify(JWT_FOR_SIGN, 'sha256', JWT_SIGNATURE, PublicKey), Assertion. --spec token(ne_binary()) -> {'ok', oauth_token()} | {'error', any()}. +-spec token(kz_term:ne_binary()) -> {'ok', oauth_token()} | {'error', any()}. token(DocId) when is_binary(DocId) -> case kz_datamgr:open_cache_doc(?KZ_OAUTH_DB, DocId) of {'ok', JObj} -> @@ -152,7 +152,7 @@ token(DocId) when is_binary(DocId) -> Error end. --spec token(api_binary() | oauth_app(), api_binary() | oauth_refresh_token()) -> +-spec token(kz_term:api_binary() | oauth_app(), kz_term:api_binary() | oauth_refresh_token()) -> {'ok', oauth_token()} | {'error', any()}. token(AppId, UserId) when is_binary(AppId) -> @@ -200,9 +200,9 @@ token(#oauth_app{name=AppId {'error', Else} end. --spec verify_token(api_binary() | oauth_provider(), api_binary()) -> - {'ok', api_object()} | - {'error', api_binary()}. +-spec verify_token(kz_term:api_binary() | oauth_provider(), kz_term:api_binary()) -> + {'ok', kz_term:api_object()} | + {'error', kz_term:api_binary()}. verify_token(ProviderId, AccessToken) when is_binary(ProviderId) -> case get_oauth_provider(ProviderId) of {'ok', Provider} -> verify_token(Provider, AccessToken); @@ -222,12 +222,12 @@ verify_token(#oauth_provider{tokeninfo_url=TokenInfoUrl}, AccessToken) -> {'error', Else} end. --spec refresh_token(ne_binary()) -> oauth_refresh_token(). +-spec refresh_token(kz_term:ne_binary()) -> oauth_refresh_token(). refresh_token(Token) -> #oauth_refresh_token{token=Token}. --spec refresh_token(api_binary() | oauth_app(), api_binary(), api_binary(), kz_proplist() ) -> - {'ok', api_object()} | +-spec refresh_token(kz_term:api_binary() | oauth_app(), kz_term:api_binary(), kz_term:api_binary(), kz_term:proplist() ) -> + {'ok', kz_term:api_object()} | {'error', any()}. refresh_token(AppId, Scope, AuthorizationCode, ExtraHeaders) when is_binary(AppId) -> @@ -239,8 +239,8 @@ refresh_token(AppId, Scope, AuthorizationCode, ExtraHeaders) refresh_token(App, Scope, AuthorizationCode, ExtraHeaders) -> refresh_token(App, Scope, AuthorizationCode, ExtraHeaders, <<"postmessage">>). --spec refresh_token(oauth_app(), api_binary(), api_binary(), kz_proplist(), api_binary()) -> - {'ok', api_object()} | +-spec refresh_token(oauth_app(), kz_term:api_binary(), kz_term:api_binary(), kz_term:proplist(), kz_term:api_binary()) -> + {'ok', kz_term:api_object()} | {'error', any()}. refresh_token(#oauth_app{name=ClientId ,secret=Secret diff --git a/core/kazoo_perf/src/kazoo_perf_maintenance.erl b/core/kazoo_perf/src/kazoo_perf_maintenance.erl index 5d796c95dcc..01cacd15299 100644 --- a/core/kazoo_perf/src/kazoo_perf_maintenance.erl +++ b/core/kazoo_perf/src/kazoo_perf_maintenance.erl @@ -13,7 +13,7 @@ %% API --spec graphite_metrics(ne_binary(), ne_binary(), ne_binary()) -> no_return. +-spec graphite_metrics(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> no_return. graphite_metrics(Account, Cluster, Zone) -> Scheme = scheme(Account, Cluster, Zone), F = fun ({Metric, Measured}) -> graphite(Scheme, Metric, Measured) end, diff --git a/core/kazoo_proper/src/kazoo_proper_maintenance.erl b/core/kazoo_proper/src/kazoo_proper_maintenance.erl index 96c832522b9..3d17efa2b8c 100644 --- a/core/kazoo_proper/src/kazoo_proper_maintenance.erl +++ b/core/kazoo_proper/src/kazoo_proper_maintenance.erl @@ -13,7 +13,7 @@ run_modules() -> _ = [run_module(M) || M <- modules()], 'no_return'. --spec run_module(atom() | ne_binary()) -> 'no_return'. +-spec run_module(atom() | kz_term:ne_binary()) -> 'no_return'. run_module(Module) when is_atom(Module) -> Exports = Module:module_info('exports'), _ = quickcheck_exports(Module, Exports), @@ -41,7 +41,7 @@ run_seq_modules() -> _ = [run_seq_module(M) || M <- modules()], 'no_return'. --spec run_seq_module(atom() | ne_binary()) -> 'no_return'. +-spec run_seq_module(atom() | kz_term:ne_binary()) -> 'no_return'. run_seq_module(Module) when is_atom(Module) -> Exports = Module:module_info('exports'), _ = seq_exports(Module, Exports), diff --git a/core/kazoo_proper/src/pqc_cb_accounts.erl b/core/kazoo_proper/src/pqc_cb_accounts.erl index bf8468c735c..c047bb0e489 100644 --- a/core/kazoo_proper/src/pqc_cb_accounts.erl +++ b/core/kazoo_proper/src/pqc_cb_accounts.erl @@ -18,19 +18,19 @@ -include("kazoo_proper.hrl"). -type account_id() :: {'call', 'pqc_kazoo_model', 'account_id_by_name', [pqc_cb_api:state() | proper_types:type()]} | - ne_binary(). + kz_term:ne_binary(). --spec command(pqc_kazoo_model:model(), ne_binary() | proper_types:type()) -> +-spec command(pqc_kazoo_model:model(), kz_term:ne_binary() | proper_types:type()) -> {'call', ?MODULE, 'create_account', [pqc_cb_api:state() | proper_types:term()]}. command(Model, Name) -> {'call', ?MODULE, 'create_account', [pqc_kazoo_model:api(Model), Name]}. --spec symbolic_account_id(pqc_kazoo_model:model(), ne_binary() | proper_types:type()) -> +-spec symbolic_account_id(pqc_kazoo_model:model(), kz_term:ne_binary() | proper_types:type()) -> account_id(). symbolic_account_id(Model, Name) -> {'call', 'pqc_kazoo_model', 'account_id_by_name', [Model, Name]}. --spec create_account(pqc_cb_api:state(), ne_binary()) -> binary(). +-spec create_account(pqc_cb_api:state(), kz_term:ne_binary()) -> binary(). create_account(API, NewAccountName) -> RequestData = kz_json:from_list([{<<"name">>, NewAccountName}]), RequestEnvelope = pqc_cb_api:create_envelope(RequestData), @@ -45,19 +45,19 @@ create_account(API, NewAccountName) -> andalso allow_number_additions(NewAccountId), Resp. --spec allow_number_additions(ne_binary()) -> {'ok', kz_account:doc()}. +-spec allow_number_additions(kz_term:ne_binary()) -> {'ok', kz_account:doc()}. allow_number_additions(AccountId) -> {'ok', _Account} = kz_util:set_allow_number_additions(AccountId, 'true'). --spec delete_account(pqc_cb_api:state(), ne_binary()) -> binary(). +-spec delete_account(pqc_cb_api:state(), kz_term:ne_binary()) -> binary(). delete_account(API, AccountId) -> URL = account_url(AccountId), RequestHeaders = pqc_cb_api:request_headers(API), pqc_cb_api:make_request([200], fun kz_http:delete/2, URL, RequestHeaders). --spec cleanup_accounts(ne_binaries()) -> 'ok'. --spec cleanup_accounts(pqc_cb_api:state(), ne_binaries()) -> 'ok'. +-spec cleanup_accounts(kz_term:ne_binaries()) -> 'ok'. +-spec cleanup_accounts(pqc_cb_api:state(), kz_term:ne_binaries()) -> 'ok'. cleanup_accounts(AccountNames) -> cleanup_accounts(pqc_cb_api:authenticate(), AccountNames). @@ -65,7 +65,7 @@ cleanup_accounts(API, AccountNames) -> _ = [cleanup_account(API, AccountName) || AccountName <- AccountNames], kt_cleanup:cleanup_soft_deletes(?KZ_ACCOUNTS_DB). --spec cleanup_account(pqc_cb_api:state(), ne_binary()) -> 'ok'. +-spec cleanup_account(pqc_cb_api:state(), kz_term:ne_binary()) -> 'ok'. cleanup_account(API, AccountName) -> _ = try pqc_cb_search:search_account_by_name(API, AccountName) of ?FAILED_RESPONSE -> diff --git a/core/kazoo_proper/src/pqc_cb_api.erl b/core/kazoo_proper/src/pqc_cb_api.erl index 5ebf2bd9b7c..1fafd273cb5 100644 --- a/core/kazoo_proper/src/pqc_cb_api.erl +++ b/core/kazoo_proper/src/pqc_cb_api.erl @@ -23,11 +23,11 @@ ] ). --type state() :: #{'auth_token' => ne_binary() - ,'account_id' => ne_binary() - ,'request_id' => ne_binary() +-type state() :: #{'auth_token' => kz_term:ne_binary() + ,'account_id' => kz_term:ne_binary() + ,'request_id' => kz_term:ne_binary() ,'trace_file' => kz_data_tracing:trace_ref() - ,'start' => kz_now() + ,'start' => kz_time:now() }. -export_type([state/0 @@ -61,8 +61,8 @@ authenticate() -> ), create_api_state(Resp, RequestId, Trace). --spec api_key() -> ne_binary(). --spec api_key(ne_binary()) -> ne_binary(). +-spec api_key() -> kz_term:ne_binary(). +-spec api_key(kz_term:ne_binary()) -> kz_term:ne_binary(). api_key() -> case kapps_util:get_master_account_id() of {'ok', MasterAccountId} -> @@ -100,11 +100,11 @@ create_api_state(<<_/binary>> = RespJSON, RequestId, Trace) -> -spec v2_base_url() -> string(). v2_base_url() -> ?API_BASE. --spec auth_account_id(state()) -> ne_binary(). +-spec auth_account_id(state()) -> kz_term:ne_binary(). auth_account_id(#{'account_id' := AccountId}) -> AccountId. --spec request_headers(state()) -> kz_proplist(). --spec request_headers(state(), kz_proplist()) -> kz_proplist(). +-spec request_headers(state()) -> kz_term:proplist(). +-spec request_headers(state(), kz_term:proplist()) -> kz_term:proplist(). request_headers(API) -> request_headers(API, []). @@ -120,8 +120,8 @@ request_headers(#{'auth_token' := AuthToken ] ). --spec default_request_headers() -> kz_proplist(). --spec default_request_headers(ne_binary()) -> kz_proplist(). +-spec default_request_headers() -> kz_term:proplist(). +-spec default_request_headers(kz_term:ne_binary()) -> kz_term:proplist(). default_request_headers() -> [{<<"content-type">>, <<"application/json">>} ,{<<"accept">>, <<"application/json">>} @@ -139,12 +139,12 @@ default_request_headers(RequestId) -> -type response() :: binary() | {'error', binary()}. --type fun_2() :: fun((string(), kz_proplist()) -> kz_http:ret()). --type fun_3() :: fun((string(), kz_proplist(), iodata()) -> kz_http:ret()). +-type fun_2() :: fun((string(), kz_term:proplist()) -> kz_http:ret()). +-type fun_3() :: fun((string(), kz_term:proplist(), iodata()) -> kz_http:ret()). --spec make_request(expected_codes(), fun_2(), string(), kz_proplist()) -> +-spec make_request(expected_codes(), fun_2(), string(), kz_term:proplist()) -> response(). --spec make_request(expected_codes(), fun_3(), string(), kz_proplist(), iodata()) -> +-spec make_request(expected_codes(), fun_3(), string(), kz_term:proplist(), iodata()) -> response(). make_request(ExpectedCodes, HTTP, URL, RequestHeaders) -> ?INFO("~p: ~s", [HTTP, URL]), @@ -192,7 +192,7 @@ handle_response(_ExpectedCode, {'error', _}=E) -> E. --spec start_trace(ne_binary()) -> {'ok', kz_data_tracing:trace_ref()}. +-spec start_trace(kz_term:ne_binary()) -> {'ok', kz_data_tracing:trace_ref()}. start_trace(RequestId) -> lager:md([{'request_id', RequestId}]), put('now', kz_time:now()), diff --git a/core/kazoo_proper/src/pqc_cb_ips.erl b/core/kazoo_proper/src/pqc_cb_ips.erl index 54492b43646..8906fbf8f55 100644 --- a/core/kazoo_proper/src/pqc_cb_ips.erl +++ b/core/kazoo_proper/src/pqc_cb_ips.erl @@ -35,9 +35,9 @@ -include_lib("proper/include/proper.hrl"). -include("kazoo_proper.hrl"). --record('dedicated', {ip :: api_ne_binary() - ,host :: api_ne_binary() - ,zone :: api_ne_binary() +-record('dedicated', {ip :: kz_term:api_ne_binary() + ,host :: kz_term:api_ne_binary() + ,zone :: kz_term:api_ne_binary() }). -define(DEDICATED(IP, Host, Zone) ,#dedicated{ip=IP, host=Host, zone=Zone} @@ -52,8 +52,8 @@ ips_url() -> ips_url(AccountId) -> string:join([pqc_cb_accounts:account_url(AccountId), "ips"], "/"). --spec ip_url(text()) -> string(). --spec ip_url(pqc_cb_accounts:account_id(), text()) -> string(). +-spec ip_url(kz_term:text()) -> string(). +-spec ip_url(pqc_cb_accounts:account_id(), kz_term:text()) -> string(). ip_url(IP) -> string:join([pqc_cb_api:v2_base_url(), "ips", kz_term:to_list(IP)], "/"). @@ -162,7 +162,7 @@ assign_ip(API, AccountId, ?DEDICATED(IP, _, _)) -> end. -spec fetch_hosts(pqc_cb_api:state()) -> - {'ok', ne_binaries()} | + {'ok', kz_term:ne_binaries()} | {'error', 'not_found'}. fetch_hosts(API) -> case pqc_cb_api:make_request([200] @@ -179,7 +179,7 @@ fetch_hosts(API) -> end. -spec fetch_zones(pqc_cb_api:state()) -> - {'ok', ne_binaries()} | + {'ok', kz_term:ne_binaries()} | {'error', 'not_found'}. fetch_zones(API) -> case pqc_cb_api:make_request([200] @@ -571,7 +571,7 @@ assign_dedicated_ips(Model, AccountId, Dedicateds) -> ,Dedicateds ). --spec are_all_ips_listed([{ne_binary(), pqc_kazoo_model:dedicated_ip()}], kz_json:objects(), boolean()) -> +-spec are_all_ips_listed([{kz_term:ne_binary(), pqc_kazoo_model:dedicated_ip()}], kz_json:objects(), boolean()) -> boolean(). are_all_ips_listed([], [], _CheckHost) -> 'true'; are_all_ips_listed(_ModelIPs, [], _CheckHost) -> 'false'; @@ -583,7 +583,7 @@ are_all_ips_listed(ModelIPs, ListedIPs, CheckHost) -> ,ModelIPs ). --spec is_ip_listed(ne_binary(), pqc_kazoo_model:dedicated_ip(), kz_json:objects()) -> +-spec is_ip_listed(kz_term:ne_binary(), pqc_kazoo_model:dedicated_ip(), kz_json:objects()) -> boolean(). is_ip_listed(IP, IPInfo, ListedIPs) -> is_ip_listed(IP, IPInfo, ListedIPs, 'true'). @@ -602,7 +602,7 @@ is_ip_listed(IP, IPInfo, ListedIPs, CheckHost) -> ,ListedIPs ). --spec all_requested_are_listed(ne_binary(), [dedicated()], kz_json:objects()) -> boolean(). +-spec all_requested_are_listed(kz_term:ne_binary(), [dedicated()], kz_json:objects()) -> boolean(). all_requested_are_listed(AccountId, Dedicateds, ListedIPs) -> [] =:= lists:foldl(fun(ListedIP, Ds) -> IP = kz_json:get_ne_binary_value(<<"ip">>, ListedIP), @@ -620,7 +620,7 @@ all_requested_are_listed(AccountId, Dedicateds, ListedIPs) -> ,ListedIPs ). --spec is_assigned(ne_binary(), dedicated(), kz_json:object()) -> boolean(). +-spec is_assigned(kz_term:ne_binary(), dedicated(), kz_json:object()) -> boolean(). is_assigned(AccountId, ?DEDICATED(DIP, DHost, DZone), ListedIP) -> IP = kz_json:get_ne_binary_value(<<"ip">>, ListedIP), Host = kz_json:get_ne_binary_value(<<"host">>, ListedIP), diff --git a/core/kazoo_proper/src/pqc_cb_phone_numbers.erl b/core/kazoo_proper/src/pqc_cb_phone_numbers.erl index eae84cf826e..415bfcd4aeb 100644 --- a/core/kazoo_proper/src/pqc_cb_phone_numbers.erl +++ b/core/kazoo_proper/src/pqc_cb_phone_numbers.erl @@ -25,12 +25,12 @@ -define(ACCOUNT_NAMES, [<<"accountone">>]). -define(PHONE_NUMBERS, [<<"+12345678901">>]). --spec cleanup_numbers(pqc_cb_api:state(), ne_binaries()) -> 'ok'. +-spec cleanup_numbers(pqc_cb_api:state(), kz_term:ne_binaries()) -> 'ok'. cleanup_numbers(_API, Numbers) -> _ = knm_numbers:delete(Numbers, [{'auth_by', <<"system">>}]), 'ok'. --spec list_number(pqc_cb_api:state(), api_ne_binary(), ne_binary()) -> pqc_cb_api:response(). +-spec list_number(pqc_cb_api:state(), kz_term:api_ne_binary(), kz_term:ne_binary()) -> pqc_cb_api:response(). list_number(_API, 'undefined', _Number) -> ?FAILED_RESPONSE; list_number(API, AccountId, Number) -> URL = number_url(AccountId, Number), @@ -38,7 +38,7 @@ list_number(API, AccountId, Number) -> pqc_cb_api:make_request([200, 404], fun kz_http:get/2, URL, RequestHeaders). --spec add_number(pqc_cb_api:state(), api_ne_binary(), ne_binary()) -> pqc_cb_api:response(). +-spec add_number(pqc_cb_api:state(), kz_term:api_ne_binary(), kz_term:ne_binary()) -> pqc_cb_api:response(). add_number(_API, 'undefined', _Number) -> ?FAILED_RESPONSE; add_number(API, AccountId, Number) -> URL = number_url(AccountId, Number), @@ -53,7 +53,7 @@ add_number(API, AccountId, Number) -> ,kz_json:encode(RequestEnvelope) ). --spec remove_number(pqc_cb_api:state(), api_ne_binary(), ne_binary()) -> pqc_cb_api:response(). +-spec remove_number(pqc_cb_api:state(), kz_term:api_ne_binary(), kz_term:ne_binary()) -> pqc_cb_api:response(). remove_number(_API, 'undefined', _Number) -> ?FAILED_RESPONSE; remove_number(API, AccountId, Number) -> URL = number_url(AccountId, Number), @@ -64,7 +64,7 @@ remove_number(API, AccountId, Number) -> ,RequestHeaders ). --spec activate_number(pqc_cb_api:state(), api_ne_binary(), ne_binary()) -> pqc_cb_api:response(). +-spec activate_number(pqc_cb_api:state(), kz_term:api_ne_binary(), kz_term:ne_binary()) -> pqc_cb_api:response(). activate_number(_API, 'undefined', _Number) -> ?FAILED_RESPONSE; activate_number(API, AccountId, Number) -> URL = number_url(AccountId, Number, "activate"), @@ -77,8 +77,8 @@ activate_number(API, AccountId, Number) -> ,kz_json:encode(RequestEnvelope) ). --spec number_url(ne_binary(), ne_binary()) -> string(). --spec number_url(ne_binary(), ne_binary(), string()) -> string(). +-spec number_url(kz_term:ne_binary(), kz_term:ne_binary()) -> string(). +-spec number_url(kz_term:ne_binary(), kz_term:ne_binary(), string()) -> string(). number_url(AccountId, Number) -> string:join([pqc_cb_accounts:account_url(AccountId) ,"phone_numbers", kz_term:to_list(kz_http_util:urlencode(Number)) diff --git a/core/kazoo_proper/src/pqc_cb_rates.erl b/core/kazoo_proper/src/pqc_cb_rates.erl index d3ceaadcacf..cc172d6a4eb 100644 --- a/core/kazoo_proper/src/pqc_cb_rates.erl +++ b/core/kazoo_proper/src/pqc_cb_rates.erl @@ -38,7 +38,7 @@ -define(GLOBAL_COST, 1). -define(ACCOUNT_COST, 4). --spec rate_doc(ne_binary() | proper_types:type(), number() | proper_types:type()) -> +-spec rate_doc(kz_term:ne_binary() | proper_types:type(), number() | proper_types:type()) -> kzd_rate:doc(). rate_doc(RatedeckId, Cost) -> kzd_rate:from_map(#{<<"prefix">> => <<"1222">> @@ -48,16 +48,16 @@ rate_doc(RatedeckId, Cost) -> } ). --spec upload_rate(pqc_cb_api:state(), kzd_rate:doc()) -> {'ok', api_ne_binary()}. +-spec upload_rate(pqc_cb_api:state(), kzd_rate:doc()) -> {'ok', kz_term:api_ne_binary()}. upload_rate(API, RateDoc) -> ?INFO("uploading rate ~p", [RateDoc]), CSV = kz_csv:from_jobjs([RateDoc]), upload_csv(API, CSV, kzd_rate:ratedeck(RateDoc)). -spec upload_csv(pqc_cb_api:state(), iodata()) -> - {'ok', api_ne_binary()}. --spec upload_csv(pqc_cb_api:state(), iodata(), api_ne_binary()) -> - {'ok', api_ne_binary()}. + {'ok', kz_term:api_ne_binary()}. +-spec upload_csv(pqc_cb_api:state(), iodata(), kz_term:api_ne_binary()) -> + {'ok', kz_term:api_ne_binary()}. upload_csv(API, CSV) -> upload_csv(API, CSV, 'undefined'). @@ -72,7 +72,7 @@ upload_csv(API, CSV, _RatedeckId) -> {'ok', TaskId}. --spec create_service_plan(pqc_cb_api:state(), ne_binary() | proper_types:type()) -> +-spec create_service_plan(pqc_cb_api:state(), kz_term:ne_binary() | proper_types:type()) -> 'ok' | {'error', any()}. create_service_plan(API, RatedeckId) -> RatesResp = get_rates(API, RatedeckId), @@ -89,7 +89,7 @@ create_service_plan(API, RatedeckId) -> end end. --spec assign_service_plan(pqc_cb_api:state(), ne_binary() | proper_types:type(), ne_binary()) -> +-spec assign_service_plan(pqc_cb_api:state(), kz_term:ne_binary() | proper_types:type(), kz_term:ne_binary()) -> pqc_cb_api:response(). assign_service_plan(_API, 'undefined', _RatedeckId) -> ?INFO("no account to assign ~s to", [_RatedeckId]), @@ -99,8 +99,8 @@ assign_service_plan(API, AccountId, RatedeckId) -> ServicePlanId = service_plan_id(RatedeckId), pqc_cb_service_plans:assign_service_plan(API, AccountId, ServicePlanId). --spec rate_account_did(pqc_cb_api:state(), ne_binary() | proper_types:type(), ne_binary()) -> - api_integer(). +-spec rate_account_did(pqc_cb_api:state(), kz_term:ne_binary() | proper_types:type(), kz_term:ne_binary()) -> + kz_term:api_integer(). rate_account_did(_API, 'undefined', _DID) -> ?INFO("account doesn't exist to rate DID ~p", [_DID]), ?FAILED_RESPONSE; @@ -109,7 +109,7 @@ rate_account_did(API, AccountId, DID) -> URL = string:join([pqc_cb_accounts:account_url(AccountId), "rates", "number", kz_term:to_list(DID)], "/"), make_rating_request(API, URL). --spec ratedeck_service_plan(ne_binary() | kzd_rate:doc()) -> kzd_service_plan:doc(). +-spec ratedeck_service_plan(kz_term:ne_binary() | kzd_rate:doc()) -> kzd_service_plan:doc(). ratedeck_service_plan(<<_/binary>> = RatedeckId) -> Plan = kz_json:from_list([{<<"ratedeck">> ,kz_json:from_list([{RatedeckId, kz_json:new()}]) @@ -142,13 +142,13 @@ wait_for_task(API, TaskId) -> wait_for_task(API, TaskId) end. --spec delete_rate(pqc_cb_api:state(), ne_binary() | kzd_rate:doc()) -> pqc_cb_api:response(). +-spec delete_rate(pqc_cb_api:state(), kz_term:ne_binary() | kzd_rate:doc()) -> pqc_cb_api:response(). delete_rate(API, <<_/binary>>=RatedeckId) -> delete_rate(API, ?RATE_ID, RatedeckId); delete_rate(API, RateDoc) -> delete_rate(API, ?RATE_ID, kzd_rate:ratedeck(RateDoc)). --spec delete_rate(pqc_cb_api:state(), ne_binary(), ne_binary()) -> pqc_cb_api:response(). +-spec delete_rate(pqc_cb_api:state(), kz_term:ne_binary(), kz_term:ne_binary()) -> pqc_cb_api:response(). delete_rate(API, ID, <<_/binary>>=RatedeckId) -> ?INFO("deleting rate ~s from ~s", [ID, RatedeckId]), @@ -173,7 +173,7 @@ get_rate(API, RateDoc) -> ). -spec get_rates(pqc_cb_api:state()) -> pqc_cb_api:response(). --spec get_rates(pqc_cb_api:state(), ne_binary()) -> pqc_cb_api:response(). +-spec get_rates(pqc_cb_api:state(), kz_term:ne_binary()) -> pqc_cb_api:response(). get_rates(API) -> get_rates(API, ?KZ_RATES_DB). get_rates(API, RatedeckId) -> @@ -184,14 +184,14 @@ get_rates(API, RatedeckId) -> ,pqc_cb_api:request_headers(API) ). --spec rate_did(pqc_cb_api:state(), ne_binary(), ne_binary()) -> api_integer(). +-spec rate_did(pqc_cb_api:state(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_integer(). rate_did(API, RatedeckId, DID) -> ?INFO("rating DID ~s using ~s", [DID, RatedeckId]), URL = rate_number_url(RatedeckId, DID), make_rating_request(API, URL). --spec make_rating_request(pqc_cb_api:state(), string()) -> api_integer(). +-spec make_rating_request(pqc_cb_api:state(), string()) -> kz_term:api_integer(). make_rating_request(API, URL) -> RequestHeaders = pqc_cb_api:request_headers(API), diff --git a/core/kazoo_proper/src/pqc_cb_response.erl b/core/kazoo_proper/src/pqc_cb_response.erl index 3cd7af2ce2c..dd908c8a74d 100644 --- a/core/kazoo_proper/src/pqc_cb_response.erl +++ b/core/kazoo_proper/src/pqc_cb_response.erl @@ -11,7 +11,7 @@ -include("kazoo_proper.hrl"). --spec account_id(pqc_cb_api:response() | kz_json:object()) -> ne_binary(). +-spec account_id(pqc_cb_api:response() | kz_json:object()) -> kz_term:ne_binary(). account_id(JSON) when is_binary(JSON) -> account_id(kz_json:decode(JSON)); account_id(APIResp) -> @@ -29,7 +29,7 @@ error_code(JSON) when is_binary(JSON) -> error_code(APIResp) -> kz_json:get_integer_value(<<"error">>, APIResp). --spec status(pqc_cb_api:response() | kz_json:object()) -> ne_binary(). +-spec status(pqc_cb_api:response() | kz_json:object()) -> kz_term:ne_binary(). status(JSON) when is_binary(JSON) -> status(kz_json:decode(JSON)); status(APIResp) -> @@ -42,7 +42,7 @@ data(JSON) when is_binary(JSON) -> data(APIResp) -> kz_json:get_value(<<"data">>, APIResp). --spec message(pqc_cb_api:response() | kz_json:object()) -> ne_binary(). +-spec message(pqc_cb_api:response() | kz_json:object()) -> kz_term:ne_binary(). message(JSON) when is_binary(JSON) -> message(kz_json:decode(JSON)); message(APIResp) -> diff --git a/core/kazoo_proper/src/pqc_cb_search.erl b/core/kazoo_proper/src/pqc_cb_search.erl index 3f687569589..49e632b8b67 100644 --- a/core/kazoo_proper/src/pqc_cb_search.erl +++ b/core/kazoo_proper/src/pqc_cb_search.erl @@ -4,7 +4,7 @@ -include("kazoo_proper.hrl"). --spec search_account_by_name(pqc_cb_api:state(), ne_binary()) -> pqc_cb_api:response(). +-spec search_account_by_name(pqc_cb_api:state(), kz_term:ne_binary()) -> pqc_cb_api:response(). search_account_by_name(API, Name) -> URL = search_url(API), RequestHeaders = pqc_cb_api:request_headers(API), diff --git a/core/kazoo_proper/src/pqc_cb_service_plans.erl b/core/kazoo_proper/src/pqc_cb_service_plans.erl index 3f592ffe535..75985f3226b 100644 --- a/core/kazoo_proper/src/pqc_cb_service_plans.erl +++ b/core/kazoo_proper/src/pqc_cb_service_plans.erl @@ -18,14 +18,14 @@ create_service_plan(_API, ServicePlan) -> {'ok', MasterAccountDb} = kapps_util:get_master_account_db(), kz_datamgr:save_doc(MasterAccountDb, ServicePlan). --spec delete_service_plan(pqc_cb_api:state(), ne_binary()) -> +-spec delete_service_plan(pqc_cb_api:state(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. delete_service_plan(_API, ServicePlanId) -> {'ok', MasterAccountDb} = kapps_util:get_master_account_db(), kz_datamgr:del_doc(MasterAccountDb, ServicePlanId). --spec assign_service_plan(pqc_cb_api:state(), ne_binary() | proper_types:type(), ne_binary()) -> pqc_cb_api:response(). +-spec assign_service_plan(pqc_cb_api:state(), kz_term:ne_binary() | proper_types:type(), kz_term:ne_binary()) -> pqc_cb_api:response(). assign_service_plan(API, AccountId, ServicePlanId) -> URL = account_service_plan_url(AccountId), RequestHeaders = pqc_cb_api:request_headers(API), @@ -40,7 +40,7 @@ assign_service_plan(API, AccountId, ServicePlanId) -> ,kz_json:encode(RequestEnvelope) ). --spec available_service_plans(pqc_cb_api:state(), ne_binary() | proper_types:type()) -> +-spec available_service_plans(pqc_cb_api:state(), kz_term:ne_binary() | proper_types:type()) -> pqc_cb_api:response(). available_service_plans(API, AccountId) -> URL = string:join([account_service_plan_url(AccountId), "available"], "/"), @@ -51,7 +51,7 @@ available_service_plans(API, AccountId) -> ,RequestHeaders ). --spec account_service_plan_url(ne_binary()) -> string(). +-spec account_service_plan_url(kz_term:ne_binary()) -> string(). account_service_plan_url(AccountId) -> string:join([pqc_cb_accounts:account_url(AccountId), "service_plans"], "/"). diff --git a/core/kazoo_proper/src/pqc_cb_tasks.erl b/core/kazoo_proper/src/pqc_cb_tasks.erl index c0dd0bd1bfa..f0742681367 100644 --- a/core/kazoo_proper/src/pqc_cb_tasks.erl +++ b/core/kazoo_proper/src/pqc_cb_tasks.erl @@ -21,7 +21,7 @@ create(API, QueryString, CSV) -> ,CSV ). --spec execute(pqc_cb_api:state(), ne_binary()) -> pqc_cb_api:response(). +-spec execute(pqc_cb_api:state(), kz_term:ne_binary()) -> pqc_cb_api:response(). execute(API, TaskId) -> pqc_cb_api:make_request([200] ,fun kz_http:patch/3 @@ -30,7 +30,7 @@ execute(API, TaskId) -> ,<<>> ). --spec fetch(pqc_cb_api:state(), ne_binary()) -> pqc_cb_api:response(). +-spec fetch(pqc_cb_api:state(), kz_term:ne_binary()) -> pqc_cb_api:response(). fetch(API, TaskId) -> pqc_cb_api:make_request([200] ,fun kz_http:get/2 @@ -38,7 +38,7 @@ fetch(API, TaskId) -> ,pqc_cb_api:request_headers(API) ). --spec delete(pqc_cb_api:state(), ne_binary()) -> pqc_cb_api:response(). +-spec delete(pqc_cb_api:state(), kz_term:ne_binary()) -> pqc_cb_api:response(). delete(API, TaskId) -> pqc_cb_api:make_request([200] ,fun kz_http:delete/2 @@ -46,7 +46,7 @@ delete(API, TaskId) -> ,pqc_cb_api:request_headers(API) ). --spec query(pqc_cb_api:state(), ne_binary(), ne_binary()) -> pqc_cb_api:response(). +-spec query(pqc_cb_api:state(), kz_term:ne_binary(), kz_term:ne_binary()) -> pqc_cb_api:response(). query(API, Category, Action) -> TaskURL = tasks_url(["category=", kz_term:to_list(Category) ,"&action=", kz_term:to_list(Action) @@ -59,7 +59,7 @@ query(API, Category, Action) -> ,pqc_cb_api:request_headers(API) ). --spec task_url(ne_binary()) -> string(). +-spec task_url(kz_term:ne_binary()) -> string(). task_url(TaskId) -> string:join([pqc_cb_api:v2_base_url(), "tasks", kz_term:to_list(TaskId)], "/"). diff --git a/core/kazoo_proper/src/pqc_kazoo_model.erl b/core/kazoo_proper/src/pqc_kazoo_model.erl index 926cfbef152..2ae2aa5af47 100644 --- a/core/kazoo_proper/src/pqc_kazoo_model.erl +++ b/core/kazoo_proper/src/pqc_kazoo_model.erl @@ -45,29 +45,29 @@ -include_lib("kazoo_stdlib/include/kz_databases.hrl"). %% #{"prefix" => cost} --type rate_data() :: #{ne_binary() => non_neg_integer()}. --type service_plans() :: [{ne_binary(), kzd_service_plan:plan()}]. +-type rate_data() :: #{kz_term:ne_binary() => non_neg_integer()}. +-type service_plans() :: [{kz_term:ne_binary(), kzd_service_plan:plan()}]. --type account_data() :: #{'name' => ne_binary() +-type account_data() :: #{'name' => kz_term:ne_binary() ,'service_plans' => service_plans() }. %% #{AccountId => AccountData} --type accounts() :: #{ne_binary() => account_data()}. +-type accounts() :: #{kz_term:ne_binary() => account_data()}. -type number_data() :: #{'number_state' => atom() - ,'account_id' => ne_binary() + ,'account_id' => kz_term:ne_binary() }. %% #{DID => NumberData} --type numbers() :: #{ne_binary() => number_data()}. +-type numbers() :: #{kz_term:ne_binary() => number_data()}. --type ratedecks() :: #{ne_binary() => rate_data()}. +-type ratedecks() :: #{kz_term:ne_binary() => rate_data()}. --type dedicated_ip() :: #{'host' => ne_binary() - ,'zone' => ne_binary() - ,'assigned_to' => api_ne_binary() +-type dedicated_ip() :: #{'host' => kz_term:ne_binary() + ,'zone' => kz_term:ne_binary() + ,'assigned_to' => kz_term:api_ne_binary() }. %% #{IP => #{...}} --type dedicated_ips() :: #{ne_binary() => dedicated_ip()}. +-type dedicated_ips() :: #{kz_term:ne_binary() => dedicated_ip()}. -record(kazoo_model ,{'accounts' = #{} :: accounts() @@ -88,7 +88,7 @@ new(API) -> #kazoo_model{'api'=API}. --spec pp(model()) -> kz_proplist(). +-spec pp(model()) -> kz_term:proplist(). pp(#kazoo_model{accounts=Account ,numbers=Numbers ,ratedecks=Ratedecks @@ -110,14 +110,14 @@ pp(#kazoo_model{accounts=Account api(#kazoo_model{'api'=API}) -> API. -spec ratedeck(model()) -> rate_data(). --spec ratedeck(model(), ne_binary()) -> rate_data(). +-spec ratedeck(model(), kz_term:ne_binary()) -> rate_data(). ratedeck(Model) -> ratedeck(Model, ?KZ_RATES_DB). ratedeck(#kazoo_model{'ratedecks'=Ratedecks}, Name) -> maps:get(Name, Ratedecks, #{}). --spec dedicated_ips(model()) -> [{ne_binary(), dedicated_ip()}]. +-spec dedicated_ips(model()) -> [{kz_term:ne_binary(), dedicated_ip()}]. dedicated_ips(#kazoo_model{'dedicated_ips'=IPs}) -> maps:fold(fun(IP, IPInfo, Acc) -> [{IP, IPInfo} | Acc] @@ -126,25 +126,25 @@ dedicated_ips(#kazoo_model{'dedicated_ips'=IPs}) -> ,IPs ). --spec dedicated_ip(model(), ne_binary()) -> dedicated_ip() | 'undefined'. +-spec dedicated_ip(model(), kz_term:ne_binary()) -> dedicated_ip() | 'undefined'. dedicated_ip(#kazoo_model{'dedicated_ips'=IPs}, IP) -> maps:get(IP, IPs, 'undefined'). --spec dedicated_zones(model()) -> ne_binaries(). +-spec dedicated_zones(model()) -> kz_term:ne_binaries(). dedicated_zones(#kazoo_model{'dedicated_ips'=IPs}) -> maps:fold(fun(_IP, #{'zone' := Zone}, Zones) -> [Zone | Zones] end ,[] ,IPs ). --spec dedicated_hosts(model()) -> ne_binaries(). +-spec dedicated_hosts(model()) -> kz_term:ne_binaries(). dedicated_hosts(#kazoo_model{'dedicated_ips'=IPs}) -> maps:fold(fun(_IP, #{'host' := Host}, Hosts) -> [Host | Hosts] end ,[] ,IPs ). --spec account_ips(model(), ne_binary()) -> [{ne_binary(), dedicated_ip()}]. +-spec account_ips(model(), kz_term:ne_binary()) -> [{kz_term:ne_binary(), dedicated_ip()}]. account_ips(#kazoo_model{'dedicated_ips'=IPs}, AccountId) -> maps:fold(fun(IP, IPInfo, Acc) -> case maps:get('assigned_to', IPInfo, 'undefined') of @@ -160,14 +160,14 @@ account_ips(#kazoo_model{'dedicated_ips'=IPs}, AccountId) -> has_accounts(#kazoo_model{'accounts'=Accounts}) -> 0 =:= map_size(Accounts). --spec has_rate_matching(model(), ne_binary(), ne_binary()) -> +-spec has_rate_matching(model(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'false' | {'true', integer()}. has_rate_matching(#kazoo_model{}=Model, RatedeckId, DID) -> Ratedeck = ratedeck(Model, RatedeckId), has_rate_matching(Ratedeck, DID). --spec has_service_plan_rate_matching(model(), ne_binary(), ne_binary()) -> boolean(). +-spec has_service_plan_rate_matching(model(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). has_service_plan_rate_matching(#kazoo_model{'accounts'=Accounts ,'service_plans'=SPs }=Model @@ -190,7 +190,7 @@ has_service_plan_rate_matching(#kazoo_model{'accounts'=Accounts end end. --spec has_rate_matching(rate_data(), ne_binary()) -> boolean(). +-spec has_rate_matching(rate_data(), kz_term:ne_binary()) -> boolean(). has_rate_matching(Ratedeck, <<"+", Number/binary>>) -> has_rate_matching(Ratedeck, Number); has_rate_matching(Ratedeck, Number) -> @@ -202,97 +202,97 @@ has_rate_matching(Ratedeck, Number) -> [Cost] -> {'true', Cost} end. --spec account_id_by_name(model(), ne_binary()) -> api_ne_binary(). +-spec account_id_by_name(model(), kz_term:ne_binary()) -> kz_term:api_ne_binary(). account_id_by_name(#kazoo_model{'accounts'=Accounts}, Name) -> case maps:get(Name, Accounts, 'undefined') of #{'id' := AccountId} -> AccountId; _ -> 'undefined' end. --spec does_account_exist(model() | map(), ne_binary()) -> boolean(). +-spec does_account_exist(model() | map(), kz_term:ne_binary()) -> boolean(). does_account_exist(#kazoo_model{'accounts'=Accounts}, AccountId) -> does_account_exist(Accounts, AccountId); does_account_exist(Accounts, AccountId) -> 'undefined' =/= maps:get(AccountId, Accounts, 'undefined'). --spec is_account_missing(model(), ne_binary()) -> boolean(). +-spec is_account_missing(model(), kz_term:ne_binary()) -> boolean(). is_account_missing(#kazoo_model{}=Model, Id) -> not does_account_exist(Model, Id). --spec does_service_plan_exist(model(), ne_binary()) -> boolean(). +-spec does_service_plan_exist(model(), kz_term:ne_binary()) -> boolean(). does_service_plan_exist(#kazoo_model{'service_plans'=Plans}, PlanId) -> 'false' =/= lists:keyfind(PlanId, 1, Plans). --spec is_number_in_account(model(), ne_binary(), ne_binary()) -> boolean(). +-spec is_number_in_account(model(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_number_in_account(#kazoo_model{}=Model, AccountId, Number) -> case number_data(Model, Number) of #{'account_id' := AccountId} -> 'true'; _ -> 'false' end. --spec is_number_missing_in_account(model(), ne_binary(), ne_binary()) -> boolean(). +-spec is_number_missing_in_account(model(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_number_missing_in_account(#kazoo_model{}=Model, AccountId, Number) -> not is_number_in_account(Model, AccountId, Number). --spec is_rate_missing(model(), ne_binary(), kzd_rate:doc()) -> boolean(). +-spec is_rate_missing(model(), kz_term:ne_binary(), kzd_rate:doc()) -> boolean(). is_rate_missing(#kazoo_model{}=Model, RatedeckId, RateDoc) -> Ratedeck = ratedeck(Model, RatedeckId), Prefix = kzd_rate:prefix(RateDoc), 'undefined' =:= maps:get(Prefix, Ratedeck, 'undefined'). --spec does_rate_exist(model(), ne_binary(), kzd_rate:doc()) -> boolean(). +-spec does_rate_exist(model(), kz_term:ne_binary(), kzd_rate:doc()) -> boolean(). does_rate_exist(Model, RatedeckId, RateDoc) -> not is_rate_missing(Model, RatedeckId, RateDoc). --spec does_ratedeck_exist(model(), ne_binary()) -> boolean(). +-spec does_ratedeck_exist(model(), kz_term:ne_binary()) -> boolean(). does_ratedeck_exist(#kazoo_model{}=Model, RatedeckId) -> Ratedeck = ratedeck(Model, RatedeckId), is_map(Ratedeck) andalso 0 < maps:size(Ratedeck). --spec does_ip_exist(model(), ne_binary()) -> boolean(). +-spec does_ip_exist(model(), kz_term:ne_binary()) -> boolean(). does_ip_exist(Model, IP) -> 'undefined' =/= dedicated_ip(Model, IP). --spec is_ip_missing(model(), ne_binary()) -> boolean(). +-spec is_ip_missing(model(), kz_term:ne_binary()) -> boolean(). is_ip_missing(Model, IP) -> 'undefined' =:= dedicated_ip(Model, IP). --spec is_ip_assigned(model(), ne_binary(), ne_binary()) -> boolean(). +-spec is_ip_assigned(model(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_ip_assigned(Model, AccountId, IP) -> case dedicated_ip(Model, IP) of #{'assigned_to' := AccountId} -> 'true'; _ -> 'false' end. --spec is_ip_unassigned(model(), ne_binary()) -> boolean(). +-spec is_ip_unassigned(model(), kz_term:ne_binary()) -> boolean(). is_ip_unassigned(Model, IP) -> IPInfo = dedicated_ip(Model, IP), 'undefined' =:= maps:get('assigned_to', IPInfo, 'undefined'). --spec add_account(model(), ne_binary(), pqc_cb_api:response()) -> model(). +-spec add_account(model(), kz_term:ne_binary(), pqc_cb_api:response()) -> model(). add_account(#kazoo_model{'accounts'=Accounts}=State, Name, APIResp) -> ID = {'call', 'pqc_cb_response', 'account_id', [APIResp]}, State#kazoo_model{'accounts' = Accounts#{Name => #{'id' => ID} ,ID => new_account(Name) }}. --spec add_rate_to_ratedeck(model(), ne_binary(), kzd_rate:doc()) -> model(). +-spec add_rate_to_ratedeck(model(), kz_term:ne_binary(), kzd_rate:doc()) -> model(). add_rate_to_ratedeck(#kazoo_model{'ratedecks'=Ratedecks}=Model, RatedeckId, RateDoc) -> Ratedeck = ratedeck(Model, RatedeckId), UpdatedDeck = Ratedeck#{kzd_rate:prefix(RateDoc) => kzd_rate:rate_cost(RateDoc)}, UpdatedDecks = Ratedecks#{RatedeckId => UpdatedDeck}, Model#kazoo_model{'ratedecks'=UpdatedDecks}. --spec remove_rate_from_ratedeck(model(), ne_binary(), kzd_rate:doc()) -> model(). +-spec remove_rate_from_ratedeck(model(), kz_term:ne_binary(), kzd_rate:doc()) -> model(). remove_rate_from_ratedeck(#kazoo_model{'ratedecks'=Ratedecks}=Model, RatedeckId, RateDoc) -> Ratedeck = ratedeck(Model, RatedeckId), UpdatedDeck = maps:remove(kzd_rate:prefix(RateDoc), Ratedeck), Model#kazoo_model{'ratedecks'=Ratedecks#{RatedeckId => UpdatedDeck}}. --spec add_number_to_account(model(), ne_binary(), ne_binary(), pqc_cb_api:response()) -> model(). +-spec add_number_to_account(model(), kz_term:ne_binary(), kz_term:ne_binary(), pqc_cb_api:response()) -> model(). add_number_to_account(#kazoo_model{'numbers'=Numbers}=Model, AccountId, Number, APIResp) -> NumberState = {'call', 'pqc_cb_response', 'number_state', [APIResp]}, NumberData = #{'account_id' => AccountId @@ -301,7 +301,7 @@ add_number_to_account(#kazoo_model{'numbers'=Numbers}=Model, AccountId, Number, Model#kazoo_model{'numbers'=Numbers#{Number => NumberData}}. -spec add_service_plan(model() | service_plans(), kzd_service_plan:doc()) -> model() | service_plans(). --spec add_service_plan(model(), ne_binary(), kzd_service_plan:doc()) -> model(). +-spec add_service_plan(model(), kz_term:ne_binary(), kzd_service_plan:doc()) -> model(). add_service_plan(#kazoo_model{'service_plans'=Plans}=Model, ServicePlan) -> Model#kazoo_model{'service_plans'=add_service_plan(Plans, ServicePlan)}; add_service_plan(Plans, ServicePlan) -> @@ -314,7 +314,7 @@ add_service_plan(Model, AccountId, ServicePlan) -> ,ServicePlan ). --spec add_service_plan_to_account(model(), ne_binary(), kzd_service_plan:doc()) -> model(). +-spec add_service_plan_to_account(model(), kz_term:ne_binary(), kzd_service_plan:doc()) -> model(). add_service_plan_to_account(#kazoo_model{'accounts'=Accounts}=Model, AccountId, ServicePlan) -> #{'service_plans' := Plans}=Account = maps:get(AccountId, Accounts), @@ -322,7 +322,7 @@ add_service_plan_to_account(#kazoo_model{'accounts'=Accounts}=Model, AccountId, Accounts1 = Accounts#{AccountId => Account1}, Model#kazoo_model{'accounts'=Accounts1}. --spec add_dedicated_ip(model(), ne_binary(), ne_binary(), ne_binary()) -> +-spec add_dedicated_ip(model(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> model(). add_dedicated_ip(#kazoo_model{'dedicated_ips'=IPs}=Model, IP, Host, Zone) -> UpdatedIPs = @@ -338,28 +338,28 @@ add_dedicated_ip(#kazoo_model{'dedicated_ips'=IPs}=Model, IP, Host, Zone) -> end, Model#kazoo_model{'dedicated_ips'=UpdatedIPs}. --spec remove_dedicated_ip(model(), ne_binary()) -> model(). +-spec remove_dedicated_ip(model(), kz_term:ne_binary()) -> model(). remove_dedicated_ip(#kazoo_model{'dedicated_ips'=IPs}=Model, IP) -> Model#kazoo_model{'dedicated_ips'=maps:remove(IP, IPs)}. --spec assign_dedicated_ip(model(), ne_binary(), ne_binary()) -> +-spec assign_dedicated_ip(model(), kz_term:ne_binary(), kz_term:ne_binary()) -> model(). assign_dedicated_ip(#kazoo_model{'dedicated_ips'=IPs}=Model, AccountId, IP) -> IPInfo = dedicated_ip(Model, IP), Model#kazoo_model{'dedicated_ips'=IPs#{IP => IPInfo#{'assigned_to' => AccountId}}}. --spec unassign_dedicated_ip(model(), ne_binary()) -> model(). +-spec unassign_dedicated_ip(model(), kz_term:ne_binary()) -> model(). unassign_dedicated_ip(#kazoo_model{'dedicated_ips'=IPs}=Model, IP) -> IPInfo = dedicated_ip(Model, IP), Model#kazoo_model{'dedicated_ips'=IPs#{IP => IPInfo#{'assigned_to' => 'undefined'}}}. --spec remove_number_from_account(model(), ne_binary()) -> model(). +-spec remove_number_from_account(model(), kz_term:ne_binary()) -> model(). remove_number_from_account(#kazoo_model{'numbers'=Numbers}=Model ,Number ) -> Model#kazoo_model{'numbers'=maps:remove(Number, Numbers)}. --spec transition_number_state(model(), ne_binary(), pqc_cb_api:response()) -> model(). +-spec transition_number_state(model(), kz_term:ne_binary(), pqc_cb_api:response()) -> model(). transition_number_state(#kazoo_model{'numbers'=Numbers}=Model, Number, APIResp) -> NumberData = number_data(Numbers, Number), NumberState = {'call', 'pqc_cb_response', 'number_state', [APIResp]}, @@ -369,13 +369,13 @@ transition_number_state(#kazoo_model{'numbers'=Numbers}=Model, Number, APIResp) } }. --spec number_data(map() | model(), ne_binary()) -> map() | 'undefined'. +-spec number_data(map() | model(), kz_term:ne_binary()) -> map() | 'undefined'. number_data(#kazoo_model{'numbers'=Numbers}, Number) -> number_data(Numbers, Number); number_data(Numbers, Number) -> maps:get(Number, Numbers, 'undefined'). --spec new_account(ne_binary()) -> account_data(). +-spec new_account(kz_term:ne_binary()) -> account_data(). new_account(Name) -> #{'name' => Name ,'service_plans' => [] diff --git a/core/kazoo_proper/src/pqc_util.erl b/core/kazoo_proper/src/pqc_util.erl index 64a8ec772b1..418a3922524 100644 --- a/core/kazoo_proper/src/pqc_util.erl +++ b/core/kazoo_proper/src/pqc_util.erl @@ -45,9 +45,9 @@ cleanup_arg(Arg) -> Arg. -spec run_counterexample(module()) -> - {ne_binary(), 'postcondition_failed'} | - {ne_binary(), atom(), any(), [erlang:stack_item()]} | - {'ok', ne_binary()}. + {kz_term:ne_binary(), 'postcondition_failed'} | + {kz_term:ne_binary(), atom(), any(), [erlang:stack_item()]} | + {'ok', kz_term:ne_binary()}. run_counterexample(PQC) -> PQC:cleanup(), io:format("cleaned up, running counterexample~n", []), diff --git a/core/kazoo_schemas/src/kz_json_schema.erl b/core/kazoo_schemas/src/kz_json_schema.erl index 1ec6a689c8a..28629f70af1 100644 --- a/core/kazoo_schemas/src/kz_json_schema.erl +++ b/core/kazoo_schemas/src/kz_json_schema.erl @@ -40,7 +40,7 @@ [jesse_error:error_reason()])} | {'allowed_errors', non_neg_integer() | 'infinity'} | {'default_schema_ver', binary()} | -{'schema_loader_fun', fun((ne_binary()) -> {'ok', kz_json:object()} | kz_json:object() | 'not_found')} | +{'schema_loader_fun', fun((kz_term:ne_binary()) -> {'ok', kz_json:object()} | kz_json:object() | 'not_found')} | {'extra_validator', extra_validator()} | {'setter_fun', fun((kz_json:path(), kz_json:json_term(), kz_json:object()) -> kz_json:object())} | {'validator_options', validator_options()}. @@ -56,7 +56,7 @@ ]} ]). --spec load(ne_binary() | string()) -> {'ok', kz_json:object()} | +-spec load(kz_term:ne_binary() | string()) -> {'ok', kz_json:object()} | {'error', any()}. load(<<"./", Schema/binary>>) -> load(Schema); load(<<"file://", Schema/binary>>) -> load(Schema); @@ -67,7 +67,7 @@ load(<<_/binary>> = Schema) -> end; load(Schema) -> load(kz_term:to_binary(Schema)). --spec fload(ne_binary() | string()) -> {'ok', kz_json:object()} | +-spec fload(kz_term:ne_binary() | string()) -> {'ok', kz_json:object()} | {'error', 'not_found'}. fload(<<"./", Schema/binary>>) -> fload(Schema); fload(<<"file://", Schema/binary>>) -> fload(Schema); @@ -78,7 +78,7 @@ fload(<<_/binary>> = Schema) -> end; fload(Schema) -> fload(kz_term:to_binary(Schema)). --spec find_and_fload(ne_binary()) -> +-spec find_and_fload(kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', 'not_found'}. find_and_fload(Schema) -> @@ -89,7 +89,7 @@ find_and_fload(Schema) -> 'false'-> {'error', 'not_found'} end. --spec fload_file(ne_binary()) -> {'ok', kz_json:object()}. +-spec fload_file(kz_term:ne_binary()) -> {'ok', kz_json:object()}. fload_file(SchemaPath) -> Schema = filename:basename(SchemaPath, ".json"), case file:read_file(SchemaPath) of @@ -97,7 +97,7 @@ fload_file(SchemaPath) -> Error -> Error end. --spec maybe_add_ext(ne_binary()) -> ne_binary(). +-spec maybe_add_ext(kz_term:ne_binary()) -> kz_term:ne_binary(). maybe_add_ext(Schema) -> case filename:extension(Schema) of <<".json">> -> Schema; @@ -105,13 +105,13 @@ maybe_add_ext(Schema) -> end. -spec flush() -> 'ok'. --spec flush(ne_binary()) -> 'ok'. +-spec flush(kz_term:ne_binary()) -> 'ok'. flush() -> kz_datamgr:flush_cache_docs(?KZ_SCHEMA_DB). flush(Schema) -> kz_datamgr:flush_cache_doc(?KZ_SCHEMA_DB, Schema). --spec add_defaults(api_object() | ne_binary(), ne_binary() | kz_json:object()) -> api_object(). +-spec add_defaults(kz_term:api_object() | kz_term:ne_binary(), kz_term:ne_binary() | kz_json:object()) -> kz_term:api_object(). add_defaults(JObj, <<_/binary>> = Schema) -> {'ok', SchemaJObj} = load(Schema), add_defaults(JObj, SchemaJObj); @@ -121,7 +121,7 @@ add_defaults(JObj, SchemaJObj) -> ,kz_json:get_json_value(<<"properties">>, SchemaJObj, kz_json:new()) ). --spec defaults_foldl(kz_json:path(), kz_json:object(), api_object()) -> api_object(). +-spec defaults_foldl(kz_json:path(), kz_json:object(), kz_term:api_object()) -> kz_term:api_object(). defaults_foldl(SchemaKey, SchemaValue, JObj) -> case kz_json:get_value(<<"default">>, SchemaValue) of 'undefined' -> @@ -133,7 +133,7 @@ defaults_foldl(SchemaKey, SchemaValue, JObj) -> ) end. --spec maybe_sub_properties(kz_json:path(), kz_json:object(), api_object()) -> api_object(). +-spec maybe_sub_properties(kz_json:path(), kz_json:object(), kz_term:api_object()) -> kz_term:api_object(). maybe_sub_properties(SchemaKey, SchemaValue, JObj) -> case kz_json:get_ne_binary_value(<<"type">>, SchemaValue) of <<"object">> -> @@ -164,7 +164,7 @@ maybe_update_data_with_sub(SchemaKey, SchemaValue, JObj) -> SubJObj -> kz_json:set_value(SchemaKey, SubJObj, JObj) end. --spec maybe_default(kz_json:path(), kz_json:json_term(), api_object()) -> api_object(). +-spec maybe_default(kz_json:path(), kz_json:json_term(), kz_term:api_object()) -> kz_term:api_object(). maybe_default(Key, Default, 'undefined') -> kz_json:set_value(Key, Default, kz_json:new()); maybe_default(Key, Default, JObj) -> @@ -173,10 +173,10 @@ maybe_default(Key, Default, JObj) -> 'true' -> JObj end. --spec validate(ne_binary() | kz_json:object(), kz_json:object()) -> +-spec validate(kz_term:ne_binary() | kz_json:object(), kz_json:object()) -> {'ok', kz_json:object()} | jesse_error:error(). --spec validate(ne_binary() | kz_json:object(), kz_json:object(), jesse_options()) -> +-spec validate(kz_term:ne_binary() | kz_json:object(), kz_json:object(), jesse_options()) -> {'ok', kz_json:object()} | jesse_error:error(). validate(SchemaJObj, DataJObj) -> @@ -195,12 +195,12 @@ validate(<<_/binary>> = Schema, DataJObj, Options) -> validate(SchemaJObj, DataJObj, Options0) when is_list(Options0) -> jesse:validate_with_schema(SchemaJObj, DataJObj, Options0 ++ ?DEFAULT_OPTIONS). --type option() :: {'version', ne_binary()} | +-type option() :: {'version', kz_term:ne_binary()} | {'error_code', integer()} | - {'error_message', ne_binary()}. + {'error_message', kz_term:ne_binary()}. -type options() :: [option()]. --type validation_error() :: {integer(), ne_binary(), kz_json:object()}. +-type validation_error() :: {integer(), kz_term:ne_binary(), kz_json:object()}. -type validation_errors() :: [validation_error()]. -spec errors_to_jobj([jesse_error:error_reason()]) -> @@ -696,7 +696,7 @@ error_to_jobj(Other, _Options) -> %% Add a validation error to the list of request errors %% @end %%-------------------------------------------------------------------- --spec validation_error(kz_json:path(), ne_binary(), kz_json:object(), options()) -> +-spec validation_error(kz_json:path(), kz_term:ne_binary(), kz_json:object(), options()) -> validation_error(). validation_error(Property, <<"type">>=C, Message, Options) -> depreciated_validation_error(Property, C, Message, Options); @@ -761,7 +761,7 @@ validation_error(Property, Code, Message, Options) -> lager:warning("UNKNOWN ERROR CODE: ~p", [Code]), depreciated_validation_error(Property, Code, Message, Options). --spec depreciated_validation_error(kz_json:path(), ne_binary(), kz_json:object(), options()) -> +-spec depreciated_validation_error(kz_json:path(), kz_term:ne_binary(), kz_json:object(), options()) -> validation_error(). depreciated_validation_error(<<"account">>, <<"expired">>, Message, Options) -> build_validate_error([<<"account">>] @@ -797,7 +797,7 @@ insert_default_options(Options) -> ,Options ). --spec build_validate_error(kz_json:path(), ne_binary(), kz_json:object(), options()) -> +-spec build_validate_error(kz_json:path(), kz_term:ne_binary(), kz_json:object(), options()) -> validation_error(). build_validate_error(Property, Code, Message, Options) -> %% Maintain the same error format we are currently using until we are ready to @@ -813,20 +813,20 @@ build_validate_error(Property, Code, Message, Options) -> ,kz_json:set_values([{[Key, Code], Error}], kz_json:new()) }. --spec build_error_message(ne_binary(), kz_json:object()) -> kz_json:object() | ne_binary(). +-spec build_error_message(kz_term:ne_binary(), kz_json:object()) -> kz_json:object() | kz_term:ne_binary(). build_error_message(?VERSION_1, JObj) -> kz_json:get_value(<<"message">>, JObj); build_error_message(_Version, JObj) -> JObj. --spec get_disallow(kz_json:object()) -> ne_binary(). +-spec get_disallow(kz_json:object()) -> kz_term:ne_binary(). get_disallow(JObj) -> case kz_json:get_value(<<"disallow">>, JObj) of <<_/binary>> = Disallow -> Disallow; Disallows when is_list(Disallows) -> kz_binary:join(Disallows) end. --spec get_types(kz_json:object()) -> ne_binary(). +-spec get_types(kz_json:object()) -> kz_term:ne_binary(). get_types(JObj) -> case kz_json:get_first_defined([<<"type">>, <<"types">>], JObj) of <<_/binary>> = Type -> Type; @@ -864,7 +864,7 @@ flatten_prop(Path, ?JSON_WRAPPER(L) = Value) when is_list(L) -> end; flatten_prop(Path, V) -> [{Path, V}]. --spec default_object(ne_binary() | kz_json:object()) -> kz_json:object(). +-spec default_object(kz_term:ne_binary() | kz_json:object()) -> kz_json:object(). default_object(?NE_BINARY=SchemaId) -> {'ok', Schema} = load(SchemaId), default_object(Schema); diff --git a/core/kazoo_services/src/bookkeepers/kz_bookkeeper_braintree.erl b/core/kazoo_services/src/bookkeepers/kz_bookkeeper_braintree.erl index 88ffef4b259..f382d2dd199 100644 --- a/core/kazoo_services/src/bookkeepers/kz_bookkeeper_braintree.erl +++ b/core/kazoo_services/src/bookkeepers/kz_bookkeeper_braintree.erl @@ -23,11 +23,11 @@ -define(TR_DESCRIPTION, <<"braintree transaction">>). -record(kz_service_update, {bt_subscription :: braintree_subscription:subscription() - ,plan_id :: api_ne_binary() + ,plan_id :: kz_term:api_ne_binary() }). -record(kz_service_updates, {bt_subscriptions = [] :: [update()] - ,account_id :: api_ne_binary() + ,account_id :: kz_term:api_ne_binary() ,bt_customer :: braintree_customer:customer() }). @@ -40,7 +40,7 @@ %% %% @end %%-------------------------------------------------------------------- --spec is_good_standing(ne_binary(), ne_binary()) -> boolean(). +-spec is_good_standing(kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_good_standing(AccountId, _Status) -> try braintree_customer:find(AccountId) of Customer -> customer_has_card(Customer, AccountId) @@ -50,7 +50,7 @@ is_good_standing(AccountId, _Status) -> 'false' end. --spec customer_has_card(braintree_customer:customer(), ne_binary()) -> boolean(). +-spec customer_has_card(braintree_customer:customer(), kz_term:ne_binary()) -> boolean(). customer_has_card(Customer, AccountId) -> try braintree_customer:default_payment_card(Customer) of Card -> @@ -74,8 +74,8 @@ customer_has_card(Customer, AccountId) -> %% %% @end %%-------------------------------------------------------------------- --spec sync(kz_service_items:items(), ne_binary()) -> bookkeeper_sync_result(). --spec sync(kz_service_item:items(), ne_binary(), updates()) -> bookkeeper_sync_result(). +-spec sync(kz_service_items:items(), kz_term:ne_binary()) -> bookkeeper_sync_result(). +-spec sync(kz_service_item:items(), kz_term:ne_binary(), updates()) -> bookkeeper_sync_result(). sync(Items, AccountId) -> ItemList = kz_service_items:to_list(Items), case fetch_bt_customer(AccountId, ItemList =/= []) of @@ -110,7 +110,7 @@ sync([ServiceItem|ServiceItems], AccountId, Updates) -> %% %% @end %%-------------------------------------------------------------------- --spec transactions(ne_binary(), gregorian_seconds(), gregorian_seconds()) -> +-spec transactions(kz_term:ne_binary(), kz_time:gregorian_seconds(), kz_time:gregorian_seconds()) -> {'ok', kz_transaction:transactions()} | {'error', 'not_found'} | {'error', 'unknown_error'}. @@ -132,7 +132,7 @@ transactions(AccountId, From0, To0) -> %% %% @end %%-------------------------------------------------------------------- --spec subscriptions(ne_binary()) -> atom() | kz_json:objects(). +-spec subscriptions(kz_term:ne_binary()) -> atom() | kz_json:objects(). subscriptions(AccountId) -> try braintree_customer:find(AccountId) of Customer -> @@ -150,8 +150,8 @@ subscriptions(AccountId) -> %% %% @end %%-------------------------------------------------------------------- --spec commit_transactions(ne_binary(),kz_transactions:kz_transactions()) -> 'ok' | 'error'. --spec commit_transactions(ne_binary(), kz_transactions:kz_transactions(), integer()) -> 'ok' | 'error'. +-spec commit_transactions(kz_term:ne_binary(),kz_transactions:kz_transactions()) -> 'ok' | 'error'. +-spec commit_transactions(kz_term:ne_binary(), kz_transactions:kz_transactions(), integer()) -> 'ok' | 'error'. commit_transactions(BillingId, Transactions) -> _ = kz_transactions:save(Transactions), commit_transactions(BillingId, Transactions, 3). @@ -185,8 +185,8 @@ commit_transactions(BillingId, _Transactions, _Try) -> %% %% @end %%-------------------------------------------------------------------- --spec charge_transactions(ne_binary(), kz_json:objects()) -> kz_json:objects(). --spec charge_transactions(ne_binary(), kz_json:objects(), dict:dict()) -> kz_json:objects(). +-spec charge_transactions(kz_term:ne_binary(), kz_json:objects()) -> kz_json:objects(). +-spec charge_transactions(kz_term:ne_binary(), kz_json:objects(), dict:dict()) -> kz_json:objects(). charge_transactions(BillingId, Transactions) -> charge_transactions(BillingId, Transactions, dict:new()). @@ -215,7 +215,7 @@ charge_transactions(BillingId, [Transaction|Transactions], Dict) -> NewDict = dict:append(Code, Transaction, Dict), charge_transactions(BillingId, Transactions, NewDict). --spec handle_charged_transactions(ne_binary(), pos_integer(), kz_json:objects()) -> boolean(). +-spec handle_charged_transactions(kz_term:ne_binary(), pos_integer(), kz_json:objects()) -> boolean(). handle_charged_transactions(BillingId, Code, []) -> lager:debug("no transaction found for ~p", [{BillingId, Code}]), 'true'; @@ -225,7 +225,7 @@ handle_charged_transactions(BillingId, Code, JObjs) -> {Success, _} = braintree_quick_sale(BillingId, Amount, Props), Success. --spec handle_topup(ne_binary(), kz_json:objects()) -> 'true' | {boolean(), ne_binary()}. +-spec handle_topup(kz_term:ne_binary(), kz_json:objects()) -> 'true' | {boolean(), kz_term:ne_binary()}. handle_topup(BillingId, []) -> lager:debug("no top-up transaction found for ~s", [BillingId]), 'true'; @@ -241,7 +241,7 @@ handle_topup(BillingId, JObjs) -> end. --spec braintree_quick_sale(ne_binary(), number() | ne_binary(), kz_proplist()) -> +-spec braintree_quick_sale(kz_term:ne_binary(), number() | kz_term:ne_binary(), kz_term:proplist()) -> {boolean(), api_bt_transaction()}. braintree_quick_sale(BillingId, Amount, Props) -> try braintree_transaction:quick_sale(BillingId @@ -271,14 +271,14 @@ handle_quick_sale_response(BtTransaction) -> kz_term:to_integer(RespCode) < 2000. --spec send_topup_notification(boolean(), ne_binary(), integer(), api_bt_transaction() | ne_binary()) -> - {boolean(), ne_binary()}. +-spec send_topup_notification(boolean(), kz_term:ne_binary(), integer(), api_bt_transaction() | kz_term:ne_binary()) -> + {boolean(), kz_term:ne_binary()}. send_topup_notification(Success, BillingId, Amount, BraintreeTransaction) -> Props = notification_data(Success, BillingId, Amount, BraintreeTransaction), kapps_notify_publisher:cast(Props, fun kapi_notifications:publish_topup/1), {Success, props:get_value(<<"Response">>, Props)}. --spec notification_data(boolean(), ne_binary(), integer(), api_bt_transaction()) -> kz_proplist(). +-spec notification_data(boolean(), kz_term:ne_binary(), integer(), api_bt_transaction()) -> kz_term:proplist(). notification_data(Success, BillingId, Amount, 'undefined') -> [{<<"Account-ID">>, BillingId} ,{<<"Amount">>, Amount} @@ -322,7 +322,7 @@ convert_transaction(BTTransaction) -> -spec set_reason_and_code(kz_json:object(), kz_transaction:transaction()) -> kz_transaction:transaction(). --spec set_reason_and_code(kz_json:object(), kz_transaction:transaction(), api_pos_integer()) -> +-spec set_reason_and_code(kz_json:object(), kz_transaction:transaction(), kz_term:api_pos_integer()) -> kz_transaction:transaction(). set_reason_and_code(BTTransaction, Transaction) -> Code = kz_json:get_integer_value(<<"purchase_order">>, BTTransaction), @@ -354,14 +354,14 @@ bookkeeper_info(BTTransaction) -> ,{<<"merchant_account_id">>, kz_json:get_value(<<"merchant_account_id">>, BTTransaction)} ]). --spec type(kz_json:object()) -> ne_binary(). +-spec type(kz_json:object()) -> kz_term:ne_binary(). type(BTTransaction) -> case kz_json:get_ne_value(<<"type">>, BTTransaction) =:= ?BT_TRANS_SALE of 'true' -> <<"debit">>; 'false' -> <<"credit">> end. --spec status(kz_json:object()) -> ne_binary(). +-spec status(kz_json:object()) -> kz_term:ne_binary(). status(BTTransaction) -> kz_json:get_ne_binary_value(<<"status">>, BTTransaction). @@ -370,20 +370,20 @@ amount(BTTransaction) -> Amount = kz_json:get_integer_value(<<"amount">>, BTTransaction), wht_util:dollars_to_units(Amount). --spec created(kz_json:object()) -> gregorian_seconds(). +-spec created(kz_json:object()) -> kz_time:gregorian_seconds(). created(BTTransaction) -> utc_to_gregorian_seconds(kz_json:get_value(<<"created_at">>, BTTransaction)). --spec modified(kz_json:object()) -> gregorian_seconds(). +-spec modified(kz_json:object()) -> kz_time:gregorian_seconds(). modified(BTTransaction) -> utc_to_gregorian_seconds(kz_json:get_value(<<"update_at">>, BTTransaction)). --spec account_id(kz_json:object()) -> ne_binary(). +-spec account_id(kz_json:object()) -> kz_term:ne_binary(). account_id(BTTransaction) -> CustomerId = kz_json:get_value([<<"customer">>, <<"id">>], BTTransaction), kz_util:format_account_id(CustomerId, 'raw'). --spec account_db(kz_json:object()) -> ne_binary(). +-spec account_db(kz_json:object()) -> kz_term:ne_binary(). account_db(BTTransaction) -> CustormerId = kz_json:get_value([<<"customer">>, <<"id">>], BTTransaction), kz_util:format_account_db(CustormerId). @@ -419,7 +419,7 @@ calculate([Addon|Addons], Acc) -> %% %% @end %%-------------------------------------------------------------------- --spec timestamp_to_braintree(api_seconds()) -> ne_binary(). +-spec timestamp_to_braintree(kz_time:api_seconds()) -> kz_term:ne_binary(). timestamp_to_braintree('undefined') -> lager:debug("timestamp undefined using now_s"), timestamp_to_braintree(kz_time:now_s()); @@ -436,7 +436,7 @@ timestamp_to_braintree(Timestamp) -> %% %% @end %%-------------------------------------------------------------------- --spec utc_to_gregorian_seconds(ne_binary()) -> api_seconds(). +-spec utc_to_gregorian_seconds(kz_term:ne_binary()) -> kz_time:api_seconds(). utc_to_gregorian_seconds(<> @@ -469,7 +469,7 @@ calculate_amount(JObjs) -> %% %% @end %%-------------------------------------------------------------------- --spec already_charged(ne_binary() | integer() , integer() | kz_json:objects()) -> boolean(). +-spec already_charged(kz_term:ne_binary() | integer() , integer() | kz_json:objects()) -> boolean(). already_charged(BillingId, Code) when is_integer(Code) -> lager:warning("checking if ~s has been charged for transaction of type ~p today", [BillingId, Code]), BtTransactions = braintree_transaction:find_by_customer(BillingId), @@ -501,7 +501,7 @@ already_charged(Code, [Transaction|Transactions]) -> %% %% @end %%-------------------------------------------------------------------- --spec already_charged_transaction(integer(), ne_binary(), integer(), kz_json:object()) -> boolean(). +-spec already_charged_transaction(integer(), kz_term:ne_binary(), integer(), kz_json:object()) -> boolean(). already_charged_transaction(_ , ?BT_TRANS_VOIDED, _, Transaction) -> _Id = kz_doc:id(Transaction), lager:warning("transaction was voided (~s)", [_Id]), @@ -579,7 +579,7 @@ handle_cumulative_discounts(ServiceItem, Subscription) -> %% %% @end %%-------------------------------------------------------------------- --spec update_subscriptions(ne_binary(), braintree_subscription:subscription(), updates()) -> +-spec update_subscriptions(kz_term:ne_binary(), braintree_subscription:subscription(), updates()) -> updates(). update_subscriptions(PlanId, Subscription, #kz_service_updates{bt_subscriptions=Subscriptions}=Updates) -> Update = #kz_service_update{bt_subscription = Subscription @@ -594,7 +594,7 @@ update_subscriptions(PlanId, Subscription, #kz_service_updates{bt_subscriptions= %% %% @end %%-------------------------------------------------------------------- --spec fetch_bt_customer(ne_binary(), boolean()) -> +-spec fetch_bt_customer(kz_term:ne_binary(), boolean()) -> 'undefined' | braintree_customer:customer(). fetch_bt_customer(AccountId, NewItems) -> lager:debug("requesting braintree customer ~s", [AccountId]), @@ -611,7 +611,7 @@ fetch_bt_customer(AccountId, NewItems) -> %% %% @end %%-------------------------------------------------------------------- --spec fetch_or_create_subscription(ne_binary(), updates() | braintree_customer:customer()) -> +-spec fetch_or_create_subscription(kz_term:ne_binary(), updates() | braintree_customer:customer()) -> braintree_subscription:subscription(). fetch_or_create_subscription(PlanId, #kz_service_updates{bt_subscriptions=[] ,bt_customer=Customer @@ -637,7 +637,7 @@ fetch_or_create_subscription(PlanId, #bt_customer{}=Customer) -> braintree_customer:new_subscription(PlanId, Customer) end. --spec find_subscription_by_plan_id(ne_binary(), [update()]) -> +-spec find_subscription_by_plan_id(kz_term:ne_binary(), [update()]) -> 'undefined' | braintree_subscription:subscription(). find_subscription_by_plan_id(PlanId, Subscriptions) -> @@ -652,7 +652,7 @@ find_subscription_by_plan_id(PlanId, Subscriptions) -> end. %% @private --spec prepare_subscription(kz_service_item:item(), ne_binary(), ne_binary(), updates()) -> +-spec prepare_subscription(kz_service_item:item(), kz_term:ne_binary(), kz_term:ne_binary(), updates()) -> braintree_subscription:subscription(). prepare_subscription(ServiceItem, AddOnId, PlanId, Updates) -> Routines = [fun(S) -> diff --git a/core/kazoo_services/src/bookkeepers/kz_bookkeeper_http.erl b/core/kazoo_services/src/bookkeepers/kz_bookkeeper_http.erl index 2ac1a5da366..7a2f58d43ae 100644 --- a/core/kazoo_services/src/bookkeepers/kz_bookkeeper_http.erl +++ b/core/kazoo_services/src/bookkeepers/kz_bookkeeper_http.erl @@ -18,12 +18,12 @@ -define(DEFAULT_SYNC_CONTENT_TYPE, ?DEFAULT_CONTENT_TYPE). --record(sync, {id :: api_ne_binary() - ,account_id :: api_ne_binary() +-record(sync, {id :: kz_term:api_ne_binary() + ,account_id :: kz_term:api_ne_binary() ,items :: kz_service_items:items() - ,url :: api_ne_binary() - ,method :: api_ne_binary() - ,content_type = ?DEFAULT_SYNC_CONTENT_TYPE :: ne_binary() | '_' + ,url :: kz_term:api_ne_binary() + ,method :: kz_term:api_ne_binary() + ,content_type = ?DEFAULT_SYNC_CONTENT_TYPE :: kz_term:ne_binary() | '_' }). -type sync() :: #sync{}. @@ -47,7 +47,7 @@ %% %% @end %%-------------------------------------------------------------------- --spec is_good_standing(ne_binary(), ne_binary()) -> boolean(). +-spec is_good_standing(kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_good_standing(_AccountId, Status) -> Status =:= kzd_services:status_good(). @@ -57,7 +57,7 @@ is_good_standing(_AccountId, Status) -> %% %% @end %%-------------------------------------------------------------------- --spec sync(kz_service_items:items(), ne_binary()) -> bookkeeper_sync_result(). +-spec sync(kz_service_items:items(), kz_term:ne_binary()) -> bookkeeper_sync_result(). sync(Items, AccountId) -> Sync = #sync{id = get_sync_id(AccountId) ,account_id = AccountId @@ -95,7 +95,7 @@ handle_resp({'error', _E}, _Sync) -> lager:debug("http billing sync failed: ~p", [_E]), 'retry'. --spec get_sync_id(ne_binary()) -> ne_binary(). +-spec get_sync_id(kz_term:ne_binary()) -> kz_term:ne_binary(). get_sync_id(AccountId) -> {'ok', JObj} = kz_services:fetch_services_doc(AccountId), kz_doc:revision(JObj). @@ -110,7 +110,7 @@ http_payload(#sync{content_type = <<"application/json">>} = Sync) -> ,{<<"items">>, kz_service_items:public_json(Sync#sync.items)} ])). --spec http_headers(sync()) -> kz_proplist(). +-spec http_headers(sync()) -> kz_term:proplist(). http_headers(Sync) -> props:filter_empty( [{"X-Sync-ID", to_list(Sync#sync.id)} @@ -119,7 +119,7 @@ http_headers(Sync) -> ] ). --spec to_list(api_binary()) -> 'undefined' | list(). +-spec to_list(kz_term:api_binary()) -> 'undefined' | list(). to_list('undefined') -> 'undefined'; to_list(Value) -> case kz_term:is_empty(Value) of @@ -133,7 +133,7 @@ to_list(Value) -> %% %% @end %%-------------------------------------------------------------------- --spec commit_transactions(ne_binary(), kz_transactions:kz_transactions()) -> ok | error. +-spec commit_transactions(kz_term:ne_binary(), kz_transactions:kz_transactions()) -> ok | error. commit_transactions(_BillingId, Transactions) -> kz_transactions:save(Transactions), 'ok'. @@ -144,7 +144,7 @@ commit_transactions(_BillingId, Transactions) -> %% %% @end %%-------------------------------------------------------------------- --spec charge_transactions(ne_binary(), kz_json:objects()) -> []. +-spec charge_transactions(kz_term:ne_binary(), kz_json:objects()) -> []. charge_transactions(_BillingId, _Transactions) -> []. %%-------------------------------------------------------------------- @@ -153,7 +153,7 @@ charge_transactions(_BillingId, _Transactions) -> []. %% %% @end %%-------------------------------------------------------------------- --spec transactions(ne_binary(), gregorian_seconds(), gregorian_seconds()) -> +-spec transactions(kz_term:ne_binary(), kz_time:gregorian_seconds(), kz_time:gregorian_seconds()) -> {'ok', kz_transaction:transactions()} | {'error', atom()}. transactions(AccountId, From, To) -> @@ -170,7 +170,7 @@ transactions(AccountId, From, To) -> %% %% @end %%-------------------------------------------------------------------- --spec handle_topup(ne_binary(), kz_transactions:transactions()) -> 'ok'. +-spec handle_topup(kz_term:ne_binary(), kz_transactions:transactions()) -> 'ok'. handle_topup(_, []) -> 'ok'; handle_topup(BillingId, [Transaction|Transactions]) -> case kz_transaction:code(Transaction) =:= ?CODE_TOPUP of @@ -180,7 +180,7 @@ handle_topup(BillingId, [Transaction|Transactions]) -> send_topup_notification(BillingId, Transaction) end. --spec send_topup_notification(ne_binary(), kz_transaction:transaction()) -> 'ok'. +-spec send_topup_notification(kz_term:ne_binary(), kz_transaction:transaction()) -> 'ok'. send_topup_notification(BillingId, Transaction) -> Props = [{<<"Account-ID">>, BillingId} ,{<<"Amount">>, wht_util:units_to_dollars(kz_transaction:amount(Transaction))} diff --git a/core/kazoo_services/src/bookkeepers/kz_bookkeeper_local.erl b/core/kazoo_services/src/bookkeepers/kz_bookkeeper_local.erl index e5b56f4d6e8..1bff08c8997 100644 --- a/core/kazoo_services/src/bookkeepers/kz_bookkeeper_local.erl +++ b/core/kazoo_services/src/bookkeepers/kz_bookkeeper_local.erl @@ -22,7 +22,7 @@ %% %% @end %%-------------------------------------------------------------------- --spec is_good_standing(ne_binary(), ne_binary()) -> boolean(). +-spec is_good_standing(kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). is_good_standing(_AccountId, _Status) -> 'true'. %%-------------------------------------------------------------------- @@ -31,7 +31,7 @@ is_good_standing(_AccountId, _Status) -> 'true'. %% %% @end %%-------------------------------------------------------------------- --spec sync(kz_service_items:items(), ne_binary()) -> bookkeeper_sync_result(). +-spec sync(kz_service_items:items(), kz_term:ne_binary()) -> bookkeeper_sync_result(). sync(_Items, _AccountId) -> 'ok'. %%-------------------------------------------------------------------- @@ -40,7 +40,7 @@ sync(_Items, _AccountId) -> 'ok'. %% %% @end %%-------------------------------------------------------------------- --spec commit_transactions(ne_binary(), kz_transactions:kz_transactions()) -> ok | error. +-spec commit_transactions(kz_term:ne_binary(), kz_transactions:kz_transactions()) -> ok | error. commit_transactions(_BillingId, Transactions) -> kz_transactions:save(Transactions), 'ok'. @@ -51,7 +51,7 @@ commit_transactions(_BillingId, Transactions) -> %% %% @end %%-------------------------------------------------------------------- --spec charge_transactions(ne_binary(), kz_json:objects()) -> kz_json:objects(). +-spec charge_transactions(kz_term:ne_binary(), kz_json:objects()) -> kz_json:objects(). charge_transactions(_BillingId, _Transactions) -> []. %%-------------------------------------------------------------------- @@ -60,7 +60,7 @@ charge_transactions(_BillingId, _Transactions) -> []. %% %% @end %%-------------------------------------------------------------------- --spec transactions(ne_binary(), gregorian_seconds(), gregorian_seconds()) -> +-spec transactions(kz_term:ne_binary(), kz_time:gregorian_seconds(), kz_time:gregorian_seconds()) -> {'ok', kz_transaction:transactions()} | {'error', atom()}. transactions(AccountId, From, To) -> @@ -77,7 +77,7 @@ transactions(AccountId, From, To) -> %% %% @end %%-------------------------------------------------------------------- --spec handle_topup(ne_binary(), kz_transactions:transactions()) -> 'ok'. +-spec handle_topup(kz_term:ne_binary(), kz_transactions:transactions()) -> 'ok'. handle_topup(_, []) -> 'ok'; handle_topup(BillingId, [Transaction|Transactions]) -> case kz_transaction:code(Transaction) =:= ?CODE_TOPUP of @@ -87,7 +87,7 @@ handle_topup(BillingId, [Transaction|Transactions]) -> send_topup_notification(BillingId, Transaction) end. --spec send_topup_notification(ne_binary(), kz_transaction:transaction()) -> 'ok'. +-spec send_topup_notification(kz_term:ne_binary(), kz_transaction:transaction()) -> 'ok'. send_topup_notification(BillingId, Transaction) -> Props = [{<<"Account-ID">>, BillingId} ,{<<"Amount">>, wht_util:units_to_dollars(kz_transaction:amount(Transaction))} diff --git a/core/kazoo_services/src/kazoo_services_app.erl b/core/kazoo_services/src/kazoo_services_app.erl index 2a2a62ee44d..345dff952ad 100644 --- a/core/kazoo_services/src/kazoo_services_app.erl +++ b/core/kazoo_services/src/kazoo_services_app.erl @@ -17,7 +17,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> _ = kazoo_services_maintenance:refresh(), kazoo_services_sup:start_link(). diff --git a/core/kazoo_services/src/kazoo_services_maintenance.erl b/core/kazoo_services/src/kazoo_services_maintenance.erl index c6d630fd6f9..598322c7687 100644 --- a/core/kazoo_services/src/kazoo_services_maintenance.erl +++ b/core/kazoo_services/src/kazoo_services_maintenance.erl @@ -45,7 +45,7 @@ flush() -> %% credit card %% @end %%-------------------------------------------------------------------- --spec credit(ne_binary(), text()) -> 'no_return'. +-spec credit(kz_term:ne_binary(), kz_term:text()) -> 'no_return'. credit(AccountId, Amount) -> Units = wht_util:dollars_to_units(Amount), @@ -64,7 +64,7 @@ credit(AccountId, Amount) -> %% debit card %% @end %%-------------------------------------------------------------------- --spec debit(ne_binary(), text()) -> 'no_return'. +-spec debit(kz_term:ne_binary(), kz_term:text()) -> 'no_return'. debit(AccountId, Amount) -> Units = wht_util:dollars_to_units(Amount), @@ -122,7 +122,7 @@ refresh() -> %% @end %%-------------------------------------------------------------------- -spec reconcile() -> 'no_return'. --spec reconcile(text()) -> 'no_return'. +-spec reconcile(kz_term:text()) -> 'no_return'. reconcile() -> reconcile('all'). @@ -152,14 +152,14 @@ reconcile(Account) -> %% reseller tree (only the one account is affected) %% @end %%-------------------------------------------------------------------- --spec sync(text()) -> 'ok'. +-spec sync(kz_term:text()) -> 'ok'. sync(Account) when not is_binary(Account) -> sync(kz_term:to_binary(Account)); sync(Account) -> _ = kz_services:sync(Account), 'ok'. --spec sync_descendants(text()) -> 'ok'. +-spec sync_descendants(kz_term:text()) -> 'ok'. sync_descendants(Account) when not is_binary(Account) -> sync_descendants(kz_term:to_binary(Account)); sync_descendants(Account) -> @@ -167,7 +167,7 @@ sync_descendants(Account) -> io:format("syncing ~p descendants of ~s", [length(Descendants), Account]), do_sync_descendants(Descendants). --spec do_sync_descendants(ne_binaries()) -> 'ok'. +-spec do_sync_descendants(kz_term:ne_binaries()) -> 'ok'. do_sync_descendants([]) -> 'ok'; do_sync_descendants([Descendant|Descendants]) -> io:format(" syncing ~s, ~p accounts remaining", [Descendant, length(Descendants)]), @@ -180,7 +180,7 @@ do_sync_descendants([Descendant|Descendants]) -> %% Set the reseller_id to the provided value on the provided account %% @end %%-------------------------------------------------------------------- --spec set_reseller_id(text(), text()) -> 'ok'. +-spec set_reseller_id(kz_term:text(), kz_term:text()) -> 'ok'. set_reseller_id(Reseller, Account) when not is_binary(Account) -> set_reseller_id(Reseller, kz_term:to_binary(Account)); set_reseller_id(Reseller, Account) when not is_binary(Reseller) -> @@ -195,7 +195,7 @@ set_reseller_id(Reseller, Account) -> %% of the provided account %% @end %%-------------------------------------------------------------------- --spec cascade_reseller_id(text(), text()) -> 'ok'. +-spec cascade_reseller_id(kz_term:text(), kz_term:text()) -> 'ok'. cascade_reseller_id(Reseller, Account) when not is_binary(Account) -> cascade_reseller_id(Reseller, kz_term:to_binary(Account)); cascade_reseller_id(Reseller, Account) when not is_binary(Reseller) -> @@ -210,7 +210,7 @@ cascade_reseller_id(Reseller, Account) -> %% to the next higher reseller %% @end %%-------------------------------------------------------------------- --spec demote_reseller(text()) -> 'ok'. +-spec demote_reseller(kz_term:text()) -> 'ok'. demote_reseller(Account) when not is_binary(Account) -> demote_reseller(kz_term:to_binary(Account)); demote_reseller(Account) -> @@ -223,7 +223,7 @@ demote_reseller(Account) -> %% sub accounts %% @end %%-------------------------------------------------------------------- --spec make_reseller(text()) -> 'ok'. +-spec make_reseller(kz_term:text()) -> 'ok'. make_reseller(Account) when not is_binary(Account) -> make_reseller(kz_term:to_binary(Account)); make_reseller(Account) -> @@ -307,7 +307,7 @@ log_services_backup_failures([JObj|JObjs]) -> find_services_backup_failures(JObjs) -> [JObj || JObj <- JObjs, kz_json:get_ne_value(<<"error">>, JObj) =/= 'undefined']. --spec fetch_all_service_docs(ne_binary()) -> kz_json:objects(). +-spec fetch_all_service_docs(kz_term:ne_binary()) -> kz_json:objects(). fetch_all_service_docs(Database) -> _ = io:format("fetching all service docs from '~s'~n", [Database]), {'ok', JObjs} = kz_datamgr:all_docs(Database, ['include_docs']), @@ -333,7 +333,7 @@ remove_orphaned_services() -> andalso io:format("removed ~p service docs~n", [Count]), 'no_return'. --spec maybe_remove_orphan(kz_json:object() | ne_binary(), non_neg_integer()) -> +-spec maybe_remove_orphan(kz_json:object() | kz_term:ne_binary(), non_neg_integer()) -> non_neg_integer(). maybe_remove_orphan(<<"_design/", _/binary>>, Count) -> Count; maybe_remove_orphan(<<_/binary>> = AccountId, Count) -> diff --git a/core/kazoo_services/src/kazoo_services_sup.erl b/core/kazoo_services/src/kazoo_services_sup.erl index c9588f4e154..0f8c520d1b0 100644 --- a/core/kazoo_services/src/kazoo_services_sup.erl +++ b/core/kazoo_services/src/kazoo_services_sup.erl @@ -35,7 +35,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -52,7 +52,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, diff --git a/core/kazoo_services/src/kz_gen_bookkeeper.erl b/core/kazoo_services/src/kz_gen_bookkeeper.erl index c9458d4c966..aef4d223e91 100644 --- a/core/kazoo_services/src/kz_gen_bookkeeper.erl +++ b/core/kazoo_services/src/kz_gen_bookkeeper.erl @@ -10,18 +10,18 @@ -include("services.hrl"). --callback is_good_standing(ne_binary(), ne_binary()) -> +-callback is_good_standing(kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). --callback sync(kz_service_items:items(), ne_binary()) -> +-callback sync(kz_service_items:items(), kz_term:ne_binary()) -> bookkeeper_sync_result(). --callback transactions(ne_binary(), gregorian_seconds(), gregorian_seconds()) -> +-callback transactions(kz_term:ne_binary(), kz_time:gregorian_seconds(), kz_time:gregorian_seconds()) -> {ok, kz_transaction:transactions()} | {error, atom()}. --callback commit_transactions(ne_binary(), kz_transactions:kz_transactions()) -> +-callback commit_transactions(kz_term:ne_binary(), kz_transactions:kz_transactions()) -> ok | error. --callback charge_transactions(ne_binary(), kz_json:objects()) -> +-callback charge_transactions(kz_term:ne_binary(), kz_json:objects()) -> kz_json:objects(). diff --git a/core/kazoo_services/src/kz_service_item.erl b/core/kazoo_services/src/kz_service_item.erl index 1dae9fa0830..e8771b4e8d3 100644 --- a/core/kazoo_services/src/kz_service_item.erl +++ b/core/kazoo_services/src/kz_service_item.erl @@ -52,19 +52,19 @@ -include("services.hrl"). --record(kz_service_item, {category :: api_binary() - ,item :: api_binary() - ,name :: api_binary() - ,quantity = 0 :: api_integer() - ,rate = 0.0 :: api_float() +-record(kz_service_item, {category :: kz_term:api_binary() + ,item :: kz_term:api_binary() + ,name :: kz_term:api_binary() + ,quantity = 0 :: kz_term:api_integer() + ,rate = 0.0 :: kz_term:api_float() ,single_discount = 'false' :: boolean() - ,single_discount_rate = 0.00 :: api_float() - ,cumulative_discount = 0 :: api_integer() - ,cumulative_discount_rate = 0.00 :: api_float() + ,single_discount_rate = 0.00 :: kz_term:api_float() + ,cumulative_discount = 0 :: kz_term:api_integer() + ,cumulative_discount_rate = 0.00 :: kz_term:api_float() ,bookkeepers = kz_json:new() :: kz_json:object() - ,activation_charge = 0.00 :: api_float() - ,minimum = 0 :: api_integer() - ,exceptions = [] :: ne_binaries() + ,activation_charge = 0.00 :: kz_term:api_float() + ,minimum = 0 :: kz_term:api_integer() + ,exceptions = [] :: kz_term:ne_binaries() }). -type item() :: #kz_service_item{}. @@ -112,7 +112,7 @@ empty() -> %% %% @end %%-------------------------------------------------------------------- --spec category(item()) -> api_binary(). +-spec category(item()) -> kz_term:api_binary(). category(#kz_service_item{category=Category}) -> Category. @@ -122,7 +122,7 @@ category(#kz_service_item{category=Category}) -> %% %% @end %%-------------------------------------------------------------------- --spec set_category(ne_binary(), item()) -> item(). +-spec set_category(kz_term:ne_binary(), item()) -> item(). set_category(Category, #kz_service_item{}=ServiceItem) -> ServiceItem#kz_service_item{category=Category}. @@ -132,7 +132,7 @@ set_category(Category, #kz_service_item{}=ServiceItem) -> %% %% @end %%-------------------------------------------------------------------- --spec item(item()) -> api_binary(). +-spec item(item()) -> kz_term:api_binary(). item(#kz_service_item{item=Item}) -> Item. @@ -142,7 +142,7 @@ item(#kz_service_item{item=Item}) -> %% %% @end %%-------------------------------------------------------------------- --spec set_item(ne_binary(), item()) -> item(). +-spec set_item(kz_term:ne_binary(), item()) -> item(). set_item(Item, #kz_service_item{}=ServiceItem) -> ServiceItem#kz_service_item{item=Item}. @@ -152,7 +152,7 @@ set_item(Item, #kz_service_item{}=ServiceItem) -> %% %% @end %%-------------------------------------------------------------------- --spec name(item()) -> api_binary(). +-spec name(item()) -> kz_term:api_binary(). name(#kz_service_item{name=Name}) -> Name. @@ -162,7 +162,7 @@ name(#kz_service_item{name=Name}) -> %% %% @end %%-------------------------------------------------------------------- --spec set_name(ne_binary(), item()) -> item(). +-spec set_name(kz_term:ne_binary(), item()) -> item(). set_name(Name, #kz_service_item{}=ServiceItem) -> ServiceItem#kz_service_item{name=Name}. @@ -172,7 +172,7 @@ set_name(Name, #kz_service_item{}=ServiceItem) -> %% %% @end %%-------------------------------------------------------------------- --spec quantity(item()) -> api_integer(). +-spec quantity(item()) -> kz_term:api_integer(). quantity(#kz_service_item{quantity=Quantity}) -> Quantity. @@ -182,7 +182,7 @@ quantity(#kz_service_item{quantity=Quantity}) -> %% %% @end %%-------------------------------------------------------------------- --spec set_quantity(api_binary() | integer(), item()) -> item(). +-spec set_quantity(kz_term:api_binary() | integer(), item()) -> item(). set_quantity('undefined', #kz_service_item{}=ServiceItem) -> ServiceItem#kz_service_item{quantity='undefined'}; set_quantity(Q, #kz_service_item{}=ServiceItem) -> @@ -201,7 +201,7 @@ set_quantity(Q, #kz_service_item{}=ServiceItem) -> %% %% @end %%-------------------------------------------------------------------- --spec rate(item()) -> api_float(). +-spec rate(item()) -> kz_term:api_float(). rate(#kz_service_item{rate=Rate}) -> Rate. @@ -211,7 +211,7 @@ rate(#kz_service_item{rate=Rate}) -> %% %% @end %%-------------------------------------------------------------------- --spec set_rate(api_binary() | float(), item()) -> item(). +-spec set_rate(kz_term:api_binary() | float(), item()) -> item(). set_rate('undefined', #kz_service_item{}=ServiceItem) -> ServiceItem#kz_service_item{rate='undefined'}; set_rate(Rate, #kz_service_item{}=ServiceItem) -> @@ -233,7 +233,7 @@ single_discount(#kz_service_item{single_discount=SingleDiscount}) -> %% %% @end %%-------------------------------------------------------------------- --spec set_single_discount(ne_binary() | boolean(), item()) -> item(). +-spec set_single_discount(kz_term:ne_binary() | boolean(), item()) -> item(). set_single_discount(SingleDiscount, #kz_service_item{}=ServiceItem) -> ServiceItem#kz_service_item{single_discount=kz_term:is_true(SingleDiscount)}. @@ -243,7 +243,7 @@ set_single_discount(SingleDiscount, #kz_service_item{}=ServiceItem) -> %% %% @end %%-------------------------------------------------------------------- --spec single_discount_rate(item()) -> api_float(). +-spec single_discount_rate(item()) -> kz_term:api_float(). single_discount_rate(#kz_service_item{single_discount_rate=Rate}) -> Rate. @@ -253,7 +253,7 @@ single_discount_rate(#kz_service_item{single_discount_rate=Rate}) -> %% %% @end %%-------------------------------------------------------------------- --spec set_single_discount_rate(api_binary() | float(), item()) -> item(). +-spec set_single_discount_rate(kz_term:api_binary() | float(), item()) -> item(). set_single_discount_rate('undefined', #kz_service_item{}=ServiceItem) -> ServiceItem#kz_service_item{single_discount_rate='undefined'}; set_single_discount_rate(Rate, #kz_service_item{}=ServiceItem) -> @@ -265,7 +265,7 @@ set_single_discount_rate(Rate, #kz_service_item{}=ServiceItem) -> %% %% @end %%-------------------------------------------------------------------- --spec cumulative_discount(item()) -> api_integer(). +-spec cumulative_discount(item()) -> kz_term:api_integer(). cumulative_discount(#kz_service_item{cumulative_discount=Quantity}) -> Quantity. @@ -275,7 +275,7 @@ cumulative_discount(#kz_service_item{cumulative_discount=Quantity}) -> %% %% @end %%-------------------------------------------------------------------- --spec set_cumulative_discount(api_binary() | integer(), item()) -> item(). +-spec set_cumulative_discount(kz_term:api_binary() | integer(), item()) -> item(). set_cumulative_discount('undefined', #kz_service_item{}=ServiceItem) -> ServiceItem#kz_service_item{cumulative_discount='undefined'}; set_cumulative_discount(Quantity, #kz_service_item{}=ServiceItem) -> @@ -287,7 +287,7 @@ set_cumulative_discount(Quantity, #kz_service_item{}=ServiceItem) -> %% %% @end %%-------------------------------------------------------------------- --spec cumulative_discount_rate(item()) -> api_float(). +-spec cumulative_discount_rate(item()) -> kz_term:api_float(). cumulative_discount_rate(#kz_service_item{cumulative_discount_rate=Rate}) -> Rate. @@ -297,7 +297,7 @@ cumulative_discount_rate(#kz_service_item{cumulative_discount_rate=Rate}) -> %% %% @end %%-------------------------------------------------------------------- --spec set_cumulative_discount_rate(api_binary() | float(), item()) -> item(). +-spec set_cumulative_discount_rate(kz_term:api_binary() | float(), item()) -> item(). set_cumulative_discount_rate('undefined', #kz_service_item{}=ServiceItem) -> ServiceItem#kz_service_item{cumulative_discount_rate='undefined'}; set_cumulative_discount_rate(Rate, #kz_service_item{}=ServiceItem) -> @@ -309,7 +309,7 @@ set_cumulative_discount_rate(Rate, #kz_service_item{}=ServiceItem) -> %% %% @end %%-------------------------------------------------------------------- --spec bookkeeper(kz_json:path(), item()) -> api_object() | ne_binary(). +-spec bookkeeper(kz_json:path(), item()) -> kz_term:api_object() | kz_term:ne_binary(). bookkeeper(Bookkeeper, #kz_service_item{bookkeepers=Bookkeepers}) -> kz_json:get_ne_value(Bookkeeper, Bookkeepers). @@ -367,7 +367,7 @@ set_minimum(Min, ServiceItem) -> %% %% @end %%-------------------------------------------------------------------- --spec exceptions(item()) -> ne_binaries(). +-spec exceptions(item()) -> kz_term:ne_binaries(). exceptions(#kz_service_item{exceptions=Exc}) -> Exc. %%-------------------------------------------------------------------- @@ -376,6 +376,6 @@ exceptions(#kz_service_item{exceptions=Exc}) -> Exc. %% %% @end %%-------------------------------------------------------------------- --spec set_exceptions(ne_binaries(), item()) -> item(). +-spec set_exceptions(kz_term:ne_binaries(), item()) -> item(). set_exceptions(Exc, ServiceItem) -> ServiceItem#kz_service_item{exceptions=Exc}. diff --git a/core/kazoo_services/src/kz_service_items.erl b/core/kazoo_services/src/kz_service_items.erl index 2e3d829c81c..8be2ea1c2f3 100644 --- a/core/kazoo_services/src/kz_service_items.erl +++ b/core/kazoo_services/src/kz_service_items.erl @@ -119,7 +119,7 @@ public_json_fold({_, ServiceItem}, JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec find(ne_binary(), ne_binary(), items()) -> kz_service_item:item(). +-spec find(kz_term:ne_binary(), kz_term:ne_binary(), items()) -> kz_service_item:item(). find(Category, Item, ServiceItems) -> Key = {Category, Item}, case dict:find(Key, ServiceItems) of @@ -153,7 +153,7 @@ log_update(ServiceItem) -> _ = log_update_cumulative_discount(Category, Item, ServiceItem), log_update_single_discount(Category, Item, ServiceItem). --spec log_update_rate(ne_binary(), ne_binary(), kz_service_item:item()) -> 'ok'. +-spec log_update_rate(kz_term:ne_binary(), kz_term:ne_binary(), kz_service_item:item()) -> 'ok'. log_update_rate(Category, Item, ServiceItem) -> case kz_service_item:rate(ServiceItem) of 'undefined' -> 'ok'; @@ -163,7 +163,7 @@ log_update_rate(Category, Item, ServiceItem) -> ) end. --spec log_update_cumulative_discount(ne_binary(), ne_binary(), kz_service_item:item()) -> 'ok'. +-spec log_update_cumulative_discount(kz_term:ne_binary(), kz_term:ne_binary(), kz_service_item:item()) -> 'ok'. log_update_cumulative_discount(Category, Item, ServiceItem) -> CumulativeDiscount = kz_service_item:cumulative_discount(ServiceItem), case kz_term:is_empty(CumulativeDiscount) @@ -176,7 +176,7 @@ log_update_cumulative_discount(Category, Item, ServiceItem) -> ) end. --spec log_update_single_discount(ne_binary(), ne_binary(), kz_service_item:item()) -> 'ok'. +-spec log_update_single_discount(kz_term:ne_binary(), kz_term:ne_binary(), kz_service_item:item()) -> 'ok'. log_update_single_discount(Category, Item, ServiceItem) -> case kz_service_item:single_discount(ServiceItem) andalso kz_service_item:single_discount_rate(ServiceItem) diff --git a/core/kazoo_services/src/kz_service_plan.erl b/core/kazoo_services/src/kz_service_plan.erl index 8a129fc37aa..1e69cc76615 100644 --- a/core/kazoo_services/src/kz_service_plan.erl +++ b/core/kazoo_services/src/kz_service_plan.erl @@ -20,7 +20,7 @@ %% Merge any plan overrides into the plan property. %% @end %%-------------------------------------------------------------------- --spec fetch(ne_binary(), ne_binary()) -> kzd_service_plan:api_doc(). +-spec fetch(kz_term:ne_binary(), kz_term:ne_binary()) -> kzd_service_plan:api_doc(). fetch(PlanId, VendorId) -> VendorDb = kz_util:format_account_db(VendorId), case fetch_plan(VendorDb, PlanId) of @@ -46,7 +46,7 @@ fetch_plan(VendorDb, PlanId) -> %% %% @end %%-------------------------------------------------------------------- --spec activation_charges(ne_binary(), ne_binary(), kzd_service_plan:doc()) -> float(). +-spec activation_charges(kz_term:ne_binary(), kz_term:ne_binary(), kzd_service_plan:doc()) -> float(). activation_charges(CategoryId, ItemId, ServicePlan) -> case kzd_service_plan:item_activation_charge(ServicePlan, CategoryId, ItemId, 'undefined') of 'undefined' -> @@ -63,7 +63,7 @@ activation_charges(CategoryId, ItemId, ServicePlan) -> -spec create_items(kzd_service_plan:doc(), kz_service_items:items(), kz_services:services()) -> kz_service_items:items(). -spec create_items(kzd_service_plan:doc(), kz_service_items:items(), kz_services:services() - ,ne_binary(), ne_binary() + ,kz_term:ne_binary(), kz_term:ne_binary() ) -> kz_service_items:items(). create_items(ServicePlan, ServiceItems, Services) -> @@ -121,13 +121,13 @@ create_items(ServicePlan, ServiceItems, Services, CategoryId, ItemId, ItemPlan) ), kz_service_items:update(ServiceItem, ServiceItems). --spec get_generic_item_plan(kzd_service_plan:doc(), ne_binary()) -> kz_json:object(). +-spec get_generic_item_plan(kzd_service_plan:doc(), kz_term:ne_binary()) -> kz_json:object(). get_generic_item_plan(ServicePlan, CategoryId) -> case kzd_service_plan:item(ServicePlan, CategoryId, <<"_all">>) of 'undefined' -> kz_json:new(); ItemPlan -> ItemPlan end. --spec get_plan_items(kzd_service_plan:doc(), kz_services:services()) -> kz_proplist(). +-spec get_plan_items(kzd_service_plan:doc(), kz_services:services()) -> kz_term:proplist(). get_plan_items(ServicePlan, Services) -> case kz_services:select_bookkeeper(Services) of 'kz_bookkeeper_http' -> @@ -210,7 +210,7 @@ cumulative_quantity(Item, CumulativeDiscount, Quantity) -> %% %% @end %%-------------------------------------------------------------------- --spec bookkeeper_jobj(ne_binary(), ne_binary(), kzd_service_plan:doc()) -> kz_json:object(). +-spec bookkeeper_jobj(kz_term:ne_binary(), kz_term:ne_binary(), kzd_service_plan:doc()) -> kz_json:object(). bookkeeper_jobj(CategoryId, ItemId, ServicePlan) -> lists:foldl(fun(Bookkeeper, J) -> Mapping = kz_json:get_value([CategoryId, ItemId] @@ -229,7 +229,7 @@ bookkeeper_jobj(CategoryId, ItemId, ServicePlan) -> %% %% @end %%-------------------------------------------------------------------- --spec get_rate_at_quantity(ne_binary(), ne_binary(), kzd_service_plan:doc(), kz_services:services()) -> +-spec get_rate_at_quantity(kz_term:ne_binary(), kz_term:ne_binary(), kzd_service_plan:doc(), kz_services:services()) -> {float(), integer()}. get_rate_at_quantity(CategoryId, ItemId, ItemPlan, Services) -> Quantity = get_quantity(CategoryId, ItemId, ItemPlan, Services), @@ -245,7 +245,7 @@ get_rate_at_quantity(CategoryId, ItemId, ItemPlan, Services) -> %% current quantity. %% @end %%-------------------------------------------------------------------- --spec get_quantity(ne_binary(), ne_binary(), kzd_item_plan:doc(), kz_services:services()) -> integer(). +-spec get_quantity(kz_term:ne_binary(), kz_term:ne_binary(), kzd_item_plan:doc(), kz_services:services()) -> integer(). get_quantity(CategoryId, ItemId, ItemPlan, Services) -> ItemQuantity = get_item_quantity(CategoryId, ItemId, ItemPlan, Services), case kzd_item_plan:minimum(ItemPlan) of @@ -264,7 +264,7 @@ get_quantity(CategoryId, ItemId, ItemPlan, Services) -> %% current quantity. %% @end %%-------------------------------------------------------------------- --spec get_flat_rate(non_neg_integer(), kzd_item_plan:doc()) -> api_float(). +-spec get_flat_rate(non_neg_integer(), kzd_item_plan:doc()) -> kz_term:api_float(). get_flat_rate(Quantity, ItemPlan) -> Rates = kzd_item_plan:flat_rates(ItemPlan), L1 = [kz_term:to_integer(K) || K <- kz_json:get_keys(Rates)], @@ -281,7 +281,7 @@ get_flat_rate(Quantity, ItemPlan) -> %% quantity. If no rates are viable attempt to use the "rate" property. %% @end %%-------------------------------------------------------------------- --spec get_quantity_rate(non_neg_integer(), kzd_item_plan:doc()) -> api_float(). +-spec get_quantity_rate(non_neg_integer(), kzd_item_plan:doc()) -> kz_term:api_float(). get_quantity_rate(Quantity, ItemPlan) -> Rates = kzd_item_plan:rates(ItemPlan), L1 = [kz_term:to_integer(K) || K <- kz_json:get_keys(Rates)], @@ -302,9 +302,9 @@ get_quantity_rate(Quantity, ItemPlan) -> %% summation. %% @end %%-------------------------------------------------------------------- --spec get_item_quantity(ne_binary(), ne_binary(), kzd_item_plan:doc(), kz_services:services()) -> +-spec get_item_quantity(kz_term:ne_binary(), kz_term:ne_binary(), kzd_item_plan:doc(), kz_services:services()) -> integer(). --spec get_item_quantity(ne_binary(), ne_binary(), kzd_item_plan:doc(), kz_services:services(), ne_binary()) -> +-spec get_item_quantity(kz_term:ne_binary(), kz_term:ne_binary(), kzd_item_plan:doc(), kz_services:services(), kz_term:ne_binary()) -> integer(). get_item_quantity(CategoryId, ItemId, ItemPlan, Services) -> diff --git a/core/kazoo_services/src/kz_service_plans.erl b/core/kazoo_services/src/kz_service_plans.erl index a4b2281897e..5b1bb7bb543 100644 --- a/core/kazoo_services/src/kz_service_plans.erl +++ b/core/kazoo_services/src/kz_service_plans.erl @@ -25,7 +25,7 @@ -include("services.hrl"). --record(kz_service_plans, {vendor_id :: api_binary() +-record(kz_service_plans, {vendor_id :: kz_term:api_binary() ,plans = [] :: kzd_service_plan:docs() }). @@ -57,7 +57,7 @@ from_service_json(ServicesJObj) -> get_plans(PlanIds, ResellerId, ServicesJObj). --spec find_reseller_id(kzd_services:doc()) -> api_ne_binary(). +-spec find_reseller_id(kzd_services:doc()) -> kz_term:api_ne_binary(). find_reseller_id(ServicesJObj) -> case kzd_services:reseller_id(ServicesJObj) of 'undefined' -> kz_json:get_ne_binary_value(<<"reseller_id">>, ServicesJObj); @@ -92,7 +92,7 @@ merge_plans(SerivcePlan, PlansJObj) -> %% %% @end %%-------------------------------------------------------------------- --spec add_service_plan(ne_binary(), ne_binary(), kzd_services:doc()) -> kzd_services:doc(). +-spec add_service_plan(kz_term:ne_binary(), kz_term:ne_binary(), kzd_services:doc()) -> kzd_services:doc(). add_service_plan(PlanId, ResellerId, ServicesJObj) -> ResellerDb = kz_util:format_account_db(ResellerId), case open_cache_doc(ResellerDb, PlanId) of @@ -124,7 +124,7 @@ open_cache_doc(Db, Id) -> %% %% @end %%-------------------------------------------------------------------- --spec delete_service_plan(ne_binary(), kzd_services:doc()) -> kzd_services:doc(). +-spec delete_service_plan(kz_term:ne_binary(), kzd_services:doc()) -> kzd_services:doc(). delete_service_plan(PlanId, ServicesJObj) -> kzd_services:set_plan(ServicesJObj, PlanId, 'undefined'). @@ -154,7 +154,7 @@ plan_summary(ServicesJObj) -> %% %% @end %%-------------------------------------------------------------------- --spec activation_charges(ne_binary(), ne_binary(), plans()) -> float(). +-spec activation_charges(kz_term:ne_binary(), kz_term:ne_binary(), plans()) -> float(). activation_charges(Category, Item, ServicePlans) -> lists:sum( [kz_service_plan:activation_charges(Category, Item, Plan) @@ -215,8 +215,8 @@ public_json_items(ServiceJObj) -> %% in the vendors #kz_service_plans data structure. %% @end %%-------------------------------------------------------------------- --spec get_plans(ne_binaries(), ne_binary(), kzd_services:doc()) -> plans(). --spec get_plan(ne_binary(), ne_binary(), kzd_services:doc(), plans()) -> plans(). +-spec get_plans(kz_term:ne_binaries(), kz_term:ne_binary(), kzd_services:doc()) -> plans(). +-spec get_plan(kz_term:ne_binary(), kz_term:ne_binary(), kzd_services:doc(), plans()) -> plans(). get_plans(PlanIds, ResellerId, Services) -> lists:foldl(fun(PlanId, ServicePlans) -> @@ -240,7 +240,7 @@ get_plan(PlanId, ResellerId, Services, ServicePlans) -> %% %% @end %%-------------------------------------------------------------------- --spec maybe_fetch_vendor_plan(ne_binary(), ne_binary(), ne_binary(), kz_json:object()) -> +-spec maybe_fetch_vendor_plan(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> kzd_service_plan:api_doc(). maybe_fetch_vendor_plan(PlanId, VendorId, VendorId, Overrides) -> AreOverridesEmpty = kz_json:is_empty(Overrides), @@ -262,7 +262,7 @@ maybe_fetch_vendor_plan(PlanId, _, ResellerId, _) -> %% for that vendor, creating a new list (record) if not present. %% @end %%-------------------------------------------------------------------- --spec append_vendor_plan(kzd_service_plan:doc(), ne_binary(), plans()) -> plans(). +-spec append_vendor_plan(kzd_service_plan:doc(), kz_term:ne_binary(), plans()) -> plans(). append_vendor_plan(Plan, VendorId, ServicePlans) -> case lists:keyfind(VendorId, #kz_service_plans.vendor_id, ServicePlans) of 'false' -> diff --git a/core/kazoo_services/src/kz_services.erl b/core/kazoo_services/src/kz_services.erl index a1479fb3965..37b34a11af4 100644 --- a/core/kazoo_services/src/kz_services.erl +++ b/core/kazoo_services/src/kz_services.erl @@ -77,12 +77,12 @@ ,application:get_env(?APP, 'service_modules', default_service_modules()) ). --record(kz_services, {account_id :: api_binary() - ,billing_id :: api_binary() - ,current_billing_id :: api_binary() +-record(kz_services, {account_id :: kz_term:api_binary() + ,billing_id :: kz_term:api_binary() + ,current_billing_id :: kz_term:api_binary() ,dirty = 'false' :: boolean() ,deleted = 'false' :: boolean() - ,status = kzd_services:status_good() :: ne_binary() + ,status = kzd_services:status_good() :: kz_term:ne_binary() ,jobj = kz_json:new() :: kz_json:object() ,updates = kz_json:new() :: kz_json:object() ,cascade_quantities = kz_json:new() :: kz_json:object() @@ -130,7 +130,7 @@ new() -> #kz_services{}. --spec new(ne_binary()) -> services(). +-spec new(kz_term:ne_binary()) -> services(). new(?MATCH_ACCOUNT_RAW(AccountId)) -> AccountJObj = get_account_definition(AccountId), JObj = base_service_object(AccountId, AccountJObj), @@ -145,7 +145,7 @@ new(?MATCH_ACCOUNT_RAW(AccountId)) -> ,deleted = kz_doc:is_soft_deleted(AccountJObj) }. --spec base_service_object(ne_binary(), kz_json:object()) -> kzd_services:doc(). +-spec base_service_object(kz_term:ne_binary(), kz_json:object()) -> kzd_services:doc(). base_service_object(AccountId, AccountJObj) -> ResellerId = get_reseller_id(AccountId), BaseJObj = kz_doc:update_pvt_parameters(kz_json:new() @@ -203,7 +203,7 @@ maybe_calc_updates(Services, 'true') -> %% %% @end %%-------------------------------------------------------------------- --spec fetch(ne_binary()) -> services(). +-spec fetch(kz_term:ne_binary()) -> services(). fetch(Account=?NE_BINARY) -> AccountId = kz_util:format_account_id(Account), case fetch_cached_services(AccountId) of @@ -212,7 +212,7 @@ fetch(Account=?NE_BINARY) -> fetch_and_build(AccountId) end. --spec fetch_and_build(ne_binary()) -> services(). +-spec fetch_and_build(kz_term:ne_binary()) -> services(). fetch_and_build(AccountId) -> case fetch_services_doc(AccountId) of {'ok', JObj} -> @@ -224,12 +224,12 @@ fetch_and_build(AccountId) -> new(AccountId) end. --spec fetch_cached_services(ne_binary()) -> {'ok', services()} | - {'error', 'not_found'}. +-spec fetch_cached_services(kz_term:ne_binary()) -> {'ok', services()} | + {'error', 'not_found'}. fetch_cached_services(?MATCH_ACCOUNT_RAW(AccountId)) -> kz_cache:fetch_local(?CACHE_NAME, ?CACHE_KEY(AccountId)). --spec cache_services(ne_binary(), services()) -> 'ok'. +-spec cache_services(kz_term:ne_binary(), services()) -> 'ok'. -ifdef(TEST). cache_services(?MATCH_ACCOUNT_RAW(_), #kz_services{}) -> 'ok'. -else. @@ -242,10 +242,10 @@ cache_services(AccountId, Services) -> flush_services() -> kz_cache:flush_local(?CACHE_NAME). --spec fetch_services_doc(ne_binary()) -> +-spec fetch_services_doc(kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. --spec fetch_services_doc(ne_binary(), boolean() | cache_failures) -> +-spec fetch_services_doc(kz_term:ne_binary(), boolean() | cache_failures) -> {'ok', kz_json:object()} | {'error', any()}. fetch_services_doc(?MATCH_ACCOUNT_RAW(AccountId)) -> @@ -297,7 +297,7 @@ fetch_services_doc(?MATCH_ACCOUNT_RAW(AccountId), 'true') -> kz_datamgr:open_doc(?KZ_SERVICES_DB, AccountId). -endif. --spec handle_fetch_result(ne_binary(), kz_json:object()) -> services(). +-spec handle_fetch_result(kz_term:ne_binary(), kz_json:object()) -> services(). handle_fetch_result(AccountId, JObj) -> lager:debug("loaded account service doc ~s", [AccountId]), IsReseller = kzd_services:is_reseller(JObj), @@ -318,7 +318,7 @@ handle_fetch_result(AccountId, JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec add_service_plan(ne_binary(), services()) -> services(). +-spec add_service_plan(kz_term:ne_binary(), services()) -> services(). add_service_plan(PlanId, #kz_services{jobj = JObj}=Services) -> ResellerId = kzd_services:reseller_id(JObj), UpdatedJObj = kz_service_plans:add_service_plan(PlanId, ResellerId, JObj), @@ -330,7 +330,7 @@ add_service_plan(PlanId, #kz_services{jobj = JObj}=Services) -> %% %% @end %%-------------------------------------------------------------------- --spec delete_service_plan(ne_binary(), services()) -> services(). +-spec delete_service_plan(kz_term:ne_binary(), services()) -> services(). delete_service_plan(PlanId, #kz_services{jobj = JObj}=Services) -> Services#kz_services{jobj = kz_service_plans:delete_service_plan(PlanId, JObj) }. @@ -341,13 +341,13 @@ delete_service_plan(PlanId, #kz_services{jobj = JObj}=Services) -> %% %% @end %%-------------------------------------------------------------------- --spec save_as_dirty(ne_binary() | services()) -> services(). +-spec save_as_dirty(kz_term:ne_binary() | services()) -> services(). save_as_dirty(Account=?NE_BINARY) -> save_as_dirty(fetch(Account)); save_as_dirty(#kz_services{}=Services) -> save_as_dirty(Services, ?BASE_BACKOFF). --spec save_as_dirty(ne_binary() | services(), pos_integer()) -> services(). +-spec save_as_dirty(kz_term:ne_binary() | services(), pos_integer()) -> services(). save_as_dirty(#kz_services{jobj = JObj %% ,updates = _Updates ,account_id = ?MATCH_ACCOUNT_RAW(AccountId) @@ -454,7 +454,7 @@ save_doc(JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec delete(ne_binary()) -> kz_std_return(). +-spec delete(kz_term:ne_binary()) -> kz_term:std_return(). delete(Account) -> AccountId = kz_util:format_account_id(Account), %% TODO: support other bookkeepers, and just cancel subscriptions.... @@ -478,7 +478,7 @@ delete(Account) -> %% %% @end %%-------------------------------------------------------------------- --spec list_categories(services()) -> api_ne_binaries(). +-spec list_categories(services()) -> kz_term:api_ne_binaries(). list_categories(#kz_services{jobj = JObj ,updates = Updates ,cascade_quantities = CascadeQuantities @@ -495,7 +495,7 @@ list_categories(#kz_services{jobj = JObj %% %% @end %%-------------------------------------------------------------------- --spec list_items(services(), ne_binary()) -> api_ne_binaries(). +-spec list_items(services(), kz_term:ne_binary()) -> kz_term:api_ne_binaries(). list_items(#kz_services{jobj = JObj ,updates = Updates ,cascade_quantities = CascadeQuantities @@ -514,7 +514,7 @@ list_items(#kz_services{jobj = JObj %% %% @end %%-------------------------------------------------------------------- --spec set_billing_id(api_binary(), ne_binary() | services()) -> 'undefined' | services(). +-spec set_billing_id(kz_term:api_binary(), kz_term:ne_binary() | services()) -> 'undefined' | services(). set_billing_id('undefined', _) -> 'undefined'; set_billing_id(BillingId, #kz_services{billing_id = BillingId}) -> 'undefined'; @@ -549,7 +549,7 @@ set_billing_id(BillingId, AccountId=?NE_BINARY) -> %% %% @end %%-------------------------------------------------------------------- --spec get_billing_id(ne_binary() | services()) -> ne_binary(). +-spec get_billing_id(kz_term:ne_binary() | services()) -> kz_term:ne_binary(). get_billing_id(#kz_services{billing_id = BillingId}) -> BillingId; get_billing_id(Account=?NE_BINARY) -> AccountId = kz_util:format_account_id(Account), @@ -573,7 +573,7 @@ get_billing_id(Account=?NE_BINARY) -> %% %% @end %%-------------------------------------------------------------------- --spec update(ne_binary(), ne_binary(), integer(), services()) -> services(). +-spec update(kz_term:ne_binary(), kz_term:ne_binary(), integer(), services()) -> services(). update(CategoryId, ItemId, Quantity, Services) when not is_integer(Quantity) -> update(CategoryId, ItemId, kz_term:to_integer(Quantity), Services); update(CategoryId, ItemId, Quantity, #kz_services{updates = JObj @@ -590,7 +590,7 @@ update(CategoryId, ItemId, Quantity, #kz_services{updates = JObj %% %% @end %%-------------------------------------------------------------------- --spec activation_charges(ne_binary(), ne_binary(), services() | ne_binary() | kz_service_plans:plans()) -> +-spec activation_charges(kz_term:ne_binary(), kz_term:ne_binary(), services() | kz_term:ne_binary() | kz_service_plans:plans()) -> float(). activation_charges(CategoryId, ItemId, Plans) when is_list(Plans) -> @@ -638,7 +638,7 @@ charge_transactions(#kz_services{billing_id = BillingId}=Services, Activations) %% %% @end %%-------------------------------------------------------------------- --spec select_bookkeeper(services() | ne_binary()) -> bookkeeper(). +-spec select_bookkeeper(services() | kz_term:ne_binary()) -> bookkeeper(). select_bookkeeper(#kz_services{billing_id = BillingId ,account_id = AccountId } @@ -671,7 +671,7 @@ select_bookkeeper(AccountId) -> %% %% @end %%-------------------------------------------------------------------- --spec check_bookkeeper(ne_binary(), integer()) -> boolean(). +-spec check_bookkeeper(kz_term:ne_binary(), integer()) -> boolean(). check_bookkeeper(BillingId, Amount) -> case select_bookkeeper(BillingId) of 'kz_bookkeeper_local' -> @@ -686,7 +686,7 @@ check_bookkeeper(BillingId, Amount) -> Bookkeeper:is_good_standing(BillingId, CurrentStatus) end. --spec current_service_status(ne_binary()) -> ne_binary(). +-spec current_service_status(kz_term:ne_binary()) -> kz_term:ne_binary(). current_service_status(AccountId) -> {'ok', ServicesJObj} = fetch_services_doc(AccountId), kzd_services:status(ServicesJObj). @@ -704,7 +704,7 @@ current_balance(AccountId) -> %% %% @end %%-------------------------------------------------------------------- --spec service_plan_json(ne_binary() | services()) -> kzd_service_plan:doc(). +-spec service_plan_json(kz_term:ne_binary() | services()) -> kzd_service_plan:doc(). service_plan_json(#kz_services{jobj = ServicesJObj}) -> Plans = kz_service_plans:from_service_json(ServicesJObj), kz_service_plans:public_json(Plans); @@ -717,7 +717,7 @@ service_plan_json(Account=?NE_BINARY) -> %% %% @end %%-------------------------------------------------------------------- --spec public_json(ne_binary() | services()) -> kz_json:object(). +-spec public_json(kz_term:ne_binary() | services()) -> kz_json:object(). public_json(#kz_services{jobj = ServicesJObj ,cascade_quantities = CascadeQuantities }) -> @@ -758,7 +758,7 @@ to_json(#kz_services{jobj = JObj %% %% @end %%-------------------------------------------------------------------- --spec find_reseller_id(api_binary()) -> api_binary(). +-spec find_reseller_id(kz_term:api_binary()) -> kz_term:api_binary(). find_reseller_id('undefined') -> case master_account_id() of {'error', _} -> 'undefined'; @@ -793,7 +793,7 @@ master_account_id() -> kapps_util:get_master_account_id(). %% accounting issues. %% @end %%-------------------------------------------------------------------- --spec allow_updates(ne_binary() | services()) -> 'true'. +-spec allow_updates(kz_term:ne_binary() | services()) -> 'true'. allow_updates(Account=?NE_BINARY) -> AccountId = kz_util:format_account_id(Account), case fetch_services_doc(AccountId) of @@ -810,7 +810,7 @@ allow_updates(#kz_services{jobj = ServicesJObj lager:debug("determining if account ~s is able to make updates", [AccountId]), maybe_follow_billing_id(AccountId, ServicesJObj). --spec maybe_follow_billing_id(ne_binary(), kz_json:object()) -> 'true'. +-spec maybe_follow_billing_id(kz_term:ne_binary(), kz_json:object()) -> 'true'. maybe_follow_billing_id(AccountId, ServicesJObj) -> case kzd_services:billing_id(ServicesJObj, AccountId) of AccountId -> maybe_allow_updates(AccountId, ServicesJObj); @@ -819,7 +819,7 @@ maybe_follow_billing_id(AccountId, ServicesJObj) -> allow_updates(BillingId) end. --spec maybe_allow_updates(ne_binary(), kz_json:object()) -> 'true'. +-spec maybe_allow_updates(kz_term:ne_binary(), kz_json:object()) -> 'true'. maybe_allow_updates(AccountId, ServicesJObj) -> StatusGood = kzd_services:status_good(), case kz_term:is_empty(kz_service_plans:plan_summary(ServicesJObj)) @@ -836,7 +836,7 @@ maybe_allow_updates(AccountId, ServicesJObj) -> maybe_bookkeeper_allow_updates(AccountId, Status) end. --spec maybe_bookkeeper_allow_updates(ne_binary(), ne_binary()) -> 'true'. +-spec maybe_bookkeeper_allow_updates(kz_term:ne_binary(), kz_term:ne_binary()) -> 'true'. maybe_bookkeeper_allow_updates(AccountId, Status) -> Bookkeeper = select_bookkeeper(AccountId), case Bookkeeper:is_good_standing(AccountId, Status) of @@ -850,7 +850,7 @@ maybe_bookkeeper_allow_updates(AccountId, Status) -> throw({<<"account_billing_invalid">>, Error}) end. --spec default_maybe_allow_updates(ne_binary()) -> 'true'. +-spec default_maybe_allow_updates(kz_term:ne_binary()) -> 'true'. default_maybe_allow_updates(AccountId) -> case ?SHOULD_ALLOW_UPDATES of 'true' -> 'true'; @@ -863,12 +863,12 @@ default_maybe_allow_updates(AccountId) -> throw({<<"account_billing_invalid">>, Error}) end. --spec spawn_move_to_good_standing(ne_binary()) -> 'true'. +-spec spawn_move_to_good_standing(kz_term:ne_binary()) -> 'true'. spawn_move_to_good_standing(?MATCH_ACCOUNT_RAW(AccountId)) -> _ = kz_util:spawn(fun move_to_good_standing/1, [AccountId]), 'true'. --spec move_to_good_standing(ne_binary()) -> services(). +-spec move_to_good_standing(kz_term:ne_binary()) -> services(). move_to_good_standing(?MATCH_ACCOUNT_RAW(AccountId)) -> #kz_services{jobj = JObj}=Services = fetch(AccountId), lager:debug("moving account ~s services to good standing", [AccountId]), @@ -881,7 +881,7 @@ move_to_good_standing(?MATCH_ACCOUNT_RAW(AccountId)) -> %% %% @end %%-------------------------------------------------------------------- --spec reconcile_only(api_ne_binary() | services()) -> 'false' | services(). +-spec reconcile_only(kz_term:api_ne_binary() | services()) -> 'false' | services(). reconcile_only('undefined') -> 'false'; reconcile_only(Account=?NE_BINARY) -> reconcile_only(fetch(Account)); @@ -900,7 +900,7 @@ reconcile_module(M, Services) -> M:reconcile(Services). -endif. --spec reconcile(api_ne_binary() | services()) -> 'false' | services(). +-spec reconcile(kz_term:api_ne_binary() | services()) -> 'false' | services(). reconcile('undefined') -> 'false'; reconcile(Account=?NE_BINARY) -> save(reconcile_only(Account)); @@ -913,7 +913,7 @@ reconcile(#kz_services{}=Services) -> %% %% @end %%-------------------------------------------------------------------- --spec reconcile_only(api_binary() | services(), text()) -> 'false' | services(). +-spec reconcile_only(kz_term:api_binary() | services(), kz_term:text()) -> 'false' | services(). reconcile_only('undefined', _Module) -> 'false'; reconcile_only(Account=?NE_BINARY, Module) -> reconcile_only(fetch(Account), Module); @@ -924,7 +924,7 @@ reconcile_only(#kz_services{account_id = _AccountId}=CurrentServices, Module) -> ServiceModule -> reconcile_module(ServiceModule, CurrentServices) end. --spec reconcile(api_binary() | services(), text()) -> 'false' | services(). +-spec reconcile(kz_term:api_binary() | services(), kz_term:text()) -> 'false' | services(). reconcile('undefined', _Module) -> 'false'; reconcile(Account=?NE_BINARY, Module) -> maybe_save(reconcile_only(Account, Module)); @@ -949,7 +949,7 @@ pause_between_service_reconciliation() -> %% %% @end %%-------------------------------------------------------------------- --spec account_id(services()) -> ne_binary(). +-spec account_id(services()) -> kz_term:ne_binary(). account_id(#kz_services{account_id = 'undefined' ,jobj = JObj }) -> @@ -971,7 +971,7 @@ is_services(#kz_services{}) -> true; is_services(_) -> false. -ifdef(TEST). --spec current_billing_id(services()) -> api_ne_binary(). +-spec current_billing_id(services()) -> kz_term:api_ne_binary(). current_billing_id(#kz_services{current_billing_id = CurrentBillingId}) -> CurrentBillingId. @@ -979,7 +979,7 @@ current_billing_id(#kz_services{current_billing_id = CurrentBillingId}) -> is_deleted(#kz_services{deleted = IsDeleted}) -> IsDeleted. --spec status(services()) -> ne_binary(). +-spec status(services()) -> kz_term:ne_binary(). status(#kz_services{status = Status}) -> Status. -endif. @@ -990,7 +990,7 @@ status(#kz_services{status = Status}) -> %% %% @end %%-------------------------------------------------------------------- --spec quantity(ne_binary(), ne_binary(), services()) -> integer(). +-spec quantity(kz_term:ne_binary(), kz_term:ne_binary(), services()) -> integer(). quantity(_, _, #kz_services{deleted = 'true'}) -> 0; quantity(CategoryId, ItemId, #kz_services{updates = Updates ,jobj = JObj @@ -998,14 +998,14 @@ quantity(CategoryId, ItemId, #kz_services{updates = Updates ItemQuantity = kzd_services:item_quantity(JObj, CategoryId, ItemId), kz_json:get_integer_value([CategoryId, ItemId], Updates, ItemQuantity). --spec diff_quantities(services()) -> api_object(). +-spec diff_quantities(services()) -> kz_term:api_object(). diff_quantities(#kz_services{deleted = 'true'}) -> 'undefined'; diff_quantities(#kz_services{jobj = JObj ,updates = Updates }) -> kz_json:foldl(fun diff_cat_quantities/3, Updates, kzd_services:quantities(JObj)). --spec diff_cat_quantities(ne_binary(), kz_json:object(), kz_json:object()) -> kz_json:object(). +-spec diff_cat_quantities(kz_term:ne_binary(), kz_json:object(), kz_json:object()) -> kz_json:object(). diff_cat_quantities(CategoryId, ItemsJObj, Updates) -> kz_json:foldl(fun(I, Q, Acc) -> diff_item_quantities(I, Q, Acc, CategoryId) @@ -1014,7 +1014,7 @@ diff_cat_quantities(CategoryId, ItemsJObj, Updates) -> ,ItemsJObj ). --spec diff_item_quantities(ne_binary(), integer(), kz_json:object(), ne_binary()) -> +-spec diff_item_quantities(kz_term:ne_binary(), integer(), kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). diff_item_quantities(ItemId, ItemQuantity, Updates, CategoryId) -> UpdateQuantity = kz_json:get_integer_value([CategoryId, ItemId], Updates), @@ -1033,7 +1033,7 @@ maybe_update_diff(Key, ItemQuantity, UpdateQuantity, Updates) -> lager:debug("updating ~p from ~p to ~p", [Key, ItemQuantity, UpdateQuantity]), kz_json:set_value(Key, UpdateQuantity - ItemQuantity, Updates). --spec diff_quantity(ne_binary(), ne_binary(), services()) -> integer(). +-spec diff_quantity(kz_term:ne_binary(), kz_term:ne_binary(), services()) -> integer(). diff_quantity(_, _, #kz_services{deleted = 'true'}) -> 0; diff_quantity(CategoryId, ItemId, #kz_services{jobj = JObj ,updates = Updates @@ -1048,7 +1048,7 @@ diff_quantity(CategoryId, ItemId, #kz_services{jobj = JObj %% %% @end %%-------------------------------------------------------------------- --spec updated_quantity(ne_binary(), ne_binary(), services()) -> integer(). +-spec updated_quantity(kz_term:ne_binary(), kz_term:ne_binary(), services()) -> integer(). updated_quantity(_, _, #kz_services{deleted = 'true'}) -> 0; updated_quantity(CategoryId, ItemId, #kz_services{updates = JObj}) -> kz_json:get_integer_value([CategoryId, ItemId], JObj, 0). @@ -1059,11 +1059,11 @@ updated_quantity(CategoryId, ItemId, #kz_services{updates = JObj}) -> %% %% @end %%-------------------------------------------------------------------- --spec category_quantity(ne_binary(), services()) -> non_neg_integer(). +-spec category_quantity(kz_term:ne_binary(), services()) -> non_neg_integer(). category_quantity(CategoryId, Services) -> category_quantity(CategoryId, [], Services). --spec category_quantity(ne_binary(), ne_binaries(), services()) -> non_neg_integer(). +-spec category_quantity(kz_term:ne_binary(), kz_term:ne_binaries(), services()) -> non_neg_integer(). category_quantity(_CategoryId, _ItemExceptions, #kz_services{deleted = 'true'}) -> 0; category_quantity(CategoryId, ItemExceptions, #kz_services{updates = UpdatedQuantities ,jobj = JObj @@ -1082,7 +1082,7 @@ category_quantity(CategoryId, ItemExceptions, #kz_services{updates = UpdatedQuan %% %% @end %%-------------------------------------------------------------------- --spec cascade_quantity(ne_binary(), ne_binary(), services()) -> non_neg_integer(). +-spec cascade_quantity(kz_term:ne_binary(), kz_term:ne_binary(), services()) -> non_neg_integer(). cascade_quantity(_, _, #kz_services{deleted = 'true'}) -> 0; cascade_quantity(CategoryId, ItemId, #kz_services{cascade_quantities = JObj}=Services) -> kz_json:get_integer_value([CategoryId, ItemId], JObj, 0) @@ -1094,11 +1094,11 @@ cascade_quantity(CategoryId, ItemId, #kz_services{cascade_quantities = JObj}=Ser %% %% @end %%-------------------------------------------------------------------- --spec cascade_category_quantity(ne_binary(), services()) -> non_neg_integer(). +-spec cascade_category_quantity(kz_term:ne_binary(), services()) -> non_neg_integer(). cascade_category_quantity(CategoryId, Services) -> cascade_category_quantity(CategoryId, [], Services). --spec cascade_category_quantity(ne_binary(), ne_binaries(), services()) -> non_neg_integer(). +-spec cascade_category_quantity(kz_term:ne_binary(), kz_term:ne_binaries(), services()) -> non_neg_integer(). cascade_category_quantity(_, _, #kz_services{deleted = 'true'}) -> 0; cascade_category_quantity(CategoryId, ItemExceptions, #kz_services{cascade_quantities = Quantities }=Services) -> @@ -1117,7 +1117,7 @@ sum_values(Acc0, JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec reset_category(ne_binary(), services()) -> services(). +-spec reset_category(kz_term:ne_binary(), services()) -> services(). reset_category(CategoryId, #kz_services{updates = JObj}=Services) -> NewUpdates = kz_json:set_value(CategoryId, kz_json:new(), JObj), Services#kz_services{updates = NewUpdates @@ -1130,7 +1130,7 @@ reset_category(CategoryId, #kz_services{updates = JObj}=Services) -> %% Helper function to know if an account is a reseller or not. %% @end %%-------------------------------------------------------------------- --spec is_reseller(ne_binary() | services() | kz_json:object()) -> boolean(). +-spec is_reseller(kz_term:ne_binary() | services() | kz_json:object()) -> boolean(). is_reseller(#kz_services{jobj = ServicesJObj}) -> is_reseller(ServicesJObj); is_reseller(Account=?NE_BINARY) -> @@ -1240,10 +1240,10 @@ calculate_transactions_charge_fold(JObj, PlanCharges) -> %% @end %%-------------------------------------------------------------------- -spec dry_run_activation_charges(services()) -> kz_json:objects(). --spec dry_run_activation_charges(ne_binary(), kz_json:object() +-spec dry_run_activation_charges(kz_term:ne_binary(), kz_json:object() ,services(), kz_json:objects() ) -> kz_json:objects(). --spec dry_run_activation_charges(ne_binary(), ne_binary() +-spec dry_run_activation_charges(kz_term:ne_binary(), kz_term:ne_binary() ,integer(), services() ,kz_json:objects() ) -> kz_json:objects(). @@ -1282,7 +1282,7 @@ dry_run_activation_charges(CategoryId, ItemId, Quantity, #kz_services{jobj = JOb ] end. --spec get_item_plan(ne_binary(), ne_binary(), kzd_service_plan:doc()) -> kz_json:object(). +-spec get_item_plan(kz_term:ne_binary(), kz_term:ne_binary(), kzd_service_plan:doc()) -> kz_json:object(). get_item_plan(CategoryId, ItemId, ServicePlan) -> case kzd_service_plan:item_plan(ServicePlan, CategoryId, ItemId, 'undefined') of 'undefined' -> kzd_service_plan:category_plan(ServicePlan, CategoryId); @@ -1295,7 +1295,7 @@ get_item_plan(CategoryId, ItemId, ServicePlan) -> %% %% @end %%-------------------------------------------------------------------- --spec get_service_modules() -> atoms(). +-spec get_service_modules() -> kz_term:atoms(). get_service_modules() -> case ?DEFAULT_SERVICE_MODULES of [_|_]=ConfModules -> @@ -1308,7 +1308,7 @@ get_service_modules() -> ConfModules end. --spec default_service_modules() -> atoms(). +-spec default_service_modules() -> kz_term:atoms(). default_service_modules() -> ['kz_service_devices' ,'kz_service_ips' @@ -1322,7 +1322,7 @@ default_service_modules() -> ,'kz_service_ratedeck' ]. --spec get_service_module(text()) -> module() | 'false'. +-spec get_service_module(kz_term:text()) -> module() | 'false'. get_service_module(Module) when not is_binary(Module) -> get_service_module(kz_term:to_binary(Module)); get_service_module(<> = Module) -> @@ -1347,7 +1347,7 @@ get_service_module(Module) -> -spec cascade_quantities(services()) -> kz_json:object(). cascade_quantities(#kz_services{cascade_quantities = JObj}) -> JObj. --spec cascade_quantities(ne_binary(), boolean()) -> kz_json:object(). +-spec cascade_quantities(kz_term:ne_binary(), boolean()) -> kz_json:object(). cascade_quantities(Account=?NE_BINARY, 'false') -> lager:debug("computing cascade quantities for ~s", [Account]), do_cascade_quantities(Account, <<"services/cascade_quantities">>); @@ -1355,7 +1355,7 @@ cascade_quantities(Account=?NE_BINARY, 'true') -> lager:debug("computing reseller cascade quantities for ~s", [Account]), do_cascade_quantities(Account, <<"services/reseller_quantities">>). --spec do_cascade_quantities(ne_binary(), ne_binary()) -> kz_json:object(). +-spec do_cascade_quantities(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). do_cascade_quantities(Account, View) -> case cascade_results(View, kz_util:format_account_id(Account)) of {'error', _} -> kz_json:new(); @@ -1430,7 +1430,7 @@ cascade_results(View, AccountId) -> %% definition as this will be depreciated in the future. %% @end %%-------------------------------------------------------------------- --spec depreciated_billing_id(kz_json:object()) -> ne_binary(). +-spec depreciated_billing_id(kz_json:object()) -> kz_term:ne_binary(). depreciated_billing_id(JObj) -> depreciated_billing_id(JObj, kz_doc:account_id(JObj)). @@ -1458,12 +1458,12 @@ depreciated_is_reseller(JObj) -> %% definition as this will be depreciated in the future. %% @end %%-------------------------------------------------------------------- --spec populate_service_plans(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec populate_service_plans(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). populate_service_plans(JObj, ResellerId) -> Plans = incorporate_default_service_plan(ResellerId, master_default_service_plan()), incorporate_depreciated_service_plans(Plans, JObj). --spec default_service_plan_id(ne_binary()) -> api_binary(). +-spec default_service_plan_id(kz_term:ne_binary()) -> kz_term:api_binary(). default_service_plan_id(ResellerId) -> case fetch_services_doc(ResellerId, true) of {'ok', JObj} -> kz_json:get_value(?DEFAULT_PLAN, JObj); @@ -1472,7 +1472,7 @@ default_service_plan_id(ResellerId) -> 'undefined' end. --spec depreciated_default_service_plan_id(ne_binary()) -> api_binary(). +-spec depreciated_default_service_plan_id(kz_term:ne_binary()) -> kz_term:api_binary(). depreciated_default_service_plan_id(ResellerId) -> case fetch_account(ResellerId) of {'ok', JObj} -> kz_json:get_value(?DEFAULT_PLAN, JObj); @@ -1489,7 +1489,7 @@ master_default_service_plan() -> incorporate_default_service_plan(MasterAccountId, kz_json:new()) end. --spec incorporate_default_service_plan(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec incorporate_default_service_plan(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). incorporate_default_service_plan(ResellerId, JObj) -> case depreciated_default_service_plan_id(ResellerId) of 'undefined' -> @@ -1498,7 +1498,7 @@ incorporate_default_service_plan(ResellerId, JObj) -> maybe_augment_with_plan(ResellerId, JObj, PlanId) end. --spec incorporate_only_default_service_plan(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec incorporate_only_default_service_plan(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). incorporate_only_default_service_plan(ResellerId, JObj) -> maybe_augment_with_plan(ResellerId, JObj, default_service_plan_id(ResellerId)). @@ -1532,7 +1532,7 @@ incorporate_depreciated_service_plans(Plans, JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec get_reseller_id(ne_binaries() | ne_binary()) -> ne_binary(). +-spec get_reseller_id(kz_term:ne_binaries() | kz_term:ne_binary()) -> kz_term:ne_binary(). get_reseller_id([]) -> {'ok', MasterAccountId} = master_account_id(), MasterAccountId; @@ -1553,7 +1553,7 @@ get_reseller_id(Account=?NE_BINARY) -> get_reseller_id([]) end. --spec get_reseller_id(ne_binary(), ne_binaries(), kz_json:object()) -> api_binary(). +-spec get_reseller_id(kz_term:ne_binary(), kz_term:ne_binaries(), kz_json:object()) -> kz_term:api_binary(). get_reseller_id(Parent, Ancestors, ServicesJObj) -> case kzd_services:is_reseller(ServicesJObj) of 'false' -> get_reseller_id(Ancestors); @@ -1630,7 +1630,7 @@ any_changed(KeyNotSameFun, Quantities) -> %% %% @end %%-------------------------------------------------------------------- --spec get_account_definition(ne_binary()) -> kz_account:doc(). +-spec get_account_definition(kz_term:ne_binary()) -> kz_account:doc(). get_account_definition(?MATCH_ACCOUNT_RAW(AccountId)) -> case fetch_account(AccountId) of {'error', _R} -> @@ -1664,7 +1664,7 @@ maybe_clean_old_billing_id(#kz_services{}=Services) -> Services. --spec clean(ne_binary()) -> kz_std_return(). +-spec clean(kz_term:ne_binary()) -> kz_term:std_return(). clean(Account) -> AccountId = kz_util:format_account_id(Account), case ?MODULE:fetch_services_doc(AccountId, 'true') of @@ -1673,7 +1673,7 @@ clean(Account) -> immediate_sync(AccountId, kz_doc:set_soft_deleted(ServicesJObj, 'true')) end. --spec immediate_sync(ne_binary(), kzd_services:doc()) -> kz_std_return(). +-spec immediate_sync(kz_term:ne_binary(), kzd_services:doc()) -> kz_term:std_return(). immediate_sync(AccountId, ServicesJObj) -> case kz_service_plans:create_items(ServicesJObj) of {'error', 'no_plans'}=E -> E; @@ -1687,7 +1687,7 @@ immediate_sync(AccountId, ServicesJObj) -> end end. --spec sync(ne_binary()) -> kz_std_return(). +-spec sync(kz_term:ne_binary()) -> kz_term:std_return(). sync(Account) -> AccountId = kz_util:format_account_id(Account), kz_util:put_callid(<>), @@ -1697,7 +1697,7 @@ sync(Account) -> sync(AccountId, ServicesJObj) end. --spec sync(ne_binary(), kz_json:object()) -> kz_std_return(). +-spec sync(kz_term:ne_binary(), kz_json:object()) -> kz_term:std_return(). sync(AccountId, ServicesJObj) -> case get_billing_id(AccountId, ServicesJObj) of AccountId -> maybe_sync_services(AccountId, ServicesJObj); @@ -1709,7 +1709,7 @@ sync(AccountId, ServicesJObj) -> sync(BillingId) end. --spec maybe_sync_services(ne_binary(), kzd_services:doc()) -> kz_std_return(). +-spec maybe_sync_services(kz_term:ne_binary(), kzd_services:doc()) -> kz_term:std_return(). maybe_sync_services(AccountId, ServicesJObj) -> case kz_service_plans:create_items(ServicesJObj) of {'error', 'no_plans'} -> @@ -1721,7 +1721,7 @@ maybe_sync_services(AccountId, ServicesJObj) -> sync_services(AccountId, ServicesJObj, ServiceItems) end. --spec sync_services(ne_binary(), kzd_services:doc(), kz_service_items:items()) -> kz_std_return(). +-spec sync_services(kz_term:ne_binary(), kzd_services:doc(), kz_service_items:items()) -> kz_term:std_return(). sync_services(AccountId, ServicesJObj, ServiceItems) -> try sync_services_bookkeeper(AccountId, ServicesJObj, ServiceItems) of 'ok' -> @@ -1749,7 +1749,7 @@ sync_services(AccountId, ServicesJObj, ServiceItems) -> {'error', R} end. --spec sync_services_bookkeeper(ne_binary(), kz_json:object(), kz_service_items:items()) -> 'ok' | 'delinquent' | 'retry'. +-spec sync_services_bookkeeper(kz_term:ne_binary(), kz_json:object(), kz_service_items:items()) -> 'ok' | 'delinquent' | 'retry'. sync_services_bookkeeper(AccountId, ServicesJObj, ServiceItems) -> Bookkeeper = ?MODULE:select_bookkeeper(AccountId), lager:debug("attempting to sync with bookkeeper ~s", [Bookkeeper]), @@ -1757,8 +1757,8 @@ sync_services_bookkeeper(AccountId, ServicesJObj, ServiceItems) -> maybe_sync_transactions(AccountId, ServicesJObj, Bookkeeper), Result. --spec maybe_sync_transactions(ne_binary(), kzd_services:doc()) -> 'ok'. --spec maybe_sync_transactions(ne_binary(), kzd_services:doc(), atom()) -> 'ok'. +-spec maybe_sync_transactions(kz_term:ne_binary(), kzd_services:doc()) -> 'ok'. +-spec maybe_sync_transactions(kz_term:ne_binary(), kzd_services:doc(), atom()) -> 'ok'. maybe_sync_transactions(AccountId, ServicesJObj) -> Bookkeeper = ?MODULE:select_bookkeeper(AccountId), maybe_sync_transactions(AccountId, ServicesJObj, Bookkeeper). @@ -1771,7 +1771,7 @@ maybe_sync_transactions(AccountId, ServicesJObj, Bookkeeper) -> sync_transactions(AccountId, ServicesJObj, Bookkeeper, Transactions) end. --spec maybe_delete_topup_transaction(ne_binary(), kz_json:objects()) -> kz_json:objects(). +-spec maybe_delete_topup_transaction(kz_term:ne_binary(), kz_json:objects()) -> kz_json:objects(). maybe_delete_topup_transaction(AccountId, Transactions) -> NonTopup = lists:filter( fun(J) -> @@ -1787,7 +1787,7 @@ maybe_delete_topup_transaction(AccountId, Transactions) -> end end. --spec sync_transactions(ne_binary(), kzd_services:doc(), atom(), kz_json:objects()) -> +-spec sync_transactions(kz_term:ne_binary(), kzd_services:doc(), atom(), kz_json:objects()) -> 'ok'. sync_transactions(AccountId, ServicesJObj, Bookkeeper, Transactions) -> BillingId = kzd_services:billing_id(ServicesJObj), @@ -1802,7 +1802,7 @@ sync_transactions(AccountId, ServicesJObj, Bookkeeper, Transactions) -> handle_topup_transactions(AccountId, Transactions, FailedTransactions) end. --spec handle_topup_transactions(ne_binary(), kz_json:objects(), kz_json:objects() | integer()) -> 'ok'. +-spec handle_topup_transactions(kz_term:ne_binary(), kz_json:objects(), kz_json:objects() | integer()) -> 'ok'. handle_topup_transactions(Account, JObjs, Failed) when is_list(Failed) -> case did_topup_failed(Failed) of 'true' -> 'ok'; @@ -1843,7 +1843,7 @@ did_topup_failed(JObjs) -> ,JObjs ). --spec maybe_sync_reseller(ne_binary(), kzd_services:doc()) -> kz_std_return(). +-spec maybe_sync_reseller(kz_term:ne_binary(), kzd_services:doc()) -> kz_term:std_return(). maybe_sync_reseller(AccountId, ServicesJObj) -> case kzd_services:reseller_id(ServicesJObj, AccountId) of AccountId -> {'ok', ServicesJObj}; @@ -1852,7 +1852,7 @@ maybe_sync_reseller(AccountId, ServicesJObj) -> mark_dirty(ResellerId) end. --spec get_billing_id(ne_binary(), kzd_services:doc()) -> ne_binary(). +-spec get_billing_id(kz_term:ne_binary(), kzd_services:doc()) -> kz_term:ne_binary(). get_billing_id(AccountId, ServicesJObj) -> case kzd_services:is_reseller(ServicesJObj) of 'true' -> AccountId; @@ -1863,7 +1863,7 @@ get_billing_id(AccountId, ServicesJObj) -> end end. --spec mark_dirty(ne_binary() | kzd_services:doc()) -> kz_std_return(). +-spec mark_dirty(kz_term:ne_binary() | kzd_services:doc()) -> kz_term:std_return(). mark_dirty(?MATCH_ACCOUNT_RAW(AccountId)) -> case ?MODULE:fetch_services_doc(AccountId, 'true') of {'error', _}=E -> E; @@ -1875,7 +1875,7 @@ mark_dirty(ServicesJObj) -> ], kz_datamgr:save_doc(?KZ_SERVICES_DB, kz_json:set_values(Values, ServicesJObj)). --spec mark_clean_and_status(ne_binary(), kzd_services:doc()) -> kz_std_return(). +-spec mark_clean_and_status(kz_term:ne_binary(), kzd_services:doc()) -> kz_term:std_return(). mark_clean_and_status(Status, ServicesJObj) -> lager:debug("marking services clean with status ~s", [Status]), Values = [{?SERVICES_PVT_IS_DIRTY, 'false'} diff --git a/core/kazoo_services/src/kz_services_modb.erl b/core/kazoo_services/src/kz_services_modb.erl index 4e876e2e709..164250927e0 100644 --- a/core/kazoo_services/src/kz_services_modb.erl +++ b/core/kazoo_services/src/kz_services_modb.erl @@ -17,13 +17,13 @@ -include_lib("kazoo_transactions/include/kazoo_transactions.hrl"). -include_lib("kazoo_services/include/kazoo_services.hrl"). --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> _Pid = kz_util:spawn(fun kazoo_modb:add_routine/1, [?MODULE]), io:format("started services modb add_rountine in ~p~n", [_Pid]), 'ignore'. --spec modb(ne_binary()) -> 'ok'. +-spec modb(kz_term:ne_binary()) -> 'ok'. modb(?MATCH_MODB_SUFFIX_ENCODED(_AccountId, _Year, _Month) = AccountMODb) -> modb(kz_util:format_account_modb(AccountMODb, 'raw')); modb(?MATCH_MODB_SUFFIX_RAW(AccountId, _Year, _Month) = AccountMODb) -> @@ -31,13 +31,13 @@ modb(?MATCH_MODB_SUFFIX_RAW(AccountId, _Year, _Month) = AccountMODb) -> save_services_to_modb(AccountMODb, ServicesJObj, ?SERVICES_BOM), maybe_save_to_previous_modb(AccountMODb, ServicesJObj). --spec save_services_to_modb(ne_binary(), kz_json:object(), ne_binary()) -> 'ok'. +-spec save_services_to_modb(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> 'ok'. save_services_to_modb(AccountMODb, ServicesJObj, Id) -> MODbDoc = update_pvts(AccountMODb, ServicesJObj, Id), kazoo_modb:save_doc(AccountMODb, MODbDoc), 'ok'. --spec maybe_save_to_previous_modb(ne_binary(), kz_json:object()) -> 'ok'. +-spec maybe_save_to_previous_modb(kz_term:ne_binary(), kz_json:object()) -> 'ok'. maybe_save_to_previous_modb(NewMODb, ServicesJObj) -> PrevMODb = kazoo_modb_util:prev_year_month_mod(NewMODb), AccountDb = kz_util:format_account_modb(PrevMODb, 'encoded'), @@ -46,7 +46,7 @@ maybe_save_to_previous_modb(NewMODb, ServicesJObj) -> 'false' -> 'ok' end. --spec update_pvts(ne_binary(), kz_json:object(), ne_binary()) -> kz_json:object(). +-spec update_pvts(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). update_pvts(?MATCH_MODB_SUFFIX_RAW(AccountId, _Year, _Month) = AccountMODb, ServicesJObj, Id) -> kz_doc:update_pvt_parameters(kz_json:delete_key(<<"_rev">>, kz_doc:set_id(ServicesJObj, Id)) ,AccountMODb diff --git a/core/kazoo_services/src/services/kz_service_billing.erl b/core/kazoo_services/src/services/kz_service_billing.erl index be41a766d5f..94c94b317cf 100644 --- a/core/kazoo_services/src/services/kz_service_billing.erl +++ b/core/kazoo_services/src/services/kz_service_billing.erl @@ -52,7 +52,7 @@ reconcile_fold(JObj, S) -> %% %% @end %%-------------------------------------------------------------------- --spec reconcile(kz_services:services(), api_binary()) -> kz_services:services(). +-spec reconcile(kz_services:services(), kz_term:api_binary()) -> kz_services:services(). reconcile(Services, 'undefined') -> Services; reconcile(Services0, Item) -> Services1 = reconcile(Services0), diff --git a/core/kazoo_services/src/services/kz_service_devices.erl b/core/kazoo_services/src/services/kz_service_devices.erl index 7e3bcd295ff..deea466476a 100644 --- a/core/kazoo_services/src/services/kz_service_devices.erl +++ b/core/kazoo_services/src/services/kz_service_devices.erl @@ -22,7 +22,7 @@ %% @end %%-------------------------------------------------------------------- -spec reconcile(kz_services:services()) -> kz_services:services(). --spec reconcile(kz_services:services(), api_binary() | kz_json:object()) -> kz_services:services(). +-spec reconcile(kz_services:services(), kz_term:api_binary() | kz_json:object()) -> kz_services:services(). reconcile(Services) -> AccountId = kz_services:account_id(Services), AccountDb = kz_util:format_account_id(AccountId, 'encoded'), @@ -56,7 +56,7 @@ reconcile(Services, <<_/binary>> = DeviceType) -> do_reconcile(Services, DeviceType) end. --spec do_reconcile(kz_services:services(), ne_binary()) -> kz_services:services(). +-spec do_reconcile(kz_services:services(), kz_term:ne_binary()) -> kz_services:services(). do_reconcile(Services, DeviceType) -> Quantity = kz_services:quantity(?CATEGORY, DeviceType, Services), lager:debug("increment ~s.~s to ~p+1", [?CATEGORY, DeviceType, Quantity]), diff --git a/core/kazoo_services/src/services/kz_service_ips.erl b/core/kazoo_services/src/services/kz_service_ips.erl index 7efacd75d37..755d263ef26 100644 --- a/core/kazoo_services/src/services/kz_service_ips.erl +++ b/core/kazoo_services/src/services/kz_service_ips.erl @@ -19,7 +19,7 @@ %% @end %%-------------------------------------------------------------------- -spec reconcile(kz_services:services()) -> kz_services:services(). --spec reconcile(kz_services:services(), api_binary() | kz_proplist()) -> +-spec reconcile(kz_services:services(), kz_term:api_binary() | kz_term:proplist()) -> kz_services:services(). reconcile(Services) -> AccountId = kz_services:account_id(Services), @@ -44,7 +44,7 @@ reconcile(Services, Props) -> ,Props ). --spec reconcile_foldl({ne_binary(), integer() | ne_binary()}, kz_services:services()) -> +-spec reconcile_foldl({kz_term:ne_binary(), integer() | kz_term:ne_binary()}, kz_services:services()) -> kz_services:services(). reconcile_foldl({Type, Quantity}, Services) -> OldQuantity = kz_services:updated_quantity(<<"ips">>, Type, Services), diff --git a/core/kazoo_services/src/services/kz_service_ledgers.erl b/core/kazoo_services/src/services/kz_service_ledgers.erl index e59b949b7d1..f9ed59846d7 100644 --- a/core/kazoo_services/src/services/kz_service_ledgers.erl +++ b/core/kazoo_services/src/services/kz_service_ledgers.erl @@ -21,7 +21,7 @@ %% @end %%-------------------------------------------------------------------- -spec reconcile(kz_services:services()) -> kz_services:services(). --spec reconcile(kz_services:services(), ne_binary() | kz_proplist()) -> kz_services:services(). +-spec reconcile(kz_services:services(), kz_term:ne_binary() | kz_term:proplist()) -> kz_services:services(). reconcile(Services) -> AccountId = kz_services:account_id(Services), case kz_ledgers:get(AccountId) of @@ -51,7 +51,7 @@ reconcile(Services, Props) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec reconcile_foldl({ne_binary(), integer() | ne_binary()}, kz_services:services()) -> kz_services:services(). +-spec reconcile_foldl({kz_term:ne_binary(), integer() | kz_term:ne_binary()}, kz_services:services()) -> kz_services:services(). reconcile_foldl({Type, Quantity}, Services) -> OldQuantity = kz_services:updated_quantity(?CATEGORY, Type, Services), kz_services:update(?CATEGORY diff --git a/core/kazoo_services/src/services/kz_service_phone_numbers.erl b/core/kazoo_services/src/services/kz_service_phone_numbers.erl index 9a30c3742ce..43f67380c54 100644 --- a/core/kazoo_services/src/services/kz_service_phone_numbers.erl +++ b/core/kazoo_services/src/services/kz_service_phone_numbers.erl @@ -60,7 +60,7 @@ reconcile(Services, PNs) -> reset(Services) -> reset(Services, ?DEFAULT_RESET_CATEGORIES). --spec reset(kz_services:services(), ne_binaries()) -> kz_services:services(). +-spec reset(kz_services:services(), kz_term:ne_binaries()) -> kz_services:services(). reset(Services, []) -> Services; reset(Services, [Category | Categories]) -> reset(kz_services:reset_category(Category, Services), Categories). @@ -71,7 +71,7 @@ reset(Services, [Category | Categories]) -> %% %% @end %%-------------------------------------------------------------------- --spec feature_activation_charge(ne_binary(), kz_services:services()) -> integer(). +-spec feature_activation_charge(kz_term:ne_binary(), kz_services:services()) -> integer(). feature_activation_charge(Feature, Services) -> Name = knm_providers:service_name(Feature, kz_services:account_id(Services)), Charge = kz_services:activation_charges(?NUMBER_SERVICES, Name, Services), @@ -83,7 +83,7 @@ feature_activation_charge(Feature, Services) -> %% %% @end %%-------------------------------------------------------------------- --spec phone_number_activation_charge(kz_services:services(), ne_binary()) -> integer(). +-spec phone_number_activation_charge(kz_services:services(), kz_term:ne_binary()) -> integer(). phone_number_activation_charge(Services, Number) -> case knm_converters:classify(Number) of 'undefined' -> 0; @@ -95,14 +95,14 @@ phone_number_activation_charge(Services, Number) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec update_categories_fold(ne_binary(), ne_binary(), kz_services:services(), kz_json:object()) -> kz_json:object(). +-spec update_categories_fold(kz_term:ne_binary(), kz_term:ne_binary(), kz_services:services(), kz_json:object()) -> kz_json:object(). update_categories_fold(Path, Category, Services, JObj) -> kz_json:foldl(fun (SubCat, Count, S) -> update_quantities_fold(SubCat, Count, S, Category) end ,kz_services:reset_category(Category, Services) ,kz_json:get_value(Path, JObj) ). --spec update_quantities_fold(ne_binary(), non_neg_integer(), kz_services:services(), ne_binary()) -> kz_services:services(). +-spec update_quantities_fold(kz_term:ne_binary(), non_neg_integer(), kz_services:services(), kz_term:ne_binary()) -> kz_services:services(). update_quantities_fold(Feature, Count, Services, ?NUMBER_SERVICES=Category) -> Name = knm_providers:service_name(Feature, kz_services:account_id(Services)), Quantity = kz_services:updated_quantity(Category, Name, Services), @@ -124,7 +124,7 @@ sum_carriers_per_class(Carriers) -> Count + Sum end, 0, Carriers). --spec manually_update_nested_quantities_fold(ne_binary(), non_neg_integer(), kz_services:services()) -> kz_services:services(). +-spec manually_update_nested_quantities_fold(kz_term:ne_binary(), non_neg_integer(), kz_services:services()) -> kz_services:services(). manually_update_nested_quantities_fold(Carrier, Count, S) -> Cat = ?NUMBER_CARRIERS, Q = kz_services:updated_quantity(Cat, Carrier, S), @@ -172,7 +172,7 @@ is_number_billable(PN) -> IsBillable. %% @private --spec update_feature_quantities(ne_binaries(), kz_services:services()) -> kz_services:services(). +-spec update_feature_quantities(kz_term:ne_binaries(), kz_services:services()) -> kz_services:services(). update_feature_quantities([], Services) -> Services; update_feature_quantities([Feature|Features], Services) -> Name = knm_providers:service_name(Feature, kz_services:account_id(Services)), diff --git a/core/kazoo_services/src/services/kz_service_ratedeck.erl b/core/kazoo_services/src/services/kz_service_ratedeck.erl index d2ea7390b13..146a2197558 100644 --- a/core/kazoo_services/src/services/kz_service_ratedeck.erl +++ b/core/kazoo_services/src/services/kz_service_ratedeck.erl @@ -23,7 +23,7 @@ %% @end %%-------------------------------------------------------------------- -spec reconcile(kz_services:services()) -> kz_services:services(). --spec reconcile(kz_services:services(), api_binary()) -> kz_services:services(). +-spec reconcile(kz_services:services(), kz_term:api_binary()) -> kz_services:services(). reconcile(Services) -> ServicePlanJObj = kz_services:service_plan_json(Services), %% TODO: resolve conflict when there is more than one ratedeck @@ -43,7 +43,7 @@ reconcile(Services) -> reconcile(Services, 'undefined') -> kz_services:reset_category(?SERVICE_CATEGORY, Services); reconcile(Services, RatedeckId) -> kz_services:update(?SERVICE_CATEGORY, RatedeckId, 1, Services). --spec get_ratedeck(api_binary() | kzd_service_plan:doc()) -> api_binary(). +-spec get_ratedeck(kz_term:api_binary() | kzd_service_plan:doc()) -> kz_term:api_binary(). get_ratedeck('undefined') -> 'undefined'; get_ratedeck(<<_/binary>> = AccountId) -> get_ratedeck(kz_services:service_plan_json(AccountId)); diff --git a/core/kazoo_services/src/services/kz_service_ratedeck_name.erl b/core/kazoo_services/src/services/kz_service_ratedeck_name.erl index 32bf1132e22..f667aab5c46 100644 --- a/core/kazoo_services/src/services/kz_service_ratedeck_name.erl +++ b/core/kazoo_services/src/services/kz_service_ratedeck_name.erl @@ -23,7 +23,7 @@ %% @end %%-------------------------------------------------------------------- -spec reconcile(kz_services:services()) -> kz_services:services(). --spec reconcile(kz_services:services(), api_binary()) -> kz_services:services(). +-spec reconcile(kz_services:services(), kz_term:api_binary()) -> kz_services:services(). reconcile(Services) -> ServicePlanJObj = kz_services:service_plan_json(Services), %% TODO: resolve conflict when there is more than one ratedeck @@ -45,7 +45,7 @@ reconcile(Services, 'undefined') -> reconcile(Services, RatedeckName) -> kz_services:update(?SERVICE_CATEGORY, RatedeckName, 1, Services). --spec get_ratedeck_name(api_binary() | kzd_service_plan:doc()) -> api_binary(). +-spec get_ratedeck_name(kz_term:api_binary() | kzd_service_plan:doc()) -> kz_term:api_binary(). get_ratedeck_name('undefined') -> 'undefined'; get_ratedeck_name(<<_/binary>> = AccountId) -> get_ratedeck_name(kz_services:service_plan_json(AccountId)); diff --git a/core/kazoo_services/src/services/kz_service_transactions.erl b/core/kazoo_services/src/services/kz_service_transactions.erl index 02c76359b91..d75652dedab 100644 --- a/core/kazoo_services/src/services/kz_service_transactions.erl +++ b/core/kazoo_services/src/services/kz_service_transactions.erl @@ -20,12 +20,12 @@ %% %% @end %%-------------------------------------------------------------------- --spec current_billing_period(ne_binary(), atom()) -> +-spec current_billing_period(kz_term:ne_binary(), atom()) -> kz_json:objects() | atom(). current_billing_period(AccountId, 'subscriptions') -> kz_bookkeeper_braintree:subscriptions(AccountId). --spec current_billing_period(ne_binary(), atom(), {gregorian_seconds(), gregorian_seconds()}) -> +-spec current_billing_period(kz_term:ne_binary(), atom(), {kz_time:gregorian_seconds(), kz_time:gregorian_seconds()}) -> {'error', 'not_found'} | {'error', 'unknown_error'} | {'ok', kz_transaction:transactions()}. diff --git a/core/kazoo_services/src/services/kz_service_ui_apps.erl b/core/kazoo_services/src/services/kz_service_ui_apps.erl index ec634e013b9..e939f08c59a 100644 --- a/core/kazoo_services/src/services/kz_service_ui_apps.erl +++ b/core/kazoo_services/src/services/kz_service_ui_apps.erl @@ -24,7 +24,7 @@ %% @end %%-------------------------------------------------------------------- -spec reconcile(kz_services:services()) -> kz_services:services(). --spec reconcile(kz_services:services(), ne_binary()) -> kz_services:services(). +-spec reconcile(kz_services:services(), kz_term:ne_binary()) -> kz_services:services(). reconcile(Services) -> AccountId = kz_services:account_id(Services), case kz_datamgr:open_doc(?ACCOUNTS_DB, AccountId) of diff --git a/core/kazoo_services/src/services/kz_service_users.erl b/core/kazoo_services/src/services/kz_service_users.erl index 83a6a18f497..1fbbb143b7c 100644 --- a/core/kazoo_services/src/services/kz_service_users.erl +++ b/core/kazoo_services/src/services/kz_service_users.erl @@ -22,7 +22,7 @@ %% @end %%-------------------------------------------------------------------- -spec reconcile(kz_services:services()) -> kz_services:services(). --spec reconcile(kz_services:services(), ne_binary()) -> kz_services:services(). +-spec reconcile(kz_services:services(), kz_term:ne_binary()) -> kz_services:services(). reconcile(Services) -> AccountId = kz_services:account_id(Services), AccountDb = kz_util:format_account_id(AccountId, 'encoded'), diff --git a/core/kazoo_services/src/services/kz_service_whitelabel.erl b/core/kazoo_services/src/services/kz_service_whitelabel.erl index 03e4bf35328..c5b8faf4d23 100644 --- a/core/kazoo_services/src/services/kz_service_whitelabel.erl +++ b/core/kazoo_services/src/services/kz_service_whitelabel.erl @@ -25,7 +25,7 @@ %% @end %%-------------------------------------------------------------------- -spec reconcile(kz_services:services()) -> kz_services:services(). --spec reconcile(kz_services:services(), ne_binary()) -> kz_services:services(). +-spec reconcile(kz_services:services(), kz_term:ne_binary()) -> kz_services:services(). reconcile(Services) -> AccountId = kz_services:account_id(Services), AccountDb = kz_util:format_account_id(AccountId, 'encoded'), diff --git a/core/kazoo_services/src/whs_account_conversion.erl b/core/kazoo_services/src/whs_account_conversion.erl index 49ea0180a07..d1416d94f5c 100644 --- a/core/kazoo_services/src/whs_account_conversion.erl +++ b/core/kazoo_services/src/whs_account_conversion.erl @@ -26,7 +26,7 @@ %% sub accounts %% @end %%-------------------------------------------------------------------- --spec promote(ne_binary()) -> {'error', _} | 'ok'. +-spec promote(kz_term:ne_binary()) -> {'error', _} | 'ok'. promote(Account) -> AccountId = kz_util:format_account_id(Account, 'raw'), case kapps_util:is_master_account(AccountId) of @@ -38,12 +38,12 @@ promote(Account) -> end end. --spec force_promote(ne_binary()) -> {'error', _} | 'ok'. +-spec force_promote(kz_term:ne_binary()) -> {'error', _} | 'ok'. force_promote(Account) -> AccountId = kz_util:format_account_id(Account, 'raw'), do_promote(AccountId). --spec do_promote(ne_binary()) -> {'error', _} | 'ok'. +-spec do_promote(kz_term:ne_binary()) -> {'error', _} | 'ok'. do_promote(AccountId) -> _ = kz_util:account_update(AccountId, fun kz_account:promote/1), _ = maybe_update_services(AccountId, ?SERVICES_PVT_IS_RESELLER, 'true'), @@ -57,7 +57,7 @@ do_promote(AccountId) -> %% to the next higher reseller %% @end %%-------------------------------------------------------------------- --spec demote(ne_binary()) -> {'error', _} | 'ok'. +-spec demote(kz_term:ne_binary()) -> {'error', _} | 'ok'. demote(Account) -> AccountId = kz_util:format_account_id(Account, 'raw'), case kapps_util:is_master_account(AccountId) of @@ -69,12 +69,12 @@ demote(Account) -> end end. --spec force_demote(ne_binary()) -> {'error', _} | 'ok'. +-spec force_demote(kz_term:ne_binary()) -> {'error', _} | 'ok'. force_demote(Account) -> AccountId = kz_util:format_account_id(Account, 'raw'), do_demote(AccountId). --spec do_demote(ne_binary()) -> {'error', _} | 'ok'. +-spec do_demote(kz_term:ne_binary()) -> {'error', _} | 'ok'. do_demote(AccountId) -> _ = kz_util:account_update(AccountId, fun kz_account:demote/1), _ = maybe_update_services(AccountId, ?SERVICES_PVT_IS_RESELLER, 'false'), @@ -89,7 +89,7 @@ do_demote(AccountId) -> %% of the provided account %% @end %%-------------------------------------------------------------------- --spec cascade_reseller_id(ne_binary(), ne_binary()) -> {'error', _} | 'ok'. +-spec cascade_reseller_id(kz_term:ne_binary(), kz_term:ne_binary()) -> {'error', _} | 'ok'. cascade_reseller_id(Reseller, Account) -> AccountId = kz_util:format_account_id(Account, 'raw'), ResellerId = kz_util:format_account_id(Reseller, 'raw'), @@ -114,7 +114,7 @@ cascade_reseller_id(Reseller, Account) -> %% Set teh reseller_id to the provided value on the provided account %% @end %%-------------------------------------------------------------------- --spec set_reseller_id(ne_binary(), ne_binary()) -> {'error', _} | 'ok'. +-spec set_reseller_id(kz_term:ne_binary(), kz_term:ne_binary()) -> {'error', _} | 'ok'. set_reseller_id(Reseller, Account) -> AccountId = kz_util:format_account_id(Account, 'raw'), ResellerId = kz_util:format_account_id(Reseller, 'raw'), @@ -128,7 +128,7 @@ set_reseller_id(Reseller, Account) -> %% %% @end %%-------------------------------------------------------------------- --spec maybe_update_services(ne_binary(), ne_binary(), any()) -> {'error', _} | 'ok'. +-spec maybe_update_services(kz_term:ne_binary(), kz_term:ne_binary(), any()) -> {'error', _} | 'ok'. maybe_update_services(AccountId, Key, Value) -> case kz_services:fetch_services_doc(AccountId, true) of {'error', _R}=Error -> @@ -143,7 +143,7 @@ maybe_update_services(AccountId, Key, Value) -> end end. --spec has_reseller_descendants(ne_binary()) -> boolean(). +-spec has_reseller_descendants(kz_term:ne_binary()) -> boolean(). has_reseller_descendants(AccountId) -> %% its very important that this check not operate against stale data! _ = kz_datamgr:flush_cache_docs(?KZ_SERVICES_DB), diff --git a/core/kazoo_sip/src/kzsip_diversion.erl b/core/kazoo_sip/src/kzsip_diversion.erl index dadf5f89c16..db19befd08d 100644 --- a/core/kazoo_sip/src/kzsip_diversion.erl +++ b/core/kazoo_sip/src/kzsip_diversion.erl @@ -45,14 +45,14 @@ -spec new() -> diversion(). new() -> kz_json:new(). --spec reason(diversion()) -> api_binary(). +-spec reason(diversion()) -> kz_term:api_binary(). -spec counter(diversion()) -> non_neg_integer(). --spec limit(diversion()) -> api_integer(). --spec privacy(diversion()) -> api_binary(). --spec screen(diversion()) -> api_binary(). --spec extensions(diversion()) -> api_list(). --spec address(diversion()) -> api_binary(). --spec user(diversion()) -> api_binary(). +-spec limit(diversion()) -> kz_term:api_integer(). +-spec privacy(diversion()) -> kz_term:api_binary(). +-spec screen(diversion()) -> kz_term:api_binary(). +-spec extensions(diversion()) -> kz_term:api_list(). +-spec address(diversion()) -> kz_term:api_binary(). +-spec user(diversion()) -> kz_term:api_binary(). user(JObj) -> kzsip_uri:user(kzsip_uri:parse(address(JObj))). @@ -75,16 +75,16 @@ extensions(JObj) -> lists:foldl(fun extensions_fold/2, [], kz_json:to_proplist(Extensions)) end. --spec extensions_fold({ne_binary(), ne_binary()}, kz_proplist()) -> - kz_proplist(). +-spec extensions_fold({kz_term:ne_binary(), kz_term:ne_binary()}, kz_term:proplist()) -> + kz_term:proplist(). extensions_fold({K, ?SOLO_EXTENSION}, Acc) -> [K | Acc]; extensions_fold({_K, _V}=Extention, Acc) -> [Extention | Acc]. --spec set_user(diversion(), ne_binary()) -> diversion(). --spec set_address(diversion(), ne_binary()) -> diversion(). --spec set_reason(diversion(), ne_binary()) -> diversion(). +-spec set_user(diversion(), kz_term:ne_binary()) -> diversion(). +-spec set_address(diversion(), kz_term:ne_binary()) -> diversion(). +-spec set_reason(diversion(), kz_term:ne_binary()) -> diversion(). -spec set_counter(diversion(), non_neg_integer()) -> diversion(). set_user(JObj, User) -> @@ -98,7 +98,7 @@ set_reason(JObj, Reason) -> set_counter(JObj, Counter) -> kz_json:set_value(?PARAM_COUNTER, Counter, JObj). --spec from_binary(ne_binary()) -> kz_json:object(). +-spec from_binary(kz_term:ne_binary()) -> kz_json:object(). from_binary(<<"Diversion:", Header/binary>>) -> from_binary(Header); from_binary(Header) -> @@ -109,12 +109,12 @@ from_binary(Header) -> parse_params(Rest, kz_json:set_value(?PARAM_ADDRESS, Name, kz_json:new())) end. --spec parse_name_addr_header(ne_binary()) -> {binary(), ne_binary()}. +-spec parse_name_addr_header(kz_term:ne_binary()) -> {binary(), kz_term:ne_binary()}. parse_name_addr_header(Header) -> Start = lists:foldl(fun name_addr_start/2, Header, [$\n, $\s]), parse_name_addr({Start, []}). --spec parse_name_addr({binary(), list()}) -> {binary(), ne_binary()}. +-spec parse_name_addr({binary(), list()}) -> {binary(), kz_term:ne_binary()}. parse_name_addr({<<"<", Header/binary>>, Acc}) -> parse_name_addr(parse_name_addr_angle(Header, [$< | Acc])); parse_name_addr({<<"\"", Header/binary>>, Acc}) -> @@ -130,40 +130,40 @@ parse_name_addr({<<>>, Acc}) -> parse_name_addr({<>, Acc}) -> parse_name_addr({Header, [C | Acc]}). --spec parse_name_addr_angle(ne_binary(), iolist()) -> +-spec parse_name_addr_angle(kz_term:ne_binary(), iolist()) -> {binary(), iolist()}. parse_name_addr_angle(<<">", Header/binary>>, Acc) -> {kz_binary:strip(Header), [$> | Acc]}; parse_name_addr_angle(<>, Acc) -> parse_name_addr_angle(Header, [C | Acc]). --spec parse_name_addr_double_quote(ne_binary(), iolist()) -> +-spec parse_name_addr_double_quote(kz_term:ne_binary(), iolist()) -> {binary(), iolist()}. parse_name_addr_double_quote(<<"\"", Header/binary>>, Acc) -> {Header, [$" | Acc]}; parse_name_addr_double_quote(<>, Acc) -> parse_name_addr_double_quote(Header, [C | Acc]). --spec parse_name_addr_single_quote(ne_binary(), iolist()) -> +-spec parse_name_addr_single_quote(kz_term:ne_binary(), iolist()) -> {binary(), iolist()}. parse_name_addr_single_quote(<<"'", Header/binary>>, Acc) -> {Header, [$' | Acc]}; parse_name_addr_single_quote(<>, Acc) -> parse_name_addr_single_quote(Header, [C | Acc]). --spec name_addr_start(char(), ne_binary()) -> ne_binary(). +-spec name_addr_start(char(), kz_term:ne_binary()) -> kz_term:ne_binary(). name_addr_start(Char, Bin) -> kz_binary:strip_left(Bin, Char). --spec parse_params(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec parse_params(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). parse_params(Params, JObj) -> case binary:split(Params, <<";">>, ['trim']) of [Param] -> parse_param(Param, JObj); [Param, Rest] -> parse_params(Rest, parse_param(Param, JObj)) end. --spec parse_param(ne_binary(), kz_json:object()) -> kz_json:object(). --spec parse_param(ne_binary(), ne_binary(), kz_json:object()) -> kz_json:object(). +-spec parse_param(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). +-spec parse_param(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). parse_param(Param, JObj) -> case binary:split(Param, <<"=">>, ['trim']) of [Name, Value] -> @@ -198,7 +198,7 @@ add_extension(Extension, JObj) -> ,JObj ). --spec add_extension(ne_binary(), ne_binary(), kz_json:object()) -> +-spec add_extension(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). add_extension(Extension, Value, JObj) -> Extensions = kz_json:get_value(?PARAM_EXTENSION, JObj, kz_json:new()), @@ -237,7 +237,7 @@ parse_privacy_param(Privacy) -> parse_screen_param(Screen) -> parse_param_value(Screen, ?PARAM_SCREEN_LITERALS). --spec parse_param_value(ne_binary(), ne_binaries()) -> ne_binary(). +-spec parse_param_value(kz_term:ne_binary(), kz_term:ne_binaries()) -> kz_term:ne_binary(). parse_param_value(<<"\"", _/binary>> = Param, _Literals) -> parse_quoted_param(Param); parse_param_value(<<"'", _/binary>> = Param, _Literals) -> @@ -251,7 +251,7 @@ parse_param_value(Param, [Literal | Literals]) -> parse_param_value(Param, []) -> parse_token_param(Param). --spec parse_token_param(ne_binary(), iolist()) -> binary(). +-spec parse_token_param(kz_term:ne_binary(), iolist()) -> binary(). parse_token_param(Token) -> parse_token_param(Token, []). parse_token_param(<<$\s, _/binary>>, Acc) -> @@ -263,46 +263,46 @@ parse_token_param(<<>>, Acc) -> parse_token_param(<>, Acc) -> parse_token_param(Token, [C | Acc]). --spec parse_quoted_param(ne_binary()) -> ne_binary(). +-spec parse_quoted_param(kz_term:ne_binary()) -> kz_term:ne_binary(). parse_quoted_param(<<"\"", Quoted/binary>>) -> parse_double_quoted_param(Quoted, []); parse_quoted_param(<<"'", Quoted/binary>>) -> parse_single_quoted_param(Quoted, []). --spec parse_double_quoted_param(ne_binary(), iolist()) -> ne_binary(). +-spec parse_double_quoted_param(kz_term:ne_binary(), iolist()) -> kz_term:ne_binary(). parse_double_quoted_param(<<"\"", _/binary>>, Acc) -> list_to_binary(lists:reverse(Acc)); parse_double_quoted_param(<>, Acc) -> parse_double_quoted_param(Quoted, [C | Acc]). --spec parse_single_quoted_param(ne_binary(), iolist()) -> ne_binary(). +-spec parse_single_quoted_param(kz_term:ne_binary(), iolist()) -> kz_term:ne_binary(). parse_single_quoted_param(<<"'", _/binary>>, Acc) -> list_to_binary(lists:reverse(Acc)); parse_single_quoted_param(<>, Acc) -> parse_single_quoted_param(Quoted, [C | Acc]). --spec maybe_unquote(ne_binary()) -> ne_binary(). +-spec maybe_unquote(kz_term:ne_binary()) -> kz_term:ne_binary(). maybe_unquote(<<"\"", Value/binary>>) -> kz_binary:truncate_right(Value, byte_size(Value)-1); maybe_unquote(Value) -> Value. --spec to_binary(kz_json:object()) -> ne_binary(). +-spec to_binary(kz_json:object()) -> kz_term:ne_binary(). to_binary(JObj) -> Address = kz_json:get_value(?PARAM_ADDRESS, JObj), maybe_add_params(JObj, fix_address(Address)). --spec fix_address(ne_binary()) -> ne_binary(). +-spec fix_address(kz_term:ne_binary()) -> kz_term:ne_binary(). fix_address(<<$", _Rest/binary>> = Address) -> Address; fix_address(<<"> = Address) -> Address; fix_address(<<"sip", _Rest/binary>> = Address) -> list_to_binary([$<, Address, $>]); fix_address(Address) -> Address. --spec maybe_add_params(kz_json:object(), ne_binary()) -> ne_binary(). +-spec maybe_add_params(kz_json:object(), kz_term:ne_binary()) -> kz_term:ne_binary(). maybe_add_params(JObj, Address) -> kz_json:foldl(fun maybe_add_param/3, Address, JObj). --spec maybe_add_param(ne_binary(), ne_binary(), ne_binary()) -> ne_binary(). +-spec maybe_add_param(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). maybe_add_param(?PARAM_REASON, Reason, Acc) -> <>; maybe_add_extension({Key, Value}, Acc) -> @@ -325,7 +325,7 @@ maybe_add_extension({Key, Value}, Acc) -> maybe_add_extension(Key, Acc) -> <>. --spec encode_reason_param(ne_binary()) -> ne_binary(). +-spec encode_reason_param(kz_term:ne_binary()) -> kz_term:ne_binary(). encode_reason_param(Reason) -> encode_param(Reason, ?PARAM_REASON_LITERALS). encode_privacy_param(Privacy) -> @@ -333,13 +333,13 @@ encode_privacy_param(Privacy) -> encode_screen_param(Screen) -> encode_param(Screen, ?PARAM_SCREEN_LITERALS). --spec encode_param(ne_binary(), ne_binaries()) -> ne_binary(). +-spec encode_param(kz_term:ne_binary(), kz_term:ne_binaries()) -> kz_term:ne_binary(). encode_param(Param, Literals) -> case lists:member(Param, Literals) of 'true' -> Param; 'false' -> quote_param(Param) end. --spec quote_param(ne_binary()) -> ne_binary(). +-spec quote_param(kz_term:ne_binary()) -> kz_term:ne_binary(). quote_param(Param) -> <<"\"", Param/binary, "\"">>. diff --git a/core/kazoo_sip/src/kzsip_uri.erl b/core/kazoo_sip/src/kzsip_uri.erl index d54cef086f6..4fb92912a60 100644 --- a/core/kazoo_sip/src/kzsip_uri.erl +++ b/core/kazoo_sip/src/kzsip_uri.erl @@ -35,8 +35,8 @@ -type scheme() :: 'sip' | 'sips'. -record(sip_uri, {scheme = 'sip' :: scheme() - ,user :: api_ne_binary() - ,host :: api_ne_binary() + ,user :: kz_term:api_ne_binary() + ,host :: kz_term:api_ne_binary() ,port = 5060 :: pos_integer() }). -type sip_uri() :: #sip_uri{}. @@ -53,7 +53,7 @@ ruri(Uri) -> nklib_unparse:uri3(Uri). uri(#uri{scheme='undefined'}=Uri) -> nklib_unparse:uri(Uri#uri{scheme='sip'}); uri(Uri) -> nklib_unparse:uri(Uri). --spec parse(ne_binary()) -> sip_uri(). +-spec parse(kz_term:ne_binary()) -> sip_uri(). parse(Bin) -> parse_scheme(Bin, #sip_uri{}). @@ -66,7 +66,7 @@ parse_scheme(<<"sips:", Bin/binary>>, Uri) -> parse_scheme(Bin, Uri) -> parse_user(Bin, Uri#sip_uri{scheme='sip'}). --spec encode(sip_uri()) -> ne_binary(). +-spec encode(sip_uri()) -> kz_term:ne_binary(). encode(#sip_uri{scheme=S, user=U, host=H, port=5060}) -> list_to_binary([atom_to_list(S), ":", U, "@", H]); encode(#sip_uri{scheme=S, user=U, host=H, port=P}) -> @@ -95,7 +95,7 @@ parse_port(P) -> {Port, _} -> kz_term:to_integer(Port) end. --spec parse_until(ne_binary(), ne_binary()) -> {binary(), binary()}. +-spec parse_until(kz_term:ne_binary(), kz_term:ne_binary()) -> {binary(), binary()}. parse_until(C, Bin) -> case binary:split(Bin, C) of [B] -> {B, <<>>}; @@ -108,14 +108,14 @@ scheme(#sip_uri{scheme=S}) -> S. set_scheme(#sip_uri{}=Sip, S) -> Sip#sip_uri{scheme=S}. --spec user(sip_uri()) -> ne_binary(). --spec set_user(sip_uri(), ne_binary()) -> sip_uri(). +-spec user(sip_uri()) -> kz_term:ne_binary(). +-spec set_user(sip_uri(), kz_term:ne_binary()) -> sip_uri(). user(#sip_uri{user=U}) -> U. set_user(#sip_uri{}=Sip, U) -> Sip#sip_uri{user=U}. --spec host(sip_uri()) -> ne_binary(). --spec set_host(sip_uri(), ne_binary()) -> sip_uri(). +-spec host(sip_uri()) -> kz_term:ne_binary(). +-spec set_host(sip_uri(), kz_term:ne_binary()) -> sip_uri(). host(#sip_uri{host=H}) -> H. set_host(#sip_uri{}=Sip, H) -> Sip#sip_uri{host=H}. diff --git a/core/kazoo_speech/src/asr/kazoo_asr_ispeech.erl b/core/kazoo_speech/src/asr/kazoo_asr_ispeech.erl index 66f7db0a24a..d519321fa7d 100644 --- a/core/kazoo_speech/src/asr/kazoo_asr_ispeech.erl +++ b/core/kazoo_speech/src/asr/kazoo_asr_ispeech.erl @@ -10,7 +10,7 @@ -define(DEFAULT_ASR_CONTENT_TYPE, <<"application/wav">>). -define(SUPPORTED_CONTENT_TYPES, [<<"application/wav">>]). --spec default_url() -> ne_binary(). +-spec default_url() -> kz_term:ne_binary(). default_url() -> kapps_config:get_ne_binary(?MOD_CONFIG_CAT, <<"asr_url">>, <<"http://api.ispeech.org/api/json">>). @@ -18,7 +18,7 @@ default_url() -> default_api_key() -> kapps_config:get_binary(?MOD_CONFIG_CAT, <<"asr_api_key">>, <<>>). --spec default_preferred_content_type() -> ne_binary(). +-spec default_preferred_content_type() -> kz_term:ne_binary(). default_preferred_content_type() -> PreferredContentType = kapps_config:get_binary(?MOD_CONFIG_CAT ,<<"asr_preferred_content_type">> @@ -26,7 +26,7 @@ default_preferred_content_type() -> ), validate_content_type(PreferredContentType). --spec validate_content_type(binary()) -> ne_binary(). +-spec validate_content_type(binary()) -> kz_term:ne_binary(). validate_content_type(ContentType) -> case lists:member(ContentType, ?SUPPORTED_CONTENT_TYPES) of 'true' -> ContentType; @@ -35,14 +35,14 @@ validate_content_type(ContentType) -> ?DEFAULT_ASR_CONTENT_TYPE end. --spec freeform(binary(), ne_binary(), ne_binary(), kz_proplist()) -> asr_resp(). +-spec freeform(binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> asr_resp(). freeform(Content, ContentType, Locale, Options) -> case maybe_convert_content(Content, ContentType) of {'error', _}=E -> E; {Content1, ContentType1} -> exec_freeform(Content1, ContentType1, Locale, Options) end. --spec commands(ne_binary(), ne_binaries(), ne_binary(), ne_binary(), kz_proplist()) -> +-spec commands(kz_term:ne_binary(), kz_term:ne_binaries(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> provider_return(). commands(Content, Commands, ContentType, Locale, Options) -> case maybe_convert_content(Content, ContentType) of @@ -50,7 +50,7 @@ commands(Content, Commands, ContentType, Locale, Options) -> {Content1, ContentType1} -> exec_commands(Content1, Commands, ContentType1, Locale, Options) end. --spec make_request(ne_binary(), kz_proplist(), iolist(), kz_proplist()) -> kz_http:ret(). +-spec make_request(kz_term:ne_binary(), kz_term:proplist(), iolist(), kz_term:proplist()) -> kz_http:ret(). make_request(BaseUrl, Headers, Body, Opts) -> case props:get_value('receiver', Opts) of Pid when is_pid(Pid) -> @@ -83,7 +83,7 @@ handle_response({'ok', _Code, _Hdrs, Content2}) -> %% Send a freeform ASR request to iSpeech %% @end %%-------------------------------------------------------------------- --spec exec_freeform(binary(), ne_binary(), ne_binary(), kz_proplist()) -> +-spec exec_freeform(binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> asr_resp(). exec_freeform(Content, ContentType, Locale, Options) -> BaseUrl = default_url(), @@ -108,7 +108,7 @@ exec_freeform(Content, ContentType, Locale, Options) -> %% Send a command list ASR request to iSpeech %% @end %%-------------------------------------------------------------------- --spec exec_commands(ne_binary(), ne_binaries(), ne_binary(), ne_binary(), kz_proplist()) -> +-spec exec_commands(kz_term:ne_binary(), kz_term:ne_binaries(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> provider_return(). exec_commands(Bin, Commands, ContentType, Locale, Opts) -> BaseUrl = default_url(), @@ -140,7 +140,7 @@ exec_commands(Bin, Commands, ContentType, Locale, Opts) -> %% Convert audio file/content-type if initial format not supported %% @end %%-------------------------------------------------------------------- --spec maybe_convert_content(binary(), ne_binary()) -> conversion_return(). +-spec maybe_convert_content(binary(), kz_term:ne_binary()) -> conversion_return(). maybe_convert_content(Content, ContentType) -> case lists:member(ContentType, ?SUPPORTED_CONTENT_TYPES) of 'true' -> {Content, ContentType}; diff --git a/core/kazoo_speech/src/gen_asr_provider.erl b/core/kazoo_speech/src/gen_asr_provider.erl index 020815359ec..7d84a3b41da 100644 --- a/core/kazoo_speech/src/gen_asr_provider.erl +++ b/core/kazoo_speech/src/gen_asr_provider.erl @@ -2,5 +2,5 @@ -include("kazoo_speech.hrl"). --callback freeform(binary(), ne_binary(), ne_binary(), kz_proplist()) -> asr_resp(). --callback commands(ne_binary(), ne_binaries(), ne_binary(), ne_binary(), kz_proplist()) -> provider_return(). +-callback freeform(binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> asr_resp(). +-callback commands(kz_term:ne_binary(), kz_term:ne_binaries(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> provider_return(). diff --git a/core/kazoo_speech/src/gen_tts_provider.erl b/core/kazoo_speech/src/gen_tts_provider.erl index 23ee725e4b3..deb61ecf0e8 100644 --- a/core/kazoo_speech/src/gen_tts_provider.erl +++ b/core/kazoo_speech/src/gen_tts_provider.erl @@ -2,6 +2,6 @@ -include("kazoo_speech.hrl"). --callback create(ne_binary(), ne_binary(), ne_binary(), kz_proplist()) -> create_resp(). +-callback create(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> create_resp(). --callback set_api_key(ne_binary()) -> 'ok'. +-callback set_api_key(kz_term:ne_binary()) -> 'ok'. diff --git a/core/kazoo_speech/src/kazoo_asr.erl b/core/kazoo_speech/src/kazoo_asr.erl index f311be8e09c..35f64328744 100644 --- a/core/kazoo_speech/src/kazoo_asr.erl +++ b/core/kazoo_speech/src/kazoo_asr.erl @@ -6,15 +6,15 @@ -include("kazoo_speech.hrl"). --spec default_provider() -> ne_binary(). +-spec default_provider() -> kz_term:ne_binary(). default_provider() -> kapps_config:get_ne_binary(?MOD_CONFIG_CAT, <<"asr_provider">>, <<"ispeech">>). --spec default_mime_type() -> ne_binary(). +-spec default_mime_type() -> kz_term:ne_binary(). default_mime_type() -> kapps_config:get_ne_binary(?MOD_CONFIG_CAT, <<"asr_mime_type">>, <<"application/wav">>). --spec default_locale() -> ne_binary(). +-spec default_locale() -> kz_term:ne_binary(). default_locale() -> kapps_config:get_ne_binary(?MOD_CONFIG_CAT, <<"asr_locale">>, <<"en-us">>). @@ -22,10 +22,10 @@ default_locale() -> %% Transcribe the audio binary %%------------------------------------------------------------------------------ -spec freeform(binary()) -> asr_resp(). --spec freeform(binary(), ne_binary()) -> asr_resp(). --spec freeform(binary(), ne_binary(), ne_binary()) -> asr_resp(). --spec freeform(binary(), ne_binary(), ne_binary(), kz_proplist()) -> asr_resp(). --spec freeform(binary(), ne_binary(), ne_binary(), kz_proplist(), ne_binary()) -> asr_resp(). +-spec freeform(binary(), kz_term:ne_binary()) -> asr_resp(). +-spec freeform(binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> asr_resp(). +-spec freeform(binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> asr_resp(). +-spec freeform(binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist(), kz_term:ne_binary()) -> asr_resp(). freeform(Content) -> freeform(Content, default_mime_type()). freeform(Content, ContentType) -> @@ -46,11 +46,11 @@ freeform(Content, ContentType, Locale, Options, ASRProvider) -> %%------------------------------------------------------------------------------ %% Transcribe the audio binary %%------------------------------------------------------------------------------ --spec commands(ne_binary(), ne_binaries()) -> asr_resp(). --spec commands(ne_binary(), ne_binaries(), ne_binary()) -> asr_resp(). --spec commands(ne_binary(), ne_binaries(), ne_binary(), ne_binary()) -> asr_resp(). --spec commands(ne_binary(), ne_binaries(), ne_binary(), ne_binary(), kz_proplist()) -> asr_resp(). --spec commands(ne_binary(), ne_binaries(), ne_binary(), ne_binary(), kz_proplist(), ne_binary()) -> asr_resp(). +-spec commands(kz_term:ne_binary(), kz_term:ne_binaries()) -> asr_resp(). +-spec commands(kz_term:ne_binary(), kz_term:ne_binaries(), kz_term:ne_binary()) -> asr_resp(). +-spec commands(kz_term:ne_binary(), kz_term:ne_binaries(), kz_term:ne_binary(), kz_term:ne_binary()) -> asr_resp(). +-spec commands(kz_term:ne_binary(), kz_term:ne_binaries(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> asr_resp(). +-spec commands(kz_term:ne_binary(), kz_term:ne_binaries(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist(), kz_term:ne_binary()) -> asr_resp(). commands(Bin, Commands) -> commands(Bin, Commands, default_mime_type()). commands(Bin, Commands, ContentType) -> diff --git a/core/kazoo_speech/src/kazoo_asr_util.erl b/core/kazoo_speech/src/kazoo_asr_util.erl index 579dcacb639..bc92996c4b2 100644 --- a/core/kazoo_speech/src/kazoo_asr_util.erl +++ b/core/kazoo_speech/src/kazoo_asr_util.erl @@ -4,7 +4,7 @@ -include("kazoo_speech.hrl"). --spec convert_content(binary(), ne_binary(), ne_binary()) -> binary() | 'error'. +-spec convert_content(binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> binary() | 'error'. convert_content(Content, <<"audio/mpeg">>=_ConvertFrom, <<"application/wav">> = _ConvertTo) -> Mp3File = kazoo_speech_util:tmp_file_name(<<"mp3">>), WavFile = kazoo_speech_util:tmp_file_name(<<"wav">>), diff --git a/core/kazoo_speech/src/kazoo_speech.hrl b/core/kazoo_speech/src/kazoo_speech.hrl index bac4f504965..8dcf8cfdc42 100644 --- a/core/kazoo_speech/src/kazoo_speech.hrl +++ b/core/kazoo_speech/src/kazoo_speech.hrl @@ -8,7 +8,7 @@ -define(TTS_API_KEY, kapps_config:get_binary(?MOD_CONFIG_CAT, <<"tts_api_key">>, <<>>)). -define(TMP_PATH, kapps_config:get_binary(?MOD_CONFIG_CAT, <<"temporary_storage_path">>, <<"/tmp">>)). --type conversion_return() :: {binary(), ne_binary()} | +-type conversion_return() :: {binary(), kz_term:ne_binary()} | {'error', 'unsupported_content_type'}. -type provider_errors() :: 'invalid_voice' | 'unknown_provider' | 'unsupported_content_type'. @@ -16,7 +16,7 @@ kz_http:ret(). -type create_resp() :: provider_return() | - {'ok', ne_binary(), ne_binary()} | %% {'ok', ContentType, BinaryData} + {'ok', kz_term:ne_binary(), kz_term:ne_binary()} | %% {'ok', ContentType, BinaryData} {'error', 'tts_provider_failure', binary()}. -type asr_resp() :: kz_http:req_id() | diff --git a/core/kazoo_speech/src/kazoo_speech_maintenance.erl b/core/kazoo_speech/src/kazoo_speech_maintenance.erl index 0b54de215cd..a1276093e93 100644 --- a/core/kazoo_speech/src/kazoo_speech_maintenance.erl +++ b/core/kazoo_speech/src/kazoo_speech_maintenance.erl @@ -7,11 +7,11 @@ -include("kazoo_speech.hrl"). --spec set_tts_api_key(ne_binary(), ne_binary()) -> 'ok'. +-spec set_tts_api_key(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. set_tts_api_key(Provider, APIKey) -> (kazoo_tts:provider_module(Provider)):set_api_key(APIKey). --spec set_tts_provider(ne_binary()) -> 'ok'. +-spec set_tts_provider(kz_term:ne_binary()) -> 'ok'. set_tts_provider(Provider) -> case code:which(kazoo_tts:provider_module(Provider)) of 'non_existing' -> io:format("No provider module for ~s~n", [Provider]); @@ -20,7 +20,7 @@ set_tts_provider(Provider) -> io:format("Updated TTS provider to ~s~n", [Provider]) end. --spec set_tts_language(ne_binary()) -> 'ok'. +-spec set_tts_language(kz_term:ne_binary()) -> 'ok'. set_tts_language(Language) -> kazoo_tts:set_default_language(Language), io:format("updated default language to ~s~n", [Language]). diff --git a/core/kazoo_speech/src/kazoo_speech_util.erl b/core/kazoo_speech/src/kazoo_speech_util.erl index cc0673d0da1..cadb89c8686 100644 --- a/core/kazoo_speech/src/kazoo_speech_util.erl +++ b/core/kazoo_speech/src/kazoo_speech_util.erl @@ -4,7 +4,7 @@ -include("kazoo_speech.hrl"). --spec tmp_file_name(ne_binary()) -> string(). +-spec tmp_file_name(kz_term:ne_binary()) -> string(). tmp_file_name(Ext) -> Prefix = kz_binary:rand_hex(10), Name = filename:join([?TMP_PATH diff --git a/core/kazoo_speech/src/kazoo_tts.erl b/core/kazoo_speech/src/kazoo_tts.erl index baa007aa805..6f93942fca9 100644 --- a/core/kazoo_speech/src/kazoo_tts.erl +++ b/core/kazoo_speech/src/kazoo_tts.erl @@ -17,23 +17,23 @@ -include("kazoo_speech.hrl"). --spec create(ne_binary()) -> create_resp(). +-spec create(kz_term:ne_binary()) -> create_resp(). create(Text) -> create(Text, <<"female/en-us">>). --spec create(ne_binary(), ne_binary()) -> create_resp(). +-spec create(kz_term:ne_binary(), kz_term:ne_binary()) -> create_resp(). create(Text, Voice) -> create(Text, Voice, <<"wav">>). --spec create(ne_binary(), ne_binary(), ne_binary()) -> create_resp(). +-spec create(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> create_resp(). create(Text, Voice, Format) -> create(Text, Voice, Format, []). --spec create(ne_binary(), ne_binary(), ne_binary(), kz_proplist()) -> create_resp(). +-spec create(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> create_resp(). create(Text, Voice, Format, Options) -> create(default_provider(), Text, Voice, Format, Options). --spec create(api_binary(), ne_binary(), ne_binary(), ne_binary(), kz_proplist()) -> create_resp(). +-spec create(kz_term:api_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> create_resp(). create('undefined', Text, Voice, Format, Options) -> create(Text, Voice, Format, Options); create(<<"flite">>, _Text, _Voice, _Format, _Options) -> @@ -41,7 +41,7 @@ create(<<"flite">>, _Text, _Voice, _Format, _Options) -> create(Provider, Text, Voice, Format, Options) -> (provider_module(Provider)):create(Text, Voice, Format, Options). --spec provider_module(ne_binary()) -> atom(). +-spec provider_module(kz_term:ne_binary()) -> atom(). provider_module(Provider) -> kz_term:to_atom(<<"kazoo_tts_", Provider/binary>>, 'true'). @@ -49,8 +49,8 @@ provider_module(Provider) -> cache_time_ms() -> kapps_config:get_integer(?MOD_CONFIG_CAT, <<"tts_cache">>, ?MILLISECONDS_IN_HOUR). --spec default_provider() -> ne_binary(). --spec default_provider(kapps_call:call()) -> ne_binary(). +-spec default_provider() -> kz_term:ne_binary(). +-spec default_provider(kapps_call:call()) -> kz_term:ne_binary(). default_provider() -> kapps_config:get_binary(?MOD_CONFIG_CAT, <<"tts_provider">>, <<"flite">>). @@ -58,25 +58,25 @@ default_provider(Call) -> Default = default_provider(), kapps_account_config:get_global(Call, ?MOD_CONFIG_CAT, <<"tts_provider">>, Default). --spec set_default_provider(ne_binary()) -> 'ok'. +-spec set_default_provider(kz_term:ne_binary()) -> 'ok'. set_default_provider(Provider) -> {'ok', _} = kapps_config:set_default(?MOD_CONFIG_CAT, <<"tts_provider">>, Provider), 'ok'. --spec default_language() -> ne_binary(). +-spec default_language() -> kz_term:ne_binary(). default_language() -> kapps_config:get_binary(?MOD_CONFIG_CAT, <<"tts_language">>, <<"en-us">>). --spec set_default_language(ne_binary()) -> 'ok'. +-spec set_default_language(kz_term:ne_binary()) -> 'ok'. set_default_language(Language) -> {'ok', _} = kapps_config:set_default(?MOD_CONFIG_CAT, <<"tts_language">>, Language), 'ok'. --spec default_voice() -> ne_binary(). +-spec default_voice() -> kz_term:ne_binary(). default_voice() -> kapps_config:get_binary(?MOD_CONFIG_CAT, <<"tts_voice">>, <<"male">>). --spec set_default_voice(ne_binary()) -> 'ok'. +-spec set_default_voice(kz_term:ne_binary()) -> 'ok'. set_default_voice(Voice) -> {'ok', _} = kapps_config:set_default(?MOD_CONFIG_CAT, <<"tts_voice">>, Voice), 'ok'. diff --git a/core/kazoo_speech/src/tts/kazoo_tts_ispeech.erl b/core/kazoo_speech/src/tts/kazoo_tts_ispeech.erl index 5ac29bb2dc3..70d179349d1 100644 --- a/core/kazoo_speech/src/tts/kazoo_tts_ispeech.erl +++ b/core/kazoo_speech/src/tts/kazoo_tts_ispeech.erl @@ -56,12 +56,12 @@ ). -define(ISPEECH_TTS_URL, kapps_config:get_string(?MOD_CONFIG_CAT, <<"tts_url_ispeech">>, <<"http://api.ispeech.org/api/json">>)). --spec set_api_key(ne_binary()) -> 'ok'. +-spec set_api_key(kz_term:ne_binary()) -> 'ok'. set_api_key(Key) -> {'ok', _} = kapps_config:set_default(?MOD_CONFIG_CAT, <<"tts_api_key">>, Key), 'ok'. --spec create(ne_binary(), ne_binary(), ne_binary(), kz_proplist()) -> create_resp(). +-spec create(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> create_resp(). create(Text, Voice, Format, Options) -> VoiceMappings = ?ISPEECH_VOICE_MAPPINGS, case props:get_value(kz_term:to_lower_binary(Voice), VoiceMappings) of @@ -71,7 +71,7 @@ create(Text, Voice, Format, Options) -> make_request(Text, ISpeechVoice, Format, Options) end. --spec make_request(ne_binary(), ne_binary(), ne_binary(), kz_proplist()) -> create_resp(). +-spec make_request(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> create_resp(). make_request(Text, ISpeechVoice, Format, Options) -> BaseUrl = ?ISPEECH_TTS_URL, @@ -101,7 +101,7 @@ make_request(Text, ISpeechVoice, Format, Options) -> -spec create_response(kz_http:ret()) -> kz_http:req_id() | - {'ok', ne_binary(), ne_binary()} | + {'ok', kz_term:ne_binary(), kz_term:ne_binary()} | {'error', 'tts_provider_failure', binary()}. create_response({'error', _R}) -> lager:warning("creating speech file failed with error ~p", [_R]), diff --git a/core/kazoo_speech/src/tts/kazoo_tts_voicefabric.erl b/core/kazoo_speech/src/tts/kazoo_tts_voicefabric.erl index e55ba332994..9b0da55b33f 100644 --- a/core/kazoo_speech/src/tts/kazoo_tts_voicefabric.erl +++ b/core/kazoo_speech/src/tts/kazoo_tts_voicefabric.erl @@ -35,12 +35,12 @@ -define(VOICEFABRIC_TTS_URL, kapps_config:get_string(?MOD_CONFIG_CAT, <<"tts_url_voicefabric">>, <<"https://voicefabric.ru/WSServer/ws/tts">>)). --spec set_api_key(ne_binary()) -> 'ok'. +-spec set_api_key(kz_term:ne_binary()) -> 'ok'. set_api_key(Key) -> {'ok', _} = kapps_config:set_default(?MOD_CONFIG_CAT, <<"tts_api_key">>, Key), 'ok'. --spec create(ne_binary(), ne_binary(), ne_binary(), kz_proplist()) -> create_resp(). +-spec create(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist()) -> create_resp(). create(Text, Voice, _Format, Options) -> lager:debug("getting ~ts from VoiceFabric", [Text]), VoiceMappings = ?VOICEFABRIC_VOICE_MAPPINGS, @@ -75,9 +75,9 @@ create(Text, Voice, _Format, Options) -> end end. --spec voicefabric_request_body(ne_binary(), list()) -> - {'ok', list(), ne_binary()} | - {'error', ne_binary()}. +-spec voicefabric_request_body(kz_term:ne_binary(), list()) -> + {'ok', list(), kz_term:ne_binary()} | + {'error', kz_term:ne_binary()}. voicefabric_request_body(<<"urlencode">>, Data) -> Headers = [{"Content-Type", "application/x-www-form-urlencoded"}], Body = kz_http_util:props_to_querystring(Data), @@ -108,7 +108,7 @@ voicefabric_request_body(ArgsEncode, _Data) -> -spec create_response(kz_http:ret()) -> kz_http:req_id() | - {'ok', ne_binary(), ne_binary()} | + {'ok', kz_term:ne_binary(), kz_term:ne_binary()} | {'error', 'tts_provider_failure', binary()}. create_response({'error', _R}) -> lager:warning("creating speech file failed with error ~p", [_R]), @@ -152,7 +152,7 @@ create_response({'ok', _Code, RespHeaders, Content}) -> _ = [lager:debug("hdr: ~p", [H]) || H <- RespHeaders], {'error', 'tts_provider_failure', Content}. --spec voicefabric_get_media_rate(kz_proplist()) -> {'ok', ne_binary()}. +-spec voicefabric_get_media_rate(kz_term:proplist()) -> {'ok', kz_term:ne_binary()}. voicefabric_get_media_rate(Headers1) -> Headers = [{kz_term:to_lower_binary(X), kz_term:to_binary(Y)} || {X, Y} <- Headers1 @@ -163,12 +163,12 @@ voicefabric_get_media_rate(Headers1) -> [X || X <- re:split(Params, "; "), voicefabric_filter_rate(X)], {'ok', Rate}. --spec voicefabric_filter_rate(ne_binary()) -> boolean(). +-spec voicefabric_filter_rate(kz_term:ne_binary()) -> boolean(). voicefabric_filter_rate(<<"rate=", _/binary>>) -> 'true'; voicefabric_filter_rate(_) -> 'false'. --spec create_default_response({'ok', 200, kz_proplist(), binary()}) -> - {'ok', ne_binary(), binary()}. +-spec create_default_response({'ok', 200, kz_term:proplist(), binary()}) -> + {'ok', kz_term:ne_binary(), binary()}. create_default_response({'ok', 200, Headers, Content}) -> ContentType = props:get_value("content-type", Headers), ContentLength = props:get_value("content-length", Headers), diff --git a/core/kazoo_stats/src/kazoo_stats.erl b/core/kazoo_stats/src/kazoo_stats.erl index c7b8ecbf86b..327bfe02ae1 100644 --- a/core/kazoo_stats/src/kazoo_stats.erl +++ b/core/kazoo_stats/src/kazoo_stats.erl @@ -44,8 +44,8 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). --spec start_link(pos_integer()) -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). +-spec start_link(pos_integer()) -> kz_types:startlink_ret(). start_link() -> start_link(?SEND_INTERVAL). start_link(Send_stats) -> gen_server:start_link({'local', ?SERVER}, ?MODULE, [Send_stats], []). @@ -107,7 +107,7 @@ init([Send_stats]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call('get_db', _From, State) -> {'reply', State, State}; handle_call(Other,_From,State) -> @@ -125,7 +125,7 @@ handle_call(Other,_From,State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast('stop', State) -> {'stop', 'ok', State}; handle_cast({Operation, Key, Val}, State) when Operation == 'add'; @@ -147,7 +147,7 @@ handle_cast(_,State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'send_stats', SendStats}=Info,State) -> send_stats(State#state.variables, State#state.sip), erlang:send_after(SendStats, self(), Info), diff --git a/core/kazoo_stats/src/kazoo_stats_app.erl b/core/kazoo_stats/src/kazoo_stats_app.erl index 9cfbb64072d..d5db9e8590f 100644 --- a/core/kazoo_stats/src/kazoo_stats_app.erl +++ b/core/kazoo_stats/src/kazoo_stats_app.erl @@ -18,7 +18,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> kazoo_stats_sup:start_link(). diff --git a/core/kazoo_stats/src/kazoo_stats_sup.erl b/core/kazoo_stats/src/kazoo_stats_sup.erl index e0438b12725..2a7e22ddad3 100644 --- a/core/kazoo_stats/src/kazoo_stats_sup.erl +++ b/core/kazoo_stats/src/kazoo_stats_sup.erl @@ -26,7 +26,7 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). @@ -43,7 +43,7 @@ start_link() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, diff --git a/core/kazoo_stdlib/include/kazoo_json.hrl b/core/kazoo_stdlib/include/kazoo_json.hrl index 8ea2f7d2a0f..9c0b088bfc9 100644 --- a/core/kazoo_stdlib/include/kazoo_json.hrl +++ b/core/kazoo_stdlib/include/kazoo_json.hrl @@ -29,7 +29,7 @@ -type json_terms() :: [json_term()]. -type json_array() :: json_terms(). --type json_string() :: ne_binary() | atom(). +-type json_string() :: kz_term:ne_binary() | atom(). -type json_number() :: integer() | float(). -type object() :: ?JSON_WRAPPER(json_proplist()) | ?EMPTY_JSON_OBJECT. diff --git a/core/kazoo_stdlib/include/kz_records.hrl b/core/kazoo_stdlib/include/kz_records.hrl new file mode 100644 index 00000000000..b6dc3afe198 --- /dev/null +++ b/core/kazoo_stdlib/include/kz_records.hrl @@ -0,0 +1,28 @@ +-ifndef(KAZOO_RECORDS_INCLUDED). + +-record(whapp_info, {startup :: kz_time:api_seconds() + ,roles = [] :: kz_term:ne_binaries() + }). + +-record(kz_node, {node = node() :: atom() | '$1' | '$2' | '_' + ,md5 :: kz_term:api_binary() | '_' + ,expires = 0 :: non_neg_integer() | 'undefined' | '$2' | '_' + ,kapps = [] :: kz_types:kapps_info() | '$1' | '_' + ,media_servers = [] :: kz_types:media_servers() | '_' + ,last_heartbeat = kz_time:now_ms() :: pos_integer() | 'undefined' | '$3' | '_' + ,zone :: atom() | 'undefined' | '$2' | '_' + ,broker :: kz_term:api_binary() | '_' + ,used_memory = 0 :: non_neg_integer() | '_' + ,processes = 0 :: non_neg_integer() | '_' + ,ports = 0 :: non_neg_integer() | '_' + ,version :: kz_term:api_binary() | '_' + ,channels = 0 :: non_neg_integer() | '_' + ,conferences = 0 :: non_neg_integer() | '_' + ,registrations = 0 :: non_neg_integer() | '_' + ,globals = [] :: kz_term:proplist() | '$1' | '_' + ,node_info :: kz_term:api_object() | '_' + ,roles = [] :: kz_term:proplist() | '$1' | '_' + }). + +-define(KAZOO_RECORDS_INCLUDED, 'true'). +-endif. diff --git a/core/kazoo_stdlib/include/kz_types.hrl b/core/kazoo_stdlib/include/kz_types.hrl index b659cee54e7..d49582b4846 100644 --- a/core/kazoo_stdlib/include/kz_types.hrl +++ b/core/kazoo_stdlib/include/kz_types.hrl @@ -1,5 +1,6 @@ -ifndef(KAZOO_TYPES_INCLUDED). -include_lib("xmerl/include/xmerl.hrl"). +-include_lib("kazoo_stdlib/include/kz_records.hrl"). -define(MILLISECONDS_IN_SECOND, 1000). -define(MILLISECONDS_IN_MINUTE, (?MILLISECONDS_IN_SECOND * ?SECONDS_IN_MINUTE)). @@ -27,112 +28,15 @@ -define(DEFAULT_CONTENT_TYPE, <<"application/json">>). --type text() :: string() | atom() | binary() | iolist(). - --type atoms() :: [atom()]. --type pids() :: [pid()]. --type references() :: [reference()]. - --type kz_proplist_key() :: any(). --type kz_proplist_value() :: any(). --type kz_proplist_property() :: atom() | {kz_proplist_key(), kz_proplist_value()}. --type kz_proplist() :: [kz_proplist_property()]. --type kz_proplists() :: [kz_proplist()]. --type kz_proplist_kv(K, V) :: [{K, V}]. - --type pid_ref() :: {pid(), reference()}. --type pid_refs() :: [pid_ref()]. --type api_pid_ref() :: pid_ref() | 'undefined'. --type api_pid_refs() :: pid_refs() | 'undefined'. - --type api_terms() :: kz_json:object() | kz_proplist(). --type api_binary() :: binary() | 'undefined'. --type api_ne_binary() :: ne_binary() | 'undefined'. --type api_ne_binaries() :: [api_ne_binary()] | 'undefined'. --type api_binaries() :: [api_binary()] | 'undefined'. --type api_object() :: kz_json:object() | 'undefined'. --type api_objects() :: kz_json:objects() | 'undefined'. --type api_boolean() :: boolean() | 'undefined'. --type api_atom() :: atom() | 'undefined'. --type api_atoms() :: atoms() | 'undefined'. --type api_string() :: string() | 'undefined'. --type api_reference() :: reference() | 'undefined'. --type api_pid() :: pid() | 'undefined'. --type api_list() :: list() | 'undefined'. - --type api_number() :: number() | 'undefined'. --type api_integer() :: integer() | 'undefined'. --type api_pos_integer() :: pos_integer() | 'undefined'. --type api_non_neg_integer() :: non_neg_integer() | 'undefined'. --type api_float() :: float() | 'undefined'. - --type kz_deeplist() :: iolist(). %[any() | kz_deeplist()]. - --type kz_std_return() :: {'ok', any()} | {'error', any()}. - --type kz_jobj_return() :: {'ok', kz_json:object()} | {'error', any()}. --type kz_jobjs_return() :: {'ok', kz_json:objects()} | {'error', any()}. - %% non-empty binary -define(NE_BINARY, <<_:8,_/binary>>). --type ne_binary() :: <<_:8,_:_*8>>. --type ne_binaries() :: [ne_binary()]. --type binaries() :: [binary()]. - --type strings() :: [string()]. --type integers() :: [integer()]. - --type functions() :: [function()]. - -%% when using gen_smtp to send emails, it takes a 5-tuple for a message-body part --type mail_message_body() :: {ne_binary(), ne_binary(), kz_proplist(), kz_proplist(), ne_binary() | iolist()}. - -%% for setting types on dicts --type dict(K,V) :: [{K, V}]. %% result of calendar:datetime_to_gregorian_seconds({{1970,1,1},{0,0,0}}). -%% Subtract this value from a gregorian seconds version of a date +%% Subtract this value from a Gregorian seconds version of a date %% to get the Unix timestamp -%% datetime_to_gregorian_seconds({date(),time()}) - ?UNIX_EPOCH_IN_GREGORIAN. +%% datetime_to_gregorian_seconds({kz_time:date(),kz_time:time()}) - ?UNIX_EPOCH_IN_GREGORIAN. -define(UNIX_EPOCH_IN_GREGORIAN, 62167219200). --type kz_now() :: erlang:timestamp(). --type kz_year() :: non_neg_integer(). --type kz_month() :: 1..12. --type kz_day() :: 1..31. --type kz_hour() :: 0..23. --type kz_minute() :: 0..59. --type kz_second() :: 0..59. --type kz_daynum() :: 1..7. --type kz_weeknum() :: 1..53. --type kz_date() :: calendar:date(). %%{kz_year(), kz_month(), kz_day()}. --type kz_time() :: calendar:time(). %%{kz_hour(), kz_minute(), kz_second()}. --type kz_datetime() :: calendar:datetime(). %%{kz_date(), kz_time()}. --type kz_iso_week() :: calendar:yearweeknum(). %%{kz_year(), kz_weeknum()}. --type gregorian_seconds() :: pos_integer(). --type unix_seconds() :: pos_integer(). --type api_seconds() :: 'undefined' | gregorian_seconds(). - --type kz_timeout() :: non_neg_integer() | 'infinity'. - --type kz_ip_list() :: ne_binaries(). - -%% Recreate the non-exported types defined in the erlang supervisor source --type sup_child_spec() :: supervisor:child_spec(). --type sup_child_specs() :: [sup_child_spec()]. --type sup_start_flags() :: supervisor:sup_flags(). - --type sup_init_ret() :: {'ok', {supervisor:sup_flags(), [supervisor:child_spec()]}} | - 'ignore'. - --type sup_child_id() :: api_pid(). --type sup_startchild_err() :: 'already_present' | - {'already_started', sup_child_id()} | - any(). --type sup_startchild_ret() :: {'ok', sup_child_id()} | - {'ok', sup_child_id(), any()} | - {'error', sup_startchild_err()}. - %% Helper macro for declaring children of supervisor -define(WORKER(I), {I, {I, 'start_link', []}, 'permanent', 5 * ?MILLISECONDS_IN_SECOND, 'worker', [I]}). -define(WORKER_ARGS(I, Args), {I, {I, 'start_link', Args}, 'permanent', 5 * ?MILLISECONDS_IN_SECOND, 'worker', [I]}). @@ -153,82 +57,6 @@ -define(CACHE(N), {N, {'kz_cache', 'start_link', [N]}, 'permanent', 5 * ?MILLISECONDS_IN_SECOND, 'worker', ['kz_cache']}). -define(CACHE_ARGS(N, Arg), {N, {'kz_cache', 'start_link', [N, Arg]}, 'permanent', 5 * ?MILLISECONDS_IN_SECOND, 'worker', ['kz_cache']}). -%% Recreate the non-exported types defined in the erlang gen_server source --type startlink_err() :: {'already_started', pid()} | - 'shutdown' | - any(). --type startlink_ret() :: {'ok', pid()} | - 'ignore' | - {'error', startlink_err()}. --type startapp_ret() :: {'ok', pid()} | - {'ok', pid(), any()} | - {'error', startlink_err()}. - --type call_from() :: pid_ref(). --type gen_server_timeout() :: 'hibernate' | non_neg_integer(). --type handle_call_ret() :: {'reply', any(), any()} | - {'reply', any(), any(), gen_server_timeout()} | - {'noreply', any()} | - {'noreply', any(), gen_server_timeout()} | - {'stop', any(), any()} | - {'stop', any(), any(), any()}. - --type handle_call_ret_state(State) :: {'reply', any(), State} | - {'reply', any(), State, gen_server_timeout()} | - {'noreply', State} | - {'noreply', State, gen_server_timeout()} | - {'stop', any(), State} | - {'stop', any(), State, any()}. - --type handle_cast_ret() :: {'noreply', any()} | - {'noreply', any(), gen_server_timeout()} | - {'stop', any(), any()}. --type handle_cast_ret_state(State) :: {'noreply', State} | - {'noreply', State, gen_server_timeout()} | - {'stop', any(), State}. - --type handle_info_ret() :: {'noreply', any()} | - {'noreply', any(), gen_server_timeout()} | - {'stop', any(), any()}. --type handle_info_ret_state(State) :: {'noreply', State} | - {'noreply', State, gen_server_timeout()} | - {'stop', any(), State}. - --type handle_fsm_ret(State) :: {'next_state', atom(), State} | - {'next_state', atom(), State, timeout() | 'hibernate'} | - {'stop', any(), State}. - --type handle_sync_event_ret(State) :: handle_fsm_ret(State) | - {'reply', any(), atom(), State} | - {'reply', any(), atom(), State, timeout() | 'hibernate'} | - {'stop', any(), any(), State}. - --type server_ref() :: atom() | - {atom(), atom()} | - {'global', any()} | - {'via', atom(), any()} | - pid(). - --type gen_server_name() :: {'local', atom()} | - {'global', any()} | - {'via', atom(), any()}. --type gen_server_option() :: {'debug', list()} | - {'timeout', non_neg_integer()} | - {'spawn_opt', list()}. --type gen_server_options() :: [gen_server_option()]. - -%% XML types --type xml_attrib_name() :: atom(). --type xml_attrib_value() :: ne_binary() | nonempty_string() | iolist() | atom() | number(). --type xml_attrib() :: #xmlAttribute{}. --type xml_attribs() :: [xml_attrib()]. - --type xml_el() :: #xmlElement{}. --type xml_els() :: [xml_el()]. - --type xml_text() :: #xmlText{value :: iolist()}. --type xml_texts() :: [xml_text()]. - %% Used by ecallmgr and kapi_dialplan at least -define(CALL_EVENTS, [<<"CALL_SECURE">>,<<"CALL_UPDATE">> @@ -255,9 +83,6 @@ -define(BRIDGE_DEFAULT_SYSTEM_TIMEOUT_S, 20). --type xml_thing() :: xml_el() | xml_text(). --type xml_things() :: xml_els() | xml_texts(). - -define(MATCH_ACCOUNT_RAW(Account), <<(Account):32/binary>> @@ -369,40 +194,6 @@ >> ). -%% KZ_NODES types --record(whapp_info, {startup :: api_seconds() - ,roles = [] :: ne_binaries() - }). - --type whapp_info() :: #whapp_info{}. --type kapps_info() :: [{binary(), whapp_info()}]. - --type media_server() :: {ne_binary(), kz_json:object()}. --type media_servers() :: [media_server()]. - --record(kz_node, {node = node() :: atom() | '$1' | '$2' | '_' - ,md5 :: api_binary() | '_' - ,expires = 0 :: non_neg_integer() | 'undefined' | '$2' | '_' - ,kapps = [] :: kapps_info() | '$1' | '_' - ,media_servers = [] :: media_servers() | '_' - ,last_heartbeat = kz_time:now_ms() :: pos_integer() | 'undefined' | '$3' | '_' - ,zone :: atom() | 'undefined' | '$2' | '_' - ,broker :: api_binary() | '_' - ,used_memory = 0 :: non_neg_integer() | '_' - ,processes = 0 :: non_neg_integer() | '_' - ,ports = 0 :: non_neg_integer() | '_' - ,version :: api_binary() | '_' - ,channels = 0 :: non_neg_integer() | '_' - ,conferences = 0 :: non_neg_integer() | '_' - ,registrations = 0 :: non_neg_integer() | '_' - ,globals = [] :: kz_proplist() | '$1' | '_' - ,node_info :: api_object() | '_' - ,roles = [] :: kz_proplist() | '$1' | '_' - }). - --type kz_node() :: #kz_node{}. --type kz_nodes() :: [kz_node()]. - -define(FAKE_CALLID(C), kz_term:to_hex_binary(crypto:hash(md5, C))). -ifdef(TEST). diff --git a/core/kazoo_stdlib/src/kz_binary.erl b/core/kazoo_stdlib/src/kz_binary.erl index 45d04f8d288..93108bc9de9 100644 --- a/core/kazoo_stdlib/src/kz_binary.erl +++ b/core/kazoo_stdlib/src/kz_binary.erl @@ -60,8 +60,8 @@ pad_left(Bin, _Size, _Value) -> Bin. %% %% @end %%-------------------------------------------------------------------- --spec join([text()]) -> binary(). --spec join([text()], iodata() | char()) -> binary(). +-spec join([kz_term:text()]) -> binary(). +-spec join([kz_term:text()], iodata() | char()) -> binary(). join(Bins) -> join(Bins, <<", ">>). join([], _) -> <<>>; @@ -71,10 +71,10 @@ join([Bin|Bins], Sep) -> [kz_term:to_binary(Bin)] ++ [[Sep, kz_term:to_binary(B)] || B <- Bins] ). --spec md5(text()) -> ne_binary(). +-spec md5(kz_term:text()) -> kz_term:ne_binary(). md5(Text) -> kz_term:to_hex_binary(erlang:md5(kz_term:to_binary(Text))). --spec remove_white_spaces(binary(), kz_proplist()) -> binary(). +-spec remove_white_spaces(binary(), kz_term:proplist()) -> binary(). remove_white_spaces(Bin, Opts) -> case props:get_value(<<"remove_white_spaces">>, Opts, 'true') of 'false' -> Bin; @@ -86,7 +86,7 @@ remove_white_spaces(Bin) -> << <> || <> <= Bin, X =/= $\s >>. -spec clean(binary()) -> binary(). --spec clean(binary(), kz_proplist()) -> binary(). +-spec clean(binary(), kz_term:proplist()) -> binary(). clean(Bin) -> clean(Bin, []). @@ -159,7 +159,7 @@ suffix(<<_/binary>> = Suffix, <<_/binary>> = Bin) -> _:_ -> 'false' end. --spec hexencode(text()) -> binary(). +-spec hexencode(kz_term:text()) -> binary(). hexencode(<<_/binary>> = Bin) -> hexencode(Bin, <<>>); hexencode(S) -> @@ -196,17 +196,17 @@ hex_char_to_binary(B) when B < 58 -> hex_char_to_binary(B) -> kz_term:to_lower_char(B) - ($a - 10). --spec rand_hex(pos_integer() | binary() | string()) -> ne_binary(). +-spec rand_hex(pos_integer() | binary() | string()) -> kz_term:ne_binary(). rand_hex(Size) when not is_integer(Size) -> rand_hex(kz_term:to_integer(Size)); rand_hex(Size) when is_integer(Size) andalso Size > 0 -> kz_term:to_hex_binary(crypto:strong_rand_bytes(Size)). --spec ucfirst(ne_binary()) -> ne_binary(). +-spec ucfirst(kz_term:ne_binary()) -> kz_term:ne_binary(). ucfirst(<>) -> <<(kz_term:to_upper_char(F)):8, Bin/binary>>. --spec lcfirst(ne_binary()) -> ne_binary(). +-spec lcfirst(kz_term:ne_binary()) -> kz_term:ne_binary(). lcfirst(<>) -> <<(kz_term:to_lower_char(F)):8, Bin/binary>>. -spec pos(char(), binary()) -> non_neg_integer() | -1. diff --git a/core/kazoo_stdlib/src/kz_date.erl b/core/kazoo_stdlib/src/kz_date.erl index 0dab5f490ae..6d13ac24f06 100644 --- a/core/kazoo_stdlib/src/kz_date.erl +++ b/core/kazoo_stdlib/src/kz_date.erl @@ -38,7 +38,7 @@ %% @doc Convert a Gregorian seconds integer to kz_date taking into consideration timezone %% @end %%-------------------------------------------------------------------- --spec from_gregorian_seconds(gregorian_seconds(), ne_binary()) -> kz_date(). +-spec from_gregorian_seconds(kz_time:gregorian_seconds(), kz_term:ne_binary()) -> kz_time:date(). from_gregorian_seconds(Seconds, <<_/binary>>=TZ) when is_integer(Seconds) -> {Date, _} = localtime:utc_to_local(calendar:gregorian_seconds_to_datetime(Seconds) ,kz_term:to_list(TZ) @@ -50,7 +50,7 @@ from_gregorian_seconds(Seconds, <<_/binary>>=TZ) when is_integer(Seconds) -> %% Calculates the date of a given ISO 8601 week %% @end %%-------------------------------------------------------------------- --spec from_iso_week(kz_iso_week()) -> kz_date(). +-spec from_iso_week(kz_time:iso_week()) -> kz_time:date(). from_iso_week({Year, Week}) -> Jan4 = calendar:date_to_gregorian_days(Year, 1, 4), Jan4DOW = calendar:day_of_the_week(Year, 1, 4), @@ -69,7 +69,7 @@ weekday_distance(D0, D1) when D0 =< 7, D1 =< 7 -> Days -> Days + 7 end. --spec to_iso_week(kz_date()) -> kz_iso_week(). +-spec to_iso_week(kz_time:date()) -> kz_time:iso_week(). to_iso_week({_Year, _Month, _Day}=Date) -> calendar:iso_week_number(Date). @@ -80,7 +80,7 @@ to_iso_week({_Year, _Month, _Day}=Date) -> %% I have been referring to this as 'spanning a month/year border' %% @end %%-------------------------------------------------------------------- --spec normalize(kz_date()) -> kz_date(). +-spec normalize(kz_time:date()) -> kz_time:date(). normalize({Y, 0, D}) -> normalize({Y - 1, 12, D}); normalize({Y, M, 0}) -> @@ -100,7 +100,7 @@ normalize({Y, M, D}=Date) -> %% calendar:time_difference/2 is obsolete. Convert to gregorian seconds instead %% @end %%-------------------------------------------------------------------- --spec relative_difference(kz_datetime(), kz_datetime()) -> 'future' | 'equal' | 'past'. +-spec relative_difference(kz_time:datetime(), kz_time:datetime()) -> 'future' | 'equal' | 'past'. relative_difference(Date1, Date2) -> case {calendar:datetime_to_gregorian_seconds(Date1) ,calendar:datetime_to_gregorian_seconds(Date2) @@ -120,7 +120,7 @@ relative_difference(Date1, Date2) -> %% It is possible for this function to cross month/year boundaries. %% @end %%-------------------------------------------------------------------- --spec find_next_weekday(kz_date(), ne_binary()) -> kz_date(). +-spec find_next_weekday(kz_time:date(), kz_term:ne_binary()) -> kz_time:date(). find_next_weekday({Y, M, D}, Weekday) -> RefDOW = wday_to_dow(Weekday), case calendar:day_of_the_week({Y, M, D}) of @@ -136,7 +136,7 @@ find_next_weekday({Y, M, D}, Weekday) -> normalize({Y, M, D + ( 7 - DOW ) + RefDOW}) end. --spec from_iso8601(binary()) -> kz_date() | 'error'. +-spec from_iso8601(binary()) -> kz_time:date() | 'error'. from_iso8601(<>) -> {kz_term:to_integer(Year), kz_term:to_integer(Month), kz_term:to_integer(Day)}; @@ -146,7 +146,7 @@ from_iso8601(<>) -> from_iso8601(_NotValid) -> 'error'. --spec to_iso8601(calendar:date() | calendar:datetime() | gregorian_seconds()) -> ne_binary(). +-spec to_iso8601(calendar:date() | calendar:datetime() | kz_time:gregorian_seconds()) -> kz_term:ne_binary(). to_iso8601({Year, Month, Day}) -> Y = kz_binary:pad_left(kz_term:to_binary(Year), 4, <<"0">>), M = kz_binary:pad_left(kz_term:to_binary(Month), 2, <<"0">>), @@ -160,7 +160,7 @@ to_iso8601({{_Y,_M,_D}=Date, _}) -> to_iso8601(Timestamp) -> to_iso8601(calendar:gregorian_seconds_to_datetime(Timestamp)). --spec to_iso8601_extended(calendar:date() | calendar:datetime() | gregorian_seconds()) -> ne_binary(). +-spec to_iso8601_extended(calendar:date() | calendar:datetime() | kz_time:gregorian_seconds()) -> kz_term:ne_binary(). to_iso8601_extended({Year, Month, Day}) -> Y = kz_binary:pad_left(kz_term:to_binary(Year), 4, <<"0">>), M = kz_binary:pad_left(kz_term:to_binary(Month), 2, <<"0">>), @@ -180,7 +180,7 @@ to_iso8601_extended(Timestamp) -> %% the position %% @end %%-------------------------------------------------------------------- --spec ordinal_to_position(ne_binary()) -> 0..4. +-spec ordinal_to_position(kz_term:ne_binary()) -> 0..4. ordinal_to_position(<<"first">>) -> 0; ordinal_to_position(<<"second">>) -> 1; ordinal_to_position(<<"third">>) -> 2; @@ -193,7 +193,7 @@ ordinal_to_position(<<"fifth">>) -> 4. %% position, in accordance with ISO 8601 %% @end %%-------------------------------------------------------------------- --spec wday_to_dow(ne_binary()) -> kz_daynum(). +-spec wday_to_dow(kz_term:ne_binary()) -> kz_time:daynum(). wday_to_dow(<<"monday">>) -> 1; wday_to_dow(<<"tuesday">>) -> 2; wday_to_dow(<<"wednesday">>) -> 3; @@ -208,7 +208,7 @@ wday_to_dow(<<"sunday">>) -> 7. %% Map the position of a week day to its textual representation. %% @end %%-------------------------------------------------------------------- --spec dow_to_wday(kz_daynum()) -> ne_binary(). +-spec dow_to_wday(kz_time:daynum()) -> kz_term:ne_binary(). dow_to_wday(1) -> <<"monday">>; dow_to_wday(2) -> <<"tuesday">>; dow_to_wday(3) -> <<"wednesday">>; @@ -217,7 +217,7 @@ dow_to_wday(5) -> <<"friday">>; dow_to_wday(6) -> <<"saturday">>; dow_to_wday(7) -> <<"sunday">>. --spec days_in_month(kz_year(), 0..13) -> 28..31. +-spec days_in_month(kz_tyime:year(), 0..13) -> 28..31. days_in_month(_Year, 1) -> 31; days_in_month(_Year, 3) -> 31; days_in_month(_Year, 5) -> 31; @@ -237,10 +237,10 @@ days_in_month(Year, 2) -> 'false' -> 28 end. --spec pad_month(kz_month() | ne_binary()) -> ne_binary(). +-spec pad_month(kz_time:month() | kz_term:ne_binary()) -> kz_term:ne_binary(). pad_month(Month) -> kz_binary:pad_left(kz_term:to_binary(Month), 2, <<"0">>). --spec pad_day(kz_day() | ne_binary()) -> ne_binary(). +-spec pad_day(kz_time:day() | kz_term:ne_binary()) -> kz_term:ne_binary(). pad_day(Day) -> kz_binary:pad_left(kz_term:to_binary(Day), 2, <<"0">>). diff --git a/core/kazoo_stdlib/src/kz_json.erl b/core/kazoo_stdlib/src/kz_json.erl index 8aa4dfdb638..d933e18abd6 100644 --- a/core/kazoo_stdlib/src/kz_json.erl +++ b/core/kazoo_stdlib/src/kz_json.erl @@ -122,14 +122,14 @@ -spec new() -> object(). new() -> ?JSON_WRAPPER([]). --spec encode(json_term()) -> text(). --spec encode(json_term(), encode_options()) -> text(). +-spec encode(json_term()) -> kz_term:text(). +-spec encode(json_term(), encode_options()) -> kz_term:text(). encode(JObj) -> encode(JObj, []). encode(JObj, Options) -> jiffy:encode(JObj, Options). --spec unsafe_decode(iolist() | ne_binary()) -> json_term(). --spec unsafe_decode(iolist() | ne_binary(), ne_binary()) -> json_term(). +-spec unsafe_decode(iolist() | kz_term:ne_binary()) -> json_term(). +-spec unsafe_decode(iolist() | kz_term:ne_binary(), kz_term:ne_binary()) -> json_term(). unsafe_decode(Thing) when is_list(Thing); is_binary(Thing) -> @@ -150,8 +150,8 @@ unsafe_decode(JSON, <<"application/json">>) -> throw({'invalid_json', {'error', {0, 'decoder_exit'}}, JSON}) end. --spec decode(iolist() | ne_binary()) -> json_term(). --spec decode(iolist() | ne_binary(), ne_binary()) -> json_term(). +-spec decode(iolist() | kz_term:ne_binary()) -> json_term(). +-spec decode(iolist() | kz_term:ne_binary(), kz_term:ne_binary()) -> json_term(). decode(Thing) when is_list(Thing) orelse is_binary(Thing) -> @@ -242,7 +242,7 @@ is_json_term(MaybeJObj) -> %% Finds out whether 2 JSON objects are recursively identical. %% @end %%-------------------------------------------------------------------- --spec are_equal(api_object(), api_object()) -> boolean(). +-spec are_equal(kz_term:api_object(), kz_term:api_object()) -> boolean(). are_equal('undefined', 'undefined') -> 'true'; are_equal('undefined', _) -> 'false'; are_equal(_, 'undefined') -> 'false'; @@ -488,7 +488,7 @@ sum_jobjs([FirstJObj|JObjs], Sumer) %% Both lists MUST be of same size. %% @end %%-------------------------------------------------------------------- --spec order_by(path(), ne_binaries(), [objects()]) -> objects(). +-spec order_by(path(), kz_term:ne_binaries(), [objects()]) -> objects(). order_by(Path, Ids, ListOfJObjs) when is_list(Ids), is_list(ListOfJObjs) -> _ = [[put(get_value(Path, JObj), JObj) || JObj <- JObjs] @@ -508,7 +508,7 @@ to_proplist(?JSON_WRAPPER(Prop)) -> Prop. %% convert everything starting at a specific key to_proplist(Key, JObj) -> to_proplist(get_json_value(Key, JObj, new())). --spec recursive_to_proplist(object() | objects() | kz_proplist()) -> kz_proplist(). +-spec recursive_to_proplist(object() | objects() | kz_term:proplist()) -> kz_term:proplist(). recursive_to_proplist(?JSON_WRAPPER(Props)) -> [{K, recursive_to_proplist(V)} || {K, V} <- Props]; recursive_to_proplist(Props) when is_list(Props) -> @@ -535,7 +535,7 @@ to_map(Key, JObj) -> to_map_fold(JObj, #{}=Map) -> maps:merge(Map, recursive_to_map(JObj)). --spec recursive_to_map(object() | objects() | kz_proplist()) -> map(). +-spec recursive_to_map(object() | objects() | kz_term:proplist()) -> map(). recursive_to_map(?JSON_WRAPPER(Props)) -> maps:from_list([{K, recursive_to_map(V)} || {K, V} <- Props]); recursive_to_map(List) when is_list(List) -> @@ -559,7 +559,7 @@ recursive_from_map(List) when is_list(List) -> [recursive_from_map(Item) || Item <- List]; recursive_from_map(Else) -> Else. --spec get_json_value(path(), object()) -> api_object(). +-spec get_json_value(path(), object()) -> kz_term:api_object(). -spec get_json_value(path(), object(), Default) -> Default | object(). get_json_value(Key, JObj) -> get_json_value(Key, JObj, 'undefined'). get_json_value(Key, ?JSON_WRAPPER(_)=JObj, Default) -> @@ -569,7 +569,7 @@ get_json_value(Key, ?JSON_WRAPPER(_)=JObj, Default) -> _ -> Default end. --spec get_ne_json_value(path(), object()) -> api_object(). +-spec get_ne_json_value(path(), object()) -> kz_term:api_object(). -spec get_ne_json_value(path(), object(), Default) -> Default | object(). get_ne_json_value(Key, JObj) -> get_ne_json_value(Key, JObj, 'undefined'). @@ -630,7 +630,7 @@ foldr(F, Acc0, ?JSON_WRAPPER([])) when is_function(F, 3) -> Acc0; foldr(F, Acc0, ?JSON_WRAPPER(Prop)) when is_function(F, 3) -> lists:foldr(fun({Key, Value}, Acc1) -> F(Key, Value, Acc1) end, Acc0, Prop). --spec get_string_value(path(), object() | objects()) -> api_list(). +-spec get_string_value(path(), object() | objects()) -> kz_term:api_list(). -spec get_string_value(path(), object(), Default) -> list() | Default. get_string_value(Key, JObj) -> get_string_value(Key, JObj, 'undefined'). @@ -640,7 +640,7 @@ get_string_value(Key, JObj, Default) -> Value -> kz_term:safe_cast(Value, Default, fun kz_term:to_list/1) end. --spec get_list_value(path(), object() | objects()) -> api_list(). +-spec get_list_value(path(), object() | objects()) -> kz_term:api_list(). -spec get_list_value(path(), object() | objects(), Default) -> Default | list(). get_list_value(Key, JObj) -> get_list_value(Key, JObj, 'undefined'). @@ -651,7 +651,7 @@ get_list_value(Key, JObj, Default) -> _Else -> Default end. --spec get_binary_value(path(), object() | objects()) -> api_binary(). +-spec get_binary_value(path(), object() | objects()) -> kz_term:api_binary(). -spec get_binary_value(path(), object() | objects(), Default) -> binary() | Default. get_binary_value(Key, JObj) -> get_binary_value(Key, JObj, 'undefined'). @@ -661,8 +661,8 @@ get_binary_value(Key, JObj, Default) -> Value -> kz_term:safe_cast(Value, Default, fun kz_term:to_binary/1) end. --spec get_ne_binary_value(path(), object() | objects()) -> api_ne_binary(). --spec get_ne_binary_value(path(), object() | objects(), Default) -> ne_binary() | Default. +-spec get_ne_binary_value(path(), object() | objects()) -> kz_term:api_ne_binary(). +-spec get_ne_binary_value(path(), object() | objects(), Default) -> kz_term:ne_binary() | Default. get_ne_binary_value(Key, JObj) -> get_ne_binary_value(Key, JObj, 'undefined'). get_ne_binary_value(Key, JObj, Default) -> @@ -672,7 +672,7 @@ get_ne_binary_value(Key, JObj, Default) -> Value -> Value end. --spec get_lower_binary(path(), object() | objects()) -> api_binary(). +-spec get_lower_binary(path(), object() | objects()) -> kz_term:api_binary(). -spec get_lower_binary(path(), object() | objects(), Default) -> binary() | Default. get_lower_binary(Key, JObj) -> get_lower_binary(Key, JObj, 'undefined'). @@ -683,7 +683,7 @@ get_lower_binary(Key, JObj, Default) -> end. %% must be an existing atom --spec get_atom_value(path(), object() | objects()) -> api_atom(). +-spec get_atom_value(path(), object() | objects()) -> kz_term:api_atom(). -spec get_atom_value(path(), object() | objects(), Default) -> atom() | Default. get_atom_value(Key, JObj) -> get_atom_value(Key, JObj, 'undefined'). @@ -693,7 +693,7 @@ get_atom_value(Key, JObj, Default) -> Value -> kz_term:safe_cast(Value, Default, fun kz_term:to_atom/1) end. --spec get_boolean_value(path(), object() | objects()) -> api_atom(). +-spec get_boolean_value(path(), object() | objects()) -> kz_term:api_atom(). -spec get_boolean_value(path(), object() | objects(), Default) -> atom() | Default. get_boolean_value(Key, JObj) -> get_boolean_value(Key, JObj, 'undefined'). @@ -703,7 +703,7 @@ get_boolean_value(Key, JObj, Default) -> Value -> kz_term:safe_cast(Value, Default, fun kz_term:to_boolean/1) end. --spec get_integer_value(path(), object() | objects()) -> api_integer(). +-spec get_integer_value(path(), object() | objects()) -> kz_term:api_integer(). -spec get_integer_value(path(), object() | objects(), Default) -> integer() | Default. get_integer_value(Key, JObj) -> get_integer_value(Key, JObj, 'undefined'). @@ -713,7 +713,7 @@ get_integer_value(Key, JObj, Default) -> Value -> kz_term:safe_cast(Value, Default, fun kz_term:to_integer/1) end. --spec get_number_value(path(), object() | objects()) -> api_number(). +-spec get_number_value(path(), object() | objects()) -> kz_term:api_number(). -spec get_number_value(path(), object() | objects(), Default) -> number() | Default. get_number_value(Key, JObj) -> get_number_value(Key, JObj, 'undefined'). @@ -723,7 +723,7 @@ get_number_value(Key, JObj, Default) -> Value -> kz_term:safe_cast(Value, Default, fun kz_term:to_number/1) end. --spec get_float_value(path(), object() | objects()) -> api_float(). +-spec get_float_value(path(), object() | objects()) -> kz_term:api_float(). -spec get_float_value(path(), object() | objects(), Default) -> float() | Default. get_float_value(Key, JObj) -> get_float_value(Key, JObj, 'undefined'). @@ -753,8 +753,8 @@ is_true(Key, JObj, Default) -> V -> kz_term:is_true(V) end. --spec get_binary_boolean(path(), object() | objects()) -> api_ne_binary(). --spec get_binary_boolean(path(), object() | objects(), Default) -> Default | ne_binary(). +-spec get_binary_boolean(path(), object() | objects()) -> kz_term:api_ne_binary(). +-spec get_binary_boolean(path(), object() | objects(), Default) -> Default | kz_term:ne_binary(). get_binary_boolean(Key, JObj) -> get_binary_boolean(Key, JObj, 'undefined'). @@ -826,7 +826,7 @@ find_first_defined([Key|Keys], JObjs, Default) -> %% Returns the json object or 'undefined' %% @end %%-------------------------------------------------------------------- --spec find_value(path(), json_term(), objects()) -> api_object(). +-spec find_value(path(), json_term(), objects()) -> kz_term:api_object(). -spec find_value(path(), json_term(), objects(), Default) -> object() | Default. find_value(Key, Value, JObjs) -> find_value(Key, Value, JObjs, 'undefined'). @@ -868,7 +868,7 @@ get_value([Key|Ks], L, Default) when is_list(L) -> get_value(K, Doc, Default) -> get_value1(K, Doc, Default). --spec get_value1(path(), api_object() | objects(), Default) -> +-spec get_value1(path(), kz_term:api_object() | objects(), Default) -> json_term() | Default. get_value1([], 'undefined', Default) -> Default; get_value1([], JObj, _Default) -> JObj; @@ -1145,11 +1145,11 @@ replace_in_list(N, V1, [V | Vs], Acc) -> %% Read a json fixture file from the filesystem into memory %% @end %%-------------------------------------------------------------------- --spec load_fixture_from_file(atom(), nonempty_string() | ne_binary()) -> +-spec load_fixture_from_file(atom(), nonempty_string() | kz_term:ne_binary()) -> object() | {'error', atom()}. --spec load_fixture_from_file(atom(), nonempty_string() | ne_binary(), iodata()) -> +-spec load_fixture_from_file(atom(), nonempty_string() | kz_term:ne_binary(), iodata()) -> object() | {'error', atom()}. @@ -1211,7 +1211,7 @@ normalize_value(Obj) -> 'false' -> Obj end. --spec normalize_key(ne_binary()) -> ne_binary(). +-spec normalize_key(kz_term:ne_binary()) -> kz_term:ne_binary(). normalize_key(Key) when is_binary(Key) -> << <<(normalize_key_char(B))>> || <> <= Key>>. @@ -1223,10 +1223,10 @@ normalize_key_char(C) when is_integer(C), 16#C0 =< C, C =< 16#D6 -> C + 32; % fr normalize_key_char(C) when is_integer(C), 16#D8 =< C, C =< 16#DE -> C + 32; % so we only loop once normalize_key_char(C) -> C. --type search_replace_format() :: {ne_binary(), ne_binary()} | - {ne_binary(), ne_binary(), fun((any()) -> any())}. +-type search_replace_format() :: {kz_term:ne_binary(), kz_term:ne_binary()} | + {kz_term:ne_binary(), kz_term:ne_binary(), fun((any()) -> any())}. -type search_replace_formatters() :: [search_replace_format()]. --spec normalize_jobj(object(), ne_binaries(), search_replace_formatters()) -> object(). +-spec normalize_jobj(object(), kz_term:ne_binaries(), search_replace_formatters()) -> object(). normalize_jobj(?JSON_WRAPPER(_)=JObj, RemoveKeys, SearchReplaceFormatters) -> normalize_jobj( lists:foldl(fun search_replace_format/2 diff --git a/core/kazoo_stdlib/src/kz_term.erl b/core/kazoo_stdlib/src/kz_term.erl index 6f452ad3615..a21c91c4362 100644 --- a/core/kazoo_stdlib/src/kz_term.erl +++ b/core/kazoo_stdlib/src/kz_term.erl @@ -46,7 +46,105 @@ -export([a1hash/3, floor/1, ceiling/1]). --include_lib("kazoo_stdlib/include/kz_types.hrl"). +-type text() :: string() | atom() | binary() | iolist(). + +-type atoms() :: [atom()]. +-type pids() :: [pid()]. +-type references() :: [reference()]. + +-type proplist_key() :: any(). +-type proplist_value() :: any(). +-type proplist_property() :: atom() | {proplist_key(), proplist_value()}. +-type proplist() :: [proplist_property()]. +-type proplists() :: [proplist()]. +-type proplist_kv(K, V) :: [{K, V}]. + +-type pid_ref() :: {pid(), reference()}. +-type pid_refs() :: [pid_ref()]. +-type api_pid_ref() :: pid_ref() | 'undefined'. +-type api_pid_refs() :: pid_refs() | 'undefined'. + +-type api_terms() :: kz_json:object() | proplist(). +-type api_binary() :: binary() | 'undefined'. +-type api_ne_binary() :: ne_binary() | 'undefined'. +-type api_ne_binaries() :: [api_ne_binary()] | 'undefined'. +-type api_binaries() :: [api_binary()] | 'undefined'. +-type api_object() :: kz_json:object() | 'undefined'. +-type api_objects() :: kz_json:objects() | 'undefined'. +-type api_boolean() :: boolean() | 'undefined'. +-type api_atom() :: atom() | 'undefined'. +-type api_atoms() :: atoms() | 'undefined'. +-type api_string() :: string() | 'undefined'. +-type api_reference() :: reference() | 'undefined'. +-type api_pid() :: pid() | 'undefined'. +-type api_list() :: list() | 'undefined'. + +-type api_number() :: number() | 'undefined'. +-type api_integer() :: integer() | 'undefined'. +-type api_pos_integer() :: pos_integer() | 'undefined'. +-type api_non_neg_integer() :: non_neg_integer() | 'undefined'. +-type api_float() :: float() | 'undefined'. + +-type deeplist() :: iolist(). %[any() | deeplist()]. + +-type std_return() :: {'ok', any()} | {'error', any()}. + +-type jobj_return() :: {'ok', kz_json:object()} | {'error', any()}. +-type jobjs_return() :: {'ok', kz_json:objects()} | {'error', any()}. + +-type ne_binary() :: <<_:8,_:_*8>>. +-type ne_binaries() :: [ne_binary()]. +-type binaries() :: [binary()]. + +-type strings() :: [string()]. +-type integers() :: [integer()]. + +-type functions() :: [function()]. + +-export_type([text/0 + ,atoms/0 + ,pids/0 + ,references/0 + ,proplist_key/0 + ,proplist_value/0 + ,proplist_property/0 + ,proplist/0 + ,proplists/0 + ,proplist_kv/2 + ,pid_ref/0 + ,pid_refs/0 + ,api_pid_ref/0 + ,api_pid_refs/0 + ,api_terms/0 + ,api_binary/0 + ,api_ne_binary/0 + ,api_ne_binaries/0 + ,api_binaries/0 + ,api_object/0 + ,api_objects/0 + ,api_boolean/0 + ,api_atom/0 + ,api_atoms/0 + ,api_string/0 + ,api_reference/0 + ,api_pid/0 + ,api_list/0 + ,api_number/0 + ,api_integer/0 + ,api_pos_integer/0 + ,api_non_neg_integer/0 + ,api_float/0 + ,deeplist/0 + ,std_return/0 + ,jobj_return/0 + ,jobjs_return/0 + ,ne_binary/0 + ,ne_binaries/0 + ,binaries/0 + ,strings/0 + ,integers/0 + ,functions/0 + ]). %%-------------------------------------------------------------------- %% @public @@ -201,12 +299,12 @@ to_boolean(<<"false">>) -> 'false'; to_boolean("false") -> 'false'; to_boolean('false') -> 'false'. --spec to_date(binary() | string() | integer()) -> kz_date(). +-spec to_date(binary() | string() | integer()) -> kz_time:date(). to_date(X) -> {Date, _ } = to_datetime(X), Date. --spec to_datetime(binary() | string() | integer()) -> kz_datetime(). +-spec to_datetime(binary() | string() | integer()) -> kz_time:datetime(). to_datetime(X) when is_integer(X) -> calendar:gregorian_seconds_to_datetime(X); to_datetime(X) when is_binary(X) -> to_datetime(to_integer(X)); to_datetime(X) when is_list(X) -> to_datetime(to_integer(X)). diff --git a/core/kazoo_stdlib/src/kz_time.erl b/core/kazoo_stdlib/src/kz_time.erl index ec5bb4fd305..2b1b9c48fc2 100644 --- a/core/kazoo_stdlib/src/kz_time.erl +++ b/core/kazoo_stdlib/src/kz_time.erl @@ -38,6 +38,42 @@ -include_lib("kazoo_stdlib/include/kz_types.hrl"). +-type now() :: erlang:timestamp(). +-type year() :: non_neg_integer(). +-type month() :: 1..12. +-type day() :: 1..31. +-type hour() :: 0..23. +-type minute() :: 0..59. +-type second() :: 0..59. +-type daynum() :: 1..7. +-type weeknum() :: 1..53. +-type date() :: calendar:date(). %%{year(), month(), day()}. +-type time() :: calendar:time(). %%{hour(), minute(), second()}. +-type datetime() :: calendar:datetime(). %%{date(), time()}. +-type iso_week() :: calendar:yearweeknum(). %%{year(), weeknum()}. +-type gregorian_seconds() :: pos_integer(). +-type unix_seconds() :: pos_integer(). +-type api_seconds() :: 'undefined' | gregorian_seconds(). + +-export_type([now/0 + ,year/0 + ,month/0 + ,day/0 + ,hour/0 + ,minute/0 + ,second/0 + ,daynum/0 + ,weeknum/0 + ,date/0 + ,time/0 + ,datetime/0 + ,iso_week/0 + ,gregorian_seconds/0 + ,unix_seconds/0 + ,api_seconds/0 + ]). + + %% returns current seconds -spec current_tstamp() -> gregorian_seconds(). current_tstamp() -> @@ -59,7 +95,7 @@ unix_seconds_to_gregorian_seconds(UnixSeconds) -> unix_timestamp_to_gregorian_seconds(UnixTimestamp) -> ?UNIX_EPOCH_IN_GREGORIAN + (kz_term:to_integer(UnixTimestamp) div ?MILLISECONDS_IN_SECOND). --spec to_gregorian_seconds(kz_datetime(), api_ne_binary()) -> gregorian_seconds(). +-spec to_gregorian_seconds(datetime(), kz_term:api_ne_binary()) -> gregorian_seconds(). -ifdef(TEST). to_gregorian_seconds(Datetime, 'undefined') -> to_gregorian_seconds(Datetime, <<"America/Los_Angeles">>); @@ -75,7 +111,7 @@ to_gregorian_seconds({{_,_,_},{_,_,_}}=Datetime, ?NE_BINARY=FromTimezone) -> ). -endif. --spec pretty_print_datetime(kz_datetime() | integer()) -> ne_binary(). +-spec pretty_print_datetime(datetime() | integer()) -> kz_term:ne_binary(). pretty_print_datetime(Timestamp) when is_integer(Timestamp) -> pretty_print_datetime(calendar:gregorian_seconds_to_datetime(Timestamp)); pretty_print_datetime({{Y,Mo,D},{H,Mi,S}}) -> @@ -83,8 +119,8 @@ pretty_print_datetime({{Y,Mo,D},{H,Mi,S}}) -> ,[Y, Mo, D, H, Mi, S] )). --spec rfc1036(calendar:datetime() | gregorian_seconds()) -> ne_binary(). --spec rfc1036(calendar:datetime() | gregorian_seconds(), ne_binary()) -> ne_binary(). +-spec rfc1036(calendar:datetime() | gregorian_seconds()) -> kz_term:ne_binary(). +-spec rfc1036(calendar:datetime() | gregorian_seconds(), kz_term:ne_binary()) -> kz_term:ne_binary(). rfc1036(DateTime) -> rfc1036(DateTime, <<"GMT">>). @@ -102,7 +138,7 @@ rfc1036({Date = {Y, Mo, D}, {H, Mi, S}}, TZ) -> rfc1036(Timestamp, TZ) when is_integer(Timestamp) -> rfc1036(calendar:gregorian_seconds_to_datetime(Timestamp), TZ). --spec iso8601_time(calendar:time() | calendar:datetime() | gregorian_seconds()) -> ne_binary(). +-spec iso8601_time(calendar:time() | calendar:datetime() | gregorian_seconds()) -> kz_term:ne_binary(). iso8601_time({Hours, Mins, Secs}) -> H = kz_binary:pad_left(kz_term:to_binary(Hours), 2, <<"0">>), M = kz_binary:pad_left(kz_term:to_binary(Mins), 2, <<"0">>), @@ -114,7 +150,7 @@ iso8601_time({{_,_,_}, {_H, _M, _S}=Time}) -> iso8601_time(Timestamp) when is_integer(Timestamp) -> iso8601_time(calendar:gregorian_seconds_to_datetime(Timestamp)). --spec iso8601(calendar:datetime() | gregorian_seconds()) -> ne_binary(). +-spec iso8601(calendar:datetime() | gregorian_seconds()) -> kz_term:ne_binary(). iso8601({_Y,_M,_D}=Date) -> kz_date:to_iso8601_extended(Date); iso8601({{_Y,_M,_D}=Date, {0, 0, 0}}) -> @@ -148,7 +184,7 @@ month(10) -> <<"Oct">>; month(11) -> <<"Nov">>; month(12) -> <<"Dec">>. --spec pretty_print_elapsed_s(non_neg_integer()) -> ne_binary(). +-spec pretty_print_elapsed_s(non_neg_integer()) -> kz_term:ne_binary(). pretty_print_elapsed_s(0) -> <<"0s">>; pretty_print_elapsed_s(Seconds) -> iolist_to_binary(unitfy_seconds(Seconds)). @@ -167,8 +203,8 @@ unitfy_seconds(Seconds) -> D = Seconds div ?SECONDS_IN_DAY, [kz_term:to_binary(D), "d", unitfy_seconds(Seconds - (D * ?SECONDS_IN_DAY))]. --spec decr_timeout(kz_timeout(), kz_now() | gregorian_seconds()) -> kz_timeout(). --spec decr_timeout(kz_timeout(), kz_now() | gregorian_seconds(), kz_now() | gregorian_seconds()) -> kz_timeout(). +-spec decr_timeout(timeout(), now() | gregorian_seconds()) -> timeout(). +-spec decr_timeout(timeout(), now() | gregorian_seconds(), now() | gregorian_seconds()) -> timeout(). decr_timeout('infinity', _) -> 'infinity'; decr_timeout(Timeout, {_Mega, _S, _Micro}=Start) when is_integer(Timeout) -> decr_timeout(Timeout, Start, now()); @@ -200,9 +236,9 @@ decr_timeout_elapsed(Timeout, Elapsed) -> microseconds_to_seconds(Microseconds) -> kz_term:to_integer(Microseconds) div ?MICROSECONDS_IN_SECOND. milliseconds_to_seconds(Milliseconds) -> kz_term:to_integer(Milliseconds) div ?MILLISECONDS_IN_SECOND. --spec elapsed_s(kz_now() | pos_integer()) -> pos_integer(). --spec elapsed_ms(kz_now() | pos_integer()) -> pos_integer(). --spec elapsed_us(kz_now() | pos_integer()) -> pos_integer(). +-spec elapsed_s(now() | pos_integer()) -> pos_integer(). +-spec elapsed_ms(now() | pos_integer()) -> pos_integer(). +-spec elapsed_us(now() | pos_integer()) -> pos_integer(). elapsed_s({_,_,_}=Start) -> elapsed_s(Start, now()); elapsed_s(Start) when is_integer(Start) -> elapsed_s(Start, now_s()). @@ -212,9 +248,9 @@ elapsed_ms(Start) when is_integer(Start) -> elapsed_ms(Start, now_ms()). elapsed_us({_,_,_}=Start) -> elapsed_us(Start, now()); elapsed_us(Start) when is_integer(Start) -> elapsed_us(Start, now_us()). --spec elapsed_s(kz_now() | pos_integer(), kz_now() | pos_integer()) -> pos_integer(). --spec elapsed_ms(kz_now() | pos_integer(), kz_now() | pos_integer()) -> pos_integer(). --spec elapsed_us(kz_now() | pos_integer(), kz_now() | pos_integer()) -> pos_integer(). +-spec elapsed_s(now() | pos_integer(), now() | pos_integer()) -> pos_integer(). +-spec elapsed_ms(now() | pos_integer(), now() | pos_integer()) -> pos_integer(). +-spec elapsed_us(now() | pos_integer(), now() | pos_integer()) -> pos_integer(). elapsed_s({_,_,_}=Start, {_,_,_}=Now) -> timer:now_diff(Now, Start) div ?MICROSECONDS_IN_SECOND; elapsed_s({_,_,_}=Start, Now) -> elapsed_s(now_s(Start), Now); @@ -254,7 +290,7 @@ elapsed_us(Start, Now) is_integer(Now) -> (Now - Start) * ?MICROSECONDS_IN_SECOND. --spec now() -> kz_now(). +-spec now() -> now(). now() -> os:timestamp(). -spec now_s() -> gregorian_seconds(). @@ -265,9 +301,9 @@ now_s() -> erlang:system_time('seconds') + ?UNIX_EPOCH_IN_GREGORIAN. now_ms() -> erlang:system_time('milli_seconds') + (?UNIX_EPOCH_IN_GREGORIAN * ?MILLISECONDS_IN_SECOND). now_us() -> erlang:system_time('micro_seconds') + (?UNIX_EPOCH_IN_GREGORIAN * ?MICROSECONDS_IN_SECOND). --spec now_s(kz_now()) -> gregorian_seconds(). --spec now_ms(kz_now()) -> pos_integer(). --spec now_us(kz_now()) -> pos_integer(). +-spec now_s(now()) -> gregorian_seconds(). +-spec now_ms(now()) -> pos_integer(). +-spec now_us(now()) -> pos_integer(). now_us({MegaSecs, Secs, MicroSecs}) -> unix_us_to_gregorian_us((MegaSecs*?MICROSECONDS_IN_SECOND + Secs)*?MICROSECONDS_IN_SECOND + MicroSecs). now_ms({_,_,_}=Now) -> diff --git a/core/kazoo_stdlib/src/kz_types.erl b/core/kazoo_stdlib/src/kz_types.erl new file mode 100644 index 00000000000..10592c30342 --- /dev/null +++ b/core/kazoo_stdlib/src/kz_types.erl @@ -0,0 +1,171 @@ +%%%------------------------------------------------------------------- +%%% @copyright (C) 2017, 2600Hz +%%% @doc +%%% @end +%%%------------------------------------------------------------------- +-module(kz_types). + +-include_lib("xmerl/include/xmerl.hrl"). +-include_lib("kazoo_stdlib/include/kz_records.hrl"). + +%% when using gen_smtp to send emails, it takes a 5-tuple for a message-body part +-type mail_message_body() :: {kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist(), kz_term:proplist(), kz_term:ne_binary() | iolist()}. + +%% for setting types on dicts +-type dict(K,V) :: [{K, V}]. + +-type ip_list() :: kz_term:ne_binaries(). + +%% Recreate the non-exported types defined in the Erlang supervisor source +-type sup_child_spec() :: supervisor:child_spec(). +-type sup_child_specs() :: [sup_child_spec()]. +-type sup_start_flags() :: supervisor:sup_flags(). + +-type sup_init_ret() :: {'ok', {supervisor:sup_flags(), [supervisor:child_spec()]}} | + 'ignore'. + +-type sup_child_id() :: kz_term:api_pid(). +-type sup_startchild_err() :: 'already_present' | + {'already_started', sup_child_id()} | + any(). +-type sup_startchild_ret() :: {'ok', sup_child_id()} | + {'ok', sup_child_id(), any()} | + {'error', sup_startchild_err()}. + +%% Recreate the non-exported types defined in the Erlang gen_server source +-type startlink_err() :: {'already_started', pid()} | + 'shutdown' | + any(). +-type startlink_ret() :: {'ok', pid()} | + 'ignore' | + {'error', startlink_err()}. +-type startapp_ret() :: {'ok', pid()} | + {'ok', pid(), any()} | + {'error', startlink_err()}. + +-type call_from() :: kz_term:pid_ref(). +-type gen_server_timeout() :: 'hibernate' | non_neg_integer(). +-type handle_call_ret() :: {'reply', any(), any()} | + {'reply', any(), any(), gen_server_timeout()} | + {'noreply', any()} | + {'noreply', any(), gen_server_timeout()} | + {'stop', any(), any()} | + {'stop', any(), any(), any()}. + +-type handle_call_ret_state(State) :: {'reply', any(), State} | + {'reply', any(), State, gen_server_timeout()} | + {'noreply', State} | + {'noreply', State, gen_server_timeout()} | + {'stop', any(), State} | + {'stop', any(), State, any()}. + +-type handle_cast_ret() :: {'noreply', any()} | + {'noreply', any(), gen_server_timeout()} | + {'stop', any(), any()}. +-type handle_cast_ret_state(State) :: {'noreply', State} | + {'noreply', State, gen_server_timeout()} | + {'stop', any(), State}. + +-type handle_info_ret() :: {'noreply', any()} | + {'noreply', any(), gen_server_timeout()} | + {'stop', any(), any()}. +-type handle_info_ret_state(State) :: {'noreply', State} | + {'noreply', State, gen_server_timeout()} | + {'stop', any(), State}. + +-type handle_fsm_ret(State) :: {'next_state', atom(), State} | + {'next_state', atom(), State, timeout() | 'hibernate'} | + {'stop', any(), State}. + +-type handle_sync_event_ret(State) :: handle_fsm_ret(State) | + {'reply', any(), atom(), State} | + {'reply', any(), atom(), State, timeout() | 'hibernate'} | + {'stop', any(), any(), State}. + +-type server_ref() :: atom() | + {atom(), atom()} | + {'global', any()} | + {'via', atom(), any()} | + pid(). + +-type gen_server_name() :: {'local', atom()} | + {'global', any()} | + {'via', atom(), any()}. +-type gen_server_option() :: {'debug', list()} | + {'timeout', non_neg_integer()} | + {'spawn_opt', list()}. +-type gen_server_options() :: [gen_server_option()]. + + +%% XML types +-type xml_attrib_name() :: atom(). +-type xml_attrib_value() :: kz_term:ne_binary() | nonempty_string() | iolist() | atom() | number(). +-type xml_attrib() :: #xmlAttribute{}. +-type xml_attribs() :: [xml_attrib()]. + +-type xml_el() :: #xmlElement{}. +-type xml_els() :: [xml_el()]. + +-type xml_text() :: #xmlText{value :: iolist()}. +-type xml_texts() :: [xml_text()]. + + +-type xml_thing() :: xml_el() | xml_text(). +-type xml_things() :: xml_els() | xml_texts(). + + +%% KZ_NODES types + +-type whapp_info() :: #whapp_info{}. +-type kapps_info() :: [{binary(), whapp_info()}]. + +-type media_server() :: {kz_term:ne_binary(), kz_json:object()}. +-type media_servers() :: [media_server()]. + +-type kz_node() :: #kz_node{}. +-type kz_nodes() :: [kz_node()]. + +-export_type([mail_message_body/0 + ,dict/2 + ,ip_list/0 + ,sup_child_spec/0 + ,sup_child_specs/0 + ,sup_start_flags/0 + ,sup_init_ret/0 + ,sup_child_id/0 + ,sup_startchild_err/0 + ,sup_startchild_ret/0 + ,startlink_err/0 + ,startlink_ret/0 + ,startapp_ret/0 + ,call_from/0 + ,gen_server_timeout/0 + ,handle_call_ret/0 + ,handle_call_ret_state/1 + ,handle_cast_ret/0 + ,handle_cast_ret_state/1 + ,handle_info_ret/0 + ,handle_info_ret_state/1 + ,handle_fsm_ret/1 + ,handle_sync_event_ret/1 + ,server_ref/0 + ,gen_server_name/0 + ,gen_server_option/0 + ,gen_server_options/0 + ,xml_attrib_name/0 + ,xml_attrib_value/0 + ,xml_attrib/0 + ,xml_attribs/0 + ,xml_el/0 + ,xml_els/0 + ,xml_text/0 + ,xml_texts/0 + ,xml_thing/0 + ,xml_things/0 + ,whapp_info/0 + ,kapps_info/0 + ,media_server/0 + ,media_servers/0 + ,kz_node/0 + ,kz_nodes/0 + ]). diff --git a/core/kazoo_stdlib/src/props.erl b/core/kazoo_stdlib/src/props.erl index c7da0d5e000..ca6a1f9cabc 100644 --- a/core/kazoo_stdlib/src/props.erl +++ b/core/kazoo_stdlib/src/props.erl @@ -40,17 +40,17 @@ %% don't import the get_keys/1 that fetches keys from the process dictionary -compile({'no_auto_import', [get_keys/1]}). --spec set_values(kz_proplist(), kz_proplist()) -> kz_proplist(). +-spec set_values(kz_term:proplist(), kz_term:proplist()) -> kz_term:proplist(). set_values([], Props) -> Props; set_values([{K, V}|KVs], Props) -> set_values(KVs, set_value(K, V, Props)); set_values([K|KVs], Props) -> set_values(KVs, set_value(K, 'true', Props)). --spec set_value(kz_proplist_property(), kz_proplist()) -> - kz_proplist(). --spec set_value(kz_proplist_key(), kz_proplist_value(), kz_proplist()) -> - kz_proplist(). +-spec set_value(kz_term:proplist_property(), kz_term:proplist()) -> + kz_term:proplist(). +-spec set_value(kz_term:proplist_key(), kz_term:proplist_value(), kz_term:proplist()) -> + kz_term:proplist(). set_value({K, V}, Props) -> set_value(K, V, Props); set_value(K, Props) -> @@ -64,16 +64,16 @@ set_value([K|Ks], V, Props) -> set_value(K, V, Props) -> [{K, V} | [KV || KV <- Props, not do_keys_match(KV, K)]]. --spec do_keys_match(kz_proplist_property(), kz_proplist_key()) -> +-spec do_keys_match(kz_term:proplist_property(), kz_term:proplist_key()) -> boolean(). do_keys_match({Key, _}, Key) -> 'true'; do_keys_match(Key, Key) -> 'true'; do_keys_match(_K1, _K2) -> 'false'. --spec insert_value(kz_proplist_property(), kz_proplist()) -> - kz_proplist(). --spec insert_value(kz_proplist_key(), kz_proplist_value(), kz_proplist()) -> - kz_proplist(). +-spec insert_value(kz_term:proplist_property(), kz_term:proplist()) -> + kz_term:proplist(). +-spec insert_value(kz_term:proplist_key(), kz_term:proplist_value(), kz_term:proplist()) -> + kz_term:proplist(). insert_value({K, V}, Props) -> insert_value(K, V, Props); insert_value(K, Props) -> @@ -85,17 +85,17 @@ insert_value(K, V, Props) -> _Value -> Props end. --spec insert_values(kz_proplist(), kz_proplist()) -> kz_proplist(). +-spec insert_values(kz_term:proplist(), kz_term:proplist()) -> kz_term:proplist(). insert_values(KVs, Props) -> lists:foldl(fun insert_value/2, Props, KVs). %% replaces value of Key with Value if Key exists; otherwise Props is unchanged --spec replace_value(any(), any(), kz_proplist()) -> kz_proplist(). +-spec replace_value(any(), any(), kz_term:proplist()) -> kz_term:proplist(). replace_value(Key, Value, Props) -> lists:keyreplace(Key, 1, Props, {Key, Value}). --type filter_fun() :: fun((kz_proplist_property()) -> boolean()). --spec filter(filter_fun(), kz_proplist()) -> kz_proplist(). +-type filter_fun() :: fun((kz_term:proplist_property()) -> boolean()). +-spec filter(filter_fun(), kz_term:proplist()) -> kz_term:proplist(). filter(Fun, Props) when is_function(Fun, 1), is_list(Props) -> [P || P <- Props, Fun(P)]. @@ -104,20 +104,20 @@ filter(Fun, Props) when is_function(Fun, 1), filter_empty(Props) -> filter(fun is_not_empty/1, Props). --spec is_not_empty(kz_proplist_property()) -> boolean(). +-spec is_not_empty(kz_term:proplist_property()) -> boolean(). is_not_empty({_, V}) -> not kz_term:is_empty(V); is_not_empty(_V) -> 'true'. --spec filter_undefined(kz_proplist()) -> kz_proplist(). +-spec filter_undefined(kz_term:proplist()) -> kz_term:proplist(). filter_undefined(Props) -> filter(fun is_not_undefined/1, Props). --spec is_not_undefined(kz_proplist_property()) -> boolean(). +-spec is_not_undefined(kz_term:proplist_property()) -> boolean(). is_not_undefined({_, 'undefined'}) -> 'false'; is_not_undefined(_V) -> 'true'. --spec get_value(kz_proplist_key() | [kz_proplist_key()], kz_proplist()) -> any(). --spec get_value(kz_proplist_key() | [kz_proplist_key()], kz_proplist(), Default) -> +-spec get_value(kz_term:proplist_key() | [kz_term:proplist_key()], kz_term:proplist()) -> any(). +-spec get_value(kz_term:proplist_key() | [kz_term:proplist_key()], kz_term:proplist(), Default) -> Default | any(). get_value(Key, Props) -> get_value(Key, Props, 'undefined'). @@ -144,8 +144,8 @@ get_value(Key, Props, Default) when is_list(Props) -> end. %% Given a list of keys, find the first one defined --spec get_first_defined([kz_proplist_key()], kz_proplist()) -> 'undefined' | any(). --spec get_first_defined([kz_proplist_key()], kz_proplist(), Default) -> Default | any(). +-spec get_first_defined([kz_term:proplist_key()], kz_term:proplist()) -> 'undefined' | any(). +-spec get_first_defined([kz_term:proplist_key()], kz_term:proplist(), Default) -> Default | any(). get_first_defined(Keys, Props) -> get_first_defined(Keys, Props, 'undefined'). get_first_defined([], _Props, Default) -> Default; @@ -155,13 +155,13 @@ get_first_defined([H|T], Props, Default) -> V -> V end. --spec get_is_true(kz_proplist_key(), kz_proplist()) -> api_boolean(). --spec get_is_true(kz_proplist_key(), kz_proplist(), Default) -> Default | boolean(). +-spec get_is_true(kz_term:proplist_key(), kz_term:proplist()) -> kz_term:api_boolean(). +-spec get_is_true(kz_term:proplist_key(), kz_term:proplist(), Default) -> Default | boolean(). get_is_true(Key, Props) -> is_true(Key, Props). get_is_true(Key, Props, Default) -> is_true(Key, Props, Default). --spec is_true(kz_proplist_key(), kz_proplist()) -> api_boolean(). --spec is_true(kz_proplist_key(), kz_proplist(), Default) -> Default | boolean(). +-spec is_true(kz_term:proplist_key(), kz_term:proplist()) -> kz_term:api_boolean(). +-spec is_true(kz_term:proplist_key(), kz_term:proplist(), Default) -> Default | boolean(). is_true(Key, Props) -> is_true(Key, Props, 'undefined'). is_true(Key, Props, Default) -> @@ -170,13 +170,13 @@ is_true(Key, Props, Default) -> V -> kz_term:is_true(V) end. --spec get_is_false(kz_proplist_key(), kz_proplist()) -> api_boolean(). --spec get_is_false(kz_proplist_key(), kz_proplist(), Default) -> Default | boolean(). +-spec get_is_false(kz_term:proplist_key(), kz_term:proplist()) -> kz_term:api_boolean(). +-spec get_is_false(kz_term:proplist_key(), kz_term:proplist(), Default) -> Default | boolean(). get_is_false(Key, Props) -> is_false(Key, Props). get_is_false(Key, Props, Default) -> is_false(Key, Props, Default). --spec is_false(kz_proplist_key(), kz_proplist()) -> api_boolean(). --spec is_false(kz_proplist_key(), kz_proplist(), Default) -> boolean() | Default. +-spec is_false(kz_term:proplist_key(), kz_term:proplist()) -> kz_term:api_boolean(). +-spec is_false(kz_term:proplist_key(), kz_term:proplist(), Default) -> boolean() | Default. is_false(Key, Props) -> is_false(Key, Props, 'undefined'). is_false(Key, Props, Default) -> @@ -185,9 +185,9 @@ is_false(Key, Props, Default) -> V -> kz_term:is_false(V) end. --spec get_integer_value(kz_proplist_key(), kz_proplist()) -> - api_integer(). --spec get_integer_value(kz_proplist_key(), kz_proplist(), Default) -> +-spec get_integer_value(kz_term:proplist_key(), kz_term:proplist()) -> + kz_term:api_integer(). +-spec get_integer_value(kz_term:proplist_key(), kz_term:proplist(), Default) -> integer() | Default. get_integer_value(Key, Props) -> get_integer_value(Key, Props, 'undefined'). @@ -197,9 +197,9 @@ get_integer_value(Key, Props, Default) -> Val -> kz_term:safe_cast(Val, Default, fun kz_term:to_integer/1) end. --spec get_atom_value(kz_proplist_key(), kz_proplist()) -> +-spec get_atom_value(kz_term:proplist_key(), kz_term:proplist()) -> atom(). --spec get_atom_value(kz_proplist_key(), kz_proplist(), Default) -> +-spec get_atom_value(kz_term:proplist_key(), kz_term:proplist(), Default) -> atom() | Default. get_atom_value(Key, Props) -> get_atom_value(Key, Props, 'undefined'). @@ -209,9 +209,9 @@ get_atom_value(Key, Props, Default) -> Val -> kz_term:safe_cast(Val, Default, fun kz_term:to_atom/1) end. --spec get_binary_value(kz_proplist_key() | [kz_proplist_key()], kz_proplist()) -> api_binary(). --spec get_binary_value(kz_proplist_key() | [kz_proplist_key()], kz_proplist(), Default) -> - ne_binary() | Default. +-spec get_binary_value(kz_term:proplist_key() | [kz_term:proplist_key()], kz_term:proplist()) -> kz_term:api_binary(). +-spec get_binary_value(kz_term:proplist_key() | [kz_term:proplist_key()], kz_term:proplist(), Default) -> + kz_term:ne_binary() | Default. get_binary_value(Key, Props) -> get_binary_value(Key, Props, 'undefined'). get_binary_value(Keys, Props, Default) when is_list(Keys) -> @@ -225,9 +225,9 @@ get_binary_value(Key, Props, Default) -> V -> kz_term:safe_cast(V, Default, fun kz_term:to_binary/1) end. --spec get_ne_binary_value(kz_proplist_key(), kz_proplist()) -> api_binary(). --spec get_ne_binary_value(kz_proplist_key(), kz_proplist(), Default) -> - ne_binary() | Default. +-spec get_ne_binary_value(kz_term:proplist_key(), kz_term:proplist()) -> kz_term:api_binary(). +-spec get_ne_binary_value(kz_term:proplist_key(), kz_term:proplist(), Default) -> + kz_term:ne_binary() | Default. get_ne_binary_value(Key, Props) -> get_ne_binary_value(Key, Props, 'undefined'). get_ne_binary_value(Key, Props, Default) -> @@ -237,18 +237,18 @@ get_ne_binary_value(Key, Props, Default) -> V -> kz_term:safe_cast(V, Default, fun kz_term:to_binary/1) end. --spec get_keys(kz_proplist()) -> [kz_proplist_key()] | []. +-spec get_keys(kz_term:proplist()) -> [kz_term:proplist_key()] | []. get_keys([]) -> []; get_keys(Props) -> [as_key(KV) || KV <- Props]. --spec as_key(kz_proplist_property()) -> atom() | kz_proplist_key(). +-spec as_key(kz_term:proplist_property()) -> atom() | kz_term:proplist_key(). as_key(A) when is_atom(A) -> A; as_key({K, _}) -> K. --spec get_all_values(kz_proplist_key(), kz_proplist()) -> [kz_proplist_value()]. +-spec get_all_values(kz_term:proplist_key(), kz_term:proplist()) -> [kz_term:proplist_value()]. get_all_values(Key, Props) -> [V || {K, V} <- Props, K =:= Key]. --spec get_values_and_keys(kz_proplist()) -> {[kz_proplist_value()], [kz_proplist_key()]}. +-spec get_values_and_keys(kz_term:proplist()) -> {[kz_term:proplist_value()], [kz_term:proplist_key()]}. get_values_and_keys(Props) -> lists:foldr(fun(Key, {Vs, Ks}) -> {[get_value(Key, Props)|Vs], [Key|Ks]} @@ -257,25 +257,25 @@ get_values_and_keys(Props) -> ,get_keys(Props) ). --spec delete(kz_proplist_key(), kz_proplist()) -> kz_proplist(). +-spec delete(kz_term:proplist_key(), kz_term:proplist()) -> kz_term:proplist(). delete(K, Props) -> case lists:keyfind(K, 1, Props) of {K, _} -> lists:keydelete(K, 1, Props); 'false' -> lists:delete(K, Props) end. --spec delete_keys([kz_proplist_key()], kz_proplist()) -> kz_proplist(). +-spec delete_keys([kz_term:proplist_key()], kz_term:proplist()) -> kz_term:proplist(). delete_keys([], Props) -> Props; delete_keys([_|_]=Ks, Props) -> lists:foldl(fun delete/2, Props, Ks). --spec is_defined(kz_proplist_key(), kz_proplist()) -> boolean(). +-spec is_defined(kz_term:proplist_key(), kz_term:proplist()) -> boolean(). is_defined(Key, Props) -> get_value(Key, Props) =/= 'undefined'. --spec unique(kz_proplist()) -> kz_proplist(). +-spec unique(kz_term:proplist()) -> kz_term:proplist(). unique(List) -> unique(List, []). --spec unique(kz_proplist(), kz_proplist()) -> kz_proplist(). +-spec unique(kz_term:proplist(), kz_term:proplist()) -> kz_term:proplist(). unique([], Uniques) -> lists:reverse(Uniques); unique([{Key, _}=H|T], Uniques) -> unique([X || X <- T, ufun(X, Key)], [H|Uniques]); @@ -285,11 +285,11 @@ unique([Key|T], Uniques) -> ufun({K, _}, Key) -> K =/= Key; ufun(K, Key) -> K =/= Key. --spec to_log(kz_proplist()) -> 'ok'. +-spec to_log(kz_term:proplist()) -> 'ok'. to_log(Props) -> to_log(Props, <<"Props">>). --spec to_log(kz_proplist(), ne_binary()) -> 'ok'. +-spec to_log(kz_term:proplist(), kz_term:ne_binary()) -> 'ok'. to_log(Props, Header) -> Id = kz_binary:rand_hex(4), lager:debug("===== Start ~s - ~s ====", [Header, Id]), diff --git a/core/kazoo_stdlib/test/kz_date_tests.erl b/core/kazoo_stdlib/test/kz_date_tests.erl index 3ad9d508112..bd98d8e9e51 100644 --- a/core/kazoo_stdlib/test/kz_date_tests.erl +++ b/core/kazoo_stdlib/test/kz_date_tests.erl @@ -106,7 +106,7 @@ prop_normalize() -> safe_date() -> ?LET({Y, M} - ,{kz_year(), kz_month()} + ,{kz_time:year(), kz_time:month()} ,{Y, M, range(1, kz_date:days_in_month(Y, M))} ). @@ -121,7 +121,7 @@ funky_date({Y, M, D}, MonthsBack) -> prop_iso_week() -> ?FORALL(ISOWeek - ,{kz_year(), kz_weeknum()} + ,{kz_time:year(), kz_time:weeknum()} ,begin RoundTrip = kz_date:to_iso_week(kz_date:from_iso_week(ISOWeek)), ?WHENFAIL(io:format("failed to convert to/from iso week for ~p <=> ~p~n" diff --git a/core/kazoo_tasks/src/kz_tasks.erl b/core/kazoo_tasks/src/kz_tasks.erl index 998d7856207..9f2053d6f86 100644 --- a/core/kazoo_tasks/src/kz_tasks.erl +++ b/core/kazoo_tasks/src/kz_tasks.erl @@ -36,39 +36,39 @@ -define(TASK_ID_SIZE, 15). -type id() :: <<_:(8*2*?TASK_ID_SIZE)>>. --type task() :: #{worker_pid => api_pid() - ,worker_node => api_ne_binary() - ,account_id => ne_binary() - ,auth_account_id => ne_binary() +-type task() :: #{worker_pid => kz_term:api_pid() + ,worker_node => kz_term:api_ne_binary() + ,account_id => kz_term:ne_binary() + ,auth_account_id => kz_term:ne_binary() ,id => id() - ,category => ne_binary() - ,action => ne_binary() - ,file_name => api_ne_binary() - ,created => gregorian_seconds() %% Time of task creation (PUT) - ,started => api_seconds() %% Time of task start (PATCH) - ,finished => api_seconds() %% Time of task finish (> started) - ,total_rows => api_pos_integer() %% CSV rows (undefined for a noinput task) - ,total_rows_failed => api_non_neg_integer() %% Rows that crashed or didn't return ok - ,total_rows_succeeded => api_non_neg_integer() %% Rows that returned 'ok' - ,was_stopped => api_boolean() %% true if stopped, undefined of false otherwise + ,category => kz_term:ne_binary() + ,action => kz_term:ne_binary() + ,file_name => kz_term:api_ne_binary() + ,created => kz_time:gregorian_seconds() %% Time of task creation (PUT) + ,started => kz_time:api_seconds() %% Time of task start (PATCH) + ,finished => kz_time:api_seconds() %% Time of task finish (> started) + ,total_rows => kz_term:api_pos_integer() %% CSV rows (undefined for a noinput task) + ,total_rows_failed => kz_term:api_non_neg_integer() %% Rows that crashed or didn't return ok + ,total_rows_succeeded => kz_term:api_non_neg_integer() %% Rows that returned 'ok' + ,was_stopped => kz_term:api_boolean() %% true if stopped, undefined of false otherwise }. --type input() :: api_ne_binary() | kz_json:objects(). +-type input() :: kz_term:api_ne_binary() | kz_json:objects(). -type output_header() :: kz_csv:header() | {replace, kz_csv:header()}. --type columns() :: sets:set(ne_binary()). +-type columns() :: sets:set(kz_term:ne_binary()). -type help_error() :: {'error', 'unknown_category_action'}. --type return() :: 'ok' | api_ne_binary() | +-type return() :: 'ok' | kz_term:api_ne_binary() | kz_csv:row() | [kz_csv:row()] | kz_csv:mapped_row() | [kz_csv:mapped_row()]. -type iterator() :: 'init' | 'stop' | any(). --type extra_args() :: #{account_id => ne_binary() - ,auth_account_id => ne_binary() +-type extra_args() :: #{account_id => kz_term:ne_binary() + ,auth_account_id => kz_term:ne_binary() }. -type args() :: map(). @@ -93,19 +93,19 @@ %%% API %%%=================================================================== --spec mandatory(kz_json:object()) -> ne_binaries(). +-spec mandatory(kz_json:object()) -> kz_term:ne_binaries(). mandatory(APIJObj) -> kz_json:get_list_value(?API_MANDATORY, APIJObj, []). --spec optional(kz_json:object()) -> ne_binaries(). +-spec optional(kz_json:object()) -> kz_term:ne_binaries(). optional(APIJObj) -> kz_json:get_list_value(?API_OPTIONAL, APIJObj, []). --spec possible_fields(kz_json:object()) -> ne_binaries(). +-spec possible_fields(kz_json:object()) -> kz_term:ne_binaries(). possible_fields(APIJObj) -> mandatory(APIJObj) ++ optional(APIJObj). --spec input_mime(kz_json:object()) -> ne_binary(). +-spec input_mime(kz_json:object()) -> kz_term:ne_binary(). input_mime(APIJObj) -> kz_json:get_ne_binary_value(?API_INPUT_MIME, APIJObj, ?NIL_MIME). @@ -122,7 +122,7 @@ all() -> view([]). %% @doc %% @end %%-------------------------------------------------------------------- --spec all(ne_binary()) -> kz_json:objects(). +-spec all(kz_term:ne_binary()) -> kz_json:objects(). all(?MATCH_ACCOUNT_RAW(AccountId)) -> view([{startkey, [AccountId, kz_time:now_s(), kz_json:new()]} ,{endkey, [AccountId]} @@ -148,8 +148,8 @@ read(TaskId=?NE_BINARY) -> %% Verify a task previous to its creation in DB. %% @end %%-------------------------------------------------------------------- --spec new(ne_binary(), ne_binary() - ,ne_binary(), ne_binary(), api_pos_integer(), input(), api_binary()) -> +-spec new(kz_term:ne_binary(), kz_term:ne_binary() + ,kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_pos_integer(), input(), kz_term:api_binary()) -> {'ok', kz_json:object()} | help_error() | {'error', kz_json:object()}. @@ -205,7 +205,7 @@ new_id() -> %%%=================================================================== %% @private --spec help(ne_binary(), ne_binary()) -> +-spec help(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object() | {'error', 'unknown_category_action'}. help(Category, Action) -> @@ -261,7 +261,7 @@ find_input_errors(API, InputRecord=[_|_]) -> Fields = kz_json:get_keys(hd(InputRecord)), find_API_errors(API, Fields, 'true'). --spec find_API_errors(kz_json:object(), ne_binaries(), boolean()) -> map(). +-spec find_API_errors(kz_json:object(), kz_term:ne_binaries(), boolean()) -> map(). find_API_errors(API, Fields, HasInputData) -> Mandatory = mandatory(API), Routines = @@ -282,7 +282,7 @@ find_API_errors(API, Fields, HasInputData) -> ], lists:foldl(fun (F, Errors) -> F(Errors) end, #{}, Routines). --spec are_mandatories_unset(nonempty_list(boolean()), nonempty_list(ne_binary())) -> boolean(). +-spec are_mandatories_unset(nonempty_list(boolean()), nonempty_list(kz_term:ne_binary())) -> boolean(). are_mandatories_unset(IsMandatory, Row) -> MapF = fun (Mandatory, Value) -> Mandatory @@ -416,7 +416,7 @@ is_processing(_) -> false. %% @private --spec status(task()) -> ne_binary(). +-spec status(task()) -> kz_term:ne_binary(). status(#{was_stopped := true}) -> ?STATUS_STOPPED; diff --git a/core/kazoo_templates/src/kz_pdf.erl b/core/kazoo_templates/src/kz_pdf.erl index cacaad739ab..4c91031186e 100644 --- a/core/kazoo_templates/src/kz_pdf.erl +++ b/core/kazoo_templates/src/kz_pdf.erl @@ -30,21 +30,21 @@ -define(PDF_CONFIG_CAT, <<(?CONFIG_CAT)/binary, ".pdf">>). -define(HTML_TO_PDF, <<"/usr/bin/htmldoc --quiet --webpage -f $pdf$ $html$">>). --type ret() :: {'ok', ne_binary()} | {'error', any()}. +-type ret() :: {'ok', kz_term:ne_binary()} | {'error', any()}. %%-------------------------------------------------------------------- %% @public %% @doc %% @end %%-------------------------------------------------------------------- --spec find_template(ne_binary(), kz_proplist() | ne_binary()) -> ret(). +-spec find_template(kz_term:ne_binary(), kz_term:proplist() | kz_term:ne_binary()) -> ret(). find_template(AccountId, DocType) when is_binary(DocType) -> find_template(AccountId, DocType, <>); find_template(AccountId, Props) -> DocType = props:get_first_defined([<<"type">>, <<"pvt_type">>], Props), find_template(AccountId, Props, <>). --spec find_template(ne_binary(), ne_binary() | kz_proplist(), ne_binary()) -> ret(). +-spec find_template(kz_term:ne_binary(), kz_term:ne_binary() | kz_term:proplist(), kz_term:ne_binary()) -> ret(). find_template(AccountId, DocType, AttachmentId) when is_binary(DocType) -> AccountDb = kz_util:format_account_db(AccountId), case kz_datamgr:fetch_attachment(AccountDb, ?TEMPLATE_DOC_ID(DocType), AttachmentId) of @@ -63,7 +63,7 @@ find_template(AccountId, Props, AttachmentId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec generate(ne_binary(), kz_proplist()) -> ret(). +-spec generate(kz_term:ne_binary(), kz_term:proplist()) -> ret(). generate(AccountId, Props) -> case find_template(AccountId, Props) of {'error', _R}=Error -> Error; @@ -71,7 +71,7 @@ generate(AccountId, Props) -> generate(AccountId, Props, Template) end. --spec generate(ne_binary(), kz_proplist(), ne_binary()) -> ret(). +-spec generate(kz_term:ne_binary(), kz_term:proplist(), kz_term:ne_binary()) -> ret(). generate(Account, Props, Template) -> AccountId = kz_util:format_account_id(Account, 'raw'), DocType = props:get_first_defined([<<"type">>, <<"pvt_type">>], Props), @@ -122,7 +122,7 @@ error_empty() -> %% @doc %% @end %%-------------------------------------------------------------------- --spec cmd_fold({ne_binary(), ne_binary()}, ne_binary()) -> ne_binary(). +-spec cmd_fold({kz_term:ne_binary(), kz_term:ne_binary()}, kz_term:ne_binary()) -> kz_term:ne_binary(). cmd_fold({Search, Replace}, Subject) -> binary:replace(Subject, Search, Replace). @@ -131,7 +131,7 @@ cmd_fold({Search, Replace}, Subject) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec default_template(ne_binary(), ne_binary()) -> ret(). +-spec default_template(kz_term:ne_binary(), kz_term:ne_binary()) -> ret(). default_template(DocType, AttachmentId) -> lager:debug("searching for default template ~s", [AttachmentId]), case kz_datamgr:fetch_attachment(?KZ_CONFIG_DB, ?TEMPLATE_DOC_ID(DocType), AttachmentId) of @@ -143,7 +143,7 @@ default_template(DocType, AttachmentId) -> Error end. --spec maybe_create_default_template(ne_binary(), ne_binary()) -> ret(). +-spec maybe_create_default_template(kz_term:ne_binary(), kz_term:ne_binary()) -> ret(). maybe_create_default_template(DocType, AttachmentId) -> PrivDir = code:priv_dir('crossbar'), TemplateFile = filename:join([PrivDir, <<"couchdb">>, <<"templates">>, AttachmentId]), @@ -155,7 +155,7 @@ maybe_create_default_template(DocType, AttachmentId) -> {'ok', Template} -> create_default_template(Template, DocType, AttachmentId) end. --spec create_default_template(binary(), ne_binary(), ne_binary()) -> ret(). +-spec create_default_template(binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> ret(). create_default_template(Template, DocType, AttachmentId) -> lager:debug("creating default template ~s", [DocType]), Default = kz_json:from_list([{<<"template_name">>, DocType}]), @@ -177,7 +177,7 @@ create_default_template(Template, DocType, AttachmentId) -> Error end. --spec save_default_attachment(binary(), ne_binary(), ne_binary()) -> ret(). +-spec save_default_attachment(binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> ret(). save_default_attachment(Template, DocType, AttachmentId) -> lager:debug("saving default template ~s attachment", [DocType]), case diff --git a/core/kazoo_templates/src/kz_template.erl b/core/kazoo_templates/src/kz_template.erl index 8ce19809c78..1caa52e1a28 100644 --- a/core/kazoo_templates/src/kz_template.erl +++ b/core/kazoo_templates/src/kz_template.erl @@ -21,7 +21,7 @@ | Options ]). --type template() :: nonempty_string() | ne_binary(). +-type template() :: nonempty_string() | kz_term:ne_binary(). -type template_result() :: {'ok', iolist() | atom()} | {'error', any()}. @@ -45,9 +45,9 @@ %% @doc %% @end %%-------------------------------------------------------------------- --spec render(atom(), kz_proplist()) -> template_result(). --spec render(template(), atom(), kz_proplist()) -> template_result(). --spec render(template(), atom(), kz_proplist(), kz_proplist()) -> template_result(). +-spec render(atom(), kz_term:proplist()) -> template_result(). +-spec render(template(), atom(), kz_term:proplist()) -> template_result(). +-spec render(template(), atom(), kz_term:proplist(), kz_term:proplist()) -> template_result(). render(Module, TemplateData) -> render_template(Module, TemplateData). @@ -62,7 +62,7 @@ render(Template, Module, TemplateData, CompileOpts) -> -spec compile(template(), atom()) -> template_result(). --spec compile(template(), atom(), kz_proplist()) -> template_result(). +-spec compile(template(), atom(), kz_term:proplist()) -> template_result(). compile(Template, Module) -> compile(Template, Module, []). @@ -94,7 +94,7 @@ compile(Path, Module, CompileOpts) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec render_template(atom(), kz_proplist()) -> template_result(). +-spec render_template(atom(), kz_term:proplist()) -> template_result(). render_template(Module, TemplateData) -> lager:debug("rendering using ~s", [Module]), try Module:render(props:filter_empty(TemplateData)) of diff --git a/core/kazoo_token_buckets/src/kazoo_token_buckets_app.erl b/core/kazoo_token_buckets/src/kazoo_token_buckets_app.erl index 69dc98ff539..73d668a8ee2 100644 --- a/core/kazoo_token_buckets/src/kazoo_token_buckets_app.erl +++ b/core/kazoo_token_buckets/src/kazoo_token_buckets_app.erl @@ -17,7 +17,7 @@ %% @public %% @doc Implement the application start behaviour %%-------------------------------------------------------------------- --spec start(application:start_type(), any()) -> startapp_ret(). +-spec start(application:start_type(), any()) -> kz_types:startapp_ret(). start(_Type, _Args) -> kazoo_token_buckets_sup:start_link(). diff --git a/core/kazoo_token_buckets/src/kazoo_token_buckets_sup.erl b/core/kazoo_token_buckets/src/kazoo_token_buckets_sup.erl index 29525134dc4..bd41d7269a8 100644 --- a/core/kazoo_token_buckets/src/kazoo_token_buckets_sup.erl +++ b/core/kazoo_token_buckets/src/kazoo_token_buckets_sup.erl @@ -39,11 +39,11 @@ %% @public %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). --spec buckets_srv() -> api_pid(). +-spec buckets_srv() -> kz_term:api_pid(). buckets_srv() -> case [P || {'kz_buckets', P, _, _} <- supervisor:which_children(?SERVER)] of [] -> 'undefined'; @@ -63,7 +63,7 @@ buckets_srv() -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'one_for_one', MaxRestarts = 5, diff --git a/core/kazoo_token_buckets/src/kz_buckets.erl b/core/kazoo_token_buckets/src/kz_buckets.erl index e18982504bb..9a72d4683bb 100644 --- a/core/kazoo_token_buckets/src/kz_buckets.erl +++ b/core/kazoo_token_buckets/src/kz_buckets.erl @@ -57,10 +57,10 @@ }). -type state() :: #state{}. --record(bucket, {key :: {ne_binary(), ne_binary()} | '_' +-record(bucket, {key :: {kz_term:ne_binary(), kz_term:ne_binary()} | '_' ,srv :: pid() | '$1' | '$2' | '_' ,ref :: reference() | '$2' | '_' - ,accessed = kz_time:now_s() :: gregorian_seconds() | '$1' | '_' + ,accessed = kz_time:now_s() :: kz_time:gregorian_seconds() | '$1' | '_' }). -type bucket() :: #bucket{}. @@ -71,7 +71,7 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> gen_server:start_link({'local', ?SERVER}, ?MODULE, [], []). @@ -83,8 +83,8 @@ start_link() -> %% StartIfMissing :: start the token bucket if it doesn't exist yet %% @end %%-------------------------------------------------------------------- --spec consume_token(ne_binary()) -> boolean(). --spec consume_token(ne_binary(), ne_binary() | boolean()) -> boolean(). +-spec consume_token(kz_term:ne_binary()) -> boolean(). +-spec consume_token(kz_term:ne_binary(), kz_term:ne_binary() | boolean()) -> boolean(). consume_token(Name) -> consume_tokens(Name, 1). @@ -94,9 +94,9 @@ consume_token(<<_/binary>> = App, <<_/binary>> = Name) -> consume_token(Name, StartIfMissing) -> consume_tokens(?DEFAULT_APP, Name, 1, StartIfMissing). --spec consume_tokens(ne_binary(), integer()) -> boolean(). --spec consume_tokens(ne_binary(), ne_binary() | integer(), integer() | boolean()) -> boolean(). --spec consume_tokens(ne_binary(), ne_binary(), integer(), boolean()) -> boolean(). +-spec consume_tokens(kz_term:ne_binary(), integer()) -> boolean(). +-spec consume_tokens(kz_term:ne_binary(), kz_term:ne_binary() | integer(), integer() | boolean()) -> boolean(). +-spec consume_tokens(kz_term:ne_binary(), kz_term:ne_binary(), integer(), boolean()) -> boolean(). consume_tokens(Key, Count) -> consume_tokens(Key, Count, 'true'). @@ -121,8 +121,8 @@ consume_tokens(App, Key, Count, StartIfMissing) -> %% remaining tokens and return false %% @end %%-------------------------------------------------------------------- --spec consume_tokens_until(ne_binary(), pos_integer()) -> boolean(). --spec consume_tokens_until(ne_binary(), ne_binary() | pos_integer(), pos_integer() | boolean()) -> boolean(). +-spec consume_tokens_until(kz_term:ne_binary(), pos_integer()) -> boolean(). +-spec consume_tokens_until(kz_term:ne_binary(), kz_term:ne_binary() | pos_integer(), pos_integer() | boolean()) -> boolean(). consume_tokens_until(Key, Count) -> consume_tokens_until(?DEFAULT_APP, Key, Count, 'true'). @@ -134,13 +134,13 @@ consume_tokens_until(Key=?NE_BINARY, Count, StartIfMissing) is_boolean(StartIfMissing) -> consume_tokens(?DEFAULT_APP, Key, Count, StartIfMissing). --spec consume_tokens_until(ne_binary(), ne_binary(), pos_integer(), boolean()) -> boolean(). +-spec consume_tokens_until(kz_term:ne_binary(), kz_term:ne_binary(), pos_integer(), boolean()) -> boolean(). consume_tokens_until(App=?NE_BINARY, Key=?NE_BINARY, Count, StartIfMissing) when is_integer(Count), is_boolean(StartIfMissing) -> consume_tokens(App, Key, Count, StartIfMissing, fun kz_token_bucket:consume_until/2). --spec consume_tokens(ne_binary(), ne_binary(), integer(), boolean(), fun()) -> boolean(). +-spec consume_tokens(kz_term:ne_binary(), kz_term:ne_binary(), integer(), boolean(), fun()) -> boolean(). consume_tokens(App, Key, Count, StartIfMissing, BucketFun) -> case get_bucket(App, Key) of 'undefined' -> @@ -153,7 +153,7 @@ consume_tokens(App, Key, Count, StartIfMissing, BucketFun) -> end end. --spec maybe_start_bucket(ne_binary(), ne_binary(), integer(), boolean(), fun()) -> boolean(). +-spec maybe_start_bucket(kz_term:ne_binary(), kz_term:ne_binary(), integer(), boolean(), fun()) -> boolean(). maybe_start_bucket(_App, _Key, _Count, 'false', _BucketFun) -> 'false'; maybe_start_bucket(App, Key, Count, 'true', BucketFun) -> lager:debug("bucket (~s ~s) missing, starting", [App, Key]), @@ -162,8 +162,8 @@ maybe_start_bucket(App, Key, Count, 'true', BucketFun) -> _OK -> consume_tokens(App, Key, Count, 'false', BucketFun) end. --spec get_bucket(ne_binary(), ne_binary()) -> api_pid(). --spec get_bucket(ne_binary(), ne_binary(), 'record'|'server') -> api_pid() | bucket(). +-spec get_bucket(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:api_pid(). +-spec get_bucket(kz_term:ne_binary(), kz_term:ne_binary(), 'record'|'server') -> kz_term:api_pid() | bucket(). get_bucket(App, Key) -> get_bucket(App, Key, 'server'). @@ -181,8 +181,8 @@ get_bucket(App, Key, 'server') -> Srv end. --spec exists(ne_binary()) -> boolean(). --spec exists(ne_binary(), ne_binary()) -> boolean(). +-spec exists(kz_term:ne_binary()) -> boolean(). +-spec exists(kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). exists(Key) -> exists(?DEFAULT_APP, Key). exists(App, Key) -> @@ -194,15 +194,15 @@ exists(App, Key) -> 'false' end. --spec start_bucket(ne_binary()) -> +-spec start_bucket(kz_term:ne_binary()) -> 'ok' | 'error' | 'exists'. --spec start_bucket(ne_binary(), ne_binary()) -> +-spec start_bucket(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok' | 'error' | 'exists'. --spec start_bucket(ne_binary(), ne_binary(), pos_integer()) -> +-spec start_bucket(kz_term:ne_binary(), kz_term:ne_binary(), pos_integer()) -> 'ok' | 'error' | 'exists'. --spec start_bucket(ne_binary(), ne_binary(), pos_integer(), pos_integer()) -> +-spec start_bucket(kz_term:ne_binary(), kz_term:ne_binary(), pos_integer(), pos_integer()) -> 'ok' | 'error' | 'exists'. --spec start_bucket(ne_binary(), ne_binary(), pos_integer(), pos_integer(), kz_token_bucket:fill_rate_time()) -> +-spec start_bucket(kz_term:ne_binary(), kz_term:ne_binary(), pos_integer(), pos_integer(), kz_token_bucket:fill_rate_time()) -> 'ok' | 'error' | 'exists'. start_bucket(Name) -> start_bucket(?DEFAULT_APP, Name). @@ -301,7 +301,7 @@ init([]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call({'start', _App, _Name, _MaxTokens, _FillRate, _FillTime} ,_From ,#state{table_id='undefined'}=State @@ -347,7 +347,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Req, #state{table_id='undefined'}=State) -> lager:debug("ignoring req: ~p", [_Req]), {'noreply', State}; @@ -367,7 +367,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'ETS-TRANSFER', Tbl, _From, _Data}, #state{table_id='undefined'}=State) -> lager:debug("recv ets transfer from ~p for ~p", [_From, Tbl]), {'noreply', State#state{table_id=Tbl}}; @@ -424,7 +424,7 @@ code_change(_OldVsn, State, _Extra) -> %%%=================================================================== %%% Internal functions %%%=================================================================== --spec new_bucket(pid(), {ne_binary(), ne_binary()}) -> bucket(). +-spec new_bucket(pid(), {kz_term:ne_binary(), kz_term:ne_binary()}) -> bucket(). new_bucket(Pid, Name) -> #bucket{key=Name ,srv=Pid diff --git a/core/kazoo_token_buckets/src/kz_buckets_sup.erl b/core/kazoo_token_buckets/src/kz_buckets_sup.erl index e6432ef7c87..92dc2e94a8d 100644 --- a/core/kazoo_token_buckets/src/kz_buckets_sup.erl +++ b/core/kazoo_token_buckets/src/kz_buckets_sup.erl @@ -32,16 +32,16 @@ %%-------------------------------------------------------------------- %% @doc Starts the supervisor %%-------------------------------------------------------------------- --spec start_link() -> startlink_ret(). +-spec start_link() -> kz_types:startlink_ret(). start_link() -> supervisor:start_link({'local', ?SERVER}, ?MODULE, []). -spec start_bucket(pos_integer(), pos_integer(), kz_token_bucket:fill_rate_time()) -> - sup_startchild_ret(). + kz_types:sup_startchild_ret(). start_bucket(MaxTokens, FillRate, FillTime) -> supervisor:start_child(?SERVER, [MaxTokens, FillRate, 'true', FillTime]). --spec stop_bucket(server_ref()) -> 'ok' | {'error', any()}. +-spec stop_bucket(kz_types:server_ref()) -> 'ok' | {'error', any()}. stop_bucket(Pid) -> supervisor:terminate_child(?SERVER, Pid). @@ -58,7 +58,7 @@ stop_bucket(Pid) -> %% specifications. %% @end %%-------------------------------------------------------------------- --spec init(any()) -> sup_init_ret(). +-spec init(any()) -> kz_types:sup_init_ret(). init([]) -> RestartStrategy = 'simple_one_for_one', MaxRestarts = 1, diff --git a/core/kazoo_token_buckets/src/kz_token_bucket.erl b/core/kazoo_token_buckets/src/kz_token_bucket.erl index dfeeec9c98b..a66de651e96 100644 --- a/core/kazoo_token_buckets/src/kz_token_bucket.erl +++ b/core/kazoo_token_buckets/src/kz_token_bucket.erl @@ -72,9 +72,9 @@ %%-------------------------------------------------------------------- %% @doc Starts the server %%-------------------------------------------------------------------- --spec start_link(pos_integer(), pos_integer()) -> startlink_ret(). --spec start_link(pos_integer(), pos_integer(), boolean()) -> startlink_ret(). --spec start_link(pos_integer(), pos_integer(), boolean(), fill_rate_time()) -> startlink_ret(). +-spec start_link(pos_integer(), pos_integer()) -> kz_types:startlink_ret(). +-spec start_link(pos_integer(), pos_integer(), boolean()) -> kz_types:startlink_ret(). +-spec start_link(pos_integer(), pos_integer(), boolean(), fill_rate_time()) -> kz_types:startlink_ret(). start_link(Max, FillRate) -> start_link(Max, FillRate, 'true'). start_link(Max, FillRate, FillAsBlock) -> start_link(Max, FillRate, FillAsBlock, default_fill_time()). @@ -90,7 +90,7 @@ start_link(Max, FillRate, FillAsBlock, FillTime) -> gen_server:start_link(?SERVER, [Max, FillRate, FillAsBlock, FillTime], []). --spec start_link(atom(), pos_integer(), pos_integer(), boolean(), fill_rate_time()) -> startlink_ret(). +-spec start_link(atom(), pos_integer(), pos_integer(), boolean(), fill_rate_time()) -> kz_types:startlink_ret(). start_link(Name, Max, FillRate, FillAsBlock, FillTime) when is_integer(FillRate), FillRate > 0, is_integer(Max), Max > 0, @@ -135,17 +135,17 @@ credit(Srv, Tokens) when is_integer(Tokens) -spec tokens(pid()) -> non_neg_integer(). tokens(Srv) -> gen_server:call(Srv, {'tokens'}). --spec set_name(pid(), {ne_binary(), ne_binary()}) -> 'ok'. +-spec set_name(pid(), {kz_term:ne_binary(), kz_term:ne_binary()}) -> 'ok'. set_name(Srv, Name) -> gen_server:cast(Srv, {'name', Name}). -spec default_fill_time() -> fill_rate_time(). --spec default_fill_time(ne_binary()) -> fill_rate_time(). +-spec default_fill_time(kz_term:ne_binary()) -> fill_rate_time(). default_fill_time() -> default_fill_time(?DEFAULT_APP). default_fill_time(App) -> normalize_fill_time(?FILL_TIME(App)). --spec normalize_fill_time(ne_binary()) -> fill_rate_time(). +-spec normalize_fill_time(kz_term:ne_binary()) -> fill_rate_time(). normalize_fill_time(<<"day">>) -> 'day'; normalize_fill_time(<<"hour">>) -> 'hour'; normalize_fill_time(<<"minute">>) -> 'minute'; @@ -195,7 +195,7 @@ init([Max, FillRate, FillAsBlock, FillTime]) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call({'consume', Req}, _From, #state{tokens=Current}=State) -> case Current - Req of N when N >= 0 -> @@ -230,7 +230,7 @@ handle_call(_Request, _From, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'credit', Req}, #state{tokens=Current ,max_tokens=Max }=State) -> @@ -263,7 +263,7 @@ handle_cast(_Msg, State) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'timeout', Ref, ?TOKEN_FILL_TIME}, #state{max_tokens=Max ,tokens=Current ,fill_rate=FillRate diff --git a/core/kazoo_transactions/src/kazoo_transactions_maintenance.erl b/core/kazoo_transactions/src/kazoo_transactions_maintenance.erl index 266419f7940..564ce4620f8 100644 --- a/core/kazoo_transactions/src/kazoo_transactions_maintenance.erl +++ b/core/kazoo_transactions/src/kazoo_transactions_maintenance.erl @@ -23,13 +23,13 @@ %% %% @end %%-------------------------------------------------------------------- --spec balance(ne_binary()) -> dollars(). +-spec balance(kz_term:ne_binary()) -> dollars(). balance(Account) -> AccountId = kz_util:format_account_id(Account, 'raw'), {'ok', Balance} = wht_util:current_balance(AccountId), wht_util:units_to_dollars(Balance). --spec balance(ne_binary(), ne_binary(), ne_binary()) -> dollars(). +-spec balance(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> dollars(). balance(Account, Year, Month) -> AccountId = kz_util:format_account_id(Account, 'raw'), {'ok', Balance} = wht_util:previous_balance(AccountId, Year, Month), @@ -65,7 +65,7 @@ top_up_status() -> end, io:format("auto top up is ~s~n", [IsEnabled]). --spec top_up_status(ne_binary()) -> 'ok'. +-spec top_up_status(kz_term:ne_binary()) -> 'ok'. top_up_status(AccountId) -> {NotifyThreshold, TopupAmount, TopupThreshold} = get_topup_thresholds(AccountId), io:format("+-----------------+------------------+------------------+---------------+-------------------------+~n"), @@ -80,14 +80,14 @@ top_up_status(AccountId) -> ]), io:format("+-----------------+------------------+------------------+---------------+-------------------------+~n"). --spec current_balance(ne_binary()) -> dollars(). +-spec current_balance(kz_term:ne_binary()) -> dollars(). current_balance(AccountId) -> case wht_util:current_balance(AccountId) of {'ok', Balance} -> wht_util:units_to_dollars(Balance); {'error', _} -> 0 end. --spec get_topup_thresholds(ne_binary()) -> {api_integer(), integer() | string(), integer() | string()}. +-spec get_topup_thresholds(kz_term:ne_binary()) -> {kz_term:api_integer(), integer() | string(), integer() | string()}. get_topup_thresholds(AccountId) -> case kz_account:fetch(AccountId) of {'error', _Reason} -> @@ -100,7 +100,7 @@ get_topup_thresholds(AccountId) -> } end. --spec is_topup_today(ne_binary()) -> boolean(). +-spec is_topup_today(kz_term:ne_binary()) -> boolean(). is_topup_today(AccountId) -> To = kz_time:now_s(), From = To - ?SECONDS_IN_DAY, diff --git a/core/kazoo_transactions/src/kz_topup.erl b/core/kazoo_transactions/src/kz_topup.erl index f5ed48832f1..ebd37d04004 100644 --- a/core/kazoo_transactions/src/kz_topup.erl +++ b/core/kazoo_transactions/src/kz_topup.erl @@ -28,7 +28,7 @@ %% %% @end %%-------------------------------------------------------------------- --spec init(api_binary(), integer()) -> +-spec init(kz_term:api_binary(), integer()) -> 'ok' | {'error', error()}. init(Account, CurrentBalance) -> @@ -48,8 +48,8 @@ init(Account, CurrentBalance) -> %% %% @end %%-------------------------------------------------------------------- --spec should_topup(ne_binary()) -> boolean(). --spec should_topup(ne_binary(), integer()) -> boolean(). +-spec should_topup(kz_term:ne_binary()) -> boolean(). +-spec should_topup(kz_term:ne_binary(), integer()) -> boolean(). should_topup(AccountId) -> case wht_util:current_balance(AccountId) of {'ok', CurrentBalance} -> should_topup(AccountId, CurrentBalance); @@ -72,7 +72,7 @@ should_topup(AccountId, CurrentBalance) -> %% %% @end %%-------------------------------------------------------------------- --spec should_topup(ne_binary(), number(), integer()) -> +-spec should_topup(kz_term:ne_binary(), number(), integer()) -> 'true' | {'error', error()}. should_topup(AccountId, Balance, Threshold) when Balance =< Threshold -> @@ -90,7 +90,7 @@ should_topup(_AccountId, _Balance, _Threshold) -> lager:warning("balance (~p) is still > to threshold (~p) for account ~s", [_Balance, _Threshold, _AccountId]), {'error', 'balance_above_threshold'}. --spec is_topup_today(ne_binary(), kz_json:objects()) -> 'true' | {'error', error()}. +-spec is_topup_today(kz_term:ne_binary(), kz_json:objects()) -> 'true' | {'error', error()}. is_topup_today(_AccountId, []) -> lager:info("no top up transactions found for ~s, processing...", [_AccountId]), 'true'; @@ -104,7 +104,7 @@ is_topup_today(_AccountId, _TopupTransactions) -> %% %% @end %%-------------------------------------------------------------------- --spec get_top_up(api_binary() | kz_account:doc()) -> +-spec get_top_up(kz_term:api_binary() | kz_account:doc()) -> {'error', error()} | {'ok', integer(), integer()}. get_top_up(<<_/binary>> = Account) -> @@ -139,7 +139,7 @@ get_top_up(JObj) -> %% %% @end %%-------------------------------------------------------------------- --spec maybe_top_up(ne_binary(), number(), integer(), integer()) -> +-spec maybe_top_up(kz_term:ne_binary(), number(), integer(), integer()) -> 'ok' | {'error', error()}. maybe_top_up(AccountId, Balance, Amount, Threshold) -> @@ -154,7 +154,7 @@ maybe_top_up(AccountId, Balance, Amount, Threshold) -> %% %% @end %%-------------------------------------------------------------------- --spec top_up(ne_binary(), integer()) -> 'ok' | {'error', any()}. +-spec top_up(kz_term:ne_binary(), integer()) -> 'ok' | {'error', any()}. top_up(AccountId, Amount) -> Services = kz_services:fetch(AccountId), Transaction = kz_transaction:debit(AccountId, wht_util:dollars_to_units(Amount)), diff --git a/core/kazoo_transactions/src/kz_transaction.erl b/core/kazoo_transactions/src/kz_transaction.erl index fd218c8ba51..73fb0da2ecd 100644 --- a/core/kazoo_transactions/src/kz_transaction.erl +++ b/core/kazoo_transactions/src/kz_transaction.erl @@ -48,29 +48,29 @@ -include("transactions.hrl"). --record(kz_transaction, {id :: api_ne_binary() - ,rev :: api_ne_binary() - ,description :: api_binary() - ,call_id :: api_ne_binary() - ,sub_account_id :: api_ne_binary() - ,sub_account_name :: api_binary() - ,event :: api_ne_binary() - ,number :: api_ne_binary() - ,numbers :: api_ne_binaries() - ,feature :: api_ne_binary() - ,bookkeeper_info :: api_object() - ,metadata :: api_object() - ,pvt_status :: api_ne_binary() - ,pvt_reason :: api_ne_binary() - ,pvt_code :: api_integer() +-record(kz_transaction, {id :: kz_term:api_ne_binary() + ,rev :: kz_term:api_ne_binary() + ,description :: kz_term:api_binary() + ,call_id :: kz_term:api_ne_binary() + ,sub_account_id :: kz_term:api_ne_binary() + ,sub_account_name :: kz_term:api_binary() + ,event :: kz_term:api_ne_binary() + ,number :: kz_term:api_ne_binary() + ,numbers :: kz_term:api_ne_binaries() + ,feature :: kz_term:api_ne_binary() + ,bookkeeper_info :: kz_term:api_object() + ,metadata :: kz_term:api_object() + ,pvt_status :: kz_term:api_ne_binary() + ,pvt_reason :: kz_term:api_ne_binary() + ,pvt_code :: kz_term:api_integer() ,pvt_amount = 0 :: units() - ,pvt_type :: ne_binary() - ,pvt_created :: gregorian_seconds() - ,pvt_modified :: gregorian_seconds() - ,pvt_account_id :: ne_binary() - ,pvt_account_db :: ne_binary() + ,pvt_type :: kz_term:ne_binary() + ,pvt_created :: kz_time:gregorian_seconds() + ,pvt_modified :: kz_time:gregorian_seconds() + ,pvt_account_id :: kz_term:ne_binary() + ,pvt_account_db :: kz_term:ne_binary() ,pvt_vsn = 2 :: pos_integer() - ,order_id :: api_ne_binary() + ,order_id :: kz_term:api_ne_binary() }). -type transaction() :: #kz_transaction{}. @@ -87,51 +87,51 @@ %% @doc %% @end %%-------------------------------------------------------------------- --spec id(transaction()) -> ne_binary(). +-spec id(transaction()) -> kz_term:ne_binary(). id(#kz_transaction{id = Id}) -> Id. --spec rev(transaction()) -> ne_binary(). +-spec rev(transaction()) -> kz_term:ne_binary(). rev(#kz_transaction{rev = Rev}) -> Rev. --spec description(transaction()) -> api_ne_binary(). +-spec description(transaction()) -> kz_term:api_ne_binary(). description(#kz_transaction{description = Description}) -> Description. --spec call_id(transaction()) -> ne_binary(). +-spec call_id(transaction()) -> kz_term:ne_binary(). call_id(#kz_transaction{call_id = CallId}) -> CallId. --spec sub_account_id(transaction()) -> ne_binary(). +-spec sub_account_id(transaction()) -> kz_term:ne_binary(). sub_account_id(#kz_transaction{sub_account_id = SubAccountId}) -> SubAccountId. --spec sub_account_name(transaction()) -> api_ne_binary(). +-spec sub_account_name(transaction()) -> kz_term:api_ne_binary(). sub_account_name(#kz_transaction{sub_account_name = SubAccountName}) -> SubAccountName. --spec event(transaction()) -> ne_binary(). +-spec event(transaction()) -> kz_term:ne_binary(). event(#kz_transaction{event = Event}) -> Event. --spec number(transaction()) -> ne_binary(). +-spec number(transaction()) -> kz_term:ne_binary(). number(#kz_transaction{number = Number}) -> Number. --spec numbers(transaction()) -> ne_binaries(). +-spec numbers(transaction()) -> kz_term:ne_binaries(). numbers(#kz_transaction{numbers = Numbers}) -> Numbers. --spec feature(transaction()) -> ne_binary(). +-spec feature(transaction()) -> kz_term:ne_binary(). feature(#kz_transaction{feature = Feature}) -> Feature. -spec bookkeeper_info(transaction()) -> kz_json:object(). bookkeeper_info(#kz_transaction{bookkeeper_info = BookkeeperInfo}) -> BookkeeperInfo. --spec metadata(transaction()) -> api_object(). +-spec metadata(transaction()) -> kz_term:api_object(). metadata(#kz_transaction{metadata = MetaData}) -> MetaData. --spec reason(transaction()) -> ne_binary(). +-spec reason(transaction()) -> kz_term:ne_binary(). reason(#kz_transaction{pvt_reason = Reason}) -> Reason. --spec status(transaction()) -> ne_binary(). +-spec status(transaction()) -> kz_term:ne_binary(). status(#kz_transaction{pvt_status = Status}) -> Status. --spec code(transaction()) -> api_integer(). +-spec code(transaction()) -> kz_term:api_integer(). code(#kz_transaction{pvt_code = Code}) -> Code. -spec amount(transaction()) -> units(). amount(#kz_transaction{pvt_amount = Amount}) -> Amount. --spec type(transaction()) -> ne_binary(). +-spec type(transaction()) -> kz_term:ne_binary(). type(#kz_transaction{pvt_type = Type}) -> Type. --spec created(transaction()) -> gregorian_seconds(). +-spec created(transaction()) -> kz_time:gregorian_seconds(). created(#kz_transaction{pvt_created = Created}) -> Created. --spec modified(transaction()) -> gregorian_seconds(). +-spec modified(transaction()) -> kz_time:gregorian_seconds(). modified(#kz_transaction{pvt_modified = Modified}) -> Modified. --spec account_id(transaction()) -> ne_binary(). +-spec account_id(transaction()) -> kz_term:ne_binary(). account_id(#kz_transaction{pvt_account_id = AccountId}) -> AccountId. --spec account_db(transaction()) -> ne_binary(). +-spec account_db(transaction()) -> kz_term:ne_binary(). account_db(#kz_transaction{pvt_account_db = AccountDb}) -> AccountDb. -spec version(transaction()) -> integer(). version(#kz_transaction{pvt_vsn = Version}) -> Version. --spec order_id(transaction()) -> api_ne_binary(). +-spec order_id(transaction()) -> kz_term:api_ne_binary(). order_id(#kz_transaction{order_id = OrderId}) -> OrderId. %%-------------------------------------------------------------------- @@ -139,16 +139,16 @@ order_id(#kz_transaction{order_id = OrderId}) -> OrderId. %% @doc %% @end %%-------------------------------------------------------------------- --type new() :: #{account_id => ne_binary() - ,account_db => ne_binary() +-type new() :: #{account_id => kz_term:ne_binary() + ,account_db => kz_term:ne_binary() ,amount => units() - ,type => ne_binary() - ,description => ne_binary() + ,type => kz_term:ne_binary() + ,description => kz_term:ne_binary() ,bookkeeper_info => kz_json:object() ,metadata => kz_json:object() - ,status => ne_binary() - ,created => gregorian_seconds() - ,modified => gregorian_seconds() + ,status => kz_term:ne_binary() + ,created => kz_time:gregorian_seconds() + ,modified => kz_time:gregorian_seconds() }. -spec new(new()) -> transaction(). @@ -176,7 +176,7 @@ new(#{account_id := AccountId }. %% @private --spec new(ne_binary(), units(), ne_binary()) -> transaction(). +-spec new(kz_term:ne_binary(), units(), kz_term:ne_binary()) -> transaction(). new(Ledger, Amount, Type) -> #kz_transaction{pvt_type = Type ,pvt_amount = abs(Amount) @@ -192,7 +192,7 @@ new(Ledger, Amount, Type) -> %% Create transaction record of type credit (with Amount & Reason) %% @end %%-------------------------------------------------------------------- --spec credit(ne_binary(), units()) -> transaction(). +-spec credit(kz_term:ne_binary(), units()) -> transaction(). credit(Ledger, Amount) -> new(Ledger, Amount, <<"credit">>). @@ -202,7 +202,7 @@ credit(Ledger, Amount) -> %% Create transaction record of type debit (with Amount & Reason) %% @end %%-------------------------------------------------------------------- --spec debit(ne_binary(), units()) -> transaction(). +-spec debit(kz_term:ne_binary(), units()) -> transaction(). debit(Ledger, Amount) -> new(Ledger, Amount, <<"debit">>). @@ -211,11 +211,11 @@ debit(Ledger, Amount) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec set_description(ne_binary(), transaction()) -> transaction(). +-spec set_description(kz_term:ne_binary(), transaction()) -> transaction(). set_description(Desc=?NE_BINARY, T) -> T#kz_transaction{description = Desc}. --spec set_sub_account_info(ne_binary(), transaction()) -> transaction(). +-spec set_sub_account_info(kz_term:ne_binary(), transaction()) -> transaction(). set_sub_account_info(?MATCH_ACCOUNT_RAW(AccountId), T) -> case kz_account:fetch(AccountId) of {'error', _R} -> @@ -228,16 +228,16 @@ set_sub_account_info(?MATCH_ACCOUNT_RAW(AccountId), T) -> } end. --spec set_event(ne_binary(), transaction()) -> transaction(). +-spec set_event(kz_term:ne_binary(), transaction()) -> transaction(). set_event(Event, T) -> T#kz_transaction{event = Event}. --spec set_number(ne_binary(), transaction()) -> transaction(). +-spec set_number(kz_term:ne_binary(), transaction()) -> transaction(). set_number(Number, T) -> T#kz_transaction{number = Number}. --spec set_numbers(ne_binaries(), transaction()) -> transaction(). +-spec set_numbers(kz_term:ne_binaries(), transaction()) -> transaction(). set_numbers(Numbers, T) -> T#kz_transaction{numbers = Numbers}. --spec set_feature(ne_binary(), transaction()) -> transaction(). +-spec set_feature(kz_term:ne_binary(), transaction()) -> transaction(). set_feature(Feature, T) -> T#kz_transaction{feature = Feature}. -spec set_bookkeeper_info(kz_json:object(), transaction()) -> transaction(). @@ -247,7 +247,7 @@ set_bookkeeper_info(BookkeeperInfo, T) -> set_metadata(MetaData, T) -> T#kz_transaction{metadata = MetaData}. --spec set_reason(ne_binary(), transaction()) -> transaction(). +-spec set_reason(kz_term:ne_binary(), transaction()) -> transaction(). set_reason(Reason, T) -> %%FIXME: check wht_util:is_valid_reason/1 T#kz_transaction{pvt_reason = Reason @@ -273,10 +273,10 @@ set_amount_and_type(Amount, T) ,pvt_type = <<"debit">> }. --spec set_type(ne_binary(), transaction()) -> transaction(). +-spec set_type(kz_term:ne_binary(), transaction()) -> transaction(). set_type(Type, T) -> T#kz_transaction{pvt_type = Type}. --spec set_order_id(api_binary(), transaction()) -> transaction(). +-spec set_order_id(kz_term:api_binary(), transaction()) -> transaction(). set_order_id(OrderId, T) -> T#kz_transaction{order_id = OrderId}. @@ -300,7 +300,7 @@ is_per_minute(Transaction) -> %% %% @end %%-------------------------------------------------------------------- --spec is_reason(ne_binary() | ne_binaries(), transaction()) -> boolean(). +-spec is_reason(kz_term:ne_binary() | kz_term:ne_binaries(), transaction()) -> boolean(). is_reason(Reason, #kz_transaction{pvt_reason = Reason}) -> 'true'; is_reason([Reason | _], #kz_transaction{pvt_reason = Reason}) -> 'true'; is_reason([_ | Reasons], Transaction) -> @@ -377,7 +377,7 @@ maybe_add_sub_account_name(JObj) -> _ -> JObj end. --spec add_sub_account_name(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec add_sub_account_name(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). add_sub_account_name(AccountId, JObj) -> case kz_account:fetch_name(AccountId) of undefined -> JObj; @@ -636,7 +636,7 @@ prepare_topup_transaction(Transaction) -> Id = <<"topup-", Month/binary, Day/binary>>, Transaction#kz_transaction{id = Id}. --spec modb_doc_id() -> ne_binary(). +-spec modb_doc_id() -> kz_term:ne_binary(). modb_doc_id() -> {{Year, Month, _}, _} = calendar:gregorian_seconds_to_datetime(kz_time:now_s()), <<(kz_term:to_binary(Year))/binary diff --git a/core/kazoo_transactions/src/kz_transactions.erl b/core/kazoo_transactions/src/kz_transactions.erl index ab4723c85e7..0f34a859baa 100644 --- a/core/kazoo_transactions/src/kz_transactions.erl +++ b/core/kazoo_transactions/src/kz_transactions.erl @@ -37,11 +37,11 @@ %% %% @end %%-------------------------------------------------------------------- --spec call_charges(ne_binary(), ne_binary()) -> integer(). +-spec call_charges(kz_term:ne_binary(), kz_term:ne_binary()) -> integer(). call_charges(Ledger, CallId) -> call_charges(Ledger, CallId, 'true'). --spec call_charges(ne_binary(), ne_binary(), ne_binary() | boolean()) -> +-spec call_charges(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary() | boolean()) -> integer() | kz_transactions(). call_charges(Ledger, CallId, 'true') -> LedgerDb = kz_util:format_account_id(Ledger, 'encoded'), @@ -79,7 +79,7 @@ call_charges(Ledger, CallId, 'false') -> call_charges(Ledger, CallId, Event) -> call_charges(Ledger, CallId, Event, 'true'). --spec call_charges(ne_binary(), ne_binary(), ne_binary(), boolean()) -> integer() | kz_transactions(). +-spec call_charges(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), boolean()) -> integer() | kz_transactions(). call_charges(Ledger, CallId, Event, 'true') -> LedgerDb = kz_util:format_account_id(Ledger, 'encoded'), ViewOptions = ['reduce' @@ -118,7 +118,7 @@ call_charges(Ledger, CallId, Event, 'false') -> %% Filter list of transactions by reason %% @end %%-------------------------------------------------------------------- --spec filter_by_reason(ne_binary(), kz_transactions()) -> kz_transactions(). +-spec filter_by_reason(kz_term:ne_binary(), kz_transactions()) -> kz_transactions(). filter_by_reason(<<"only_bookkeeper">>, Transactions) -> {BTTransactions, LTransactions} = lists:partition(fun is_from_braintree/1, Transactions), case ?KZ_SERVICE_MASTER_ACCOUNT_BOOKKEEPER of @@ -180,7 +180,7 @@ is_per_minute(Transaction) -> %% fetch last transactions %% @end %%-------------------------------------------------------------------- --spec fetch_last(ne_binary(), pos_integer()) -> +-spec fetch_last(kz_term:ne_binary(), pos_integer()) -> {'ok', kz_transactions()} | {'error', any()}. fetch_last(Account, Count) -> @@ -195,7 +195,7 @@ fetch_last(Account, Count) -> %% fetch last transactions from From to To %% @end %%-------------------------------------------------------------------- --spec fetch(ne_binary(), gregorian_seconds(), gregorian_seconds()) -> +-spec fetch(kz_term:ne_binary(), kz_time:gregorian_seconds(), kz_time:gregorian_seconds()) -> {'ok', kz_transactions()} | {'error', any()}. fetch(Account, From, To) -> @@ -203,7 +203,7 @@ fetch(Account, From, To) -> fetch(Account, ViewOptionsList). %% @private --spec fetch(ne_binary(), kz_proplists()) -> +-spec fetch(kz_term:ne_binary(), kz_term:proplists()) -> {'ok', kz_transactions()} | {'error', any()}. fetch(Account, ViewOptionsList) -> @@ -218,8 +218,8 @@ fetch(Account, ViewOptionsList) -> end. %% @private --spec get_range(ne_binary(), gregorian_seconds(), gregorian_seconds()) -> - ViewOptionsList :: kz_proplists(). +-spec get_range(kz_term:ne_binary(), kz_time:gregorian_seconds(), kz_time:gregorian_seconds()) -> + ViewOptionsList :: kz_term:proplists(). get_range(Account, From, To) -> [ begin {Account, Year, Month} = kazoo_modb_util:split_account_mod(MODb), @@ -238,7 +238,7 @@ get_range(Account, From, To) -> %% fetch last local transactions from From to To %% @end %%-------------------------------------------------------------------- --spec fetch_local(ne_binary(), gregorian_seconds(), gregorian_seconds()) -> +-spec fetch_local(kz_term:ne_binary(), kz_time:gregorian_seconds(), kz_time:gregorian_seconds()) -> {'ok', kz_transactions()} | {'error', any()}. fetch_local(Account, From, To) -> @@ -246,7 +246,7 @@ fetch_local(Account, From, To) -> fetch_local(Account, ViewOptionsList). %% @private --spec fetch_local(ne_binary(), kz_proplists()) -> +-spec fetch_local(kz_term:ne_binary(), kz_term:proplists()) -> {'ok', kz_transactions()} | {'error', any()}. fetch_local(_Account, []) -> {'ok', []}; @@ -254,7 +254,7 @@ fetch_local(Account, ViewOptionsList) -> do_fetch_local(Account, ViewOptionsList, []). %% @private --spec do_fetch_local(ne_binary(), kz_proplists(), kz_json:objects()) -> +-spec do_fetch_local(kz_term:ne_binary(), kz_term:proplists(), kz_json:objects()) -> {'ok', kz_transactions()} | {'error', any()}. do_fetch_local(Account, [ViewOptions|ViewOptionsList], Acc) -> @@ -269,14 +269,14 @@ do_fetch_local(_Account, [], ViewRes) -> {'ok', Transactions}. %% @private --spec fetch_bookkeeper(ne_binary(), kz_proplists()) -> +-spec fetch_bookkeeper(kz_term:ne_binary(), kz_term:proplists()) -> {'ok', kz_transactions()} | {'error', any()}. fetch_bookkeeper(Account, ViewOptionsList) -> do_fetch_bookkeeper(Account, ViewOptionsList, []). %% @private --spec do_fetch_bookkeeper(ne_binary(), kz_proplists(), kz_json:objects()) -> +-spec do_fetch_bookkeeper(kz_term:ne_binary(), kz_term:proplists(), kz_json:objects()) -> {'ok', kz_transactions()} | {'error', any()}. do_fetch_bookkeeper(Account, [ViewOptions|ViewOptionsList], Acc) -> @@ -296,7 +296,7 @@ do_fetch_bookkeeper(_Account, [], Transactions) -> %% fetch last bookkeeper transactions from From to To %% @end %%-------------------------------------------------------------------- --spec fetch_bookkeeper(ne_binary(), gregorian_seconds(), gregorian_seconds()) -> +-spec fetch_bookkeeper(kz_term:ne_binary(), kz_time:gregorian_seconds(), kz_time:gregorian_seconds()) -> {'ok', kz_transactions()} | {'error', any()}. fetch_bookkeeper(Account, From, To) -> @@ -316,7 +316,7 @@ fetch_bookkeeper(Account, From, To) -> %% @end %%-------------------------------------------------------------------- -spec de_duplicate_transactions(kz_transactions(), kz_transactions()) -> kz_transactions(). --spec de_duplicate_transactions(kz_proplist(), kz_proplist(), kz_transactions()) -> kz_transactions(). +-spec de_duplicate_transactions(kz_term:proplist(), kz_term:proplist(), kz_transactions()) -> kz_transactions(). de_duplicate_transactions(Transactions, BookkeeperTransactions) -> PropsTr = transactions_to_props(Transactions), PropsBTr = transactions_to_props(BookkeeperTransactions), @@ -331,11 +331,11 @@ de_duplicate_transactions([{Key, Value}|Transactions], BookkeeperTransactions, A end. %% @private --spec transactions_to_props(kz_transactions()) -> kz_proplist(). +-spec transactions_to_props(kz_transactions()) -> kz_term:proplist(). transactions_to_props(Transactions) -> lists:foldl(fun transaction_to_prop_fold/2, [], Transactions). --spec transaction_to_prop_fold(kz_transaction:transaction(), kz_proplist()) -> kz_proplist(). +-spec transaction_to_prop_fold(kz_transaction:transaction(), kz_term:proplist()) -> kz_term:proplist(). transaction_to_prop_fold(Transaction, Acc) -> Amount = kz_transaction:amount(Transaction), Timestamp = kz_transaction:created(Transaction), diff --git a/core/kazoo_transactions/src/wht_util.erl b/core/kazoo_transactions/src/wht_util.erl index d92be3554ad..24a51836e1b 100644 --- a/core/kazoo_transactions/src/wht_util.erl +++ b/core/kazoo_transactions/src/wht_util.erl @@ -59,7 +59,7 @@ %% tracked in hundred-ths of a cent -define(DOLLAR_TO_UNIT, 10000). --spec reasons() -> #{ne_binary() => 1000..9999}. +-spec reasons() -> #{kz_term:ne_binary() => 1000..9999}. reasons() -> #{per_minute_call() => ?CODE_PER_MINUTE_CALL ,sub_account_per_minute_call() => ?CODE_PER_MINUTE_CALL_SUB_ACCOUNT @@ -81,8 +81,8 @@ reasons() -> ,unknown() => ?CODE_UNKNOWN }. --spec reasons(integer()) -> ne_binaries(). --spec reasons(integer(), integer()) -> ne_binaries(). +-spec reasons(integer()) -> kz_term:ne_binaries(). +-spec reasons(integer(), integer()) -> kz_term:ne_binaries(). reasons(Min) -> reasons(Min, 10000). @@ -103,7 +103,7 @@ reasons(Min, Max) %% %% @end %%-------------------------------------------------------------------- --spec dollars_to_units(text() | dollars()) -> units(). +-spec dollars_to_units(kz_term:text() | dollars()) -> units(). dollars_to_units(Dollars) when is_number(Dollars) -> round(Dollars * ?DOLLAR_TO_UNIT); dollars_to_units(Dollars) -> @@ -122,7 +122,7 @@ units_to_dollars(Units) -> units_to_dollars(kz_term:to_integer(Units)). %% @public --spec pretty_print_dollars(dollars()) -> ne_binary(). +-spec pretty_print_dollars(dollars()) -> kz_term:ne_binary(). pretty_print_dollars(Amount) -> kz_term:to_binary(io_lib:format("$~.2f", [Amount])). @@ -147,16 +147,16 @@ base_call_cost(RateCost, RateMin, RateSurcharge) %%-------------------------------------------------------------------- -type balance_ret() :: {'ok', units() | dollars()} | {'error', any()}. --spec current_balance(ne_binary()) -> balance_ret(). +-spec current_balance(kz_term:ne_binary()) -> balance_ret(). current_balance(Account) -> get_balance(Account, []). --spec previous_balance(ne_binary(), ne_binary(), ne_binary()) -> balance_ret(). +-spec previous_balance(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> balance_ret(). previous_balance(Account, Year, Month) -> Options = [{'year', kz_term:to_binary(Year)}, {'month', kz_date:pad_month(Month)}], get_balance(Account, Options). --spec get_balance(ne_binary(), kazoo_modb:view_options()) -> balance_ret(). +-spec get_balance(kz_term:ne_binary(), kazoo_modb:view_options()) -> balance_ret(). get_balance(Account, Options) -> View = <<"transactions/credit_remaining">>, ViewOptions = ['reduce' @@ -174,8 +174,8 @@ get_balance(Account, Options) -> Error end. --spec get_balance_from_previous(ne_binary(), kazoo_modb:view_options()) -> balance_ret(). --spec get_balance_from_previous(ne_binary(), kazoo_modb:view_options(), integer()) -> balance_ret(). +-spec get_balance_from_previous(kz_term:ne_binary(), kazoo_modb:view_options()) -> balance_ret(). +-spec get_balance_from_previous(kz_term:ne_binary(), kazoo_modb:view_options(), integer()) -> balance_ret(). get_balance_from_previous(Account, ViewOptions) -> Retries = props:get_value('retry', ViewOptions, 3), get_balance_from_previous(Account, ViewOptions, Retries). @@ -195,7 +195,7 @@ get_balance_from_previous(_Account, _ViewOptions, _) -> lager:warning("3rd attempt to find balance in previous modb getting from account ~s", [_Account]), {'error', 'retries_exceeded'}. --spec maybe_rollup(ne_binary(), kz_proplist(), units()) -> balance_ret(). +-spec maybe_rollup(kz_term:ne_binary(), kz_term:proplist(), units()) -> balance_ret(). maybe_rollup(Account, ViewOptions, Balance) -> case props:get_integer_value('retry', ViewOptions) of 'undefined' when Balance =< 0 -> @@ -212,7 +212,7 @@ maybe_rollup(Account, ViewOptions, Balance) -> maybe_rollup_previous_month(Account, Balance) end. --spec verify_monthly_rollup_exists(ne_binary(), units()) -> balance_ret(). +-spec verify_monthly_rollup_exists(kz_term:ne_binary(), units()) -> balance_ret(). verify_monthly_rollup_exists(Account, Balance) -> case kazoo_modb:open_doc(Account, <<"monthly_rollup">>) of {'ok', _} -> {'ok', Balance}; @@ -223,7 +223,7 @@ verify_monthly_rollup_exists(Account, Balance) -> {'error', _R} -> {'ok', Balance} end. --spec maybe_rollup_previous_month(ne_binary(), units()) -> balance_ret(). +-spec maybe_rollup_previous_month(kz_term:ne_binary(), units()) -> balance_ret(). maybe_rollup_previous_month(Account, Balance) -> case get_rollup_from_previous(Account) of {'error', _} -> {'ok', Balance}; @@ -232,7 +232,7 @@ maybe_rollup_previous_month(Account, Balance) -> {'ok', Balance - PrevBalance} end. --spec get_rollup_from_previous(ne_binary()) -> balance_ret(). +-spec get_rollup_from_previous(kz_term:ne_binary()) -> balance_ret(). get_rollup_from_previous(Account) -> {Y, M, _} = erlang:date(), {Year, Month} = kazoo_modb_util:prev_year_month(Y, M), @@ -249,7 +249,7 @@ get_rollup_from_previous(Account) -> E end. --spec get_rollup_balance(ne_binary(), kazoo_modb:view_options()) -> balance_ret(). +-spec get_rollup_balance(kz_term:ne_binary(), kazoo_modb:view_options()) -> balance_ret(). get_rollup_balance(Account, Options) -> View = <<"transactions/credit_remaining">>, ViewOptions = ['reduce' @@ -272,7 +272,7 @@ get_rollup_balance(Account, Options) -> %% %% @end %%-------------------------------------------------------------------- --spec current_account_dollars(ne_binary()) -> balance_ret(). +-spec current_account_dollars(kz_term:ne_binary()) -> balance_ret(). current_account_dollars(Account) -> case current_balance(Account) of {'ok', Units} -> {'ok', units_to_dollars(Units)}; @@ -337,11 +337,11 @@ calculate_call(JObj) -> {ChargedSeconds, trunc(Cost - Discount)} end. --spec get_integer_value(ne_binary(), kz_json:object()) -> integer(). +-spec get_integer_value(kz_term:ne_binary(), kz_json:object()) -> integer(). get_integer_value(Key, JObj) -> get_integer_value(Key, JObj, 0). --spec get_integer_value(ne_binary(), kz_json:object(), any()) -> integer(). +-spec get_integer_value(kz_term:ne_binary(), kz_json:object(), any()) -> integer(). get_integer_value(Key, JObj, Default) -> Keys = [Key, kz_json:normalize_key(Key)], kz_term:to_integer( @@ -409,27 +409,27 @@ calculate_call(R, RI, RM, Sur, Secs) -> %% %% @end %%-------------------------------------------------------------------- --spec default_reason() -> ne_binary(). +-spec default_reason() -> kz_term:ne_binary(). default_reason() -> unknown(). --spec per_minute_call() -> ne_binary(). --spec sub_account_per_minute_call() -> ne_binary(). --spec feature_activation() -> ne_binary(). --spec sub_account_feature_activation() -> ne_binary(). --spec number_activation() -> ne_binary(). --spec sub_account_number_activation() -> ne_binary(). --spec manual_addition() -> ne_binary(). --spec sub_account_manual_addition() -> ne_binary(). --spec auto_addition() -> ne_binary(). --spec sub_account_auto_addition() -> ne_binary(). --spec admin_discretion() -> ne_binary(). --spec topup() -> ne_binary(). --spec database_rollup() -> ne_binary(). --spec recurring() -> ne_binary(). --spec monthly_recurring() -> ne_binary(). --spec recurring_prorate() -> ne_binary(). --spec mobile() -> ne_binary(). --spec unknown() -> ne_binary(). +-spec per_minute_call() -> kz_term:ne_binary(). +-spec sub_account_per_minute_call() -> kz_term:ne_binary(). +-spec feature_activation() -> kz_term:ne_binary(). +-spec sub_account_feature_activation() -> kz_term:ne_binary(). +-spec number_activation() -> kz_term:ne_binary(). +-spec sub_account_number_activation() -> kz_term:ne_binary(). +-spec manual_addition() -> kz_term:ne_binary(). +-spec sub_account_manual_addition() -> kz_term:ne_binary(). +-spec auto_addition() -> kz_term:ne_binary(). +-spec sub_account_auto_addition() -> kz_term:ne_binary(). +-spec admin_discretion() -> kz_term:ne_binary(). +-spec topup() -> kz_term:ne_binary(). +-spec database_rollup() -> kz_term:ne_binary(). +-spec recurring() -> kz_term:ne_binary(). +-spec monthly_recurring() -> kz_term:ne_binary(). +-spec recurring_prorate() -> kz_term:ne_binary(). +-spec mobile() -> kz_term:ne_binary(). +-spec unknown() -> kz_term:ne_binary(). per_minute_call() -> <<"per_minute_call">>. sub_account_per_minute_call() -> <<"sub_account_per_minute_call">>. @@ -456,7 +456,7 @@ unknown() -> <<"unknown">>. %% %% @end %%-------------------------------------------------------------------- --spec is_valid_reason(ne_binary()) -> boolean(). +-spec is_valid_reason(kz_term:ne_binary()) -> boolean(). is_valid_reason(Reason) -> maps:is_key(Reason, reasons()). @@ -466,7 +466,7 @@ is_valid_reason(Reason) -> %% %% @end %%-------------------------------------------------------------------- --spec reason_code(ne_binary()) -> pos_integer(). +-spec reason_code(kz_term:ne_binary()) -> pos_integer(). reason_code(Reason) -> maps:get(Reason, reasons(), ?CODE_UNKNOWN). @@ -476,7 +476,7 @@ reason_code(Reason) -> %% %% @end %%-------------------------------------------------------------------- --spec code_reason(pos_integer()) -> api_ne_binary(). +-spec code_reason(pos_integer()) -> kz_term:api_ne_binary(). code_reason(Code) -> case lists:keyfind(Code, 2, maps:to_list(reasons())) of 'false' -> default_reason(); @@ -499,7 +499,7 @@ collapse_call_transactions(Transactions) -> %% %% @end %%-------------------------------------------------------------------- --spec modb(ne_binary()) -> 'ok'. +-spec modb(kz_term:ne_binary()) -> 'ok'. modb(?MATCH_MODB_SUFFIX_RAW(_AccountId, Year, Month) = AccountMODb) -> {Y, M, _} = erlang:date(), case {kz_term:to_binary(Y), kz_date:pad_month(M)} of @@ -515,7 +515,7 @@ modb(?MATCH_MODB_SUFFIX_ENCODED(_AccountId, Year, Month) = AccountMODb) -> modb(AccountMODb) -> lager:debug("~s was not matched as a account modb database, ignoring...", [AccountMODb]). --spec rollup_current_modb(ne_binary(), 0..3) -> 'ok'. +-spec rollup_current_modb(kz_term:ne_binary(), 0..3) -> 'ok'. rollup_current_modb(_AccountMODb, 0) -> lager:debug("retries exceeded during rollup current modb ~s", [_AccountMODb]); rollup_current_modb(AccountMODb, Loop) -> @@ -530,7 +530,7 @@ rollup_current_modb(AccountMODb, Loop) -> end. -spec rollup(kz_transaction:transaction()) -> 'ok'. --spec rollup(ne_binary(), integer()) -> 'ok'. +-spec rollup(kz_term:ne_binary(), integer()) -> 'ok'. rollup(Transaction) -> Transaction1 = kz_transaction:set_reason(<<"database_rollup">>, Transaction), Transaction2 = kz_transaction:set_description(<<"monthly rollup">>, Transaction1), @@ -552,14 +552,14 @@ rollup(?NE_BINARY = AccountMODb, Balance) -> lager:debug("creating monthly rollup for ~s as a debit for ~p", [AccountMODb, Balance]), rollup(kz_transaction:debit(AccountId, -1*Balance)). --spec update_rollup(ne_binary(), integer()) -> 'ok'. +-spec update_rollup(kz_term:ne_binary(), integer()) -> 'ok'. update_rollup(Account, Balance) -> case kazoo_modb:open_doc(Account, <<"monthly_rollup">>) of {'ok', JObj} -> update_rollup(Account, Balance, JObj); {'error', _R} -> rollup(Account, Balance) end. --spec update_rollup(ne_binary(), integer(), kz_json:object()) -> 'ok'. +-spec update_rollup(kz_term:ne_binary(), integer(), kz_json:object()) -> 'ok'. update_rollup(Account, Balance, JObj) -> Transaction = kz_transaction:from_json(JObj), case kz_transaction:type(Transaction) of @@ -573,7 +573,7 @@ update_rollup(Account, Balance, JObj) -> rollup(Account, abs(Balance)) end. --spec update_existing_rollup(ne_binary(), integer(), kz_transaction:transaction()) -> 'ok'. +-spec update_existing_rollup(kz_term:ne_binary(), integer(), kz_transaction:transaction()) -> 'ok'. update_existing_rollup(_Account, Balance, Transaction) -> {'ok', _} = kz_transaction:save(kz_transaction:set_amount_and_type(Balance, Transaction)), lager:debug("updated rollup in ~s with new balance ~p", [_Account, Balance]). diff --git a/core/kazoo_translator/src/convertors/kzt_kazoo.erl b/core/kazoo_translator/src/convertors/kzt_kazoo.erl index 59e01c8bcde..625a10ce3c1 100644 --- a/core/kazoo_translator/src/convertors/kzt_kazoo.erl +++ b/core/kazoo_translator/src/convertors/kzt_kazoo.erl @@ -38,7 +38,7 @@ resume_callflow(Call, FlowJObj) -> 'ok' = kz_amqp_worker:cast(Event, fun kapi_call:publish_event/1), {'usurp', Call}. --spec parse_cmds(ne_binary()) -> +-spec parse_cmds(kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', 'not_parsed'}. parse_cmds(<<_/binary>> = JSON) -> @@ -61,7 +61,7 @@ parse_cmds(<<_/binary>> = JSON) -> {'error', 'not_parsed'} end. --spec req_params(kapps_call:call()) -> kz_proplist(). +-spec req_params(kapps_call:call()) -> kz_term:proplist(). req_params(Call) -> Owners = case kz_attributes:owner_ids(kapps_call:authorizing_id(Call), Call) of [] -> 'undefined'; diff --git a/core/kazoo_translator/src/convertors/kzt_twiml.erl b/core/kazoo_translator/src/convertors/kzt_twiml.erl index 7395f31bdc2..39f1ffeb2bf 100644 --- a/core/kazoo_translator/src/convertors/kzt_twiml.erl +++ b/core/kazoo_translator/src/convertors/kzt_twiml.erl @@ -16,7 +16,7 @@ ]). -spec parse_cmds(binary()) -> - {'ok', xml_els()} | + {'ok', kz_types:xml_els()} | {'error', 'not_parsed'}. parse_cmds(XMLBin) -> try xmerl_scan:string(kz_term:to_list(XMLBin)) of @@ -28,7 +28,7 @@ parse_cmds(XMLBin) -> {'error', 'not_parsed'} end. --spec exec(kapps_call:call(), xml_el() | text()) -> +-spec exec(kapps_call:call(), kz_types:xml_el() | kz_term:text()) -> {'error', kapps_call:call()} | {'request', kapps_call:call()} | {'stop', kapps_call:call()}. @@ -47,7 +47,7 @@ exec(Call, Resp) -> {'error', Call} end. --spec exec_elements(kapps_call:call(), xml_els() | xml_texts()) -> +-spec exec_elements(kapps_call:call(), kz_types:xml_els() | kz_types:xml_texts()) -> {'error', kapps_call:call()} | {'request', kapps_call:call()} | {'stop', kapps_call:call()}. @@ -70,7 +70,7 @@ exec_elements(Call, [El|Els]) -> {'error', Call} end. --spec exec_element(kapps_call:call(), xml_el()) -> +-spec exec_element(kapps_call:call(), kz_types:xml_el()) -> {'ok', kapps_call:call()} | {'request', kapps_call:call()} | {'stop', kapps_call:call()} | @@ -144,7 +144,7 @@ exec_element(Call, _Xml) -> lager:debug("unhandled XML object: ~p", [_Xml]), {'ok', Call}. --spec req_params(kapps_call:call()) -> kz_proplist(). +-spec req_params(kapps_call:call()) -> kz_term:proplist(). req_params(Call) -> props:filter_undefined( [{<<"CallSid">>, kapps_call:call_id(Call)} @@ -178,7 +178,7 @@ hangup(Call) -> kapps_call_command:hangup(Call), {'stop', kzt_util:update_call_status(?STATUS_COMPLETED, Call)}. --spec reject(kapps_call:call(), xml_attribs()) -> +-spec reject(kapps_call:call(), kz_types:xml_attribs()) -> {'stop', kapps_call:call()}. reject(Call, Attrs) -> Props = kz_xml:attributes_to_proplist(Attrs), @@ -190,7 +190,7 @@ reject(Call, Attrs) -> _ = kapps_call_command:response(Code, Reason, kzt_twiml_util:reject_prompt(Props), Call), {'stop', kzt_util:update_call_status(kzt_twiml_util:reject_status(Code), Call)}. --spec pause(kapps_call:call(), xml_attribs()) -> +-spec pause(kapps_call:call(), kz_types:xml_attribs()) -> {'ok', kapps_call:call()}. pause(Call, Attrs) -> kapps_call_command:answer(Call), @@ -201,7 +201,7 @@ pause(Call, Attrs) -> timer:sleep(PauseFor), {'ok', Call}. --spec set_variable(kapps_call:call(), xml_attribs()) -> +-spec set_variable(kapps_call:call(), kz_types:xml_attribs()) -> {'ok', kapps_call:call()}. set_variable(Call, Attrs) -> kapps_call_command:answer(Call), @@ -211,7 +211,7 @@ set_variable(Call, Attrs) -> ,Call )}. --spec set_variables(kapps_call:call(), xml_els()) -> kapps_call:call(). +-spec set_variables(kapps_call:call(), kz_types:xml_els()) -> kapps_call:call(). set_variables(Call, Els) when is_list(Els) -> lists:foldl(fun(#xmlElement{name='Variable' ,attributes=Attrs @@ -220,7 +220,7 @@ set_variables(Call, Els) when is_list(Els) -> (_, C) -> C end, Call, Els). --spec play(kapps_call:call(), xml_els() | xml_texts(), xml_attribs()) -> +-spec play(kapps_call:call(), kz_types:xml_els() | kz_types:xml_texts(), kz_types:xml_attribs()) -> {'ok', kapps_call:call()} | {'error', _, kapps_call:call()}. play(Call, XmlText, Attrs) -> @@ -236,7 +236,7 @@ play(Call, XmlText, Attrs) -> N when N > 0 -> kzt_receiver:play_loop(Call, PlayMe, Terminators, N) end. --spec redirect(kapps_call:call(), xml_els() | xml_texts(), xml_attribs()) -> +-spec redirect(kapps_call:call(), kz_types:xml_els() | kz_types:xml_texts(), kz_types:xml_attribs()) -> {'request', kapps_call:call()}. redirect(Call, XmlText, Attrs) -> kapps_call_command:answer(Call), @@ -261,7 +261,7 @@ redirect(Call, XmlText, Attrs) -> {'request', lists:foldl(fun({F, V}, C) -> F(V, C) end, Call1, Setters)}. %% @private --spec exec_gather_els(pid(), kapps_call:call(), xml_els()) -> 'ok'. +-spec exec_gather_els(pid(), kapps_call:call(), kz_types:xml_els()) -> 'ok'. exec_gather_els(_Parent, _Call, []) -> lager:info("finished gather sub elements"); exec_gather_els(Parent, Call, [SubAction|SubActions]) -> @@ -273,7 +273,7 @@ exec_gather_els(Parent, Call, [SubAction|SubActions]) -> {'ok', Call1} -> exec_gather_els(Parent, Call1, SubActions) end. --spec exec_gather_els(kapps_call:call(), xml_els()) -> +-spec exec_gather_els(kapps_call:call(), kz_types:xml_els()) -> {'ok', kapps_call:call()}. exec_gather_els(Call, SubActions) -> {_Pid, _Ref}=PidRef = @@ -281,7 +281,7 @@ exec_gather_els(Call, SubActions) -> lager:debug("started to exec gather els: ~p(~p)", [_Pid, _Ref]), {'ok', kzt_util:set_gather_pidref(PidRef, Call)}. --spec gather(kapps_call:call(), xml_els(), xml_attribs()) -> +-spec gather(kapps_call:call(), kz_types:xml_els(), kz_types:xml_attribs()) -> kzt_receiver:collect_dtmfs_return(). gather(Call, [], Attrs) -> gather(Call, Attrs); gather(Call, SubActions, Attrs) -> @@ -291,7 +291,7 @@ gather(Call, SubActions, Attrs) -> ), gather(C, Attrs). --spec gather(kapps_call:call(), xml_attribs()) -> +-spec gather(kapps_call:call(), kz_types:xml_attribs()) -> kzt_receiver:collect_dtmfs_return(). gather(Call, Attrs) -> kapps_call_command:answer(Call), @@ -303,7 +303,7 @@ gather(Call, Attrs) -> gather(Call, FinishKey, Timeout, Props, kzt_twiml_util:num_digits(Props)). --spec gather(kapps_call:call(), api_binary(), kz_timeout(), kz_proplist(), pos_integer()) -> +-spec gather(kapps_call:call(), kz_term:api_binary(), timeout(), kz_term:proplist(), pos_integer()) -> {'ok', kapps_call:call()} | {'request', kapps_call:call()} | {'error', _, kapps_call:call()} | @@ -326,7 +326,7 @@ on_first_dtmf(Call) -> exit(Pid, 'kill') end. --spec gather_finished(kapps_call:call(), kz_proplist()) -> +-spec gather_finished(kapps_call:call(), kz_term:proplist()) -> {'ok', kapps_call:call()} | {'request', kapps_call:call()}. gather_finished(Call, Props) -> @@ -369,7 +369,7 @@ record_call(Call, Attrs) -> _E -> lager:debug("call record failed: ~p", [_E]), {'stop', Call} end. --spec finish_record_call(kapps_call:call(), kz_proplist(), ne_binary()) -> +-spec finish_record_call(kapps_call:call(), kz_term:proplist(), kz_term:ne_binary()) -> {'request', kapps_call:call()}. finish_record_call(Call, Props, MediaName) -> CurrentUri = kzt_util:get_voice_uri(Call), diff --git a/core/kazoo_translator/src/convertors/kzt_twiml_dial.erl b/core/kazoo_translator/src/convertors/kzt_twiml_dial.erl index c562032f8dd..a12ec8774bc 100644 --- a/core/kazoo_translator/src/convertors/kzt_twiml_dial.erl +++ b/core/kazoo_translator/src/convertors/kzt_twiml_dial.erl @@ -16,7 +16,7 @@ -include("kzt.hrl"). --spec exec(kapps_call:call(), xml_els() | xml_texts(), xml_attribs()) -> +-spec exec(kapps_call:call(), kz_types:xml_els() | kz_types:xml_texts(), kz_types:xml_attribs()) -> {'ok' | 'stop', kapps_call:call()}. exec(Call, [#xmlText{type='text'}|_]=DialMeTxts, Attrs) -> kapps_call_command:answer(Call), @@ -172,7 +172,7 @@ send_bridge_command(EPs, Timeout, Strategy, IgnoreEarlyMedia, Call) -> ], kapps_call_command:send_command(B, Call). --spec setup_call_for_dial(kapps_call:call(), kz_proplist()) -> kapps_call:call(). +-spec setup_call_for_dial(kapps_call:call(), kz_term:proplist()) -> kapps_call:call(). setup_call_for_dial(Call, Props) -> Setters = [{fun kapps_call:set_caller_id_number/2, caller_id(Props, Call)} ,{fun kzt_util:set_hangup_dtmf/2, hangup_dtmf(Props)} @@ -182,7 +182,7 @@ setup_call_for_dial(Call, Props) -> ], kapps_call:exec(Setters, Call). --spec maybe_end_dial(kapps_call:call(), kz_proplist()) -> +-spec maybe_end_dial(kapps_call:call(), kz_term:proplist()) -> {'ok' | 'stop' | 'request', kapps_call:call()}. maybe_end_dial(Call, Props) -> maybe_end_dial(Call, Props, kzt_twiml_util:action_url(Props)). @@ -216,9 +216,9 @@ is_numeric_or_plus(_) -> 'false'. %% capture the failed B-leg and continue processing the TwiML (if any). force_outbound(Props) -> props:get_is_true('continueOnFail', Props, 'true'). --spec xml_elements_to_endpoints(kapps_call:call(), xml_els()) -> +-spec xml_elements_to_endpoints(kapps_call:call(), kz_types:xml_els()) -> kz_json:objects(). --spec xml_elements_to_endpoints(kapps_call:call(), xml_els(), kz_json:objects()) -> +-spec xml_elements_to_endpoints(kapps_call:call(), kz_types:xml_els(), kz_json:objects()) -> kz_json:objects(). xml_elements_to_endpoints(Call, EPs) -> xml_elements_to_endpoints(Call, EPs, []). @@ -312,8 +312,8 @@ sip_device(URI) -> request_id(N, Call) -> iolist_to_binary([N, <<"@">>, kapps_call:from_realm(Call)]). --spec media_processing(kapps_call:call()) -> ne_binary(). --spec media_processing(boolean(), api_binary()) -> ne_binary(). +-spec media_processing(kapps_call:call()) -> kz_term:ne_binary(). +-spec media_processing(boolean(), kz_term:api_binary()) -> kz_term:ne_binary(). media_processing(Call) -> media_processing(kzt_util:get_record_call(Call), kzt_util:get_hangup_dtmf(Call)). @@ -324,7 +324,7 @@ get_max_participants(Props) when is_list(Props) -> get_max_participants(props:get_integer_value('maxParticipants', Props, 40)); get_max_participants(N) when is_integer(N), N =< 40, N > 0 -> N. --spec dial_timeout(kz_proplist() | pos_integer()) -> pos_integer(). +-spec dial_timeout(kz_term:proplist() | pos_integer()) -> pos_integer(). dial_timeout(Props) when is_list(Props) -> dial_timeout(props:get_integer_value('timeout', Props, 20)); dial_timeout(T) when is_integer(T), T > 0 -> T. @@ -336,13 +336,13 @@ dial_strategy(Props) -> <<"single">> -> <<"single">> end. --spec caller_id(kz_proplist(), kapps_call:call()) -> ne_binary(). +-spec caller_id(kz_term:proplist(), kapps_call:call()) -> kz_term:ne_binary(). caller_id(Props, Call) -> kz_term:to_binary( props:get_value('callerId', Props, kapps_call:caller_id_number(Call)) ). --spec hangup_dtmf(kz_proplist() | api_binary()) -> api_binary(). +-spec hangup_dtmf(kz_term:proplist() | kz_term:api_binary()) -> kz_term:api_binary(). hangup_dtmf(Props) when is_list(Props) -> case props:get_value('hangupOnStar', Props) of 'true' -> <<"*">>; @@ -358,7 +358,7 @@ should_record_call(Props) -> kz_term:is_true(props:get_value('record', Props, 'f timelimit_s(Props) -> props:get_integer_value('timeLimit', Props, 14400). --spec build_conference_doc(ne_binary(), kz_proplist()) -> kz_json:object(). +-spec build_conference_doc(kz_term:ne_binary(), kz_term:proplist()) -> kz_json:object(). build_conference_doc(ConfId, ConfProps) -> StartOnEnter = props:is_true('startConferenceOnEnter', ConfProps), @@ -400,7 +400,7 @@ conference_id(Txts) -> MD5. --spec add_conference_profile(kapps_call:call(), kz_proplist()) -> kapps_call:call(). +-spec add_conference_profile(kapps_call:call(), kz_term:proplist()) -> kapps_call:call(). add_conference_profile(Call, ConfProps) -> AccountId = kapps_call:account_id(Call), Profile = kz_json:from_list( diff --git a/core/kazoo_translator/src/convertors/kzt_twiml_say.erl b/core/kazoo_translator/src/convertors/kzt_twiml_say.erl index 68b7842a6c6..6efad112a63 100644 --- a/core/kazoo_translator/src/convertors/kzt_twiml_say.erl +++ b/core/kazoo_translator/src/convertors/kzt_twiml_say.erl @@ -12,7 +12,7 @@ -include("kzt.hrl"). --spec exec(kapps_call:call(), xml_els() | xml_texts(), xml_attribs()) -> +-spec exec(kapps_call:call(), kz_types:xml_els() | kz_types:xml_texts(), kz_types:xml_attribs()) -> {'ok', kapps_call:call()} | {'error', _, kapps_call:call()}. exec(Call, XmlText, Attrs) -> diff --git a/core/kazoo_translator/src/convertors/kzt_twiml_util.erl b/core/kazoo_translator/src/convertors/kzt_twiml_util.erl index 961e6e13ea0..22d4f9ee2cf 100644 --- a/core/kazoo_translator/src/convertors/kzt_twiml_util.erl +++ b/core/kazoo_translator/src/convertors/kzt_twiml_util.erl @@ -28,11 +28,11 @@ -include("kzt.hrl"). --spec get_terminators(kz_proplist()) -> ne_binaries(). +-spec get_terminators(kz_term:proplist()) -> kz_term:ne_binaries(). get_terminators(Props) -> kapi_dialplan:terminators(props:get_binary_value('terminators', Props)). --spec get_lang(kz_proplist()) -> ne_binary(). +-spec get_lang(kz_term:proplist()) -> kz_term:ne_binary(). get_lang(Props) -> case props:get_binary_value('language', Props) of 'undefined' -> ?DEFAULT_TTS_LANG; @@ -44,7 +44,7 @@ get_lang(Props) -> <<"it">> -> <<"it">> end. --spec get_voice(kz_proplist()) -> ne_binary(). +-spec get_voice(kz_term:proplist()) -> kz_term:ne_binary(). get_voice(Props) -> case props:get_binary_value('voice', Props) of <<"man">> -> <<"male">>; @@ -54,18 +54,18 @@ get_voice(Props) -> 'undefined' -> ?DEFAULT_TTS_VOICE end. --spec get_engine(kz_proplist()) -> ne_binary(). +-spec get_engine(kz_term:proplist()) -> kz_term:ne_binary(). get_engine(Props) -> case props:get_binary_value('engine', Props) of 'undefined' -> ?DEFAULT_TTS_ENGINE; Engine -> Engine end. --spec loop_count(kz_proplist()) -> integer(). +-spec loop_count(kz_term:proplist()) -> integer(). loop_count(Props) -> props:get_integer_value('loop', Props, 1). --spec finish_dtmf(kz_proplist()) -> ne_binary(). --spec finish_dtmf(kz_proplist(), ne_binary()) -> ne_binary(). +-spec finish_dtmf(kz_term:proplist()) -> kz_term:ne_binary(). +-spec finish_dtmf(kz_term:proplist(), kz_term:ne_binary()) -> kz_term:ne_binary(). finish_dtmf(Props) -> finish_dtmf(Props, <<"#">>). finish_dtmf(Props, Default) when is_list(Props) -> case props:get_binary_value('finishOnKey', Props) of @@ -75,11 +75,11 @@ finish_dtmf(Props, Default) when is_list(Props) -> DTMF end. --spec get_finish_key(kz_proplist()) -> ne_binaries(). +-spec get_finish_key(kz_term:proplist()) -> kz_term:ne_binaries(). get_finish_key(Props) -> kapi_dialplan:terminators(props:get_binary_value('finishOnKey', Props)). --spec get_max_length(kz_proplist()) -> pos_integer(). +-spec get_max_length(kz_term:proplist()) -> pos_integer(). get_max_length(Props) -> Max = kapps_config:get_integer(?MODULE, <<"max_length">>, 3600), case props:get_integer_value('maxLength', Props) of @@ -88,7 +88,7 @@ get_max_length(Props) -> end. %% limit pause to 1 hour (3600000 ms) --spec pause_for(kz_proplist()) -> 1000..3600000. +-spec pause_for(kz_term:proplist()) -> 1000..3600000. pause_for(Props) -> case props:get_integer_value('length', Props) of 'undefined' -> ?MILLISECONDS_IN_SECOND; @@ -96,14 +96,14 @@ pause_for(Props) -> N when is_integer(N), N > 3600 -> 3600000 end. --spec action_url(kz_proplist()) -> api_binary(). +-spec action_url(kz_term:proplist()) -> kz_term:api_binary(). action_url(Props) -> props:get_binary_value('action', Props). --spec reject_prompt(kz_proplist()) -> api_binary(). +-spec reject_prompt(kz_term:proplist()) -> kz_term:api_binary(). reject_prompt(Props) -> props:get_binary_value('prompt', Props). --spec timeout_s(kz_proplist()) -> pos_integer(). --spec timeout_s(kz_proplist(), pos_integer()) -> pos_integer(). +-spec timeout_s(kz_term:proplist()) -> pos_integer(). +-spec timeout_s(kz_term:proplist(), pos_integer()) -> pos_integer(). timeout_s(Props) -> timeout_s(Props, 30). timeout_s(Props, Default) -> case props:get_integer_value('timeout', Props, Default) of @@ -111,14 +111,14 @@ timeout_s(Props, Default) -> N when is_integer(N), N > 0 -> N end. --spec num_digits(kz_proplist()) -> kz_timeout(). +-spec num_digits(kz_term:proplist()) -> timeout(). num_digits(Props) -> case props:get_integer_value('numDigits', Props) of 'undefined' -> 'infinity'; N when is_integer(N), N > 0 -> N end. --spec reject_reason(kz_proplist()) -> ne_binary(). +-spec reject_reason(kz_term:proplist()) -> kz_term:ne_binary(). reject_reason(Props) -> case props:get_binary_value('reason', Props) of 'undefined' -> <<"rejected">>; @@ -126,10 +126,10 @@ reject_reason(Props) -> <<"busy">> -> <<"busy">> end. --spec reject_code(ne_binary()) -> ne_binary(). +-spec reject_code(kz_term:ne_binary()) -> kz_term:ne_binary(). reject_code(<<"busy">>) -> <<"486">>; reject_code(<<"rejected">>) -> <<"503">>. --spec reject_status(ne_binary()) -> ne_binary(). +-spec reject_status(kz_term:ne_binary()) -> kz_term:ne_binary(). reject_status(<<"486">>) -> ?STATUS_BUSY; reject_status(<<"503">>) -> ?STATUS_NOANSWER. diff --git a/core/kazoo_translator/src/kzt_receiver.erl b/core/kazoo_translator/src/kzt_receiver.erl index 01622644f10..3b39c6df023 100644 --- a/core/kazoo_translator/src/kzt_receiver.erl +++ b/core/kazoo_translator/src/kzt_receiver.erl @@ -23,13 +23,13 @@ ]). -record(dial_req, {call :: kapps_call:call() - ,hangup_dtmf :: api_binary() + ,hangup_dtmf :: kz_term:api_binary() ,collect_dtmf = 'false' :: boolean() ,record_call :: boolean() - ,call_timeout :: kz_timeout() | 'undefined' - ,call_time_limit :: kz_timeout() - ,start :: kz_now() - ,call_b_leg :: api_binary() + ,call_timeout :: timeout() | 'undefined' + ,call_time_limit :: timeout() + ,start :: kz_time:now() + ,call_b_leg :: kz_term:api_binary() }). -type dial_req() :: #dial_req{}. @@ -44,13 +44,13 @@ -spec default_on_first_fun(any()) -> 'ok'. default_on_first_fun(_) -> 'ok'. --spec collect_dtmfs(kapps_call:call(), api_binary(), kz_timeout(), pos_integer()) -> +-spec collect_dtmfs(kapps_call:call(), kz_term:api_binary(), timeout(), pos_integer()) -> collect_dtmfs_return(). --spec collect_dtmfs(kapps_call:call(), api_binary(), kz_timeout(), pos_integer(), function()) -> +-spec collect_dtmfs(kapps_call:call(), kz_term:api_binary(), timeout(), pos_integer(), function()) -> collect_dtmfs_return(). --spec collect_dtmfs(kapps_call:call(), api_binary(), kz_timeout(), pos_integer(), function(), binary()) -> +-spec collect_dtmfs(kapps_call:call(), kz_term:api_binary(), timeout(), pos_integer(), function(), binary()) -> collect_dtmfs_return(). --spec collect_dtmfs(kapps_call:call(), api_binary(), kz_timeout(), pos_integer(), function(), binary(), kz_json:object()) -> +-spec collect_dtmfs(kapps_call:call(), kz_term:api_binary(), timeout(), pos_integer(), function(), binary(), kz_json:object()) -> collect_dtmfs_return(). collect_dtmfs(Call, FinishKey, Timeout, N) -> @@ -132,7 +132,7 @@ collect_dtmfs(Call, FinishKey, Timeout, N, OnFirstFun, Collected, JObj) -> collect_dtmfs(Call, FinishKey, Timeout, N, OnFirstFun, Collected) end. --spec handle_dtmf(kapps_call:call(), api_binary(), kz_timeout(), pos_integer(), function(), binary(), api_binary()) -> +-spec handle_dtmf(kapps_call:call(), kz_term:api_binary(), timeout(), pos_integer(), function(), binary(), kz_term:api_binary()) -> collect_dtmfs_return(). handle_dtmf(Call, FinishKey, _Timeout, _N, _OnFirstFun, _Collected, FinishKey) -> lager:info("finish key '~s' pressed", [FinishKey]), @@ -164,8 +164,8 @@ handle_dtmf(Call, FinishKey, Timeout, N, OnFirstFun, Collected, DTMF) -> ,<> ). --spec collect_decr_timeout(kapps_call:call(), kz_timeout(), kz_now()) -> - kz_timeout(). +-spec collect_decr_timeout(kapps_call:call(), timeout(), kz_time:now()) -> + timeout(). collect_decr_timeout(Call, Timeout, Start) -> case kzt_util:get_gather_pidref(Call) of {_Pid, _Ref} when is_pid(_Pid) @@ -174,7 +174,7 @@ collect_decr_timeout(Call, Timeout, Start) -> _ -> kz_time:decr_timeout(Timeout, Start) end. --spec collect_timeout(kapps_call:call(), kz_timeout()) -> kz_timeout(). +-spec collect_timeout(kapps_call:call(), timeout()) -> timeout(). collect_timeout(Call, Timeout) -> case kzt_util:get_gather_pidref(Call) of {_Pid, _Ref} when is_pid(_Pid) @@ -183,10 +183,10 @@ collect_timeout(Call, Timeout) -> _ -> Timeout end. --spec say_loop(kapps_call:call(), ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_timeout()) -> +-spec say_loop(kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), timeout()) -> {'ok', kapps_call:call()} | {'error', _, kapps_call:call()}. --spec say_loop(kapps_call:call(), ne_binary(), ne_binary(), ne_binary(), list() | 'undefined', ne_binary(), kz_timeout()) -> +-spec say_loop(kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), list() | 'undefined', kz_term:ne_binary(), timeout()) -> {'ok', kapps_call:call()} | {'error', _, kapps_call:call()}. say_loop(Call, SayMe, Voice, Lang, Engine, N) -> @@ -209,10 +209,10 @@ say_loop(Call, SayMe, Voice, Lang, Terminators, Engine, N) -> {'error', _, _}=ERR -> ERR end. --spec play_loop(kapps_call:call(), binary(), kz_timeout()) -> +-spec play_loop(kapps_call:call(), binary(), timeout()) -> {'ok', kapps_call:call()} | {'error', _, kapps_call:call()}. --spec play_loop(kapps_call:call(), binary(), list() | 'undefined', kz_timeout()) -> +-spec play_loop(kapps_call:call(), binary(), list() | 'undefined', timeout()) -> {'ok', kapps_call:call()} | {'error', _, kapps_call:call()}. play_loop(Call, PlayMe, N) -> @@ -293,12 +293,12 @@ process_call_event(Call, EvtName, JObj) -> wait_for_call_event(Call, EvtName) end. --spec decr_loop_counter(kz_timeout()) -> kz_timeout(). +-spec decr_loop_counter(timeout()) -> timeout(). decr_loop_counter('infinity') -> 'infinity'; decr_loop_counter(N) when is_integer(N), N > 0 -> N-1; decr_loop_counter(_) -> 0. --spec wait_for_noop(kapps_call:call(), ne_binary()) -> +-spec wait_for_noop(kapps_call:call(), kz_term:ne_binary()) -> {'ok', kapps_call:call()} | {'error', noop_error(), kapps_call:call()}. wait_for_noop(Call, NoopId) -> @@ -313,7 +313,7 @@ wait_for_noop(Call, NoopId) -> end. -type noop_error() :: 'channel_destroy' | 'channel_hungup'. --spec process_noop_event(kapps_call:call(), ne_binary(), kz_json:object()) -> +-spec process_noop_event(kapps_call:call(), kz_term:ne_binary(), kz_json:object()) -> {'ok', kapps_call:call()} | {'error', noop_error(), kapps_call:call()}. process_noop_event(Call, NoopId, JObj) -> @@ -335,7 +335,7 @@ process_noop_event(Call, NoopId, JObj) -> -spec wait_for_offnet(kapps_call:call()) -> {'ok', kapps_call:call()}. --spec wait_for_offnet(kapps_call:call(), kz_proplist()) -> +-spec wait_for_offnet(kapps_call:call(), kz_term:proplist()) -> {'ok', kapps_call:call()}. wait_for_offnet(Call) -> wait_for_offnet(Call, []). @@ -400,7 +400,7 @@ wait_for_conference(Call) -> ,start=kz_time:now() }). --spec call_status(ne_binary()) -> ne_binary(). +-spec call_status(kz_term:ne_binary()) -> kz_term:ne_binary(). call_status(<<"ORIGINATOR_CANCEL">>) -> ?STATUS_COMPLETED; call_status(<<"NORMAL_CLEARING">>) -> ?STATUS_COMPLETED; call_status(<<"SUCCESS">>) -> ?STATUS_COMPLETED; @@ -533,7 +533,7 @@ handle_dtmf_event(#dial_req{call=Call -spec handle_hangup(kapps_call:call(), kz_json:object()) -> {'ok', kapps_call:call()}. --spec handle_hangup(kapps_call:call(), kz_json:object(), ne_binary()) -> +-spec handle_hangup(kapps_call:call(), kz_json:object(), kz_term:ne_binary()) -> {'ok', kapps_call:call()}. handle_hangup(Call, JObj) -> handle_hangup(Call, JObj, kz_call_event:hangup_cause(JObj)). @@ -551,7 +551,7 @@ handle_hangup(Call, _JObj, HangupCause) -> {'ok', kapps_call:exec(Updates, Call)}. -spec maybe_hangup_other_leg(kapps_call:call()) -> 'ok'. --spec maybe_hangup_other_leg(kapps_call:call(), api_binary()) -> 'ok'. +-spec maybe_hangup_other_leg(kapps_call:call(), kz_term:api_binary()) -> 'ok'. maybe_hangup_other_leg(Call) -> maybe_hangup_other_leg(Call, kapps_call:other_leg_call_id(Call)). @@ -563,7 +563,7 @@ maybe_hangup_other_leg(Call, OtherLeg) -> ], kapps_call_command:send_command(Req, Call). --spec dial_status(kapps_call:call() | api_binary()) -> ne_binary(). +-spec dial_status(kapps_call:call() | kz_term:api_binary()) -> kz_term:ne_binary(). dial_status(?STATUS_ANSWERED) -> ?STATUS_COMPLETED; dial_status(?STATUS_RINGING) -> ?STATUS_NOANSWER; dial_status(<<_/binary>>) -> ?STATUS_FAILED; @@ -652,7 +652,7 @@ maybe_start_recording(#dial_req{record_call='true' ), MediaJObj. --spec recording_meta(kapps_call:call(), ne_binary()) -> +-spec recording_meta(kapps_call:call(), kz_term:ne_binary()) -> {'ok', kz_json:object()} | {'error', any()}. recording_meta(Call, MediaName) -> @@ -701,7 +701,7 @@ handle_conference_timeout(#dial_req{call=Call}) -> lager:debug("timed out waiting for call to be answered by the conference"), {'ok', kzt_util:update_call_status(?STATUS_NOANSWER, Call)}. --spec which_time(api_integer(), pos_integer()) -> non_neg_integer(). +-spec which_time(kz_term:api_integer(), pos_integer()) -> non_neg_integer(). which_time('undefined', Timelimit) when is_integer(Timelimit), Timelimit > 0 -> Timelimit; diff --git a/core/kazoo_translator/src/kzt_translator.erl b/core/kazoo_translator/src/kzt_translator.erl index 4df6b57149f..3e253485329 100644 --- a/core/kazoo_translator/src/kzt_translator.erl +++ b/core/kazoo_translator/src/kzt_translator.erl @@ -17,7 +17,7 @@ -include("kzt.hrl"). -spec exec(kapps_call:call(), binary()) -> exec_return(). --spec exec(kapps_call:call(), binary(), api_binary() | list()) -> exec_return(). +-spec exec(kapps_call:call(), binary(), kz_term:api_binary() | list()) -> exec_return(). exec(Call, Cmds) -> exec(Call, Cmds, <<"text/xml">>). @@ -33,7 +33,7 @@ exec(Call, Cmds, CT) -> [{Translator, Cmds1}|_] -> Translator:exec(Call, Cmds1) end. --spec just_the_type(ne_binary()) -> ne_binary(). +-spec just_the_type(kz_term:ne_binary()) -> kz_term:ne_binary(). just_the_type(ContentType) -> case binary:split(ContentType, <<";">>) of [ContentType] -> kz_binary:strip(ContentType); @@ -43,7 +43,7 @@ just_the_type(ContentType) -> end. -spec get_user_vars(kapps_call:call()) -> kz_json:object(). --spec set_user_vars(kz_proplist(), kapps_call:call()) -> kapps_call:call(). +-spec set_user_vars(kz_term:proplist(), kapps_call:call()) -> kapps_call:call(). get_user_vars(Call) -> ReqVars = kzt_util:get_request_vars(Call), UserVars = kapps_call:kvs_fetch(?KZT_USER_VARS, kz_json:new(), Call), @@ -52,7 +52,7 @@ set_user_vars(Prop, Call) -> UserVars = get_user_vars(Call), kapps_call:kvs_store(?KZT_USER_VARS, kz_json:set_values(Prop, UserVars), Call). --spec find_candidate_translators(ne_binary()) -> atoms(). +-spec find_candidate_translators(kz_term:ne_binary()) -> kz_term:atoms(). find_candidate_translators(<<"text/xml">>) -> ['kzt_twiml']; find_candidate_translators(<<"application/xml">>) -> diff --git a/core/kazoo_translator/src/kzt_util.erl b/core/kazoo_translator/src/kzt_util.erl index 9a80ecd5242..ccaf33d490a 100644 --- a/core/kazoo_translator/src/kzt_util.erl +++ b/core/kazoo_translator/src/kzt_util.erl @@ -59,7 +59,7 @@ -define(DEFAULT_HTTP_METHOD, 'post'). --spec http_method(api_binary() | list()) -> 'get' | 'post'. +-spec http_method(kz_term:api_binary() | list()) -> 'get' | 'post'. http_method(L) when is_list(L) -> http_method(kz_term:to_binary(props:get_value('method', L))); http_method('undefined') -> ?DEFAULT_HTTP_METHOD; @@ -75,12 +75,12 @@ http_method(<<_/binary>> = Method) -> end; http_method(Method) -> http_method(kz_term:to_binary(Method)). --spec resolve_uri(ne_binary(), ne_binary()) -> ne_binary(). +-spec resolve_uri(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). resolve_uri(Path, NewPath) -> kz_util:resolve_uri(Path, NewPath). %% see cf_offnet.erl --spec offnet_req(kz_proplist(), kapps_call:call()) -> 'ok'. +-spec offnet_req(kz_term:proplist(), kapps_call:call()) -> 'ok'. offnet_req(Data, Call) -> {ECIDNum, ECIDName} = kz_attributes:caller_id(<<"emergency">>, Call), {CIDNumber, CIDName} = kz_attributes:caller_id(<<"external">>, Call), @@ -110,14 +110,14 @@ offnet_req(Data, Call) -> kz_amqp_worker:cast(Req, fun kapi_offnet_resource:publish_req/1). --spec update_call_status(ne_binary(), kapps_call:call()) -> kapps_call:call(). --spec get_call_status(kapps_call:call()) -> api_binary(). +-spec update_call_status(kz_term:ne_binary(), kapps_call:call()) -> kapps_call:call(). +-spec get_call_status(kapps_call:call()) -> kz_term:api_binary(). update_call_status(Status, Call) -> kapps_call:kvs_store(<<"call_status">>, Status, Call). get_call_status(Call) -> kapps_call:kvs_fetch(<<"call_status">>, Call). --spec add_error(kapps_call:call(), ne_binary(), any()) -> kapps_call:call(). +-spec add_error(kapps_call:call(), kz_term:ne_binary(), any()) -> kapps_call:call(). add_error(Call, K, V) -> case kapps_call:kvs_fetch(<<"response_errors">>, Call) of 'undefined' -> @@ -126,16 +126,16 @@ add_error(Call, K, V) -> kapps_call:kvs_append_list(<<"response_errors">>, [{K, V}|Vs], Call) end. --spec get_errors(kapps_call:call()) -> kz_proplist(). +-spec get_errors(kapps_call:call()) -> kz_term:proplist(). get_errors(Call) -> kapps_call:kvs_fetch(<<"response_errors">>, Call). --spec set_hangup_dtmf(ne_binary(), kapps_call:call()) -> kapps_call:call(). --spec get_hangup_dtmf(kapps_call:call()) -> api_binary(). +-spec set_hangup_dtmf(kz_term:ne_binary(), kapps_call:call()) -> kapps_call:call(). +-spec get_hangup_dtmf(kapps_call:call()) -> kz_term:api_binary(). set_hangup_dtmf(DTMF, Call) -> kapps_call:kvs_store(<<"hangup_dtmf">>, DTMF, Call). get_hangup_dtmf(Call) -> kapps_call:kvs_fetch(<<"hangup_dtmf">>, Call). --spec set_digit_pressed(api_binary(), kapps_call:call()) -> kapps_call:call(). --spec get_digit_pressed(kapps_call:call()) -> api_binary() | kz_json:object(). +-spec set_digit_pressed(kz_term:api_binary(), kapps_call:call()) -> kapps_call:call(). +-spec get_digit_pressed(kapps_call:call()) -> kz_term:api_binary() | kz_json:object(). set_digit_pressed(DTMF, Call) -> kapps_call:kvs_store(<<"digit_pressed">>, DTMF, Call). get_digit_pressed(Call) -> case kapps_call:kvs_fetch(<<"digit_pressed">>, Call) of @@ -143,27 +143,27 @@ get_digit_pressed(Call) -> D -> D end. --spec get_digits_pressed(kapps_call:call()) -> api_object(). +-spec get_digits_pressed(kapps_call:call()) -> kz_term:api_object(). get_digits_pressed(Call) -> kapps_call:kvs_fetch(<<"dtmf_collections">>, Call). -spec set_record_call(boolean(), kapps_call:call()) -> kapps_call:call(). --spec get_record_call(kapps_call:call()) -> api_boolean(). +-spec get_record_call(kapps_call:call()) -> kz_term:api_boolean(). set_record_call(R, Call) -> kapps_call:kvs_store(<<"record_call">>, R, Call). get_record_call(Call) -> kapps_call:kvs_fetch(<<"record_call">>, Call). -spec set_call_timeout(pos_integer(), kapps_call:call()) -> kapps_call:call(). --spec get_call_timeout(kapps_call:call()) -> api_integer(). +-spec get_call_timeout(kapps_call:call()) -> kz_term:api_integer(). set_call_timeout(T, Call) -> kapps_call:kvs_store(<<"call_timeout">>, T, Call). get_call_timeout(Call) -> kapps_call:kvs_fetch(<<"call_timeout">>, Call). -spec set_call_time_limit(pos_integer(), kapps_call:call()) -> kapps_call:call(). --spec get_call_time_limit(kapps_call:call()) -> api_integer(). +-spec get_call_time_limit(kapps_call:call()) -> kz_term:api_integer(). set_call_time_limit(T, Call) -> kapps_call:kvs_store(<<"call_time_limit">>, T, Call). get_call_time_limit(Call) -> kapps_call:kvs_fetch(<<"call_time_limit">>, Call). --spec set_voice_uri(api_binary(), kapps_call:call()) -> kapps_call:call(). --spec get_voice_uri(kapps_call:call()) -> api_binary(). +-spec set_voice_uri(kz_term:api_binary(), kapps_call:call()) -> kapps_call:call(). +-spec get_voice_uri(kapps_call:call()) -> kz_term:api_binary(). set_voice_uri(Uri, Call) -> kapps_call:kvs_store(<<"voice_uri">>, Uri, Call). get_voice_uri(Call) -> kapps_call:kvs_fetch(<<"voice_uri">>, Call). @@ -172,10 +172,10 @@ get_voice_uri(Call) -> kapps_call:kvs_fetch(<<"voice_uri">>, Call). set_voice_uri_method(M, Call) -> kapps_call:kvs_store(<<"voice_uri_method">>, M, Call). get_voice_uri_method(Call) -> kapps_call:kvs_fetch(<<"voice_uri_method">>, Call). --spec set_digits_collected(api_binary(), kapps_call:call()) -> kapps_call:call(). +-spec set_digits_collected(kz_term:api_binary(), kapps_call:call()) -> kapps_call:call(). -spec get_digits_collected(kapps_call:call()) -> binary(). -spec clear_digits_collected(kapps_call:call()) -> kapps_call:call(). --spec add_digit_collected(ne_binary(), kapps_call:call()) -> kapps_call:call(). +-spec add_digit_collected(kz_term:ne_binary(), kapps_call:call()) -> kapps_call:call(). set_digits_collected(Ds, Call) -> kapps_call:kvs_store(<<"digits_collected">>, Ds, Call). get_digits_collected(Call) -> kapps_call:kvs_fetch(<<"digits_collected">>, Call). clear_digits_collected(Call) -> kapps_call:kvs_store(<<"digits_collected">>, <<>>, Call). @@ -185,95 +185,95 @@ add_digit_collected(D, Call) -> end ,D, Call). --spec set_recording_url(ne_binary(), kapps_call:call()) -> kapps_call:call(). --spec get_recording_url(kapps_call:call()) -> api_binary(). +-spec set_recording_url(kz_term:ne_binary(), kapps_call:call()) -> kapps_call:call(). +-spec get_recording_url(kapps_call:call()) -> kz_term:api_binary(). set_recording_url(RU, Call) -> kapps_call:kvs_store(<<"recording_url">>, RU, Call). get_recording_url(Call) -> kapps_call:kvs_fetch(<<"recording_url">>, Call). -spec set_recording_duration(pos_integer(), kapps_call:call()) -> kapps_call:call(). --spec get_recording_duration(kapps_call:call()) -> api_integer(). +-spec get_recording_duration(kapps_call:call()) -> kz_term:api_integer(). set_recording_duration(RD, Call) -> kapps_call:kvs_store(<<"recording_duration">>, RD, Call). get_recording_duration(Call) -> kapps_call:kvs_fetch(<<"recording_duration">>, Call). --spec set_recording_sid(ne_binary(), kapps_call:call()) -> kapps_call:call(). --spec get_recording_sid(kapps_call:call()) -> api_binary(). +-spec set_recording_sid(kz_term:ne_binary(), kapps_call:call()) -> kapps_call:call(). +-spec get_recording_sid(kapps_call:call()) -> kz_term:api_binary(). set_recording_sid(SID, Call) -> kapps_call:kvs_store(<<"recording_sid">>, SID, Call). get_recording_sid(Call) -> kapps_call:kvs_fetch(<<"recording_sid">>, Call). --spec set_transcription_sid(ne_binary(), kapps_call:call()) -> kapps_call:call(). --spec get_transcription_sid(kapps_call:call()) -> api_binary(). +-spec set_transcription_sid(kz_term:ne_binary(), kapps_call:call()) -> kapps_call:call(). +-spec get_transcription_sid(kapps_call:call()) -> kz_term:api_binary(). set_transcription_sid(SID, Call) -> kapps_call:kvs_store(<<"transcription_sid">>, SID, Call). get_transcription_sid(Call) -> kapps_call:kvs_fetch(<<"transcription_sid">>, Call). --spec set_transcription_text(ne_binary(), kapps_call:call()) -> kapps_call:call(). --spec get_transcription_text(kapps_call:call()) -> api_binary(). +-spec set_transcription_text(kz_term:ne_binary(), kapps_call:call()) -> kapps_call:call(). +-spec get_transcription_text(kapps_call:call()) -> kz_term:api_binary(). set_transcription_text(RD, Call) -> kapps_call:kvs_store(<<"transcription_text">>, RD, Call). get_transcription_text(Call) -> kapps_call:kvs_fetch(<<"transcription_text">>, Call). --spec set_transcription_status(ne_binary(), kapps_call:call()) -> kapps_call:call(). --spec get_transcription_status(kapps_call:call()) -> api_binary(). +-spec set_transcription_status(kz_term:ne_binary(), kapps_call:call()) -> kapps_call:call(). +-spec get_transcription_status(kapps_call:call()) -> kz_term:api_binary(). set_transcription_status(RD, Call) -> kapps_call:kvs_store(<<"transcription_status">>, RD, Call). get_transcription_status(Call) -> kapps_call:kvs_fetch(<<"transcription_status">>, Call). --spec set_transcription_url(ne_binary(), kapps_call:call()) -> kapps_call:call(). --spec get_transcription_url(kapps_call:call()) -> api_binary(). +-spec set_transcription_url(kz_term:ne_binary(), kapps_call:call()) -> kapps_call:call(). +-spec get_transcription_url(kapps_call:call()) -> kz_term:api_binary(). set_transcription_url(RD, Call) -> kapps_call:kvs_store(<<"transcription_url">>, RD, Call). get_transcription_url(Call) -> kapps_call:kvs_fetch(<<"transcription_url">>, Call). --spec set_dial_call_status(ne_binary(), kapps_call:call()) -> kapps_call:call(). --spec get_dial_call_status(kapps_call:call()) -> api_binary(). +-spec set_dial_call_status(kz_term:ne_binary(), kapps_call:call()) -> kapps_call:call(). +-spec get_dial_call_status(kapps_call:call()) -> kz_term:api_binary(). set_dial_call_status(DCS, Call) -> kapps_call:kvs_store(<<"dial_call_status">>, DCS, Call). get_dial_call_status(Call) -> kapps_call:kvs_fetch(<<"dial_call_status">>, Call). --spec set_dial_call_sid(ne_binary(), kapps_call:call()) -> kapps_call:call(). --spec get_dial_call_sid(kapps_call:call()) -> api_binary(). +-spec set_dial_call_sid(kz_term:ne_binary(), kapps_call:call()) -> kapps_call:call(). +-spec get_dial_call_sid(kapps_call:call()) -> kz_term:api_binary(). set_dial_call_sid(DCS, Call) -> kapps_call:kvs_store(<<"dial_call_sid">>, DCS, Call). get_dial_call_sid(Call) -> kapps_call:kvs_fetch(<<"dial_call_sid">>, Call). -spec set_dial_call_duration(pos_integer(), kapps_call:call()) -> kapps_call:call(). --spec get_dial_call_duration(kapps_call:call()) -> api_integer(). +-spec get_dial_call_duration(kapps_call:call()) -> kz_term:api_integer(). set_dial_call_duration(DCS, Call) -> kapps_call:kvs_store(<<"dial_call_duration">>, DCS, Call). get_dial_call_duration(Call) -> kapps_call:kvs_fetch(<<"dial_call_duration">>, Call). --spec set_queue_sid(ne_binary(), kapps_call:call()) -> kapps_call:call(). --spec get_queue_sid(kapps_call:call()) -> api_binary(). +-spec set_queue_sid(kz_term:ne_binary(), kapps_call:call()) -> kapps_call:call(). +-spec get_queue_sid(kapps_call:call()) -> kz_term:api_binary(). set_queue_sid(DCS, Call) -> kapps_call:kvs_store(<<"queue_sid">>, DCS, Call). get_queue_sid(Call) -> kapps_call:kvs_fetch(<<"queue_sid">>, Call). --spec set_dequeue_result(ne_binary(), kapps_call:call()) -> kapps_call:call(). --spec get_dequeue_result(kapps_call:call()) -> api_binary(). +-spec set_dequeue_result(kz_term:ne_binary(), kapps_call:call()) -> kapps_call:call(). +-spec get_dequeue_result(kapps_call:call()) -> kz_term:api_binary(). set_dequeue_result(DCS, Call) -> kapps_call:kvs_store(<<"dequeue_result">>, DCS, Call). get_dequeue_result(Call) -> kapps_call:kvs_fetch(<<"dequeue_result">>, Call). --spec set_dequeued_call_sid(ne_binary(), kapps_call:call()) -> kapps_call:call(). --spec get_dequeued_call_sid(kapps_call:call()) -> api_binary(). +-spec set_dequeued_call_sid(kz_term:ne_binary(), kapps_call:call()) -> kapps_call:call(). +-spec get_dequeued_call_sid(kapps_call:call()) -> kz_term:api_binary(). set_dequeued_call_sid(DCS, Call) -> kapps_call:kvs_store(<<"dequeued_call_sid">>, DCS, Call). get_dequeued_call_sid(Call) -> kapps_call:kvs_fetch(<<"dequeued_call_sid">>, Call). -spec set_dequeued_call_queue_time(pos_integer(), kapps_call:call()) -> kapps_call:call(). --spec get_dequeued_call_queue_time(kapps_call:call()) -> api_integer(). +-spec get_dequeued_call_queue_time(kapps_call:call()) -> kz_term:api_integer(). set_dequeued_call_queue_time(DCS, Call) -> kapps_call:kvs_store(<<"dequeued_call_queue_time">>, DCS, Call). get_dequeued_call_queue_time(Call) -> kapps_call:kvs_fetch(<<"dequeued_call_queue_time">>, Call). -spec set_dequeued_call_duration(pos_integer(), kapps_call:call()) -> kapps_call:call(). --spec get_dequeued_call_duration(kapps_call:call()) -> api_integer(). +-spec get_dequeued_call_duration(kapps_call:call()) -> kz_term:api_integer(). set_dequeued_call_duration(DCS, Call) -> kapps_call:kvs_store(<<"dequeued_call_duration">>, DCS, Call). get_dequeued_call_duration(Call) -> kapps_call:kvs_fetch(<<"dequeued_call_duration">>, Call). -spec set_media_meta(kz_json:object(), kapps_call:call()) -> kapps_call:call(). --spec get_media_meta(kapps_call:call()) -> api_object(). +-spec get_media_meta(kapps_call:call()) -> kz_term:api_object(). set_media_meta(DCS, Call) -> kapps_call:kvs_store(<<"media_meta">>, DCS, Call). get_media_meta(Call) -> kapps_call:kvs_fetch(<<"media_meta">>, Call). -spec set_amqp_listener(pid(), kapps_call:call()) -> kapps_call:call(). --spec get_amqp_listener(kapps_call:call()) -> api_pid(). +-spec get_amqp_listener(kapps_call:call()) -> kz_term:api_pid(). set_amqp_listener(Pid, Call) -> kapps_call:kvs_store(<<"amqp_listener">>, Pid, Call). get_amqp_listener(Call) -> kapps_call:kvs_fetch(<<"amqp_listener">>, Call). --spec set_gather_pidref(pid_ref() | 'undefined', kapps_call:call()) -> +-spec set_gather_pidref(kz_term:pid_ref() | 'undefined', kapps_call:call()) -> kapps_call:call(). -spec get_gather_pidref(kapps_call:call()) -> - pid_ref() | 'undefined'. + kz_term:pid_ref() | 'undefined'. set_gather_pidref('undefined', Call) -> kapps_call:kvs_store(<<"gather_pidref">>, 'undefined', Call); set_gather_pidref({_, _}=PidRef, Call) -> diff --git a/core/kazoo_voicemail/src/kazoo_voicemail_maintenance.erl b/core/kazoo_voicemail/src/kazoo_voicemail_maintenance.erl index b8288bb90f5..d3ad1622fd8 100644 --- a/core/kazoo_voicemail/src/kazoo_voicemail_maintenance.erl +++ b/core/kazoo_voicemail/src/kazoo_voicemail_maintenance.erl @@ -40,8 +40,8 @@ migrate() -> io:format("~n********** migration process died with reason:~n~p~n", [_Reason]) end. --spec migrate(ne_binary()) -> 'ok'. --spec migrate(ne_binary(), ne_binary() | ne_binaries() | kz_json:object()) -> 'ok'. +-spec migrate(kz_term:ne_binary()) -> 'ok'. +-spec migrate(kz_term:ne_binary(), kz_term:ne_binary() | kz_term:ne_binaries() | kz_json:object()) -> 'ok'. migrate(?NE_BINARY = AccountId) -> kvm_migrate_account:manual_migrate(AccountId); migrate(AccountJObj) -> @@ -64,30 +64,30 @@ recover_messages_all() -> MODbs = kapps_util:get_all_account_mods(), recover_messages(MODbs, length(MODbs)). --spec recover_messages_month(ne_binary(), ne_binary()) -> 'ok'. +-spec recover_messages_month(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. recover_messages_month(Year, Month) -> MODbs = [MODb || MODb <- kapps_util:get_all_account_mods() ,modb_filter(MODb, Year, Month) ], recover_messages(MODbs, length(MODbs)). --spec recover_messages_account(ne_binary()) -> 'ok'. +-spec recover_messages_account(kz_term:ne_binary()) -> 'ok'. recover_messages_account(Account) -> MODbs = kapps_util:get_account_mods(Account), recover_messages(MODbs, length(MODbs)). --spec recover_messages_account(ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec recover_messages_account(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. recover_messages_account(Account, Year, Month) -> MODbs = [MODb || MODb <- kapps_util:get_account_mods(Account) ,modb_filter(MODb, Year, Month) ], recover_messages(MODbs, length(MODbs)). --spec modb_filter(ne_binary(), ne_binary(), ne_binary()) -> boolean(). +-spec modb_filter(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> boolean(). modb_filter(?MATCH_MODB_SUFFIX_ENCODED(_A, _B, _C, Year, Month), Year, Month) -> 'true'; modb_filter(_, _, _) -> 'false'. --spec recover_messages(ne_binaries(), non_neg_integer()) -> 'ok'. +-spec recover_messages(kz_term:ne_binaries(), non_neg_integer()) -> 'ok'. recover_messages([], _) -> 'ok'; recover_messages([MODb|MODbs], Total) -> ?SUP_LOG_DEBUG("(~p/~p) attempting to recover voicemail messages from ~s", [length(MODbs)+1, Total, MODb]), @@ -95,7 +95,7 @@ recover_messages([MODb|MODbs], Total) -> timer:sleep(50), recover_messages(MODbs, Total). --spec recover_missing_metadata(ne_binary()) -> 'ok'. +-spec recover_missing_metadata(kz_term:ne_binary()) -> 'ok'. recover_missing_metadata(MODb) -> ViewOptions = ['include_docs'], case kz_datamgr:get_results(MODb, ?VIEW_MISSING_METADATA, ViewOptions) of @@ -115,7 +115,7 @@ recover_missing_metadata(MODb) -> ?SUP_LOG_DEBUG(" unable to query missing_metadata view: ~p", [_R]) end. --spec recover_missing_metadata(ne_binary(), kz_json:objects()) -> 'ok'. +-spec recover_missing_metadata(kz_term:ne_binary(), kz_json:objects()) -> 'ok'. recover_missing_metadata(MODb, JObjs) -> Messages = [maybe_rebuild_message_metadata(JObj) || JObj <- JObjs], _ = kz_datamgr:save_docs(MODb, Messages), @@ -130,7 +130,7 @@ maybe_rebuild_message_metadata(JObj) -> JObj end. --spec rebuild_message_metadata(kz_json:object(), ne_binary()) -> kz_json:object(). +-spec rebuild_message_metadata(kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). rebuild_message_metadata(JObj, AttachmentName) -> MediaId = kz_json:get_value(<<"_id">>, JObj), ?SUP_LOG_DEBUG(" rebuilding metadata for ~s", [MediaId]), @@ -154,7 +154,7 @@ rebuild_message_metadata(JObj, AttachmentName) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec renotify(text(), text()) -> 'ok'. +-spec renotify(kz_term:text(), kz_term:text()) -> 'ok'. renotify(Account, MessageId) -> MODb = get_modb(Account, MessageId), AccountId = get_account_id(Account), @@ -172,7 +172,7 @@ renotify(Account, MessageId) -> ) end. --spec log_renotify_result(ne_binary(), ne_binary(), kz_amqp_worker:request_return()) -> 'ok'. +-spec log_renotify_result(kz_term:ne_binary(), kz_term:ne_binary(), kz_amqp_worker:request_return()) -> 'ok'. log_renotify_result(MessageId, BoxId, {'ok', JObj}) -> ?SUP_LOG_DEBUG("re-notify sent message ~s from mailbox ~s: ~s" ,[MessageId, BoxId, kz_json:encode(JObj)] @@ -190,7 +190,7 @@ log_renotify_result(MessageId, BoxId, Result) -> ,[MessageId, BoxId, Result] ). --spec get_modb(ne_binary(), ne_binary()) -> ne_binary(). +-spec get_modb(kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). get_modb(?MATCH_MODB_SUFFIX_ENCODED(_A, _B, _C, _Y, _M) = MODb, _) -> MODb; get_modb(?MATCH_MODB_SUFFIX_encoded(_A, _B, _C, _Y, _M) = MODb, _) -> MODb; get_modb(?MATCH_MODB_SUFFIX_RAW(_A, _B, _C, _Y, _M) = MODb, _) -> @@ -200,7 +200,7 @@ get_modb(?MATCH_MODB_SUFFIX_UNENCODED(_A, _B, _C, _Y, _M) = MODb, _) -> get_modb(Account, ?MATCH_MODB_PREFIX(Year, Month, _)) -> kz_util:format_account_mod_id(Account, Year, Month). --spec get_account_id(ne_binary()) -> ne_binary(). +-spec get_account_id(kz_term:ne_binary()) -> kz_term:ne_binary(). get_account_id(?MATCH_ACCOUNT_RAW(AccountId)) -> AccountId; get_account_id(?MATCH_ACCOUNT_UNENCODED(A, B, Rest)) -> ?MATCH_ACCOUNT_RAW(A, B, Rest); get_account_id(?MATCH_ACCOUNT_ENCODED(A, B, Rest)) -> ?MATCH_ACCOUNT_RAW(A, B, Rest); @@ -208,7 +208,7 @@ get_account_id(?MATCH_MODB_SUFFIX_RAW(AccountId, _, _)) -> AccountId; get_account_id(?MATCH_MODB_SUFFIX_ENCODED(A, B, Rest, _, _)) -> ?MATCH_ACCOUNT_RAW(A, B, Rest); get_account_id(?MATCH_MODB_SUFFIX_UNENCODED(A, B, Rest, _, _)) -> ?MATCH_ACCOUNT_RAW(A, B, Rest). --spec rebuild_kapps_call(kz_json:object(), ne_binary()) -> kapps_call:call(). +-spec rebuild_kapps_call(kz_json:object(), kz_term:ne_binary()) -> kapps_call:call(). rebuild_kapps_call(JObj, AccountId) -> Metadata = kzd_box_message:metadata(JObj), To = kz_json:get_value(<<"to">>, Metadata, <<"unknown@nodomain">>), diff --git a/core/kazoo_voicemail/src/kvm_message.erl b/core/kazoo_voicemail/src/kvm_message.erl index 76d0eb46cd8..876b972b459 100644 --- a/core/kazoo_voicemail/src/kvm_message.erl +++ b/core/kazoo_voicemail/src/kvm_message.erl @@ -41,7 +41,7 @@ %% ] %% @end %%-------------------------------------------------------------------- --spec new(kapps_call:call(), kz_proplist()) -> new_msg_ret(). +-spec new(kapps_call:call(), kz_term:proplist()) -> new_msg_ret(). new(Call, Props) -> BoxId = props:get_value(<<"Box-Id">>, Props), %% FIXME: dis guy is file size not audio duration @@ -76,7 +76,7 @@ new(Call, Props) -> end end. --spec forward_message(kapps_call:call(), kz_json:object(), ne_binary(), kz_proplist()) -> new_msg_ret(). +-spec forward_message(kapps_call:call(), kz_json:object(), kz_term:ne_binary(), kz_term:proplist()) -> new_msg_ret(). forward_message(Call, Metadata, SrcBoxId, Props) -> case props:get_value(<<"Attachment-Name">>, Props) of 'undefined' -> @@ -87,7 +87,7 @@ forward_message(Call, Metadata, SrcBoxId, Props) -> new_forward_message(Call, Metadata, SrcBoxId, Props) end. --spec new_forward_message(kapps_call:call(), kz_json:object(), ne_binary(), kz_proplist()) -> new_msg_ret(). +-spec new_forward_message(kapps_call:call(), kz_json:object(), kz_term:ne_binary(), kz_term:proplist()) -> new_msg_ret(). new_forward_message(Call, Metadata, SrcBoxId, Props) -> DestBoxId = props:get_value(<<"Box-Id">>, Props), Length = props:get_value(<<"Length">>, Props), @@ -126,17 +126,17 @@ new_forward_message(Call, Metadata, SrcBoxId, Props) -> %% @doc fetch message doc %% @end %%-------------------------------------------------------------------- --spec fetch(ne_binary(), ne_binary()) -> db_ret(). +-spec fetch(kz_term:ne_binary(), kz_term:ne_binary()) -> db_ret(). fetch(AccountId, MessageId) -> fetch(AccountId, MessageId, 'undefined'). --spec fetch(ne_binary(), ne_binary(), api_ne_binary()) -> db_ret(). +-spec fetch(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_ne_binary()) -> db_ret(). fetch(AccountId, MessageId, BoxId) -> RetenTimestamp = kz_time:now_s() - kvm_util:retention_seconds(AccountId), {_, DbRet} = do_fetch(AccountId, MessageId, BoxId, RetenTimestamp), DbRet. --spec do_fetch(ne_binary(), ne_binary(), api_ne_binary(), gregorian_seconds()) -> {boolean(), db_ret()}. +-spec do_fetch(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_ne_binary(), kz_time:gregorian_seconds()) -> {boolean(), db_ret()}. do_fetch(AccountId, MessageId, BoxId, RetenTimestamp) -> case kvm_util:open_modb_doc(AccountId, MessageId, kzd_box_message:type()) of {'ok', JObj} -> @@ -158,8 +158,8 @@ do_fetch(AccountId, MessageId, BoxId, RetenTimestamp) -> %% @doc fetch message metadata %% @end %%-------------------------------------------------------------------- --spec message(ne_binary(), ne_binary()) -> db_ret(). --spec message(ne_binary(), ne_binary(), api_ne_binary()) -> db_ret(). +-spec message(kz_term:ne_binary(), kz_term:ne_binary()) -> db_ret(). +-spec message(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:api_ne_binary()) -> db_ret(). message(AccountId, MessageId) -> message(AccountId, MessageId, 'undefined'). @@ -178,7 +178,7 @@ message(AccountId, MessageId, BoxId) -> %% Note: for use only by cf_voicemail %% @end %%-------------------------------------------------------------------- --spec set_folder(ne_binary(), kz_json:object(), ne_binary()) -> db_ret(). +-spec set_folder(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> db_ret(). set_folder(Folder, Message, AccountId) -> MessageId = kzd_box_message:media_id(Message), FromFolder = kzd_box_message:folder(Message, ?VM_FOLDER_NEW), @@ -188,7 +188,7 @@ set_folder(Folder, Message, AccountId) -> {'error', _} -> {'error', Message} end. --spec maybe_set_folder(ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_json:object()) -> db_ret(). +-spec maybe_set_folder(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object()) -> db_ret(). maybe_set_folder(_, ?VM_FOLDER_DELETED = ToFolder, MessageId, AccountId, _Msg) -> %% ensuring that message is really deleted change_folder(ToFolder, MessageId, AccountId, 'undefined'); @@ -205,11 +205,11 @@ maybe_set_folder(_FromFolder, ToFolder, MessageId, AccountId, _Msg) -> %% folder(for recovering later by user) %% @end %%-------------------------------------------------------------------- --spec change_folder(vm_folder(), message(), ne_binary(), api_binary()) -> db_ret(). +-spec change_folder(vm_folder(), message(), kz_term:ne_binary(), kz_term:api_binary()) -> db_ret(). change_folder(Folder, Message, AccountId, BoxId) -> change_folder(Folder, Message, AccountId, BoxId, []). --spec change_folder(vm_folder(), message(), ne_binary(), api_binary(), update_funs()) -> db_ret(). +-spec change_folder(vm_folder(), message(), kz_term:ne_binary(), kz_term:api_binary(), update_funs()) -> db_ret(). change_folder(Folder, Message, AccountId, BoxId, Funs0) -> Funs = [fun(J) -> kzd_box_message:apply_folder(Folder, J) end | Funs0 @@ -227,8 +227,8 @@ change_folder(Folder, Message, AccountId, BoxId, Funs0) -> %% @doc Update a single message doc %% @end %%-------------------------------------------------------------------- --spec update(ne_binary(), api_ne_binary(), message()) -> db_ret(). --spec update(ne_binary(), api_ne_binary(), message(), update_funs()) -> db_ret(). +-spec update(kz_term:ne_binary(), kz_term:api_ne_binary(), message()) -> db_ret(). +-spec update(kz_term:ne_binary(), kz_term:api_ne_binary(), message(), update_funs()) -> db_ret(). update(AccountId, BoxId, Message) -> update(AccountId, BoxId, Message, []). @@ -268,11 +268,11 @@ do_update(JObj, Funs) -> %% @doc Move a message to another vmbox %% @end %%-------------------------------------------------------------------- --spec move_to_vmbox(ne_binary(), message(), ne_binary(), ne_binary()) -> db_ret(). +-spec move_to_vmbox(kz_term:ne_binary(), message(), kz_term:ne_binary(), kz_term:ne_binary()) -> db_ret(). move_to_vmbox(AccountId, Things, OldBoxId, NewBoxId) -> move_to_vmbox(AccountId, Things, OldBoxId, NewBoxId, []). --spec move_to_vmbox(ne_binary(), message(), ne_binary(), ne_binary(), update_funs()) -> db_ret(). +-spec move_to_vmbox(kz_term:ne_binary(), message(), kz_term:ne_binary(), kz_term:ne_binary(), update_funs()) -> db_ret(). move_to_vmbox(AccountId, ?NE_BINARY = FromId, OldBoxId, NewBoxId, Funs) -> AccountDb = kvm_util:get_db(AccountId), case kz_datamgr:open_cache_doc(AccountDb, NewBoxId) of @@ -286,7 +286,7 @@ move_to_vmbox(AccountId, ?NE_BINARY = FromId, OldBoxId, NewBoxId, Funs) -> move_to_vmbox(AccountId, JObj, OldBoxId, NewBoxId, Funs) -> move_to_vmbox(AccountId, kzd_box_message:get_msg_id(JObj), OldBoxId, NewBoxId, Funs). --spec maybe_do_move(ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_json:object(), update_funs(), gregorian_seconds()) -> db_ret(). +-spec maybe_do_move(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), update_funs(), kz_time:gregorian_seconds()) -> db_ret(). maybe_do_move(AccountId, FromId, OldBoxId, NewBoxId, NBoxJ, Funs, RetenTimestamp) -> case do_fetch(AccountId, FromId, OldBoxId, RetenTimestamp) of {'true', {'ok', JObj}} -> @@ -298,7 +298,7 @@ maybe_do_move(AccountId, FromId, OldBoxId, NewBoxId, NBoxJ, Funs, RetenTimestamp Error end. --spec do_move(ne_binary(), ne_binary(), ne_binary(), ne_binary(), kz_json:object(), update_funs()) -> db_ret(). +-spec do_move(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), update_funs()) -> db_ret(). do_move(AccountId, FromId, OldBoxId, NewBoxId, NBoxJ, Funs) -> {ToId, TransformFuns} = kvm_util:get_change_vmbox_funs(AccountId, NewBoxId, NBoxJ, OldBoxId), @@ -333,11 +333,11 @@ do_move(AccountId, FromId, OldBoxId, NewBoxId, NBoxJ, Funs) -> %% @doc copy a message to other vmbox(es) %% @end %%-------------------------------------------------------------------- --spec copy_to_vmboxes(ne_binary(), ne_binary()|kz_json:object(), ne_binary(), ne_binary()|ne_binaries()) -> kz_json:object(). +-spec copy_to_vmboxes(kz_term:ne_binary(), kz_term:ne_binary() | kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary() | kz_term:ne_binaries()) -> kz_json:object(). copy_to_vmboxes(AccountId, MsgThing, OldBoxId, NewBoxIds) -> copy_to_vmboxes(AccountId, MsgThing, OldBoxId, NewBoxIds, []). --spec copy_to_vmboxes(ne_binary(), ne_binary()|kz_json:object(), ne_binary(), ne_binary()|ne_binaries(), update_funs()) -> kz_json:object(). +-spec copy_to_vmboxes(kz_term:ne_binary(), kz_term:ne_binary() | kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary() | kz_term:ne_binaries(), update_funs()) -> kz_json:object(). copy_to_vmboxes(AccountId, Id, OldBoxId, ?NE_BINARY = NewBoxId, Funs) -> copy_to_vmboxes(AccountId, Id, OldBoxId, [NewBoxId], Funs); copy_to_vmboxes(AccountId, ?NE_BINARY = Id, OldBoxId, NewBoxIds, Funs) -> @@ -351,7 +351,7 @@ copy_to_vmboxes(AccountId, ?NE_BINARY = Id, OldBoxId, NewBoxIds, Funs) -> copy_to_vmboxes(AccountId, JObj, OldBoxId, NewBoxIds, Funs) -> copy_to_vmboxes(AccountId, kzd_box_message:get_msg_id(JObj), OldBoxId, NewBoxIds, Funs). --spec maybe_copy_to_vmboxes(ne_binary(), ne_binary(), ne_binary(), ne_binaries(), bulk_map(), update_funs(), gregorian_seconds()) -> bulk_map(). +-spec maybe_copy_to_vmboxes(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binaries(), bulk_map(), update_funs(), kz_time:gregorian_seconds()) -> bulk_map(). maybe_copy_to_vmboxes(AccountId, FromId, OldBoxId, NewBoxIds, CopyMap, Funs, RetenTimestamp) -> case do_fetch(AccountId, FromId, OldBoxId, RetenTimestamp) of {'true', {'ok', JObj}} -> @@ -365,14 +365,14 @@ maybe_copy_to_vmboxes(AccountId, FromId, OldBoxId, NewBoxIds, CopyMap, Funs, Ret maps:update_with(failed, fun(List) -> [IdReason|List] end, [IdReason], CopyMap) end. --spec copy_to_vmboxes(ne_binary(), ne_binary(), ne_binary(), ne_binaries(), bulk_map(), update_funs()) -> bulk_map(). +-spec copy_to_vmboxes(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binaries(), bulk_map(), update_funs()) -> bulk_map(). copy_to_vmboxes(_, _, _, [], CopyMap, _) -> CopyMap; copy_to_vmboxes(AccountId, FromId, OldBoxId, [NBId | NBIds], CopyMap, Funs) -> NewCopyMap = copy_to_vmbox(AccountId, FromId, OldBoxId, NBId, CopyMap, Funs), copy_to_vmboxes(AccountId, FromId, OldBoxId, NBIds, NewCopyMap, Funs). --spec copy_to_vmbox(ne_binary(), ne_binary(), ne_binary(), ne_binary(), bulk_map(), update_funs()) -> bulk_map(). +-spec copy_to_vmbox(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), bulk_map(), update_funs()) -> bulk_map(). copy_to_vmbox(AccountId, ?NE_BINARY = FromId, OldBoxId, ?NE_BINARY = NBId, CopyMap, Funs) -> AccountDb = kvm_util:get_db(AccountId), copy_to_vmbox(AccountId, FromId, OldBoxId, NBId, CopyMap @@ -380,7 +380,7 @@ copy_to_vmbox(AccountId, ?NE_BINARY = FromId, OldBoxId, ?NE_BINARY = NBId, CopyM ,Funs ). --spec copy_to_vmbox(ne_binary(), ne_binary(), ne_binary(), ne_binary(), bulk_map(), kz_datamgr:data_error() | {'ok', kz_json:object()}, update_funs()) -> +-spec copy_to_vmbox(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), bulk_map(), kz_datamgr:data_error() | {'ok', kz_json:object()}, update_funs()) -> bulk_map(). copy_to_vmbox(_AccountId, FromId, _OldBoxId, NBId, CopyMap ,{'error', Reason} @@ -404,7 +404,7 @@ copy_to_vmbox(AccountId, FromId, OldBoxId, NBId, CopyMap maps:update_with(failed, fun(List) -> [IdReason|List] end, [IdReason], CopyMap) end. --spec do_copy(ne_binary(), ne_binary(), ne_binary(), update_funs()) -> db_ret(). +-spec do_copy(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), update_funs()) -> db_ret(). do_copy(AccountId, ?NE_BINARY = FromId, ToId, Funs) -> FromDb = kvm_util:get_db(AccountId, FromId), ToDb = kvm_util:get_db(AccountId, ToId), @@ -432,7 +432,7 @@ do_copy(AccountId, ?NE_BINARY = FromId, ToId, Funs) -> Error end. --spec move_copy_final_check(ne_binary(), ne_binary(), ne_binary()) -> db_ret(). +-spec move_copy_final_check(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> db_ret(). move_copy_final_check(AccountId, FromId, ToId) -> FromDb = kvm_util:get_db(AccountId, FromId), ToDb = kvm_util:get_db(AccountId, ToId), @@ -450,7 +450,7 @@ move_copy_final_check(AccountId, FromId, ToId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec media_url(ne_binary(), message()) -> binary(). +-spec media_url(kz_term:ne_binary(), message()) -> binary(). media_url(AccountId, ?NE_BINARY = MessageId) -> case fetch(AccountId, MessageId) of {'ok', Message} -> @@ -472,10 +472,10 @@ media_url(AccountId, Message) -> %% @doc %% @end %%-------------------------------------------------------------------- --type sotre_media_url() :: fun(() -> ne_binary() | {'error', any()}). +-type sotre_media_url() :: fun(() -> kz_term:ne_binary() | {'error', any()}). --spec create_new_message_doc(kapps_call:call(), kz_proplist()) -> - {ne_binary(), sotre_media_url()} | +-spec create_new_message_doc(kapps_call:call(), kz_term:proplist()) -> + {kz_term:ne_binary(), sotre_media_url()} | {'error', any()}. create_new_message_doc(Call, Props) -> AccountId = kapps_call:account_id(Call), @@ -502,8 +502,8 @@ create_new_message_doc(Call, Props) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec create_forward_message_doc(kapps_call:call(), kz_json:object(), ne_binary(), kz_proplist()) -> - {ne_binary(), sotre_media_url()} | +-spec create_forward_message_doc(kapps_call:call(), kz_json:object(), kz_term:ne_binary(), kz_term:proplist()) -> + {kz_term:ne_binary(), sotre_media_url()} | {'error', any()}. create_forward_message_doc(Call, Metadata, SrcBoxId, Props) -> AccountId = kapps_call:account_id(Call), @@ -555,7 +555,7 @@ try_save_document(Call, MsgJObj, Loop) -> %% create a fake Destination Box JObj to pass to change vmbox functions %% Note: set pvt_account_id and db just to make sure for case when timezone is not passed %% so kzd_voicemail_box can find timezone from vmbox the owner or account --spec fake_vmbox_jobj(kapps_call:call(), kz_proplist()) -> kz_json:object(). +-spec fake_vmbox_jobj(kapps_call:call(), kz_term:proplist()) -> kz_json:object(). fake_vmbox_jobj(Call, Props) -> kz_json:from_list( [{<<"_id">>, props:get_value(<<"Box-Id">>, Props)} @@ -572,7 +572,7 @@ fake_vmbox_jobj(Call, Props) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec store_recording(ne_binary(), ne_binary() | sotre_media_url(), kapps_call:call(), ne_binary()) -> +-spec store_recording(kz_term:ne_binary(), kz_term:ne_binary() | sotre_media_url(), kapps_call:call(), kz_term:ne_binary()) -> 'ok' | {'error', kapps_call:call()}. store_recording(AttachmentName, Url, Call, MessageId) -> @@ -583,7 +583,7 @@ store_recording(AttachmentName, Url, Call, MessageId) -> check_attachment_exists(Call, MessageId) end. --spec check_attachment_exists(kapps_call:call(), ne_binary()) -> 'ok' | {'error', kapps_call:call()}. +-spec check_attachment_exists(kapps_call:call(), kz_term:ne_binary()) -> 'ok' | {'error', kapps_call:call()}. check_attachment_exists(Call, MessageId) -> case fetch(kapps_call:account_id(Call), MessageId) of {'ok', JObj} -> @@ -603,11 +603,11 @@ check_attachment_exists(Call, MessageId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec forward_to_vmbox(kapps_call:call(), kz_json:object(), ne_binary(), kz_proplist()) -> new_msg_ret(). +-spec forward_to_vmbox(kapps_call:call(), kz_json:object(), kz_term:ne_binary(), kz_term:proplist()) -> new_msg_ret(). forward_to_vmbox(Call, Metadata, SrcBoxId, Props) -> forward_to_vmbox(Call, Metadata, SrcBoxId, Props, []). --spec forward_to_vmbox(kapps_call:call(), kz_json:object(), ne_binary(), kz_proplist(), update_funs()) -> new_msg_ret(). +-spec forward_to_vmbox(kapps_call:call(), kz_json:object(), kz_term:ne_binary(), kz_term:proplist(), update_funs()) -> new_msg_ret(). forward_to_vmbox(Call, Metadata, SrcBoxId, Props, Funs) -> AccountId = kapps_call:account_id(Call), MediaId = kzd_box_message:media_id(Metadata), @@ -632,7 +632,7 @@ forward_to_vmbox(Call, Metadata, SrcBoxId, Props, Funs) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec prepend_and_notify(kapps_call:call(), ne_binary(), kz_json:object(), ne_binary(), kz_proplist()) -> new_msg_ret(). +-spec prepend_and_notify(kapps_call:call(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary(), kz_term:proplist()) -> new_msg_ret(). prepend_and_notify(Call, ForwardId, Metadata, SrcBoxId, Props) -> Length = props:get_value(<<"Length">>, Props), try prepend_forward_message(Call, ForwardId, Metadata, SrcBoxId, Props) of @@ -658,7 +658,7 @@ prepend_and_notify(Call, ForwardId, Metadata, SrcBoxId, Props) -> forward_to_vmbox(Call, Metadata, SrcBoxId, Props, UpdateFuns) end. --spec prepend_forward_message(kapps_call:call(), ne_binary(), kz_json:object(), ne_binary(), kz_proplist()) -> db_ret(). +-spec prepend_forward_message(kapps_call:call(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary(), kz_term:proplist()) -> db_ret(). prepend_forward_message(Call, ForwardId, Metadata, _SrcBoxId, Props) -> lager:debug("trying to prepend a message to forwarded voicemail message ~s", [ForwardId]), AccountId = kapps_call:account_id(Call), @@ -690,7 +690,7 @@ prepend_forward_message(Call, ForwardId, Metadata, _SrcBoxId, Props) -> end. --spec try_put_fwd_attachment(ne_binary(), ne_binary(), ne_binary(), iodata(), 1..3) -> db_ret(). +-spec try_put_fwd_attachment(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary(), iodata(), 1..3) -> db_ret(). try_put_fwd_attachment(AccountId, ForwardId, _JoinFilename, _FileContents, 0) -> lager:error("max retries to save prepend forward voicemail attachment ~s in db ~s" ,[ForwardId, kvm_util:get_db(AccountId, ForwardId)] @@ -709,7 +709,7 @@ try_put_fwd_attachment(AccountId, ForwardId, JoinFilename, FileContents, Loop) - Error end. --spec write_attachment_to_file(ne_binary(), ne_binary()) -> {'ok', ne_binary()} | {'error', any()}. +-spec write_attachment_to_file(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_term:ne_binary()} | {'error', any()}. write_attachment_to_file(AccountId, MessageId) -> case fetch(AccountId, MessageId) of {'ok', Doc} -> @@ -717,7 +717,7 @@ write_attachment_to_file(AccountId, MessageId) -> {'error', _}=Error -> Error end. --spec write_attachment_to_file(ne_binary(), ne_binary(), ne_binaries()) -> {'ok', ne_binary()} | {'error', any()}. +-spec write_attachment_to_file(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binaries()) -> {'ok', kz_term:ne_binary()} | {'error', any()}. write_attachment_to_file(AccountId, MessageId, [AttachmentId]) -> Db = kvm_util:get_db(AccountId, MessageId), {'ok', AttachmentBin} = kz_datamgr:fetch_attachment(Db, MessageId, AttachmentId), @@ -726,7 +726,7 @@ write_attachment_to_file(AccountId, MessageId, [AttachmentId]) -> lager:debug("saved attachment ~s from ~s in ~s", [AttachmentId, MessageId, FilePath]), {'ok', FilePath}. --spec remove_malform_vm(kapps_call:call(), ne_binary()) -> 'ok'. +-spec remove_malform_vm(kapps_call:call(), kz_term:ne_binary()) -> 'ok'. remove_malform_vm(Call, ForwardId) -> AccountDb = kz_util:format_account_db(kapps_call:account_id(Call)), _ = kz_datamgr:del_doc(AccountDb, ForwardId), @@ -739,7 +739,7 @@ remove_malform_vm(Call, ForwardId) -> %%-------------------------------------------------------------------- -type notify_action() :: 'save' | 'delete' | 'nothing'. --spec notify_and_update_meta(kapps_call:call(), ne_binary(), integer(), kz_proplist()) -> {'ok', kapps_call:call()}. +-spec notify_and_update_meta(kapps_call:call(), kz_term:ne_binary(), integer(), kz_term:proplist()) -> {'ok', kapps_call:call()}. notify_and_update_meta(Call, MediaId, Length, Props) -> BoxId = props:get_value(<<"Box-Id">>, Props), NotifyAction = props:get_atom_value(<<"After-Notify-Action">>, Props), @@ -760,7 +760,7 @@ notify_and_update_meta(Call, MediaId, Length, Props) -> maybe_update_meta(Length, 'nothing', Call, MediaId, BoxId) end. --spec log_notification_response(notify_action(), ne_binary(), kz_json:object(), kapps_call:call()) -> 'ok'. +-spec log_notification_response(notify_action(), kz_term:ne_binary(), kz_json:object(), kapps_call:call()) -> 'ok'. log_notification_response('nothing', _MediaId, _UpdateJObj, Call) -> AccountId = kapps_call:account_id(Call), lager:debug("successfully sent new voicemail notification for message ~s in account ~s: ~s" @@ -782,7 +782,7 @@ log_notification_response(_Action, MediaId, UpdateJObj, Call) -> ,[MediaId, AccountId]) end. --spec maybe_update_meta(pos_integer(), notify_action(), kapps_call:call(), ne_binary(), ne_binary()) -> {'ok', kapps_call:call()}. +-spec maybe_update_meta(pos_integer(), notify_action(), kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kapps_call:call()}. maybe_update_meta(Length, Action, Call, MediaId, BoxId) -> case Action of 'delete' -> @@ -805,7 +805,7 @@ maybe_update_meta(Length, Action, Call, MediaId, BoxId) -> {'ok', Call} end. --spec update_metadata(kapps_call:call(), ne_binary(), ne_binary(), update_funs()) -> {'ok', kapps_call:call()}. +-spec update_metadata(kapps_call:call(), kz_term:ne_binary(), kz_term:ne_binary(), update_funs()) -> {'ok', kapps_call:call()}. update_metadata(Call, BoxId, MessageId, UpdateFuns) -> AccountId = kapps_call:account_id(Call), case update(AccountId, BoxId, MessageId, UpdateFuns) of @@ -856,11 +856,11 @@ check_for_collision(Call, JObj, SavedJObj, DieAnotherDay) -> DieAnotherDay(kz_doc:set_id(NewJObj, NewId)) end. --spec give_me_another_id(ne_binary()) -> ne_binary(). +-spec give_me_another_id(kz_term:ne_binary()) -> kz_term:ne_binary(). give_me_another_id(?MATCH_MODB_PREFIX(Year, Month, _)) -> kazoo_modb_util:modb_id(Year, Month). --spec send_system_alert(kapps_call:call() | 'undefined', ne_binary(), ne_binary(), ne_binary()) -> 'ok'. +-spec send_system_alert(kapps_call:call() | 'undefined', kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. send_system_alert('undefined', AccountId, Subject, Msg) -> Notify = [{<<"Message">>, Msg} ,{<<"Subject">>, <<"System Alert: ", Subject/binary>>} diff --git a/core/kazoo_voicemail/src/kvm_messages.erl b/core/kazoo_voicemail/src/kvm_messages.erl index 0a843826434..a20f4df8c6a 100644 --- a/core/kazoo_voicemail/src/kvm_messages.erl +++ b/core/kazoo_voicemail/src/kvm_messages.erl @@ -37,12 +37,12 @@ %% keys are: <<"new">>, <<"saved">>, <<"deleted">>, <<"non_deleted">>, <<"total">> --type per_folder_count() :: #{ne_binary() => non_neg_integer()}. +-type per_folder_count() :: #{kz_term:ne_binary() => non_neg_integer()}. --type count_map() :: #{ne_binary() => per_folder_count()}. +-type count_map() :: #{kz_term:ne_binary() => per_folder_count()}. -type non_deleted_tuple() :: {non_neg_integer(), non_neg_integer()}. --type get_map() :: #{ne_binary() => kz_json:objects()}. +-type get_map() :: #{kz_term:ne_binary() => kz_json:objects()}. %%-------------------------------------------------------------------- %% @public @@ -54,7 +54,7 @@ %% as key's value %% @end %%-------------------------------------------------------------------- --spec get(ne_binary()) -> get_map(). +-spec get(kz_term:ne_binary()) -> get_map(). get(AccountId) -> ViewOpts = [{'startkey', []} ,{'endkey', []} @@ -68,7 +68,7 @@ get(AccountId) -> %% are in retention duration range and in whatever folder they're in. %% @end %%-------------------------------------------------------------------- --spec get(ne_binary(), message() | kz_proplist()) -> kz_json:objects(). +-spec get(kz_term:ne_binary(), message() | kz_term:proplist()) -> kz_json:objects(). get(AccountId, ?NE_BINARY=BoxId) -> ViewOpts = [{'startkey', [BoxId]} ,{'endkey', [BoxId]} @@ -97,7 +97,7 @@ get(AccountId, Box) -> %% #{<<"new">> => 7,<<"non_deleted">> => 7,<<"total">> => 7}} %% @end %%-------------------------------------------------------------------- --spec count(ne_binary()) -> count_map(). +-spec count(kz_term:ne_binary()) -> count_map(). count(AccountId) -> count_per_folder(AccountId). @@ -108,7 +108,7 @@ count(AccountId) -> %% are in retention duration and are in 'new' or 'saved' folder only. %% @end %%-------------------------------------------------------------------- --spec count(ne_binary(), ne_binary()) -> non_neg_integer(). +-spec count(kz_term:ne_binary(), kz_term:ne_binary()) -> non_neg_integer(). count(AccountId, BoxId) -> {New, Saved} = count_non_deleted(AccountId, BoxId), New + Saved. @@ -122,7 +122,7 @@ count(AccountId, BoxId) -> %% Note: returns counts in {new, saved} format (both values are integer) %% @end %%-------------------------------------------------------------------- --spec count_non_deleted(ne_binary(), ne_binary()) -> non_deleted_tuple(). +-spec count_non_deleted(kz_term:ne_binary(), kz_term:ne_binary()) -> non_deleted_tuple(). count_non_deleted(AccountId, BoxId) -> CountMap = count_per_folder(AccountId, [BoxId], ?MSG_COUNT_PER_BOX_FOLDER, ?COUNT_NON_DELETED), VMBoxCount = maps:get(BoxId, CountMap, maps:new()), @@ -139,7 +139,7 @@ count_non_deleted(AccountId, BoxId) -> %% returns same format as count_non_deleted/2 %% @end %%-------------------------------------------------------------------- --spec count_by_owner(ne_binary(), ne_binary()) -> non_deleted_tuple(). +-spec count_by_owner(kz_term:ne_binary(), kz_term:ne_binary()) -> non_deleted_tuple(). count_by_owner(?MATCH_ACCOUNT_ENCODED(_)=AccountDb, OwnerId) -> AccountId = kz_util:format_account_id(AccountDb), count_by_owner(AccountId, OwnerId); @@ -158,7 +158,7 @@ count_by_owner(AccountId, OwnerId) -> {0, 0} end. --spec sum_owner_mailboxes(ne_binary(), ne_binaries(), non_deleted_tuple()) -> non_deleted_tuple(). +-spec sum_owner_mailboxes(kz_term:ne_binary(), kz_term:ne_binaries(), non_deleted_tuple()) -> non_deleted_tuple(). sum_owner_mailboxes(_, [], Results) -> Results; sum_owner_mailboxes(AccountId, [BoxId|BoxIds], {New, Saved}) -> {BoxNew, BoxSaved} = count_non_deleted(AccountId, BoxId), @@ -183,7 +183,7 @@ sum_owner_mailboxes(AccountId, [BoxId|BoxIds], {New, Saved}) -> %% #{<<"new">> => 7,<<"non_deleted">> => 7,<<"total">> => 7}} %% @end %%-------------------------------------------------------------------- --spec count_per_folder(ne_binary()) -> count_map(). +-spec count_per_folder(kz_term:ne_binary()) -> count_map(). count_per_folder(AccountId) -> count_per_folder(AccountId, [], ?MSG_COUNT_PER_FOLDER, ?COUNT_ALL). @@ -193,7 +193,7 @@ count_per_folder(AccountId) -> %% Same as count_per_folder/1 but only for a specific box %% @end %%-------------------------------------------------------------------- --spec count_per_folder(ne_binary(), ne_binary()) -> count_map(). +-spec count_per_folder(kz_term:ne_binary(), kz_term:ne_binary()) -> count_map(). count_per_folder(AccountId, BoxId) -> count_per_folder(AccountId, [BoxId], ?MSG_COUNT_PER_BOX_FOLDER, ?COUNT_ALL). @@ -204,7 +204,7 @@ count_per_folder(AccountId, BoxId) -> %% previous result. %% @end %%-------------------------------------------------------------------- --spec count_per_folder(ne_binary(), ne_binaries(), ne_binary(), ne_binaries()) -> count_map(). +-spec count_per_folder(kz_term:ne_binary(), kz_term:ne_binaries(), kz_term:ne_binary(), kz_term:ne_binaries()) -> count_map(). count_per_folder(AccountId, Keys, View, Folders) -> lists:foldl(fun(Folder, ResultMap) -> count_per_folder(AccountId, Keys, View, Folder, ResultMap) @@ -213,7 +213,7 @@ count_per_folder(AccountId, Keys, View, Folders) -> ,Folders ). --spec count_per_folder(ne_binary(), ne_binaries(), ne_binary(), ne_binary(), count_map()) -> count_map(). +-spec count_per_folder(kz_term:ne_binary(), kz_term:ne_binaries(), kz_term:ne_binary(), kz_term:ne_binary(), count_map()) -> count_map(). count_per_folder(AccountId, Keys, View, Folder, ResultMap) -> ViewOpts = [{'startkey', Keys ++ [Folder]} ,{'endkey', Keys ++ [Folder]} @@ -228,8 +228,8 @@ count_per_folder(AccountId, Keys, View, Folder, ResultMap) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec update(ne_binary(), ne_binary(), messages()) -> kz_json:object(). --spec update(ne_binary(), ne_binary(), messages(), update_funs()) -> kz_json:object(). +-spec update(kz_term:ne_binary(), kz_term:ne_binary(), messages()) -> kz_json:object(). +-spec update(kz_term:ne_binary(), kz_term:ne_binary(), messages(), update_funs()) -> kz_json:object(). update(AccountId, BoxId, Msgs) -> update(AccountId, BoxId, Msgs, []). @@ -241,7 +241,7 @@ update(AccountId, _BoxId, JObjs, Funs) -> RetenTimestamp = kz_time:now_s() - kvm_util:retention_seconds(AccountId), do_update(AccountId, #{succeeded => JObjs}, Funs, RetenTimestamp). --spec do_update(ne_binary(), bulk_map(), update_funs(), gregorian_seconds()) -> kz_json:object(). +-spec do_update(kz_term:ne_binary(), bulk_map(), update_funs(), kz_time:gregorian_seconds()) -> kz_json:object(). do_update(AccountId, FetchMap, Funs, RetenTimestamp) -> #{to_update_map := ToUpdateMap ,failed := Failed @@ -266,7 +266,7 @@ bulk_result(Map) -> ]) ). --spec update_fun(ne_binary(), kz_json:objects(), bulk_map()) -> bulk_map(). +-spec update_fun(kz_term:ne_binary(), kz_json:objects(), bulk_map()) -> bulk_map(). update_fun(Db, JObjs, #{failed := Failed}=ResultMap) -> case kz_datamgr:save_docs(Db, JObjs) of {'ok', Saved} -> @@ -282,16 +282,16 @@ update_fun(Db, JObjs, #{failed := Failed}=ResultMap) -> %% @doc fetch message docs for a voicemail box %% @end %%-------------------------------------------------------------------- --spec fetch(ne_binary(), ne_binaries()) -> kz_json:object(). +-spec fetch(kz_term:ne_binary(), kz_term:ne_binaries()) -> kz_json:object(). fetch(AccountId, MsgIds) -> fetch(AccountId, MsgIds, 'undefined'). --spec fetch(ne_binary(), ne_binaries(), api_ne_binary()) -> kz_json:object(). +-spec fetch(kz_term:ne_binary(), kz_term:ne_binaries(), kz_term:api_ne_binary()) -> kz_json:object(). fetch(AccountId, MsgIds, BoxId) -> RetenTimestamp = kz_time:now_s() - kvm_util:retention_seconds(AccountId), bulk_result(fetch(AccountId, MsgIds, BoxId, RetenTimestamp)). --spec fetch(ne_binary(), ne_binaries(), api_ne_binary(), gregorian_seconds()) -> bulk_map(). +-spec fetch(kz_term:ne_binary(), kz_term:ne_binaries(), kz_term:api_ne_binary(), kz_time:gregorian_seconds()) -> bulk_map(). fetch(AccountId, MsgIds, BoxId, RetenTimestamp) -> DbsRange = kvm_util:split_to_modbs(AccountId, MsgIds), Fun = fun(Db, Ids, ResultMap) -> @@ -299,7 +299,7 @@ fetch(AccountId, MsgIds, BoxId, RetenTimestamp) -> end, maps:fold(Fun, #{succeeded => [], failed => []}, DbsRange). --spec fetch_fun(ne_binary(), ne_binary(), ne_binaries(), bulk_map(), gregorian_seconds()) -> bulk_map(). +-spec fetch_fun(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binaries(), bulk_map(), kz_time:gregorian_seconds()) -> bulk_map(). fetch_fun(Db, BoxId, Ids, ResultMap, RetenTimestamp) -> case kz_datamgr:db_exists(Db) andalso kz_datamgr:open_docs(Db, Ids) @@ -312,7 +312,7 @@ fetch_fun(Db, BoxId, Ids, ResultMap, RetenTimestamp) -> fetch_faild_with_reason(R, Db, Ids, ResultMap) end. --spec fetch_faild_with_reason(any(), ne_binary(), ne_binaries(), bulk_map()) -> bulk_map(). +-spec fetch_faild_with_reason(any(), kz_term:ne_binary(), kz_term:ne_binaries(), bulk_map()) -> bulk_map(). fetch_faild_with_reason(Reason, Db, Ids, #{failed := Failed}=ResultMap) -> lager:warning("failed to bulk fetch voicemail messages from db ~s: ~p", [Db, Reason]), IdReasons = [{Id, kz_term:to_binary(Reason)} || Id <- Ids], @@ -323,12 +323,12 @@ fetch_faild_with_reason(Reason, Db, Ids, #{failed := Failed}=ResultMap) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec change_folder(kvm_message:vm_folder(), messages(), ne_binary(), ne_binary()) -> +-spec change_folder(kvm_message:vm_folder(), messages(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). change_folder(Folder, Msgs, AccountId, BoxId) -> change_folder(Folder, Msgs, AccountId, BoxId, []). --spec change_folder(kvm_message:vm_folder(), messages(), ne_binary(), ne_binary(), update_funs()) -> +-spec change_folder(kvm_message:vm_folder(), messages(), kz_term:ne_binary(), kz_term:ne_binary(), update_funs()) -> kz_json:object(). change_folder(Folder, Msgs, AccountId, BoxId, Funs) -> Fun = [fun(JObj) -> kzd_box_message:apply_folder(Folder, JObj) end @@ -341,12 +341,12 @@ change_folder(Folder, Msgs, AccountId, BoxId, Funs) -> %% @doc Move messages to another vmbox %% @end %%-------------------------------------------------------------------- --spec move_to_vmbox(ne_binary(), messages(), ne_binary(), ne_binary()) -> +-spec move_to_vmbox(kz_term:ne_binary(), messages(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_json:object(). move_to_vmbox(AccountId, MsgThings, OldBoxId, NewBoxId) -> move_to_vmbox(AccountId, MsgThings, OldBoxId, NewBoxId, []). --spec move_to_vmbox(ne_binary(), messages(), ne_binary(), ne_binary(), update_funs()) -> +-spec move_to_vmbox(kz_term:ne_binary(), messages(), kz_term:ne_binary(), kz_term:ne_binary(), update_funs()) -> kz_json:object(). move_to_vmbox(AccountId, [?NE_BINARY = _Msg | _] = MsgIds, OldBoxId, NewBoxId, Funs) -> AccountDb = kvm_util:get_db(AccountId), @@ -357,7 +357,7 @@ move_to_vmbox(AccountId, MsgJObjs, OldBoxId, NewBoxId, Funs) -> MsgIds = [kzd_box_message:get_msg_id(J) || J <- MsgJObjs], move_to_vmbox(AccountId, MsgIds, OldBoxId, NewBoxId, Funs). --spec do_move(ne_binary(), ne_binaries(), ne_binary(), ne_binary(), kz_json:object(), bulk_map(), update_funs(), gregorian_seconds()) -> bulk_map(). +-spec do_move(kz_term:ne_binary(), kz_term:ne_binaries(), kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), bulk_map(), update_funs(), kz_time:gregorian_seconds()) -> bulk_map(). do_move(_AccountId, [], _OldboxId, _NewBoxId, _NBoxJ, ResultMap, _, _) -> ResultMap; do_move(AccountId, [FromId | FromIds], OldboxId, NewBoxId, NBoxJ, ResultMap, Funs, RetenTimestamp) -> @@ -376,12 +376,12 @@ do_move(AccountId, [FromId | FromIds], OldboxId, NewBoxId, NBoxJ, ResultMap, Fun %% @doc copy messages to other vmbox(es) %% @end %%-------------------------------------------------------------------- --spec copy_to_vmboxes(ne_binary(), ne_binaries(), ne_binary(), ne_binary() | ne_binaries()) -> +-spec copy_to_vmboxes(kz_term:ne_binary(), kz_term:ne_binaries(), kz_term:ne_binary(), kz_term:ne_binary() | kz_term:ne_binaries()) -> kz_json:object(). copy_to_vmboxes(AccountId, Ids, OldBoxId, NewBoxIds) -> copy_to_vmboxes(AccountId, Ids, OldBoxId, NewBoxIds, []). --spec copy_to_vmboxes(ne_binary(), ne_binaries(), ne_binary(), ne_binary() | ne_binaries(), update_funs()) -> +-spec copy_to_vmboxes(kz_term:ne_binary(), kz_term:ne_binaries(), kz_term:ne_binary(), kz_term:ne_binary() | kz_term:ne_binaries(), update_funs()) -> kz_json:object(). copy_to_vmboxes(AccountId, Ids, OldBoxId, ?NE_BINARY = NewBoxId, Funs) -> copy_to_vmboxes(AccountId, Ids, OldBoxId, [NewBoxId], Funs); @@ -405,12 +405,12 @@ copy_to_vmboxes(AccountId, Ids, OldBoxId, NewBoxIds, Funs) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_view_results(ne_binary(), ne_binary(), kz_proplist(), norm_fun()) -> kz_json:objects(). +-spec get_view_results(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:proplist(), norm_fun()) -> kz_json:objects(). get_view_results(?NE_BINARY = AccountId, View, ViewOpts, NormFun) -> {From, To, Dbs} = kvm_util:get_range_db(AccountId), get_view_results(Dbs, View, maybe_add_range_to_keys(From, To, ViewOpts), NormFun, []). --spec get_view_results(ne_binaries(), ne_binary(), kz_proplist(), norm_fun(), kz_json:objects()) -> kz_json:objects(). +-spec get_view_results(kz_term:ne_binaries(), kz_term:ne_binary(), kz_term:proplist(), norm_fun(), kz_json:objects()) -> kz_json:objects(). get_view_results([], _View, _ViewOpts, 'undefined', ViewResults) -> ViewResults; get_view_results([], _View, _ViewOpts, NormFun, ViewResults) -> @@ -430,7 +430,7 @@ get_view_results([Db | Dbs], View, ViewOpts, NormFun, Acc) -> get_view_results(Dbs, View, ViewOpts, NormFun, Acc) end. --spec maybe_add_range_to_keys(gregorian_seconds(), gregorian_seconds(), kz_proplist()) -> kz_proplist(). +-spec maybe_add_range_to_keys(kz_time:gregorian_seconds(), kz_time:gregorian_seconds(), kz_term:proplist()) -> kz_term:proplist(). maybe_add_range_to_keys(From, To, ViewOpts) -> [{'startkey', add_timestamp_if_defined('startkey', To, ViewOpts)} ,{'endkey', add_timestamp_if_defined('startkey', From, ViewOpts)} @@ -438,7 +438,7 @@ maybe_add_range_to_keys(From, To, ViewOpts) -> | props:delete_keys(['startkey', 'endkey'], ViewOpts) ]. --spec add_timestamp_if_defined('startkey' | 'endkey', gregorian_seconds(), kz_proplist()) -> kz_json:path(). +-spec add_timestamp_if_defined('startkey' | 'endkey', kz_time:gregorian_seconds(), kz_term:proplist()) -> kz_json:path(). add_timestamp_if_defined(Key, Timestamp, ViewOpts) -> case props:get_value(Key, ViewOpts) of [] -> [Timestamp]; @@ -473,7 +473,7 @@ normalize_account_listing(JObj, Map) -> %% retention %% @end %%-------------------------------------------------------------------- --spec normalize_bulk_results(bulk_map(), kz_json:objects(), ne_binary(), api_ne_binary(), api_seconds()) -> bulk_map(). +-spec normalize_bulk_results(bulk_map(), kz_json:objects(), kz_term:ne_binary(), kz_term:api_ne_binary(), kz_time:api_seconds()) -> bulk_map(). normalize_bulk_results(ResultMap, [], _Method, _BoxId, _) -> lager:debug("voicemail ~s bulk for mailbox ~s resulted in ~b succeeded and ~b failed docs" ,[_Method @@ -513,7 +513,7 @@ normalize_bulk_results(#{succeeded := Succeeded %% check message retention, also if the operation is update, checks if the message is in retention enforce set %% so the message won't be added to succeeded list --spec is_prior_to_retention(kz_json:object(), api_seconds(), bulk_map()) -> boolean(). +-spec is_prior_to_retention(kz_json:object(), kz_time:api_seconds(), bulk_map()) -> boolean(). is_prior_to_retention(JObj, _, #{enforce_set := EnforceSet}) -> sets:is_element(kz_doc:id(JObj), EnforceSet); is_prior_to_retention(JObj, RetenTimestamp, _) -> @@ -530,7 +530,7 @@ is_prior_to_retention(JObj, RetenTimestamp, _) -> -define(PER_BOX_FOLDER_VIEW_BOX_ID_KEY_INDEX, 1). -define(PER_BOX_FOLDER_VIEW_FOLDER_KEY_INDEX, 2). --spec normalize_count(ne_binary(), kz_json:objects(), count_map()) -> count_map(). +-spec normalize_count(kz_term:ne_binary(), kz_json:objects(), count_map()) -> count_map(). normalize_count(?MSG_COUNT_PER_BOX_FOLDER, ViewResults, ResultMap) -> lists:foldl(fun(JObj, Map) -> sum_per_folder(JObj, ?PER_BOX_FOLDER_VIEW_FOLDER_KEY_INDEX, ?PER_BOX_FOLDER_VIEW_BOX_ID_KEY_INDEX, Map) @@ -577,7 +577,7 @@ sum_per_folder(JObj, FolderKeyIndex, BoxIdKeyIndex, ResultMap) -> %% as an error. %% @end %%-------------------------------------------------------------------- --spec split_to_modbs_and_apply_funs(bulk_map(), ne_binary(), update_funs(), gregorian_seconds()) -> bulk_map(). +-spec split_to_modbs_and_apply_funs(bulk_map(), kz_term:ne_binary(), update_funs(), kz_time:gregorian_seconds()) -> bulk_map(). split_to_modbs_and_apply_funs(FetchMap, AccountId, Funs, RetenTimestamp) -> Succeeded = maps:get(succeeded, FetchMap, []), Failed = maps:get(failed, FetchMap, []), @@ -587,7 +587,7 @@ split_to_modbs_and_apply_funs(FetchMap, AccountId, Funs, RetenTimestamp) -> }, split_to_modbs_and_apply_funs(Map, AccountId, Succeeded, Funs, RetenTimestamp). --spec split_to_modbs_and_apply_funs(bulk_map(), ne_binary(), kz_json:objects(), update_funs(), gregorian_seconds()) -> bulk_map(). +-spec split_to_modbs_and_apply_funs(bulk_map(), kz_term:ne_binary(), kz_json:objects(), update_funs(), kz_time:gregorian_seconds()) -> bulk_map(). split_to_modbs_and_apply_funs(SplitMap, _AccountId, [], _Funs, _RetenTimestamp) -> SplitMap; split_to_modbs_and_apply_funs(#{to_update_map := ToUpdateMap diff --git a/core/kazoo_voicemail/src/kvm_util.erl b/core/kazoo_voicemail/src/kvm_util.erl index f6627889cb1..e16768dd5dc 100644 --- a/core/kazoo_voicemail/src/kvm_util.erl +++ b/core/kazoo_voicemail/src/kvm_util.erl @@ -32,9 +32,9 @@ %% @doc Generate database name based on DocId %% @end %%-------------------------------------------------------------------- --spec get_db(ne_binary()) -> ne_binary(). --spec get_db(ne_binary(), kazoo_data:docid() | kz_json:object()) -> ne_binary(). --spec get_db(ne_binary(), ne_binary(), ne_binary()) -> ne_binary(). +-spec get_db(kz_term:ne_binary()) -> kz_term:ne_binary(). +-spec get_db(kz_term:ne_binary(), kazoo_data:docid() | kz_json:object()) -> kz_term:ne_binary(). +-spec get_db(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:ne_binary()) -> kz_term:ne_binary(). get_db(AccountId) -> kz_util:format_account_db(AccountId). @@ -55,8 +55,8 @@ get_db(AccountId, Year, Month) -> %% @doc Generate a range of database names %% @end %%-------------------------------------------------------------------- --spec get_range_db(ne_binary()) -> {gregorian_seconds(), gregorian_seconds(), ne_binaries()}. --spec get_range_db(ne_binary(), pos_integer()) -> {gregorian_seconds(), gregorian_seconds(), ne_binaries()}. +-spec get_range_db(kz_term:ne_binary()) -> {kz_time:gregorian_seconds(), kz_time:gregorian_seconds(), kz_term:ne_binaries()}. +-spec get_range_db(kz_term:ne_binary(), pos_integer()) -> {kz_time:gregorian_seconds(), kz_time:gregorian_seconds(), kz_term:ne_binaries()}. get_range_db(AccountId) -> get_range_db(AccountId, retention_days(AccountId)). @@ -65,7 +65,7 @@ get_range_db(AccountId, Days) -> From = To - retention_seconds(Days), {From, To, lists:reverse([Db || Db <- kazoo_modb:get_range(AccountId, From, To)])}. --spec split_to_modbs(ne_binary(), ne_binaries()) -> map(). +-spec split_to_modbs(kz_term:ne_binary(), kz_term:ne_binaries()) -> map(). split_to_modbs(AccountId, MsgIds) -> lists:foldl(fun(Id, Map) -> Db = get_db(AccountId, Id), @@ -77,7 +77,7 @@ split_to_modbs(AccountId, MsgIds) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec open_modb_doc(ne_binary(), kazoo_data:docid(), ne_binary()) -> db_ret(). +-spec open_modb_doc(kz_term:ne_binary(), kazoo_data:docid(), kz_term:ne_binary()) -> db_ret(). open_modb_doc(AccountId, DocId, Type) -> case kazoo_modb:open_doc(AccountId, DocId) of {'ok', JObj}-> check_doc_type(JObj, Type, kz_doc:type(JObj)); @@ -89,7 +89,7 @@ open_modb_doc(AccountId, DocId, Type) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec open_accountdb_doc(ne_binary(), kazoo_data:docid(), ne_binary()) -> db_ret(). +-spec open_accountdb_doc(kz_term:ne_binary(), kazoo_data:docid(), kz_term:ne_binary()) -> db_ret(). open_accountdb_doc(AccountId, DocId, Type) -> case kz_datamgr:open_doc(get_db(AccountId), DocId) of {'ok', JObj} -> check_doc_type(JObj, Type, kz_doc:type(JObj)); @@ -102,7 +102,7 @@ open_accountdb_doc(AccountId, DocId, Type) -> %% (especially for requests from crossbar) %% @end %%-------------------------------------------------------------------- --spec check_doc_type(kz_json:object(), ne_binary(), ne_binary()) -> db_ret(). +-spec check_doc_type(kz_json:object(), kz_term:ne_binary(), kz_term:ne_binary()) -> db_ret(). check_doc_type(Doc, Type, Type) -> {'ok', Doc}; check_doc_type(_Doc, _ExpectedType, _DocType) -> @@ -114,8 +114,8 @@ check_doc_type(_Doc, _ExpectedType, _DocType) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec check_msg_belonging(api_ne_binary(), kz_json:object()) -> boolean(). --spec check_msg_belonging(api_ne_binary(), kz_json:object(), api_ne_binary()) -> boolean(). +-spec check_msg_belonging(kz_term:api_ne_binary(), kz_json:object()) -> boolean(). +-spec check_msg_belonging(kz_term:api_ne_binary(), kz_json:object(), kz_term:api_ne_binary()) -> boolean(). check_msg_belonging(BoxId, JObj) -> check_msg_belonging(BoxId, JObj, kzd_box_message:source_id(JObj)). @@ -132,11 +132,11 @@ check_msg_belonging(_BoxId, _JObj, _SourceId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec retention_seconds() -> gregorian_seconds(). +-spec retention_seconds() -> kz_time:gregorian_seconds(). retention_seconds() -> retention_seconds(?RETENTION_DAYS). --spec retention_seconds(integer() | api_binary()) -> gregorian_seconds(). +-spec retention_seconds(integer() | kz_term:api_binary()) -> kz_time:gregorian_seconds(). retention_seconds(Days) when is_integer(Days) andalso Days > 0 -> ?SECONDS_IN_DAY * Days + ?SECONDS_IN_HOUR; @@ -145,7 +145,7 @@ retention_seconds(?NE_BINARY=AccountId) -> retention_seconds(_) -> retention_seconds(?RETENTION_DAYS). --spec retention_days(ne_binary()) -> integer(). +-spec retention_days(kz_term:ne_binary()) -> integer(). retention_days(AccountId) -> case kapps_account_config:get_pos_integer(AccountId, ?CF_CONFIG_CAT, [?KEY_VOICEMAIL, ?KEY_RETENTION_DURATION]) of 'undefined' -> ?RETENTION_DAYS; @@ -162,7 +162,7 @@ retention_days(AccountId) -> enforce_retention(JObj) -> enforce_retention(JObj, kz_time:now_s() - retention_seconds(kz_doc:account_id(JObj))). --spec enforce_retention(kz_json:object(), gregorian_seconds() | boolean()) -> kz_json:object(). +-spec enforce_retention(kz_json:object(), kz_time:gregorian_seconds() | boolean()) -> kz_json:object(). enforce_retention(JObj, RetentionTimestamp) when is_integer(RetentionTimestamp) -> enforce_retention(JObj, is_prior_to_retention(JObj, RetentionTimestamp)); @@ -175,7 +175,7 @@ enforce_retention(JObj, 'true') -> kzd_box_message:set_metadata(kzd_box_message:set_folder_deleted(Metadata), JObj) end. --spec is_prior_to_retention(kz_json:object(), api_seconds()) -> boolean(). +-spec is_prior_to_retention(kz_json:object(), kz_time:api_seconds()) -> boolean(). is_prior_to_retention(_, 'undefined') -> 'false'; is_prior_to_retention(JObj, RetentionTimestamp) -> @@ -189,13 +189,13 @@ is_prior_to_retention(JObj, RetentionTimestamp) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_change_vmbox_funs(ne_binary(), ne_binary(), kz_json:object(), ne_binary()) -> - {ne_binary(), update_funs()}. +-spec get_change_vmbox_funs(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> + {kz_term:ne_binary(), update_funs()}. get_change_vmbox_funs(AccountId, NewBoxId, NBoxJ, OldBoxId) -> get_change_vmbox_funs(AccountId, NewBoxId, NBoxJ, OldBoxId, 'undefined'). --spec get_change_vmbox_funs(ne_binary(), ne_binary(), kz_json:object(), ne_binary(), api_binary()) -> - {ne_binary(), update_funs()}. +-spec get_change_vmbox_funs(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary(), kz_term:api_binary()) -> + {kz_term:ne_binary(), update_funs()}. get_change_vmbox_funs(AccountId, NewBoxId, NBoxJ, OldBoxId, ToId) -> Timestamp = kz_time:now_s(), {{Y, M, _}, _} = calendar:gregorian_seconds_to_datetime(Timestamp), @@ -228,7 +228,7 @@ get_change_vmbox_funs(AccountId, NewBoxId, NBoxJ, OldBoxId, ToId) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_caller_id_name(kapps_call:call()) -> ne_binary(). +-spec get_caller_id_name(kapps_call:call()) -> kz_term:ne_binary(). get_caller_id_name(Call) -> CallerIdName = kapps_call:caller_id_name(Call), case kapps_call:kvs_fetch('prepend_cid_name', Call) of @@ -243,7 +243,7 @@ get_caller_id_name(Call) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec get_caller_id_number(kapps_call:call()) -> ne_binary(). +-spec get_caller_id_number(kapps_call:call()) -> kz_term:ne_binary(). get_caller_id_number(Call) -> CallerIdNumber = kapps_call:caller_id_number(Call), case kapps_call:kvs_fetch('prepend_cid_number', Call) of @@ -262,7 +262,7 @@ get_caller_id_number(Call) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec publish_saved_notify(ne_binary(), ne_binary(), kapps_call:call(), pos_integer(), kz_proplist()) -> +-spec publish_saved_notify(kz_term:ne_binary(), kz_term:ne_binary(), kapps_call:call(), pos_integer(), kz_term:proplist()) -> kz_amqp_worker:request_return(). publish_saved_notify(MediaId, BoxId, Call, Length, Props) -> MaybeTranscribe = props:get_value(<<"Transcribe-Voicemail">>, Props, 'false'), @@ -293,7 +293,7 @@ publish_saved_notify(MediaId, BoxId, Call, Length, Props) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec publish_voicemail_saved(pos_integer(), ne_binary(), kapps_call:call(), ne_binary(), gregorian_seconds()) -> 'ok'. +-spec publish_voicemail_saved(pos_integer(), kz_term:ne_binary(), kapps_call:call(), kz_term:ne_binary(), kz_time:gregorian_seconds()) -> 'ok'. publish_voicemail_saved(Length, BoxId, Call, MediaId, Timestamp) -> Prop = [{<<"From-User">>, kapps_call:from_user(Call)} ,{<<"From-Realm">>, kapps_call:from_realm(Call)} @@ -339,8 +339,8 @@ get_notify_completed_message([JObj|JObjs], Acc) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec maybe_transcribe(ne_binary(), ne_binary(), boolean()) -> api_object(). --spec maybe_transcribe(ne_binary(), kz_json:object(), binary(), api_binary()) -> api_object(). +-spec maybe_transcribe(kz_term:ne_binary(), kz_term:ne_binary(), boolean()) -> kz_term:api_object(). +-spec maybe_transcribe(kz_term:ne_binary(), kz_json:object(), binary(), kz_term:api_binary()) -> kz_term:api_object(). maybe_transcribe(AccountId, MediaId, 'true') -> Db = get_db(AccountId, MediaId), {'ok', MediaDoc} = kz_datamgr:open_doc(Db, MediaId), @@ -378,7 +378,7 @@ maybe_transcribe(Db, MediaDoc, Bin, ContentType) -> 'undefined' end. --spec is_valid_transcription(api_binary(), binary(), kz_json:object()) -> api_object(). +-spec is_valid_transcription(kz_term:api_binary(), binary(), kz_json:object()) -> kz_term:api_object(). is_valid_transcription(<<"success">>, ?NE_BINARY, Resp) -> Resp; is_valid_transcription(_Res, _Txt, _) -> lager:info("not valid transcription: ~s: '~s'", [_Res, _Txt]), diff --git a/core/kazoo_voicemail/src/kz_voicemail.hrl b/core/kazoo_voicemail/src/kz_voicemail.hrl index 33dfec02bf0..5dd9e3d0781 100644 --- a/core/kazoo_voicemail/src/kz_voicemail.hrl +++ b/core/kazoo_voicemail/src/kz_voicemail.hrl @@ -21,18 +21,18 @@ kapps_config:get_integer(?CF_CONFIG_CAT, [?KEY_VOICEMAIL, <<"migrate_interaccount_delay_ms">>], 2 * ?MILLISECONDS_IN_SECOND)). -type db_ret() :: 'ok' | {'ok', kz_json:object() | kz_json:objects()} | {'error', any()}. --type vm_folder() :: ne_binary() | {ne_binary(), boolean()}. --type message() :: ne_binary() | kz_json:object(). --type messages() :: ne_binaries() | kz_json:objects(). +-type vm_folder() :: kz_term:ne_binary() | {kz_term:ne_binary(), boolean()}. +-type message() :: kz_term:ne_binary() | kz_json:object(). +-type messages() :: kz_term:ne_binaries() | kz_json:objects(). -type update_funs() :: [fun((kz_json:object()) -> kz_json:object())]. --type bulk_map() :: #{succeeded => ne_binaries() | kz_json:objects() - ,failed => [{ne_binary(), ne_binary()}] - ,to_update_map => #{ne_binary() => kz_json:objects()} +-type bulk_map() :: #{succeeded => kz_term:ne_binaries() | kz_json:objects() + ,failed => [{kz_term:ne_binary(), kz_term:ne_binary()}] + ,to_update_map => #{kz_term:ne_binary() => kz_json:objects()} ,enforce_set => set:sets() }. --type next_account() :: {ne_binary(), gregorian_seconds(), gregorian_seconds()}. +-type next_account() :: {kz_term:ne_binary(), kz_time:gregorian_seconds(), kz_time:gregorian_seconds()}. -define(KZ_VOICEMAIL_HRL, 'true'). -endif. diff --git a/core/kazoo_voicemail/src/migrate/kvm_migrate_account.erl b/core/kazoo_voicemail/src/migrate/kvm_migrate_account.erl index d446840c328..bf940cb1902 100644 --- a/core/kazoo_voicemail/src/migrate/kvm_migrate_account.erl +++ b/core/kazoo_voicemail/src/migrate/kvm_migrate_account.erl @@ -32,10 +32,10 @@ -define(SUCCEEDED, 'succeeded'). -type migrate_stats() :: non_neg_integer() | - ne_binary() | - ne_binaries() | - {ne_binary(), atom()} | - [{ne_binary(), atom()}] | + kz_term:ne_binary() | + kz_term:ne_binaries() | + {kz_term:ne_binary(), atom()} | + [{kz_term:ne_binary(), atom()}] | 'undefined'. %%-------------------------------------------------------------------- @@ -73,8 +73,8 @@ start_worker({AccountId, FirstOfMonth, LastOfMonth}, Server) -> %% @doc Manual migration for an Account or a list of account's mailboxes %% @end %%-------------------------------------------------------------------- --spec manual_migrate(ne_binary()) -> 'ok'. --spec manual_migrate(ne_binary(), ne_binary() | ne_binaries()) -> 'ok'. +-spec manual_migrate(kz_term:ne_binary()) -> 'ok'. +-spec manual_migrate(kz_term:ne_binary(), kz_term:ne_binary() | kz_term:ne_binaries()) -> 'ok'. manual_migrate(AccountId) -> ?SUP_LOG_WARNING("######## Beginnig migration for account ~s~n~n", [AccountId]), manual_migrate_loop(AccountId, 1). @@ -134,7 +134,7 @@ manual_migrate(AccountId, BoxIds) -> %% @doc Process messages and do migrate %% @end %%-------------------------------------------------------------------- --spec migrate_messages(ne_binary(), kz_json:objects()) -> 'ok'. +-spec migrate_messages(kz_term:ne_binary(), kz_json:objects()) -> 'ok'. migrate_messages(AccountId, ViewResults) -> MsgCount = length(ViewResults), _ = update_process_key(?TOTAL_MESSAGES, MsgCount), @@ -148,7 +148,7 @@ migrate_messages(AccountId, ViewResults) -> %% @doc Check Db existence and process with migration %% @end %%-------------------------------------------------------------------- --spec maybe_migrate(ne_binary(), kz_json:objects(), dict:dict(), ne_binaries() | non_neg_integer()) -> 'ok'. +-spec maybe_migrate(kz_term:ne_binary(), kz_json:objects(), dict:dict(), kz_term:ne_binaries() | non_neg_integer()) -> 'ok'. maybe_migrate(AccountId, ViewResults, MsgsDict, Dbs) when is_list(Dbs) -> NewMsgsDict = check_dbs_existence(Dbs, MsgsDict), maybe_migrate(AccountId, ViewResults, NewMsgsDict, dict:size(NewMsgsDict)); @@ -167,7 +167,7 @@ maybe_migrate(AccountId, ViewResults, MsgsDict, _DbCount) -> do_migrate(MsgsDict) -> dict:fold(fun bulk_save_modb/3, [], MsgsDict). --spec bulk_save_modb(ne_binary(), kz_json:objects(), list()) -> 'ok'. +-spec bulk_save_modb(kz_term:ne_binary(), kz_json:objects(), list()) -> 'ok'. bulk_save_modb(Db, Js, _Acc) -> case kz_datamgr:save_docs(Db, Js) of {'ok', Saved} -> @@ -184,7 +184,7 @@ bulk_save_modb(Db, Js, _Acc) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec update_mailboxes(ne_binary(), kz_json:objects()) -> 'ok'. +-spec update_mailboxes(kz_term:ne_binary(), kz_json:objects()) -> 'ok'. update_mailboxes(AccountId, ViewResults) -> MODbFailed = dict:from_list(get_stats(?FAILED_MODB)), Failed = dict:from_list(get_stats(?FAILED)), @@ -251,7 +251,7 @@ update_message_array(BoxJObj, MODbFailed, Failed) -> %% fake message_doc result for manual migration %% @end %%-------------------------------------------------------------------- --spec get_messages_from_vmboxes(ne_binary(), ne_binaries()) -> db_ret(). +-spec get_messages_from_vmboxes(kz_term:ne_binary(), kz_term:ne_binaries()) -> db_ret(). get_messages_from_vmboxes(AccountId, ExpectedBoxIds) -> case kz_datamgr:open_cache_docs(kz_util:format_account_db(AccountId), ExpectedBoxIds) of {'ok', JObjs} -> {'ok', normalize_mailbox_results(JObjs)}; @@ -312,7 +312,7 @@ has_messages(JObj) -> %% @doc Check Db existence and remove messages that non exists dbs %% @end %%-------------------------------------------------------------------- --spec check_dbs_existence(ne_binaries(), dict:dict()) -> dict:dict(). +-spec check_dbs_existence(kz_term:ne_binaries(), dict:dict()) -> dict:dict(). check_dbs_existence([], MsgsDict) -> MsgsDict; check_dbs_existence([Db | Dbs], MsgsDict) -> case kz_datamgr:db_exists(Db) of @@ -329,9 +329,9 @@ check_dbs_existence([Db | Dbs], MsgsDict) -> %% @doc Normalize bulk save results and update stats accordingly %% @end %%-------------------------------------------------------------------- --spec normalize_bulk_result(ne_binary(), kz_json:objects()) -> +-spec normalize_bulk_result(kz_term:ne_binary(), kz_json:objects()) -> {non_neg_integer(), non_neg_integer()}. --spec normalize_bulk_result(ne_binary(), kz_json:objects(), dict:dict()) -> +-spec normalize_bulk_result(kz_term:ne_binary(), kz_json:objects(), dict:dict()) -> {non_neg_integer(), non_neg_integer()}. normalize_bulk_result(Db, Saved) -> DefaultDict = dict:from_list([{<<"succeeded">>, []} @@ -372,7 +372,7 @@ normalize_bulk_result(Db, [S | Saved], Dict) -> %% kazoo_data bulk operation for faster db writes. %% @end %%-------------------------------------------------------------------- --spec process_messages(ne_binary(), kz_json:objects()) -> dict:dict(). +-spec process_messages(kz_term:ne_binary(), kz_json:objects()) -> dict:dict(). process_messages(AccountId, JObjs) -> DefaultExt = ?DEFAULT_VM_EXTENSION, Fun = fun(J, Acc) -> @@ -381,7 +381,7 @@ process_messages(AccountId, JObjs) -> end, lists:foldl(Fun, dict:new(), JObjs). --spec create_message(ne_binary(), kz_json:object(), ne_binary()) -> kz_json:object(). +-spec create_message(kz_term:ne_binary(), kz_json:object(), kz_term:ne_binary()) -> kz_json:object(). create_message(AccountId, FakeBoxJObj, DefaultExt) -> AccountDb = kvm_util:get_db(AccountId), BoxJObj0 = kz_doc:set_account_id(kz_json:get_value(<<"value">>, FakeBoxJObj), AccountId), @@ -497,7 +497,7 @@ update_process_total_key(?FAILED_MODB, Count) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec migration_result(pid(), ne_binary(), gregorian_seconds(), gregorian_seconds()) -> 'ok'. +-spec migration_result(pid(), kz_term:ne_binary(), kz_time:gregorian_seconds(), kz_time:gregorian_seconds()) -> 'ok'. migration_result(Server, AccountId, FirstOfMonth, LastOfMonth) -> TotalMsgs = get_stats(?TOTAL_MESSAGES), TotalSucceeded = get_stats(?TOTAL_SUCCEEDED), @@ -525,12 +525,12 @@ migration_result(Server, AccountId, FirstOfMonth, LastOfMonth) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec is_latest_modb(ne_binary()) -> boolean(). +-spec is_latest_modb(kz_term:ne_binary()) -> boolean(). is_latest_modb(AccountId) -> print_summary(AccountId, 'true'). --spec print_summary(ne_binary()) -> 'ok'. --spec print_summary(ne_binary(), boolean()) -> 'ok' | boolean(). +-spec print_summary(kz_term:ne_binary()) -> 'ok'. +-spec print_summary(kz_term:ne_binary(), boolean()) -> 'ok' | boolean(). print_summary(AccountId) -> print_summary(AccountId, 'false'). diff --git a/core/kazoo_voicemail/src/migrate/kvm_migrate_crawler.erl b/core/kazoo_voicemail/src/migrate/kvm_migrate_crawler.erl index 0ba53702ecc..7e4b80af996 100644 --- a/core/kazoo_voicemail/src/migrate/kvm_migrate_crawler.erl +++ b/core/kazoo_voicemail/src/migrate/kvm_migrate_crawler.erl @@ -39,16 +39,16 @@ -type workers() :: [worker()]. -record(state, {max_worker = ?MAX_PROCESS :: integer() ,workers = [] :: workers() - ,account_ids = [] :: ne_binaries() + ,account_ids = [] :: kz_term:ne_binaries() ,retention_passed = 'false' :: boolean() ,total_account = 0 :: non_neg_integer() ,total_processed = 0 :: non_neg_integer() ,total_succeeded = 0 :: non_neg_integer() ,total_failed = 0 :: non_neg_integer() ,total_account_failed = 0 :: non_neg_integer() - ,failed_accounts = [] :: ne_binaries() - ,calling_process = 'undefined' :: api_pid() - ,timer_ref :: api_reference() + ,failed_accounts = [] :: kz_term:ne_binaries() + ,calling_process = 'undefined' :: kz_term:api_pid() + ,timer_ref :: kz_term:api_reference() ,account_queue :: queue:queue() | 'undefined' }). -type state() :: #state{}. @@ -88,11 +88,11 @@ %% Starts the server %% @end %%-------------------------------------------------------------------- --spec start() -> startlink_ret(). +-spec start() -> kz_types:startlink_ret(). start() -> gen_server:start(?SERVER, [], []). --spec start(pid()) -> startlink_ret(). +-spec start(pid()) -> kz_types:startlink_ret(). start(Pid) -> gen_server:start(?SERVER, [Pid], []). @@ -101,17 +101,17 @@ stop(Server) -> gen_server:call(Server, 'stop'). %% Workers API --spec account_is_done(pid(), ne_binary(), gregorian_seconds(), gregorian_seconds()) -> 'ok'. +-spec account_is_done(pid(), kz_term:ne_binary(), kz_time:gregorian_seconds(), kz_time:gregorian_seconds()) -> 'ok'. account_is_done(Server, AccountId, FirstOfMonth, LastOfMonth) -> gen_server:call(Server, {'account_is_done', {AccountId, FirstOfMonth, LastOfMonth, 'normal'}}). --spec account_maybe_failed(pid(), ne_binary(), gregorian_seconds(), gregorian_seconds(), any()) -> 'ok'. +-spec account_maybe_failed(pid(), kz_term:ne_binary(), kz_time:gregorian_seconds(), kz_time:gregorian_seconds(), any()) -> 'ok'. account_maybe_failed(_Server, _AccountId, _FirstOfMonth, _LastOfMonth, 'timeout') -> ?SUP_LOG_WARNING("ignoring 'timeout' error for worker of account ~s", [_AccountId]); account_maybe_failed(Server, AccountId, FirstOfMonth, LastOfMonth, Reason) -> gen_server:call(Server, {'account_is_done', {AccountId, FirstOfMonth, LastOfMonth, Reason}}). --spec update_stats(pid(), ne_binary(), kz_proplist()) -> 'ok'. +-spec update_stats(pid(), kz_term:ne_binary(), kz_term:proplist()) -> 'ok'. update_stats(Server, AccountId, Stats) -> gen_server:call(Server, {'update_stats', {AccountId, Stats}}). @@ -154,7 +154,7 @@ init(Pid) -> %% Handling call messages %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call({'account_is_done', MaybeDone}, _From, #state{account_queue = Queue ,total_account_failed = TotalAccFailed ,failed_accounts = FailedAccounts @@ -199,7 +199,7 @@ handle_call(_Request, _From, State) -> %% Handling cast messages %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast(_Msg, State) -> lager:debug("unhandled cast: ~p", [_Msg]), {'noreply', State}. @@ -210,7 +210,7 @@ handle_cast(_Msg, State) -> %% Handling all non call/cast messages %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info({'timeout', _Ref, _Msg}, #state{account_ids = [] ,workers = [] ,retention_passed = 'true' @@ -332,12 +332,12 @@ maybe_spawn_worker(#state{workers = Workers %% @doc %% @end %%-------------------------------------------------------------------- --spec make_callid(reference(), ne_binary()) -> ne_binary(). +-spec make_callid(reference(), kz_term:ne_binary()) -> kz_term:ne_binary(). make_callid(Ref, AccountId) -> Id = ref_to_id(Ref), <<"task_", AccountId/binary, "_", Id/binary>>. --spec ref_to_id(reference()) -> ne_binary(). +-spec ref_to_id(reference()) -> kz_term:ne_binary(). ref_to_id(Ref) -> Bin = list_to_binary(io_lib:format("~p", [Ref])), Start = <<"#Ref<">>, @@ -397,14 +397,14 @@ get_next(_Queue, _WorkerNextAccount, _NextAccount, _Q, _IsRetPassed) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec populate_queue(ne_binaries()) -> queue:queue(). +-spec populate_queue(kz_term:ne_binaries()) -> queue:queue(). populate_queue(AccountIds) -> Props = [{AccountId, 'undefined', 'undefined'} || AccountId <- AccountIds ], queue:from_list(Props). --spec populate_queue(ne_binaries(), gregorian_seconds()) -> queue:queue(). +-spec populate_queue(kz_term:ne_binaries(), kz_time:gregorian_seconds()) -> queue:queue(). populate_queue(AccountIds, LastOfMonth) -> {{Year, Month, _}, _} = calendar:gregorian_seconds_to_datetime(LastOfMonth), FirstOfMonth = calendar:datetime_to_gregorian_seconds({{Year, Month, 1}, {0, 0, 0}}), @@ -433,7 +433,7 @@ remove_account_from_queue(Key, Queue) -> %% @doc %% @end %%-------------------------------------------------------------------- --spec previous_month_timestamp(gregorian_seconds()) -> gregorian_seconds(). +-spec previous_month_timestamp(kz_time:gregorian_seconds()) -> kz_time:gregorian_seconds(). previous_month_timestamp(TimeStamp) -> {{Year, Month, _}, _} = calendar:gregorian_seconds_to_datetime(TimeStamp), {PrevYear, PrevMonth} = kazoo_modb_util:prev_year_month(Year, Month), diff --git a/core/kazoo_web/src/kz_http.erl b/core/kazoo_web/src/kz_http.erl index 4b270b1ecd4..ba45c566218 100644 --- a/core/kazoo_web/src/kz_http.erl +++ b/core/kazoo_web/src/kz_http.erl @@ -33,7 +33,7 @@ -type http_body() :: iodata(). --type httpc_result() :: {any(), kz_proplist(), http_body()} | +-type httpc_result() :: {any(), kz_term:proplist(), http_body()} | {string(), string() | binary()} | reference(). @@ -44,14 +44,14 @@ any() }. --type httpc_request() :: {string(), kz_proplist()} | - {string(), kz_proplist(), string(), http_body()}. +-type httpc_request() :: {string(), kz_term:proplist()} | + {string(), kz_term:proplist(), string(), http_body()}. -type req_id() :: {'http_req_id', reference()} | {'ok', reference()} | reference(). --type ret() :: {'ok', pos_integer(), kz_proplist(), text()} | +-type ret() :: {'ok', pos_integer(), kz_term:proplist(), kz_term:text()} | {'ok', 'saved_to_file'} | {'error', any()} | req_id(). @@ -66,8 +66,8 @@ %% @doc Send synchronous request %%-------------------------------------------------------------------- -spec get(string()) -> ret(). --spec get(string(), kz_proplist()) -> ret(). --spec get(string(), kz_proplist(), kz_proplist()) -> ret(). +-spec get(string(), kz_term:proplist()) -> ret(). +-spec get(string(), kz_term:proplist(), kz_term:proplist()) -> ret(). get(Url) -> req('get', Url, [], [], []). get(Url, Headers) -> @@ -76,8 +76,8 @@ get(Url, Headers, Options) -> req('get', Url, Headers, [], Options). -spec options(string()) -> ret(). --spec options(string(), kz_proplist()) -> ret(). --spec options(string(), kz_proplist(), kz_proplist()) -> ret(). +-spec options(string(), kz_term:proplist()) -> ret(). +-spec options(string(), kz_term:proplist(), kz_term:proplist()) -> ret(). options(Url) -> req('options', Url, [], [], []). options(Url, Headers) -> @@ -86,8 +86,8 @@ options(Url, Headers, Options) -> req('options', Url, Headers, [], Options). -spec head(string()) -> ret(). --spec head(string(), kz_proplist()) -> ret(). --spec head(string(), kz_proplist(), kz_proplist()) -> ret(). +-spec head(string(), kz_term:proplist()) -> ret(). +-spec head(string(), kz_term:proplist(), kz_term:proplist()) -> ret(). head(Url) -> req('head', Url, [], [], []). head(Url, Headers) -> @@ -96,8 +96,8 @@ head(Url, Headers, Options) -> req('head', Url, Headers, [], Options). -spec trace(string()) -> ret(). --spec trace(string(), kz_proplist()) -> ret(). --spec trace(string(), kz_proplist(), kz_proplist()) -> ret(). +-spec trace(string(), kz_term:proplist()) -> ret(). +-spec trace(string(), kz_term:proplist(), kz_term:proplist()) -> ret(). trace(Url) -> req('trace', Url, [], [], []). trace(Url, Headers) -> @@ -106,9 +106,9 @@ trace(Url, Headers, Options) -> req('trace', Url, Headers, [], Options). -spec delete(string()) -> ret(). --spec delete(string(), kz_proplist()) -> ret(). --spec delete(string(), kz_proplist(), http_body()) -> ret(). --spec delete(string(), kz_proplist(), http_body(), kz_proplist()) -> ret(). +-spec delete(string(), kz_term:proplist()) -> ret(). +-spec delete(string(), kz_term:proplist(), http_body()) -> ret(). +-spec delete(string(), kz_term:proplist(), http_body(), kz_term:proplist()) -> ret(). delete(Url) -> req('delete', Url, [], [], []). delete(Url, Headers) -> @@ -119,9 +119,9 @@ delete(Url, Headers, Body, Options) -> req('delete', Url, Headers, Body, Options). -spec post(string()) -> ret(). --spec post(string(), kz_proplist()) -> ret(). --spec post(string(), kz_proplist(), http_body()) -> ret(). --spec post(string(), kz_proplist(), http_body(), kz_proplist()) -> ret(). +-spec post(string(), kz_term:proplist()) -> ret(). +-spec post(string(), kz_term:proplist(), http_body()) -> ret(). +-spec post(string(), kz_term:proplist(), http_body(), kz_term:proplist()) -> ret(). post(Url) -> req('post', Url, [], [], []). post(Url, Headers) -> @@ -132,9 +132,9 @@ post(Url, Headers, Body, Options) -> req('post', Url, Headers, Body, Options). -spec patch(string()) -> ret(). --spec patch(string(), kz_proplist()) -> ret(). --spec patch(string(), kz_proplist(), http_body()) -> ret(). --spec patch(string(), kz_proplist(), http_body(), kz_proplist()) -> ret(). +-spec patch(string(), kz_term:proplist()) -> ret(). +-spec patch(string(), kz_term:proplist(), http_body()) -> ret(). +-spec patch(string(), kz_term:proplist(), http_body(), kz_term:proplist()) -> ret(). patch(Url) -> req('patch', Url, [], [], []). patch(Url, Headers) -> @@ -145,9 +145,9 @@ patch(Url, Headers, Body, Options) -> req('patch', Url, Headers, Body, Options). -spec put(string()) -> ret(). --spec put(string(), kz_proplist()) -> ret(). --spec put(string(), kz_proplist(), http_body()) -> ret(). --spec put(string(), kz_proplist(), http_body(), kz_proplist()) -> ret(). +-spec put(string(), kz_term:proplist()) -> ret(). +-spec put(string(), kz_term:proplist(), http_body()) -> ret(). +-spec put(string(), kz_term:proplist(), http_body(), kz_term:proplist()) -> ret(). put(Url) -> req('put', Url, [], [], []). put(Url, Headers) -> @@ -163,9 +163,9 @@ put(Url, Headers, Body, Options) -> %%-------------------------------------------------------------------- -spec req(string()) -> ret(). -spec req(method(), string()) -> ret(). --spec req(method(), string(), kz_proplist()) -> ret(). --spec req(method(), string(), kz_proplist(), http_body()) -> ret(). --spec req(method(), string(), kz_proplist(), http_body(), kz_proplist()) -> ret(). +-spec req(method(), string(), kz_term:proplist()) -> ret(). +-spec req(method(), string(), kz_term:proplist(), http_body()) -> ret(). +-spec req(method(), string(), kz_term:proplist(), http_body(), kz_term:proplist()) -> ret(). req(Url) -> req('get', Url, [], [], []). req(Method, Url) -> @@ -183,11 +183,11 @@ req(Method, Url, Hdrs, Body, Opts) -> %% @public %% @doc Send an asynchronous HTTP request %%-------------------------------------------------------------------- --spec async_req(pid(), text()) -> ret(). --spec async_req(pid(), method(), text()) -> ret(). --spec async_req(pid(), method(), text(), kz_proplist()) -> ret(). --spec async_req(pid(), method(), text(), kz_proplist(), http_body()) -> ret(). --spec async_req(pid(), method(), text(), kz_proplist(), http_body(), kz_proplist()) -> ret(). +-spec async_req(pid(), kz_term:text()) -> ret(). +-spec async_req(pid(), method(), kz_term:text()) -> ret(). +-spec async_req(pid(), method(), kz_term:text(), kz_term:proplist()) -> ret(). +-spec async_req(pid(), method(), kz_term:text(), kz_term:proplist(), http_body()) -> ret(). +-spec async_req(pid(), method(), kz_term:text(), kz_term:proplist(), http_body(), kz_term:proplist()) -> ret(). async_req(Pid, Url) -> async_req(Pid, 'get', Url, [], [], []). async_req(Pid, Method, Url) -> @@ -210,7 +210,7 @@ async_req(Pid, Method, Url, Hdrs, Body, Opts) -> %% @private %% @doc Send request using httpc and handle its response %%-------------------------------------------------------------------- --spec execute_request(method(), httpc_request(), kz_proplist()) -> ret(). +-spec execute_request(method(), httpc_request(), kz_term:proplist()) -> ret(). execute_request(Method, Request, Opts) -> HTTPOptions = get_options(?HTTP_OPTIONS, Opts), Opts1 = get_options(?OPTIONS, Opts), @@ -227,7 +227,7 @@ execute_request(Method, Request, Opts) -> %% @public %% @doc Response to caller in a proper manner %%-------------------------------------------------------------------- --spec handle_response(httpc_ret() | {pos_integer(), {method(), text(), httpc_ret()}}) -> ret(). +-spec handle_response(httpc_ret() | {pos_integer(), {method(), kz_term:text(), httpc_ret()}}) -> ret(). handle_response({Micros, {_Method, _Url, Resp}}) when is_integer(Micros) -> ElapsedMs = float_to_list(Micros / ?MILLISECONDS_IN_SECOND, [{'decimals', 2}, 'compact']), lager:debug("~sms: ~s ~s", [ElapsedMs, _Method, _Url]), @@ -262,7 +262,7 @@ handle_response({'error', Error}=Err) -> %% @private %% @doc Build Authorization header using basic_auth option %%-------------------------------------------------------------------- --spec maybe_basic_auth(kz_proplist(), kz_proplist()) -> {kz_proplist(), kz_proplist()}. +-spec maybe_basic_auth(kz_term:proplist(), kz_term:proplist()) -> {kz_term:proplist(), kz_term:proplist()}. maybe_basic_auth(Headers, Options) -> case props:get_value('basic_auth', Options) of 'undefined' -> {Headers, Options}; @@ -275,7 +275,7 @@ maybe_basic_auth(Headers, Options) -> %% @private %% @doc Build httpc request argument based on method %%-------------------------------------------------------------------- --spec build_request(method(), text(), kz_proplist(), http_body()) -> httpc_request(). +-spec build_request(method(), kz_term:text(), kz_term:proplist(), http_body()) -> httpc_request(). build_request(Method, Url, Headers, _Body) when Method =:= 'options'; Method =:= 'get'; Method =:= 'head'; @@ -310,6 +310,6 @@ ensure_string_headers(Headers) -> %% which type of options should be returned. %% @end %%-------------------------------------------------------------------- --spec get_options(list(), kz_proplist()) -> kz_proplist(). +-spec get_options(list(), kz_term:proplist()) -> kz_term:proplist(). get_options(Type, Options) -> [KV || KV = {K, _V} <- Options, lists:member(K, Type)]. diff --git a/core/kazoo_web/src/kz_http_util.erl b/core/kazoo_web/src/kz_http_util.erl index 4ace9ee5542..a2fe9931db0 100644 --- a/core/kazoo_web/src/kz_http_util.erl +++ b/core/kazoo_web/src/kz_http_util.erl @@ -281,8 +281,8 @@ json_to_querystring(JObj, Prefix) -> {Vs, Ks} = kz_json:get_values(JObj), fold_kvs(Ks, Vs, Prefix, []). --spec props_to_querystring(kz_proplist()) -> iolist(). --spec props_to_querystring(kz_proplist(), binary() | ne_binaries()) -> iolist(). +-spec props_to_querystring(kz_term:proplist()) -> iolist(). +-spec props_to_querystring(kz_term:proplist(), binary() | kz_term:ne_binaries()) -> iolist(). props_to_querystring(Props) -> props_to_querystring(Props, <<>>). @@ -318,11 +318,11 @@ encode_kv(<<>>, K, ?JSON_WRAPPER(_)=JObj) -> json_to_querystring(JObj, [K]); %% if a prefix is defined, nest the key in square brackets encode_kv(Prefix, K, ?JSON_WRAPPER(_)=JObj) -> json_to_querystring(JObj, [Prefix, <<"[">>, K, <<"]">>]). --spec encode_kv(iolist() | binary(), key(), ne_binary(), string() | binary()) -> iolist(). +-spec encode_kv(iolist() | binary(), key(), kz_term:ne_binary(), string() | binary()) -> iolist(). encode_kv(<<>>, K, Sep, V) -> [kz_term:to_binary(K), Sep, kz_term:to_binary(V)]; encode_kv(Prefix, K, Sep, V) -> [Prefix, <<"[">>, kz_term:to_binary(K), <<"]">>, Sep, kz_term:to_binary(V)]. --spec encode_kv(iolist() | binary(), key(), [string()], ne_binary(), iolist()) -> iolist(). +-spec encode_kv(iolist() | binary(), key(), [string()], kz_term:ne_binary(), iolist()) -> iolist(). encode_kv(Prefix, K, [V], Sep, Acc) -> lists:reverse([encode_kv(Prefix, K, Sep, urlencode(V)) | Acc]); encode_kv(Prefix, K, [V|Vs], Sep, Acc) -> diff --git a/core/kazoo_xml/src/kz_xml.erl b/core/kazoo_xml/src/kz_xml.erl index 7bbf9c1b7ca..cd274395261 100644 --- a/core/kazoo_xml/src/kz_xml.erl +++ b/core/kazoo_xml/src/kz_xml.erl @@ -19,13 +19,13 @@ -include_lib("kazoo_stdlib/include/kz_types.hrl"). --spec elements(list()) -> xml_els(). --spec elements(list(), atom()) -> xml_els(). +-spec elements(list()) -> kz_types:xml_els(). +-spec elements(list(), atom()) -> kz_types:xml_els(). elements(Els) -> [El || #xmlElement{}=El <- Els]. elements(Els, Name) -> [El || #xmlElement{name=N}=El <- Els, N =:= Name]. --spec texts_to_binary(xml_texts()) -> binary(). --spec texts_to_binary(xml_texts(), pos_integer()) -> binary(). +-spec texts_to_binary(kz_types:xml_texts()) -> binary(). +-spec texts_to_binary(kz_types:xml_texts(), pos_integer()) -> binary(). texts_to_binary([]) -> <<>>; texts_to_binary([_|_]=Vs) -> lists:foldl(fun(C, B) -> @@ -42,17 +42,17 @@ texts_to_binary(Vs, Size) when is_list(Vs), is_integer(Size), Size > 0 -> 'false' -> B end. --spec attributes_to_proplist(xml_attribs()) -> kz_proplist(). +-spec attributes_to_proplist(kz_types:xml_attribs()) -> kz_term:proplist(). attributes_to_proplist(L) -> [{K, V} || #xmlAttribute{name=K, value=V} <- L]. --spec filter_empty_text(xml_els() | xml_texts()) -> xml_els() | xml_texts(). +-spec filter_empty_text(kz_types:xml_els() | kz_types:xml_texts()) -> kz_types:xml_els() | kz_types:xml_texts(). filter_empty_text([_|_]=Els) -> [El || El <- Els, not is_empty_text(El) ]. --spec is_empty_text(xml_text() | xml_el()) -> boolean(). +-spec is_empty_text(kz_types:xml_text() | kz_types:xml_el()) -> boolean(). is_empty_text(#xmlText{value=" "}) -> 'true'; is_empty_text(_El) -> 'false'. @@ -62,7 +62,7 @@ is_empty_text(_El) -> 'false'. %% Generic helper to get the text value of a XML path %% @end %%-------------------------------------------------------------------- --spec get_value(kz_deeplist(), xml_el() | string()) -> api_binary(). +-spec get_value(kz_term:deeplist(), kz_types:xml_el() | string()) -> kz_term:api_binary(). get_value(Paths, Xml) -> Path = lists:flatten(Paths), try xmerl_xpath:string(Path, Xml) of @@ -76,7 +76,7 @@ get_value(Paths, Xml) -> %% @private --spec extract_values(xml_els()) -> api_binary(). +-spec extract_values(kz_types:xml_els()) -> kz_term:api_binary(). extract_values([]) -> 'undefined'; extract_values(Elements) -> Values = [case Element of diff --git a/core/sup/src/sup.erl b/core/sup/src/sup.erl index 35ce4012b54..d21e717c630 100644 --- a/core/sup/src/sup.erl +++ b/core/sup/src/sup.erl @@ -86,7 +86,7 @@ main(CommandLineArgs, Loops) -> %%% Internals --spec in_kazoo(atom(), module(), atom(), binaries()) -> no_return(). +-spec in_kazoo(atom(), module(), atom(), kz_term:binaries()) -> no_return(). in_kazoo(SUPName, M, F, As) -> kz_util:put_callid(SUPName), lager:notice("~s: ~s ~s ~s", [?MODULE, M, F, kz_util:iolist_join($,, As)]), @@ -108,7 +108,7 @@ print_result(Result, 'false') -> 'error':'badarg' -> stdout("~p", [String]) end. --spec get_target(kz_proplist(), boolean()) -> atom(). +-spec get_target(kz_term:proplist(), boolean()) -> atom(). get_target(Options, Verbose) -> Node = props:get_value('node', Options), Host = get_host(), @@ -124,7 +124,7 @@ get_target(Options, Verbose) -> print_ping_failed(Target, Cookie) end. --spec get_cookie(kz_proplist(), atom()) -> atom(). +-spec get_cookie(kz_term:proplist(), atom()) -> atom(). get_cookie(Options, Node) -> CookieStr = case { props:get_value('cookie', Options, "") @@ -174,7 +174,7 @@ print_invalid_cli_args() -> stderr("Invalid command or wrong number of arguments, please try again", []), halt(1). --spec parse_args(string()) -> {'ok', kz_proplist(), list()}. +-spec parse_args(string()) -> {'ok', kz_term:proplist(), list()}. parse_args(CommandLineArgs) -> case getopt:parse(option_spec_list(), CommandLineArgs) of {'ok', {Options, Args}} when is_list(Options) -> diff --git a/core/webseq/src/webseq.erl b/core/webseq/src/webseq.erl index a49ce1c00a9..74b4416617b 100644 --- a/core/webseq/src/webseq.erl +++ b/core/webseq/src/webseq.erl @@ -24,15 +24,15 @@ -include("webseq.hrl"). --spec what(what()) -> ne_binary(). +-spec what(what()) -> kz_term:ne_binary(). what(B) when is_binary(B) -> B; what(IO) when is_list(IO) -> iolist_to_binary(IO). -define(GPROC_KEY(Type), {'n', 'l', type_key(Type)}). --type type_key() :: {?MODULE, ne_binary() | '_' | '$1'}. +-type type_key() :: {?MODULE, kz_term:ne_binary() | '_' | '$1'}. --spec type_key(diagram_type() | ne_binary() | atom()) -> type_key(). +-spec type_key(diagram_type() | kz_term:ne_binary() | atom()) -> type_key(). type_key({'file', Filename}) -> type_key(Filename); type_key({'file', Name, _Filename}) -> type_key(Name); type_key({'db', Database}) -> type_key(Database); @@ -40,13 +40,13 @@ type_key({'db', Name, _Database}) -> type_key(Name); type_key(<<_/binary>>=Name) -> {?MODULE, Name}; type_key(A) when is_atom(A) -> {?MODULE, A}. --type webseq_srv() :: server_ref() | diagram_type() | ne_binary(). +-type webseq_srv() :: kz_types:server_ref() | diagram_type() | kz_term:ne_binary(). -spec start(diagram_type()) -> - {'ok', server_ref()} | - {'error', 'already_started', server_ref()}. + {'ok', kz_types:server_ref()} | + {'error', 'already_started', kz_types:server_ref()}. start(Type) -> - case server_ref(Type) of + case get_server_ref(Type) of 'undefined' -> start_srv(Type); Pid -> {'error', 'already_started', Pid} end. @@ -65,7 +65,7 @@ stop() -> end. stop(Type) -> - case server_ref(Type) of + case get_server_ref(Type) of 'undefined' -> 'ok'; Pid -> stop_pid([Pid, Type]) end. @@ -90,16 +90,16 @@ running() -> lager:debug("running: ~p", [Running]), [{Pid, Type} || [Pid, Type] <- Running, erlang:is_process_alive(Pid)]. --spec server_ref(webseq_srv()) -> api_pid(). -server_ref(Pid) when is_pid(Pid) -> Pid; -server_ref(Type) -> +-spec get_server_ref(webseq_srv()) -> kz_term:api_pid(). +get_server_ref(Pid) when is_pid(Pid) -> Pid; +get_server_ref(Type) -> try gproc:lookup_value(?GPROC_KEY(Type)) of Pid -> Pid catch _:_ -> 'undefined' end. --spec start_srv(diagram_type()) -> startlink_ret(). +-spec start_srv(diagram_type()) -> kz_types:startlink_ret(). start_srv(Type) -> case webseq_diagram_srv:start(Type) of {'error', _E}=E -> @@ -113,24 +113,24 @@ start_srv(Type) -> -spec title(webseq_srv(), what()) -> 'ok'. title(Srv, Title) -> - gen_server:cast(server_ref(Srv), {'write', "title ~s~n", [what(Title)]}). + gen_server:cast(get_server_ref(Srv), {'write', "title ~s~n", [what(Title)]}). -spec evt(webseq_srv(), who(), who(), what()) -> 'ok'. evt(Ref, From, To, Desc) -> - Srv = server_ref(Ref), + Srv = get_server_ref(Ref), gen_server:cast(Srv, {'write', "~s->~s: ~s~n", [who(Srv, From), who(Srv, To), what(Desc)]}). -spec note(webseq_srv(), who(), 'right' | 'left', what()) -> 'ok'. note(Ref, Who, Dir, Note) -> - Srv = server_ref(Ref), + Srv = get_server_ref(Ref), gen_server:cast(Srv, {'write', "note ~s of ~s: ~s~n", [Dir, who(Srv, Who), what(Note)]}). -spec trunc(webseq_srv()) -> 'ok'. -spec rotate(webseq_srv()) -> 'ok'. -trunc(Srv) -> gen_server:cast(server_ref(Srv), 'trunc'). -rotate(Srv) -> gen_server:cast(server_ref(Srv), 'rotate'). +trunc(Srv) -> gen_server:cast(get_server_ref(Srv), 'trunc'). +rotate(Srv) -> gen_server:cast(get_server_ref(Srv), 'rotate'). --spec process_pid(kz_json:object()) -> ne_binary(). +-spec process_pid(kz_json:object()) -> kz_term:ne_binary(). process_pid(P) -> ProcId = kz_json:get_value(<<"Process-ID">>, P), case re:run(ProcId, <<".*(<.*>)">>, [{'capture', [1], 'binary'}]) of @@ -139,12 +139,12 @@ process_pid(P) -> _ -> ProcId end. --spec reg_who(webseq_srv(), pid(), ne_binary()) -> 'ok'. -reg_who(Srv, P, W) -> gen_server:cast(server_ref(Srv), {'reg_who', P, W}). +-spec reg_who(webseq_srv(), pid(), kz_term:ne_binary()) -> 'ok'. +reg_who(Srv, P, W) -> gen_server:cast(get_server_ref(Srv), {'reg_who', P, W}). --spec who(webseq_srv(), ne_binary() | pid()) -> ne_binary(). +-spec who(webseq_srv(), kz_term:ne_binary() | pid()) -> kz_term:ne_binary(). who(Srv, P) -> - case catch gen_server:call(server_ref(Srv), {'who', P}) of + case catch gen_server:call(get_server_ref(Srv), {'who', P}) of {'EXIT', _} when is_pid(P) -> pid_to_list(P); {'EXIT', _} -> P; 'undefined' when is_pid(P) -> pid_to_list(P); diff --git a/core/webseq/src/webseq.hrl b/core/webseq/src/webseq.hrl index d90c60abfa1..25c4aa9da00 100644 --- a/core/webseq/src/webseq.hrl +++ b/core/webseq/src/webseq.hrl @@ -3,13 +3,13 @@ -include_lib("kazoo_stdlib/include/kz_types.hrl"). -include_lib("kazoo_stdlib/include/kz_log.hrl"). --type diagram_type() :: {'file', Filename::ne_binary()} | - {'file', Name::ne_binary(), Filename::ne_binary()} | - {'db', Database::ne_binary()} | - {'db', Name::ne_binary(), Database::ne_binary()}. +-type diagram_type() :: {'file', Filename::kz_term:ne_binary()} | + {'file', Name::kz_term:ne_binary(), Filename::kz_term:ne_binary()} | + {'db', Database::kz_term:ne_binary()} | + {'db', Name::kz_term:ne_binary(), Database::kz_term:ne_binary()}. --type who() :: pid() | ne_binary(). --type what() :: ne_binary() | iolist(). +-type who() :: pid() | kz_term:ne_binary(). +-type what() :: kz_term:ne_binary() | iolist(). -define(WEBSEQ_HRL, 'true'). -endif. diff --git a/core/webseq/src/webseq_diagram_srv.erl b/core/webseq/src/webseq_diagram_srv.erl index 61cbb36ea70..11a4bd0697a 100644 --- a/core/webseq/src/webseq_diagram_srv.erl +++ b/core/webseq/src/webseq_diagram_srv.erl @@ -32,39 +32,39 @@ -include("webseq.hrl"). -record(state, {type :: diagram_type() - ,name :: ne_binary() + ,name :: kz_term:ne_binary() ,io_device :: 'undefined' | file:io_device() ,who_registry :: dict:dict() }). -type state() :: #state{}. --spec start(diagram_type()) -> startlink_ret(). +-spec start(diagram_type()) -> kz_types:startlink_ret(). start(Type) -> gen_server:start(?MODULE, [Type], []). --spec stop(server_ref()) -> 'ok'. +-spec stop(kz_types:server_ref()) -> 'ok'. stop(Pid) -> gen_server:call(Pid, 'stop'). --spec title(server_ref(), what()) -> 'ok'. +-spec title(kz_types:server_ref(), what()) -> 'ok'. title(Srv, Title) -> gen_server:cast(Srv, {'write', "title ~s~n", [what(Title)]}). --spec evt(server_ref(), who(), who(), what()) -> 'ok'. +-spec evt(kz_types:server_ref(), who(), who(), what()) -> 'ok'. evt(Srv, From, To, Desc) -> gen_server:cast(Srv, {'write', "~s->~s: ~s~n", [who(Srv, From), who(Srv, To), what(Desc)]}). --spec note(server_ref(), who(), 'right' | 'left', what()) -> 'ok'. +-spec note(kz_types:server_ref(), who(), 'right' | 'left', what()) -> 'ok'. note(Srv, Who, Dir, Note) -> gen_server:cast(Srv, {'write', "note ~s of ~s: ~s~n", [Dir, who(Srv, Who), what(Note)]}). --spec trunc(server_ref()) -> 'ok'. +-spec trunc(kz_types:server_ref()) -> 'ok'. trunc(Srv) -> gen_server:cast(Srv, 'trunc'). --spec rotate(server_ref()) -> 'ok'. +-spec rotate(kz_types:server_ref()) -> 'ok'. rotate(Srv) -> gen_server:cast(Srv, 'rotate'). --spec process_pid(kz_json:object()) -> api_binary(). +-spec process_pid(kz_json:object()) -> kz_term:api_binary(). process_pid(P) -> ProcId = kz_json:get_value(<<"Process-ID">>, P), case re:run(ProcId, <<".*(<.*>)">>, [{'capture', [1], 'binary'}]) of @@ -73,10 +73,10 @@ process_pid(P) -> _ -> ProcId end. --spec reg_who(server_ref(), pid(), ne_binary()) -> 'ok'. +-spec reg_who(kz_types:server_ref(), pid(), kz_term:ne_binary()) -> 'ok'. reg_who(Srv, P, W) -> gen_server:cast(Srv, {'reg_who', P, W}). --spec who(server_ref(), ne_binary() | pid()) -> ne_binary(). +-spec who(kz_types:server_ref(), kz_term:ne_binary() | pid()) -> kz_term:ne_binary(). who(Srv, P) -> case catch gen_server:call(Srv, {'who', P}) of {'EXIT', _} when is_pid(P) -> kz_term:to_binary(pid_to_list(P)); @@ -86,7 +86,7 @@ who(Srv, P) -> W -> W end. --spec what(what()) -> ne_binary(). +-spec what(what()) -> kz_term:ne_binary(). what(B) when is_binary(B) -> B; what(IO) when is_list(IO) -> iolist_to_binary(IO). @@ -157,7 +157,7 @@ init({'db', Name, Database}=Type) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_call(any(), pid_ref(), state()) -> handle_call_ret_state(state()). +-spec handle_call(any(), kz_term:pid_ref(), state()) -> kz_types:handle_call_ret_state(state()). handle_call('stop', _, State) -> {'stop', 'normal', 'ok', State}; handle_call({'who', P}, _, #state{who_registry=Who}=State) when is_pid(P) -> @@ -184,7 +184,7 @@ handle_call(_,_,S) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_cast(any(), state()) -> handle_cast_ret_state(state()). +-spec handle_cast(any(), state()) -> kz_types:handle_cast_ret_state(state()). handle_cast({'write', Str, Args}, #state{type={'file', _Name, _Filename} ,io_device=IO }=State) -> @@ -231,7 +231,7 @@ handle_cast(_Msg, S) -> %% {stop, Reason, State} %% @end %%-------------------------------------------------------------------- --spec handle_info(any(), state()) -> handle_info_ret_state(state()). +-spec handle_info(any(), state()) -> kz_types:handle_info_ret_state(state()). handle_info(_Info, S) -> lager:debug("unhandled message: ~p", [_Info]), {'noreply', S}. @@ -268,14 +268,14 @@ terminate(_Reason, #state{io_device=IO}) -> gproc:goodbye(), lager:debug("webseq terminating: ~p", [_Reason]). --spec webseq_doc(ne_binary(), text(), text()) -> kz_json:object(). +-spec webseq_doc(kz_term:ne_binary(), kz_term:text(), kz_term:text()) -> kz_json:object(). webseq_doc(Name, Str, Args) -> Line = iolist_to_binary(io_lib:format(Str, Args)), kz_json:from_list([{<<"line">>, Line} ,{<<"name">>, Name} ]). --spec write_to_db(ne_binary(), ne_binary(), text(), text()) -> 'ok'. +-spec write_to_db(kz_term:ne_binary(), kz_term:ne_binary(), kz_term:text(), kz_term:text()) -> 'ok'. write_to_db(Database, Name, Str, Args) -> Doc = kz_doc:update_pvt_parameters( webseq_doc(Name, Str, Args) @@ -289,14 +289,14 @@ write_to_db(Database, Name, Str, Args) -> throw(E) end. --spec start_file(ne_binary()) -> +-spec start_file(kz_term:ne_binary()) -> {'ok', file:io_device()} | {'error', any()}. start_file(Filename) -> _ = file:rename(Filename, iolist_to_binary([Filename, ".", kz_term:to_binary(kz_time:now_s())])), file:open(Filename, ['append', 'raw', 'delayed_write']). --spec trunc_database(ne_binary(), ne_binary()) -> 'ok'. +-spec trunc_database(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. trunc_database(Database, Name) -> case get_docs_by_name(Database, Name) of {'ok', []} -> 'ok'; @@ -312,7 +312,7 @@ trunc_database(Database, Name) -> throw(E) end. --spec get_docs_by_name(ne_binary(), ne_binary()) -> +-spec get_docs_by_name(kz_term:ne_binary(), kz_term:ne_binary()) -> {'ok', kz_json:objects()} | {'error', any()}. get_docs_by_name(Database, Name) -> @@ -321,7 +321,7 @@ get_docs_by_name(Database, Name, Opts) -> Options = props:insert_value('key', Name, Opts), kz_datamgr:get_results(Database, <<"webseq/listing_by_name">>, Options). --spec rotate_db(ne_binary(), ne_binary()) -> 'ok'. +-spec rotate_db(kz_term:ne_binary(), kz_term:ne_binary()) -> 'ok'. rotate_db(Database, Name) -> case get_docs_by_name(Database, Name, ['include_docs']) of {'ok', []} -> 'ok'; @@ -336,19 +336,19 @@ rotate_db(Database, Name) -> throw(E) end. --spec rotate_db(ne_binary(), ne_binary(), kz_json:objects()) -> {'ok', kz_json:objects()}. +-spec rotate_db(kz_term:ne_binary(), kz_term:ne_binary(), kz_json:objects()) -> {'ok', kz_json:objects()}. rotate_db(Database, Name, Docs) -> RotatedName = <>, Rotated = [rotate_doc(RotatedName, kz_json:get_value(<<"doc">>, Doc)) || Doc <- Docs], {'ok', _} = kz_datamgr:save_docs(Database, Rotated). --spec rotate_doc(ne_binary(), kz_json:object()) -> kz_json:object(). +-spec rotate_doc(kz_term:ne_binary(), kz_json:object()) -> kz_json:object(). rotate_doc(RotatedName, Doc) -> kz_json:set_value(<<"name">>, RotatedName ,kz_doc:update_pvt_parameters(Doc, 'undefined') ). --spec init_db(ne_binary()) -> 'ok'. +-spec init_db(kz_term:ne_binary()) -> 'ok'. init_db(Database) -> lager:debug("refreshing ~s", [Database]), Views = kapps_util:get_views_json('webseq', "views"), diff --git a/scripts/check-dialyzer.escript b/scripts/check-dialyzer.escript index 9f51618ee9c..1d7931441fc 100755 --- a/scripts/check-dialyzer.escript +++ b/scripts/check-dialyzer.escript @@ -128,7 +128,12 @@ do_warn_path({'beams', Beams}, {N, PLT}) -> do_warn_path({'app', Beams}, {N, PLT}) -> {N + scan_and_print(PLT, Beams), PLT}. -scan_and_print(PLT, Beams) -> +scan_and_print(PLT, Bs) -> + %% explicitly adding `kz_types' so dialyzer knows about `sup_init_ret', `handle_call_ret_state' and other supervisor, + %% gen_server, ... critical types defined in `kz_types'. Dialyzer is strict about types for these `init', `handle_*' + %% functions and if we don't add `kz_types' here, dialyzer thinks their types are `any()' and will warn about it. + Beams = Bs ++ [fix_path("core/kazoo_stdlib/ebin/kz_types.beam")], + io:format("scanning ~s~n", [string:join(Beams, " ")]), length([print(W) || W <- scan(PLT, Beams), diff --git a/scripts/dialyze-changed.bash b/scripts/dialyze-changed.bash index 24382a4ce7a..30a61be1420 100755 --- a/scripts/dialyze-changed.bash +++ b/scripts/dialyze-changed.bash @@ -27,6 +27,7 @@ for ERL in $ERL_FILES; do fi done +BEAM_FILES+=("core/kazoo_stdlib/ebin/kz_types.beam") ARGS=${BEAM_FILES[@]} echo "dialyzing changed files(${#BEAM_FILES[@]}):" dialyzer --plt .kazoo.plt $MOD_BEAM $ARGS $@ diff --git a/scripts/dialyze-usage.bash b/scripts/dialyze-usage.bash index d0f291b3424..0c9612a83fc 100755 --- a/scripts/dialyze-usage.bash +++ b/scripts/dialyze-usage.bash @@ -2,6 +2,10 @@ ## give a module name, grep the codebase for calls to that module ## create a list of beam files and feed it to dialyzer + +pushd $(dirname $0) > /dev/null +cd $(pwd -P)/.. + MODULE=$1 ERL_FILES=$(grep -rl "$1:" {core,applications} --include "*.erl" --exclude="\*pqc.erl" | grep -v "test/") MOD_BEAM=$(find {core,applications} -name "$MODULE.beam") @@ -20,6 +24,9 @@ done shift +BEAM_FILES+=("core/kazoo_stdlib/ebin/kz_types.beam") ARGS=${BEAM_FILES[@]} echo "dialyzing usages of $MODULE" dialyzer --plt .kazoo.plt $MOD_BEAM $ARGS $@ + +popd > /dev/null diff --git a/scripts/kz_diaspora.bash b/scripts/kz_diaspora.bash index 1232661faeb..a990a9f4fa8 100755 --- a/scripts/kz_diaspora.bash +++ b/scripts/kz_diaspora.bash @@ -277,6 +277,179 @@ dedupe() { replace kapps_util get_event_type kz_util get_event_type } +replace_types() { + local MODULE="$1" + local GREP_PATTERN="$2" + local SED_PATTERN="$3" + local REPLACE_TO="$4" + for FILE in `grep -Elr --include=*.erl --include=*.hrl --include=*.escript --exclude="$MODULE.erl" "$GREP_PATTERN" "$ROOT"/{core,applications,scripts}`; do + sed -ri "s/$SED_PATTERN/$REPLACE_TO/g" "$FILE" + done +} + +change_to_module_type() { + local MODULE="$1" + declare -a TYPES_ARR=("${!2}") + + local TYPES="$(echo -n ${TYPES_ARR[@]} | sed -r 's/ +/\|/g; s/\|*$//g')" + + local GREP_PATTERN="(:{0}(:{2})|([ ,([{>]))($TYPES) *\\(" + local SED_PATTERN="(:{0}(:{2})|([ ,([{>]))($TYPES)(\(\)|\(([a-zA-Z_]|\[\])+\(?\))" + local REPLACE_TO="\1$MODULE:\4\5" + + replace_types "$MODULE" "$GREP_PATTERN" "$SED_PATTERN" "$REPLACE_TO" +} + +change_kz_node_to_module_type() { + local GREP_PATTERN="(:{0}(:{2})|([ ,([{>]))(kz_node kz_nodes) *\\(" + local SED_PATTERN="(:{0}(:{2})|([ ,([{>]))(kz_node kz_nodes)\s*(\(\))" + + replace_types "kz_types" "$GREP_PATTERN" "$SED_PATTERN" "\1kz_types:\4\5" +} + +change_kz_timeout() { + local GREP_PATTERN="kz_timeout" + local SED_PATTERN="kz_timeout" + + replace_types "kz_types" "$GREP_PATTERN" "$SED_PATTERN" "timeout" +} + +removing_kz_prefix_from_types() { + local MODULE="$1" + declare -a TYPES=("${!2}") + + K_TYPES="$(echo -n ${TYPES[@]} | grep -Eo 'kz_[a-z_]+' | tr '\n' ' ' | sed -r 's/ +/\|/g; s/\|*$//g')" + WITHOUT_K="$(echo -n $K_TYPES | sed 's/kz_//g')" + + local GREP_PATTERN="$MODULE:$K_TYPES" + local SED_PATTERN="$MODULE:kz_($WITHOUT_K)" + local REPLACE_TO="$MODULE:\1" + + replace_types "$MODULE" "$GREP_PATTERN" "$SED_PATTERN" "$REPLACE_TO" +} + +kz_type_modules() { + local kz_types=(mail_message_body + dict + kz_ip_list + sup_child_spec + sup_child_specs + sup_start_flags + sup_init_ret + sup_child_id + sup_startchild_err + sup_startchild_ret + startlink_err + startlink_ret + startapp_ret + call_from + gen_server_timeout + handle_call_ret + handle_call_ret_state + handle_cast_ret + handle_cast_ret_state + handle_info_ret + handle_info_ret_state + handle_fsm_ret + handle_sync_event_ret + server_ref + gen_server_name + gen_server_option + gen_server_options + xml_attrib_name + xml_attrib_value + xml_attrib + xml_attribs + xml_el + xml_els + xml_text + xml_texts + xml_thing + xml_things + whapp_info + kapps_info + media_server + media_serve + ) + local kz_term=(text + atoms + pids + references + kz_proplist_key + kz_proplist_value + kz_proplist_property + kz_proplist + kz_proplists + kz_proplist_kv + pid_ref + pid_refs + api_pid_ref + api_pid_refs + api_terms + api_binary + api_ne_binary + api_ne_binaries + api_binaries + api_object + api_objects + api_boolean + api_atom + api_atoms + api_string + api_reference + api_pid + api_list + api_number + api_integer + api_pos_integer + api_non_neg_integer + api_float + kz_deeplist + kz_std_return + kz_jobj_return + kz_jobjs_return + ne_binary + ne_binaries + binaries + strings + integers + functions + ) + local kz_time=(kz_now + kz_year + kz_month + kz_day + kz_hour + kz_minute + kz_second + kz_daynum + kz_weeknum + kz_date + kz_time + kz_datetime + kz_iso_week + gregorian_seconds + unix_seconds + api_seconds + ) + echo " * ensuring core types migration" + change_to_module_type "kz_types" kz_types[@] + echo " * ensuring term types migration" + change_to_module_type "kz_term" kz_term[@] + echo " * ensuring time types migration" + change_to_module_type "kz_time" kz_time[@] + echo " * manually checking kz_node types" + change_kz_node_to_module_type + echo " * using built in kz_timeout type" + change_kz_timeout + echo " * removing kz_ prefix from kz_types" + removing_kz_prefix_from_types "kz_types" kz_types[@] + echo " * removing kz_ prefix from kz_term" + removing_kz_prefix_from_types "kz_term" kz_term[@] + echo " * removing kz_ prefix from kz_time" + removing_kz_prefix_from_types "kz_time" kz_time[@] +} + echo "ensuring kz_term is used" kz_util_to_term echo "ensuring kz_binary is used" @@ -299,5 +472,7 @@ echo "ensuring includes from kazoo are moved to kazoo_stdlib" kz_includes echo 'ensuring utility calls are not duplicated all over the place' dedupe +echo "ensuring kz_types migration to module is performed" +kz_type_modules popd >/dev/null