module IftttPush

Attributes

configuration[RW]

Public Class Methods

configure() { |configuration| ... } click to toggle source
# File lib/ifttt_push.rb, line 9
def configure
  self.configuration ||= Configuration.new
  yield(configuration)
end
notify(title:, message:, link_url:) click to toggle source
# File lib/ifttt_push.rb, line 14
def notify(title:, message:, link_url:)
  body = {
    value1: title,
    value2: message,
    value3: link_url
  }

  uri = URI.parse('https://maker.ifttt.com:80/trigger/push_notification/with/key/' + self.configuration.key)
  http = Net::HTTP.new(uri.host, uri.port)

  http.post(uri.path, body.to_json, "Content-Type" => "application/json")
end