async addLabelToCard()

in src/Worker.ts [357:378]


  async addLabelToCard() {
    const client = await this.kintoneClientCreator.createKintoneClient([
      this.apps.cards.token,
      this.apps.labels.token,
    ]);
    const cardInfo = await this.getRecordIdAndLabelIdsFromCard();
    cardInfo.tableIds.forEach((record) => {
      if (record.value.LABEL_ID.value === this.trelloAction.data.label.id) {
        throw new Error(
          `Label ${this.trelloAction.data.label.name}(${this.trelloAction.data.label.id}) is already exists`
        );
      }
    });

    return ApiExecutor.addLabelToCard(
      client,
      this.apps.cards.id,
      this.trelloAction.data,
      cardInfo.recordId,
      cardInfo.tableIds
    );
  }