IM_Client/api/user/UserOperation.h

49 lines
1.6 KiB
C++

//
// Created by dongl on 23-5-10.
//
#ifndef IM2_USEROPERATION_H
#define IM2_USEROPERATION_H
#include <string>
#include <optional>
#include "event2/bufferevent.h"
#include "core/Client.h"
#include "MP/Request.h"
#include "core/management.h"
#define LOGIN_ACCOUNT mp::MP_LOGIN_ACCOUNT
#define LOGIN_PHONE mp::MP_LOGIN_PHONE
#define LOGIN_EMAIL mp::MP_LOGIN_EMAIL
#define REGISTER_EMAIL mp::MP_SUB_TYPE::MP_REGISTER_EMAIL
#define REGISTER_PHONE mp::MP_SUB_TYPE::MP_REGISTER_PHONE
class UserOperation {
public:
explicit UserOperation(Client* client);
virtual ~UserOperation();
public:
std::optional<agreement_response> login(const std::string& account, const std::string& password);
std::optional<agreement_response> register_(const std::string& account, const std::string& password, const std::string& code);
std::optional<agreement_response> get_code(const std::string& account);
std::optional<agreement_response> FetchFriends(uint64_t account);
private:
std::string packet_base(mp::MP_TYPE, mp::MP_SUB_TYPE, const std::string &account, const std::string &password);
std::string packet_base(mp::MP_TYPE, mp::MP_SUB_TYPE, const std::string &account, const std::string &password, const std::string &data);
std::string packet_base(mp::MP_TYPE type, mp::MP_SUB_TYPE subType, const std::string& account);
std::string login_packet(mp::MP_SUB_TYPE subType, const std::string &account, const std::string &password);
std::string register_packet(mp::MP_SUB_TYPE subType, const std::string &account, const std::string &password, const std::string &code);
private:
Client* client;
};
#endif //IM2_USEROPERATION_H