Sha256: ffa5ce9a8d8fd707c96a03d25021b028158c3467c97655bdfa92082e2a7921ac

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

module A2z
  module Responses
    class OperationRequest
      include Helpers
      
      attr_accessor :request_id, :request_processing_time, :headers, :arguments
      
      def initialize
        @headers = []
        @arguments = []
      end
      
      def self.from_response(data)
        new.tap do |operation_request|
          operation_request.request_id = data['RequestId']
          operation_request.request_processing_time = data['RequestProcessingTime'].to_f
          
          if data['HTTPHeaders'] && data['HTTPHeaders']['Header']
            headers = array_wrap(data['HTTPHeaders']['Header'])
            headers = headers.collect { |h| [ h['Name'], h['Value'] ] }
            operation_request.headers = Hash[headers]
          end
          
          if data['Arguments'] && data['Arguments']['Argument']
            arguments = array_wrap(data['Arguments']['Argument'])
            arguments = arguments.collect { |a| [ a['Name'], a['Value'] ] }
            operation_request.arguments = Hash[arguments]
          end
          
          operation_request.freeze
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
a2z-0.1.3 lib/a2z/responses/operation_request.rb
a2z-0.1.2 lib/a2z/responses/operation_request.rb
a2z-0.1.1 lib/a2z/responses/operation_request.rb
a2z-0.1.0 lib/a2z/responses/operation_request.rb