Class: Mailflow::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/mailflow/client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, server_key) ⇒ Client

Returns a new instance of Client.



14
15
16
17
# File 'lib/mailflow/client.rb', line 14

def initialize(host, server_key)
  @host = host
  @server_key = server_key
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



8
9
10
# File 'lib/mailflow/client.rb', line 8

def host
  @host
end

#server_keyObject (readonly)

Returns the value of attribute server_key.



8
9
10
# File 'lib/mailflow/client.rb', line 8

def server_key
  @server_key
end

Class Method Details

.instanceObject



10
11
12
# File 'lib/mailflow/client.rb', line 10

def self.instance
  @instance ||= new(Mailflow.config.host, Mailflow.config.server_key)
end

Instance Method Details

#messagesObject



19
20
21
# File 'lib/mailflow/client.rb', line 19

def messages
  @messages ||= MessageScope.new(self)
end

#moonropeObject



35
36
37
# File 'lib/mailflow/client.rb', line 35

def moonrope
  @moonrope ||= MoonropeClient::Connection.new(@host, headers: { 'X-Server-API-Key' => @server_key }, ssl: true)
end

#send_message(&block) ⇒ Object



23
24
25
26
27
# File 'lib/mailflow/client.rb', line 23

def send_message(&block)
  send_message = SendMessage.new(self)
  block.call(send_message)
  send_message.send!
end

#send_raw_message(&block) ⇒ Object



29
30
31
32
33
# File 'lib/mailflow/client.rb', line 29

def send_raw_message(&block)
  send_raw_message = SendRawMessage.new(self)
  block.call(send_raw_message)
  send_raw_message.send!
end