class IFTTT::Profile

Public Class Methods

new(key) click to toggle source
# File lib/ifttt.rb, line 7
def initialize(key)
    @key=key
end

Public Instance Methods

get(event) click to toggle source
# File lib/ifttt.rb, line 10
def get(event)
    return Net::HTTP.get(URI("https://maker.ifttt.com/trigger/#{event}/with/key/#{@key}"))
end
post(event,array=[]) click to toggle source
# File lib/ifttt.rb, line 13
def post(event,array=[])
    hash=Hash.new
    if array!=nil 
        for i in 0...array.size
            hash["value#{i+1}"]=array[i]
        end
    end
    uri = URI("https://maker.ifttt.com/trigger/#{event}/with/key/#{@key}")
    req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
    req.body = hash.to_json
    res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') do |http|
        http.request(req)
    end
end