1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
# frozen_string_literal: true
module Aws
module Stubbing
module Protocols
# @api private
class RpcV2
def stub_data(_api, operation, data)
resp = Seahorse::Client::Http::Response.new
resp.status_code = 200
resp.headers['Smithy-Protocol'] = 'rpc-v2-cbor'
resp.headers['Content-Type'] = 'application/cbor'
resp.headers['x-amzn-RequestId'] = 'stubbed-request-id'
resp.body = build_body(operation, data)
resp
end
def stub_error(error_code)
resp = Seahorse::Client::Http::Response.new
resp.status_code = 400
resp.body = Aws::RpcV2.encode(
{
'code' => error_code,
'message' => 'stubbed-response-error-message'
}
)
resp
end
private
def build_body(operation, data)
Aws::RpcV2::Builder.new(operation.output).serialize(data)
end
end
end
end
end
|