Gets a license provider based on api type or version
@param {String} poolName                 - The name of the license pool
@param {Object} options                  - Options
@param {Boolean} options.autoApiType     - Automatically determine API type rather
than basing on BIG-IQ version.
@param {Boolean} [options.noUnreachable] - Do not use the unreachable API even on BIG-IQs that support it.
function getLicenseProvider(poolName, options) {
    const methodOptions = {};
    Object.assign(methodOptions, options);
    const factoryOptions = {};
    Object.assign(factoryOptions, this.constructorOptions);

    let licenseProvider;

    if (methodOptions.autoApiType) {
        return getApiType.call(this, poolName, methodOptions)
            .then((apiType) => {
                // Even though the main API by type is the same across BIG-IQ versions,
                // there are some subtle differences the implementations need to know
                // about
                factoryOptions.version = this.version;
                try {
                    licenseProvider = bigIqLicenseProviderFactory.getLicenseProviderByType(
                        apiType,
                        this.bigIp,
                        factoryOptions
                    );
                    return q(licenseProvider);
                } catch (err) {
                    this.logger.info(
                        'Error getting license provider by type', err && err.message ? err.message : err
                    );
                    return q.reject(err);
                }
            })
            .catch((err) => {
                this.logger.info('Error getting api type', err && err.message ? err.message : err);
                return q.reject(err);
            });
    }

    try {
        licenseProvider = bigIqLicenseProviderFactory.getLicenseProviderByVersion(
            this.version,
            this.bigIp,
            factoryOptions
        );

        return q(licenseProvider);
    } catch (err) {
        this.logger.info(
            'Error getting license provider by type', err && err.message ? err.message : err
        );
        return q.reject(err);
    }
}