Module: Iftttify::ActAsIFTTT::ClassMethods

Defined in:
lib/iftttify/iftttify.rb

Instance Method Summary collapse

Instance Method Details

#iftttify(method, options = {}) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/iftttify/iftttify.rb', line 52

def iftttify(method, options = {})
  send(:define_method, method) do
    begin
      response = Iftttify.process request, options do |post|
        send(options[:with], post)
      end

      render text: "<?xml version=\"1.0\"?><methodResponse><params><param><value>#{response}</value></param></params></methodResponse>", content_type: 'text/xml'
    rescue Iftttify::Exceptions::InvalidCredential => e
      render text: 'invalid credential', status: :unauthorized
    end
  end
end