Skip to content

Commit

Permalink
Merge pull request #45 from omu/dev
Browse files Browse the repository at this point in the history
Add new helper methods for serializers
  • Loading branch information
huseyin authored Oct 17, 2018
2 parents 108e8db + dee4e0e commit fa81c77
Show file tree
Hide file tree
Showing 46 changed files with 1,102 additions and 1,036 deletions.
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ GEM
httpi (2.4.4)
rack
socksify
i18n (1.1.0)
i18n (1.1.1)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
jaro_winkler (1.5.1)
Expand All @@ -104,7 +104,7 @@ GEM
loofah (2.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.0)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
Expand All @@ -116,7 +116,7 @@ GEM
msgpack (1.2.4)
multi_json (1.13.1)
nio4r (2.3.1)
nokogiri (1.8.4)
nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
nori (2.6.0)
parallel (1.12.1)
Expand Down Expand Up @@ -163,14 +163,14 @@ GEM
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
reek (5.0.2)
reek (5.2.0)
codeclimate-engine-rb (~> 0.4.0)
kwalify (~> 0.7.0)
parser (>= 2.5.0.0, < 2.6, != 2.5.1.1)
rainbow (>= 2.0, < 4.0)
rollbar (2.17.0)
rollbar (2.18.0)
multi_json
rubocop (0.59.1)
rubocop (0.59.2)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1)
Expand Down
124 changes: 62 additions & 62 deletions app/serializers/kps/queries/addresses_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,77 +3,77 @@
module Kps
module Queries
class AddressesSerializer < Serializer
attribute(:id_number) { object[:kimlik_no].safe_to_i }
attribute(:id_number) { integer object[:kimlik_no] }

attribute :current_address do
address = object[:yerlesim_yeri_adresi]

{
full_address: address[:acik_adres].titleize_tr,
no: address[:adres_no].safe_to_i,
full_address: string(address[:acik_adres]),
no: integer(address[:adres_no]),
type: {
code: address.dig(:adres_tip, :kod).safe_to_i,
description: address.dig(:adres_tip, :aciklama).titleize_tr
code: integer(address.dig(:adres_tip, :kod)),
description: string(address.dig(:adres_tip, :aciklama))
},
city_and_district_addresses: {
independent_unit_status: {
code: address.dig(:il_ilce_merkez_adresi, :bagimsiz_bolum_durum, :kod).safe_to_i,
description: address.dig(:il_ilce_merkez_adresi, :bagimsiz_bolum_durum, :aciklama).titleize_tr
},
dependent_unit_type: {
code: address.dig(:il_ilce_merkez_adresi, :bagimsiz_bolum_tipi, :kod).safe_to_i,
description: address.dig(:il_ilce_merkez_adresi, :bagimsiz_bolum_tipi, :aciklama).titleize_tr
},
apartment: {
block: address.dig(:il_ilce_merkez_adresi, :bina_ada).titleize_tr,
pilot: address.dig(:il_ilce_merkez_adresi, :bina_parsel).titleize_tr,
layout: address.dig(:il_ilce_merkez_adresi, :bina_pafta).titleize_tr,
block_name: address.dig(:il_ilce_merkez_adresi, :bina_blok_adi).titleize_tr,
code: address.dig(:il_ilce_merkez_adresi, :bina_kodu).safe_to_i,
no: address.dig(:il_ilce_merkez_adresi, :bina_no).safe_to_i,
site_name: address.dig(:il_ilce_merkez_adresi, :bina_site_adi),
status: {
code: address.dig(:il_ilce_merkez_adresi, :bina_durum, :kod).safe_to_i,
description: address.dig(:il_ilce_merkez_adresi, :bina_durum, :aciklama).titleize_tr
},
block: string(address.dig(:il_ilce_merkez_adresi, :bina_ada)),
block_name: string(address.dig(:il_ilce_merkez_adresi, :bina_blok_adi)),
code: integer(address.dig(:il_ilce_merkez_adresi, :bina_kodu)),
layout: string(address.dig(:il_ilce_merkez_adresi, :bina_pafta)),
no: integer(address.dig(:il_ilce_merkez_adresi, :bina_no)),
pilot: string(address.dig(:il_ilce_merkez_adresi, :bina_parsel)),
site_name: string(address.dig(:il_ilce_merkez_adresi, :bina_site_adi)),
numbering_type: {
code: address.dig(:il_ilce_merkez_adresi, :bina_numarataj_tipi, :kod).safe_to_i,
description: address.dig(:il_ilce_merkez_adresi, :bina_numarataj_tipi, :aciklama).titleize_tr
code: integer(address.dig(:il_ilce_merkez_adresi, :bina_numarataj_tipi, :kod)),
description: string(address.dig(:il_ilce_merkez_adresi, :bina_numarataj_tipi, :aciklama))
},
status: {
code: integer(address.dig(:il_ilce_merkez_adresi, :bina_durum, :kod)),
description: string(address.dig(:il_ilce_merkez_adresi, :bina_durum, :aciklama))
},
structure_type: {
code: address.dig(:il_ilce_merkez_adresi, :bina_yapi_tipi, :kod).safe_to_i,
description: address.dig(:il_ilce_merkez_adresi, :bina_yapi_tipi, :aciklama).titleize_tr
code: integer(address.dig(:il_ilce_merkez_adresi, :bina_yapi_tipi, :kod)),
description: string(address.dig(:il_ilce_merkez_adresi, :bina_yapi_tipi, :aciklama))
}
},
csbm: address.dig(:il_ilce_merkez_adresi, :csbm).titleize_tr,
csbm_code: address.dig(:il_ilce_merkez_adresi, :csbm_kodu).safe_to_i,
exterior_door_no: address.dig(:il_ilce_merkez_adresi, :dis_kapi_no).safe_to_i,
interior_door_no: address.dig(:il_ilce_merkez_adresi, :ic_kapi_no).safe_to_i,
csbm: string(address.dig(:il_ilce_merkez_adresi, :csbm)),
csbm_code: integer(address.dig(:il_ilce_merkez_adresi, :csbm_kodu)),
exterior_door_no: integer(address.dig(:il_ilce_merkez_adresi, :dis_kapi_no)),
interior_door_no: integer(address.dig(:il_ilce_merkez_adresi, :ic_kapi_no)),
city: {
code: address.dig(:il_ilce_merkez_adresi, :il_kodu).safe_to_i,
name: address.dig(:il_ilce_merkez_adresi, :il).titleize_tr
code: integer(address.dig(:il_ilce_merkez_adresi, :il_kodu)),
name: string(address.dig(:il_ilce_merkez_adresi, :il))
},
dependent_unit_type: {
code: integer(address.dig(:il_ilce_merkez_adresi, :bagimsiz_bolum_tipi, :kod)),
description: string(address.dig(:il_ilce_merkez_adresi, :bagimsiz_bolum_tipi, :aciklama))
},
district: {
code: address.dig(:il_ilce_merkez_adresi, :ilce_kodu).safe_to_i,
name: address.dig(:il_ilce_merkez_adresi, :ilce).titleize_tr
code: integer(address.dig(:il_ilce_merkez_adresi, :ilce_kodu)),
name: string(address.dig(:il_ilce_merkez_adresi, :ilce))
},
independent_unit_status: {
code: integer(address.dig(:il_ilce_merkez_adresi, :bagimsiz_bolum_durum, :kod)),
description: string(address.dig(:il_ilce_merkez_adresi, :bagimsiz_bolum_durum, :aciklama))
},
neighborhood: {
code: address.dig(:il_ilce_merkez_adresi, :mahalle_kodu).safe_to_i,
name: address.dig(:il_ilce_merkez_adresi, :mahalle).titleize_tr
code: integer(address.dig(:il_ilce_merkez_adresi, :mahalle_kodu)),
name: string(address.dig(:il_ilce_merkez_adresi, :mahalle))
},
reason_of_stucture_use: {
code: address.dig(:il_ilce_merkez_adresi, :yapi_kullanim_amac, :kod).safe_to_i,
name: address.dig(:il_ilce_merkez_adresi, :yapi_kullanim_amac, :aciklama).titleize_tr
},
code: integer(address.dig(:il_ilce_merkez_adresi, :yapi_kullanim_amac, :kod)),
name: string(address.dig(:il_ilce_merkez_adresi, :yapi_kullanim_amac, :aciklama))
}
},
village_address: address[:koy_adresi].titleize_tr,
abroad_address: address[:yurt_disi_adresi].titleize_tr,
reason_of_relocation: address[:tasinma_neden].titleize_tr,
municipality_address: address[:belde_adresi].titleize_tr,
declarant_id_number: address[:beyanda_bulunan_kimlik_no].safe_to_i,
date_of_relocation: address[:tasinma_tarihi] && build_date(*address[:tasinma_tarihi].values_at(:yil, :ay, :gun)),
date_of_declaration: address[:beyan_tarihi] && build_date(*address[:beyan_tarihi].values_at(:yil, :ay, :gun)),
date_of_registration: address[:tescil_tarihi] && build_date(*address[:tescil_tarihi].values_at(:yil, :ay, :gun))
abroad_address: string(address[:yurt_disi_adresi]),
daclaration_date: build_date(*address[:beyan_tarihi].values_at(:yil, :ay, :gun)),
declarant_id_number: integer(address[:beyanda_bulunan_kimlik_no]),
municipality_address: string(address[:belde_adresi]),
reason_of_relocation: string(address[:tasinma_neden]),
registration_date: build_date(*address[:tescil_tarihi].values_at(:yil, :ay, :gun)),
relocation_date: build_date(*address[:tasinma_tarihi].values_at(:yil, :ay, :gun)),
village_address: string(address[:koy_adresi]),
}
end

Expand All @@ -84,21 +84,21 @@ class AddressesSerializer < Serializer
next if address[:hata_bilgisi]

object << {
declarant_id_number: address[:beyanda_bulunan_kimlik_no].safe_to_i,
full_address: address[:acik_adres].titleize_tr,
address_no: address[:adres_no].safe_to_i,
address_no: integer(address[:adres_no]),
declarant_id_number: integer(address[:beyanda_bulunan_kimlik_no]),
full_address: string(address[:acik_adres]),
address_type: {
code: address.dig(:adres_tip, :kod),
description: address.dig(:adres_tip, :aciklama).titleize_tr
code: integer(address.dig(:adres_tip, :kod)),
description: string(address.dig(:adres_tip, :aciklama))
},
village_address: address[:koy_adresi].titleize_tr,
municipality_address: address[:belde_adresi].titleize_tr,
city_address: address[:il_ilce_merkez_adresi].titleize_tr,
abroad_address: address[:yurt_disi_adresi].titleize_tr,
reason_of_relocation: address[:tasinma_neden].titleize_tr,
date_of_relocation: address[:tasinma_tarihi] && build_date(*address[:tasinma_tarihi].values_at(:yil, :ay, :gun)),
date_of_declaration: address[:beyan_tarihi] && build_date(*address[:beyan_tarihi].values_at(:yil, :ay, :gun)),
date_of_registration: address[:tescil_tarihi] && build_date(*address[:tescil_tarihi].values_at(:yil, :ay, :gun))
abroad_address: string(address[:yurt_disi_adresi]),
city_address: string(address[:il_ilce_merkez_adresi]),
daclaration_date: build_date(*address[:beyan_tarihi].values_at(:yil, :ay, :gun)),
municipality_address: string(address[:belde_adresi]),
reason_of_relocation: string(address[:tasinma_neden]),
registration_date: build_date(*address[:tescil_tarihi].values_at(:yil, :ay, :gun)),
relocation_date: build_date(*address[:tasinma_tarihi].values_at(:yil, :ay, :gun)),
village_address: string(address[:koy_adresi]),
}
end

Expand Down
Loading

0 comments on commit fa81c77

Please sign in to comment.