Class: StandardSingpass::Myinfo::PersonDataParser

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/standard_singpass/myinfo/person_data_parser.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(person_data) ⇒ PersonDataParser

Returns a new instance of PersonDataParser.



25
26
27
28
# File 'lib/standard_singpass/myinfo/person_data_parser.rb', line 25

def initialize(person_data)
  data = person_data || {}
  @data = T.let(data.key?("person_info") ? (data["person_info"] || {}) : data, T::Hash[String, T.untyped])
end

Class Method Details

.call(person_data) ⇒ Object



12
13
14
# File 'lib/standard_singpass/myinfo/person_data_parser.rb', line 12

def self.call(person_data)
  new(person_data).parse
end

Instance Method Details

#parseObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/standard_singpass/myinfo/person_data_parser.rb', line 31

def parse
  {
    # Identity
    nric: extract_value("uinfin"),
    name: extract_value("name"),
    alias_name: extract_value("aliasname"),
    hanyu_pinyin_name: extract_value("hanyupinyinname"),
    hanyu_pinyin_alias_name: extract_value("hanyupinyinaliasname"),
    married_name: extract_value("marriedname"),
    sex: extract_code("sex"),
    race: extract_code("race"),
    nationality: extract_code("nationality"),
    date_of_birth: extract_value("dob"),
    residential_status: extract_code("residentialstatus"),
    marital_status: extract_code("marital"),

    # Contact
    email: extract_value("email"),
    mobile_number:,

    # Address
    registered_address:,
    hdb_type: extract_label("hdbtype"),
    housing_type: extract_label("housingtype"),

    # Pass info — FIN-only; absent for SC/PR.
    pass_type: extract_label("passtype"),
    pass_status: extract_label("passstatus"),
    pass_expiry_date: extract_value("passexpirydate"),
    employment_sector: extract_label("employmentsector"),

    # Employment. Singpass `employment` returns the employer's company
    # name for FIN holders, but a status label ("EMPLOYED" / "SELF-
    # EMPLOYED") for SC/PR. Stored as `:employment` rather than
    # `:employer_name` so consumers don't render "Employer: EMPLOYED"
    # for citizen borrowers.
    employment: extract_value("employment"),
    # SSOC 4-digit code → desc (e.g. "5223" → "SALES SUPERVISOR"). Codes
    # alone are meaningless to humans reviewing what's been shared.
    occupation: extract_label("occupation"),
    cpf_employers:,

    # Income — MAS TDSR inputs
    noa_basic:,
    noa_history_basic:,
    noa: noa_detailed,
    noa_history: noa_history_detailed,
    cpf_contributions:,

    # Assets / liabilities
    cpf_balances:,
    cpf_housing_withdrawal:,
    owner_private: extract_value("ownerprivate"),
    hdb_ownership:,
    vehicles:
  }.compact
end