Sha256: 885781d08f8785daa6a73c98335cf90edf1a40c12b2121eb0cb6d585628b7d71

Contents?: true

Size: 1.21 KB

Versions: 186

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

module Aws
  module Stubbing
    module Protocols
      class Query

        def stub_data(api, operation, data)
          resp = Seahorse::Client::Http::Response.new
          resp.status_code = 200
          resp.body = build_body(api, operation, data)
          resp
        end

        def stub_error(error_code)
          http_resp = Seahorse::Client::Http::Response.new
          http_resp.status_code = 400
          http_resp.body = XmlError.new(error_code).to_xml
          http_resp
        end

        private

        def build_body(api, operation, data)
          xml = []
          builder = Aws::Xml::DocBuilder.new(target: xml, indent: '  ')
          builder.node(operation.name + 'Response', xmlns: xmlns(api)) do
            if (rules = operation.output)
              rules.location_name = operation.name + 'Result'
              Xml::Builder.new(rules, target: xml, pad:'  ').to_xml(data)
            end
            builder.node('ResponseMetadata') do
              builder.node('RequestId', 'stubbed-request-id')
            end
          end
          xml.join
        end

        def xmlns(api)
          api.metadata['xmlNamespace']
        end

      end
    end
  end
end

Version data entries

186 entries across 186 versions & 1 rubygems

Version Path
aws-sdk-core-3.189.0 lib/aws-sdk-core/stubbing/protocols/query.rb
aws-sdk-core-3.188.0 lib/aws-sdk-core/stubbing/protocols/query.rb
aws-sdk-core-3.187.1 lib/aws-sdk-core/stubbing/protocols/query.rb
aws-sdk-core-3.187.0 lib/aws-sdk-core/stubbing/protocols/query.rb
aws-sdk-core-3.186.0 lib/aws-sdk-core/stubbing/protocols/query.rb
aws-sdk-core-3.185.2 lib/aws-sdk-core/stubbing/protocols/query.rb
aws-sdk-core-3.185.1 lib/aws-sdk-core/stubbing/protocols/query.rb
aws-sdk-core-3.185.0 lib/aws-sdk-core/stubbing/protocols/query.rb
aws-sdk-core-3.184.0 lib/aws-sdk-core/stubbing/protocols/query.rb
aws-sdk-core-3.183.1 lib/aws-sdk-core/stubbing/protocols/query.rb
aws-sdk-core-3.183.0 lib/aws-sdk-core/stubbing/protocols/query.rb
aws-sdk-core-3.182.0 lib/aws-sdk-core/stubbing/protocols/query.rb
aws-sdk-core-3.181.1 lib/aws-sdk-core/stubbing/protocols/query.rb
aws-sdk-core-3.181.0 lib/aws-sdk-core/stubbing/protocols/query.rb
aws-sdk-core-3.180.3 lib/aws-sdk-core/stubbing/protocols/query.rb
aws-sdk-core-3.180.2 lib/aws-sdk-core/stubbing/protocols/query.rb
aws-sdk-core-3.180.1 lib/aws-sdk-core/stubbing/protocols/query.rb
aws-sdk-core-3.180.0 lib/aws-sdk-core/stubbing/protocols/query.rb
aws-sdk-core-3.179.0 lib/aws-sdk-core/stubbing/protocols/query.rb
aws-sdk-core-3.178.0 lib/aws-sdk-core/stubbing/protocols/query.rb