diff --git a/.DS_Store b/.DS_Store index 7492825..f9766d0 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/UserInterfaceState.xcuserstate b/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/UserInterfaceState.xcuserstate index 45431d9..2003377 100644 Binary files a/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/UserInterfaceState.xcuserstate and b/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 3a2882a..91a430f 100644 --- a/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/Vendoo.xcworkspace/xcuserdata/okechi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -9,6 +9,7 @@ shouldBeEnabled = "Yes" ignoreCount = "0" continueAfterRunningActions = "No" +<<<<<<< HEAD filePath = "Vendoo/ListingPreviewViewController.swift" timestampString = "501292645.293697" startingColumnNumber = "9223372036854775807" @@ -615,12 +616,14 @@ shouldBeEnabled = "Yes" ignoreCount = "0" continueAfterRunningActions = "No" +======= +>>>>>>> master filePath = "Vendoo/ItemTableViewController.swift" - timestampString = "501291030.615232" + timestampString = "502130300.686017" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "198" - endingLineNumber = "198" + startingLineNumber = "217" + endingLineNumber = "217" landmarkName = "tableView(_:cellForRowAtIndexPath:)" landmarkType = "5"> @@ -632,11 +635,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Vendoo/ItemTableViewController.swift" - timestampString = "501291030.615232" + timestampString = "502130607.978907" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "219" - endingLineNumber = "219" + startingLineNumber = "253" + endingLineNumber = "253" landmarkName = "tableView(_:cellForRowAtIndexPath:)" landmarkType = "5"> @@ -648,11 +651,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Vendoo/ItemTableViewController.swift" - timestampString = "501291030.615232" + timestampString = "502130713.514106" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "254" - endingLineNumber = "254" + startingLineNumber = "258" + endingLineNumber = "258" landmarkName = "tableView(_:cellForRowAtIndexPath:)" landmarkType = "5"> @@ -663,6 +666,7 @@ shouldBeEnabled = "Yes" ignoreCount = "0" continueAfterRunningActions = "No" +<<<<<<< HEAD filePath = "Vendoo/HomeViewController.swift" timestampString = "501429562.960347" startingColumnNumber = "9223372036854775807" @@ -761,11 +765,15 @@ continueAfterRunningActions = "No" filePath = "Vendoo/HomeViewController.swift" timestampString = "501438721.606962" +======= + filePath = "Vendoo/SignUpViewController.swift" + timestampString = "502139384.128941" +>>>>>>> master startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "172" - endingLineNumber = "172" - landmarkName = "viewDidLoad()" + startingLineNumber = "54" + endingLineNumber = "54" + landmarkName = "signUpUser(_:)" landmarkType = "5"> diff --git a/Vendoo/.DS_Store b/Vendoo/.DS_Store index cf8ea48..d9f4a62 100644 Binary files a/Vendoo/.DS_Store and b/Vendoo/.DS_Store differ diff --git a/Vendoo/AppDelegate.swift b/Vendoo/AppDelegate.swift index a38a8a6..3db7e02 100644 --- a/Vendoo/AppDelegate.swift +++ b/Vendoo/AppDelegate.swift @@ -28,6 +28,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { let storyboard = UIStoryboard(name: "Main", bundle: nil) let view: UIViewController! + + //based on if there is a currently logged in user, the entry view controller will either be signin or sign up if NSUserDefaults.standardUserDefaults().boolForKey("signedIn"){ view = storyboard.instantiateViewControllerWithIdentifier("SignInViewController") }else { @@ -73,6 +75,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { extension AppDelegate { func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool { + + //set up oauth for use with etsy if (url.host == "oauth-callback") { print(url) let components = NSURLComponents(URL: url, resolvingAgainstBaseURL: false) diff --git a/Vendoo/CategoriesTableViewController.swift b/Vendoo/CategoriesTableViewController.swift index 50f38d9..38873c8 100644 --- a/Vendoo/CategoriesTableViewController.swift +++ b/Vendoo/CategoriesTableViewController.swift @@ -136,415 +136,6 @@ class CategoriesTableViewController: UIViewController, UITableViewDelegate, UITa cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true //ebay - //leaving this in for category debugging purposes - /* - switch (cell.categoryName.text!) { - case ("Accessories") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true //ebay - break - case ("Antiques") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Art") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Baby") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Bags & Purses") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true //ebay - break - case ("Bath, Beauty & Health") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Books") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Business & Industrial") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Cameras & Photo") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Candles") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true //ebay - break - case ("Cell Phones & Accessories") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Clothing & Shoes") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Ceramics & Pottery") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true //ebay - break - case ("Children") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true //ebay - break - case ("Coins & Paper Money") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Collectibles") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Computers/Tablets & Networking") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Consumer Electronics") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Crafts") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Dolls & Miniatures") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("DVDs & Movies") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Entertainment Memorabilia") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Everything Else") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Furniture") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true //ebay - break - case ("Gift Cards & Coupons") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Geekery") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true //ebay - break - case ("Glass") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true //ebay - break - case ("Holidays") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true //ebay - break - case ("Home/Houseware & Garden") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Jewelry & Watches") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Knitting") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true //ebay - break - case ("Music") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true //ebay - break - case ("Musical Instruments & Gear") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Needlecraft") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true //ebay - break - case ("Paper Goods") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true //ebay - break - case ("Patterns") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true //ebay - break - case ("Pet Supplies") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Pottery & Glass") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Plants and Edibles") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true //ebay - break - case ("Quilts") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true //ebay - break - case ("Real Estate") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Specialty Services") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Sporting Goods") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Sports Memorabilia & Fan Shop") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Stamps") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Supplies") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true //ebay - break - case ("Tickets & Experiences") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Toys & Hobbies") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Travel") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Video Games & Consoles") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = false //ebay - //ask to drill into ebay categories - cell.shouldAskAboutLeafCategories = true - break - case ("Vintage") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true //ebay - break - case ("Wedding") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true //ebay - break - case ("Woodworking") : - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = false //facebook - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = false //etsy - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true //amazon - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true //ebay - break - default: - break - }*/ - - /*//ebay - if(true){ - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))?.hidden = true - } - //amazon - if(true){ - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 1, inSection: 0))?.hidden = true - } - //etsy - if(false){ - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 2, inSection: 0))?.hidden = true - - } - //facebook - if(false){ - cell.networks.cellForItemAtIndexPath(NSIndexPath(forRow: 3, inSection: 0))?.hidden = true - }*/ - }) @@ -567,6 +158,8 @@ class CategoriesTableViewController: UIViewController, UITableViewDelegate, UITa popover!.sourceRect = CGRectMake(100,100,50,50) popoverContent.setManagers(self.ebayManager) + + //dynamically loads ebay categories until leaf category is reached popoverContent.loadCategories(self.selectedCategory, selectedCatCompletion: { (categoryID, error) -> Void in self.selectedSub = categoryID as! String @@ -696,11 +289,13 @@ class CategoriesTableViewController: UIViewController, UITableViewDelegate, UITa let cell: CategoryCell! = tableView.cellForRowAtIndexPath(indexPath) as! CategoryCell//tableView.dequeueReusableCellWithIdentifier("CategoryCell", forIndexPath: indexPath) as? CategoryCell if(self.ebayManager.isAuthorized ) { + + //checks if the selected category is a leaf, if it is then go to choose networks else dynamically load child categories var dict: Dictionary> = (EbayWebServiceManager.settingsDictionary["categories"]!) as! Dictionary> let catDict = dict[self.selectedCategory] if (catDict != nil && !(catDict!["isLeaf"] as! Bool)){ - self.potentialEbay = true + self.potentialEbay = true //determines whether ebay should be an option for posting self.navigateCategories() } else{ @@ -712,41 +307,6 @@ class CategoriesTableViewController: UIViewController, UITableViewDelegate, UITa } } - /* - // Override to support conditional editing of the table view. - override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { - // Return false if you do not want the specified item to be editable. - return true - } - */ - - /* - // Override to support editing the table view. - override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { - if editingStyle == .Delete { - // Delete the row from the data source - tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) - } else if editingStyle == .Insert { - // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view - } - } - */ - - /* - // Override to support rearranging the table view. - override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) { - - } - */ - - /* - // Override to support conditional rearranging of the table view. - override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool { - // Return false if you do not want the item to be re-orderable. - return true - } - */ - // MARK: - Navigation @@ -777,7 +337,6 @@ class CategoriesTableViewController: UIViewController, UITableViewDelegate, UITa if self.potentialAmazon { (segue.destinationViewController as! NetworksTableViewController).toggleMarketPlaceVisibitlity("amazon") } - //print(self.categoryPicker.selectedRowInComponent(0)) } } diff --git a/Vendoo/CategoryPopUpController.swift b/Vendoo/CategoryPopUpController.swift index 8e85e20..a59cb5e 100644 --- a/Vendoo/CategoryPopUpController.swift +++ b/Vendoo/CategoryPopUpController.swift @@ -36,7 +36,6 @@ class CategoryPopUpController: UIViewController { self.ebayManager = ebayManager } - //@FIXME: Fix category selection for retrieving categories id values, hybrid categories don't work with this and have to manually add these func loadCategories( selectedCategory: String, selectedCatCompletion: ServiceResponse?) { self.parentCategory.append(selectedCategory) var catCode: String! diff --git a/Vendoo/EbaySettingsViewController.swift b/Vendoo/EbaySettingsViewController.swift index c916219..ed677dc 100644 --- a/Vendoo/EbaySettingsViewController.swift +++ b/Vendoo/EbaySettingsViewController.swift @@ -89,6 +89,7 @@ extension EbaySettingsViewController { } + //@TODO options for switching default settings for ebay listing will be added during beta testing after user input phase @IBAction func selectListingType(sender: AnyObject) { } diff --git a/Vendoo/EbayWebServiceManager.swift b/Vendoo/EbayWebServiceManager.swift index 7bb672e..da0f366 100644 --- a/Vendoo/EbayWebServiceManager.swift +++ b/Vendoo/EbayWebServiceManager.swift @@ -21,9 +21,13 @@ class EbayWebServiceManager: NSObject { //----------------------------------------------// let baseURL = "https://api.ebay.com/ws/api.dll" + //api credentials for app private var apiKey: String! private var devKey: String! private var certID: String! + var isAuthorized: Bool = NSUserDefaults.standardUserDefaults().boolForKey("ebayAuthorized") + + //request variables private var mutableData: NSMutableData = NSMutableData() private var currentElementName:NSString = "" private var catID: NSString! @@ -33,8 +37,9 @@ class EbayWebServiceManager: NSObject { private var userEmail:String = (NSUserDefaults.standardUserDefaults().objectForKey("email") as? String)! private var signinURL: String! private var xmlResponseDictionary: Dictionary = Dictionary() + + //class variables var delegate: EbayWebServiceManagerDelegate? - var isAuthorized: Bool = NSUserDefaults.standardUserDefaults().boolForKey("ebayAuthorized") static var settingsDictionary = Dictionary() private var subCategories = Dictionary>() private var completion: ServiceResponse! @@ -107,6 +112,7 @@ class EbayWebServiceManager: NSObject { //MARK: - authentication methods extension EbayWebServiceManager { + //used to set up all xml requests when making calls to ebay service private func requestMaker(soapMessage: String!, theRequest: NSMutableURLRequest!) { let msgLength = soapMessage.characters.count theRequest.addValue("text/xml", forHTTPHeaderField: "Content-Type") @@ -118,6 +124,8 @@ extension EbayWebServiceManager { theRequest.addValue("0", forHTTPHeaderField: "X-EBAY-API-SITEID") theRequest.addValue("", forHTTPHeaderField: "SOAPAction") theRequest.HTTPMethod = "POST" + + //adds xml soap message to request before starting call theRequest.HTTPBody = soapMessage.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) // or false let connection = NSURLConnection(request: theRequest, delegate: self, startImmediately: true) connection!.start() @@ -127,6 +135,7 @@ extension EbayWebServiceManager { } } + //authorize ebay for use with app by first getting a sessionID func authorizeApp(onComplete: ServiceResponse){ let soapMessage = "" + @@ -143,8 +152,8 @@ extension EbayWebServiceManager { } + func deauthorizeApp(){ - //@TODO: Add an alert to let user know if their account has not been deauthorized and keep them logged in. var soapMessage = "" + "" + "" + @@ -176,6 +185,7 @@ extension EbayWebServiceManager { } } + //used to retrieve users paypal email private func getPaypalEmail(onCompletion: ServiceResponse){ var soapMessage = "" + "" + @@ -214,35 +224,10 @@ extension EbayWebServiceManager { self.requestMaker(soapMessage, theRequest: theRequest) } + //used to add images to listing posting request before actually posting func addImagesToListing(listingID: String, imageURLs: [String], listingOnCompletion: ServiceResponse, body: [String:String],onCompletion: ServiceResponse) { listItem(body, imageUrls: imageURLs, completion: listingOnCompletion) - /* - var soapMessage = "" + - "" + - "" + - "\(self.xmlResponseDictionary["eBayAuthToken"] as! String)" + - "" - - soapMessage = soapMessage + "en_US" + - "" + - "\(listingID)" - - for i in 0...(imageURLs.count - 1) { - soapMessage = soapMessage + "" + - "\(imageURLs[i].stringByReplacingOccurrencesOfString("&", withString: "&"))" + - "" - } - - - soapMessage = soapMessage + "" - - let url = NSURL(string: self.baseURL) - let theRequest = NSMutableURLRequest(URL: url!) - theRequest.addValue("ReviseItem", forHTTPHeaderField: "X-EBAY-API-CALL-NAME") - self.completion = onCompletion - self.requestMaker(soapMessage, theRequest: theRequest) - */ } func listItem(params: [String: String], imageUrls: [String], completion: ServiceResponse?){ @@ -254,6 +239,7 @@ extension EbayWebServiceManager { "\(self.xmlResponseDictionary["eBayAuthToken"] as! String)" + "" + //if paypal email not in local cache retrieve it before continuing to post to ebay if((dict["payment"] as? String) == "PayPal") { dispatch_group_enter(emailRetrievalGroup) if((EbayWebServiceManager.settingsDictionary["paypal_email"]) == nil) { @@ -284,7 +270,8 @@ extension EbayWebServiceManager { "\(dict["payment"] as! String!)" + "\(dict["paypal_email"] as! String!)Gallery" - for i in 0...(imageUrls.count - 1) { //will replace with actual count once everything is working with images + //append image urls to listing request + for i in 0...(imageUrls.count - 1) { soapMessage = soapMessage + "\(imageUrls[i].stringByReplacingOccurrencesOfString("&", withString: "&"))" @@ -307,6 +294,8 @@ extension EbayWebServiceManager { "US" + "" print(soapMessage) + + //make request let url = NSURL(string: self.baseURL) let theRequest = NSMutableURLRequest(URL: url!) theRequest.addValue("AddItem", forHTTPHeaderField: "X-EBAY-API-CALL-NAME") @@ -317,6 +306,7 @@ extension EbayWebServiceManager { } } + //after getting a sessionID get a unique oauth token func fetchToken() { let soapMessage = "" + "\(self.xmlResponseDictionary["SessionID"] as! String!)" @@ -328,10 +318,11 @@ extension EbayWebServiceManager { self.requestMaker(soapMessage, theRequest: theRequest) } + //used to get sub categories when creating a new listing func getSubCategories(selectedCategory: String, detailLevel: Int, catCode: String, onCompletion: ServiceResponse) { self.isGettingNotification = false self.isGettingSubCategories = true - //var dict = EbayWebServiceManager.settingsDictionary["categories"]! + var soapMessage = "" + "" + "" + @@ -350,6 +341,7 @@ extension EbayWebServiceManager { self.requestMaker(soapMessage, theRequest: theRequest) } + //used for notifications to retrieve current information about the status of a listing func getListingInfo(listingID: String, onComplete: ServiceResponse?){ var soapMessage = "" + "" + @@ -405,6 +397,7 @@ extension EbayWebServiceManager: NSURLConnectionDelegate { } } +//used to parse xml responses and save data extension EbayWebServiceManager: NSXMLParserDelegate { func parser(parser: NSXMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String]) { @@ -454,23 +447,6 @@ extension EbayWebServiceManager: NSXMLParserDelegate { "\(string)" + "" - /* - * - - - boolean - ItemIDType (string) - string - - DetailLevelCodeType - - string - string - string - WarningLevelCodeType - - */ - let url = NSURL(string: self.baseURL) let theRequest = NSMutableURLRequest(URL: url!) theRequest.addValue("GetUser", forHTTPHeaderField: "X-EBAY-API-CALL-NAME") @@ -487,6 +463,7 @@ extension EbayWebServiceManager: NSXMLParserDelegate { } break + //saves paypal email from response case "DefaultPayPalEmailAddress": var dict = (EbayWebServiceManager.settingsDictionary) dict["paypal_email"] = string @@ -494,6 +471,8 @@ extension EbayWebServiceManager: NSXMLParserDelegate { NSUserDefaults.standardUserDefaults().setObject(EbayWebServiceManager.settingsDictionary, forKey: "ebaySettings") self.completion(nil, nil) break + + //saves userID from response and gets toplevel ebay categories case "UserID" : if(!self.isGettingNotification) { print(string) @@ -545,12 +524,6 @@ extension EbayWebServiceManager: NSXMLParserDelegate { self.currentCategory = string } - /* var dict: Dictionary> = (EbayWebServiceManager.settingsDictionary["categories"]!) as! Dictionary> - - dict[string] = ["cat_id": self.catID, "isLeaf": false, "level": self.catLevel] - EbayWebServiceManager.settingsDictionary["categories"] = dict - NSUserDefaults.standardUserDefaults().setObject(EbayWebServiceManager.settingsDictionary, forKey: "ebaySettings")*/ - } @@ -564,7 +537,6 @@ extension EbayWebServiceManager: NSXMLParserDelegate { dict[self.currentCategory]!["isLeaf"] = true } else { - //@FIXME: breaking here retrieveing subcategories if (self.catDetailLevel == Int((self.subCategories[self.currentCategory]!["level"] as! String))) { self.subCategories[self.currentCategory]!["isLeaf"] = true diff --git a/Vendoo/EtsyRESTAPIManager.swift b/Vendoo/EtsyRESTAPIManager.swift index 77dcb8c..fcf0221 100644 --- a/Vendoo/EtsyRESTAPIManager.swift +++ b/Vendoo/EtsyRESTAPIManager.swift @@ -37,7 +37,6 @@ class EtsyRESTAPIManager: NSObject { //User specific class variables private var etsyUser: String! private var oauthswift: OAuth1Swift! - //private let oauthswift = OAuth1Swift(parameters: ["consumerKey":"snbs78qkfy3yqq6yhe6yv49b","consumerSecret":"4sbva4oqb6", "requestTokenUrl": "https://openapi.etsy.com/v2/oauth/request_token?scope=listings_w%20listings_r%20listings_d%20transactions_r%20transactions_w%20"]) override init(){ super.init() @@ -61,7 +60,8 @@ class EtsyRESTAPIManager: NSObject { self.oauthswift.client.credential.oauth_token = (oauthDictionary?["token"] as? String!)! self.oauthswift.client.credential.oauth_token_secret = (oauthDictionary?["secret"] as? String!)! - self.sendGETRequest("/taxonomy/categories", /*body: ["oauth_token":(oauthDictionary?["token"] as? String!)!],*/ onCompletion: { + //used to get all etsy categories if user is authorized + self.sendGETRequest("/taxonomy/categories", onCompletion: { (dict, error) -> Void in var resultDictionary = Dictionary() @@ -75,6 +75,7 @@ class EtsyRESTAPIManager: NSObject { }) } + //sets up posting defaults when posting to etsy if(NSUserDefaults.standardUserDefaults().boolForKey("etsyDefaultsOverriden")) { EtsyRESTAPIManager.settingsDictionary = (NSUserDefaults.standardUserDefaults().objectForKey("etsySettings") as? Dictionary)! @@ -115,20 +116,7 @@ extension EtsyRESTAPIManager { oauthswift!.authorize_url_handler = SafariURLHandler(viewController: viewcontroller) - /* - let authRequest = self.oauthswift.client.makeRequest("https://openapi.etsy.com/v2/oauth/request_token?", method: OAuthSwiftHTTPRequest.Method.GET, parameters: ["scope":"listings_w%20listings_r%20listings_d%20transactions_r%20transactions_w"] , headers: nil) - - do{ - - try authRequest?.makeRequest() - - - }catch{ - (error) - } - */ - - /*["scope":"listings_w%20listings_r%20listings_d%20transactions_r%20transactions_w"]*/ + //start oauth handshake self.oauthswift!.client.get("https://openapi.etsy.com/v2/oauth/request_token?scope=listings_w%20listings_r%20listings_d%20transactions_r%20transactions_w", success: { data, response in @@ -136,9 +124,6 @@ extension EtsyRESTAPIManager { let dataString = NSString(data: data, encoding: NSUTF8StringEncoding) - - //print(response.allHeaderFields) - //print(dataSting) let json = JSON(data) print(json) print(dataString) @@ -147,8 +132,6 @@ extension EtsyRESTAPIManager { self.oauthswift!.authorizeWithCallbackURL( NSURL(string: "vendoo://oauth-callback/etsy")!, success: { credential, response, parameters in - print(credential.oauth_token) - print(credential.oauth_token_secret) print(response) boolResult = false @@ -165,7 +148,7 @@ extension EtsyRESTAPIManager { //save data to keychain - + //sign oauth token with verifier self.oauthswift!.client.get("https://openapi.etsy.com/v2/oauth/access_token", parameters: ["oauth_verifier":(self.oauthswift.client.credential.oauth_verifier)], success: { data, response in @@ -175,8 +158,7 @@ extension EtsyRESTAPIManager { print(response) let json1 = JSON(response) print(json1) - //print(response.allHeaderFields) - //print(dataSting) + let json = JSON(data) print(json) print(dataString!) @@ -197,7 +179,7 @@ extension EtsyRESTAPIManager { } print(matches) - + //save oauth credentials for current user let oauth: Dictionary? = [ "token" : String(matches[1].characters.dropFirst()) , "secret" : String(matches[3].characters.dropFirst()) ] do{ @@ -210,6 +192,9 @@ extension EtsyRESTAPIManager { self.oauthswift.client.credential.oauth_token = oauth!["token"]! as! String self.oauthswift.client.credential.oauth_token_secret = oauth!["secret"]! as! String + // get required credentials from users account to allow posting of new listings + + //get user name self.oauthswift!.client.get("https://openapi.etsy.com/v2/users/__SELF__", success: { data, response in @@ -227,12 +212,14 @@ extension EtsyRESTAPIManager { onComplete(nil,nil) + //get users payment template if one exists, if not create one for user self.sendGETRequest("/private/shops/__SELF__/payment_templates", onCompletion: { (data, error) -> Void in - self.sendGETRequest("/taxonomy/categories", /*body: ["oauth_token":(oauthDictionary?["token"] as? String!)!],*/ onCompletion: { + self.sendGETRequest("/taxonomy/categories", onCompletion: { (dict, error) -> Void in + //save retrieved categories to settings dictionary var resultDictionary = Dictionary() for catDictionary in (dict as! [Dictionary]) { print(catDictionary) @@ -245,7 +232,7 @@ extension EtsyRESTAPIManager { NSUserDefaults.standardUserDefaults().setObject(EtsyRESTAPIManager.settingsDictionary, forKey: "etsySettings") - + //retrieve shipping template if one exists, if not create one self.sendGETRequest("/private/users/__SELF__/shipping/templates", onCompletion: nil) }) @@ -268,19 +255,12 @@ extension EtsyRESTAPIManager { } - /*let results = regex.matchesInString(dataString! as String, - options: [], range: NSMakeRange(0, nsString.length)) - print(results.map { nsString.substringWithRange($0.range)})*/ } catch let error as NSError { print("invalid regex: \(error.localizedDescription)") } - /* - - */ - }, failure: { @@ -289,14 +269,9 @@ extension EtsyRESTAPIManager { }) - //return boolResult - }) }) - //getting error here when trying to retrieve the login url from the response - //var dataDictionary = self.convertStringToDictionary(dataString! as String) - //print(dataDictionary!["login_url"]) } , failure: { error in print(error) @@ -308,27 +283,12 @@ extension EtsyRESTAPIManager { } - - - - - - - - //once everything is authorized save true value to the authorization boolean - /* - NSUserDefaults.standardUserDefaults().setBool(true, forKey: "etsyAuthorized") - self.isAuthorized = NSUserDefaults.standardUserDefaults().boolForKey("etsyAuthorized") - */ } func deAuthorizeApp(viewcontroller: UIViewController){ - - - oauthswift!.authorize_url_handler = SafariURLHandler(viewController: viewcontroller) oauthswift!.client.get("https://openapi.etsy.com/v2/oauth/request_token?scope=listings_w%20listings_r%20listings_d%20transactions_r%20transactions_w", success: { @@ -337,12 +297,6 @@ extension EtsyRESTAPIManager { print(dataString!) print(response) - - - - //getting error here when trying to retrieve the login url from the response - //var dataDictionary = self.convertStringToDictionary(dataString! as String) - //print(dataDictionary!["login_url"]) } , failure: { error in print(error) @@ -409,7 +363,7 @@ extension EtsyRESTAPIManager { //MARK: - Request Methods extension EtsyRESTAPIManager { - + //the following functions are attempts to get image upload working for etsy func sendFile( urlPath:String, fileName:String, @@ -442,10 +396,7 @@ extension EtsyRESTAPIManager { queue: queue, completionHandler:completionHandler) } - - // this is a very verbose version of that function - // you can shorten it, but i left it as-is for clarity - // and as an example + func photoDataToFormData(data:NSData,boundary:String,fileName:String) -> NSData { var fullData = NSMutableData() @@ -486,42 +437,8 @@ extension EtsyRESTAPIManager { return fullData } - func generateUserRequest(etsyName: String!, etsyOptions: [String]!) -> String { - - //starting url for user request to api - var userRequest: String! - - if(etsyName == nil || etsyName == ""){ - userRequest = (baseURL + "/private/users/etsystore?") - } - else{ - userRequest = (baseURL + "/private/users/" + etsyName + "?") - } - - //final api request - return userRequest + "api_key=" + self.apiKey - } - - func generateListingRequest(etsyListing: String!){ - - //starting url for listing request - } - //sends the pregenerated url as a request to api service func sendGETRequest(request: String, onCompletion: ServiceResponse?) { - /* let request = NSMutableURLRequest(URL: NSURL(string: request)!) - - let session = NSURLSession.sharedSession() - - let task = session.dataTaskWithRequest(request, completionHandler: {data, response, error -> Void in - if let jsonData = data { - let json:JSON = JSON(data: jsonData) - onCompletion(json, error) - } else { - onCompletion(nil, error) - } - }) - task.resume()*/ self.oauthswift.client.get(self.baseURL + request, success: { @@ -534,6 +451,7 @@ extension EtsyRESTAPIManager { switch (request) { case "/private/shops/__SELF__/payment_templates" : + //create a payment template if none is found if ((dict!["results"]!.isKindOfClass(NSNull.classForCoder()))) { //@TODO: Put payment template parameters in function call self.oauthswift.client.post(self.baseURL + "/private/shops/__SELF__/payment_templates", @@ -560,11 +478,13 @@ extension EtsyRESTAPIManager { onCompletion!(nil,nil) } break + case "/private/users/__SELF__/shipping/templates" : var dict2 = (dict!["results"] as! [[String : AnyObject]]) if ((dict!["results"]!.isKindOfClass(NSNull.classForCoder()))) { - //@TODO: Put payment template parameters in function call + + //create default shipping template if none found self.oauthswift.client.post(self.baseURL + "/private/shipping/templates", parameters: [ "title":"vendoo_default", @@ -593,6 +513,8 @@ extension EtsyRESTAPIManager { } break + + //gets etsy categories case "/taxonomy/categories": var dict2 = (dict!["results"] as! [[String : AnyObject]]) onCompletion!(dict2, nil) @@ -635,6 +557,8 @@ extension EtsyRESTAPIManager { //sends the pregenerated url as a request to api service func sendPOSTRequest(request: String, var body: [String: AnyObject]?, onCompletion: ServiceResponse?) { + //attempt to post images to etsy + /* let request = NSMutableURLRequest(URL: NSURL(string: request)!) // Set the method to POST @@ -660,6 +584,7 @@ extension EtsyRESTAPIManager { onCompletion(nil, nil) }*/ + //for posting image to etsy, currently not working if(request.containsString("listings/") && request.containsString("/images")){ let url = NSURL(string: self.baseURL + request)! @@ -680,6 +605,8 @@ extension EtsyRESTAPIManager { } ) + //more attempts to get image uploads to etsy to work :-( + /* let requested = NSMutableURLRequest(URL: url) requested.HTTPMethod = "POST" @@ -814,6 +741,8 @@ extension EtsyRESTAPIManager { case "/private/shipping/templates": break + + //save new listing id from new esty posting case "/private/listings": var dict2 = (dict!["results"] as! [[String : AnyObject]]) print(((dict2[0]["listing_id"])!)) @@ -835,7 +764,6 @@ extension EtsyRESTAPIManager { case "/private/listings": print(error.userInfo["Response-Body"]) if((error.userInfo["Response-Body"]!.isEqualToString("price is below listing fee."))) { - //@TODO: add alert to let user know that the price they have given is too low for etsy } break @@ -857,6 +785,7 @@ extension EtsyRESTAPIManager { //MARK: - JSON Methods extension EtsyRESTAPIManager { + //converts responses from etsy to JSON dictionaries func convertStringToDictionary(text: String) -> [String:AnyObject]? { if let data = text.dataUsingEncoding(NSUTF8StringEncoding) { do { diff --git a/Vendoo/EtsySettingsViewController.swift b/Vendoo/EtsySettingsViewController.swift index 54fb447..848dbf3 100644 --- a/Vendoo/EtsySettingsViewController.swift +++ b/Vendoo/EtsySettingsViewController.swift @@ -8,6 +8,7 @@ import UIKit +/// Used to both display and change options for posting to etsy class EtsySettingsViewController: UIViewController { var wereDefaultsChanged: Bool = NSUserDefaults.standardUserDefaults().boolForKey("etsyDefaultsOverriden") diff --git a/Vendoo/FacebookGraphAPIManager.swift b/Vendoo/FacebookGraphAPIManager.swift index 7cf1a8c..666c029 100644 --- a/Vendoo/FacebookGraphAPIManager.swift +++ b/Vendoo/FacebookGraphAPIManager.swift @@ -18,12 +18,7 @@ protocol FacebookGraphAPIManagerDelegate { func listingUploadedFB(fbID: String) } -/* - NOTE: - I am able to authorize application for use with facebook and deauthorize it while showing the toggle button switching back and forth, but during the last step of the process, for some reason NSUserDefault key for fbauthorized is not being called, in response handler, may need to run in a different thread - - NEED to figure out how to post picture and text as the same timeline post current can only upload item title, price and description. - */ + class FacebookGraphAPIManager: NSObject { //API Manager class variables @@ -52,7 +47,6 @@ class FacebookGraphAPIManager: NSObject { let dictionary = Locksmith.loadDataForUserAccount(self.userEmail, inService: "vendoo") print("account credentials loaded") - //print((NSUserDefaults.standardUserDefaults().objectForKey("") as? FBSDKAccessToken!)) } } diff --git a/Vendoo/FirebaseManager.swift b/Vendoo/FirebaseManager.swift index c217f7d..17b7253 100644 --- a/Vendoo/FirebaseManager.swift +++ b/Vendoo/FirebaseManager.swift @@ -12,32 +12,40 @@ import Locksmith import FirebaseStorage import TYMActivityIndicatorView +/// This class is responsible for initializing a new user, as well as managing web request to both firebase database and data storage class FirebaseManager: NSObject { + let ref = FIRDatabase.database().reference() let user_email = ((NSUserDefaults.standardUserDefaults().objectForKey("email") as? String)!).stringByReplacingOccurrencesOfString(".", withString: "_") let storage = FIRStorage.storage() var indicator = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.WhiteLarge) + var firGroup = dispatch_group_create() //let key: String! override init(){ super.init() indicator.color = UIColor.blueColor() + //check if user has been created - self.ref.child("Users").observeSingleEventOfType(.Value, withBlock: { snapshot in - // do some stuff once - - if(!snapshot.hasChild(self.user_email)){ - let user = ["name": (NSUserDefaults.standardUserDefaults().objectForKey("name") as? String)!, "user_Listings": "", "listing_Keys": "", "favorite_listings_keys": ""] - self.ref.child("Users").child(self.user_email).setValue(user) + dispatch_group_enter(self.firGroup) + self.ref.child("Users").observeSingleEventOfType(.Value, withBlock: { snapshot in - } - }) - - - + //if user created, setup user's firebase directory for use with app + if(!snapshot.hasChild(self.user_email)){ + let user = ["name": (NSUserDefaults.standardUserDefaults().objectForKey("name") as? String)!, "user_Listings": "", "listing_Keys": "", "favorite_listings_keys": ""] + self.ref.child("Users").child(self.user_email).setValue(user, withCompletionBlock: { + (error, reference) -> Void in + + dispatch_group_leave(self.firGroup) + }) + + }else{ + dispatch_group_leave(self.firGroup) + } + }) } } diff --git a/Vendoo/HomeViewController.swift b/Vendoo/HomeViewController.swift index ac3be80..0c0fb18 100644 --- a/Vendoo/HomeViewController.swift +++ b/Vendoo/HomeViewController.swift @@ -8,26 +8,37 @@ import UIKit +/// This class is resonsible for retrieving all listing information for the current user. +/// Acts as the tab bar controller for entire application. +/// Responsible for retrieving notifications from each currently authorized network + class HomeViewController: UITabBarController { - //acts as RESTful api call manager for etsy - //call this from tabbar controller to use etsy REST calls + + //Web Service Managers let etsyManager: EtsyRESTAPIManager = EtsyRESTAPIManager() let fbGraphManager = FacebookGraphAPIManager() let firebaseManager = FirebaseManager() let ebayGraphManager = EbayWebServiceManager() + + //Retrieved Listing Variables for draft, current, ended, sold var userListings: [Listing] = [] var endedListings: [Listing] = [] var soldListings: [Listing] = [] + + //notification manager variables var notificationsManager = ServiceNotificationManager() var notifications: [Dictionary] = (NSUserDefaults.standardUserDefaults().objectForKey("notifications") == nil ? [] : (NSUserDefaults.standardUserDefaults().objectForKey("notifications") as! [Dictionary])) override func viewDidLoad() { super.viewDidLoad() + + //initialize notifications manager 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(), { + dispatch_group_notify(self.firebaseManager.firGroup, dispatch_get_main_queue(), { //get all listing information for current user self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)").observeSingleEventOfType( .Value, withBlock: { @@ -37,11 +48,11 @@ class HomeViewController: UITabBarController { let listingDict = userDict!["user_Listings"] as? [String : AnyObject] - //sync notifications + //sync notifications (syncs only the notifications for networks that are currently authorized) if userDict!["notifications"] != nil { self.notifications = [] for (_, v) in userDict!["notifications"] as! [String : AnyObject] { - if v["seen"] as! Bool == false/*add network visibility as well*/{ + if v["seen"] as! Bool == false{ var is_networkAuth = false switch((v["network"] as! String)){ case "ebay": @@ -69,18 +80,23 @@ class HomeViewController: UITabBarController { NSUserDefaults.standardUserDefaults().setObject(userDict!["name"] as? String, forKey: "name") + //check if user has any listings to track for notifications if listingDict != nil { - var notificationStartTracker = 0 + var notificationStartTracker = 0 //number used to indicate when to start retrieving notifications + dispatch_async(dispatch_get_main_queue(), { - //let notificationStartGroup = dispatch_group_create() for (key, values) in listingDict! { + + //use this too make sure all listings are retrieved before showing listings in ItemsTableView 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] let storageRef = self.firebaseManager.storage.referenceForURL((databaseDict["image_storage"] as? String)!) + + //Get Main image first let mainListingImage = storageRef.child("images/\(key)/main.jpg") @@ -88,14 +104,17 @@ class HomeViewController: UITabBarController { mainListingImage.dataWithMaxSize(10 * 1024 * 1024, completion: { (dataMain, error) -> Void in + //for the case when there are connectivity issues, allows app to continue without waiting if(error != nil){ print("problem retrieving items") notificationStartTracker += 1 }else{ let mainImage = UIImage(data: dataMain!) - var listingImages: [UIImage] = [mainImage!] - var count = 0 + var listingImages: [UIImage] = [mainImage!] //set of all images for this listing + + var count = 0 //indicates when checking of all supporting images are done + //Get supporting images for i in 1...4 { let supportListingImg1 = storageRef.child("images/\(key)/\(i).jpg") @@ -112,21 +131,21 @@ class HomeViewController: UITabBarController { if(count == 4){ dispatch_group_leave(serviceGroup) notificationStartTracker += 1 - //dispatch_group_enter(notificationStartGroup) - //dispatch_group_leave(notificationStartGroup) } }) } - + //once images have been retrieved create a listing object with the reitrieved information dispatch_group_notify(serviceGroup, dispatch_get_main_queue(), { print(listingImages.count) let listingInfo = values as? [String : AnyObject] + //if no Listing status found then the listing is either active or a draft if listingInfo!["listingStatus"] == nil { self.userListings.append( - Listing(itemTitle: (listingInfo!["listingTitle"] as? String)!, + Listing( + itemTitle: (listingInfo!["listingTitle"] as? String)!, itemCategory: listingInfo!["listingCategory"] as? String, itemQuantity: (listingInfo!["listingQuantity"] as? String)!, itemPrice: listingInfo!["listingPrice"] as? String, @@ -137,6 +156,7 @@ class HomeViewController: UITabBarController { networksSellingOn: (listingInfo!["networks"] as? Dictionary)! )) } + //create ended Listing objects else if listingInfo!["listingStatus"] as? String == "Ended" { self.endedListings.append( Listing(itemTitle: (listingInfo!["listingTitle"] as? String)!, @@ -150,6 +170,7 @@ class HomeViewController: UITabBarController { networksSellingOn: (listingInfo!["networks"] as? Dictionary)! )) } + //create sold Listing object else if listingInfo!["listingStatus"] as? String == "Sold" { self.soldListings.append( Listing(itemTitle: (listingInfo!["listingTitle"] as? String)!, @@ -165,16 +186,12 @@ class HomeViewController: UITabBarController { } print(notificationStartTracker) + + //once all listings have been retrieved and processed start retrieving possible notifications if(notificationStartTracker == listingDict?.count){ NSNotificationCenter.defaultCenter().postNotificationName("finished_fetching_listings", object: nil) self.notificationsManager.setListings(self.userListings) self.notificationsManager.startServicePolling() - /*self.notificationsManager.startServicePolling({ - (_,_) -> Void in - NSNotificationCenter.defaultCenter().postNotificationName("finished_fetching_listings", object: nil) - - - })*/ } @@ -193,14 +210,7 @@ class HomeViewController: UITabBarController { } - /* - dispatch_group_notify(notificationStartGroup, dispatch_get_main_queue(), { - - })*/ - - - }) }else { NSNotificationCenter.defaultCenter().postNotificationName("finished_fetching_listings", object: nil) @@ -237,9 +247,10 @@ extension HomeViewController: ServiceNotificationManagerDelegate { } func listingHasStartedRetrievingNotifications() { - + //can be iterated upon to do work when notification retrieval process starts } + //delegate method that is used to add notifications to global notifications set func listingHasEnded(fbInfo: AnyObject?, ebayInfo: AnyObject?, amazonInfo: AnyObject?, etsyInfo: AnyObject?) { var notificationArray: [[String: AnyObject]] = self.notifications @@ -269,25 +280,18 @@ extension HomeViewController: ServiceNotificationManagerDelegate { notificationArray.append( notification as! [String : AnyObject] ) + + //Move listing from active to ended on local system 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() - })*/ - + //Move listing from active to ended and save new notifications to Firebase self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)").observeSingleEventOfType( .Value, withBlock: { (snapshot) -> Void in var userDict = snapshot.value as? [String : AnyObject] - var notifications = userDict!["notifications"] as? [String: AnyObject] + var notifications = userDict!["notifications"] as? [String: AnyObject] //get the current notifications from firebase if notifications == nil { userDict!["notifications"] = [((ebayInfo as! [String : AnyObject])["listingKey"] as! String):notification] @@ -343,10 +347,13 @@ extension HomeViewController: ServiceNotificationManagerDelegate { notificationArray.append( notification as! [String : AnyObject] ) + + //Move listing from active to ended on local system 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 + //Move listing from active to ended and save new notifications to Firebase self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)").observeSingleEventOfType( .Value, withBlock: { (snapshot) -> Void in @@ -356,7 +363,7 @@ extension HomeViewController: ServiceNotificationManagerDelegate { if notifications == nil { userDict!["notifications"] = [((etsyInfo as! [String : AnyObject])["listingKey"] as! String):notification] }else { - notifications![((etsyInfo as! [String : AnyObject])["listingKey"] as! String)] = notification + notifications![((etsyInfo as! [String : AnyObject])["listingKey"] as! String)] = notification //get the current notifications from firebase userDict!["notifications"] = notifications } @@ -383,6 +390,7 @@ extension HomeViewController: ServiceNotificationManagerDelegate { } + //delegate function called mostly by facebook notification when a new comment is posted func listingHasNewNotifications(fbInfo: AnyObject?, ebayInfo: AnyObject?, amazonInfo: AnyObject?, etsyInfo: AnyObject?) { var notificationArray: [Dictionary] = self.notifications @@ -395,6 +403,7 @@ extension HomeViewController: ServiceNotificationManagerDelegate { var userDict = snapshot.value as? [String : AnyObject] + //check if there are any notifications currently, if not then create a notifications directory in firebase and append notification to it if (userDict!["notifications"] != nil) { var notificationsFir = userDict!["notifications"] as! [String : AnyObject] notificationsFir[fbInfo!["UUID"] as! String] = fbInfo @@ -408,6 +417,8 @@ extension HomeViewController: ServiceNotificationManagerDelegate { }) }else { + + //if notification directory already exists append existing notification to it let id = (fbInfo!["UUID"] as! String) print(id) userDict!["notifications"] = ([ id : fbInfo as! [String:AnyObject]]) @@ -459,9 +470,6 @@ extension HomeViewController: ServiceNotificationManagerDelegate { ] ) } - - //@TODO: add firbase logic to add notifications and delete already viewed notifications - //reload data for notifications } } diff --git a/Vendoo/ItemImagePickerViewController.swift b/Vendoo/ItemImagePickerViewController.swift index bee776f..4e920ee 100644 --- a/Vendoo/ItemImagePickerViewController.swift +++ b/Vendoo/ItemImagePickerViewController.swift @@ -31,17 +31,19 @@ class ItemImagePickerViewController: UIViewController { @IBOutlet weak var itemDescription: UITextView! @IBOutlet weak var itemPrice: UITextField! @IBOutlet weak var textEditScrollView: UIScrollView! - @IBOutlet weak var categoryPicker: UIPickerView! @IBOutlet weak var priceLabel: UILabel! @IBOutlet weak var containerScrollView: UIScrollView! + @IBOutlet weak var plus_label0: UILabel! + @IBOutlet weak var plus_label1: UILabel! + @IBOutlet weak var plus_label2: UILabel! + @IBOutlet weak var plus_label3: UILabel! + @IBOutlet weak var plus_label4: UILabel! //class variables - var pickerData: [String] = [String]() var itemImagesSelections = [false,false,false,false,false] private var picker = UIImagePickerController() private var currImageSelected: UIImageView! - private var currUILabel: UILabel! private var imageIndex: Int! private var isEditing: Bool = false private var currentInformation: Dictionary! @@ -54,8 +56,8 @@ class ItemImagePickerViewController: UIViewController { self.tabBarController?.tabBar.hidden = true // Connect data: - self.categoryPicker.delegate = self - self.categoryPicker.dataSource = self + //self.categoryPicker.delegate = self + //self.categoryPicker.dataSource = self self.itemDescription.delegate = self self.itemName.delegate = self self.itemQuantity.delegate = self @@ -63,7 +65,6 @@ class ItemImagePickerViewController: UIViewController { self.picker.delegate = self addEditableItemsToScrollView() // Input data into the Array: - pickerData = ["Category 1", "Category 2", "Category 3", "Category 4", "Category 5", "Category 6"] let tapGestureMain = UITapGestureRecognizer(target: self, action: #selector(ItemImagePickerViewController.takePicture)) self.view.addGestureRecognizer(tapGestureMain) @@ -135,43 +136,60 @@ extension ItemImagePickerViewController { print(self.itemDescription.text!) print(self.possibleItemImageMain.image) print(self.itemPrice.text!) + if ( + self.itemName.text! == "" || + Int(self.itemQuantity.text!) == nil || + Int(self.itemQuantity.text!) < 1 || + self.itemPrice.text! == "" || + Double(self.itemPrice.text!) == nil || + Double(self.itemPrice.text!) < 0.30 || + self.itemDescription.text! == "Description" + ){ - var dict: Dictionary = ["title":self.itemName.text!, "description":self.itemDescription.text!, "price":self.itemPrice.text!, "quantity":self.itemQuantity.text!] - var counter = 0 - var images: [UIImageView] = [] - for bool in self.itemImagesSelections { - if !bool { - break - } - switch counter { - case 1: - images.append(self.possibleItemImage2) - break - case 2: - images.append(self.possibleItemImage3) - break - case 3: - images.append(self.possibleItemImage4) - break - case 4: - images.append(self.possibleItemImage5) - break - default: - images.append(self.possibleItemImageMain) - } - counter += 1 - } - - dict["pictures"] = images - (segue.destinationViewController as! CategoriesTableViewController).setListingDictionary(dict) - - if(self.isEditing) { - (segue.destinationViewController as! CategoriesTableViewController).setManagers((self.currentInformation["fbManager"] as? FacebookGraphAPIManager)!, fireManager: (self.currentInformation["firebaseManager"] as? FirebaseManager)!, ebayManager: (self.currentInformation["ebayManager"] as? EbayWebServiceManager)!, etsyManager: (self.currentInformation["etsyManager"] as? EtsyRESTAPIManager)!) + let alert = UIAlertController(title: "Required Information Missing", message: "To proceed with your listing, at least one image must be provided. Along with all provided fields including:\n Title\nDescription\nQuantity (must be greater than 0)\nPrice (must be greater than $0.30).", preferredStyle: .Alert) + alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)})) - }else { - (segue.destinationViewController as! CategoriesTableViewController).setManagers(((self.tabBarController as? HomeViewController)?.fbGraphManager)!, - fireManager: ((self.tabBarController as? HomeViewController)?.firebaseManager)!, ebayManager: ((self.tabBarController as? HomeViewController)?.ebayGraphManager)!, - etsyManager: ((self.tabBarController as? HomeViewController)?.etsyManager)!) + self.presentViewController(alert, animated: true, completion: nil) + + }else{ + var dict: Dictionary = ["title":self.itemName.text!, "description":self.itemDescription.text!, "price":self.itemPrice.text!, "quantity":self.itemQuantity.text!] + var counter = 0 + var images: [UIImageView] = [] + for bool in self.itemImagesSelections { + if !bool { + break + } + switch counter { + case 1: + images.append(self.possibleItemImage2) + break + case 2: + images.append(self.possibleItemImage3) + break + case 3: + images.append(self.possibleItemImage4) + break + case 4: + images.append(self.possibleItemImage5) + break + default: + images.append(self.possibleItemImageMain) + } + counter += 1 + } + + dict["pictures"] = images + (segue.destinationViewController as! CategoriesTableViewController).setListingDictionary(dict) + + if(self.isEditing) { + (segue.destinationViewController as! CategoriesTableViewController).setManagers((self.currentInformation["fbManager"] as? FacebookGraphAPIManager)!, fireManager: (self.currentInformation["firebaseManager"] as? FirebaseManager)!, ebayManager: (self.currentInformation["ebayManager"] as? EbayWebServiceManager)!, etsyManager: (self.currentInformation["etsyManager"] as? EtsyRESTAPIManager)!) + + }else { + (segue.destinationViewController as! CategoriesTableViewController).setManagers(((self.tabBarController as? HomeViewController)?.fbGraphManager)!, + fireManager: ((self.tabBarController as? HomeViewController)?.firebaseManager)!, ebayManager: ((self.tabBarController as? HomeViewController)?.ebayGraphManager)!, + etsyManager: ((self.tabBarController as? HomeViewController)?.etsyManager)!) + } + } } @@ -185,12 +203,30 @@ extension ItemImagePickerViewController: UIImagePickerControllerDelegate, UINavi func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) { - if (self.possibleItemImageMain.image != nil && self.currUILabel != nil ){ - self.currUILabel.hidden = true + switch(self.imageIndex){ + case 0: + self.plus_label0.hidden = true + break + case 1: + self.plus_label1.hidden = true + break + case 2: + self.plus_label2.hidden = true + break + case 3: + self.plus_label3.hidden = true + break + case 4: + self.plus_label4.hidden = true + break + default: + break } + self.currImageSelected.image = image self.itemImagesSelections[self.imageIndex] = true - dismissViewControllerAnimated(true, completion: nil) + self.dismissViewControllerAnimated(true, completion: nil) + } @@ -203,16 +239,12 @@ extension ItemImagePickerViewController: UIImagePickerControllerDelegate, UINavi let location: CGPoint = sender.locationInView(self.view) if(sender.state == UIGestureRecognizerState.Ended) { - var viewsWereSaved = [false, false] for view in self.view.subviews { if (view.isKindOfClass(UIImageView) && CGRectContainsPoint(view.frame, location)) { self.currImageSelected = view as! UIImageView switch (view.tag) { case 1: if(self.itemImagesSelections[0]) { - //self.itemImagesSelections[1] = true - viewsWereSaved[0] = true - self.imageIndex = 1 accessCam() } else { @@ -226,8 +258,6 @@ extension ItemImagePickerViewController: UIImagePickerControllerDelegate, UINavi case 2: if(self.itemImagesSelections[0] && self.itemImagesSelections[1]) { - viewsWereSaved[0] = true - self.imageIndex = 2 accessCam() } else { @@ -241,8 +271,6 @@ extension ItemImagePickerViewController: UIImagePickerControllerDelegate, UINavi case 3: if(self.itemImagesSelections[0] && self.itemImagesSelections[1] && self.itemImagesSelections[2]) { - viewsWereSaved[0] = true - self.imageIndex = 3 accessCam() } else { @@ -256,8 +284,6 @@ extension ItemImagePickerViewController: UIImagePickerControllerDelegate, UINavi case 4: if(self.itemImagesSelections[0] && self.itemImagesSelections[1] && self.itemImagesSelections[2] && self.itemImagesSelections[3]) { - viewsWereSaved[0] = true - self.imageIndex = 4 accessCam() } else { @@ -269,18 +295,13 @@ extension ItemImagePickerViewController: UIImagePickerControllerDelegate, UINavi } break default: - //self.itemImagesSelections[0] = true - self.imageIndex = 0 accessCam() break } } - if (view.isKindOfClass(UILabel) && CGRectContainsPoint(view.frame, location)) { - self.currUILabel = view as! UILabel - viewsWereSaved[1] = true - } + } } @@ -321,39 +342,6 @@ extension ItemImagePickerViewController: UIImagePickerControllerDelegate, UINavi -//MARK: - UIPickerViewDelegate -extension ItemImagePickerViewController: UIPickerViewDelegate { - - // Catpure the picker view selection - func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { - // This method is triggered whenever the user makes a change to the picker selection. - // The parameter named row and component represents what was selected. - } - -} - -//MARK: - UIPickerViewDatasource -extension ItemImagePickerViewController: UIPickerViewDataSource { - - // The number of columns of data - func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int { - return 1 - } - - // The number of rows of data - func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { - return pickerData.count - } - - // The data to return for the row and component (column) that's being passed in - func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { - return pickerData[row] - } - - - -} - extension ItemImagePickerViewController: UITextViewDelegate { func textViewDidBeginEditing(textView: UITextView) { @@ -522,7 +510,29 @@ extension ItemImagePickerViewController { if(!self.isEditing) { self.tabBarController?.selectedIndex = 0 + self.itemName.text = "" + self.itemPrice.text = "" + self.itemQuantity.text = "" + self.itemDescription.text = "Description" + self.imageIndex = nil + self.currentInformation = nil + self.possibleItemImageMain.image = nil + self.possibleItemImage2.image = nil + self.possibleItemImage3.image = nil + self.possibleItemImage4.image = nil + self.possibleItemImage5.image = nil + self.itemImagesSelections[0] = false + self.itemImagesSelections[1] = false + self.itemImagesSelections[2] = false + self.itemImagesSelections[3] = false + self.itemImagesSelections[4] = false + self.plus_label0.hidden = false + self.plus_label1.hidden = false + self.plus_label2.hidden = false + self.plus_label3.hidden = false + self.plus_label4.hidden = false }else{ + self.presentingViewController?.dismissViewControllerAnimated(true, completion: nil) } } diff --git a/Vendoo/ItemTableViewController.swift b/Vendoo/ItemTableViewController.swift index 7dae7af..192efa7 100644 --- a/Vendoo/ItemTableViewController.swift +++ b/Vendoo/ItemTableViewController.swift @@ -11,6 +11,7 @@ */ import UIKit import TYMActivityIndicatorView +import SWRevealViewController class ItemTableViewController: UIViewController { @@ -39,6 +40,7 @@ class ItemTableViewController: UIViewController { NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(stopIndicator), name: "finished_fetching_listings", object: nil) if self.revealViewController() != nil { menuButton.target = self.revealViewController() + (menuButton.target as! SWRevealViewController).delegate = self menuButton.action = "revealToggle:" self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer()) } @@ -59,6 +61,7 @@ class ItemTableViewController: UIViewController { override func viewWillAppear(animated: Bool) { super.viewWillAppear(animated) + (menuButton.target as! SWRevealViewController).delegate = self self.tabBarController?.tabBar.hidden = false } override func didReceiveMemoryWarning() { @@ -87,6 +90,42 @@ extension ItemTableViewController { } } +// MARK: - Side Menu View +extension ItemTableViewController: SWRevealViewControllerDelegate { + func revealController(revealController: SWRevealViewController!, didMoveToPosition position: FrontViewPosition) { + if(position == FrontViewPosition.Left) { + for view in self.view.subviews { + view.userInteractionEnabled = true + } + self.tabBarController?.tabBar.userInteractionEnabled = true + } else { + for view in self.view.subviews { + if !view.isKindOfClass(UINavigationBar){ + view.userInteractionEnabled = false + } + } + self.tabBarController?.tabBar.userInteractionEnabled = false + } + } + + func revealController(revealController: SWRevealViewController!, willMoveToPosition position: FrontViewPosition) { + if(position == FrontViewPosition.Left) { + for view in self.view.subviews { + view.userInteractionEnabled = true + } + self.tabBarController?.tabBar.userInteractionEnabled = true + } else { + for view in self.view.subviews { + if !view.isKindOfClass(UINavigationBar){ + view.userInteractionEnabled = false + } + + } + self.tabBarController?.tabBar.userInteractionEnabled = false + } + } +} + // MARK: - Navigation extension ItemTableViewController { diff --git a/Vendoo/ListingPreviewViewController.swift b/Vendoo/ListingPreviewViewController.swift index b5ca715..6796a44 100644 --- a/Vendoo/ListingPreviewViewController.swift +++ b/Vendoo/ListingPreviewViewController.swift @@ -68,10 +68,22 @@ class ListingPreviewViewController: UIViewController { /*if(!self.networksDictionary["areNetworksChosen"]!) { self.networks.hidden = true }*/ - /*else if (self.itemViewState == "Editable") { + else if (self.itemViewState == "Editible") { //self.cancel_backBtn.titleLabel?.text = "Back" - - }*/ + if( + self.itemTitle.text == "" || + self.itemDescription.text == "" || + self.itemPrice.text == "" || + self.itemCategory.text == "" || + self.itemQuantity == nil || + self.itemPictureMain.image == nil || + self.networks.numberOfItemsInSection(0) == 0 + ){ + + self.publishBtn.hidden = true + self.publishBtn.enabled = false + } + } // Do any additional setup after loading the view. // Initialization code @@ -210,20 +222,6 @@ extension Dictionary { } } } -/* - //MARK: - FacebookGraphAPIManagerDelegate methods - extension ListingPreviewViewController: FacebookGraphAPIManagerDelegate { - func listingUploadedFB(fbID: String) { - - self.firManager.ref.child("Users").child("\(self.firManager.user_email)").child("user_Listings").child(self.lastListingKey).updateChildValues(["network_listing_IDs":["fbID":fbID]]) - - self.alert.title = "Listing Published" - self.alert.message = "Your listing has been published to facebook" - - self.presentViewController(self.alert, animated: true, completion: nil) - } - } - */ //MARK: - IBActions extension ListingPreviewViewController { @@ -233,7 +231,7 @@ extension ListingPreviewViewController { let vc = storyboard.instantiateViewControllerWithIdentifier("Reveal View Controller") as! SWRevealViewController self.presentViewController(vc, animated: true, completion: nil) } - else if self.itemViewState == "Editable" || self.itemViewState == "NonEditable"{ + else if self.itemViewState == "Editible" || self.itemViewState == "NonEditable"{ self.presentingViewController?.dismissViewControllerAnimated(true, completion: nil) } @@ -261,34 +259,6 @@ extension ListingPreviewViewController { //save listing to private user path in firebase let newListingRef = self.firManager.ref.child("Users").child("\(self.firManager.user_email)").child("user_Listings").childByAutoId() let postingGroup: dispatch_group_t = dispatch_group_create() - - /*if(!(self.networksDictionary["ebay"]!)&&(!(self.networksDictionary["etsy"]!))&&(!(self.networksDictionary["amazon"]!))&&(!(self.networksDictionary["facebook"]!))) { - - }else { - dispatch_g - }*/ - //post to ebay - /*if(self.networksDictionary["ebay"]!){ - dispatch_group_enter(postingGroup) - - let body: [String: String] = [ "title": self.itemTitle.text, - "quantity":self.itemQuantity.text, - "description":self.itemDescription.text, - "price":self.itemPrice.text, - "category_id":self.itemListingDictionary["ebaySubCategoryID"] as! String - ] - - self.ebayManager.listItem(body, completion: { - (listingID, error) -> Void in - if((self.newInProgressListing["networkIDs"] == nil)){ - self.newInProgressListing["networkIDs"] = Dictionary() - } - var networkIDs = (self.newInProgressListing["networkIDs"] as! Dictionary) - networkIDs["ebay"] = listingID as! String - self.newInProgressListing["networkIDs"] = networkIDs - dispatch_group_leave(postingGroup) - }) - }*/ //post to amazon @@ -590,7 +560,6 @@ extension ListingPreviewViewController { //notifies once all selected networks have been posted to dispatch_group_notify(postingGroup, dispatch_get_main_queue(), { - //self.networksDictionary["areNetworksChosen"] = true self.newInProgressListing.update(["listingID": newListingRef.key, "seller email": (NSUserDefaults.standardUserDefaults().objectForKey("email") as? String)!, "listingTitle": self.itemTitle.text, @@ -637,7 +606,7 @@ extension ListingPreviewViewController { } - //change code to new multi-image saving + //save listing images to firebase for i in 0...(self.itemListingDictionary["pictures"] as! [UIImageView]).count - 1 { switch (i) { @@ -692,23 +661,9 @@ extension ListingPreviewViewController { self.newInProgressListing["networkIDs"] = networkIDs dispatch_group_leave(postingGroup) } - - /*self.ebayManager.listItem(body, completion: { - (listingID, error) -> Void in - if((self.newInProgressListing["networkIDs"] == nil)){ - self.newInProgressListing["networkIDs"] = Dictionary() - } - var networkIDs = (self.newInProgressListing["networkIDs"] as! Dictionary) - networkIDs["ebay"] = listingID as! String - self.newInProgressListing["networkIDs"] = networkIDs - dispatch_group_leave(postingGroup) - })*/ + self.ebayManager.listItem(body, imageUrls: imageURLs, completion: listingCompletion) - //self.ebayManager.addImagesToListing(networkIDs["ebay"] as! String, imageURLs: imageURLs, listingOnCompletion: listingCompletion, body: body, onCompletion: { - //(_, _) -> Void in - //dispatch_group_leave(postingGroup) - //}) - + } else { dispatch_group_leave(postingGroup) @@ -749,35 +704,6 @@ extension ListingPreviewViewController { } extension ListingPreviewViewController: UICollectionViewDelegate { - /* - // Uncomment this method to specify if the specified item should be highlighted during tracking - override func collectionView(collectionView: UICollectionView, shouldHighlightItemAtIndexPath indexPath: NSIndexPath) -> Bool { - return true - } - */ - - /* - // Uncomment this method to specify if the specified item should be selected - override func collectionView(collectionView: UICollectionView, shouldSelectItemAtIndexPath indexPath: NSIndexPath) -> Bool { - return true - } - */ - - /* - // Uncomment these methods to specify if an action menu should be displayed for the specified item, and react to actions performed on the item - override func collectionView(collectionView: UICollectionView, shouldShowMenuForItemAtIndexPath indexPath: NSIndexPath) -> Bool { - return false - } - - override func collectionView(collectionView: UICollectionView, canPerformAction action: Selector, forItemAtIndexPath indexPath: NSIndexPath, withSender sender: AnyObject?) -> Bool { - return false - } - - override func collectionView(collectionView: UICollectionView, performAction action: Selector, forItemAtIndexPath indexPath: NSIndexPath, withSender sender: AnyObject?) { - - } - */ - } //Mark: - UICollectionViewDataSource methods @@ -794,54 +720,11 @@ extension ListingPreviewViewController: UICollectionViewDataSource { return self.selectedNetworks.count } + //used for displaying relevant networks in listing preview func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { let cell: NetworkCollectionViewCell! = self.networks.dequeueReusableCellWithReuseIdentifier("network", forIndexPath: indexPath) as! NetworkCollectionViewCell cell.setImg(selectedNetworks[indexPath.row]) - /*switch (indexPath.row){ - case 0: - cell = collectionView.dequeueReusableCellWithReuseIdentifier("ebay", forIndexPath: indexPath) - - if(self.networksDictionary["ebay"] == false){ - cell.hidden = true - } - else{ - cell.hidden = false - } - break - - case 1: - cell = collectionView.dequeueReusableCellWithReuseIdentifier("amazon", forIndexPath: indexPath) - - if(self.networksDictionary["amazon"] == false){ - cell.hidden = true - } - else{ - cell.hidden = false - } - break - case 2: - cell = collectionView.dequeueReusableCellWithReuseIdentifier("etsy", forIndexPath: indexPath) - - if(self.networksDictionary["etsy"] == false){ - cell.hidden = true - } - else{ - cell.hidden = false - } - break - default: - cell = collectionView.dequeueReusableCellWithReuseIdentifier("facebook", forIndexPath: indexPath) - - if(self.networksDictionary["facebook"] == false){ - cell.hidden = true - } - else{ - cell.hidden = false - } - break - }*/ - return cell } diff --git a/Vendoo/Main.storyboard b/Vendoo/Main.storyboard index 16a3c1d..f1a7966 100755 --- a/Vendoo/Main.storyboard +++ b/Vendoo/Main.storyboard @@ -263,7 +263,7 @@ - + @@ -275,31 +275,31 @@ - + - +