Sha256: f720b45d5d77f303a3e9f8d2b049ef1b58470ff0bd30d5292ca52758164dcdfb

Contents?: true

Size: 1009 Bytes

Versions: 161

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['jsonVersion']}"
        end

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

      end
    end
  end
end

Version data entries

161 entries across 161 versions & 1 rubygems

Version Path
aws-sdk-core-3.198.0 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.197.2 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.197.1 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.197.0 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.194.1 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.194.0 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.193.0 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.192.1 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.192.0 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.191.6 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.191.5 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.191.4 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.191.3 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.191.2 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.191.1 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.191.0 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.190.3 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.190.2 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.190.1 lib/aws-sdk-core/stubbing/protocols/json.rb
aws-sdk-core-3.190.0 lib/aws-sdk-core/stubbing/protocols/json.rb