Skip to content

Swf 21 hook up to web apis #11

Merged
merged 23 commits into from Apr 3, 2019
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
79afbdf
SWF-21 [cocoapods] install Alamofire
ahm11003 Mar 12, 2019
ff0b413
Merge branch 'master' into SWF-21-hook-up-to-web-apis
ahm11003 Mar 12, 2019
f2a8883
SWF-21 [cocoapods] install SwiftyJSON
ahm11003 Mar 13, 2019
e85d2cb
SWF-21 initial web service setup
ahm11003 Mar 14, 2019
da5294a
Updated Accounts Model and created request to Multi-Account-Summary-D…
rrk12005 Mar 14, 2019
a2599ec
Quick Fix for bug where request not parsing payload JSON
rrk12005 Mar 14, 2019
ba4409d
SWF-21 improve login logic & more
ahm11003 Mar 21, 2019
8405351
Merge branch 'master' into SWF-21-hook-up-to-web-apis
ahm11003 Mar 28, 2019
c80231e
SWF-21 pass fetched accounts to AccountTVIC
ahm11003 Mar 28, 2019
c4cc995
SWF-21 Modified header for transactions fetch
ahm11003 Mar 28, 2019
21d742c
SWF-21 preliminary fetch function for transactions
ahm11003 Mar 28, 2019
8487ce3
SWF-21 Initial transaction implementation
ahm11003 Mar 28, 2019
24deb73
SWF-21 Initial setup for “loading” during account tap
ahm11003 Mar 28, 2019
a3682e4
SWF-21 basic paradigm for passing account data to root interface cont…
ahm11003 Mar 28, 2019
56caa7c
SWF-21 Extensions on WKInterfaceImage
ahm11003 Mar 28, 2019
2c01f37
SWF-21 Replace alerts with new activity indicator
ahm11003 Mar 28, 2019
82d2319
SWF-21 Remove unused code
ahm11003 Mar 28, 2019
28a7fc1
Merge branch 'master' into SWF-21-hook-up-to-web-apis
ahm11003 Mar 29, 2019
3ee46a5
SWF-21 move fetch transactions call
ahm11003 Mar 29, 2019
6bedc02
SWF-21 UI fixes
ahm11003 Mar 29, 2019
00d3583
SWF-21 Care credit image assets, loading label
ahm11003 Mar 29, 2019
d5f19aa
Added requests and handlers for fetching pending transactions, fetchi…
rrk12005 Apr 2, 2019
86153df
fixed constructor implementation for transaction and added newline af…
rrk12005 Apr 3, 2019
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

SWF-21 initial web service setup

- created `Defaults` to hold all of our url’s and other static info
- set up initial login web service call
  • Loading branch information
ahm11003 committed Mar 14, 2019
commit e85d2cb36e52d87070cdb4b17a57422bed7e3e6c
@@ -27,28 +27,32 @@ class ExtensionDelegate: NSObject, WKExtensionDelegate {
// Sent when the system needs to launch the application in the background to process tasks. Tasks arrive in a set, so loop through and process each one.
for task in backgroundTasks {
// Use a switch statement to check the task type
switch task {
case let backgroundTask as WKApplicationRefreshBackgroundTask:
// Be sure to complete the background task once you’re done.
backgroundTask.setTaskCompletedWithSnapshot(false)
case let snapshotTask as WKSnapshotRefreshBackgroundTask:
// Snapshot tasks have a unique completion call, make sure to set your expiration date
snapshotTask.setTaskCompleted(restoredDefaultState: true, estimatedSnapshotExpiration: Date.distantFuture, userInfo: nil)
case let connectivityTask as WKWatchConnectivityRefreshBackgroundTask:
// Be sure to complete the connectivity task once you’re done.
connectivityTask.setTaskCompletedWithSnapshot(false)
case let urlSessionTask as WKURLSessionRefreshBackgroundTask:
// Be sure to complete the URL session task once you’re done.
urlSessionTask.setTaskCompletedWithSnapshot(false)
case let relevantShortcutTask as WKRelevantShortcutRefreshBackgroundTask:
// Be sure to complete the relevant-shortcut task once you're done.
relevantShortcutTask.setTaskCompletedWithSnapshot(false)
case let intentDidRunTask as WKIntentDidRunRefreshBackgroundTask:
// Be sure to complete the intent-did-run task once you're done.
intentDidRunTask.setTaskCompletedWithSnapshot(false)
default:
// make sure to complete unhandled task types
task.setTaskCompletedWithSnapshot(false)
if #available(watchOSApplicationExtension 5.0, *) {
switch task {
case let backgroundTask as WKApplicationRefreshBackgroundTask:
// Be sure to complete the background task once you’re done.
backgroundTask.setTaskCompletedWithSnapshot(false)
case let snapshotTask as WKSnapshotRefreshBackgroundTask:
// Snapshot tasks have a unique completion call, make sure to set your expiration date
snapshotTask.setTaskCompleted(restoredDefaultState: true, estimatedSnapshotExpiration: Date.distantFuture, userInfo: nil)
case let connectivityTask as WKWatchConnectivityRefreshBackgroundTask:
// Be sure to complete the connectivity task once you’re done.
connectivityTask.setTaskCompletedWithSnapshot(false)
case let urlSessionTask as WKURLSessionRefreshBackgroundTask:
// Be sure to complete the URL session task once you’re done.
urlSessionTask.setTaskCompletedWithSnapshot(false)
case let relevantShortcutTask as WKRelevantShortcutRefreshBackgroundTask:
// Be sure to complete the relevant-shortcut task once you're done.
relevantShortcutTask.setTaskCompletedWithSnapshot(false)
case let intentDidRunTask as WKIntentDidRunRefreshBackgroundTask:
// Be sure to complete the intent-did-run task once you're done.
intentDidRunTask.setTaskCompletedWithSnapshot(false)
default:
// make sure to complete unhandled task types
task.setTaskCompletedWithSnapshot(false)
}
} else {
// Fallback on earlier versions
}
}
}
@@ -8,6 +8,8 @@
import WatchKit
import Foundation
import Alamofire
import SwiftyJSON

class MainMenuInterfaceController: WKInterfaceController {
@IBOutlet weak var accountsButton: WKInterfaceButton!
@@ -16,7 +18,22 @@ class MainMenuInterfaceController: WKInterfaceController {
override func awake(withContext context: Any?) {
super.awake(withContext: context)

// Configure interface objects here.
// We should find a better place for this call, just for testing purposes
Alamofire.request(Defaults.LOGIN_URL, method: .post, parameters: Defaults.headerForLogin, encoding: JSONEncoding.default).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 token = dict["access_token"]?.string {
debugPrint(token)
// now we should save our token somewhere safe (UserDefaults)
UserDefaults.standard.set(token, forKey: "access_token")
}
case .failure(let error):
NSLog("Error: %s", error.localizedDescription)
}
}
}

override func willActivate() {
@@ -23,6 +23,8 @@
67BAC287219E254900713FEF /* SynchronyFinancial WatchKit Extension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 67BAC286219E254900713FEF /* SynchronyFinancial WatchKit Extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
67BAC28E219E254900713FEF /* ExtensionDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67BAC28D219E254900713FEF /* ExtensionDelegate.swift */; };
67BAC292219E254900713FEF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 67BAC291219E254900713FEF /* Assets.xcassets */; };
67E17B86223812C2008871FE /* Defaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67E17B85223812C2008871FE /* Defaults.swift */; };
67E17B87223812C2008871FE /* Defaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67E17B85223812C2008871FE /* Defaults.swift */; };
A023013199652496572E43E0 /* libPods-SynchronyFinancial.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FC287DF4ECF0A5ECBD80C136 /* libPods-SynchronyFinancial.a */; };
BBECE7F685B263BB9794F863 /* libPods-SynchronyFinancial WatchKit App.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4EA10823B2E5A7A4FEF31740 /* libPods-SynchronyFinancial WatchKit App.a */; };
/* End PBXBuildFile section */
@@ -91,6 +93,7 @@
67BAC28D219E254900713FEF /* ExtensionDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtensionDelegate.swift; sourceTree = "<group>"; };
67BAC291219E254900713FEF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
67BAC293219E254900713FEF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
67E17B85223812C2008871FE /* Defaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Defaults.swift; sourceTree = "<group>"; };
9F53D0FFFE126D2BE8D08B80 /* Pods-SynchronyFinancial WatchKit App.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SynchronyFinancial WatchKit App.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SynchronyFinancial WatchKit App/Pods-SynchronyFinancial WatchKit App.debug.xcconfig"; sourceTree = "<group>"; };
B4F433747E1B9A2ED14BA462 /* Pods-SynchronyFinancial.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SynchronyFinancial.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SynchronyFinancial/Pods-SynchronyFinancial.debug.xcconfig"; sourceTree = "<group>"; };
CAA6D46F907ADAABF49FD409 /* libPods-SynchronyFinancial WatchKit Extension.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SynchronyFinancial WatchKit Extension.a"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -151,6 +154,7 @@
67BAC267219E254700713FEF /* SynchronyFinancial */ = {
isa = PBXGroup;
children = (
67E17B85223812C2008871FE /* Defaults.swift */,
6717460B21F8FCC100696468 /* Account.swift */,
6717460921F8FCBE00696468 /* Transaction.swift */,
67BAC268219E254700713FEF /* AppDelegate.swift */,
@@ -430,6 +434,7 @@
buildActionMask = 2147483647;
files = (
6717460A21F8FCBF00696468 /* Transaction.swift in Sources */,
67E17B86223812C2008871FE /* Defaults.swift in Sources */,
67BAC269219E254700713FEF /* AppDelegate.swift in Sources */,
6717460C21F8FCC100696468 /* Account.swift in Sources */,
);
@@ -441,6 +446,7 @@
files = (
67BAC28E219E254900713FEF /* ExtensionDelegate.swift in Sources */,
673F396E21A644570051469E /* MainMenuInterfaceController.swift in Sources */,
67E17B87223812C2008871FE /* Defaults.swift in Sources */,
6717460E21F8FCDB00696468 /* Transaction.swift in Sources */,
6717460D21F8FCD800696468 /* Account.swift in Sources */,
);
@@ -624,7 +630,7 @@
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 5.1;
WATCHOS_DEPLOYMENT_TARGET = 4.2;
};
name = Debug;
};
@@ -647,7 +653,7 @@
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 5.1;
WATCHOS_DEPLOYMENT_TARGET = 4.2;
};
name = Release;
};
@@ -667,7 +673,7 @@
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 5.1;
WATCHOS_DEPLOYMENT_TARGET = 4.2;
};
name = Debug;
};
@@ -687,7 +693,7 @@
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 5.1;
WATCHOS_DEPLOYMENT_TARGET = 4.2;
};
name = Release;
};
@@ -0,0 +1,97 @@
//
// Defaults.swift
// SynchronyFinancial
//
// Created by Alan Maynard on 3/12/19.
// Copyright © 2019 Alan Maynard. All rights reserved.
//
import Foundation

final class Defaults {

// MARK: - Request URLs
static let LOGIN_URL = "https://syf-paysol-mocks.getsandbox.com/paysol/login/api/rest/v1_0/login"
static let MULTI_ACCT_URL = "https://syf-paysol-mocks.getsandbox.com/paysol/account/api/rest/v1_0/multi_account_summary_details"
static let FETCH_BANKS_URL = "https://syf-paysol-mocks.getsandbox.com/paysol/payment/api/rest/v1_0/fetch_banks"
static let TRANS_HISTORY_URL = "https://syf-paysol-mocks.getsandbox.com/paysol/account/api/rest/v1_0/transaction_history"
static let CANCEL_PAYMENT_URL = "https://syf-paysol-mocks.getsandbox.com/paysol/payment/api/rest/v1_0/cancel_payment"
static let MAKE_PAYMENT_URL = "https://syf-paysol-mocks.getsandbox.com/paysol/payment/api/rest/v1_0/make_payment"

static let defaultHeader = ["channel": "AW", "device_id": "apple_watch", "trans_id": "apple_watch"]

static var headerForLogin: [String: Any] = {
return ["client_id": "carecredit",
"client_secret": "",
"grant_type": "password",
"header": defaultHeader,
"iovation": ["device_fingerprint": "apple_watch",
"ip_address": "0.0.0.0",
"mobile_latitude": 0.0,
"mobile_longitude": 0.0],
"password": "Test12test",
"scope": "default",
"username": "carecredit"]
}()

// this header is used for multi-account and fetch banks resources
static var headerForMulti: [String: Any] = {
return ["header": defaultHeader,
"username": "carecredit"]
}()

static var headerForTransaction: [String: Any] = {
// get account alias
var account_alias = ""

// get today's date as ISO860 - YYYYMMDD string
var end_date = ""

// get desired start date as ISO860 - YYYYMMDD string
var start_date = ""

return ["account_alias": account_alias,
"begin_sequence": "1",
"end_date": end_date,
"end_sequence": "30",
"header": defaultHeader,
"scope_indicator": "B",
"start_date": start_date,
"username": "carecredit"]
}()

static var headerForCancelPmt: [String: Any] = {
// get account_alias
var account_alias = ""

// get payment confirmation number
var pmt_confirmation = ""

// get payment id
var payment_id = ""

return ["account_alias": account_alias,
"header": defaultHeader,
"scope_indicator": "B",
"payment_confirmation_number": pmt_confirmation,
"payment_id": payment_id,
"username": "carecredit"]
}()


static var headerForPmt: [String: Any] = {
// get account alias
var account_alias = ""

// get bank account id to pay from
var bank_acct_id = ""

return ["account_alias": account_alias,
"bank_account_id": bank_acct_id,
"header": defaultHeader,
"payment_amount": 123.45,
"payment_amount_type": "CBL",
"scheduled_payment_post_date": "20190306",
"username": "carecredit"]
}()
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.