yagop / node-telegram-bot-api

Telegram Bot API for NodeJS
MIT License
8.12k stars 1.49k forks source link

add getStarTransactions from Bot API 7.5 #1205

Open imedfan opened 2 weeks ago

imedfan commented 2 weeks ago

Feature Request

This code adds getStarTransactions method and required type (https://core.telegram.org/bots/api#getstartransactions)

src/telegram.js

  /**
   * Use this method to get the bot's Telegram Star transactions.
   * On success, returns a [StarTransactions](https://core.telegram.org/bots/api#startransactions) object.
   * @param  {Object} [options] Additional Telegram query options
   * @return {Promise}
   * @see https://core.telegram.org/bots/api#startransactions
   */
  getStarTransactions(form = {}) {
      return this._request('getStarTransactions', { form });
  }

test/telegram.js

  describe('#getStarTransactions', function getStarTransactions() {
    before(function before() {
      utils.handleRatelimit(bot, 'getStarTransactions', this);
    });
    it('should return StarTransactions object', function test() {
      return bot.getWebHookInfo().then(resp => {
        assert.ok(is.object(resp));
      });
    });
  });

type definitions index.d.ts (https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node-telegram-bot-api)

  interface StarTransaction {
        id: string;
        amount: number;
        date: number;
    }

 getStarTransactions(): Promise<TelegramBot.StarTransaction[]>;