{"action":"created","issue":{"url":"https://api.github.com/repos/Matt-Zhang/SixDegreeCoffee-Backend/issues/1","labels_url":"https://api.github.com/repos/Matt-Zhang/SixDegreeCoffee-Backend/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/Matt-Zhang/SixDegreeCoffee-Backend/issues/1/comments","events_url":"https://api.github.com/repos/Matt-Zhang/SixDegreeCoffee-Backend/issues/1/events","html_url":"https://github.com/Matt-Zhang/SixDegreeCoffee-Backend/issues/1","id":70432181,"number":1,"title":"APIs","user":{"login":"Matt-Zhang","id":3301926,"avatar_url":"https://avatars.githubusercontent.com/u/3301926?v=3","gravatar_id":"","url":"https://api.github.com/users/Matt-Zhang","html_url":"https://github.com/Matt-Zhang","followers_url":"https://api.github.com/users/Matt-Zhang/followers","following_url":"https://api.github.com/users/Matt-Zhang/following{/other_user}","gists_url":"https://api.github.com/users/Matt-Zhang/gists{/gist_id}","starred_url":"https://api.github.com/users/Matt-Zhang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Matt-Zhang/subscriptions","organizations_url":"https://api.github.com/users/Matt-Zhang/orgs","repos_url":"https://api.github.com/users/Matt-Zhang/repos","events_url":"https://api.github.com/users/Matt-Zhang/events{/privacy}","received_events_url":"https://api.github.com/users/Matt-Zhang/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-04-23T14:53:19Z","updated_at":"2015-04-27T23:07:20Z","closed_at":null,"body":"Not being aware how many code you have wrote, I paste my temporary APIs. The first part is to get instances from json which you generate in each as_json(). The second part is the router, and of course, we still need many other routers. If you have any problem, please tell me.\r\n\r\nPlease pass all argument in String way, i.e. please transforms int to string.\r\n\r\nI'm sorry to hope you write success in every message. It's stupid. If error happens, please add {\"error\": \"detail reason\"} to the return. Otherwise write nothing. I'm so sorry.\r\n\r\n### This is the Meeting class\r\n\r\n`\r\n\r\n    @objc required init(representation: AnyObject) {\r\n        let r: AnyObject = representation.valueForKeyPath(\"meeting\")!\r\n        self.organizer = User(representation: r.valueForKeyPath(\"organizer\")!)\r\n        self.mid = r.valueForKeyPath(\"mid\") as! String\r\n        self.title = r.valueForKeyPath(\"title\") as! String\r\n        \r\n        self.participatedPeople = []\r\n        let participatedPeople = r.valueForKeyPath(\"participated_people\") as! [AnyObject?]\r\n        for people in participatedPeople {\r\n            self.participatedPeople.append(User(representation: people!))\r\n        }\r\n        \r\n        self.relation = r.valueForKeyPath(\"relation\") as! String\r\n        self.nr_people = (r.valueForKeyPath(\"nr_people\") as! String).toInt()!\r\n        self.nr_supposedPeople = (r.valueForKeyPath(\"nr_supposedPeople\") as! String).toInt()!\r\n        self.nr_viewed = (r.valueForKeyPath(\"nr_viewed\") as! String).toInt()!\r\n        self.nr_discussion = (r.valueForKeyPath(\"nr_discussion\") as! String).toInt()!\r\n        self.note = r.valueForKeyPath(\"note\") as! String\r\n        self.time = NSDate(timeIntervalSince1970: (r.valueForKeyPath(\"time\") as! NSString).doubleValue)\r\n        self.place = r.valueForKeyPath(\"place\") as! String\r\n        self.type = MeetingType(rawValue: (r.valueForKeyPath(\"type\") as! String).toInt()!)!\r\n      }`\r\n\r\n\r\n###This is the User class:\r\n\r\n`\r\n\r\n    required init(representation r: AnyObject) {\r\n        \r\n        self.uid = r.valueForKeyPath(\"uid\") as! String\r\n        self.avatar = r.valueForKeyPath(\"avatar\") as! String\r\n        self.username = r.valueForKeyPath(\"username\") as! String\r\n        self.phone = r.valueForKeyPath(\"phone\") as? String\r\n        \r\n        self.title = r.valueForKeyPath(\"title\") as? String\r\n        self.university = r.valueForKeyPath(\"university\") as? String\r\n        self.major = r.valueForKeyPath(\"major\") as? String\r\n        self.note = r.valueForKeyPath(\"note\") as? String\r\n        self.age = r.valueForKeyPath(\"age\") as? String\r\n        self.nr_friends = r.valueForKeyPath(\"nr_friends\") as? Int\r\n        self.sex = Sex(rawValue: (r.valueForKeyPath(\"sex\") as! String).toInt()!)\r\n        self.location = r.valueForKeyPath(\"photo.description\") as? String\r\n    }`\r\n\r\n\r\n###This is the Discussion class: \r\n\r\n`\r\n\r\n    required init(representation: AnyObject) {\r\n        var r: AnyObject = representation.valueForKeyPath(\"discussion\")!\r\n        \r\n        self.mid = r.valueForKeyPath(\"mid\") as! String\r\n        self.discussionID = r.valueForKeyPath(\"discussionID\") as! String\r\n        self.sender = User(representation: r.valueForKeyPath(\"sender\")!)\r\n        if ((r.valueForKeyPath(\"replied_user\")) != nil) {\r\n            self.repliedUser = User(representation: r.valueForKeyPath(\"replied_user\")!)\r\n        }\r\n        self.message = r.valueForKeyPath(\"message\") as! String\r\n        self.time = NSDate(timeIntervalSince1970: (r.valueForKeyPath(\"time\") as! NSString).doubleValue)\r\n    }`\r\n\r\n\r\n\r\n\r\n### **After these, I have also write some APIs. You only need to read CASE part, the parameters are arguments of the url requests.**\r\n\r\n`\r\n\r\n    func get() -> Request {\r\n        setAuthHeader()\r\n        let (path: String, parameters: [String: AnyObject]?) = {\r\n            switch self.route {\r\n            case .Token:\r\n                return (\"/user/token\", nil)\r\n            // Return User.as_json to instance a user\r\n            case .GetProfile(let id):\r\n                return (\"/user/getProfile/\" + id, nil)\r\n            \r\n            case .GetAvatar(let picPath):\r\n                return (\"/user/getAvatar\" + picPath, nil)\r\n                \r\n            case .GetPublicMeetings(let begin, let end):\r\n                return (\"/meeting/publicMeeting\", [\"begin\": \"\\(begin)\", \"end\": \"\\(end)\"])\r\n                \r\n            case .GetPrivateMeetings(let begin, let end):\r\n                return (\"/meeting/privateMeeting\", [\"begin\": \"\\(begin)\", \"end\": \"\\(end)\"])\r\n                \r\n            case .GetParticipatedMeetings(let begin, let end):\r\n                return (\"/meeting/publicMeeting\", [\"begin\": \"\\(begin)\", \"end\": \"\\(end)\"])\r\n                \r\n            case .GetMyOrganizedMeeting():\r\n                return (\"/meeting/organizedMeeting\", nil)\r\n                \r\n            case .GetInvitingMeeting():\r\n                return (\"/meeting/invitedMeeting\", nil)\r\n                \r\n            case .GetDiscussions(let mid, let begin, let end):\r\n                return (\"/discussion/\" + mid, [\"begin\": begin, \"end\": end])\r\n                \r\n            case .GetFirstDegreeFriends():\r\n                return (\"/friend/firstDegree\", nil)\r\n                \r\n                \r\n                \r\n                default:\r\n                    assert(false, \"wrong router\")\r\n                }\r\n            }()\r\n        return Alamofire.request(.GET,\r\n            URLString: Router.baseURLString + path,\r\n            parameters: parameters,\r\n            encoding: .URL)\r\n    }\r\n    \r\n    func post() -> Request {\r\n        setAuthHeader()\r\n        let (path: String, parameters: [String: AnyObject]?) = {\r\n            switch self.route {\r\n            case .Hello:\r\n                return (\"/hello\", nil)\r\n            // Send user.as_json, return succeed or not\r\n            case .UpdateProfile(let userProfile):\r\n                return (\"/user/updateProfile\", userProfile)\r\n            \r\n            case .PublishMeeting(let meeting):\r\n                return (\"/meeting/publish\", [\"meeting\": meeting.as_json()])\r\n            \r\n            case .ApplyForMeeting(let mid):\r\n                return (\"/meeting/applyForMeeting\",[\"mid\": mid])\r\n            \r\n            case .AgreeToParticipateInvitedMeeting(let mid):\r\n                return (\"/meeting/agreeToParticipateInvitedMeeting\",[\"mid\": mid])\r\n                \r\n            case .AgreeOthersToParticipateMeeting(let mid, let uid):\r\n                return (\"/meeting/agreeOthersToParticipateMeeting\",[\"mid\": mid, \"uid\": uid])\r\n                \r\n                \r\n            case .InviteOthersToMeeting(let mid, let uid):\r\n                return (\"/meeting/inviteOthersTopMeeting\",[\"mid\": mid, \"uid\": uid])\r\n                \r\n            case .CreateDiscussion(let mid, let discussion):\r\n                return (\"/discussion/make\", [\"mid\": mid, \"discussion\": discussion.as_json()])\r\n            \r\n            case .AddFriend(let uid):\r\n                return (\"/friend/add/\\(uid)\", nil)\r\n                \r\n            default:\r\n                assert(false, \"wrong route!\")\r\n                }\r\n            }()\r\n        return Alamofire.request(.POST,\r\n            URLString: Router.baseURLString + path,\r\n            parameters: parameters,\r\n            encoding: .JSON)\r\n    }`"},"comment":{"url":"https://api.github.com/repos/Matt-Zhang/SixDegreeCoffee-Backend/issues/comments/96845829","html_url":"https://github.com/Matt-Zhang/SixDegreeCoffee-Backend/issues/1#issuecomment-96845829","issue_url":"https://api.github.com/repos/Matt-Zhang/SixDegreeCoffee-Backend/issues/1","id":96845829,"user":{"login":"dwt136","id":3500914,"avatar_url":"https://avatars.githubusercontent.com/u/3500914?v=3","gravatar_id":"","url":"https://api.github.com/users/dwt136","html_url":"https://github.com/dwt136","followers_url":"https://api.github.com/users/dwt136/followers","following_url":"https://api.github.com/users/dwt136/following{/other_user}","gists_url":"https://api.github.com/users/dwt136/gists{/gist_id}","starred_url":"https://api.github.com/users/dwt136/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwt136/subscriptions","organizations_url":"https://api.github.com/users/dwt136/orgs","repos_url":"https://api.github.com/users/dwt136/repos","events_url":"https://api.github.com/users/dwt136/events{/privacy}","received_events_url":"https://api.github.com/users/dwt136/received_events","type":"User","site_admin":false},"created_at":"2015-04-27T23:07:20Z","updated_at":"2015-04-27T23:07:20Z","body":"what value should this field be set if it was a public meeting and the current user wasn't a friend(neither 1st nor 2nd dgr) of the organiser?"}}