Class: EmailVision::Message

Inherits:
BaseClient show all
Defined in:
lib/email_vision/message.rb

Constant Summary

Constants inherited from BaseClient

BaseClient::SESSION_TIMEOUT

Instance Attribute Summary

Attributes inherited from BaseClient

#options

Instance Method Summary collapse

Methods inherited from BaseClient

#api_namespaced, #check_server_status!, #client, #connect!, #connected?, #connection, #execute, #initialize, #request_without_protection

Constructor Details

This class inherits a constructor from EmailVision::BaseClient

Instance Method Details

#clone(id, new_name) ⇒ Object



25
26
27
# File 'lib/email_vision/message.rb', line 25

def clone(id, new_name)
  execute(:clone_message, :id => id, :new_name => new_name)
end

#create(attributes) ⇒ Object



18
19
20
21
22
23
# File 'lib/email_vision/message.rb', line 18

def create(attributes)
  defaults = { :encoding => "UTF-8" }
  execute(:create_email_message_by_obj, :message => defaults.merge(attributes))
rescue Savon::SOAP::Fault => e
  check_server_status!(e, "CEM_MESSAGE_FAILED") { nil }
end

#delete(id) ⇒ Object



29
30
31
32
33
# File 'lib/email_vision/message.rb', line 29

def delete(id)
  execute(:delete_message, :id => id)
rescue Savon::SOAP::Fault => e
  check_server_status!(e, "GET_MESSAGE_FAILED") { false }
end

#find(id) ⇒ Object



3
4
5
6
7
# File 'lib/email_vision/message.rb', line 3

def find(id)
  execute(:get_message, :id => id)
rescue Savon::SOAP::Fault => e
  check_server_status!(e, "GET_MESSAGE_FAILED") { nil }
end

#find_all_by_field(field, value, limit = 9999) ⇒ Object



13
14
15
16
# File 'lib/email_vision/message.rb', line 13

def find_all_by_field(field, value, limit=9999)
  result = execute(:get_email_messages_by_field, :field => field, :value => value, :limit => limit || 1)
  Array(result)
end

#find_all_by_period(from, to) ⇒ Object



9
10
11
# File 'lib/email_vision/message.rb', line 9

def find_all_by_period(from, to)
  execute(:get_messages_by_period, :date_begin => format_date(from), :date_end => format_date(to)) || []
end

#test(id, member_id, options = {}) ⇒ Object



41
42
43
44
45
46
# File 'lib/email_vision/message.rb', line 41

def test(id, member_id, options={})
  options = { :id => id, :member_id => member_id }.merge(options)
  execute(:test_email_message_by_member, options)
rescue Savon::SOAP::Fault => e
  check_server_status!(e, "TEM_MESSAGE_FAILED") { false }
end

#update(attributes) ⇒ Object



35
36
37
38
39
# File 'lib/email_vision/message.rb', line 35

def update(attributes)
  execute(:update_message_by_obj, :message => attributes)
rescue Savon::SOAP::Fault => e
  check_server_status!(e, "GET_MESSAGE_FAILED") { false }
end