2.3 KiB
KYC: Residence
Sprint: ?
Outcome:
User can add address with complete information(city and province and etc..)
Endpoints:
POST {$domain}/api/v2/barong/resource/profiles/address
File destination:
{$Dalan_Path}/app/api/v2/resource/profiles.rb
Commits:
f7820d8 3e0fff4 67c41b3 f420fa4 bff2746 63977c3
What did we implement:
Opendax just implements address as a string but we need more information like city and province and document for residency.
So first of all we implemented city and province as below steps:
1.create migrations:
20210420111532_create_provinces.rb → have just a name
20210420111629_create_cities.rb → have name and must connect to province(foreign key) references :province, foreign_key: true
2.create models
Province model:
-
Create validation for name: only allows letters, digits "-", "'", and space. length: 1..255
-
Mention to rails that this model has many cities
City model:
- Mention to rails that this model belongs to province and this column is required.
- Create validation for name: only allows letters, digits "-", "'", and space. length: 1..255
we need seeds to fill city and province tables. So we used a JSON file from git and create a seed. data of the seed was put in config/seeds.yml file and the functions are in lib/barong/seed.rb.(seed_provinces and seed_cities) they check the existence of the data(city or province) then create it in db.
After these steps, we were ready to create a new API. we check the existence of the city and province that the user has been sent and create poa label. if user submitted another doc for poa and it has not been accepted, the new document will be replaced.
sequenceDiagram
title: residence
User->>Ranj: residence information
Ranj-->>Dalan: post /profiles/address params
Dalan->>Ranj: 400, message: 'Required params are empty'
Dalan->>Ranj: 401, message: 'Invalid bearer token'
Dalan->>Ranj: 404, message: 'needed data doesnt exist'
Dalan->>Ranj: 422, message: 'Validation errors',(address.already_exist,province_doesnt_exist)
Dalan->>Ranj: 422, message: 'code_doesnt_expired'(there is an active process for addding new mobile)
Dalan->>Ranj: 200, message: 'New phone was added'
note left of Dalan: if there is a pending address it will be replaced with new one