Advertisement
Guest User

Untitled

a guest
Aug 26th, 2015
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. private func login() {
  2. let url = "/user/login/hubnami"
  3. Alamofire.request(.POST, baseURL + url, parameters: ["email": self.email, "password": self.password!, "csrf_test_name": self.token], encoding: ParameterEncoding.URL, headers: nil).responseJSON { (_, _, jsonResponse, _) -> Void in
  4. var json = JSON(jsonResponse!)
  5. if json != nil {
  6. println(json)
  7. if json["status"] == "success" {
  8. println("LOGIN: Success!.")
  9. self.isLogin = true
  10. } else if json["status"] == "failed" {
  11. println("LOGIN: Failed!.")
  12. }
  13. } else {
  14. println(json)
  15. }
  16. }
  17. }
  18.  
  19. var user = HKUser(email: "phuonglm86@gmail.com", password: "123456")
  20. user.login()
  21.  
  22. {
  23. "status" : "success",
  24. "data" : {
  25. "redirect_url" : false,
  26. "info" : {
  27. "language" : "en_US",
  28. "userLoggedIn" : "1",
  29. "networkKeys" : {
  30. "google" : "AIzaSyALVLyEVwIhhfEH5SN65-UVMLlOS5YWRJI",
  31. "facebook" : "CAAFVXuEkiCcBAEWYixhrKVJstmmDlvJQRNizaTguniPfm7FI3SkimwjjZAyKiQQJZBKeSG7yi3k3imBeEuXL2x5F7xlz8qoazoWWbpobtmmFEhYOBZBNC5FIVcKRxB0f4uJTNMYJAU8HQeAP2ydb3K31ENrwXMbbgggZCwAXZB4sjR4YmgBZATvS4U9pBXeSl0nMZBXXZCOc3ZCZBh8W365r3q",
  32. "vimeo" : "298b04d74270272cb305811626209408",
  33. "instagram" : "da5dadde525841569a0fe79ed5e489a4",
  34. "bitly" : "14a6d5f0d13e4159f51a5054bdbdaf52fad6a14b"
  35. },
  36. "timezone_offset" : 25200,
  37. "accountCreatedTime" : 1439338073,
  38. "scope" : "client",
  39. "userId" : "2466",
  40. "accountId" : "4270",
  41. "userName" : "Phuong",
  42. "accountName" : "Phuong",
  43. "userEmail" : "phuonglm86@gmail.com",
  44. "userPicture" : "https://graph.facebook.com/v2.3/944873948889162/picture",
  45. "timezone" : "Asia/Jakarta",
  46. "role" : "admin",
  47. "startTime" : "2015-07-28",
  48. "endTime" : "2015-08-26",
  49. "memberSince" : 1439338073
  50. }
  51. }
  52. }
  53.  
  54. func getAllUserDashboards() {
  55. let url = "/profile/get_tags_all"
  56. Alamofire.request(.GET, baseURL + url, parameters: nil, encoding: .URL, headers: nil).responseJSON { (_, _, jsonData, _) -> Void in
  57. if jsonData != nil {
  58. println("Get All Dashboards: Success!")
  59. self.dashboards = JSON(jsonData!)
  60. println(jsonData!)
  61. } else {
  62. println("Get All Dashboards: Failed!")
  63. }
  64. }
  65. }
  66.  
  67. func creatNewDashboard(nameDashboard: String) {
  68. let url = "/account/create_dashboard"
  69. Alamofire.request(.GET, baseURL + url, parameters: ["tag_name": nameDashboard], encoding: .URL, headers: nil).responseJSON() { (request, response, jsonData, _) -> Void in
  70. if jsonData != nil {
  71. println("Create Dashboard: Success!")
  72. println("Create Dashboard (jsonData!)")
  73. } else {
  74. println("Create Dashboard: Failed!")
  75. }
  76. }
  77. }
  78.  
  79. user.getAllUserDashboards()
  80.  
  81. user.creatNewDashboard("new_Dashboard")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement