Generate random integers

    :param api_key: The Random.org api key.
    :param api_version: The Random.org api version.
    :param number: The number of integers to generate
    :param minimum: The lower boundary for the range from which the
                    random numbers will be picked. Must be within
                    the [-1e9,1e9] range.
    :param maximum: The upper boundary for the range from which the
                    random numbers will be picked. Must be within
                    the [-1e9,1e9] range.
    :param replacement: Specifies whether the random numbers should
                        be picked with replacement. The default (true)
                        will cause the numbers to be picked with replacement,
                        i.e., the resulting numbers may contain duplicate
                        values (like a series of dice rolls). If you want the
                        numbers picked to be unique (like raffle tickets drawn
                        from a container), set this value to false.
    :param base: Specifies the base that will be used to display the numbers.
                 Values allowed are 2, 8, 10 and 16. This affects the JSON
                 types and formatting of the resulting data as discussed below.
    :return: A list of integers.

    CLI Example:

    .. code-block:: bash

        salt '*' random_org.generateIntegers number=5 minimum=1 maximum=6

        salt '*' random_org.generateIntegers number=5 minimum=2 maximum=255 base=2

def generateIntegers(api_key=None,
                     api_version=None,
                     **kwargs):
    '''
    Generate random integers

    :param api_key: The Random.org api key.
    :param api_version: The Random.org api version.
    :param number: The number of integers to generate
    :param minimum: The lower boundary for the range from which the
                    random numbers will be picked. Must be within
                    the [-1e9,1e9] range.
    :param maximum: The upper boundary for the range from which the
                    random numbers will be picked. Must be within
                    the [-1e9,1e9] range.
    :param replacement: Specifies whether the random numbers should
                        be picked with replacement. The default (true)
                        will cause the numbers to be picked with replacement,
                        i.e., the resulting numbers may contain duplicate
                        values (like a series of dice rolls). If you want the
                        numbers picked to be unique (like raffle tickets drawn
                        from a container), set this value to false.
    :param base: Specifies the base that will be used to display the numbers.
                 Values allowed are 2, 8, 10 and 16. This affects the JSON
                 types and formatting of the resulting data as discussed below.
    :return: A list of integers.

    CLI Example:

    .. code-block:: bash

        salt '*' random_org.generateIntegers number=5 minimum=1 maximum=6

        salt '*' random_org.generateIntegers number=5 minimum=2 maximum=255 base=2

    '''
    ret = {'res': True}

    if not api_key or not api_version:
        try:
            options = __salt__['config.option']('random_org')
            if not api_key:
                api_key = options.get('api_key')
            if not api_version:
                api_version = options.get('api_version')
        except (NameError, KeyError, AttributeError):
            log.error('No Random.org api key found.')
            ret['message'] = 'No Random.org api key or api version found.'
            ret['res'] = False
            return ret

    for item in ['number', 'minimum', 'maximum']:
        if item not in kwargs:
            ret['res'] = False
            ret['message'] = 'Rquired argument, {0} is missing.'.format(item)
            return ret

    if not _numeric(kwargs['number']) or not 1 <= kwargs['number'] <= 10000:
        ret['res'] = False
        ret['message'] = 'Number of integers must be between 1 and 10000'
        return ret

    if not _numeric(kwargs['minimum']) or not -1000000000 <= kwargs['minimum'] <= 1000000000:
        ret['res'] = False
        ret['message'] = 'Minimum argument must be between -1,000,000,000 and 1,000,000,000'
        return ret

    if not _numeric(kwargs['maximum']) or not -1000000000 <= kwargs['maximum'] <= 1000000000:
        ret['res'] = False
        ret['message'] = 'Maximum argument must be between -1,000,000,000 and 1,000,000,000'
        return ret

    if 'base' in kwargs:
        base = kwargs['base']
        if base not in [2, 8, 10, 16]:
            ret['res'] = False
            ret['message'] = 'Base must be either 2, 8, 10 or 16.'
            return ret
    else:
        base = 10

    if 'replacement' not in kwargs:
        replacement = True
    else:
        replacement = kwargs['replacement']

    if isinstance(api_version, int):
        api_version = six.text_type(api_version)

    _function = RANDOM_ORG_FUNCTIONS.get(api_version).get('generateIntegers').get('method')
    data = {}
    data['id'] = 1911220
    data['jsonrpc'] = '2.0'
    data['method'] = _function
    data['params'] = {'apiKey': api_key,
                      'n': kwargs['number'],
                      'min': kwargs['minimum'],
                      'max': kwargs['maximum'],
                      'replacement': replacement,
                      'base': base
                      }

    result = _query(api_version=api_version, data=data)
    log.debug('result %s', result)
    if result:
        if 'random' in result:
            random_data = result.get('random').get('data')
            ret['data'] = random_data
        else:
            ret['res'] = False
            ret['message'] = result['message']
    else:
        ret['res'] = False
        ret['message'] = result['message']
    return ret