Sha256: 40a428251c78c9409bb5977e26b18f2d863639c5ae55f2d4860fc4994a1fa1ce

Contents?: true

Size: 1.38 KB

Versions: 17

Compression:

Stored size: 1.38 KB

Contents

module Exlibris::Aleph
  require 'httparty'
  class RestAPI
    include HTTParty
    format :xml
    def initialize(uri)
      @uri = uri
      raise "Initialization error in #{self.class}. Missing URI." if @uri.nil?
    end
    def error
      return nil if reply_code == "0000" 
      return "#{reply_text}"
    end
    def reply_code
      return "No response." if @response.nil?
      return (not @response.first.last.kind_of?(Hash) or @response.first.last["reply_code"].nil?) ? "Unexpected response hash." : @response.first.last["reply_code"] if @response.instance_of?(Hash)
      response_match = @response.match(/\<reply-code\>(.+)\<\/reply-code\>/) if @response.instance_of?(String)
      return (response_match.nil?) ? "Unexpected response string." : response_match[1] if @response.instance_of?(String)
      return "Unexpected response type."
    end
    def reply_text
      return "No response." if @response.nil?
      return (not @response.first.last.kind_of?(Hash) or @response.first.last["reply_text"].nil?) ? "Unexpected response hash." : @response.first.last["reply_text"] if @response.instance_of?(Hash)
      response_match = @response.match(/\<reply-text\>(.+)\<\/reply-text\>/) if @response.instance_of?(String)
      return (response_match.nil?) ? "Unexpected response string." : response_match[1] if @response.instance_of?(String)
      return "Unexpected response type."
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
umlaut-3.0.0beta2 lib/exlibris/aleph/rest_api.rb
umlaut-3.0.0beta1 lib/exlibris/aleph/rest_api.rb
umlaut-3.0.0alpha15 lib/exlibris/aleph/rest_api.rb
umlaut-3.0.0alpha14 lib/exlibris/aleph/rest_api.rb
umlaut-3.0.0alpha13 lib/exlibris/aleph/rest_api.rb
umlaut-3.0.0alpha12 lib/exlibris/aleph/rest_api.rb
umlaut-3.0.0alpha11 lib/exlibris/aleph/rest_api.rb
umlaut-3.0.0alpha10 lib/exlibris/aleph/rest_api.rb
umlaut-3.0.0alpha9 lib/exlibris/aleph/rest_api.rb
umlaut-3.0.0alpha8 lib/exlibris/aleph/rest_api.rb
umlaut-3.0.0alpha7 lib/exlibris/aleph/rest_api.rb
umlaut-3.0.0alpha6 lib/exlibris/aleph/rest_api.rb
umlaut-3.0.0alpha5 lib/exlibris/aleph/rest_api.rb
umlaut-3.0.0alpha4 lib/exlibris/aleph/rest_api.rb
umlaut-3.0.0alpha3 lib/exlibris/aleph/rest_api.rb
umlaut-3.0.0alpha2 lib/exlibris/aleph/rest_api.rb
umlaut-3.0.0alpha1 lib/exlibris/aleph/rest_api.rb