Currently working on ebay notifications

This commit is contained in:
Okechi Onyeje 2016-09-03 15:18:58 -04:00
parent f2ed3b9165
commit 9888a1c7a5
6 changed files with 96 additions and 1256 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -40,6 +40,7 @@ class EbayWebServiceManager: NSObject {
private var completion: ServiceResponse! private var completion: ServiceResponse!
private var isGettingSubCategories: Bool = false private var isGettingSubCategories: Bool = false
private var isRevisingListing: Bool = false private var isRevisingListing: Bool = false
var isGettingNotification: Bool = false
//---------------------------------------------// //---------------------------------------------//
@ -328,6 +329,27 @@ extension EbayWebServiceManager {
self.catDetailLevel = detailLevel self.catDetailLevel = detailLevel
self.requestMaker(soapMessage, theRequest: theRequest) self.requestMaker(soapMessage, theRequest: theRequest)
} }
func getListingInfo(listingID: String, onComplete: ServiceResponse?){
var soapMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<GetItemRequest xmlns=\"urn:ebay:apis:eBLBaseComponents\">" +
"<RequesterCredentials>" +
"<eBayAuthToken>\(self.xmlResponseDictionary["eBayAuthToken"] as! String)</eBayAuthToken>" +
"</RequesterCredentials>"
soapMessage = soapMessage +
"<ItemID>\(listingID)</ItemID>" +
"</GetItemRequest>"
let url = NSURL(string: self.baseURL)
let theRequest = NSMutableURLRequest(URL: url!)
theRequest.addValue("GetItem", forHTTPHeaderField: "X-EBAY-API-CALL-NAME")
self.completion = onComplete
self.isGettingNotification = true
self.requestMaker(soapMessage, theRequest: theRequest)
}
} }
extension EbayWebServiceManager: NSURLConnectionDelegate { extension EbayWebServiceManager: NSURLConnectionDelegate {
@ -478,6 +500,7 @@ extension EbayWebServiceManager: NSXMLParserDelegate {
self.catLevel = string self.catLevel = string
break break
case "CategoryName" : case "CategoryName" :
if (!self.isGettingNotification) {
if(!self.isGettingSubCategories) { if(!self.isGettingSubCategories) {
if((EbayWebServiceManager.settingsDictionary["categories"]) == nil) { if((EbayWebServiceManager.settingsDictionary["categories"]) == nil) {
EbayWebServiceManager.settingsDictionary["categories"] = Dictionary<String , Dictionary<String, AnyObject>>() EbayWebServiceManager.settingsDictionary["categories"] = Dictionary<String , Dictionary<String, AnyObject>>()
@ -498,6 +521,9 @@ extension EbayWebServiceManager: NSXMLParserDelegate {
} }
}
self.currentCategory = string self.currentCategory = string
break break
@ -534,6 +560,14 @@ extension EbayWebServiceManager: NSXMLParserDelegate {
self.isRevisingListing = true self.isRevisingListing = true
break break
/*
Used for retrieving listing info for notifications
*/
case "ListingStatus":
print("ListingStatus: \(string)")
self.completion(string, nil)
self.isGettingNotification = false
break
default: default:
//print(string) //print(string)
print("\(self.currentElementName):\(string)") print("\(self.currentElementName):\(string)")

View File

@ -39,6 +39,8 @@ class ItemImagePickerViewController: UIViewController {
private var imageIndex: Int! private var imageIndex: Int!
private var isEditing: Bool = false private var isEditing: Bool = false
private var currentInformation: Dictionary<String, AnyObject>! private var currentInformation: Dictionary<String, AnyObject>!
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()

View File

@ -67,7 +67,13 @@ class ServiceNotificationManager: NSObject {
//@TODO: Skeleton for Notfications Manager is set up. Need to implement listing request for each listing to retrieve relevant notifications for user such as if listing has ended //@TODO: Skeleton for Notfications Manager is set up. Need to implement listing request for each listing to retrieve relevant notifications for user such as if listing has ended
if(ebayID != nil){ if(ebayID != nil){
/*if self.ebayGraphManager.isAuthorized {
self.ebayGraphManager.getListingInfo(ebayID!, onComplete: {
(listingStatus, error) -> Void in
dispatch_group_leave(notificationGroup)
})
}*/
} }
if(facebookID != nil){ if(facebookID != nil){