Class: APIGatewayDSL::ResponseIntegration

Inherits:
Object
  • Object
show all
Defined in:
lib/api_gateway_dsl/response_integration.rb,
lib/api_gateway_dsl/response_integration/collection.rb

Defined Under Namespace

Classes: Collection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(regexp, status_code, mappings, templates) ⇒ ResponseIntegration

Returns a new instance of ResponseIntegration.



6
7
8
9
10
11
# File 'lib/api_gateway_dsl/response_integration.rb', line 6

def initialize(regexp, status_code, mappings, templates)
  @regexp      = regexp
  @status_code = status_code
  @mappings    = mappings
  @templates   = templates
end

Instance Attribute Details

#regexpObject (readonly)

Returns the value of attribute regexp.



4
5
6
# File 'lib/api_gateway_dsl/response_integration.rb', line 4

def regexp
  @regexp
end

Instance Method Details

#as_jsonObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/api_gateway_dsl/response_integration.rb', line 13

def as_json
  {}.tap do |result|
    result[:statusCode] = @status_code

    if (response_parameters = @mappings.as_json).present?
      result[:responseParameters] = response_parameters
    end

    if (response_templates = @templates.as_json).present?
      result[:responseTemplates] = response_templates
    end
  end
end