class ServicesNumberingConfig {
  constructor(application, resourceID) {
    this._application = application;
    this._resourceID = resourceID;
  }
  async getResourceID() {
    if (!this._resourceID) {
      this._resourceID = await this._application.getResourceID();
    }
    return this._resourceID;
  }
  async getConfig(entityName) {
    const serviceName = "DynaformBuilder.getNumberConfig";
    const response = await this._application.callServiceBroker(serviceName, {
      paramsConfig: {
        resourceID: await this.getResourceID(),
        entityName
      }
    });
    return {
      isAutoNumbering: response.config.isAutoNum === "true",
      initialNumber: Number(response.config.numeroInicial)
    };
  }
  async saveConfig(payload) {
    const serviceName = "DynaformBuilder.saveNumberConfig";
    return this._application.callServiceBroker(serviceName, {
      paramsConfig: Object.assign({ resourceID: await this.getResourceID() }, payload)
    });
  }
}

export { ServicesNumberingConfig as S };
