Class: Biro::Ph3a::Request

Inherits:
BaseRequest show all
Includes:
Utils::Soap
Defined in:
lib/biro/gateways/ph3a/request.rb

Instance Method Summary collapse

Methods included from Utils::Soap

#soap, #wsdl

Methods inherited from BaseRequest

#initialize, #url

Constructor Details

This class inherits a constructor from Biro::BaseRequest

Instance Method Details

#development_urlObject



6
7
8
# File 'lib/biro/gateways/ph3a/request.rb', line 6

def development_url
  'https://ws.databusca.com.br/DataHistory.svc?wsdl'
end

#find(document) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/biro/gateways/ph3a/request.rb', line 18

def find(document)
  begin
    @retries ||= 0
    @token = nil

    params = {}
    get_parameters params, document
    response = soap.call(:get_person_data, message: params)
    Response.new(response)
  rescue => e
    Biro.log(:warn, "Unable to process Ph3a request")

    retry if (@retries += 1) < 3 && e.message.include?("User not authenticated")
    raise AuthenticationError.new("Error at PH3A request: #{e.message}") if e.message.include?("User not authenticated")
    raise StandardError.new("Error at PH3A request: #{e.message}")
  end
end

#production_urlObject



10
11
12
# File 'lib/biro/gateways/ph3a/request.rb', line 10

def production_url
  'https://ws.databusca.com.br/DataHistory.svc?wsdl'
end

#required_paramsObject



14
15
16
# File 'lib/biro/gateways/ph3a/request.rb', line 14

def required_params
  [:username, :password, :domain]
end