Module: IftttPush

Defined in:
lib/ifttt_push.rb,
lib/ifttt_push/configuration.rb

Defined Under Namespace

Classes: Configuration

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject

Returns the value of attribute configuration.



7
8
9
# File 'lib/ifttt_push.rb', line 7

def configuration
  @configuration
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Yields:



9
10
11
12
# File 'lib/ifttt_push.rb', line 9

def configure
  self.configuration ||= Configuration.new
  yield(configuration)
end

.notify(title:, message:, link_url:) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# 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