Class: ModelParser

Inherits:
Object
  • Object
show all
Defined in:
lib/Helpers/model_parser.rb

Instance Method Summary collapse

Instance Method Details

#ParseCustomerBeneficiary(benificiaryHashed) ⇒ Object



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/Helpers/model_parser.rb', line 178

def ParseCustomerBeneficiary(benificiaryHashed)

  beneficiary = Beneficiary.new(benificiaryHashed)

  #parse Services
  if(beneficiary)

    servicesArr = beneficiary.instance_variable_get("@services")

    servicesLst = []
    if(servicesArr)
      servicesArr.each do |ser|

        buffService = Service.new(ser)
        servicesLst << buffService

      end
    end
    beneficiary.Services = servicesLst
  end

  return beneficiary
end

#ParseCustomerEntityResponse(entityResponseHashed) ⇒ Object



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/Helpers/model_parser.rb', line 202

def ParseCustomerEntityResponse(entityResponseHashed)

  custEntResp = CustomerEntityResponse.new(entityResponseHashed)

  validationErrs = custEntResp.instance_variable_get("@validationErrors")

  respValidationErrs = ValidationError.new(validationErrs)

  if(respValidationErrs.instance_variable_get("@errorDetails"))

    errDetailsArr = respValidationErrs.instance_variable_get("@errorDetails")
    if(errDetailsArr)

      validationErrsList = []
      errDetailsArr.each do |ed|

        vErr = ValidationError.new(ed)
        validationErrsList << vErr

      end

      respValidationErrs.ErrorDetails = validationErrsList

    end

  end

  custEntResp.ValidationErrors = respValidationErrs

  return custEntResp

end

#ParseCustomerObject(objHashed) ⇒ Object



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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/Helpers/model_parser.rb', line 13

def ParseCustomerObject(objHashed)


  #puts objHashed
  buffCustomer = Customer.new(objHashed)

  #Parse and populate CreditCards
  if(buffCustomer.instance_variable_get("@creditCards"))
    #puts 'Has Creditcards'

    cardsArr = buffCustomer.instance_variable_get("@creditCards")
    cardsList = []

    cardsArr.each do |c|

      buffCard = CreditCard.new(c)
      cardsList << buffCard
    end

    buffCustomer.CreditCards = cardsList

  end

  #Parse and populate Accounts
  if(buffCustomer.instance_variable_get("@customerEntities"))
    #puts 'Has Accounts'

    accountsArr = buffCustomer.instance_variable_get("@customerEntities")
    accountsList = []

    accountsArr.each do |acc|

      buffAccount = CustomerEntity.new(acc)

      #parse beneficiary and services
      benificHashed = buffAccount.instance_variable_get("@entityBeneficiary")
      accBeneficiary = ParseCustomerBeneficiary(benificHashed)

      buffAccount.EntityBeneficiary = accBeneficiary

      entityRespHashed = buffAccount.instance_variable_get("@responseDetails")
      custEntResponse = ParseCustomerEntityResponse(entityRespHashed)

      buffAccount.ResponseDetails = custEntResponse

      accountsList << buffAccount

    end
    buffCustomer.CustomerEntities = accountsList
  end

  #Parse and populate paymentInstructions
  if(buffCustomer.instance_variable_get("@paymentInstructions"))

    instructionsArr = buffCustomer.instance_variable_get("@paymentInstructions")
    instructionsList = []

    instructionsArr.each do |inst|

      buffInstruction = Instruction.new(inst)
      instructionsList << buffInstruction

    end
    buffCustomer.PaymentInstructions = instructionsList
  end

  #Parse and populate ACHs
  if(buffCustomer.instance_variable_get("@aCHs"))
    #puts 'Has ACHs'

    achsArr = buffCustomer.instance_variable_get("@aCHs")
    achsList = []

    achsArr.each do |ach|

      buffAch = ACH.new(ach)

      resDetail = buffAch.instance_variable_get("@responseDetails")
      instrumentResp = InstrumentResponse.new(resDetail)

      #parse instrumentResp.ValidationErrors
      valErrs = instrumentResp.instance_variable_get("@validationErrors")
      instrumentResp.ValidationErrors = ValidationError.new(valErrs)


      buffAch.ResponseDetails = instrumentResp

      achsList << buffAch

    end
    buffCustomer.ACHs = achsList
  end

  #Parse and populate billing Addresses
  if(buffCustomer.instance_variable_get("@billingAddress"))


    billingAddressArr = buffCustomer.instance_variable_get("@billingAddress")
    billingAddressArrList = []

    billingAddressArr.each do |ba|

      buffBillAddr = Address.new(ba)
      billingAddressArrList << buffBillAddr

    end
    buffCustomer.BillingAddress = billingAddressArrList
  end

  #Parse and populate shipping Addresses
  if(buffCustomer.instance_variable_get("@shippingAddress"))

    shippingAddressArr = buffCustomer.instance_variable_get("@shippingAddress")
    shippingAddressList = []

    shippingAddressArr.each do |sa|

      buffShipAddr = Address.new(sa)
      shippingAddressList << buffShipAddr

    end

    buffCustomer.ShippingAddress = shippingAddressList
  end

  #Parse and populate ResponseDetails
  if(buffCustomer.instance_variable_get("@responseDetails"))
    #puts 'HAS RESPONSE DETAILS'

    responseDetails = buffCustomer.instance_variable_get("@responseDetails")
    buffResponseDet = CustomerResponse.new(responseDetails)

    #parse inner model as well
    validationErrors = buffResponseDet.instance_variable_get("@validationErrors")
    buffValisationErrors = ValidationError.new(validationErrors)
    buffResponseDet.ValidationErrors = buffValisationErrors

    buffCustomer.ResponseDetails = buffResponseDet


  end

  #Parse and populate Options
  if(buffCustomer.instance_variable_get("@options"))
    #puts 'HAS OPTIONS'

    options = buffCustomer.instance_variable_get("@options")
    buffOptions = CustomerResponse.new(options)

    #parse inner model as well
    validationErrors = buffOptions.instance_variable_get("@validationErrors")
    buffValisationErrors = ValidationError.new(validationErrors)
    buffOptions.ValidationErrors = buffValisationErrors

    buffCustomer.Options = buffOptions


  end

  return buffCustomer

end