Class: BancoBrasilStatements::StatementsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/bb_statements/api/statements_api.rb

Constant Summary collapse

PAGE_SIZE =
50

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ StatementsApi

Returns a new instance of StatementsApi.



7
8
9
10
# File 'lib/bb_statements/api/statements_api.rb', line 7

def initialize(api_client = ApiClient.default)
  @api_client = api_client
  @gw_app_key = api_client.config.gw_app_key
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



3
4
5
# File 'lib/bb_statements/api/statements_api.rb', line 3

def api_client
  @api_client
end

#gw_app_keyObject

Returns the value of attribute gw_app_key.



3
4
5
# File 'lib/bb_statements/api/statements_api.rb', line 3

def gw_app_key
  @gw_app_key
end

Instance Method Details

#consult_statements(branch_office, account, opts = {}) ⇒ Object

GET /conta-corrente/agencia/agencia/conta/conta Consulta os extratos de uma conta.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/bb_statements/api/statements_api.rb', line 14

def consult_statements(branch_office, , opts = {})
  client_opts = build_client_opts(api_client: api_client,
                                  gw_app_key: gw_app_key,
                                  opts: opts) 

  # query parameters
  query_params = client_opts[:query_params]
  query_params[@api_client.config.app_key_name.to_sym] = gw_app_key
  query_params[:dataInicioSolicitacao] = opts[:start_date].strftime('%d%m%Y').to_i unless opts[:start_date].nil?
  query_params[:dataFimSolicitacao] = opts[:end_date].strftime('%d%m%Y').to_i unless opts[:end_date].nil?
  query_params[:quantidadeRegistroPaginaSolicitacao] = unless opts[:page_size].nil?
    opts[:page_size]
  else
    PAGE_SIZE
  end

  query_params[:numeroPaginaSolicitacao] = opts[:page_index] unless opts[:page_index].nil?

  unless Rails.env.production?
    branch_office = 452
     = 123873
  end

  api_client.call_api(:GET, "/conta-corrente/agencia/#{branch_office}/conta/#{}", client_opts)
end