Class: BigCheck::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/big_check/client.rb

Constant Summary collapse

ENDPOINT =
'https://webservices.cibg.nl/Ribiz/OpenbaarV4.asmx?wsdl'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



7
8
9
# File 'lib/big_check/client.rb', line 7

def initialize
  @client = @client || Savon.client(wsdl: ENDPOINT, log: false, raise_errors: false, ssl_verify_mode: :none)
end

Instance Attribute Details

#classificationsObject (readonly)

Returns the value of attribute classifications.



5
6
7
# File 'lib/big_check/client.rb', line 5

def classifications
  @classifications
end

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/big_check/client.rb', line 5

def client
  @client
end

#hcpObject (readonly)

Returns the value of attribute hcp.



5
6
7
# File 'lib/big_check/client.rb', line 5

def hcp
  @hcp
end

#responseObject (readonly)

Returns the value of attribute response.



5
6
7
# File 'lib/big_check/client.rb', line 5

def response
  @response
end

Instance Method Details

#check_by_big(big_number) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/big_check/client.rb', line 11

def check_by_big(big_number)
  message = {
    "WebSite" => "Ribiz",
    "RegistrationNumber" => big_number
  }
  begin
    @response = @client.call(:list_hcp_approx4, message: message)
    fail unless @response.http.code == 200
    @hcp = BigCheck::HCP.new(@response.body)
    return true
  rescue Savon::SOAPFault => e
    raise NotFoundError.new(e.message)
  rescue Savon::HTTPError => e
    raise ServerNotFoundError.new(e.message)
  rescue => e
    raise UnknownError.new(e.message)
  end
end

#get_classificationsObject



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/big_check/client.rb', line 30

def get_classifications
  begin
    @response = @client.call(:get_ribiz_reference_data)
    fail unless @response.http.code == 200
    @classifications = BigCheck::Classifications.new(@response.body)
  rescue Savon::SOAPFault => e
    raise NotFoundError.new(e.message)
  rescue Savon::HTTPError => e
    raise ServerNotFoundError.new(e.message)
  rescue => e
    raise UnknownError.new(e.message)
  end
end