module QRParams
Constants
- QR_BILL_WITHOUT_REFERENCE
- QR_BILL_WITH_CREDITOR_REFERENCE
- QR_BILL_WITH_QR_REFERENCE
Public Class Methods
base_params_valid?(params)
click to toggle source
# File lib/qr-bills/qr-params.rb, line 74 def self.base_params_valid?(params) if params[:bill_type] == "" || params[:bill_type] == nil raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: bill type cannot be blank" end if params[:qrcode_filepath] == "" || params[:qrcode_filepath] == nil raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: qrcode_filepath cannot be blank" end if params[:bill_params][:currency] == "" || params[:bill_params][:currency] == nil raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: currency cannot be blank" end true end
get_qr_params()
click to toggle source
# File lib/qr-bills/qr-params.rb, line 6 def self.get_qr_params { bill_type: "", # see global variables / README qrcode_filepath: "", # where to store the qrcode, i.e. : /tmp/qrcode_1234.png fonts: { eot: File.expand_path("#{File.dirname(__FILE__)}/../../web/assets/fonts/LiberationSans-Regular.eot"), woff: File.expand_path("#{File.dirname(__FILE__)}/../../web/assets/fonts/LiberationSans-Regular.woff"), ttf: File.expand_path("#{File.dirname(__FILE__)}/../../web/assets/fonts/LiberationSans-Regular.ttf"), svg: File.expand_path("#{File.dirname(__FILE__)}/../../web/assets/fonts/LiberationSans-Regular.svg") }, locales: { path: File.expand_path("#{File.dirname(__FILE__)}/../../config/locales") }, bill_params: { language: "it", amount: 0.0, currency: "CHF", reference_type: "", # QRR = QR reference, SCOR = Creditor reference, NON = without reference reference: "", # qr reference or creditor reference (iso-11649) additionally_information: "", bill_information_coded: "", alternative_scheme_parameters: "", creditor: { address: { type: "S", name: "", line1: "", line2: "", postal_code: "", town: "", country: "", iban: "" }, }, debtor: { address: { type: "S", name: "", line1: "", line2: "", postal_code: "", town: "", country: "", }, } }, output_params: { format: "html" } } end
qr_bill_with_creditor_reference_valid?(params)
click to toggle source
# File lib/qr-bills/qr-params.rb, line 102 def self.qr_bill_with_creditor_reference_valid?(params) if params[:bill_params][:reference_type] != "SCOR" raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: reference type must be 'SCOR' for QR bill with (new) creditor reference" end if params[:bill_params][:reference] == "" || params[:bill_params][:reference] == nil raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: reference cannot be blank for QR bill with (new) creditor reference" end true end
qr_bill_with_qr_reference_valid?(params)
click to toggle source
# File lib/qr-bills/qr-params.rb, line 90 def self.qr_bill_with_qr_reference_valid?(params) if params[:bill_params][:reference_type] != "QRR" raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: reference type must be 'QRR' for QR bill with standard reference" end if params[:bill_params][:reference] == "" || params[:bill_params][:reference] == nil raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: reference cannot be blank for QR bill with standard reference" end true end
qr_bill_without_reference_valid?(params)
click to toggle source
# File lib/qr-bills/qr-params.rb, line 114 def self.qr_bill_without_reference_valid?(params) if params[:bill_params][:reference_type] != "NON" raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: reference type must be 'NON' for QR bill without reference" end if params[:bill_params][:reference] != "" raise ArgumentError, "#{QRExceptions::INVALID_PARAMETERS}: reference must be blank for QR bill without reference" end true end
valid?(params)
click to toggle source
# File lib/qr-bills/qr-params.rb, line 58 def self.valid?(params) return false unless params.key?(:bill_type) return false unless QRParams.base_params_valid?(params) case params[:bill_type] when QRParams::QR_BILL_WITH_QR_REFERENCE QRParams.qr_bill_with_qr_reference_valid?(params) when QRParams::QR_BILL_WITH_CREDITOR_REFERENCE QRParams.qr_bill_with_creditor_reference_valid?(params) when QRParams::QR_BILL_WITHOUT_REFERENCE QRParams.qr_bill_without_reference_valid?(params) else false end end