Class: Oddb2xml::SwissIndexDownloader
- Inherits:
-
Downloader
- Object
- Downloader
- Oddb2xml::SwissIndexDownloader
- Defined in:
- lib/oddb2xml/downloader.rb
Instance Method Summary collapse
- #download_by(lang = 'DE') ⇒ Object
- #init ⇒ Object
-
#initialize(type = :pharma) ⇒ SwissIndexDownloader
constructor
A new instance of SwissIndexDownloader.
Constructor Details
#initialize(type = :pharma) ⇒ SwissIndexDownloader
Returns a new instance of SwissIndexDownloader.
55 56 57 58 59 |
# File 'lib/oddb2xml/downloader.rb', line 55 def initialize(type=:pharma) @type = (type == :pharma ? 'Pharma' : 'NonPharma') url = "https://index.ws.e-mediat.net/Swissindex/#{@type}/ws_#{@type}_V101.asmx?WSDL" super(url) end |
Instance Method Details
#download_by(lang = 'DE') ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/oddb2xml/downloader.rb', line 67 def download_by(lang = 'DE') client = Savon::Client.new do |wsdl, http| http.auth.ssl.verify_mode = :none wsdl.document = @url end begin type = @type response = client.request :download_all do soap.xml = <<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> <lang xmlns="http://swissindex.e-mediat.net/Swissindex#{type}_out_V101">#{lang}</lang> </soap:Body> </soap:Envelope> XML end if response.success? if xml = response.to_xml return xml else # received broken data or internal error raise StandardError end else raise Timeout::Error end rescue Timeout::Error retrievable? ? retry : raise end end |
#init ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/oddb2xml/downloader.rb', line 60 def init Savon.configure do |config| config.log_level = :info config.log = false # $stdout config.raise_errors = true end end |