...
Code Block | ||
---|---|---|
| ||
def request_bpmwidget_backend(path, method = :get, parameters = {}) request_params = { method: method, url: build_bpm_widget_path(path), user: bpm_config.login, password: bpm_config.password } 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 { def bpm_parameters code: response.code,{ headersuser_identifier: response.headersuser_identifier, bodyentity_type: response.body } end def request_params(path) { url: build_bpm_widget_path(path)params[:entity_type], userentity_code: configurationparams[:loginentity_code], passwordentity_class: configuration[:password], headers: { 'Content-Type': 'application/json' } } params[:entity_class] } end def build_bpm_widget_path(path = '') URI.join(configuration[:url]bpm_config.url, '/widget/', path).to_s end def configurationrequest_params(path) { url: "http://homs:3000", # hbw_url loginbuild_bpm_widget_path(path), user: "user@example.com", # hbw_login configuration[:login], password: "renewmeplease"configuration[:password], # hbw_tokenheaders: { } 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)) 'Content-Type': 'application/json' } } end def bpm_config YourApplication::Config.widgets.bpm end |
Параметры GET и DELETE запросов должны передаваться в query-части url, например:
...