Module: Citybox::Regions
- Defined in:
- lib/citybox/regions.rb
Overview
module for regions services
Class Method Summary collapse
-
.list_communes ⇒ Object
list all communes.
-
.list_communes_by_region(region_id) ⇒ Object
list all communes for region with id ‘region_id’.
-
.list_regions ⇒ Object
list all regions.
Class Method Details
.list_communes ⇒ Object
list all communes
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/citybox/regions.rb', line 29 def self.list_communes xml = "<?xml version='1.0' encoding='utf-8'?> <soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> <soap:Body> <listarTodasLasComunas xmlns='http://tempuri.org/'> <usuario>#{Citybox.user}</usuario> <contrasena>#{Citybox.password}</contrasena> </listarTodasLasComunas> </soap:Body> </soap:Envelope>" begin xml_response = RestClient.post @server_url, xml, content_type: "text/xml" json_response = Crack::XML.parse(xml_response) json_response["soap:Envelope"]["soap:Body"]["listarTodasLasComunasResponse"]["listarTodasLasComunasResult"]["ComunaTO"] rescue => e puts e return nil end end |
.list_communes_by_region(region_id) ⇒ Object
list all communes for region with id ‘region_id’
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/citybox/regions.rb', line 51 def self.list_communes_by_region region_id xml = "<?xml version='1.0' encoding='utf-8'?> <soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> <soap:Body> <listarComunasSegunRegion xmlns='http://tempuri.org/'> <usuario>#{Citybox.user}</usuario> <contrasena>#{Citybox.password}</contrasena> <codigoRegion>#{region_id}</codigoRegion> </listarComunasSegunRegion> </soap:Body> </soap:Envelope>" begin xml_response = RestClient.post @server_url, xml, content_type: "text/xml" json_response = Crack::XML.parse(xml_response) json_response["soap:Envelope"]["soap:Body"]["listarComunasSegunRegionResponse"]["listarComunasSegunRegionResult"]["ComunaTO"] rescue => e puts e return nil end end |
.list_regions ⇒ Object
list all regions
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/citybox/regions.rb', line 7 def self.list_regions xml = "<?xml version='1.0' encoding='utf-8'?> <soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> <soap:Body> <listarTodasLasRegiones xmlns='http://tempuri.org/'> <usuario>#{Citybox.user}</usuario> <contrasena>#{Citybox.password}</contrasena> </listarTodasLasRegiones> </soap:Body> </soap:Envelope>" begin xml_response = RestClient.post @server_url, xml, content_type: "text/xml" json_response = Crack::XML.parse(xml_response) json_response["soap:Envelope"]["soap:Body"]["listarTodasLasRegionesResponse"]["listarTodasLasRegionesResult"]["RegionTO"] rescue => e puts e return nil end end |