Sha256: e31dc8181c96fbfe336a127f86a690aaa368d7a7a26dd40665de314e9fe7e54d

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

module Einvoice
  module Neweb
    module Model
      class Query < Base
        VALID_OPTIONS_KEYS = [
          :invoice_date_time_s,
          :invoice_date_time_e,
          :data_number_s,
          :data_number_e,
          :sync_status_update
        ].freeze

        attr_accessor *VALID_OPTIONS_KEYS

        validates :invoice_date_time_s, presence: true, length: { maximum: 14 }, format: { with: /\A\d{4}\d{2}\d{2}\d{2}\d{2}\Z/ }
        validates :invoice_date_time_e, presence: true, length: { maximum: 14 }, format: { with: /\A\d{4}\d{2}\d{2}\d{2}\d{2}\Z/ }
        validates :data_number_s, presence: true, length: { maximum: 20 }
        validates :data_number_e, presence: true, length: { maximum: 20 }
        validates :sync_status_update, presence: true, length: { maximum: 1 }

        def initialize
          # overwritten
        end

        def attributes=(hash)
          hash.each do |key, value|
            send("#{key}=", value)
          end
        end

        def payload
          serializable_hash(except: [:errors, :validation_context])
        end

        def wrapped_payload
          { invoice_map_root:
            { invoice_map: payload }
          }
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
einvoice-1.1.1 lib/einvoice/neweb/model/query.rb
einvoice-1.1.0 lib/einvoice/neweb/model/query.rb
einvoice-1.0.0 lib/einvoice/neweb/model/query.rb