summaryrefslogtreecommitdiff
path: root/contrib/smsweb/smswsc/phonebook_entry.rb
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/smsweb/smswsc/phonebook_entry.rb')
-rw-r--r--contrib/smsweb/smswsc/phonebook_entry.rb56
1 files changed, 56 insertions, 0 deletions
diff --git a/contrib/smsweb/smswsc/phonebook_entry.rb b/contrib/smsweb/smswsc/phonebook_entry.rb
new file mode 100644
index 0000000..ef13bc4
--- /dev/null
+++ b/contrib/smsweb/smswsc/phonebook_entry.rb
@@ -0,0 +1,56 @@
+require 'smswsc/builder'
+require 'rexml/document'
+
+module SMSWSC
+
+ class PhonebookEntry
+ attr_accessor :name
+ attr_accessor :addr_type
+ attr_accessor :addr
+ attr_accessor :uri
+
+ def initialize(options = {})
+ @addr_type = options["addr-type"]
+ @addr = options["addr"]
+ @name = options["name"]
+ end
+
+ def uri=(value)
+ @uri = value
+ end
+
+ def self.load_xml(parent)
+ entry = PhonebookEntry.new
+
+ parent.each_element do |element|
+ case element.name
+ when "addr-type"
+ entry.addr_type = element.text.to_s
+ when "addr"
+ entry.addr = element.text.to_s
+ when "name"
+ entry.name = element.text.to_s
+ when "uri"
+ entry.uri = URI.parse(element.text.to_s)
+ end
+ end
+
+ return entry
+ end
+
+ def to_xml(builder = nil, element = "phonebook-entry")
+ xml = ""
+ unless builder
+ builder = SMSWSC.new_builder(xml)
+ end
+
+ builder.tag!(element.to_s) {
+ builder.tag! "addr-type", @addr_type
+ builder.tag! "addr", @addr
+ builder.tag! "name", @name
+ }
+
+ return xml
+ end
+ end
+end