1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/app/interactors/send_telegram_message.rb

27 lines
453 B
Ruby
Raw Normal View History

2019-09-06 15:00:01 -04:00
# frozen_string_literal: true
class SendTelegramMessage
include Interactor
BASE_URL = 'https://api.telegram.org'
def url
@url ||= [
BASE_URL,
'/bot',
Rails.application.credentials.telegram_bot_api_token,
'/sendMessage',
].join.freeze
end
def call
RestClient.post(
url,
chat_id: context.chat_id,
text: context.text,
)
rescue RuntimeError => e
context.fail! error: e
end
end