class APIGatewayDSL::Integration

Attributes

context[R]
mappings[R]
method[R]
templates[R]
url[R]

Public Class Methods

new(operation, *args, &_block) click to toggle source
# File lib/api_gateway_dsl/integration.rb, line 6
def initialize(operation, *args, &_block)
  options = args.last.is_a?(Hash) ? args.last : {}

  @operation = operation

  @context = @operation.context.dup.tap { |c| c.default_body_file = 'request/body' }

  @passthrough_behavior = options[:passthrough_behavior] || 'WHEN_NO_TEMPLATES'
  @content_handling     = options[:content_handling]     || 'CONVERT_TO_TEXT'
  @credentials          = options[:credentials]

  @mappings  = Mapping::Collection.new
  @templates = Template::Collection.new(@context)
end

Public Instance Methods

as_json() click to toggle source
# File lib/api_gateway_dsl/integration.rb, line 21
def as_json # rubocop:disable Metrics/MethodLength
  {}.tap do |result|
    if (request_parameters = mappings.as_json).present?
      result[:requestParameters] = request_parameters
    end

    result[:passthroughBehavior] = @passthrough_behavior
    result[:contentHandling]     = @content_handling

    if (request_templates = @templates.as_json).present?
      result[:requestTemplates] = request_templates
    end

    if (responses = @operation.responses.response_integrations.as_json).present?
      result[:responses] = responses
    end
  end
end