Class: SPImaging::Protocol
- Inherits:
-
Object
- Object
- SPImaging::Protocol
- Defined in:
- lib/spimaging/protocol.rb
Class Method Summary collapse
Instance Method Summary collapse
- #download_images(xml) ⇒ Object
-
#initialize(config) ⇒ Protocol
constructor
A new instance of Protocol.
Constructor Details
#initialize(config) ⇒ Protocol
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/spimaging/protocol.rb', line 10 def initialize(config) @base_url = config['base_url'] @render_path = config['render_path'] @username = config['username'] @password = config['password'] url = URI.parse @base_url @http = Net::HTTP.new url.host, url.port @http.use_ssl = (url.scheme =~ /https/i) end |
Class Method Details
.instance ⇒ Object
6 7 8 |
# File 'lib/spimaging/protocol.rb', line 6 def self.instance @instance ||= self.new Configuration.current end |
Instance Method Details
#download_images(xml) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/spimaging/protocol.rb', line 22 def download_images(xml) request = Net::HTTP::Post.new URI.join(@base_url, "image/retrieve").to_s request.body = xml request['Accept'] = 'text/html' request['Content-Type'] = 'application/xml' request.basic_auth @username, @password response = http.request request SPImaging::ShowImagesResponse.new response.code, response.body, response.content_type, response['content-encoding'], response['content-disposition'] end |