class Ozonetel::Outbound::Call
Public Class Methods
connect(params={})
click to toggle source
# File lib/ozonetel/outbound/call.rb, line 11 def self.connect(params={}) self.new.connect(params) end
new()
click to toggle source
# File lib/ozonetel/outbound/call.rb, line 9 def initialize; end
Public Instance Methods
connect(params={})
click to toggle source
# File lib/ozonetel/outbound/call.rb, line 15 def connect(params={}) params = params.merge(configuration) if valid?(params) response = self.class.get(URI.escape("?#{transform_params(params)}")) handle_response(response) end end
Protected Instance Methods
configuration()
click to toggle source
# File lib/ozonetel/outbound/call.rb, line 40 def configuration {:outbound_version => Ozonetel.outbound_version, :api_key => Ozonetel.api_key} end
handle_response(response)
click to toggle source
# File lib/ozonetel/outbound/call.rb, line 44 def handle_response(response) case response.code.to_i when 200...300 then Ozonetel::Response.new(response) when 401 then raise Ozonetel::AuthenticationError, response.body when 403 then Ozonetel::Response.new(response) else raise Ozonetel::UnexpectedError, response.body end end
transform_params(params)
click to toggle source
# File lib/ozonetel/outbound/call.rb, line 34 def transform_params(params) transformed_params = [] params.each do |k,v| transformed_params << "#{k}=#{v}" end transformed_params.join('&') end
valid?(params)
click to toggle source
# File lib/ozonetel/outbound/call.rb, line 25 def valid?(params) mandatory_keys = [:phone_no, :api_key] unless mandatory_keys.all?{|key| params.keys.include?(key)} raise Ozonetel::ParamsError, "#{key} parameter missing." else return true end end