Class: Zaig::RegistrationPayload

Inherits:
Object
  • Object
show all
Defined in:
lib/zaig/registration_payload.rb

Overview

Service class to build a registration payload request.

Instance Method Summary collapse

Instance Method Details

#call(obj) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/zaig/registration_payload.rb', line 6

def call(obj)
  payload = {
    client_category: obj[:client_category],
    credit_request_date: obj[:credit_request_date],
    credit_type: obj[:credit_type] || "clean",
    document_number: CNPJ.new(obj[:document_number]).formatted,
    id: obj[:id],
    legal_name: obj[:legal_name],
    monthly_revenue: format_money(obj[:monthly_revenue], require_positive: true),
    trading_name: obj[:trading_name]
  }
  payload[:address] = build_address(obj[:address]) if obj[:address]
  payload[:constitution_date] = obj[:constitution_date] if obj[:constitution_date]
  payload[:constitution_type] = obj[:constitution_type] if obj[:constitution_type]
  payload[:email] = obj[:email] if obj[:email]
  payload[:financial] = build_financial(obj[:financial]) if obj[:financial]
  payload[:guarantors] = build_shareholders(obj[:guarantors]) if obj[:guarantors]
  payload[:phones] = build_phones(obj[:phones]) if obj[:phones]
  payload[:scr_parameters] = build_scr_parameters(obj[:scr_parameters]) if obj[:scr_parameters]
  payload[:shareholders] = build_shareholders(obj[:shareholders]) if obj[:shareholders]
  payload[:source] = build_source(obj[:source]) if obj[:source]
  payload[:warrants] = build_warrants(obj[:warrants]) if obj[:warrants]
  payload
end