Class: LocalSearchService::LocalSearchService
- Inherits:
-
AuthenticatedService
- Object
- Handsoap::Service
- BasicService
- AuthenticatedService
- LocalSearchService::LocalSearchService
- Defined in:
- lib/local_search_service/local_search_service.rb
Overview
Client to access the developer garden ip location service.
See also:
Constant Summary collapse
- @@LOCAL_SEARCH_SCHEMA =
'http://localsearch.developer.telekom.com/schema/'
- @@LOCAL_SEARCH_SCHEMA_SERVICE_ENDPOINT =
{ :uri => "https://gateway.developer.telekom.com/p3gw-mod-odg-localsearch/services/localsearch", :version => 1 }
Class Method Summary collapse
-
.LOCAL_SEARCH_SCHEMA ⇒ Object
Static Methods.
-
.xpath_query(doc, query_string, global_search = true) ⇒ Object
Performs a xpath query in the ip location namespace for the given document and query string.
Instance Method Summary collapse
-
#local_search(search_parameter = { :what => "test" }, environment = ServiceEnvironment.MOCK) ⇒ Object
Retrieves spatial information about the given ip address.
- #on_create_document(doc) ⇒ Object
Methods inherited from AuthenticatedService
#initialize, #invoke_authenticated
Methods inherited from BasicService
#initialize, #on_response_document
Constructor Details
This class inherits a constructor from AuthenticatedService
Class Method Details
.LOCAL_SEARCH_SCHEMA ⇒ Object
Static Methods
75 76 77 |
# File 'lib/local_search_service/local_search_service.rb', line 75 def self.LOCAL_SEARCH_SCHEMA return @@LOCAL_SEARCH_SCHEMA end |
.xpath_query(doc, query_string, global_search = true) ⇒ Object
Performs a xpath query in the ip location namespace for the given document and query string.
Parameters
doc
-
XmlQueryFront document.
query_string
-
Element to look for
global_search
-
Searches within all levels using “//” if
global_search = true
.
85 86 87 |
# File 'lib/local_search_service/local_search_service.rb', line 85 def self.xpath_query(doc, query_string, global_search = true) self.xpath_query_for_schema(@@LOCAL_SEARCH_SCHEMA, doc, query_string, global_search) end |
Instance Method Details
#local_search(search_parameter = { :what => "test" }, environment = ServiceEnvironment.MOCK) ⇒ Object
Retrieves spatial information about the given ip address.
Parameters
search_parameters
-
Search parameter hash specifying the terms and options to perform the search. Have a look at the developer garden service documentation for more details about valid parameters and their behavior.
environment
-
Service environment as defined in ServiceLevel.
Returns
A LocalSearchResponse object. This object has a search_result
-method which returns an Handsoap::XmlQueryFront::NodeSelection
object. NodeSelection is basically part of Handsoap’s XmlQueryFront, a concept to abstract from the underlying xml parser which is currently nokogiri, by default. Have a closer look at the Handsoap-Framework at github (github.com/unwire/handsoap/) to get more details about this. Don’t hestitate to clone the project and have a look at its source code. It’s not too much code and is fairly easy to read. For more information about the xml structure of the response object please refer to the Developergarden documentation.
The tests of this gem also show some basic examples on how to parse a LocalSearchResult.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/local_search_service/local_search_service.rb', line 52 def local_search(search_parameter = { :what => "test" }, environment = ServiceEnvironment.MOCK) response = nil response = invoke_authenticated("local:LocalSearchRequest") do |request, doc| request.add('environment', environment) search_parameter.each_pair do |param, value| request.add('searchParameters') do |params| unless value.nil? then params.add("parameter", param.to_s) params.add("value", value.to_s) end end end end response = LocalSearchResponse.new(response) return response end |
#on_create_document(doc) ⇒ Object
29 30 31 32 |
# File 'lib/local_search_service/local_search_service.rb', line 29 def on_create_document(doc) super(doc) doc.alias 'local', @@LOCAL_SEARCH_SCHEMA end |