Skip to content
Permalink
Browse files

Quick Fix for bug where request not parsing payload JSON

  • Loading branch information
rrk12005 committed Mar 14, 2019
1 parent da5294a commit a2599ecc509e4602850381fa943455190708d24a
Showing with 19 additions and 11 deletions.
  1. +19 −11 SynchronyFinancial/SynchronyFinancial WatchKit Extension/FetchData.swift
@@ -19,25 +19,33 @@ class FetchData{
let json = JSON(value)
let dict = json.dictionaryValue
guard dict["status"]?.dictionaryValue["response_code"]?.string == "0" else { return }
print(json)

if let accounts = dict["account_number_list"]?.arrayValue{
for account in accounts{
guard let accountAlias = account.dictionaryValue["account_alias"]?.string else {return}
guard let creditLimit = account.dictionaryValue["credit_limit"]?.double else {return}
guard let creditLimit = account.dictionaryValue["credit_limit"]?.string else {return}
guard let payDueDate = account.dictionaryValue["next_payment_due_date"]?.string else {return}
guard let curBal = account.dictionaryValue["current_balance"]?.double else {return}
guard let availCredit = account.dictionaryValue["available_credit"]?.double else {return}
guard let minPayDue = account.dictionaryValue["minimum_payment_due"]?.double else {return}
guard let statementBal = account.dictionaryValue["statement_bal"]?.double else {return}
guard let curBal = account.dictionaryValue["current_balance"]?.string else {return}
guard let availCredit = account.dictionaryValue["available_credit"]?.string else {return}
guard let minPayDue = account.dictionaryValue["minimum_payment_due"]?.string else {return}
guard let statementBal = account.dictionaryValue["statement_bal"]?.string else {return}
guard let accountName = account.dictionaryValue["cc_program_name"]?.string else {return}

let creditLimitD = Double(creditLimit)!
let curBalD = Double(curBal)!
let availCreditD = Double(availCredit)!
let minPayDueD = Double(minPayDue)!
let stateBalD = Double(statementBal)!
debugPrint(accountAlias)
debugPrint(creditLimit)
debugPrint(creditLimitD)
debugPrint(payDueDate)
debugPrint(curBal)
debugPrint(availCredit)
debugPrint(minPayDue)
debugPrint(statementBal)
debugPrint(curBalD)
debugPrint(availCreditD)
debugPrint(minPayDueD)
debugPrint(stateBalD)
debugPrint(accountName)
let inAccount = Account(accountAlias: accountAlias, creditLimit: creditLimit, paymentDueDate: payDueDate, curBalance: curBal, availCredit: availCredit, minPayDue: minPayDue, statementBal: statementBal, accountName: accountName)
let inAccount = Account(accountAlias: accountAlias, creditLimit: creditLimitD, paymentDueDate: payDueDate, curBalance: curBalD, availCredit: availCreditD, minPayDue: minPayDueD, statementBal: stateBalD, accountName: accountName)
accountList.append(inAccount)
}
}

0 comments on commit a2599ec

Please sign in to comment.
You can’t perform that action at this time.