Class: Emailvision::Notification

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/emailvision/notification.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) {|_self| ... } ⇒ Notification

Returns a new instance of Notification.

Yields:

  • (_self)

Yield Parameters:



13
14
15
16
17
# File 'lib/emailvision/notification.rb', line 13

def initialize(params = {})
  yield(self) if block_given?

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

Class Attribute Details

.debugObject

Returns the value of attribute debug.



9
10
11
# File 'lib/emailvision/notification.rb', line 9

def debug
  @debug
end

Instance Attribute Details

#debugObject

Returns the value of attribute debug.



11
12
13
# File 'lib/emailvision/notification.rb', line 11

def debug
  @debug
end

Instance Method Details

#base_uriObject

Base uri



33
34
35
# File 'lib/emailvision/notification.rb', line 33

def base_uri
  'http://api.notificationmessaging.com/NMSXML'
end

#send(body, params = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/emailvision/notification.rb', line 19

def send(body, params = {})
  # == Processing body ==
  body_xml = Emailvision::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