changed ShippingOptions get_options to return a ShippingOption list
2 files changed, 28 insertions(+), 6 deletions(-)

M README.rst
M kunaki/kunaki.py
M README.rst +3 -3
@@ 56,9 56,9 @@ Please first refer to Kunaki XML Web Ser
         # Retrieve options list
         options = shipping_opts.get_options()
         for opt in options:
-            print 'Description:', opt[0]
-            print 'Delivery Time:', opt[1]
-            print 'Price:', opt[2]
+            print 'Description:', opt.description
+            print 'Delivery Time:', opt.delivery_time
+            print 'Price:', opt.price
     else:
         print 'Error:', shipping_opts.error_msg
 

          
M kunaki/kunaki.py +25 -3
@@ 18,6 18,24 @@ class ShippingProduct(KunakiElement):
         return product
 
 
+class ShippingOption(KunakiElement):
+    """ Kunaki Shipping Option. Used for Shipping Options response.
+    """
+    def __init__(self, description, delivery_time, price):
+        self.description = description
+        self.delivery_time = delivery_time
+        self.price = price
+
+    def get_tree(self):
+        """ Builds tree structure for the Shipping Option.
+        """
+        opt = ET.Element('Option')
+        ET.SubElement(opt, 'Description').text = unicode(self.description)
+        ET.SubElement(opt, 'DeliveryTime').text = unicode(self.delivery_time)
+        ET.SubElement(opt, 'Price').text = unicode(self.price)
+        return opt
+
+
 class ShippingOptions(KunakiRequest):
     """ Kunaki Shipping Options request.
     """

          
@@ 40,13 58,17 @@ class ShippingOptions(KunakiRequest):
         return options
 
     def get_options(self):
-        """ Returns options retrieved from Kunaki as a list of tuples
-        (<Description>, <DeliveryTime>, <Price>)
+        """ Returns ShippingOption list retrieved from Kunaki
         """
         assert self.response is not None
         options = []
         for opt in self.response.findall('Option'):
-            options.append(tuple(x.text for x in opt.getchildren()))
+            shipping_opt = ShippingOption(
+                description=opt.find('Description').text,
+                delivery_time=opt.find('DeliveryTime').text,
+                price=opt.find('Price').text,
+            )
+            options.append(shipping_opt)
         return options
 
     def add_product(self, product):