lib/event_inventory/base.rb
# Executes the call to the web service.
Executes the call to the web service.
Executes the call to the web service .
def perform
        uri = URI.parse(url)
        session = Patron::Session.new
        session.timeout = 60
        session.base_url = "#{uri.scheme}://#{uri.host}:#{uri.port}/"
        session.proxy = EventInventory.proxy if EventInventory.proxy
        retries = 5
        begin
          response = case @action.method
            when :get
              session.get([uri.path, uri.query].compact.join('?'))
            when :post
              session.post(uri.path, uri.query)
          end
        rescue Patron::PartialFileError, Patron::ConnectionFailed, Patron::HostResolutionError, Patron::TimeoutError
          if (retries -= 1) > 0
            retry
          else
            raise NetworkError.new($!.to_s)
          end
        end
        case body = response.body
          when /Security Token: (\w+) \(APPCLIENT_ID\) is not registered/
            raise AuthorizationError, "Invalid security token (#{$1})"
          when /IP Address: ([\d\.]+) is not enabled/
            raise AuthorizationError, "Unauthorized IP (#{$1})"
          when /^Missing parameter: (.*)\./
            raise ParameterError, "Missing #{$1}"
          when /There was an error parsing (\w+) parameter \[(\w+)=(.*?)\]/
            raise ParameterError, "Invalid #{$2} (#{$1}, \"#{$3}\")"
          else
            @action.parser.parse(body) if body
        end
      end
def perform uri = URI . parse ( url ) session = Patron :: Session . new session . timeout = 60 session . base_url = "#{uri.scheme}://#{uri.host}:#{uri.port}/" session . proxy = EventInventory . proxy if EventInventory . proxy retries = 5 begin response = case @action . method when :get session . get ( [ uri . path , uri . query ] . compact . join ( '?' ) ) when :post session . post ( uri . path , uri . query ) end rescue Patron :: PartialFileError , Patron :: ConnectionFailed , Patron :: HostResolutionError , Patron :: TimeoutError if ( retries -= 1 ) > 0 retry else raise NetworkError . new ( $! . to_s ) end end case body = response . body when / Security Token: ( \w +)  \( APPCLIENT_ID \)  is not registered / raise AuthorizationError , "Invalid security token (#{$1})" when / IP Address: ([ \d \. ]+) is not enabled / raise AuthorizationError , "Unauthorized IP (#{$1})" when / ^Missing parameter: (.*) \. / raise ParameterError , "Missing #{$1}" when / There was an error parsing ( \w +) parameter  \[ ( \w +)=(.*?) \] / raise ParameterError , "Invalid #{$2} (#{$1}, \"#{$3}\")" else @action . parser . parse ( body ) if body end end
Executes the call to the web service.
Executes the call to the web service .