mirror of
https://bitbucket.org/vendoo/vendoo_v1.0.git
synced 2025-12-25 03:37:39 +00:00
Merged RDB-Notification-Manager into Rapid-Dev-Branch
This commit is contained in:
commit
ec3bab8b14
@ -16,6 +16,7 @@
|
||||
3E1B1F0B1D2493EE00DBCF08 /* EtsySettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E1B1F0A1D2493EE00DBCF08 /* EtsySettingsViewController.swift */; };
|
||||
3E1DC3CD1D4232490091BC60 /* CategoriesTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E1DC3CC1D4232490091BC60 /* CategoriesTableViewController.swift */; };
|
||||
3E1DC3CF1D42328C0091BC60 /* CategoryCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E1DC3CE1D42328C0091BC60 /* CategoryCell.swift */; };
|
||||
3E3A004A1D76680E00A3A5B6 /* ServiceNotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E3A00491D76680E00A3A5B6 /* ServiceNotificationManager.swift */; };
|
||||
3E4897D11D0067030069F742 /* FirebaseManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E4897D01D0067030069F742 /* FirebaseManager.swift */; };
|
||||
3E6CC3571CF2A94B00E00A70 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E6CC3561CF2A94B00E00A70 /* AppDelegate.swift */; };
|
||||
3E6CC3591CF2A94B00E00A70 /* SignInViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E6CC3581CF2A94B00E00A70 /* SignInViewController.swift */; };
|
||||
@ -74,6 +75,7 @@
|
||||
3E1B1F0A1D2493EE00DBCF08 /* EtsySettingsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EtsySettingsViewController.swift; sourceTree = "<group>"; };
|
||||
3E1DC3CC1D4232490091BC60 /* CategoriesTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CategoriesTableViewController.swift; sourceTree = "<group>"; };
|
||||
3E1DC3CE1D42328C0091BC60 /* CategoryCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CategoryCell.swift; sourceTree = "<group>"; };
|
||||
3E3A00491D76680E00A3A5B6 /* ServiceNotificationManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServiceNotificationManager.swift; sourceTree = "<group>"; };
|
||||
3E4897D01D0067030069F742 /* FirebaseManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FirebaseManager.swift; sourceTree = "<group>"; };
|
||||
3E6CC3531CF2A94B00E00A70 /* Vendoo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Vendoo.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
3E6CC3561CF2A94B00E00A70 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
@ -175,6 +177,7 @@
|
||||
3E4897CF1D00629B0069F742 /* FirebaseServices */,
|
||||
3E7CF3FF1CF6363200F486B2 /* EtsyServices */,
|
||||
3EC325241CF7E6B300626C48 /* FacebookServices */,
|
||||
3E3A00491D76680E00A3A5B6 /* ServiceNotificationManager.swift */,
|
||||
);
|
||||
name = Services;
|
||||
sourceTree = "<group>";
|
||||
@ -753,6 +756,7 @@
|
||||
3E7CF3FC1CF5FE9400F486B2 /* RecoverPasswordViewController.swift in Sources */,
|
||||
3E1DC3CF1D42328C0091BC60 /* CategoryCell.swift in Sources */,
|
||||
3EC325111CF703A600626C48 /* ItemCell.swift in Sources */,
|
||||
3E3A004A1D76680E00A3A5B6 /* ServiceNotificationManager.swift in Sources */,
|
||||
3EA668A11D02836C00EE57A8 /* EbayWebServiceManager.swift in Sources */,
|
||||
3EF422B21D73262000B9A3EB /* UserCell.swift in Sources */,
|
||||
3ECEDB871CF9C722003566B3 /* ListingPreviewViewController.swift in Sources */,
|
||||
|
||||
Binary file not shown.
@ -9,61 +9,13 @@
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/NetworksTableViewController.swift"
|
||||
timestampString = "496411234.903757"
|
||||
filePath = "Vendoo/HomeViewController.swift"
|
||||
timestampString = "497362780.635053"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "865"
|
||||
endingLineNumber = "865"
|
||||
landmarkName = "toggleNetworkSelection(_:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/NetworksTableViewController.swift"
|
||||
timestampString = "496411248.199957"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "864"
|
||||
endingLineNumber = "864"
|
||||
landmarkName = "toggleNetworkSelection(_:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/NetworksTableViewController.swift"
|
||||
timestampString = "496412537.639036"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "867"
|
||||
endingLineNumber = "867"
|
||||
landmarkName = "toggleNetworkSelection(_:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/NetworksTableViewController.swift"
|
||||
timestampString = "496412911.680164"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "879"
|
||||
endingLineNumber = "879"
|
||||
landmarkName = "toggleNetworkSelection(_:)"
|
||||
startingLineNumber = "232"
|
||||
endingLineNumber = "232"
|
||||
landmarkName = "listingHasEnded(_:ebayInfo:amazonInfo:etsyInfo:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -73,13 +25,13 @@
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/SignInViewController.swift"
|
||||
timestampString = "496597298.054868"
|
||||
filePath = "Vendoo/HomeViewController.swift"
|
||||
timestampString = "497362780.635053"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "36"
|
||||
endingLineNumber = "36"
|
||||
landmarkName = "viewDidLoad()"
|
||||
startingLineNumber = "238"
|
||||
endingLineNumber = "238"
|
||||
landmarkName = "listingHasEnded(_:ebayInfo:amazonInfo:etsyInfo:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -89,13 +41,29 @@
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/SignInViewController.swift"
|
||||
timestampString = "496597377.488932"
|
||||
filePath = "Vendoo/EtsyRESTAPIManager.swift"
|
||||
timestampString = "498402567.760806"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "70"
|
||||
endingLineNumber = "70"
|
||||
landmarkName = "signInUser(_:)"
|
||||
startingLineNumber = "625"
|
||||
endingLineNumber = "625"
|
||||
landmarkName = "getListingInfo(_:onCompletion:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/EtsyRESTAPIManager.swift"
|
||||
timestampString = "498399550.82937"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "618"
|
||||
endingLineNumber = "618"
|
||||
landmarkName = "getListingInfo(_:onCompletion:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -105,13 +73,13 @@
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/SignInViewController.swift"
|
||||
timestampString = "496597380.466944"
|
||||
filePath = "Vendoo/EtsyRESTAPIManager.swift"
|
||||
timestampString = "498402567.760806"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "71"
|
||||
endingLineNumber = "71"
|
||||
landmarkName = "signInUser(_:)"
|
||||
startingLineNumber = "623"
|
||||
endingLineNumber = "623"
|
||||
landmarkName = "getListingInfo(_:onCompletion:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
@ -121,46 +89,14 @@
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/SignInViewController.swift"
|
||||
timestampString = "496597417.616973"
|
||||
filePath = "Vendoo/ServiceNotificationManager.swift"
|
||||
timestampString = "498402552.569625"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "57"
|
||||
endingLineNumber = "57"
|
||||
landmarkName = "signInUser(_:)"
|
||||
startingLineNumber = "124"
|
||||
endingLineNumber = "124"
|
||||
landmarkName = "pollServices()"
|
||||
landmarkType = "5">
|
||||
<Locations>
|
||||
<Location
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
symbolName = "Vendoo.SignInViewController.signInUser (Swift.AnyObject) -> ()"
|
||||
moduleName = "Vendoo"
|
||||
usesParentBreakpointCondition = "Yes"
|
||||
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/SignInViewController.swift"
|
||||
timestampString = "496597493.364189"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "57"
|
||||
endingLineNumber = "57"
|
||||
offsetFromSymbolStart = "19">
|
||||
</Location>
|
||||
<Location
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
symbolName = "Vendoo.SignInViewController.(signInUser (Swift.AnyObject) -> ()).(closure #1)"
|
||||
moduleName = "Vendoo"
|
||||
usesParentBreakpointCondition = "Yes"
|
||||
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/SignInViewController.swift"
|
||||
timestampString = "496597493.364295"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "58"
|
||||
endingLineNumber = "58"
|
||||
offsetFromSymbolStart = "37">
|
||||
</Location>
|
||||
</Locations>
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
@ -169,13 +105,45 @@
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/SignInViewController.swift"
|
||||
timestampString = "496597422.377232"
|
||||
filePath = "Vendoo/HomeViewController.swift"
|
||||
timestampString = "499579562.452493"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "40"
|
||||
endingLineNumber = "40"
|
||||
landmarkName = "viewDidLoad()"
|
||||
startingLineNumber = "256"
|
||||
endingLineNumber = "256"
|
||||
landmarkName = "listingHasEnded(_:ebayInfo:amazonInfo:etsyInfo:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/HomeViewController.swift"
|
||||
timestampString = "499579731.915475"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "273"
|
||||
endingLineNumber = "273"
|
||||
landmarkName = "listingHasEnded(_:ebayInfo:amazonInfo:etsyInfo:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/HomeViewController.swift"
|
||||
timestampString = "499579805.922963"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "275"
|
||||
endingLineNumber = "275"
|
||||
landmarkName = "listingHasEnded(_:ebayInfo:amazonInfo:etsyInfo:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
|
||||
BIN
Vendoo/.DS_Store
vendored
BIN
Vendoo/.DS_Store
vendored
Binary file not shown.
@ -41,6 +41,9 @@ class EbayWebServiceManager: NSObject {
|
||||
private var isGettingSubCategories: Bool = false
|
||||
private var isRevisingListing: Bool = false
|
||||
private var requestGroup: dispatch_group_t = dispatch_group_create()
|
||||
var isGettingNotification: Bool = false
|
||||
private var qtySold: Int!
|
||||
private var currItemQuantity: Int!
|
||||
//---------------------------------------------//
|
||||
|
||||
|
||||
@ -346,6 +349,27 @@ extension EbayWebServiceManager {
|
||||
self.catDetailLevel = detailLevel
|
||||
self.requestMaker(soapMessage, theRequest: theRequest)
|
||||
}
|
||||
|
||||
func getListingInfo(listingID: String, onComplete: ServiceResponse?){
|
||||
var soapMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<GetItemRequest xmlns=\"urn:ebay:apis:eBLBaseComponents\">" +
|
||||
"<RequesterCredentials>" +
|
||||
"<eBayAuthToken>\(self.xmlResponseDictionary["eBayAuthToken"] as! String)</eBayAuthToken>" +
|
||||
"</RequesterCredentials>"
|
||||
|
||||
soapMessage = soapMessage +
|
||||
"<ItemID>\(listingID)</ItemID>" +
|
||||
"</GetItemRequest>"
|
||||
|
||||
let url = NSURL(string: self.baseURL)
|
||||
let theRequest = NSMutableURLRequest(URL: url!)
|
||||
theRequest.addValue("GetItem", forHTTPHeaderField: "X-EBAY-API-CALL-NAME")
|
||||
|
||||
self.completion = onComplete
|
||||
self.isGettingNotification = true
|
||||
self.requestMaker(soapMessage, theRequest: theRequest)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
extension EbayWebServiceManager: NSURLConnectionDelegate {
|
||||
@ -471,21 +495,23 @@ extension EbayWebServiceManager: NSXMLParserDelegate {
|
||||
self.completion(nil, nil)
|
||||
break
|
||||
case "UserID" :
|
||||
print(string)
|
||||
EbayWebServiceManager.settingsDictionary["userID"] = string
|
||||
NSUserDefaults.standardUserDefaults().setObject(EbayWebServiceManager.settingsDictionary, forKey: "ebaySettings")
|
||||
print(self.xmlResponseDictionary["eBayAuthToken"])
|
||||
let soapmessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<GetCategoriesRequest xmlns=\"urn:ebay:apis:eBLBaseComponents\">" +
|
||||
"<RequesterCredentials><eBayAuthToken>\(self.xmlResponseDictionary["eBayAuthToken"] as! String)</eBayAuthToken>" +
|
||||
"</RequesterCredentials><CategorySiteID>0</CategorySiteID><DetailLevel>ReturnAll</DetailLevel><LevelLimit>1</LevelLimit>" +
|
||||
"</GetCategoriesRequest>"
|
||||
|
||||
let url = NSURL(string: self.baseURL)
|
||||
let theRequest = NSMutableURLRequest(URL: url!)
|
||||
theRequest.addValue("GetCategories", forHTTPHeaderField: "X-EBAY-API-CALL-NAME")
|
||||
self.completion(nil, nil)
|
||||
self.requestMaker(soapmessage, theRequest: theRequest)
|
||||
if(!self.isGettingNotification) {
|
||||
print(string)
|
||||
EbayWebServiceManager.settingsDictionary["userID"] = string
|
||||
NSUserDefaults.standardUserDefaults().setObject(EbayWebServiceManager.settingsDictionary, forKey: "ebaySettings")
|
||||
print(self.xmlResponseDictionary["eBayAuthToken"])
|
||||
let soapmessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
|
||||
"<GetCategoriesRequest xmlns=\"urn:ebay:apis:eBLBaseComponents\">" +
|
||||
"<RequesterCredentials><eBayAuthToken>\(self.xmlResponseDictionary["eBayAuthToken"] as! String)</eBayAuthToken>" +
|
||||
"</RequesterCredentials><CategorySiteID>0</CategorySiteID><DetailLevel>ReturnAll</DetailLevel><LevelLimit>1</LevelLimit>" +
|
||||
"</GetCategoriesRequest>"
|
||||
|
||||
let url = NSURL(string: self.baseURL)
|
||||
let theRequest = NSMutableURLRequest(URL: url!)
|
||||
theRequest.addValue("GetCategories", forHTTPHeaderField: "X-EBAY-API-CALL-NAME")
|
||||
self.completion(nil, nil)
|
||||
self.requestMaker(soapmessage, theRequest: theRequest)
|
||||
}
|
||||
break
|
||||
/*
|
||||
Used to build both the top level categories, and subcategories on request during item listing workflow
|
||||
@ -497,9 +523,16 @@ extension EbayWebServiceManager: NSXMLParserDelegate {
|
||||
self.catLevel = string
|
||||
break
|
||||
case "CategoryName" :
|
||||
if(!self.isGettingSubCategories) {
|
||||
if((EbayWebServiceManager.settingsDictionary["categories"]) == nil) {
|
||||
EbayWebServiceManager.settingsDictionary["categories"] = Dictionary<String , Dictionary<String, AnyObject>>()
|
||||
if (!self.isGettingNotification) {
|
||||
if(!self.isGettingSubCategories) {
|
||||
if((EbayWebServiceManager.settingsDictionary["categories"]) == nil) {
|
||||
EbayWebServiceManager.settingsDictionary["categories"] = Dictionary<String , Dictionary<String, AnyObject>>()
|
||||
}
|
||||
var dict: Dictionary<String, Dictionary<String, AnyObject>> = (EbayWebServiceManager.settingsDictionary["categories"]!) as! Dictionary<String, Dictionary<String, AnyObject>>
|
||||
|
||||
dict[string] = ["cat_id": self.catID, "isLeaf": false, "level": self.catLevel]
|
||||
EbayWebServiceManager.settingsDictionary["categories"] = dict
|
||||
NSUserDefaults.standardUserDefaults().setObject(EbayWebServiceManager.settingsDictionary, forKey: "ebaySettings")
|
||||
}
|
||||
var dict: Dictionary<String, Dictionary<String, AnyObject>> = (EbayWebServiceManager.settingsDictionary["categories"]!) as! Dictionary<String, Dictionary<String, AnyObject>>
|
||||
|
||||
@ -509,16 +542,17 @@ extension EbayWebServiceManager: NSXMLParserDelegate {
|
||||
|
||||
}
|
||||
else {
|
||||
if "\(self.catDetailLevel)" == self.catLevel {
|
||||
/*if "\(self.catDetailLevel)" == self.catLevel {
|
||||
if((self.subCategories[string] == nil )){
|
||||
self.subCategories[string] = ["cat_id": self.catID, "isLeaf": false, "level": self.catLevel]
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
self.currentCategory = string*/
|
||||
}
|
||||
|
||||
self.currentCategory = string
|
||||
|
||||
break
|
||||
|
||||
case "LeafCategory":
|
||||
@ -547,13 +581,38 @@ extension EbayWebServiceManager: NSXMLParserDelegate {
|
||||
Used during the listing creation process to save the new listing id, as well as adding pictures to the new listing
|
||||
*/
|
||||
case "ItemID":
|
||||
self.completion(string, nil)
|
||||
if (!self.isGettingNotification) {
|
||||
self.completion(string, nil)
|
||||
}
|
||||
break
|
||||
|
||||
case "ReviseItemResponse":
|
||||
self.isRevisingListing = true
|
||||
break
|
||||
|
||||
/*
|
||||
Used for retrieving listing info for notifications
|
||||
*/
|
||||
case "Quantity":
|
||||
if self.isGettingNotification {
|
||||
print("Quantity: \(string)")
|
||||
self.currItemQuantity = Int(string)
|
||||
}
|
||||
break
|
||||
case "QuantitySold":
|
||||
if self.isGettingNotification {
|
||||
print("QuantitySold: \(string)")
|
||||
self.qtySold = Int(string)
|
||||
}
|
||||
break
|
||||
case "ListingStatus":
|
||||
if self.isGettingNotification {
|
||||
print("ListingStatus: \(string)")
|
||||
self.completion(["status":string, "quantitySold": self.qtySold, "itemQuantity": self.currItemQuantity], nil)
|
||||
self.qtySold = nil
|
||||
self.currItemQuantity = nil
|
||||
}
|
||||
break
|
||||
default:
|
||||
//print(string)
|
||||
print("\(self.currentElementName):\(string)")
|
||||
|
||||
@ -608,6 +608,28 @@ extension EtsyRESTAPIManager {
|
||||
)
|
||||
}
|
||||
|
||||
//gets listing info
|
||||
func getListingInfo (request: String, onCompletion: ServiceResponse?) {
|
||||
self.oauthswift.client.get(self.baseURL + request,
|
||||
success: {
|
||||
(data, response) -> Void in
|
||||
let dataString = NSString(data: data, encoding: NSUTF8StringEncoding)
|
||||
let dict = self.convertStringToDictionary(dataString! as String)
|
||||
print(dict)
|
||||
print(response)
|
||||
var dict2 = (dict!["results"] as! [[String : AnyObject]])
|
||||
|
||||
let listingState = dict2[0]["state"] as! String
|
||||
|
||||
onCompletion!(["status":listingState], nil)
|
||||
|
||||
|
||||
}, failure: {
|
||||
(error) -> Void in
|
||||
print(error)
|
||||
}
|
||||
)}
|
||||
|
||||
//sends the pregenerated url as a request to api service
|
||||
func sendPOSTRequest(request: String, var body: [String: AnyObject]?, onCompletion: ServiceResponse?) {
|
||||
|
||||
|
||||
@ -16,11 +16,16 @@ class HomeViewController: UITabBarController {
|
||||
let firebaseManager = FirebaseManager()
|
||||
let ebayGraphManager = EbayWebServiceManager()
|
||||
var userListings: [Listing] = []
|
||||
var endedListings: [Listing] = []
|
||||
var soldListings: [Listing] = []
|
||||
var notificationsManager = ServiceNotificationManager()
|
||||
var notifications: [Dictionary<String, String>] = (NSUserDefaults.standardUserDefaults().objectForKey("notifications") == nil ? [] : (NSUserDefaults.standardUserDefaults().objectForKey("notifications") as! [Dictionary<String, String>]))
|
||||
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
ServiceNotificationManager.delegate = self
|
||||
self.notificationsManager.setManagers(fbGraphManager, fireManager: firebaseManager, ebayManager: ebayGraphManager, etsyManager: etsyManager)
|
||||
// Do any additional setup after loading the view.
|
||||
dispatch_async(dispatch_get_main_queue(), {
|
||||
|
||||
@ -35,11 +40,12 @@ class HomeViewController: UITabBarController {
|
||||
NSUserDefaults.standardUserDefaults().setObject(userDict!["name"] as? String, forKey: "name")
|
||||
|
||||
if listingDict != nil {
|
||||
var notificationStartTracker = 0
|
||||
dispatch_async(dispatch_get_main_queue(), {
|
||||
|
||||
|
||||
//let notificationStartGroup = dispatch_group_create()
|
||||
for (key, values) in listingDict! {
|
||||
let serviceGroup: dispatch_group_t = dispatch_group_create()
|
||||
//dispatch_group_enter(notificationStartGroup)
|
||||
self.firebaseManager.ref.observeSingleEventOfType(.Value, withBlock: { snapshot in
|
||||
|
||||
let databaseDict = snapshot.value as! [String : AnyObject]
|
||||
@ -54,6 +60,7 @@ class HomeViewController: UITabBarController {
|
||||
|
||||
if(error != nil){
|
||||
print("problem retrieving items")
|
||||
notificationStartTracker += 1
|
||||
}else{
|
||||
|
||||
let mainImage = UIImage(data: dataMain!)
|
||||
@ -74,6 +81,9 @@ class HomeViewController: UITabBarController {
|
||||
count+=1
|
||||
if(count == 4){
|
||||
dispatch_group_leave(serviceGroup)
|
||||
notificationStartTracker += 1
|
||||
//dispatch_group_enter(notificationStartGroup)
|
||||
//dispatch_group_leave(notificationStartGroup)
|
||||
}
|
||||
})
|
||||
|
||||
@ -83,20 +93,58 @@ class HomeViewController: UITabBarController {
|
||||
dispatch_group_notify(serviceGroup, dispatch_get_main_queue(), {
|
||||
print(listingImages.count)
|
||||
let listingInfo = values as? [String : AnyObject]
|
||||
self.userListings.append(
|
||||
Listing(itemTitle: (listingInfo!["listingTitle"] as? String)!,
|
||||
itemCategory: listingInfo!["listingCategory"] as? String,
|
||||
itemQuantity: (listingInfo!["listingQuantity"] as? String)!,
|
||||
itemPrice: listingInfo!["listingPrice"] as? String,
|
||||
itemDescription: listingInfo!["listingDescription"] as? String,
|
||||
itemImages: listingImages,
|
||||
isDraftListing: (listingInfo!["isListingDraft"] as? Bool)!,
|
||||
itemKey: key,
|
||||
networksSellingOn: (listingInfo!["networks"] as? Dictionary<String, Bool>)!
|
||||
))
|
||||
|
||||
NSNotificationCenter.defaultCenter().postNotificationName("finished_fetching_listings", object: nil)
|
||||
if listingInfo!["listingStatus"] == nil {
|
||||
self.userListings.append(
|
||||
Listing(itemTitle: (listingInfo!["listingTitle"] as? String)!,
|
||||
itemCategory: listingInfo!["listingCategory"] as? String,
|
||||
itemQuantity: (listingInfo!["listingQuantity"] as? String)!,
|
||||
itemPrice: listingInfo!["listingPrice"] as? String,
|
||||
itemDescription: listingInfo!["listingDescription"] as? String,
|
||||
itemImages: listingImages,
|
||||
isDraftListing: (listingInfo!["isListingDraft"] as? Bool)!,
|
||||
itemKey: key,
|
||||
networksSellingOn: (listingInfo!["networks"] as? Dictionary<String, Bool>)!
|
||||
))
|
||||
}
|
||||
else if listingInfo!["listingStatus"] as? String == "Ended" {
|
||||
self.endedListings.append(
|
||||
Listing(itemTitle: (listingInfo!["listingTitle"] as? String)!,
|
||||
itemCategory: listingInfo!["listingCategory"] as? String,
|
||||
itemQuantity: (listingInfo!["listingQuantity"] as? String)!,
|
||||
itemPrice: listingInfo!["listingPrice"] as? String,
|
||||
itemDescription: listingInfo!["listingDescription"] as? String,
|
||||
itemImages: listingImages,
|
||||
isDraftListing: (listingInfo!["isListingDraft"] as? Bool)!,
|
||||
itemKey: key,
|
||||
networksSellingOn: (listingInfo!["networks"] as? Dictionary<String, Bool>)!
|
||||
))
|
||||
}
|
||||
else if listingInfo!["listingStatus"] as? String == "Sold" {
|
||||
self.soldListings.append(
|
||||
Listing(itemTitle: (listingInfo!["listingTitle"] as? String)!,
|
||||
itemCategory: listingInfo!["listingCategory"] as? String,
|
||||
itemQuantity: (listingInfo!["listingQuantity"] as? String)!,
|
||||
itemPrice: listingInfo!["listingPrice"] as? String,
|
||||
itemDescription: listingInfo!["listingDescription"] as? String,
|
||||
itemImages: listingImages,
|
||||
isDraftListing: (listingInfo!["isListingDraft"] as? Bool)!,
|
||||
itemKey: key,
|
||||
networksSellingOn: (listingInfo!["networks"] as? Dictionary<String, Bool>)!
|
||||
))
|
||||
}
|
||||
|
||||
print(notificationStartTracker)
|
||||
if(notificationStartTracker == listingDict?.count){
|
||||
NSNotificationCenter.defaultCenter().postNotificationName("finished_fetching_listings", object: nil)
|
||||
self.notificationsManager.setListings(self.userListings)
|
||||
self.notificationsManager.startServicePolling()
|
||||
}
|
||||
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
@ -108,6 +156,11 @@ class HomeViewController: UITabBarController {
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
dispatch_group_notify(notificationStartGroup, dispatch_get_main_queue(), {
|
||||
|
||||
|
||||
})*/
|
||||
|
||||
|
||||
|
||||
@ -139,3 +192,146 @@ class HomeViewController: UITabBarController {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
extension HomeViewController: ServiceNotificationManagerDelegate {
|
||||
func listingHasFinishedRetrievingNotifications() {
|
||||
NSUserDefaults.standardUserDefaults().setObject(self.notifications, forKey: "notifications")
|
||||
}
|
||||
|
||||
func listingHasStartedRetrievingNotifications() {
|
||||
|
||||
}
|
||||
|
||||
func listingHasEnded(fbInfo: AnyObject?, ebayInfo: AnyObject?, amazonInfo: AnyObject?, etsyInfo: AnyObject?) {
|
||||
if (fbInfo != nil) {
|
||||
self.notifications.append(
|
||||
[
|
||||
"network": "facebook",
|
||||
"message": (ebayInfo as! [String : AnyObject])["notification"] as! String,
|
||||
"type": "ended",
|
||||
"key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String,
|
||||
"UUID": NSUUID().UUIDString
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
if (ebayInfo != nil) {
|
||||
self.notifications.append(
|
||||
[
|
||||
"network": "ebay",
|
||||
"message": (ebayInfo as! [String : AnyObject])["notification"] as! String,
|
||||
"type": (ebayInfo as! [String : AnyObject])["type"] as! String,
|
||||
"key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String,
|
||||
"UUID": NSUUID().UUIDString
|
||||
]
|
||||
)
|
||||
self.endedListings.appendContentsOf( self.userListings.filter({$0.key == ((ebayInfo as! [String : AnyObject])["listingKey"] as! String)}))
|
||||
self.userListings = self.userListings.filter({$0.key != ((ebayInfo as! [String : AnyObject])["listingKey"] as! String)})
|
||||
let itemsView = self.viewControllers![0] as! ItemTableViewController
|
||||
|
||||
self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)/user_Listings/\(((ebayInfo as! [String : AnyObject])["listingKey"] as! String))").observeSingleEventOfType( .Value, withBlock: {
|
||||
(snapshot) -> Void in
|
||||
|
||||
var listingDict = snapshot.value as? [String : AnyObject]
|
||||
listingDict!["listingStatus"] = "Ended"
|
||||
self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)/user_Listings/\(((ebayInfo as! [String : AnyObject])["listingKey"] as! String))").setValue(listingDict)
|
||||
|
||||
itemsView.itemTable.reloadData()
|
||||
})
|
||||
}
|
||||
|
||||
if (amazonInfo != nil) {
|
||||
self.notifications.append(
|
||||
[
|
||||
"network": "amazon",
|
||||
"message": (ebayInfo as! [String : AnyObject])["notification"] as! String,
|
||||
"type": (ebayInfo as! [String : AnyObject])["type"] as! String,
|
||||
"key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String,
|
||||
"UUID": NSUUID().UUIDString
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
if (etsyInfo != nil) {
|
||||
self.notifications.append(
|
||||
[
|
||||
"network": "etsy",
|
||||
"message": (etsyInfo as! [String : AnyObject])["notification"] as! String,
|
||||
"type": "ended",
|
||||
"key": (etsyInfo as! [String : AnyObject])["listingKey"] as! String,
|
||||
"UUID": NSUUID().UUIDString
|
||||
]
|
||||
)
|
||||
self.endedListings.appendContentsOf( self.userListings.filter({$0.key == ((etsyInfo as! [String : AnyObject])["listingKey"] as! String)}))
|
||||
self.userListings = self.userListings.filter({$0.key != ((etsyInfo as! [String : AnyObject])["listingKey"] as! String)})
|
||||
let itemsView = self.viewControllers![0] as! ItemTableViewController
|
||||
|
||||
self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)/user_Listings/\(((etsyInfo as! [String : AnyObject])["listingKey"] as! String))").observeSingleEventOfType( .Value, withBlock: {
|
||||
(snapshot) -> Void in
|
||||
|
||||
var listingDict = snapshot.value as? [String : AnyObject]
|
||||
listingDict!["listingStatus"] = "Ended"
|
||||
self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)/user_Listings/\(((etsyInfo as! [String : AnyObject])["listingKey"] as! String))").setValue(listingDict)
|
||||
|
||||
itemsView.itemTable.reloadData()
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func listingHasNewNotifications(fbInfo: AnyObject?, ebayInfo: AnyObject?, amazonInfo: AnyObject?, etsyInfo: AnyObject?) {
|
||||
|
||||
|
||||
if (fbInfo != nil) {
|
||||
self.notifications.append(
|
||||
[
|
||||
"network": "facebook",
|
||||
"message": (ebayInfo as! [String : AnyObject])["notification"] as! String,
|
||||
"type": (ebayInfo as! [String : AnyObject])["type"] as! String,
|
||||
"key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String,
|
||||
"UUID": NSUUID().UUIDString
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
if (ebayInfo != nil) {
|
||||
self.notifications.append(
|
||||
[
|
||||
"network": "ebay",
|
||||
"message": (ebayInfo as! [String : AnyObject])["notification"] as! String,
|
||||
"type": (ebayInfo as! [String : AnyObject])["type"] as! String,
|
||||
"key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String,
|
||||
"UUID": NSUUID().UUIDString
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
if (amazonInfo != nil) {
|
||||
self.notifications.append(
|
||||
[
|
||||
"network": "amazon",
|
||||
"message": (ebayInfo as! [String : AnyObject])["notification"] as! String,
|
||||
"type": "",
|
||||
"key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String,
|
||||
"UUID": NSUUID().UUIDString
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
if (etsyInfo != nil) {
|
||||
self.notifications.append(
|
||||
[
|
||||
"network": "etsy",
|
||||
"message": (etsyInfo as! [String : AnyObject])["notification"] as! String,
|
||||
"type": (etsyInfo as! [String : AnyObject])["type"] as! String,
|
||||
"key": (etsyInfo as! [String : AnyObject])["listingKey"] as! String,
|
||||
"UUID": NSUUID().UUIDString
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
//@TODO: add firbase logic to add notifications and delete already viewed notifications
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,6 +45,8 @@ class ItemImagePickerViewController: UIViewController {
|
||||
private var imageIndex: Int!
|
||||
private var isEditing: Bool = false
|
||||
private var currentInformation: Dictionary<String, AnyObject>!
|
||||
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
|
||||
@ -80,6 +80,12 @@ class ItemTableViewController: UIViewController {
|
||||
|
||||
}
|
||||
|
||||
// MARK: - IBAction
|
||||
extension ItemTableViewController {
|
||||
@IBAction func segSwitch(sender: UISegmentedControl) {
|
||||
self.itemTable.reloadData()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Navigation
|
||||
extension ItemTableViewController {
|
||||
@ -129,63 +135,143 @@ extension ItemTableViewController: UITableViewDataSource{
|
||||
|
||||
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
// #warning Incomplete implementation, return the number of rows
|
||||
return ((self.tabBarController as? HomeViewController)?.userListings.count)!
|
||||
if self.tableSegmentController.selectedSegmentIndex == 0 {
|
||||
return ((self.tabBarController as? HomeViewController)?.userListings.count)!
|
||||
}
|
||||
else if tableSegmentController.selectedSegmentIndex == 1 {
|
||||
return ((self.tabBarController as? HomeViewController)?.endedListings.count)!
|
||||
}
|
||||
else{
|
||||
return ((self.tabBarController as? HomeViewController)?.soldListings.count)!
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
|
||||
let cell: ItemCell! = (tableView.dequeueReusableCellWithIdentifier("Item Cell", forIndexPath: indexPath) as! ItemCell)
|
||||
|
||||
|
||||
|
||||
|
||||
// Configure the cell...
|
||||
//for each listing cell generated need to find the marketplaces it belongs to, the listing price, the name of the item, the status of the item, and the item image.
|
||||
//Once these objects are retrieved, access the ItemCell properties and manipulate as needed
|
||||
cell.itemImage.image = (self.tabBarController as? HomeViewController)?.userListings[indexPath.row].images[0] //come back
|
||||
cell.itemName.text = (self.tabBarController as? HomeViewController)!.userListings[indexPath.row].title
|
||||
cell.itemPrice.text = (self.tabBarController as? HomeViewController)!.userListings[indexPath.row].price
|
||||
|
||||
//check if item is published
|
||||
if((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].isDraft!){
|
||||
cell.itemStatus.text = "Status: Unpublished"
|
||||
dispatch_async(dispatch_get_main_queue(), {
|
||||
|
||||
cell.alpha = 0.5
|
||||
|
||||
|
||||
})
|
||||
if self.tableSegmentController.selectedSegmentIndex == 0 {
|
||||
cell.itemImage.image = (self.tabBarController as? HomeViewController)?.userListings[indexPath.row].images[0] //come back
|
||||
cell.itemName.text = (self.tabBarController as? HomeViewController)!.userListings[indexPath.row].title
|
||||
cell.itemPrice.text = (self.tabBarController as? HomeViewController)!.userListings[indexPath.row].price
|
||||
|
||||
}else {
|
||||
cell.itemStatus.text = "Status: Active"
|
||||
}
|
||||
|
||||
if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["areNetworksChosen"])!){
|
||||
cell.networks.hidden = true
|
||||
}else{
|
||||
dispatch_async(dispatch_get_main_queue(), {
|
||||
if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["ebay"])!){
|
||||
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true
|
||||
}
|
||||
if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["amazon"])!){
|
||||
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true
|
||||
}
|
||||
if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["etsy"])!){
|
||||
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true
|
||||
//check if item is published
|
||||
if((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].isDraft!){
|
||||
cell.itemStatus.text = "Status: Unpublished"
|
||||
dispatch_async(dispatch_get_main_queue(), {
|
||||
|
||||
}
|
||||
if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["facebook"])!){
|
||||
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = true
|
||||
}
|
||||
|
||||
})
|
||||
cell.alpha = 0.5
|
||||
|
||||
|
||||
})
|
||||
|
||||
}else {
|
||||
cell.itemStatus.text = "Status: Active"
|
||||
}
|
||||
|
||||
if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["areNetworksChosen"])!){
|
||||
cell.networks.hidden = true
|
||||
}else{
|
||||
dispatch_async(dispatch_get_main_queue(), {
|
||||
if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["ebay"])!){
|
||||
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true
|
||||
}
|
||||
if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["amazon"])!){
|
||||
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true
|
||||
}
|
||||
if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["etsy"])!){
|
||||
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true
|
||||
|
||||
}
|
||||
if(!((self.tabBarController as? HomeViewController)!.userListings[indexPath.row].networks["facebook"])!){
|
||||
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = true
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else if tableSegmentController.selectedSegmentIndex == 1 {
|
||||
cell.itemImage.image = (self.tabBarController as? HomeViewController)?.endedListings[indexPath.row].images[0] //come back
|
||||
cell.itemName.text = (self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].title
|
||||
cell.itemPrice.text = (self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].price
|
||||
|
||||
cell.itemStatus.text = "Status: Unsold"
|
||||
|
||||
if(!((self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].networks["areNetworksChosen"])!){
|
||||
cell.networks.hidden = true
|
||||
}else{
|
||||
dispatch_async(dispatch_get_main_queue(), {
|
||||
if(!((self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].networks["ebay"])!){
|
||||
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true
|
||||
}
|
||||
if(!((self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].networks["amazon"])!){
|
||||
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true
|
||||
}
|
||||
if(!((self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].networks["etsy"])!){
|
||||
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true
|
||||
|
||||
}
|
||||
if(!((self.tabBarController as? HomeViewController)!.endedListings[indexPath.row].networks["facebook"])!){
|
||||
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = true
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
cell.itemImage.image = (self.tabBarController as? HomeViewController)?.soldListings[indexPath.row].images[0] //come back
|
||||
cell.itemName.text = (self.tabBarController as? HomeViewController)!.soldListings[indexPath.row].title
|
||||
cell.itemPrice.text = (self.tabBarController as? HomeViewController)!.soldListings[indexPath.row].price
|
||||
|
||||
cell.itemStatus.text = "Status: Sold"
|
||||
|
||||
if(!((self.tabBarController as? HomeViewController)!.soldListings[indexPath.row].networks["areNetworksChosen"])!){
|
||||
cell.networks.hidden = true
|
||||
}else{
|
||||
dispatch_async(dispatch_get_main_queue(), {
|
||||
if(!((self.tabBarController as? HomeViewController)!.soldListings[indexPath.row].networks["ebay"])!){
|
||||
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true
|
||||
}
|
||||
if(!((self.tabBarController as? HomeViewController)!.soldListings[indexPath.row].networks["amazon"])!){
|
||||
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true
|
||||
}
|
||||
if(!((self.tabBarController as? HomeViewController)!.soldListings[indexPath.row].networks["etsy"])!){
|
||||
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true
|
||||
|
||||
}
|
||||
if(!((self.tabBarController as? HomeViewController)!.soldListings[indexPath.row].networks["facebook"])!){
|
||||
cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = true
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return cell
|
||||
}
|
||||
|
||||
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
|
||||
self.selectedListing = (self.tabBarController as? HomeViewController)?.userListings[indexPath.row]
|
||||
if self.tableSegmentController.selectedSegmentIndex == 0 {
|
||||
self.selectedListing = (self.tabBarController as? HomeViewController)?.userListings[indexPath.row]
|
||||
}
|
||||
else if tableSegmentController.selectedSegmentIndex == 1 {
|
||||
self.selectedListing = (self.tabBarController as? HomeViewController)?.endedListings[indexPath.row]
|
||||
}
|
||||
else{
|
||||
self.selectedListing = (self.tabBarController as? HomeViewController)?.soldListings[indexPath.row]
|
||||
}
|
||||
self.performSegueWithIdentifier("ItemDetailSegue", sender: self)
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@ class Listing : NSObject {
|
||||
var images: [UIImage]!
|
||||
var key: String!
|
||||
var networks: Dictionary<String, Bool>!
|
||||
var listingStatus: String!
|
||||
|
||||
init(itemTitle:String, itemCategory: String!, itemQuantity: String!, itemPrice: String!, itemDescription: String!, itemImages: [UIImage], isDraftListing: Bool, itemKey: String, networksSellingOn: Dictionary<String, Bool>){
|
||||
|
||||
|
||||
@ -1242,14 +1242,18 @@
|
||||
</navigationItem>
|
||||
</items>
|
||||
</navigationBar>
|
||||
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" id="X2D-np-ma4">
|
||||
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" id="X2D-np-ma4">
|
||||
<rect key="frame" x="0.0" y="44" width="375" height="29"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<segments>
|
||||
<segment title="Selling"/>
|
||||
<segment title="Unsold"/>
|
||||
<segment title="Sold"/>
|
||||
</segments>
|
||||
<color key="tintColor" red="0.2784313725" green="0.80392156859999997" blue="0.68235294120000001" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<connections>
|
||||
<action selector="segSwitch:" destination="Iwh-sn-a0Q" eventType="valueChanged" id="YfI-EH-qgs"/>
|
||||
</connections>
|
||||
</segmentedControl>
|
||||
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="123" sectionHeaderHeight="1" sectionFooterHeight="28" id="Thg-pb-lhN">
|
||||
<rect key="frame" x="0.0" y="72" width="375" height="543"/>
|
||||
@ -2501,11 +2505,11 @@
|
||||
<image name="start" width="50" height="50"/>
|
||||
</resources>
|
||||
<inferredMetricsTieBreakers>
|
||||
<segue reference="rkZ-c8-XJc"/>
|
||||
<segue reference="nUj-1v-ftF"/>
|
||||
<segue reference="syc-IR-LNQ"/>
|
||||
<segue reference="nWA-7e-2Ec"/>
|
||||
<segue reference="vCG-jU-HYF"/>
|
||||
<segue reference="rkZ-c8-XJc"/>
|
||||
<segue reference="Ogu-p5-UtK"/>
|
||||
<segue reference="NOz-ya-avj"/>
|
||||
<segue reference="KKl-Gj-ZVc"/>
|
||||
</inferredMetricsTieBreakers>
|
||||
<color key="tintColor" red="0.2784313725" green="0.80392156859999997" blue="0.68235294120000001" alpha="1" colorSpace="calibratedRGB"/>
|
||||
|
||||
24
Vendoo/NotificationTableViewCell.swift
Normal file
24
Vendoo/NotificationTableViewCell.swift
Normal file
@ -0,0 +1,24 @@
|
||||
//
|
||||
// NotificationTableViewCell.swift
|
||||
// Vendoo
|
||||
//
|
||||
// Created by Okechi Onyeje on 11/2/16.
|
||||
// Copyright © 2016 Okechi Onyeje. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class NotificationTableViewCell: UITableViewCell {
|
||||
|
||||
override func awakeFromNib() {
|
||||
super.awakeFromNib()
|
||||
// Initialization code
|
||||
}
|
||||
|
||||
override func setSelected(selected: Bool, animated: Bool) {
|
||||
super.setSelected(selected, animated: animated)
|
||||
|
||||
// Configure the view for the selected state
|
||||
}
|
||||
|
||||
}
|
||||
35
Vendoo/NotificationsViewController.swift
Normal file
35
Vendoo/NotificationsViewController.swift
Normal file
@ -0,0 +1,35 @@
|
||||
//
|
||||
// NotificationsViewController.swift
|
||||
// Vendoo
|
||||
//
|
||||
// Created by Okechi Onyeje on 11/2/16.
|
||||
// Copyright © 2016 Okechi Onyeje. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class NotificationsViewController: UIViewController {
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
// Do any additional setup after loading the view.
|
||||
}
|
||||
|
||||
override func didReceiveMemoryWarning() {
|
||||
super.didReceiveMemoryWarning()
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// MARK: - Navigation
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
|
||||
// Get the new view controller using segue.destinationViewController.
|
||||
// Pass the selected object to the new view controller.
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
181
Vendoo/ServiceNotificationManager.swift
Normal file
181
Vendoo/ServiceNotificationManager.swift
Normal file
@ -0,0 +1,181 @@
|
||||
//
|
||||
// ServiceNotificationManager.swift
|
||||
// Vendoo
|
||||
//
|
||||
// Created by Okechi Onyeje on 8/30/16.
|
||||
// Copyright © 2016 Okechi Onyeje. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
protocol ServiceNotificationManagerDelegate {
|
||||
func listingHasEnded(fbInfo: AnyObject?, ebayInfo: AnyObject?, amazonInfo: AnyObject?, etsyInfo: AnyObject?)
|
||||
func listingHasNewNotifications(fbInfo: AnyObject?, ebayInfo: AnyObject?, amazonInfo: AnyObject?, etsyInfo: AnyObject?)
|
||||
func listingHasFinishedRetrievingNotifications()
|
||||
func listingHasStartedRetrievingNotifications()
|
||||
|
||||
}
|
||||
|
||||
class ServiceNotificationManager: NSObject {
|
||||
|
||||
var etsyManager: EtsyRESTAPIManager!
|
||||
var fbGraphManager: FacebookGraphAPIManager!
|
||||
var firebaseManager: FirebaseManager!
|
||||
var ebayGraphManager: EbayWebServiceManager!
|
||||
var userListings: [Listing] = []
|
||||
var timer: NSTimer!
|
||||
static var delegate: ServiceNotificationManagerDelegate?
|
||||
|
||||
override init() {
|
||||
super.init()
|
||||
|
||||
|
||||
}
|
||||
|
||||
func startServicePolling() {
|
||||
//timer = NSTimer.scheduledTimerWithTimeInterval(60.0, target: self, selector: #selector(ServiceNotificationManager.pollServices), userInfo: nil, repeats: true)
|
||||
pollServices()
|
||||
}
|
||||
|
||||
func stopServicePolling() {
|
||||
timer.invalidate()
|
||||
}
|
||||
|
||||
func setManagers(fbManager: FacebookGraphAPIManager, fireManager: FirebaseManager, ebayManager: EbayWebServiceManager, etsyManager: EtsyRESTAPIManager){
|
||||
self.fbGraphManager = fbManager
|
||||
self.firebaseManager = fireManager
|
||||
self.ebayGraphManager = ebayManager
|
||||
self.etsyManager = etsyManager
|
||||
}
|
||||
|
||||
func setListings(listings: [Listing]) {
|
||||
self.userListings = listings
|
||||
}
|
||||
|
||||
func pollServices(){
|
||||
let notificationGroup = dispatch_group_create()
|
||||
for listing in userListings {
|
||||
|
||||
self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)/user_Listings/\(listing.key)").observeSingleEventOfType( .Value, withBlock: {
|
||||
(snapshot) -> Void in
|
||||
//dispatch_group_enter(notificationGroup)
|
||||
|
||||
let listingDict = snapshot.value as? [String : AnyObject]
|
||||
|
||||
if !(listingDict!["isListingDraft"] as! Bool) {
|
||||
if let networksDict = listingDict!["networkIDs"] as? [String : AnyObject] {
|
||||
let ebayID = (networksDict["ebay"] as? String)
|
||||
let facebookID = (networksDict["facebook"] as? String)
|
||||
let etsyID = (networksDict["etsy"] as? Int)
|
||||
let amazonID = (networksDict["amazon"] as? String)
|
||||
|
||||
//@TODO: Skeleton for Notfications Manager is set up. Need to implement listing request for each listing to retrieve relevant notifications for user such as if listing has ended
|
||||
if(ebayID != nil){
|
||||
if self.ebayGraphManager.isAuthorized {
|
||||
self.ebayGraphManager.isGettingNotification = true
|
||||
self.ebayGraphManager.getListingInfo(ebayID!, onComplete: {
|
||||
(listingNotificationInfo, error) -> Void in
|
||||
//dispatch_group_leave(notificationGroup)
|
||||
let info = (listingNotificationInfo as! [String : AnyObject])
|
||||
if(info["status"] as! String == "Ended") {
|
||||
if((info["quantitySold"] as! Int) > 0) {
|
||||
//@TODO: Add both firbase logic and code logic to do notifications for sold listings
|
||||
if (((info["itemQuantity"] as! Int) - (info["quantitySold"] as! Int)) == 0) {
|
||||
|
||||
ServiceNotificationManager.delegate?.listingHasNewNotifications(
|
||||
nil,
|
||||
ebayInfo: [
|
||||
"type": "Sold",
|
||||
"notification": "Your listing \"\(listingDict!["listingTitle"] as! String)\" has sold out on ebay.",
|
||||
"listingKey": listing.key],
|
||||
amazonInfo: nil,
|
||||
etsyInfo: nil
|
||||
)
|
||||
}
|
||||
}else{
|
||||
ServiceNotificationManager.delegate?.listingHasEnded(
|
||||
nil,
|
||||
ebayInfo: [
|
||||
"type": "Ended",
|
||||
"notification": "Your listing \"\(listingDict!["listingTitle"] as! String)\" has ended on ebay.",
|
||||
"listingKey": listing.key],
|
||||
amazonInfo: nil,
|
||||
etsyInfo: nil
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
if(facebookID != nil){
|
||||
|
||||
}
|
||||
if(etsyID != nil){
|
||||
if (self.etsyManager.isAuthorized) {
|
||||
self.etsyManager.getListingInfo ("/listings/\(etsyID!)", onCompletion: {
|
||||
(listingNotificationInfo, error) -> Void in
|
||||
|
||||
let info = (listingNotificationInfo as! [String : AnyObject])
|
||||
|
||||
//@TODO: Test this code with the draft condition for both expired and sold_out
|
||||
if ((info["status"] as! String == "expired") || (info["status"] as! String == "removed")) {
|
||||
|
||||
ServiceNotificationManager.delegate?.listingHasEnded(
|
||||
nil,
|
||||
ebayInfo: nil,
|
||||
amazonInfo: nil,
|
||||
etsyInfo: [
|
||||
"type": "Ended",
|
||||
"notification": "Your listing \"\(listingDict!["listingTitle"] as! String)\" has ended on etsy.",
|
||||
"listingKey": listing.key]
|
||||
)
|
||||
|
||||
|
||||
}else if info["status"] as! String == "sold_out" {
|
||||
|
||||
ServiceNotificationManager.delegate?.listingHasNewNotifications(
|
||||
nil,
|
||||
ebayInfo: nil,
|
||||
amazonInfo: nil,
|
||||
etsyInfo: [
|
||||
"type": "Sold",
|
||||
"notification": "Your listing \"\(listingDict!["listingTitle"] as! String)\" has sold out on etsy.",
|
||||
"listingKey": listing.key]
|
||||
)
|
||||
|
||||
} else if info["status"] as! String == "draft" {
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
if(amazonID != nil){
|
||||
|
||||
}
|
||||
//dispatch_group_leave(notificationGroup)
|
||||
}else {
|
||||
// dispatch_group_leave(notificationGroup)
|
||||
}
|
||||
|
||||
|
||||
}else {
|
||||
//dispatch_group_leave(notificationGroup)
|
||||
}
|
||||
})
|
||||
}
|
||||
self.ebayGraphManager.isGettingNotification = false
|
||||
|
||||
|
||||
//dispatch_group_notify(notificationGroup, dispatch_get_main_queue(), {
|
||||
//self.delegate?.listingHasNewNotifications(nil, ebayInfo: nil, amazonInfo: nil, etsyInfo: nil)
|
||||
//})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user