class PushMore
Constants
- WEBHOOK_BASE_URL
Send notifcations to Telegram through PushMore.io
Example:
>> PushMore.new("hello world!", key: "foobar123").deliver => true
Arguments:
body: (String) key: (String)
Public Class Methods
configuration()
click to toggle source
# File lib/push_more.rb, line 7 def self.configuration @configuration ||= OpenStruct.new end
configure() { |configuration| ... }
click to toggle source
# File lib/push_more.rb, line 11 def self.configure yield(configuration) end
new(body, key: nil)
click to toggle source
# File lib/push_more.rb, line 27 def initialize(body, key: nil) @body = body return if PushMore.configuration.enabled == false @key = key || PushMore.configuration.api_key || ENV.fetch("PUSH_MORE_KEY") end
Public Instance Methods
deliver()
click to toggle source
# File lib/push_more.rb, line 35 def deliver return if PushMore.configuration.enabled == false http = Net::HTTP.new(webhook_uri.host, webhook_uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_PEER request = Net::HTTP::Post.new(webhook_uri.request_uri) request.body = @body response = http.request(request) if response.body.include? "Error" raise response.body else true end end
Private Instance Methods
webhook_uri()
click to toggle source
# File lib/push_more.rb, line 56 def webhook_uri URI.parse WEBHOOK_BASE_URL + @key end