login.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00027 #ifndef ASTXX_MANAGER_ACTION_LOGIN_H
00028 #define ASTXX_MANAGER_ACTION_LOGIN_H
00029
00030 #include <astxx/manager/basic_action.h>
00031 #include <astxx/manager/message.h>
00032 #include <astxx/manager/error.h>
00033
00034 namespace astxx {
00035 namespace manager {
00036 namespace action {
00040 class login : public basic_action {
00041 public:
00043 class error : public manager::error {
00044 public:
00045 explicit error(const std::string& desc) throw() : manager::error(desc) { }
00046 };
00047
00048 public:
00053 login(const std::string& username, const std::string& secret) : username(username), secret(secret) {
00054 }
00055
00059 message::action action() const {
00060 message::action action("Login");
00061 action["Username"] = username;
00062 action["Secret"] = secret;
00063 return action;
00064 }
00065
00070 message::response handle_response(message::response response) {
00071 basic_action::handle_response(response);
00072
00073 if ("Success" != response) {
00074 throw login::error(response["Message"]);
00075 }
00076
00077 return response;
00078 }
00079
00080 private:
00081 std::string username;
00082 std::string secret;
00083 };
00084 }
00085 }
00086 }
00087
00088 #endif