Sha256: c035750c462688aedd9f6346541695479d04e24cf1da2da401655f300aa4ab38

Contents?: true

Size: 801 Bytes

Versions: 1

Compression:

Stored size: 801 Bytes

Contents

module Lita
  module Adapters
    class RingCentral < Adapter
      class Callback
        attr_reader :robot

        def initialize(robot)
          @robot = robot
        end

        def create_user(user_data)
          User.create user_data['phoneNumber']
        end

        def update(message)
          Lita.logger.info 'Processing RingCentral Message'
          user_phone_number = message['body']['from']['phoneNumber']
          user = Lita::User.find_by_name user_phone_number
          user = create_user(message['body']['from']) unless user
          source = Lita::Source.new user: user, room: user_phone_number
          post = message['body']['subject'].to_s
          msg = Lita::Message.new @robot, post, source
          @robot.receive msg
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lita-ringcentral-0.0.1 lib/lita/adapters/ringcentral/callback.rb