Sha256: 69a472a5d66549fe2e16db48175666645a07992abdac73234e8f11b6ca905d38

Contents?: true

Size: 917 Bytes

Versions: 21

Compression:

Stored size: 917 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Verifications
    module PostalLetter
      # A form object to be used when admins want to mark a verification letter
      # as sent.
      class PostageForm < AuthorizationHandler
        attribute :full_address, String
        attribute :verification_code, String

        validates :full_address, presence: true
        validates :verification_code, presence: true

        def handler_name
          "postal_letter"
        end

        def map_model(model)
          self.verification_code = model.verification_metadata["pending_verification_code"]
          self.full_address = model.verification_metadata["address"]
        end

        def verification_metadata
          {
            address: full_address,
            verification_code: verification_code,
            letter_sent_at: Time.zone.now
          }
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
decidim-verifications-0.8.0 app/forms/decidim/verifications/postal_letter/postage_form.rb