Class: PushMore
- Inherits:
-
Object
- Object
- PushMore
- Defined in:
- lib/push_more.rb
Constant Summary collapse
- WEBHOOK_BASE_URL =
Send notifcations to Telegram through PushMore.io
Example:
>> PushMore.new("hello world!", key: "foobar123").deliver => trueArguments:
body: (String) key: (String) "https://pushmore.io/webhook/"
Class Method Summary collapse
Instance Method Summary collapse
- #deliver ⇒ Object
-
#initialize(body, key: nil) ⇒ PushMore
constructor
A new instance of PushMore.
Constructor Details
#initialize(body, key: nil) ⇒ PushMore
Returns a new instance of PushMore.
27 28 29 30 |
# File 'lib/push_more.rb', line 27 def initialize(body, key: nil) @body = body @key = key || PushMore.configuration.api_key || ENV.fetch("PUSH_MORE_KEY") end |
Class Method Details
.configuration ⇒ Object
7 8 9 |
# File 'lib/push_more.rb', line 7 def self.configuration @configuration ||= OpenStruct.new end |
.configure {|configuration| ... } ⇒ Object
11 12 13 |
# File 'lib/push_more.rb', line 11 def self.configure yield(configuration) end |
Instance Method Details
#deliver ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/push_more.rb', line 32 def deliver 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 |