Permalink
Browse files
Updated Accounts Model and created request to Multi-Account-Summary-D…
…etails and fetching necessary data
- Loading branch information
Showing
with
89 additions
and 12 deletions.
- +52 −0 SynchronyFinancial/SynchronyFinancial WatchKit Extension/FetchData.swift
- +4 −0 SynchronyFinancial/SynchronyFinancial WatchKit Extension/MainMenuInterfaceController.swift
- +4 −0 SynchronyFinancial/SynchronyFinancial.xcodeproj/project.pbxproj
- +24 −12 SynchronyFinancial/SynchronyFinancial/Account.swift
- +2 −0 SynchronyFinancial/SynchronyFinancial/Defaults.swift
- +3 −0 SynchronyFinancial/TestArea.playground/Contents.swift
@@ -0,0 +1,52 @@ | ||
// | ||
// FetchData.swift | ||
// SynchronyFinancial WatchKit Extension | ||
// | ||
// Created by Rahul Kantesaria on 3/14/19. | ||
// Copyright © 2019 Alan Maynard. All rights reserved. | ||
// | ||
import Foundation | ||
import Alamofire | ||
import SwiftyJSON | ||
|
||
class FetchData{ | ||
class func getAccountInfo(){ | ||
var accountList: [Account] = [] | ||
Alamofire.request(Defaults.MULTI_ACCT_URL, method: .post, parameters: Defaults.headerForMulti, encoding: JSONEncoding.default, headers: Defaults.authHeader).responseJSON { payload in | ||
switch payload.result { | ||
case .success(let value): | ||
let json = JSON(value) | ||
let dict = json.dictionaryValue | ||
guard dict["status"]?.dictionaryValue["response_code"]?.string == "0" else { return } | ||
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 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 accountName = account.dictionaryValue["cc_program_name"]?.string else {return} | ||
debugPrint(accountAlias) | ||
debugPrint(creditLimit) | ||
debugPrint(payDueDate) | ||
debugPrint(curBal) | ||
debugPrint(availCredit) | ||
debugPrint(minPayDue) | ||
debugPrint(statementBal) | ||
debugPrint(accountName) | ||
let inAccount = Account(accountAlias: accountAlias, creditLimit: creditLimit, paymentDueDate: payDueDate, curBalance: curBal, availCredit: availCredit, minPayDue: minPayDue, statementBal: statementBal, accountName: accountName) | ||
accountList.append(inAccount) | ||
} | ||
} | ||
//debugPrint(json) | ||
case .failure(let error): | ||
NSLog("Error: %s", error.localizedDescription) | ||
} | ||
} | ||
} | ||
|
||
|
||
} |
@@ -0,0 +1,3 @@ | ||
import UIKit | ||
|
||
var str = "Hello, playground" |