Created
January 19, 2016 02:35
-
-
Save tranhieutt/6d2b445d2ec78273e3a7 to your computer and use it in GitHub Desktop.
Zilyo_API_Search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Alamofire | |
public class ServiceManager { | |
class var sharedInstance: ServiceManager { | |
struct Static { | |
static var onceToken: dispatch_once_t = 0 | |
static var instance: ServiceManager? = nil | |
} | |
dispatch_once(&Static.onceToken) { | |
Static.instance = ServiceManager() | |
} | |
return Static.instance! | |
} | |
public func getInformationOfItemVia(barCodeString: String, completion: ((list : NSDictionary!) -> Void)?) { | |
//--- block code. | |
let manager = Alamofire.Manager.sharedInstance | |
let headers = ["Accept": "application/json","X-Mashape-Key": "tKxQHTDGAbmsh3dKmcUkZOz0utf1p1ZyJ4OjsnDxjp0ybJQGxP"] | |
let params = ["latitude" : 21.027764,"longitude":105.834160] as Dictionary<String, AnyObject> | |
manager.request(.GET, "https://zilyo.p.mashape.com/search",parameters: params, headers: headers).responseJSON { response in | |
let json = JSON(data: response.data!); | |
print(json) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment