class CpsFormatter_2

Public Instance Methods

create_subs_for_recreate(answer_from_get_subs) click to toggle source
# File lib/imperituroard/platforms/cps/request_formatter.rb, line 5
def create_subs_for_recreate(answer_from_get_subs)

  output_result = {}

  credent = answer_from_get_subs["get_subscriber_response"]["subscriber"]["credential"]

  credd = []

  for dd in credent

    if dd.key?("type")
      credd.append({:networkId => dd["network_id"], :type => dd["type"]})
    else
      credd.append({:networkId => dd["network_id"]})
    end
  end

  service = answer_from_get_subs["get_subscriber_response"]["subscriber"]["service"]
  notify = answer_from_get_subs["get_subscriber_response"]["subscriber"]["notification"]
  avp = answer_from_get_subs["get_subscriber_response"]["subscriber"]["avp"]

  if notify == nil || notify == {}
    if avp != nil && avp != {}
      output_result = {:subscriber => {:credential => credd, :service => service, :avp => avp}}
    else
      output_result = {:subscriber => {:credential => credd, :service => service}}
    end
  else
    if avp != nil && avp != {}
      output_result = {:subscriber => {:credential => credd, :notification => notify, :service => service, :avp => avp}}
    else
      output_result = {:subscriber => {:credential => credd, :notification => notify, :service => service}}
    end
  end
  output_result
end