Sha256: 7e8d360e992d0c37b95576b84bc03d500998931966f5db0e7a5b1d127356684c

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

module Workarea
  module Storefront
    class KountOrdersController < ApplicationController
      skip_before_action :verify_authenticity_token, only: [:bulk]
      before_action :authenticate

      def bulk
        event_batch = Kount::EventBatch.new(request.raw_post)

        if event_batch.valid?
          event_batch.process!
          successful_response
        else
          unsuccessful_response
        end
      end

      private

        def authenticate
          authenticated = authenticate_with_http_basic do |username, password|
            Kount.credentials[:ens_username].present? &&
              Kount.credentials[:ens_password].present? &&
              username == Kount.credentials[:ens_username] &&
              password == Kount.credentials[:ens_password]
          end

          unsuccessful_response unless authenticated
        end

        def successful_response
          render json: { status: 200 }
        end

        def unsuccessful_response
          head :bad_request
        end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workarea-kount-3.3.1 app/controllers/workarea/storefront/kount_orders_controller.rb
workarea-kount-3.3.0 app/controllers/workarea/storefront/kount_orders_controller.rb