Class: CpsFormatter_2

Inherits:
Object
  • Object
show all
Defined in:
lib/imperituroard/platforms/cps/request_formatter.rb

Instance Method Summary collapse

Instance Method Details

#create_subs_for_recreate(answer_from_get_subs) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 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