Sha256: 6eae8cfd2a7c0ff53aa52cdf5132e636c585fb4c35b904f3c44ee4eff6349630

Contents?: true

Size: 1009 Bytes

Versions: 25

Compression:

Stored size: 1009 Bytes

Contents

# frozen_string_literal: true

module Aws
  module Stubbing
    module Protocols
      class Json

        def stub_data(api, operation, data)
          resp = Seahorse::Client::Http::Response.new
          resp.status_code = 200
          resp.headers["Content-Type"] = content_type(api)
          resp.headers["x-amzn-RequestId"] = "stubbed-request-id"
          resp.body = build_body(operation, data)
          resp
        end

        def stub_error(error_code)
          http_resp = Seahorse::Client::Http::Response.new
          http_resp.status_code = 400
          http_resp.body = <<-JSON.strip
{
  "code": #{error_code.inspect},
  "message": "stubbed-response-error-message"
}
          JSON
          http_resp
        end

        private

        def content_type(api)
          "application/x-amz-json-#{api.metadata['jsonVerison']}"
        end

        def build_body(operation, data)
          Aws::Json::Builder.new(operation.output).to_json(data)
        end

      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
aws-sdk-core-3.114.0 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.113.1 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.113.0 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.112.1 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.112.0 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.111.2 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.111.1 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.111.0 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.110.0 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.109.3 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.109.2 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.109.1 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.109.0 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.108.0 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.107.0 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.105.0 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.104.4 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.104.3 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.104.2 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.104.1 lib/aws-sdk-core/stubbing/protocols/json.rb