You are viewing documentation for version 3 of the AWS SDK for Ruby. Version 2 documentation can be found here.

Class: Aws::Stubbing::Protocols::RestJson

Inherits:
Rest
  • Object
show all
Defined in:
gems/aws-sdk-core/lib/aws-sdk-core/stubbing/protocols/rest_json.rb

Direct Known Subclasses

ApiGateway

Instance Method Summary collapse

Methods inherited from Rest

#stub_data

Instance Method Details

#body_for(_, _, rules, data) ⇒ Object



6
7
8
# File 'gems/aws-sdk-core/lib/aws-sdk-core/stubbing/protocols/rest_json.rb', line 6

def body_for(_, _, rules, data)
  Aws::Json::Builder.new(rules).serialize(data)
end

#stub_error(error_code) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'gems/aws-sdk-core/lib/aws-sdk-core/stubbing/protocols/rest_json.rb', line 10

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