Infodetails | ||
---|---|---|
| ||
This article in Russian: Инструкция по интеграции HBW во внешнюю систему |
...
The following methods need to be implemented for sending requests ted for sending GET, POST, PUT and PUT DELETE requests to the HydraOMS backend:
Code Block | ||
---|---|---|
| ||
def request_bpmwidget_backend(path, method = :get, parameters = {}) request_params = { method: method, url: build_bpm_widget_path(path), user: bpm_config.hbw_login, password: bpm_config.passwordhbw_token } if method == :get request_params.merge!({headers: {params: parameters.merge(bpm_parameters)}}) else request_params.merge!({payload: parameters.merge(bpm_parameters)}) end response(params) end private def response(params) response = RestClient::Request.execute(request_params) end {private code: response.code, headers: response.headers, body: response.body } end def request_params(path)def bpm_parameters { urluser_identifier: build_bpm_widget_path(path)config[:hbw_login], userentity_type: configurationparams[:loginentity_type], passwordentity_code: configuration params[:passwordentity_code], headersentity_class: { 'Content-Type': 'application/json' } } end params[:entity_class] } end def build_bpm_widget_path(path = '') URI.join(configuration[:url]bpm_config.url, '/widget/', path) end def configuration { url: "http://homs:3000", # hbw_url login: "user@example.com", # hbw_login password: "renewmeplease" # hbw_token } end def with_user_identifier(parameters) parameters.merge( user_identifier: session[:email] # email of current user ) end def allow_params(*allowed_params) with_user_identifier(params.slice(*allowed_params)) end |
...
.to_s
end
def bpm_config
YourApplication::Config.widgets.bpm
end |
GET and DELETE parameters should be passed as query part of url, e.g.:
...