%%%-----------------------------------------------------------------------------
%%% @copyright (C) 2010-2019, 2600Hz
%%% @doc Accessors for `device_rate_limits' document.
%%% @end
%%%-----------------------------------------------------------------------------
-module(kzd_device_rate_limits).

-export([new/0]).
-export([per_minute/1, per_minute/2, set_per_minute/2]).
-export([per_minute_invites/1, per_minute_invites/2, set_per_minute_invites/2]).
-export([per_minute_registrations/1, per_minute_registrations/2, set_per_minute_registrations/2]).
-export([per_minute_total_packets/1, per_minute_total_packets/2, set_per_minute_total_packets/2]).
-export([per_second/1, per_second/2, set_per_second/2]).
-export([per_second_invites/1, per_second_invites/2, set_per_second_invites/2]).
-export([per_second_registrations/1, per_second_registrations/2, set_per_second_registrations/2]).
-export([per_second_total_packets/1, per_second_total_packets/2, set_per_second_total_packets/2]).


-include("kz_documents.hrl").

-type doc() :: kz_json:object().
-export_type([doc/0]).

-define(SCHEMA, <<"device_rate_limits">>).

-spec new() -> doc().
new() ->
    kz_json_schema:default_object(?SCHEMA).

-spec per_minute(doc()) -> kz_term:api_object().
per_minute(Doc) ->
    per_minute(Doc, 'undefined').

-spec per_minute(doc(), Default) -> kz_json:object() | Default.
per_minute(Doc, Default) ->
    kz_json:get_json_value([<<"per_minute">>], Doc, Default).

-spec set_per_minute(doc(), kz_json:object()) -> doc().
set_per_minute(Doc, PerMinute) ->
    kz_json:set_value([<<"per_minute">>], PerMinute, Doc).

-spec per_minute_invites(doc()) -> kz_term:api_integer().
per_minute_invites(Doc) ->
    per_minute_invites(Doc, 'undefined').

-spec per_minute_invites(doc(), Default) -> integer() | Default.
per_minute_invites(Doc, Default) ->
    kz_json:get_integer_value([<<"per_minute">>, <<"invites">>], Doc, Default).

-spec set_per_minute_invites(doc(), integer()) -> doc().
set_per_minute_invites(Doc, PerMinuteInvites) ->
    kz_json:set_value([<<"per_minute">>, <<"invites">>], PerMinuteInvites, Doc).

-spec per_minute_registrations(doc()) -> kz_term:api_integer().
per_minute_registrations(Doc) ->
    per_minute_registrations(Doc, 'undefined').

-spec per_minute_registrations(doc(), Default) -> integer() | Default.
per_minute_registrations(Doc, Default) ->
    kz_json:get_integer_value([<<"per_minute">>, <<"registrations">>], Doc, Default).

-spec set_per_minute_registrations(doc(), integer()) -> doc().
set_per_minute_registrations(Doc, PerMinuteRegistrations) ->
    kz_json:set_value([<<"per_minute">>, <<"registrations">>], PerMinuteRegistrations, Doc).

-spec per_minute_total_packets(doc()) -> kz_term:api_integer().
per_minute_total_packets(Doc) ->
    per_minute_total_packets(Doc, 'undefined').

-spec per_minute_total_packets(doc(), Default) -> integer() | Default.
per_minute_total_packets(Doc, Default) ->
    kz_json:get_integer_value([<<"per_minute">>, <<"total_packets">>], Doc, Default).

-spec set_per_minute_total_packets(doc(), integer()) -> doc().
set_per_minute_total_packets(Doc, PerMinuteTotalPackets) ->
    kz_json:set_value([<<"per_minute">>, <<"total_packets">>], PerMinuteTotalPackets, Doc).

-spec per_second(doc()) -> kz_term:api_object().
per_second(Doc) ->
    per_second(Doc, 'undefined').

-spec per_second(doc(), Default) -> kz_json:object() | Default.
per_second(Doc, Default) ->
    kz_json:get_json_value([<<"per_second">>], Doc, Default).

-spec set_per_second(doc(), kz_json:object()) -> doc().
set_per_second(Doc, PerSecond) ->
    kz_json:set_value([<<"per_second">>], PerSecond, Doc).

-spec per_second_invites(doc()) -> kz_term:api_integer().
per_second_invites(Doc) ->
    per_second_invites(Doc, 'undefined').

-spec per_second_invites(doc(), Default) -> integer() | Default.
per_second_invites(Doc, Default) ->
    kz_json:get_integer_value([<<"per_second">>, <<"invites">>], Doc, Default).

-spec set_per_second_invites(doc(), integer()) -> doc().
set_per_second_invites(Doc, PerSecondInvites) ->
    kz_json:set_value([<<"per_second">>, <<"invites">>], PerSecondInvites, Doc).

-spec per_second_registrations(doc()) -> kz_term:api_integer().
per_second_registrations(Doc) ->
    per_second_registrations(Doc, 'undefined').

-spec per_second_registrations(doc(), Default) -> integer() | Default.
per_second_registrations(Doc, Default) ->
    kz_json:get_integer_value([<<"per_second">>, <<"registrations">>], Doc, Default).

-spec set_per_second_registrations(doc(), integer()) -> doc().
set_per_second_registrations(Doc, PerSecondRegistrations) ->
    kz_json:set_value([<<"per_second">>, <<"registrations">>], PerSecondRegistrations, Doc).

-spec per_second_total_packets(doc()) -> kz_term:api_integer().
per_second_total_packets(Doc) ->
    per_second_total_packets(Doc, 'undefined').

-spec per_second_total_packets(doc(), Default) -> integer() | Default.
per_second_total_packets(Doc, Default) ->
    kz_json:get_integer_value([<<"per_second">>, <<"total_packets">>], Doc, Default).

-spec set_per_second_total_packets(doc(), integer()) -> doc().
set_per_second_total_packets(Doc, PerSecondTotalPackets) ->
    kz_json:set_value([<<"per_second">>, <<"total_packets">>], PerSecondTotalPackets, Doc).
