Sha256: beb2ba3505133c8148faa4d07236327de093cac983aae6736a5dc082ca908c30

Contents?: true

Size: 985 Bytes

Versions: 2

Compression:

Stored size: 985 Bytes

Contents

# typed: strict
# frozen_string_literal: true

class SettingsController < ApplicationController
  extend T::Sig

  include PathParameter::SettingsParameters

  before_action :ensure_json_request
  sig { void }
  def ensure_json_request
    return if request.format.json?

    not_acceptable
  end

  sig { void }
  def new
    @step = T.let(params.fetch(:step, 1).to_i || 1, T.nilable(Integer))
  end

  sig { void }
  def edit
    @step = params.fetch(:step, 1).to_i || 1

    response = YettoService.get_plug_installation(pparam_plug_installation_id)

    if response.unavailable?
      logger.error("Fetching Yetto inbox failed: `#{response}`")

      return not_acceptable
    end

    plug_installation = response.parse_json_body
    access_token = plug_installation.fetch("credentials", {}).fetch("access_token", "")

    if access_token.blank?
      logger.error("Fetching Yetto access_token failed: `#{response}`")

      return not_acceptable
    end

    not_found
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hephaestus-0.5.1 templates/app/controllers/settings_controller.rb
hephaestus-0.5.0 templates/app/controllers/settings_controller.rb