200
edits
Changes
m
→Obligations of Service logic
What you need to know to write a new Service. How to generate data, and callback methods service logic can or must provide.
Recall that an umlaut "service" is defined in config/umlaut_config/services.yml to be a particular class holding the service logic, and some configuration parameters.
That class holding the service logic is called a "service adaptor", or somewhat ambiguously, sometimes times just a "service". Service adaptors live in lib/service_adaptors, and extend [http://umlaut.rubyforge.org/api/classes/Service.html Service].
====Methods implemented by a service adaptor====
A service adaptor must define [http://umlaut.rubyforge.org/api/classes/Service.html#service_types_generated service_types_generated()] to return an Array of ServiceTypeValues constituting the types of ServiceResponses the service
A service adaptor may optionally list some required configuration params. If they are not supplied, an exception will be thrown when the service is initialized from services.yml. eg:
: required_config_params :api_key, :base_url
url handling.
Avoid stateful-ness, object is re-used accross requests, and due to possible multi-threaded implementation, may even be used concurrently, so write thread-safe. Or avoid state altogether.