lib/fluent/plugin/out_boundio.rb in fluent-plugin-boundio-0.0.1 vs lib/fluent/plugin/out_boundio.rb in fluent-plugin-boundio-0.0.2
- old
+ new
@@ -1,24 +1,25 @@
# -*- 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 :user_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|
@@ -33,11 +34,12 @@
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
- response = https.post('/api/vd2/' + @user_serial_id + '/call', URI.escape(query))
- $log.info "boundio makeing a call: #{message} "
+ 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