Sha256: 3ce76406552b00ad0bc6817aa9a7ee5e605c06f55a037200f83def561dc1660a

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

module Spree
  module Admin
    class BoltCallbackUrlsController < Spree::Admin::BaseController
      def edit
        callback_urls = SolidusBolt::MerchantConfiguration::GetCallbackUrlsService.call

        @oauth_logout = callback_urls['callback_urls'].find { |c| c['type'] == 'oauth_logout' }&.dig('url')
        @oauth_redirect = callback_urls['callback_urls'].find { |c| c['type'] == 'oauth_redirect' }&.dig('url')
        @get_account = callback_urls['callback_urls'].find { |c| c['type'] == 'get_account' }&.dig('url')
      end

      def update
        SolidusBolt::MerchantConfiguration::SetCallbackUrlsService.call(
          oauth_logout: params[:bolt_callback_urls][:oauth_logout],
          oauth_redirect: params[:bolt_callback_urls][:oauth_redirect],
          get_account: params[:bolt_callback_urls][:get_account]
        )
        flash[:success] = "Successfully updated callback urls."

        redirect_to edit_admin_bolt_callback_urls_path
      rescue SolidusBolt::ServerError => e
        flash[:error] = e.message

        render :new
      end

      private

      def bolt_webhook_params
        params
          .require(:bolt_webhook)
          .permit(
            :event,
            :webhook_url,
          )
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
solidus_bolt-0.7.2 app/controllers/spree/admin/bolt_callback_urls_controller.rb
solidus_bolt-0.7.1 app/controllers/spree/admin/bolt_callback_urls_controller.rb
solidus_bolt-0.7.0 app/controllers/spree/admin/bolt_callback_urls_controller.rb