Class: Esendex::Account::Dispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/xednese/account/dispatcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(credentials, reference) ⇒ Dispatcher

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Dispatcher.


7
8
9
10
# File 'lib/xednese/account/dispatcher.rb', line 7

def initialize(credentials, reference)
  @credentials = credentials
  @reference = reference
end

Instance Method Details

#send(body, to) ⇒ Responses::MessageDispatcherHeaders

Sends a message to a single recipient.

Parameters:

  • body (String)

    the message body

  • to (String)

    the number to send to

Returns:


16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/xednese/account/dispatcher.rb', line 16

def send(body, to)
  args = {
    account_reference: @reference,
    messages: [{to: to, body: body}]
  }

  messages = Requests::Messages.new(args)

  Client.post(@credentials, 'v1.0/messagedispatcher', messages) do |code, body|
    Responses::MessageDispatcherHeaders.deserialise(body)
  end
end