Page tree

Versions Compared

Key

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

...

  • 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 and PUT requests to the HydraOMS backend:

Code Block
languageruby
def get_bpm_backend(path, parameters = {})
  params = request_params(path).merge(
    method:  :get,
    payload: parameters
  )

  return response(params)
end

def post_bpm_backend(path, parameters = {})
  params = request_params(path).merge(
    method:  :post,
    payload: parameters
  )

  return response(params)
end

def put_bpm_backend(path, parameters = {})
  params = request_params(path).merge(
    method:  :put,
    payload: parameters
  )

  return response(params)
end

private

def response(params)
  response = RestClient::Request.execute(params)

  return {
    code: response.code,
    headers: response.headers,
    body: response.body
  }
end

def request_params(path)
  return {
    url:      build_bpm_widget_path(path),
    user:     configuration[:login],
    password: configuration[:password],
    headers: {
      'Content-Type': 'application/json'
    }
  }
end

def build_bpm_widget_path(path = '')
  return URI.join(configuration[: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

...