Class: Cnes::HttpClientFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/cnes/http_client_factory.rb

Instance Method Summary collapse

Instance Method Details

#createObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/cnes/http_client_factory.rb', line 5

def create
  request = Koine::RestClient::Request.new(
    base_url: 'http://cnes.datasus.gov.br',
    headers: { 'Referer' => 'http://cnes.datasus.gov.br' }
  )

  cnes = Koine::RestClient::Client.new(base_request: request)

  request = Koine::RestClient::Request.new(
    base_url: 'https://apidadosabertos.saude.gov.br/'
  )

  dados_abertos = Koine::RestClient::Client.new(base_request: request)

  HttpClient.new(cnes: cnes, dados_abertos: dados_abertos)
end