Sha256: 50821c1db3fe401c80989968bdc68b35083b1574e95ca254175bb766be21b7c4

Contents?: true

Size: 523 Bytes

Versions: 2

Compression:

Stored size: 523 Bytes

Contents

module Bobot
  class Postback
    def self.perform(event)
      payload = event.payload
      begin
        payload = ActiveSupport::JSON.decode(payload)
        step    = payload["step"]
        params  = payload["params"].hash
      rescue ::ActiveSupport::JSON.parse_error
        step    = payload.to_sym
        params  = nil
      end

      bot = Postback.new(event)
      if bot.respond_to?(step)
        bot.public_send(*([step, params].compact))
      else
        bot.unknown_payload
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bobot-1.0.53 lib/generators/bobot/templates/app/bobot/postback.rb
bobot-1.0.52 lib/generators/bobot/templates/app/bobot/postback.rb