Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Infodetails
hiddentrue

This article in Russian: Инструкция по интеграции HBW во внешнюю систему

...

  • hbw_url – HydraOMS usl (e.g., http://localhost:3000);

  • hbw_assetspublic_path – url for HydraOMS static files include (usually the same as hbw_urlof HydraOMS which is assessible using browser (e.g. https://some.domain:8100 or https://homs.some.domain, used for loading static files and opening web-sockets. You can use the same value for both hbw_url and hbw_public_path);

  • hbw_login – login (e.g., user@example.com);

  • hbw_token – token (e.g., renewmeplease).

...

  • entity_class – integration type (e.g., billing_customer (Hydra Service Provider Console application), self_care_customer (Hydra Self Care Portal application), customer_care_portal (Hydra Customer Care Portal application) or other string valueapplication name);

  • entity_type – entity type (e.g., customer, account, operator or other string value).

...

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
languageruby
def getrequest_bpmwidget_backend(path, method = :get, parameters = {})
  request_params = request_params(path).merge({
    method:  :get method,
    payloadurl: parameters   )    return response(params)
end

def postbuild_bpm_backendwidget_path(path),
parameters = {})  user: params = request_params(path).merge(  bpm_config.hbw_login,
    methodpassword:  :post,bpm_config.hbw_token
  }
  payload:
parameters  if )method == :get
 return response(params) end

def put_bpm_backend(path, parameters = {} request_params.merge!({headers: {params: parameters.merge(bpm_parameters)}})
  paramselse
=    request_params(path).merge(
    method:  :put,
    !({payload: parameters
  ).merge(bpm_parameters)})
   return response(params)
end
 private 
def response(params)   response = RestClient::Request.execute(request_params)
end
  return
{private
  
 code: response.code,
    headers: response.headers,
    body: response.body
  }
end

def request_params(path)
  return 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 = '')
  return URI.join(configuration[:url]bpm_config.url, '/widget/', path)
end

def configuration
  return {
    url:      "http://localhost:3000", # hbw_url
    login:    "user@example.com",      # hbw_login
    password: "renewmeplease"          # hbw_token
  }
end

def with_user_identifier(parameters)
  return parameters.merge(
    user_identifier: session[:email] # email of current user
  )
end     
  
def allow_params(*allowed_params)
  return 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.: 

...

POST and PUT parameters should be passed as body part of request. Request body's content-type is application/json.

HydraOMS answer content-type is application/json.

Proxy controllers

Proxy controllers are used as an middleware for requests from third-party application to HydraOMS. They check data send by widget and pass it to HydraOMS backend with adding auth headers and other necessary information.

Code Block
languageruby
# ButtonsANY controller
# GET /match 'widget/buttons*path'
def list_buttons(params)proxy
  method = request.method.downcase.to_sym
  returnresult get= request_bpm_backend('buttons', allow_params('entity_class', 'entity_type', 'entity_code'))
end

# POST /widget/buttons
def start_process(params)
  return post_bpm_backend('buttons', allow_params('entity_class', 'entity_type', 'entity_code', 'bp_code', 'initial_variables'))
end


# Tasks controller
# GET /widget/tasks
def list_tasks(params)
  return get_bpm_backend('tasks', allow_params('entity_class', 'entity_code'))
end

# GET /widget/tasks/:id/form
def fetch_task_form(params)
  return get_bpm_backend('tasks/#{params[:id]}/form', allow_params('entity_class', 'id'))
end

# PUT /widget/tasks/:id/form
def save_task_form(params)
  return put_bpm_backend('tasks/#{params[:id]}/form', allow_params('entity_class', 'form_data', 'id'))
end

# GET /widget/tasks/:id/lookup
def fetch_lookup_value(params)
  return get_bpm_backend('tasks/#{params[:id]}/lookup', allow_params('entity_class', 'name', 'q', 'id'))
end


# Users controller
# GET /widget/users/check
def check_user_access(params)
  return get_bpm_backend('users/check')
params[:path], method, permitted_params)
 
  if method == :put
    if result
      head :no_content
    else
      head :bad_request
    end
  else
    render json: result
  end
end
 
private
 
def permitted_params
  params.symbolize_keys.except(*service_params)
end
 
def service_params
  %i[controller action path format]
end

Embedding JS

Here you can find an example of embedding HydraOMS widget into HTML page of third-party application. After external JS and CSS are loaded, HydraOMS widget will be initialized with application and entity data and then render() function is being called.

Code Block
languagexml
titleHTML page example
<html>
<head>
  <title>HydraOMS Widget</title>
  <script type="text/javascript" src="${hbw_assetspublic_path}/assets/hbw.js"></script>
  <link rel="stylesheet" type="text/css" href="${hbw_assetspublic_path}/assets/hbw.css">
</head>
<body>
  <div class="hbw-styles">
   <div <div id='hbw-container'>
   </div>
  </div>
  <script <script type="text/javascript">
    var config = {
      entity_widgetURL: 'https://homs.some.domain', // hbw_public_path, important for WebSocket connection
      entity_class: 'crm_account',
      entity_type: 'customer',
      container_id: 'hbw-container', // Same as <div> id
      userIdentifier: 'user@example.com', // user identifier for Web-Socket connection
      locale: {
        code: 'en', // locale code
        dateTimeFormat: 'MM/DD/YYYY HH:mm aaa' // date-fns format, see https://date-fns.org/v1.30.1/docs/format for more details
      }
    };
    var entityId = ...; // Set here id or other uniq value of entity, like customerId
 
    window.hbw_widget = new (modulejs.require('HBW'))({
      userIdentifier: config.userIdentifier,
      widgetContainer: `#${config.container_id}`,
      widgetURL: config.widgetURL,
      widgetPath: '/widget',
      entity_class: config.entity_class,
      entity_type: config.entity_type,
      entity_code: `${entityId}`,
      locale: config.locale,
      payload: {
        variables: {
          someInitialVariable: { // You can pass other useful information to process initial _variables
            value: 'initialValue',
            type: 'string'
          }
        }
      }
    });
 
    window.hbw_widget.render();
 
    // If you use some kind ot SPA (Single Page Application), call this before exiting current page:
    // window.hbw_widget.unmountWidget();
  </script>
</body>
</html>

...