class Aws::Stubbing::Protocols::Json

@api private

Public Instance Methods

stub_data(api, operation, data) click to toggle source
# File lib/aws-sdk-core/stubbing/protocols/json.rb, line 9
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
stub_error(error_code) click to toggle source
# File lib/aws-sdk-core/stubbing/protocols/json.rb, line 18
        def stub_error(error_code)
          resp = Seahorse::Client::Http::Response.new
          resp.status_code = 400
          resp.body = <<~JSON.strip
            {
              "code": #{error_code.inspect},
              "message": "stubbed-response-error-message"
            }
          JSON
          resp
        end

Private Instance Methods

build_body(operation, data) click to toggle source
# File lib/aws-sdk-core/stubbing/protocols/json.rb, line 36
def build_body(operation, data)
  Aws::Json::Builder.new(operation.output).to_json(data)
end
content_type(api) click to toggle source
# File lib/aws-sdk-core/stubbing/protocols/json.rb, line 32
def content_type(api)
  "application/x-amz-json-#{api.metadata['jsonVersion']}"
end