Class: Zavudev::Resources::Senders::Telegram

Inherits:
Object
  • Object
show all
Defined in:
lib/zavudev/resources/senders/telegram.rb,
sig/zavudev/resources/senders/telegram.rbs

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Telegram

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Telegram.

Parameters:



55
56
57
# File 'lib/zavudev/resources/senders/telegram.rb', line 55

def initialize(client:)
  @client = client
end

Instance Method Details

#connect(sender_id, bot_token:, request_options: {}) ⇒ Zavudev::Models::Senders::TelegramConnectResponse

Connect a Telegram bot to a sender. Provide the bot token from @BotFather; Zavu validates it, registers the webhook, and routes the sender's Telegram messages through it.

Parameters:

  • sender_id (String)
  • bot_token (String) —

    Bot token from @BotFather.

  • request_options (Zavudev::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



22
23
24
25
26
27
28
29
30
31
# File 'lib/zavudev/resources/senders/telegram.rb', line 22

def connect(sender_id, params)
  parsed, options = Zavudev::Senders::TelegramConnectParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v1/senders/%1$s/telegram", sender_id],
    body: parsed,
    model: Zavudev::Models::Senders::TelegramConnectResponse,
    options: options
  )
end

#disconnect(sender_id, request_options: {}) ⇒ nil

Disconnect Telegram from a sender and remove the webhook.

Parameters:

Returns:

  • (nil)

See Also:



43
44
45
46
47
48
49
50
# File 'lib/zavudev/resources/senders/telegram.rb', line 43

def disconnect(sender_id, params = {})
  @client.request(
    method: :delete,
    path: ["v1/senders/%1$s/telegram", sender_id],
    model: NilClass,
    options: params[:request_options]
  )
end