-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b676bf
commit 0422793
Showing
5 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module XmlPayload | ||
class MulticastMessage | ||
def self.multicastmessage(vfirst_config, message_content, phone_number_array, sender_id = nil) | ||
doc = XmlPayload::XmlGenerator.new_doc | ||
message_tag = XmlPayload::XmlGenerator.create_node("MESSAGE", attributes: {"VER" => XmlPayload::VERSION}) | ||
doc.root = message_tag | ||
user_tag = XmlPayload::XmlGenerator.user_tag vfirst_config | ||
doc.root << user_tag | ||
|
||
sms_tag = XmlPayload::XmlGenerator.create_node("SMS", attributes: { "UDH" => "0", | ||
"CODING" => "1", | ||
"TEXT" => message_content.to_s, | ||
"PROPERTY" => "0", | ||
"ID" => "1", | ||
}) | ||
phone_number_array.each do |phone_number| | ||
address_tag = XmlPayload::XmlGenerator.create_node("ADDRESS", attributes: { "FROM" => sender_id.to_s || vfirst_config.default_sender.to_s, | ||
"TO" => phone_number.to_s, | ||
"SEQ" => "", | ||
"TAG" => "", | ||
}) | ||
|
||
sms_tag << address_tag | ||
doc.root << sms_tag | ||
end | ||
|
||
doc | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'spec_helper' | ||
require 'valuefirst.rb' | ||
|
||
describe "MulticastMessage" do | ||
|
||
describe "::multicastmessage" do | ||
it "it return a dtd compliant xml document" do | ||
payload = XmlPayload::MulticastMessage.multicastmessage(vfirst_config, | ||
"Sample mesage", | ||
["XXXXXXXX01", "XXXXXXXX02", "XXXXXXXX03", "XXXXXXXX04"]) | ||
expect(payload.class).to be XML::Document | ||
expect(payload.validate(load_dtd_from_file("messagev12"))).to eq true | ||
end | ||
end | ||
end |