Class: Biro::Ph3a::Response

Inherits:
BaseResponse show all
Defined in:
lib/biro/gateways/ph3a/response.rb

Instance Attribute Summary

Attributes inherited from BaseResponse

#body

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



6
7
8
# File 'lib/biro/gateways/ph3a/response.rb', line 6

def initialize response
  @body = response.body
end

Instance Method Details

#addressesObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/biro/gateways/ph3a/response.rb', line 10

def addresses
  Array.wrap(person_data_result.dig(:addresses)&.dig(:source)&.dig(:address)).map do |t|
    {
      city: t.dig(:city),
      complement: t.dig(:complement),
      country: t.dig(:country),
      is_enabled: t.dig(:is_enabled),
      match: t.dig(:match),
      neighboorhood: t.dig(:district),
      number: t.dig(:number),
      score: t.dig(:score).to_i,
      state: t.dig(:state),
      street: t.dig(:street),
      type: t.dig(:type),
      zip_code: t.dig(:zip_code),
      phone_area_code: t.dig(:area_code),
      phone: t.dig(:phone)
    }
  end
end

#ageObject



31
32
33
# File 'lib/biro/gateways/ph3a/response.rb', line 31

def age
  person_data_result.dig(:age).to_i
end

#birthdateObject



35
36
37
# File 'lib/biro/gateways/ph3a/response.rb', line 35

def birthdate
  person_data_result.dig(:birth_date)
end

#blood_typeObject



39
40
41
# File 'lib/biro/gateways/ph3a/response.rb', line 39

def blood_type
  person_data_result.dig(:blood_type)
end

#ccfObject



43
44
45
# File 'lib/biro/gateways/ph3a/response.rb', line 43

def ccf
  person_data_result.dig(:ccf)
end

#ccf_historyObject



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/biro/gateways/ph3a/response.rb', line 47

def ccf_history
  Array.wrap(person_data_result.dig(:ccf_historico)&.dig(:ccf)).map do |t|
    {
      agency: t.dig(:agencia).to_i,
      bank_code: t.dig(:codigo_banco).to_i,
      reason: t.dig(:motivo),
      amount: t.dig(:quantidade),
      occurrence_date: t.dig(:ultima_ocorrencia),
    }
  end
end

#ccf_totalObject



59
60
61
# File 'lib/biro/gateways/ph3a/response.rb', line 59

def ccf_total
  person_data_result.dig(:ccf_total).to_i
end

#compound_nameObject



63
64
65
# File 'lib/biro/gateways/ph3a/response.rb', line 63

def compound_name
  person_data_result.dig(:compound_name)
end

#contact_personsObject



67
68
69
# File 'lib/biro/gateways/ph3a/response.rb', line 67

def contact_persons
  person_data_result.dig(:contact_persons)
end

#contact_persons_historyObject



71
72
73
# File 'lib/biro/gateways/ph3a/response.rb', line 71

def contact_persons_history
  person_data_result.dig(:contact_persons_history)
end

#cpfObject



95
96
97
# File 'lib/biro/gateways/ph3a/response.rb', line 95

def cpf
  person_data_result.dig(:document)
end

#deathObject



276
277
278
# File 'lib/biro/gateways/ph3a/response.rb', line 276

def death
  person_data_result.dig(:supposed_death)
end

#death_dateObject



75
76
77
# File 'lib/biro/gateways/ph3a/response.rb', line 75

def death_date
  person_data_result.dig(:death_date)
end

#death_yearObject



79
80
81
# File 'lib/biro/gateways/ph3a/response.rb', line 79

def death_year
  person_data_result.dig(:death_year)
end

#deficiencyObject



83
84
85
# File 'lib/biro/gateways/ph3a/response.rb', line 83

def deficiency
  person_data_result.dig(:deficiency)
end

#deficiency_listObject



87
88
89
# File 'lib/biro/gateways/ph3a/response.rb', line 87

def deficiency_list
  person_data_result.dig(:deficiencys)
end

#digital_behaviorObject



91
92
93
# File 'lib/biro/gateways/ph3a/response.rb', line 91

def digital_behavior
  person_data_result.dig(:digital_behavior)
end

#educationObject



99
100
101
102
103
104
# File 'lib/biro/gateways/ph3a/response.rb', line 99

def education
  {
    description: person_data_result.dig(:education_level)&.dig(:description),
    level: person_data_result.dig(:education_level)&.dig(:education_level).to_i
  }
end

#emailsObject



106
107
108
109
110
111
112
113
# File 'lib/biro/gateways/ph3a/response.rb', line 106

def emails
  Array.wrap(person_data_result.dig(:emails)&.dig(:email)).map do |t|
    {
      address: t.dig(:email_value),
      is_enabled: t.dig(:is_enabled),
    }
  end
end

#eye_colorObject



115
116
117
# File 'lib/biro/gateways/ph3a/response.rb', line 115

def eye_color
  person_data_result.dig(:eye_color)
end

#fathers_documentObject



119
120
121
# File 'lib/biro/gateways/ph3a/response.rb', line 119

def fathers_document
  person_data_result.dig(:father_document)
end

#fathers_nameObject



123
124
125
# File 'lib/biro/gateways/ph3a/response.rb', line 123

def fathers_name
  person_data_result.dig(:father_name)
end

#first_nameObject



127
128
129
# File 'lib/biro/gateways/ph3a/response.rb', line 127

def first_name
  person_data_result.dig(:first_name)
end

#genderObject



131
132
133
# File 'lib/biro/gateways/ph3a/response.rb', line 131

def gender
  person_data_result.dig(:genre)
end

#hair_colorObject



135
136
137
# File 'lib/biro/gateways/ph3a/response.rb', line 135

def hair_color
  person_data_result.dig(:hair_color)
end

#heightObject



139
140
141
# File 'lib/biro/gateways/ph3a/response.rb', line 139

def height
  person_data_result.dig(:height)
end

#last_nameObject



151
152
153
# File 'lib/biro/gateways/ph3a/response.rb', line 151

def last_name
  person_data_result.dig(:last_name)
end

#marital_statusObject



155
156
157
# File 'lib/biro/gateways/ph3a/response.rb', line 155

def marital_status
  person_data_result.dig(:marital_status)
end

#match_nameObject



159
160
161
# File 'lib/biro/gateways/ph3a/response.rb', line 159

def match_name
  person_data_result.dig(:match_name)
end

#middle_nameObject



163
164
165
# File 'lib/biro/gateways/ph3a/response.rb', line 163

def middle_name
  person_data_result.dig(:middle_name)
end

#mothers_documentObject



167
168
169
# File 'lib/biro/gateways/ph3a/response.rb', line 167

def mothers_document
  person_data_result.dig(:mother_document)
end

#mothers_nameObject



171
172
173
# File 'lib/biro/gateways/ph3a/response.rb', line 171

def mothers_name
  person_data_result.dig(:mother_name)
end

#nacionalityObject



175
176
177
# File 'lib/biro/gateways/ph3a/response.rb', line 175

def nacionality
  person_data_result.dig(:nacionality)
end

#nameObject



179
180
181
# File 'lib/biro/gateways/ph3a/response.rb', line 179

def name
  person_data_result.dig(:name)
end

#name_cpf_brasilObject



183
184
185
# File 'lib/biro/gateways/ph3a/response.rb', line 183

def name_cpf_brasil
  person_data_result.dig(:name_cpf_brasil)
end

#number_dependentsObject



187
188
189
# File 'lib/biro/gateways/ph3a/response.rb', line 187

def number_dependents
  person_data_result.dig(:number_dependents).to_i
end

#pepObject



208
209
210
# File 'lib/biro/gateways/ph3a/response.rb', line 208

def pep
  person_data_result.dig(:politically_exposed_person)
end

#person_householdObject



212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/biro/gateways/ph3a/response.rb', line 212

def person_household
  Array.wrap(person_data_result.dig(:person_household)&.dig(:person_household)).map do |t|
    {
      addresses: person_household_addresses(t.dig(:adresses)),
      call_name: t.dig(:call_name),
      complete_name: t.dig(:complete_name),
      document: t.dig(:document),
      father_name: t.dig(:father_name),
      first_name: t.dig(:first_name),
      genre: t.dig(:genre),
      iptu: t.dig(:iptu),
      kinship: t.dig(:kinship),
      last_name: t.dig(:last_name),
      match_name: t.dig(:match_name),
      middle_name: t.dig(:middle_name),
      mother_name: t.dig(:mother_name),
      second_name: t.dig(:second_name),
      suffix_name: t.dig(:suffix_name),
      vehicles: t.dig(:vehicles)
    }
  end
end

#phonesObject



191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/biro/gateways/ph3a/response.rb', line 191

def phones
  Array.wrap(person_data_result.dig(:phones)&.dig(:phone)).map do |t|
    {
      area_code: t.dig(:area_code).to_i,
      at_procon: t.dig(:at_procon),
      document: t.dig(:document),
      full_name: t.dig(:full_name),
      is_enabled: t.dig(:is_enabled),
      is_household: t.dig(:is_household),
      is_mobile: t.dig(:is_mobile),
      number_simple: t.dig(:number_simple),
      number: t.dig(:phone_number),
      operator_name: t.dig(:phone_operator_name)
    }
  end
end

#professional_infoObject



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/biro/gateways/ph3a/response.rb', line 235

def professional_info
  Array.wrap(person_data_result.dig(:professional_data)&.dig(:professional_data)).map do |t|
    {
      cbo: t.dig(:cbo).to_i,
      cbo_description: t.dig(:cbo_descricao),
      company_cnpj: t.dig(:cnpj),
      company_address: t.dig(:cmpany_address),
      admission_date: t.dig(:data_admissao),
      resignation_date: t.dig(:data_demissao),
      family_salary: t.dig(:family_salary),
      pis: t.dig(:pis),
      social_name: t.dig(:razao_social),
      income_from: t.dig(:renda_de).to_f,
      income_to: t.dig(:renda_ate).to_f,
      salary: t.dig(:salario).to_f,
      admission_type: t.dig(:tipo_admissao).to_i,
      resignation_type: t.dig(:tipo_demissao).to_i
    }
  end
end

#retiredObject



256
257
258
# File 'lib/biro/gateways/ph3a/response.rb', line 256

def retired
  person_data_result.dig(:retired_data)
end

#rgObject



143
144
145
# File 'lib/biro/gateways/ph3a/response.rb', line 143

def rg
  person_data_result.dig(:id_card)
end

#rg_stateObject



147
148
149
# File 'lib/biro/gateways/ph3a/response.rb', line 147

def rg_state
  person_data_result.dig(:id_card_state)
end

#second_nameObject



260
261
262
# File 'lib/biro/gateways/ph3a/response.rb', line 260

def second_name
  person_data_result.dig(:second_name)
end

#skin_colorObject



264
265
266
# File 'lib/biro/gateways/ph3a/response.rb', line 264

def skin_color
  person_data_result.dig(:skin_color)
end

#spouses_documentObject



268
269
270
# File 'lib/biro/gateways/ph3a/response.rb', line 268

def spouses_document
  person_data_result.dig(:spouse_document)
end

#spouses_nameObject



272
273
274
# File 'lib/biro/gateways/ph3a/response.rb', line 272

def spouses_name
  person_data_result.dig(:spouse_name)
end

#vehiclesObject



280
281
282
# File 'lib/biro/gateways/ph3a/response.rb', line 280

def vehicles
  person_data_result.dig(:vehicles)
end

#voter_idObject



284
285
286
# File 'lib/biro/gateways/ph3a/response.rb', line 284

def voter_id
  person_data_result.dig(:voter_registration)
end

#weightObject



288
289
290
# File 'lib/biro/gateways/ph3a/response.rb', line 288

def weight
  person_data_result.dig(:weight).to_f
end