Class: BBR::GetIdFromAddress

Inherits:
Object
  • Object
show all
Extended by:
BBR
Defined in:
lib/bbr/get_id_from_address.rb

Class Method Summary collapse

Methods included from BBR

bbr_id_from_address, building_data_from_address, building_data_from_bbr_id, raw_building_data_from_address, raw_building_data_from_bbr_id

Class Method Details

.call(address) ⇒ Object



5
6
7
# File 'lib/bbr/get_id_from_address.rb', line 5

def self.call(address)
  formatted_response(request(request_action, xml_body(address)))
end

.formatted_response(response = nil) ⇒ Object



27
28
29
# File 'lib/bbr/get_id_from_address.rb', line 27

def self.formatted_response(response=nil)
  response.present? ? response.at_xpath('//BygningId').try(:content) : nil
end

.request_actionObject



23
24
25
# File 'lib/bbr/get_id_from_address.rb', line 23

def self.request_action
  @request_action ||= 'EnhedSearch'
end

.xml_body(address) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/bbr/get_id_from_address.rb', line 10

def self.xml_body(address)
  <<-XML
    <da:EnhedSearch>
      <da:inputRecord>
        <ns:Field>
          <ns:Type>EntireAddress</ns:Type>
          <ns:Value>#{ address }</ns:Value>
        </ns:Field>
      </da:inputRecord>
    </da:EnhedSearch>
  XML
end