Class: ApiBrasil::Services::BaseService

Inherits:
Object
  • Object
show all
Defined in:
lib/api_brasil/services/base_service.rb

Overview

Base de todos os servicos - guarda o cliente HTTP compartilhado e expoe os atalhos por verbo.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ BaseService

Returns a new instance of BaseService.

Parameters:



12
13
14
# File 'lib/api_brasil/services/base_service.rb', line 12

def initialize(http)
  @http = http
end

Instance Attribute Details

#httpApiBrasil::Core::HttpClient (readonly)



9
10
11
# File 'lib/api_brasil/services/base_service.rb', line 9

def http
  @http
end

Instance Method Details

#delete(path, body = nil, options = {}) ⇒ Object

Returns:

  • (Object)


37
38
39
# File 'lib/api_brasil/services/base_service.rb', line 37

def delete(path, body = nil, options = {})
  http.delete(path, body, options)
end

#download(path, options = {}) ⇒ String

Baixa os bytes crus de uma rota (PDF, imagens...).

Returns:

  • (String)


44
45
46
# File 'lib/api_brasil/services/base_service.rb', line 44

def download(path, options = {})
  http.get(path, { response_type: "raw" }.merge(options))
end

#get(path, options = {}) ⇒ Object

Returns:

  • (Object)


17
18
19
# File 'lib/api_brasil/services/base_service.rb', line 17

def get(path, options = {})
  http.get(path, options)
end

#patch(path, body = nil, options = {}) ⇒ Object

Returns:

  • (Object)


32
33
34
# File 'lib/api_brasil/services/base_service.rb', line 32

def patch(path, body = nil, options = {})
  http.patch(path, body, options)
end

#post(path, body = nil, options = {}) ⇒ Object

Returns:

  • (Object)


22
23
24
# File 'lib/api_brasil/services/base_service.rb', line 22

def post(path, body = nil, options = {})
  http.post(path, body, options)
end

#put(path, body = nil, options = {}) ⇒ Object

Returns:

  • (Object)


27
28
29
# File 'lib/api_brasil/services/base_service.rb', line 27

def put(path, body = nil, options = {})
  http.put(path, body, options)
end