Sha256: 17bbc204acc93945ada817d409394db69993a7491f2c4dddfb77b96e6a289ffb
Contents?: true
Size: 1.27 KB
Versions: 8
Compression:
Stored size: 1.27 KB
Contents
# frozen_string_literal: true module Spree class BacktracsController < Spree::BaseController protect_from_forgery with: :null_session, only: :shipnotify before_action :authenticate_backtracs def export @shipments = SolidusBacktracs::Shipment::ExportableQuery.apply(Spree::Shipment.all) @shipments = SolidusBacktracs::Shipment::BetweenQuery.apply( @shipments, from: date_param(:start_date), to: date_param(:end_date), ) @shipments = @shipments.page(params[:page]).per(50) respond_to do |format| format.xml { render layout: false } end end def shipnotify shipment_notice_class = SolidusBacktracs.configuration.shipment_notice_class.constantize shipment_notice_class.from_payload(params.to_unsafe_h).apply head :ok rescue SolidusBacktracs::Error => e head :bad_request end private def date_param(name) return if params[name].blank? Time.strptime("#{params[name]} UTC", '%m/%d/%Y %H:%M %Z') end def authenticate_backtracs authenticate_or_request_with_http_basic do |username, password| username == SolidusBacktracs.configuration.username && password == SolidusBacktracs.configuration.password end end end end
Version data entries
8 entries across 8 versions & 2 rubygems