class Smartfocus::Notification

Attributes

debug[RW]
debug[RW]

Public Class Methods

new(params = {}) { |self| ... } click to toggle source
# File lib/smartfocus/notification.rb, line 13
def initialize(params = {})
  yield(self) if block_given?

  self.debug ||= params[:debug] || self.class.debug
end

Public Instance Methods

base_uri() click to toggle source

Base uri

# File lib/smartfocus/notification.rb, line 33
def base_uri
  'http://api.notificationmessaging.com/NMSXML'
end
send(body, params = {}) click to toggle source
# File lib/smartfocus/notification.rb, line 19
def send(body, params = {})
  # == Processing body ==
  body_xml = Smartocus::Tools.to_xml_as_is body

  # == Send request ==
  logger.send "#{base_uri} with body : #{body_xml}"
  response = self.class.send :post, base_uri, :body => body_xml
  logger.receive "#{base_uri} with status : #{response.header.inspect}"

  # == Check result ==
  response.header.code == '200'
end

Private Instance Methods

logger() click to toggle source
# File lib/smartfocus/notification.rb, line 39
def logger
  if @logger.nil?
    @logger = Smartocus::Logger.new(STDOUT)
    @logger.level = (debug ? Logger::DEBUG : Logger::WARN)
  end
  @logger
end