Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Updated Accounts Model and created request to Multi-Account-Summary-D…
…etails and fetching necessary data
- Loading branch information
Showing
6 changed files
with
89 additions
and
12 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
SynchronyFinancial/SynchronyFinancial WatchKit Extension/FetchData.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import UIKit | ||
|
||
var str = "Hello, playground" |