Class: SmswayApi::Method::SendMessage

Inherits:
SmswayApi::Method show all
Defined in:
lib/smsway_api/method/send_message.rb

Instance Method Summary collapse

Methods inherited from SmswayApi::Method

#http_verb, #parse_response

Constructor Details

#initialize(*args) ⇒ SendMessage

Returns a new instance of SendMessage.



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/smsway_api/method/send_message.rb', line 3

def initialize *args
  if args.first.is_a?(SmswayApi::Message)
    @messages = args
  elsif args.length == 2 && args.first.is_a?(String)
    @messages = []
    sms = SmswayApi::Message::Sms.new(args.first)
    sms.add_recipient(args.last)
    @messages << sms
  else
    @messages = Array.wrap(args.first)
  end
end

Instance Method Details

#build_xmlObject



16
17
18
19
20
21
22
23
24
# File 'lib/smsway_api/method/send_message.rb', line 16

def build_xml
  super do |xml|
    abonents = 1
    @messages.each do |m|
      m.build(xml, abonents)
      abonents += m.recepients.size
    end
  end
end

#parse(response) ⇒ Object



30
31
32
# File 'lib/smsway_api/method/send_message.rb', line 30

def parse response
  Hash.from_xml(response)
end

#uriObject



26
27
28
# File 'lib/smsway_api/method/send_message.rb', line 26

def uri
  'xml/index.php'
end