Class: SigepWeb::SearchClient

Inherits:
WebServiceInterfaceApi show all
Defined in:
lib/sigep_web/search_client.rb

Instance Method Summary collapse

Methods inherited from WebServiceInterfaceApi

#process

Constructor Details

#initialize(options = {}) ⇒ SearchClient

Returns a new instance of SearchClient.



3
4
5
6
7
# File 'lib/sigep_web/search_client.rb', line 3

def initialize(options = {})
  @id_contract = options[:id_contract]
  @id_post_card = options[:id_post_card]
  super()
end

Instance Method Details

#requestObject



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

def request
  authenticate = SigepWeb.configuration.authenticate
  begin
    response = process(:busca_cliente, {
      idContrato: @id_contract,
      idCartaoPostagem: @id_post_card,
      usuario: authenticate.user,
      senha: authenticate.password
    }).to_hash[:busca_cliente_response][:return]

    {
      success: true,
      response: response
    }
  rescue Savon::SOAPFault => msg
    {
      success: false,
      error: msg
    }
  end
end