<commit_before>-module(betfair).

-export([start/0,
         make/0,
         get_opts/0,
         prop/1,
         request/2,
         request/3]).

-define(SCOPE, l).
-define(TIMEOUT, 5000). %% TODO: pass in as option


%%------------------------------------------------------------------------------
%% API
%%------------------------------------------------------------------------------

make() ->
    make:all([load]).

start() ->
    application:ensure_all_started(?MODULE).

-spec get_opts() -> list(tuple()).
get_opts() ->
    application:get_all_env(?MODULE).

-spec prop(atom()) -> list().
prop(Name) ->
    proplists:get_value(Name, get_opts()).

-type betfair_sync_response() :: {betfair_response, binary()} | {error, term()}.
-type betfair_async_response() :: ok | {error, term()}.
-type betfair_response() :: betfair_sync_response() | betfair_async_response().

-spec request(atom(), list(tuple())) -> betfair_response().
request(Method, MFilters) ->
    request(Method, MFilters, []).

-spec request(atom(), list(tuple()), list(tuple())) -> betfair_response().
request(Method, MFilters, Opts) ->
    case betfair_rpc:check_filters(MFilters) of
        ok    -> case betfair_rpc:is_valid_method(Method) of
                     true  -> do_request(Method, MFilters, Opts);
                     _     -> {invalid_method, Method}
                 end;
        Error -> {incorrect_filter, Error}
    end.<commit_msg>type refactoring and addition api call<commit_after>-module(betfair).

-export([start/0,
         make/0,
         get_opts/0,
         prop/1,
         request/1,
         request/2,
         request/3]).

-define(SCOPE, l).
-define(TIMEOUT, 5000). %% TODO: pass in as option


%%------------------------------------------------------------------------------
%% API
%%------------------------------------------------------------------------------

make() ->
    make:all([load]).

start() ->
    application:ensure_all_started(?MODULE).

-spec get_opts() -> list(tuple()).
get_opts() ->
    application:get_all_env(?MODULE).

-spec prop(atom()) -> list().
prop(Name) ->
    proplists:get_value(Name, get_opts()).

-type method() :: atom().
-type market_filters() :: list(tuple()).

-type sync_response() :: {betfair_response, binary()} | {error, term()}.
-type async_response() :: ok | {error, term()}.
-type response() :: sync_response() | async_response().

-spec request(method()) -> response().
request(Method) ->
    request(Method, []).

-spec request(method(), market_filters()) -> response().
request(Method, MFilters) ->
    request(Method, MFilters, []).

-spec request(method(), market_filters(), list(tuple())) -> response().
request(Method, MFilters, Opts) ->
    case betfair_rpc:check_filters(MFilters) of
        ok    -> case betfair_rpc:is_valid_method(Method) of
                     true  -> do_request(Method, MFilters, Opts);
                     _     -> {invalid_method, Method}
                 end;
        Error -> {incorrect_filter, Error}
    end.
{'fraction_non_alphanumeric': 0.26373626373626374, 'fraction_numerical': 0.006993006993006993, 'mean_word_length': 1.998003992015968, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5783027', 'n_tokens_mistral': 901, 'n_tokens_neox': 873, 'n_words': 178}