async invoke({
    functionId,
    functionName,
    serviceName,
    accountId = undefined,
    region = undefined,
    invokerContext = '',
    event = '{}',
    invocationType = 'Sync'
  }) {
    if (!functionId && (!serviceName || !functionName)) {
      throw new Error(`Neither Function id nor serviceName/functionName is provided.`);
    }
    if (invocationType !== 'Sync' && invocationType !== 'Async') {
      throw new Error(
        `Incorrect invocationType ${invocationType}. It should be 'Sync' or 'Async'`
      );
    }
    const base64Event = Buffer.from(event).toString('base64');
    const content = {
      InvokeParams: {
        accountId,
        functionId,
        serviceName,
        functionName,
        invocationType,
        regionId: region,
        context: invokerContext,
        payload: base64Event
      }
    };
    const params = JSON.stringify(this._buildParams(content));
    const cookie = await this._login();
    const options = {
      method: 'POST',
      host: 'localhost',
      port: '9999',
      path: '/function_compute/invoke',
      headers: {
        cookie
      },
      agent: this._agent,
      rejectUnauthorized: false
    };

    debug(`Invoking: ${params}.`);

    return new Promise((resolve, reject) => {
      const req = https.request(options, (res) => {
        let raw = '';
        res.on('data', (chunk) => {
          raw += chunk;
        });
        res.on('end', () => {
          debug(`Invoke back: ${raw}.`);
          try {
            let parsed = JSON.parse(raw);
            if (parsed.code === 200) {
              const ret = parsed.data && Buffer.from(parsed.data, 'base64');
              resolve(ret);
            } else {
              reject(new Error(`${parsed.message}`));
            }
          } catch (err) {
            reject(new Error('Server Internal Error'));
          }
        });
      });
      req.on('error', (e) => {
        console.error(`Request to invoke error: ${e}`);
        reject(e);
      });
      req.write(params);
      req.end();
    });
  }
Invoke a function.

@param functionId the id of the function.
@param functionName the name of the function.
@param serviceName the name of the service in which the function is.
@param accountId the id of the account to which the function belongs.
@param region the region of the function.
@param invokerContext the invoker context, which can be used to provide additional
                      information about invoker.
@param event the event that would be passed to the function.
@param invocationType the type of the invocation. Can be 'Sync' or 'Async'.
@param timeout the maximum time to return. Default is 70.
@returns {Promise}