From 2ccfb5f45129774347e6aa4d13a0ffd544a09d3f Mon Sep 17 00:00:00 2001 From: Cole Alban Date: Sat, 27 Aug 2016 12:55:41 -0400 Subject: [PATCH] Create URL Query String fror amazon --- Vendoo.xcodeproj/project.pbxproj | 16 +++++ Vendoo/.DS_Store | Bin 10244 -> 10244 bytes Vendoo/AmazonWebServiceManager.swift | 82 +++++++++++++++++++++ Vendoo/EbayWebServiceManager.swift | 24 +++++-- Vendoo/FeedType.swift | 28 ++++++++ Vendoo/ListingPreviewViewController.swift | 11 ++- Vendoo/Main.storyboard | 84 +++++++++++----------- Vendoo/NetworksTableViewController.swift | 4 ++ 8 files changed, 200 insertions(+), 49 deletions(-) create mode 100644 Vendoo/AmazonWebServiceManager.swift create mode 100644 Vendoo/FeedType.swift diff --git a/Vendoo.xcodeproj/project.pbxproj b/Vendoo.xcodeproj/project.pbxproj index 908bce8..7b1404b 100644 --- a/Vendoo.xcodeproj/project.pbxproj +++ b/Vendoo.xcodeproj/project.pbxproj @@ -43,6 +43,8 @@ 3EFB0E331D0B968300A05D7A /* SideMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EFB0E321D0B968300A05D7A /* SideMenuView.swift */; }; 3F8E0464700649BDD8B552B1 /* Pods_Vendoo_VendooTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B876489113F498AF1D2FD7E9 /* Pods_Vendoo_VendooTests.framework */; }; A87525ED0EE7D42D9A7708D8 /* Pods_Vendoo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23ECC3C8465826BD6AC74A02 /* Pods_Vendoo.framework */; }; + B6FD38131D70EB27008FB41E /* AmazonWebServiceManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6FD38121D70EB27008FB41E /* AmazonWebServiceManager.swift */; }; + B6FD38151D71CF3E008FB41E /* FeedType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6FD38141D71CF3E008FB41E /* FeedType.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -108,6 +110,8 @@ 3EFB0E321D0B968300A05D7A /* SideMenuView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SideMenuView.swift; sourceTree = ""; }; 7D1FC6F6278B48A7BA9A9E03 /* Pods_Vendoo_VendooUITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Vendoo_VendooUITests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; A44ED233D6B5454EF92FEB08 /* Pods-Vendoo-VendooUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Vendoo-VendooUITests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Vendoo-VendooUITests/Pods-Vendoo-VendooUITests.debug.xcconfig"; sourceTree = ""; }; + B6FD38121D70EB27008FB41E /* AmazonWebServiceManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AmazonWebServiceManager.swift; sourceTree = ""; }; + B6FD38141D71CF3E008FB41E /* FeedType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedType.swift; sourceTree = ""; }; B876489113F498AF1D2FD7E9 /* Pods_Vendoo_VendooTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Vendoo_VendooTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; E16BF843456476262BD075A1 /* Pods-Vendoo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Vendoo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Vendoo/Pods-Vendoo.debug.xcconfig"; sourceTree = ""; }; E25BEE3F146F38C121B72346 /* Pods-Vendoo-VendooTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Vendoo-VendooTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Vendoo-VendooTests/Pods-Vendoo-VendooTests.debug.xcconfig"; sourceTree = ""; }; @@ -169,6 +173,7 @@ 3E4897CE1D0062860069F742 /* Services */ = { isa = PBXGroup; children = ( + B676704A1D6FB9EA0014C99F /* AmazonServices */, 3EA668941D026E2A00EE57A8 /* EbayServices */, 3E4897CF1D00629B0069F742 /* FirebaseServices */, 3E7CF3FF1CF6363200F486B2 /* EtsyServices */, @@ -332,6 +337,15 @@ name = Menu; sourceTree = ""; }; + B676704A1D6FB9EA0014C99F /* AmazonServices */ = { + isa = PBXGroup; + children = ( + B6FD38121D70EB27008FB41E /* AmazonWebServiceManager.swift */, + B6FD38141D71CF3E008FB41E /* FeedType.swift */, + ); + name = AmazonServices; + sourceTree = ""; + }; D989DD70699180D9DB9DA709 /* Frameworks */ = { isa = PBXGroup; children = ( @@ -747,11 +761,13 @@ 3EC3251E1CF734C100626C48 /* NetworksTableViewController.swift in Sources */, 3EC325201CF7C3AB00626C48 /* NetworkTableViewCell.swift in Sources */, 3EC325261CF7E90000626C48 /* FacebookGraphAPIManager.swift in Sources */, + B6FD38131D70EB27008FB41E /* AmazonWebServiceManager.swift in Sources */, 3E7CF3FC1CF5FE9400F486B2 /* RecoverPasswordViewController.swift in Sources */, 3E1DC3CF1D42328C0091BC60 /* CategoryCell.swift in Sources */, 3EC325111CF703A600626C48 /* ItemCell.swift in Sources */, 3EA668A11D02836C00EE57A8 /* EbayWebServiceManager.swift in Sources */, 3ECEDB871CF9C722003566B3 /* ListingPreviewViewController.swift in Sources */, + B6FD38151D71CF3E008FB41E /* FeedType.swift in Sources */, 3E1B1F0B1D2493EE00DBCF08 /* EtsySettingsViewController.swift in Sources */, 3EC325231CF7DA5500626C48 /* HomeViewController.swift in Sources */, 3EC3252D1CF894C400626C48 /* ItemImagePickerViewController.swift in Sources */, diff --git a/Vendoo/.DS_Store b/Vendoo/.DS_Store index 8d98363c962d0d20de45ad6eb6f249159cd5cff4..10bee238e1b739bf52775678653512122becf6a5 100644 GIT binary patch delta 45 zcmZn(XbG6$LAU^hRb)@B}oNz9wsL>PG{He_sOSNP4soXLN@_CJO};28 g#m5xKz`&sK9}E~6HqRDj;n~ct@SA1xEDString{ + let dateFormatter: NSDateFormatter = NSDateFormatter() + dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" + dateFormatter.timeZone = NSTimeZone(forSecondsFromGMT: 0) + dateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") + return dateFormatter.stringFromDate(NSDate()) + } + +} diff --git a/Vendoo/EbayWebServiceManager.swift b/Vendoo/EbayWebServiceManager.swift index 59d8111..8cf9463 100644 --- a/Vendoo/EbayWebServiceManager.swift +++ b/Vendoo/EbayWebServiceManager.swift @@ -13,6 +13,10 @@ protocol EbayWebServiceManagerDelegate { func signInUser(string: String!) } + +/* + This class will manage the API requests for Ebay + */ class EbayWebServiceManager: NSObject { @@ -103,7 +107,12 @@ class EbayWebServiceManager: NSObject { //MARK: - authentication methods extension EbayWebServiceManager { - private func requestMaker(soapMessage: String!, theRequest: NSMutableURLRequest!) { + /* + This function will take in a mutable request and modify it for the given request. + soapMessage: The xml body to be placed in the request + theRequest: The request to be modified + */ + private func requestMaker(soapMessage: String!, theRequest: NSMutableURLRequest!){ let msgLength = soapMessage.characters.count theRequest.addValue("text/xml", forHTTPHeaderField: "Content-Type") theRequest.addValue(String(msgLength), forHTTPHeaderField: "Content-Length") @@ -123,12 +132,19 @@ extension EbayWebServiceManager { } } + + /* + This function will authorize ebay for this application. + It creates a soapMessage that will serve as the body + for an http request that will fire to the ebay API + to get a session ID. + */ func authorizeApp(){ let soapMessage = "" + - "" + - "Kroleo-Kroleo-Vendoo-S-ktqeobkk" + - "" + "" + + "Kroleo-Kroleo-Vendoo-S-ktqeobkk" + + "" let url = NSURL(string: self.baseURL) let theRequest = NSMutableURLRequest(URL: url!) diff --git a/Vendoo/FeedType.swift b/Vendoo/FeedType.swift new file mode 100644 index 0000000..00a3b57 --- /dev/null +++ b/Vendoo/FeedType.swift @@ -0,0 +1,28 @@ +// +// FeedType.swift +// Vendoo +// +// Created by cole alban on 8/27/16. +// Copyright © 2016 Okechi Onyeje. All rights reserved. +// + +import Foundation + + +enum FeedType: String{ + case POST_PRODUCT_DATA = "_POST_PRODUCT_DATA_" + case POST_INVENTORY_AVAILABILITY_DATA = "_POST_INVENTORY_AVAILABILITY_DATA_" + case POST_PRODUCT_OVERRIDES_DATA = "_POST_PRODUCT_OVERRIDES_DATA_" + case POST_PRODUCT_PRICING_DATA = "_POST_PRODUCT_PRICING_DATA_" + case POST_PRODUCT_IMAGE_DATA = "_POST_PRODUCT_IMAGE_DATA_" + case POST_PRODUCT_RELATIONSHIP_DATA = "_POST_PRODUCT_RELATIONSHIP_DATA_" + case POST_FLAT_FILE_INVLOADER_DATA = "_POST_FLAT_FILE_INVLOADER_DATA_" + case POST_FLAT_FILE_LISTINGS_DATA = "_POST_FLAT_FILE_LISTINGS_DATA_" + case POST_FLAT_FILE_BOOKLOADER_DATA = "_POST_FLAT_FILE_BOOKLOADER_DATA_" + case POST_FLAT_FILE_CONVERGENCE_LISTINGS_DATA = "_POST_FLAT_FILE_CONVERGENCE_LISTINGS_DATA_" + case POST_FLAT_FILE_PRICEANDQUANTITYONLY_UPDATE_DATA = "_POST_FLAT_FILE_PRICEANDQUANTITYONLY_UPDATE_DATA_" + case POST_UIEE_BOOKLOADER_DATA = " _POST_UIEE_BOOKLOADER_DATA_" + case POST_STD_ACES_DATA = "_POST_STD_ACES_DATA_" + + +} \ No newline at end of file diff --git a/Vendoo/ListingPreviewViewController.swift b/Vendoo/ListingPreviewViewController.swift index a402872..f922768 100644 --- a/Vendoo/ListingPreviewViewController.swift +++ b/Vendoo/ListingPreviewViewController.swift @@ -33,6 +33,7 @@ class ListingPreviewViewController: UIViewController { private var firManager: FirebaseManager! = nil private var ebayManager: EbayWebServiceManager! = nil private var etsyManager: EtsyRESTAPIManager! = nil + private var amazonManager: AmazonWebServiceManager! = nil private var itemListingDictionary: Dictionary! = Dictionary() private var alert = UIAlertController(title: "Listing Published", message: "Your listing has been published", preferredStyle: .Alert) private var lastListingKey: String! @@ -60,8 +61,6 @@ class ListingPreviewViewController: UIViewController { } func setListing(){ - - self.itemPicture.image = (self.itemListingDictionary["pictures"] as? [UIImageView])![0].image self.itemTitle.text = self.itemListingDictionary["title"] as! String self.itemDescription.text = self.itemListingDictionary["description"] as! String @@ -272,7 +271,13 @@ extension ListingPreviewViewController { //post to amazon if(self.networksDictionary["amazon"]!){ - + var listingParameters: [String: AnyObject] = [ + "title": self.itemTitle.text, + "quantity": self.itemQuantity.text, + "price": self.self.itemPrice.text, + "photo": self.itemPicture.image! + ] + self.amazonManager.listItem(listingParameters) } diff --git a/Vendoo/Main.storyboard b/Vendoo/Main.storyboard index 98bbf3b..5601300 100755 --- a/Vendoo/Main.storyboard +++ b/Vendoo/Main.storyboard @@ -470,7 +470,7 @@ - + @@ -505,7 +505,7 @@ - + @@ -540,7 +540,7 @@ - + @@ -575,7 +575,7 @@ - + @@ -610,7 +610,7 @@ - +