mirror of
https://bitbucket.org/vendoo/vendoo_v1.0.git
synced 2025-12-25 11:47:40 +00:00
Etsy Ended and Sold notifications implemented
This commit is contained in:
parent
5df12695df
commit
518fbb3e1e
Binary file not shown.
@ -35,5 +35,117 @@
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/EtsyRESTAPIManager.swift"
|
||||
timestampString = "498402567.760806"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "625"
|
||||
endingLineNumber = "625"
|
||||
landmarkName = "getListingInfo(_:onCompletion:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "No"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/EtsyRESTAPIManager.swift"
|
||||
timestampString = "498399550.82937"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "618"
|
||||
endingLineNumber = "618"
|
||||
landmarkName = "getListingInfo(_:onCompletion:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/EtsyRESTAPIManager.swift"
|
||||
timestampString = "498402567.760806"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "623"
|
||||
endingLineNumber = "623"
|
||||
landmarkName = "getListingInfo(_:onCompletion:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/ServiceNotificationManager.swift"
|
||||
timestampString = "498402552.569625"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "124"
|
||||
endingLineNumber = "124"
|
||||
landmarkName = "pollServices()"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/HomeViewController.swift"
|
||||
timestampString = "499579562.452493"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "256"
|
||||
endingLineNumber = "256"
|
||||
landmarkName = "listingHasEnded(_:ebayInfo:amazonInfo:etsyInfo:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/HomeViewController.swift"
|
||||
timestampString = "499579731.915475"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "273"
|
||||
endingLineNumber = "273"
|
||||
landmarkName = "listingHasEnded(_:ebayInfo:amazonInfo:etsyInfo:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
<BreakpointProxy
|
||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||
<BreakpointContent
|
||||
shouldBeEnabled = "Yes"
|
||||
ignoreCount = "0"
|
||||
continueAfterRunningActions = "No"
|
||||
filePath = "Vendoo/HomeViewController.swift"
|
||||
timestampString = "499579805.922963"
|
||||
startingColumnNumber = "9223372036854775807"
|
||||
endingColumnNumber = "9223372036854775807"
|
||||
startingLineNumber = "275"
|
||||
endingLineNumber = "275"
|
||||
landmarkName = "listingHasEnded(_:ebayInfo:amazonInfo:etsyInfo:)"
|
||||
landmarkType = "5">
|
||||
</BreakpointContent>
|
||||
</BreakpointProxy>
|
||||
</Breakpoints>
|
||||
</Bucket>
|
||||
|
||||
@ -608,6 +608,28 @@ extension EtsyRESTAPIManager {
|
||||
)
|
||||
}
|
||||
|
||||
//gets listing info
|
||||
func getListingInfo (request: String, onCompletion: ServiceResponse?) {
|
||||
self.oauthswift.client.get(self.baseURL + request,
|
||||
success: {
|
||||
(data, response) -> Void in
|
||||
let dataString = NSString(data: data, encoding: NSUTF8StringEncoding)
|
||||
let dict = self.convertStringToDictionary(dataString! as String)
|
||||
print(dict)
|
||||
print(response)
|
||||
var dict2 = (dict!["results"] as! [[String : AnyObject]])
|
||||
|
||||
let listingState = dict2[0]["state"] as! String
|
||||
|
||||
onCompletion!(["status":listingState], nil)
|
||||
|
||||
|
||||
}, failure: {
|
||||
(error) -> Void in
|
||||
print(error)
|
||||
}
|
||||
)}
|
||||
|
||||
//sends the pregenerated url as a request to api service
|
||||
func sendPOSTRequest(request: String, var body: [String: AnyObject]?, onCompletion: ServiceResponse?) {
|
||||
|
||||
|
||||
@ -257,12 +257,25 @@ extension HomeViewController: ServiceNotificationManagerDelegate {
|
||||
self.notifications.append(
|
||||
[
|
||||
"network": "etsy",
|
||||
"message": (ebayInfo as! [String : AnyObject])["notification"] as! String,
|
||||
"message": (etsyInfo as! [String : AnyObject])["notification"] as! String,
|
||||
"type": "ended",
|
||||
"key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String,
|
||||
"key": (etsyInfo as! [String : AnyObject])["listingKey"] as! String,
|
||||
"UUID": NSUUID().UUIDString
|
||||
]
|
||||
)
|
||||
self.endedListings.appendContentsOf( self.userListings.filter({$0.key == ((etsyInfo as! [String : AnyObject])["listingKey"] as! String)}))
|
||||
self.userListings = self.userListings.filter({$0.key != ((etsyInfo as! [String : AnyObject])["listingKey"] as! String)})
|
||||
let itemsView = self.viewControllers![0] as! ItemTableViewController
|
||||
|
||||
self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)/user_Listings/\(((etsyInfo as! [String : AnyObject])["listingKey"] as! String))").observeSingleEventOfType( .Value, withBlock: {
|
||||
(snapshot) -> Void in
|
||||
|
||||
var listingDict = snapshot.value as? [String : AnyObject]
|
||||
listingDict!["listingStatus"] = "Ended"
|
||||
self.firebaseManager.ref.child("Users/\(self.firebaseManager.user_email)/user_Listings/\(((etsyInfo as! [String : AnyObject])["listingKey"] as! String))").setValue(listingDict)
|
||||
|
||||
itemsView.itemTable.reloadData()
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@ -310,13 +323,15 @@ extension HomeViewController: ServiceNotificationManagerDelegate {
|
||||
self.notifications.append(
|
||||
[
|
||||
"network": "etsy",
|
||||
"message": (ebayInfo as! [String : AnyObject])["notification"] as! String,
|
||||
"type": "",
|
||||
"key": (ebayInfo as! [String : AnyObject])["listingKey"] as! String,
|
||||
"message": (etsyInfo as! [String : AnyObject])["notification"] as! String,
|
||||
"type": (etsyInfo as! [String : AnyObject])["type"] as! String,
|
||||
"key": (etsyInfo as! [String : AnyObject])["listingKey"] as! String,
|
||||
"UUID": NSUUID().UUIDString
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
//@TODO: add firbase logic to add notifications and delete already viewed notifications
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,7 +114,45 @@ class ServiceNotificationManager: NSObject {
|
||||
|
||||
}
|
||||
if(etsyID != nil){
|
||||
if (self.etsyManager.isAuthorized) {
|
||||
self.etsyManager.getListingInfo ("/listings/\(etsyID!)", onCompletion: {
|
||||
(listingNotificationInfo, error) -> Void in
|
||||
|
||||
let info = (listingNotificationInfo as! [String : AnyObject])
|
||||
|
||||
//@TODO: Test this code with the draft condition for both expired and sold_out
|
||||
if ((info["status"] as! String == "expired") || (info["status"] as! String == "removed")) {
|
||||
|
||||
ServiceNotificationManager.delegate?.listingHasEnded(
|
||||
nil,
|
||||
ebayInfo: nil,
|
||||
amazonInfo: nil,
|
||||
etsyInfo: [
|
||||
"type": "Ended",
|
||||
"notification": "Your listing \"\(listingDict!["listingTitle"] as! String)\" has ended on etsy.",
|
||||
"listingKey": listing.key]
|
||||
)
|
||||
|
||||
|
||||
}else if info["status"] as! String == "sold_out" {
|
||||
|
||||
ServiceNotificationManager.delegate?.listingHasNewNotifications(
|
||||
nil,
|
||||
ebayInfo: nil,
|
||||
amazonInfo: nil,
|
||||
etsyInfo: [
|
||||
"type": "Sold",
|
||||
"notification": "Your listing \"\(listingDict!["listingTitle"] as! String)\" has sold out on etsy.",
|
||||
"listingKey": listing.key]
|
||||
)
|
||||
|
||||
} else if info["status"] as! String == "draft" {
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
if(amazonID != nil){
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user