Class: Decidim::Verifications::IdDocuments::InformationForm

Inherits:
AuthorizationHandler show all
Defined in:
decidim-verifications/app/forms/decidim/verifications/id_documents/information_form.rb

Overview

A form object to be used as the base for identity document verification

Constant Summary collapse

DOCUMENT_TYPES =
%w(DNI NIE passport).freeze

Instance Method Summary collapse

Methods inherited from AuthorizationHandler

#form_attributes, handler_for, handler_name, #metadata, #to_partial_path, #unique_id, #verification_attachment

Instance Method Details

#document_types_for_selectObject


46
47
48
49
50
51
52
53
# File 'decidim-verifications/app/forms/decidim/verifications/id_documents/information_form.rb', line 46

def document_types_for_select
  DOCUMENT_TYPES.map do |type|
    [
      I18n.t(type.downcase, scope: "decidim.verifications.id_documents"),
      type
    ]
  end
end

#handler_nameObject


28
29
30
# File 'decidim-verifications/app/forms/decidim/verifications/id_documents/information_form.rb', line 28

def handler_name
  "id_documents"
end

#map_model(model) ⇒ Object


32
33
34
35
36
# File 'decidim-verifications/app/forms/decidim/verifications/id_documents/information_form.rb', line 32

def map_model(model)
  self.document_type = model.["document_type"]
  self.document_number = model.["document_number"]
  self.verification_type = model.["verification_type"].presence || "online"
end

#uses_online_method?Boolean

Returns:

  • (Boolean)

55
56
57
# File 'decidim-verifications/app/forms/decidim/verifications/id_documents/information_form.rb', line 55

def uses_online_method?
  verification_type == "online"
end

#verification_metadataObject


38
39
40
41
42
43
44
# File 'decidim-verifications/app/forms/decidim/verifications/id_documents/information_form.rb', line 38

def 
  {
    "document_type" => document_type,
    "document_number" => document_number,
    "verification_type" => verification_type
  }
end