Class: VertxMail::MailService

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-mail-client/src/main/resources/vertx-mail/mail_service.rb

Overview

smtp mail service for vert.x this Interface provides the methods to be used by the application program and is used to generate the service in other languages

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (::VertxMail::MailService) create(vertx = nil, config = nil)

create an instance of MailService that is running in the local JVM

Parameters:

  • vertx (::Vertx::Vertx) (defaults to: nil)
    the Vertx instance the operation will be run in
  • config (Hash) (defaults to: nil)
    MailConfig configuration to be used for sending mails

Returns:

Raises:

  • (ArgumentError)


23
24
25
26
27
28
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mail-client/src/main/resources/vertx-mail/mail_service.rb', line 23

def self.create(vertx=nil,config=nil)
  if vertx.class.method_defined?(:j_del) && config.class == Hash && !block_given?
    return ::VertxMail::MailService.new(Java::IoVertxExtMail::MailService.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtMail::MailConfig.java_class]).call(vertx.j_del,Java::IoVertxExtMail::MailConfig.new(::Vertx::Util::Utils.to_json_object(config))))
  end
  raise ArgumentError, "Invalid arguments when calling create(vertx,config)"
end

+ (::VertxMail::MailService) create_event_bus_proxy(vertx = nil, address = nil)

create an instance of MailService that calls the mail service via the event bus running somewhere else

Parameters:

  • vertx (::Vertx::Vertx) (defaults to: nil)
    the Vertx instance the operation will be run in
  • address (String) (defaults to: nil)
    the eb address of the mail service running somewhere, default is "vertx.mail"

Returns:

Raises:

  • (ArgumentError)


33
34
35
36
37
38
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mail-client/src/main/resources/vertx-mail/mail_service.rb', line 33

def self.create_event_bus_proxy(vertx=nil,address=nil)
  if vertx.class.method_defined?(:j_del) && address.class == String && !block_given?
    return ::VertxMail::MailService.new(Java::IoVertxExtMail::MailService.java_method(:createEventBusProxy, [Java::IoVertxCore::Vertx.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,address))
  end
  raise ArgumentError, "Invalid arguments when calling create_event_bus_proxy(vertx,address)"
end

Instance Method Details

- (self) send_mail(email = nil) { ... }

send a single mail via MailService

Parameters:

  • email (Hash) (defaults to: nil)
    MailMessage object containing the mail text, from/to, attachments etc

Yields:

  • will be called when the operation is finished or it fails (may be null to ignore the result) the result JsonObject currently only contains {"result":"success"}

Returns:

  • (self)

Raises:

  • (ArgumentError)


43
44
45
46
47
48
49
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mail-client/src/main/resources/vertx-mail/mail_service.rb', line 43

def send_mail(email=nil)
  if email.class == Hash && block_given?
    @j_del.java_method(:sendMail, [Java::IoVertxExtMail::MailMessage.java_class,Java::IoVertxCore::Handler.java_class]).call(Java::IoVertxExtMail::MailMessage.new(::Vertx::Util::Utils.to_json_object(email)),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.encode) : nil : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling send_mail(email)"
end

- (void) start

This method returns an undefined value.

start the MailServer instance if it is running locally (this operation is currently a no-op)

Raises:

  • (ArgumentError)


52
53
54
55
56
57
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mail-client/src/main/resources/vertx-mail/mail_service.rb', line 52

def start
  if !block_given?
    return @j_del.java_method(:start, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling start()"
end

- (void) stop

This method returns an undefined value.

stop the MailServer instance if it is running locally

this operation shuts down the connection pool, doesn't wait for completion of the close operations when the mail service is running on the event bus, this operation has no effect

Raises:

  • (ArgumentError)


63
64
65
66
67
68
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mail-client/src/main/resources/vertx-mail/mail_service.rb', line 63

def stop
  if !block_given?
    return @j_del.java_method(:stop, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling stop()"
end