mirror of
https://bitbucket.org/vendoo/vendoo_v1.0.git
synced 2025-12-26 12:17:39 +00:00
finished authorization portion of etsy integration, just need to do deauthorization and make the create new listing requests
This commit is contained in:
parent
0ab59c5d7b
commit
49c69c001b
Binary file not shown.
@ -90,11 +90,11 @@
|
|||||||
ignoreCount = "0"
|
ignoreCount = "0"
|
||||||
continueAfterRunningActions = "No"
|
continueAfterRunningActions = "No"
|
||||||
filePath = "Vendoo/EtsyRESTAPIManager.swift"
|
filePath = "Vendoo/EtsyRESTAPIManager.swift"
|
||||||
timestampString = "486467803.784775"
|
timestampString = "486486828.045437"
|
||||||
startingColumnNumber = "9223372036854775807"
|
startingColumnNumber = "9223372036854775807"
|
||||||
endingColumnNumber = "9223372036854775807"
|
endingColumnNumber = "9223372036854775807"
|
||||||
startingLineNumber = "52"
|
startingLineNumber = "67"
|
||||||
endingLineNumber = "52"
|
endingLineNumber = "67"
|
||||||
landmarkName = "authorizeApp(_:)"
|
landmarkName = "authorizeApp(_:)"
|
||||||
landmarkType = "5">
|
landmarkType = "5">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
@ -106,11 +106,11 @@
|
|||||||
ignoreCount = "0"
|
ignoreCount = "0"
|
||||||
continueAfterRunningActions = "No"
|
continueAfterRunningActions = "No"
|
||||||
filePath = "Vendoo/EtsyRESTAPIManager.swift"
|
filePath = "Vendoo/EtsyRESTAPIManager.swift"
|
||||||
timestampString = "486467838.042152"
|
timestampString = "486489301.995309"
|
||||||
startingColumnNumber = "9223372036854775807"
|
startingColumnNumber = "9223372036854775807"
|
||||||
endingColumnNumber = "9223372036854775807"
|
endingColumnNumber = "9223372036854775807"
|
||||||
startingLineNumber = "66"
|
startingLineNumber = "145"
|
||||||
endingLineNumber = "66"
|
endingLineNumber = "145"
|
||||||
landmarkName = "authorizeApp(_:)"
|
landmarkName = "authorizeApp(_:)"
|
||||||
landmarkType = "5">
|
landmarkType = "5">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
@ -122,59 +122,11 @@
|
|||||||
ignoreCount = "0"
|
ignoreCount = "0"
|
||||||
continueAfterRunningActions = "No"
|
continueAfterRunningActions = "No"
|
||||||
filePath = "Vendoo/EtsyRESTAPIManager.swift"
|
filePath = "Vendoo/EtsyRESTAPIManager.swift"
|
||||||
timestampString = "486468123.916868"
|
timestampString = "486489301.995309"
|
||||||
startingColumnNumber = "9223372036854775807"
|
startingColumnNumber = "9223372036854775807"
|
||||||
endingColumnNumber = "9223372036854775807"
|
endingColumnNumber = "9223372036854775807"
|
||||||
startingLineNumber = "82"
|
startingLineNumber = "147"
|
||||||
endingLineNumber = "82"
|
endingLineNumber = "147"
|
||||||
landmarkName = "authorizeApp(_:)"
|
|
||||||
landmarkType = "5">
|
|
||||||
<Locations>
|
|
||||||
<Location
|
|
||||||
shouldBeEnabled = "Yes"
|
|
||||||
ignoreCount = "0"
|
|
||||||
continueAfterRunningActions = "No"
|
|
||||||
symbolName = "Vendoo.EtsyRESTAPIManager.authorizeApp (__ObjC.UIViewController) -> ()"
|
|
||||||
moduleName = "Vendoo"
|
|
||||||
usesParentBreakpointCondition = "Yes"
|
|
||||||
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/EtsyRESTAPIManager.swift"
|
|
||||||
timestampString = "486468325.641074"
|
|
||||||
startingColumnNumber = "9223372036854775807"
|
|
||||||
endingColumnNumber = "9223372036854775807"
|
|
||||||
startingLineNumber = "82"
|
|
||||||
endingLineNumber = "82"
|
|
||||||
offsetFromSymbolStart = "1371">
|
|
||||||
</Location>
|
|
||||||
<Location
|
|
||||||
shouldBeEnabled = "Yes"
|
|
||||||
ignoreCount = "0"
|
|
||||||
continueAfterRunningActions = "No"
|
|
||||||
symbolName = "Vendoo.EtsyRESTAPIManager.(authorizeApp (__ObjC.UIViewController) -> ()).(closure #3)"
|
|
||||||
moduleName = "Vendoo"
|
|
||||||
usesParentBreakpointCondition = "Yes"
|
|
||||||
urlString = "file:///Users/okechi/Documents/iOs%20Practice/Vendoo/Vendoo_bb/Vendoo/Vendoo/EtsyRESTAPIManager.swift"
|
|
||||||
timestampString = "486468325.641241"
|
|
||||||
startingColumnNumber = "9223372036854775807"
|
|
||||||
endingColumnNumber = "9223372036854775807"
|
|
||||||
startingLineNumber = "84"
|
|
||||||
endingLineNumber = "84"
|
|
||||||
offsetFromSymbolStart = "23">
|
|
||||||
</Location>
|
|
||||||
</Locations>
|
|
||||||
</BreakpointContent>
|
|
||||||
</BreakpointProxy>
|
|
||||||
<BreakpointProxy
|
|
||||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
|
||||||
<BreakpointContent
|
|
||||||
shouldBeEnabled = "Yes"
|
|
||||||
ignoreCount = "0"
|
|
||||||
continueAfterRunningActions = "No"
|
|
||||||
filePath = "Vendoo/EtsyRESTAPIManager.swift"
|
|
||||||
timestampString = "486468325.45733"
|
|
||||||
startingColumnNumber = "9223372036854775807"
|
|
||||||
endingColumnNumber = "9223372036854775807"
|
|
||||||
startingLineNumber = "86"
|
|
||||||
endingLineNumber = "86"
|
|
||||||
landmarkName = "authorizeApp(_:)"
|
landmarkName = "authorizeApp(_:)"
|
||||||
landmarkType = "5">
|
landmarkType = "5">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
@ -186,11 +138,43 @@
|
|||||||
ignoreCount = "0"
|
ignoreCount = "0"
|
||||||
continueAfterRunningActions = "No"
|
continueAfterRunningActions = "No"
|
||||||
filePath = "Vendoo/EtsyRESTAPIManager.swift"
|
filePath = "Vendoo/EtsyRESTAPIManager.swift"
|
||||||
timestampString = "486468341.941555"
|
timestampString = "486489480.473889"
|
||||||
startingColumnNumber = "9223372036854775807"
|
startingColumnNumber = "9223372036854775807"
|
||||||
endingColumnNumber = "9223372036854775807"
|
endingColumnNumber = "9223372036854775807"
|
||||||
startingLineNumber = "84"
|
startingLineNumber = "114"
|
||||||
endingLineNumber = "84"
|
endingLineNumber = "114"
|
||||||
|
landmarkName = "authorizeApp(_:)"
|
||||||
|
landmarkType = "5">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
shouldBeEnabled = "Yes"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "Vendoo/EtsyRESTAPIManager.swift"
|
||||||
|
timestampString = "486489493.707548"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "70"
|
||||||
|
endingLineNumber = "70"
|
||||||
|
landmarkName = "authorizeApp(_:)"
|
||||||
|
landmarkType = "5">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
shouldBeEnabled = "Yes"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "Vendoo/EtsyRESTAPIManager.swift"
|
||||||
|
timestampString = "486489552.994372"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "99"
|
||||||
|
endingLineNumber = "99"
|
||||||
landmarkName = "authorizeApp(_:)"
|
landmarkName = "authorizeApp(_:)"
|
||||||
landmarkType = "5">
|
landmarkType = "5">
|
||||||
</BreakpointContent>
|
</BreakpointContent>
|
||||||
|
|||||||
@ -11,24 +11,29 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import SwiftyJSON
|
import SwiftyJSON
|
||||||
import OAuthSwift
|
import OAuthSwift
|
||||||
|
import Locksmith
|
||||||
|
|
||||||
typealias ServiceResponse = (JSON, NSError?) -> Void
|
typealias ServiceResponse = (JSON, NSError?) -> Void
|
||||||
|
|
||||||
|
|
||||||
class EtsyRESTAPIManager: NSObject {
|
class EtsyRESTAPIManager: NSObject {
|
||||||
|
|
||||||
//API Manager class variables
|
//API Manager class variables
|
||||||
//----------------------------------------------//
|
//----------------------------------------------//
|
||||||
static let sharedInstance = EtsyRESTAPIManager()
|
static let sharedInstance = EtsyRESTAPIManager()
|
||||||
|
|
||||||
let baseURL = "https://openapi.etsy.com/v2"
|
let baseURL = "https://openapi.etsy.com/v2/private"
|
||||||
|
|
||||||
private var apiKey: String!
|
private var apiKey: String!
|
||||||
private var apiSecret: String!
|
private var apiSecret: String!
|
||||||
|
private var userEmail:String = (NSUserDefaults.standardUserDefaults().objectForKey("email") as? String)!
|
||||||
var isAuthorized: Bool = NSUserDefaults.standardUserDefaults().boolForKey("etsyAuthorized")
|
var isAuthorized: Bool = NSUserDefaults.standardUserDefaults().boolForKey("etsyAuthorized")
|
||||||
//---------------------------------------------//
|
//---------------------------------------------//
|
||||||
|
|
||||||
//User specific class variables
|
//User specific class variables
|
||||||
private var etsyUser: String!
|
private var etsyUser: String!
|
||||||
|
private var oauth_token: String!
|
||||||
|
private var oauth_secret: String!
|
||||||
//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"])
|
//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(){
|
override init(){
|
||||||
@ -37,6 +42,16 @@ class EtsyRESTAPIManager: NSObject {
|
|||||||
|
|
||||||
self.apiKey = ((dict["Etsy"] as! Dictionary<String, AnyObject>)["consumerKey"] as! String)
|
self.apiKey = ((dict["Etsy"] as! Dictionary<String, AnyObject>)["consumerKey"] as! String)
|
||||||
self.apiSecret = ((dict["Etsy"] as! Dictionary<String, AnyObject>)["consumerSecret"] as! String)
|
self.apiSecret = ((dict["Etsy"] as! Dictionary<String, AnyObject>)["consumerSecret"] as! String)
|
||||||
|
|
||||||
|
if(self.isAuthorized){
|
||||||
|
let dictionary = Locksmith.loadDataForUserAccount(self.userEmail)
|
||||||
|
let oauthDictionary = dictionary?["etsy_oauth"] as? Dictionary<String, AnyObject!>
|
||||||
|
self.oauth_token = oauthDictionary?["token"] as? String!
|
||||||
|
self.oauth_secret = oauthDictionary?["secret"] as? String!
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -52,9 +67,8 @@ extension EtsyRESTAPIManager {
|
|||||||
func authorizeApp(viewcontroller: UIViewController){
|
func authorizeApp(viewcontroller: UIViewController){
|
||||||
|
|
||||||
|
|
||||||
|
if(!isAuthorized){
|
||||||
|
let oauthswift = OAuth1Swift(parameters: ["consumerKey":self.apiKey,"consumerSecret":self.apiSecret, "requestTokenUrl" : "https://openapi.etsy.com/v2/oauth/request_token?scope=listings_w%20listings_r%20listings_d%20transactions_r%20transactions_w",
|
||||||
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",
|
|
||||||
"authorizeUrl": "https://www.etsy.com/oauth/signin?",
|
"authorizeUrl": "https://www.etsy.com/oauth/signin?",
|
||||||
"accessTokenUrl": "https://openapi.etsy.com/v2/oauth/access_token?"])
|
"accessTokenUrl": "https://openapi.etsy.com/v2/oauth/access_token?"])
|
||||||
|
|
||||||
@ -79,14 +93,57 @@ extension EtsyRESTAPIManager {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
dispatch_async(dispatch_get_main_queue(), {() -> Void in
|
||||||
oauthswift!.authorizeWithCallbackURL( NSURL(string: "vendoo://oauth-callback/etsy")!, success: {
|
oauthswift!.authorizeWithCallbackURL( NSURL(string: "vendoo://oauth-callback/etsy")!, success: {
|
||||||
credential, response, parameters in
|
credential, response, parameters in
|
||||||
print(credential.oauth_token)
|
print(credential.oauth_token)
|
||||||
print(credential.oauth_token_secret)
|
print(credential.oauth_token_secret)
|
||||||
print(response)
|
print(response)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}, failure: { error in
|
}, failure: { error in
|
||||||
print(error)
|
print(error)
|
||||||
|
|
||||||
|
dispatch_async(dispatch_get_main_queue(), {() -> Void in
|
||||||
|
print(oauthswift!.client.credential.oauth_token)
|
||||||
|
print(oauthswift!.client.credential.oauth_token_secret)
|
||||||
|
//save data to keychain
|
||||||
|
let creds = oauthswift?.client.credential
|
||||||
|
let oauth: Dictionary<String, AnyObject!>? = [ "token" : creds!.oauth_token, "secret" : creds!.oauth_token_secret ]
|
||||||
|
do{
|
||||||
|
try Locksmith.saveData(["etsy_oauth" : oauth!], forUserAccount: self.userEmail)
|
||||||
|
print("account credentials saved")
|
||||||
|
NSUserDefaults.standardUserDefaults().setBool(true, forKey: "etsyAuthorized")
|
||||||
|
self.isAuthorized = true
|
||||||
|
}
|
||||||
|
catch{
|
||||||
|
(error)
|
||||||
|
print(error)
|
||||||
|
//could not save data to keychain
|
||||||
|
print("account credentials could not be saved")
|
||||||
|
|
||||||
|
}
|
||||||
|
oauthswift!.client.get(self.baseURL,
|
||||||
|
success: {
|
||||||
|
data, response in
|
||||||
|
let dataString = NSString(data: data, encoding: NSUTF8StringEncoding)
|
||||||
|
print(dataString)
|
||||||
|
}
|
||||||
|
, failure: { error in
|
||||||
|
print(error)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -98,6 +155,10 @@ extension EtsyRESTAPIManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func deAuthorizeApp(viewcontroller: UIViewController) -> Bool {
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,6 +56,11 @@
|
|||||||
</array>
|
</array>
|
||||||
<key>LSRequiresIPhoneOS</key>
|
<key>LSRequiresIPhoneOS</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
<key>NSAppTransportSecurity</key>
|
||||||
|
<dict>
|
||||||
|
<key>NSAllowsArbitraryLoads</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
<key>UILaunchStoryboardName</key>
|
<key>UILaunchStoryboardName</key>
|
||||||
<string>LaunchScreen</string>
|
<string>LaunchScreen</string>
|
||||||
<key>UIMainStoryboardFile</key>
|
<key>UIMainStoryboardFile</key>
|
||||||
|
|||||||
@ -396,13 +396,17 @@ extension NetworksTableViewController: UITableViewDelegate {
|
|||||||
|
|
||||||
|
|
||||||
//OAuthorization code for etsy
|
//OAuthorization code for etsy
|
||||||
if(cell.networkToggle.on == true){
|
if(((self.tabBarController as? HomeViewController)?.fbGraphManager.isAuthorized)!){
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), { () -> Void in
|
dispatch_async(dispatch_get_main_queue(), { () -> Void in
|
||||||
cell.networkToggle.setOn(false, animated: true)
|
cell.networkToggle.setOn(false, animated: true)
|
||||||
})
|
})
|
||||||
|
|
||||||
//code to deauthorize network
|
//code to deauthorize network
|
||||||
|
let tabBar = self.tabBarController
|
||||||
|
|
||||||
|
let didSucceed:Bool = ((tabBar as? HomeViewController)?.etsyManager.deAuthorizeApp(self))!
|
||||||
|
cell.networkToggle.on = !didSucceed
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
||||||
@ -433,6 +437,7 @@ extension NetworksTableViewController: UITableViewDelegate {
|
|||||||
//OAuthorization code for facebook
|
//OAuthorization code for facebook
|
||||||
if((self.tabBarController as? HomeViewController)?.fbGraphManager.isAuthorized)!{
|
if((self.tabBarController as? HomeViewController)?.fbGraphManager.isAuthorized)!{
|
||||||
|
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), { () -> Void in
|
dispatch_async(dispatch_get_main_queue(), { () -> Void in
|
||||||
cell.networkToggle.setOn(false, animated: true)
|
cell.networkToggle.setOn(false, animated: true)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -4,6 +4,10 @@
|
|||||||
<dict>
|
<dict>
|
||||||
<key>Etsy</key>
|
<key>Etsy</key>
|
||||||
<dict>
|
<dict>
|
||||||
|
<key>accessToken</key>
|
||||||
|
<string></string>
|
||||||
|
<key>accessSecret</key>
|
||||||
|
<string></string>
|
||||||
<key>consumerKey</key>
|
<key>consumerKey</key>
|
||||||
<string>snbs78qkfy3yqq6yhe6yv49b</string>
|
<string>snbs78qkfy3yqq6yhe6yv49b</string>
|
||||||
<key>consumerSecret</key>
|
<key>consumerSecret</key>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user