Sha256: 1ba058aea54255e8962aa50e1ac9e95a96e0a796beeec7947cec98f65893aec5
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
# -*- coding: utf-8 -*- class Fluent::BoundioOutput < Fluent::Output Fluent::Plugin.register_output('boundio', self) config_param :user_serial_id, :string config_param :user_key, :string, :default => nil # Optional at this time config_param :api_key, :string config_param :default_number, :string config_param :developer_tool, :string, :default => 'no' def initialize super require 'uri' require 'net/https' end def configure(conf) super @developer_tool = Fluent::Config.bool_value(@developer_tool) || false @voice_type = 1 end def emit(tag, es, chain) es.each do |time,record| number = record['number'].nil? ? @default_number : record['number'] call(number, record['message']) end chain.next end def call(number, message) begin https = Net::HTTP.new('boundio.jp', 443) https.use_ssl = true cast = "file_d(#{message}, #{@voice_type})" query = 'key=' + @api_key + '&tel_to=' + number + '&cast=' + cast path = @developer_tool ? '/api/vd2/' : '/api/v2/' response = https.post(path + @user_serial_id + '/call', URI.escape(query)) $log.info "boundio makeing a call: #{path} #{message} " $log.info "boundio call result: #{response.body}" rescue => e $log.error("Boundio Error: #{e.message}") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fluent-plugin-boundio-0.0.2 | lib/fluent/plugin/out_boundio.rb |