iberbox  2.1.2
account.h
Go to the documentation of this file.
1 
10 #ifndef ACCOUNT_H
11 #define ACCOUNT_H
12 
13 #include "iberbox/config.h"
14 #include "iberbox/payments.h"
15 #include "iberbox/user.h"
16 
17 #ifdef EMSCRIPTEN
18 typedef std::string AccountHandle;
19 typedef std::string PermissionHandle;
20 #else
21 typedef uint64_t AccountHandle;
22 typedef uint64_t PermissionHandle;
23 #endif
24 
25 #include "iberbox/node.h"
26 
27 #ifdef USE_SCAPIX
28 #include <scapix/bridge/object.h>
29 #endif
30 
31 #include <inttypes.h>
32 #include <memory>
33 #include <vector>
34 #include <string>
35 
36 namespace iberbox {
37 
42 #ifdef USE_SCAPIX
43  : public scapix::bridge::object<AccountInfoData>
44 #endif
45 {
46 public:
48  {
49  RW_ACCESS = 0,
50  RO_ACCESS = 1,
51  };
59  virtual ~AccountInfoData();
60 
65  uint64_t getId() const;
70  const AccountHandle& getHandle() const;
75  const std::string& getStringHandle() const;
80  int getType() const;
86  std::string getName() const;
91  uint64_t getCreationTime() const;
96  uint64_t getTotalStorage() const;
101  uint64_t getUsedStorage() const;
106  uint64_t getRenewTime() const;
113  int getPeriod() const;
118  int getAmount() const;
123  int getDiscount() const;
129  int getTotal() const;
136  bool hasCredit() const;
142  bool hasPaymentMethod() const;
147  std::string getPlan() const;
152  std::string getNIF() const;
157  uint64_t getStatusId() const;
162  std::string getReferrerCode() const;
167  int getBalance() const;
172  int getUpgrades() const;
179  bool isReseller() const;
184  uint32_t getFeatures() const;
185 
189  unsigned getCrypto() const;
190  uint8_t getAccessLevel() const;
191 
192  static const uint64_t INVALID_ID;
194 
195 protected:
196  uint64_t mId;
197  std::string mHandle;
198  int mType;
199  std::string mName;
200  uint64_t mCreationTime;
201  uint64_t mTotalStorage;
202  uint64_t mUsedStorage;
203  uint64_t mRenewTime;
204  int mPeriod;
205  int mAmount;
206  int mDiscount;
207  int mHasCredit;
208  int mHasPaymentMethod;
209  std::string mPlan;
210  std::string mNif;
211  uint64_t mStatusId;
212  std::string mReferrerCode;
213  int mBalance;
214  int mUpgrades;
215  bool mIsReseller;
216  uint32_t mFeatures;
217  uint8_t mCrypto;
218  uint8_t mAccessLevel;
219 };
220 
221 typedef std::shared_ptr<AccountInfoData> AccountInfo;
222 
223 
225 typedef std::shared_ptr<SessionInfoData> SessionInfo;
226 typedef std::vector<SessionInfo> SessionInfoDataList;
227 typedef std::shared_ptr<SessionInfoDataList> SessionInfoList;
228 
230 #ifdef USE_SCAPIX
231  : public scapix::bridge::object<SessionInfoData>
232 #endif
233 {
234 public:
235  SessionInfoData();
236  virtual ~SessionInfoData();
237 
238  uint64_t getId() const;
239  std::string getHandle() const;
240  uint64_t getCreationTime() const;
241  uint64_t getLastTime() const;
242  std::string getIP() const;
243  std::string getUserAgent() const;
244  bool isActive() const;
245 
246 protected:
247  uint64_t mId;
248  std::string mHandle;
249  uint64_t mCreationTime;
250  uint64_t mLastTime;
251  std::string mIP;
252  std::string mUserAgent;
253  int mActive;
254 };
255 
257 #ifdef USE_SCAPIX
258  : public scapix::bridge::object<BalanceInfoData>
259 #endif
260 {
261  public:
262  BalanceInfoData();
263  virtual ~BalanceInfoData();
264 
265  enum BalanceType {
266  NONE = 0,
267  REFERRAL = 1,
268  INVOICE = 2,
269  COUPON = 3,
270  };
271 
272  int32_t getId() const;
273  int64_t getCreationTime() const;
274  int32_t getType() const;
275  std::string getSubject() const;
276  int32_t getAmount() const;
277 
278  protected:
279  int32_t mId;
280  int64_t mCreationTime;
281  int32_t mType;
282  std::string mSubject;
283  int32_t mAmount;
284 };
285 typedef std::shared_ptr<BalanceInfoData> BalanceInfo;
286 typedef std::vector<BalanceInfo> BalanceInfoDataList;
287 typedef std::shared_ptr<BalanceInfoDataList> BalanceInfoList;
288 
290 #ifdef USE_SCAPIX
291  : public scapix::bridge::object<BalancesInfoData>
292 #endif
293 {
294  public:
296  virtual ~BalancesInfoData();
297 
298  int32_t getTotal() const;
299  BalanceInfoList getBalances() const;
300  protected:
301  int32_t mTotal;
302  BalanceInfoList mBalances;
303 
304 };
305 typedef std::shared_ptr<BalancesInfoData> BalancesInfo;
306 
308 #ifdef USE_SCAPIX
309  : public scapix::bridge::object<CouponInfoData>
310 #endif
311 {
312  public:
313  CouponInfoData();
314  virtual ~CouponInfoData();
315 
316  enum CouponType {
317  NONE = 0,
318  RESELLER = 1,
319  SPECIAL_PLAN = 2,
320  DISCOUNT = 3
321  };
322 
323  int32_t getId() const;
324  std::string getCode() const;
325  int32_t getType() const;
326  std::string getEmail() const;
327  int64_t getCreationTime() const;
328  int64_t getUsedTime() const;
329 
330  protected:
331  int32_t mId;
332  std::string mCode;
333  int32_t mType;
334  std::string mEmail;
335  int64_t mCreationTime;
336  int64_t mUsedTime;
337 };
338 typedef std::shared_ptr<CouponInfoData> CouponInfo;
339 typedef std::vector<CouponInfo> CouponInfoDataList;
340 typedef std::shared_ptr<CouponInfoDataList> CouponInfoList;
341 
343 #ifdef USE_SCAPIX
344  : public scapix::bridge::object<PermissionInfoData>
345 #endif
346 {
347  public:
349  virtual ~PermissionInfoData();
350 
351  uint64_t getId() const;
352  const PermissionHandle &getHandle() const;
353  std::string getName() const;
354  int64_t getCreationTime() const;
355  int32_t getAccessLevel() const;
356 
357  protected:
358  uint64_t mId;
359  std::string mHandle;
360  std::string mName;
361  int64_t mCreationTime;
362  int32_t mAccessLevel;
363 };
364 typedef std::shared_ptr<PermissionInfoData> PermissionInfo;
365 typedef std::vector<PermissionInfo> PermissionInfoDataList;
366 typedef std::shared_ptr<PermissionInfoDataList> PermissionInfoList;
367 
369 #ifdef USE_SCAPIX
370  : public scapix::bridge::object<CommandLogData>
371 #endif
372 {
373  public:
374  CommandLogData();
375  virtual ~CommandLogData();
376 
377  std::string getCommand() const;
378  uint64_t getId() const;
379  NodeHandle getHandle() const;
380  uint64_t getParentId() const;
381  NodeHandle getParentHandle() const;
382  std::string getIp() const;
383  std::string getUserAgent() const;
384  int64_t getCreationTime() const;
385  UserHandle getUserHandle() const;
386  Node getNode() const;
387 
388  protected:
389  std::string mCommand;
390  Node mNode;
391  std::string mIp;
392  std::string mUserAgent;
393  uint64_t mUserId;
394  uint64_t mId;
395  uint64_t mParentId;
396  int64_t mCreationTime;
397 };
398 typedef std::shared_ptr<CommandLogData> CommandLog;
399 typedef std::vector<CommandLog> CommandLogDataList;
400 typedef std::shared_ptr<CommandLogDataList> CommandLogList;
401 
402 }
403 
404 #endif // ACCOUNT_H
std::shared_ptr< CouponInfoDataList > CouponInfoList
Definition: account.h:340
bool hasCredit() const
Gets whether the account has credit or not.
uint8_t getAccessLevel() const
std::shared_ptr< BalancesInfoData > BalancesInfo
Definition: account.h:305
uint64_t getCreationTime() const
Gets the time when the account was created.
static const uint64_t INVALID_ID
Definition: account.h:192
virtual ~AccountInfoData()
Destroys the Account Info Data object.
CouponType
Definition: account.h:316
std::vector< BalanceInfo > BalanceInfoDataList
Definition: account.h:286
uint64_t getRenewTime() const
Gets the time when the account should be renewed.
uint64_t getStatusId() const
Gets the status identifier of the account.
std::shared_ptr< CommandLogDataList > CommandLogList
Definition: account.h:400
std::vector< CouponInfo > CouponInfoDataList
Definition: account.h:339
The iberbox namespace.
Definition: task.h:21
std::vector< CommandLog > CommandLogDataList
Definition: account.h:399
bool isReseller() const
Gets whether the account corresponds to a reseller or not.
int getUpgrades() const
Gets the upgrades of the account.
std::string getPlan() const
Gets the plan name.
std::string getName() const
Gets the name of the account holder.
std::shared_ptr< SessionInfoData > SessionInfo
Definition: account.h:224
Definition: account.h:307
int getTotal() const
Gets the total price of the subscription for the current period.
uint64_t NodeHandle
Definition: node.h:26
unsigned getCrypto() const
Gets the default cryto scheme.
std::shared_ptr< AccountInfoData > AccountInfo
Definition: account.h:221
uint64_t AccountHandle
Definition: node.h:27
std::shared_ptr< NodeData > Node
Definition: node.h:666
uint64_t PermissionHandle
Definition: account.h:22
std::shared_ptr< CommandLogData > CommandLog
Definition: account.h:398
uint64_t AccountHandle
Definition: account.h:21
Definition: account.h:289
Definition: account.h:342
std::shared_ptr< PermissionInfoDataList > PermissionInfoList
Definition: account.h:366
Definition: account.h:229
AccountInfoData()
Constructs a new Account Info Data object.
AccessLevel
Definition: account.h:47
uint64_t getTotalStorage() const
Gets the total storage of the account.
uint64_t getId() const
Gets the identifier of the account.
std::shared_ptr< PermissionInfoData > PermissionInfo
Definition: account.h:364
Definition: account.h:256
int getBalance() const
Gets the balance of the account.
std::shared_ptr< CouponInfoData > CouponInfo
Definition: account.h:338
BalanceType
Definition: account.h:265
std::shared_ptr< SessionInfoDataList > SessionInfoList
Definition: account.h:227
int getType() const
Gets the type of the account.
int getPeriod() const
Gets the period of the account subscription.
std::shared_ptr< BalanceInfoDataList > BalanceInfoList
Definition: account.h:287
std::string getReferrerCode() const
Gets the referrer code.
int getAmount() const
Gets the fee of the subscription for the current period.
std::string getNIF() const
Gets the NIF of the account.
const AccountHandle & getHandle() const
Gets the handle of the account.
The Account Info Data class.
Definition: account.h:41
static const AccountHandle INVALID_HANDLE
Definition: account.h:193
const std::string & getStringHandle() const
Gets the string handle of the account.
std::vector< PermissionInfo > PermissionInfoDataList
Definition: account.h:365
std::shared_ptr< BalanceInfoData > BalanceInfo
Definition: account.h:285
std::vector< SessionInfo > SessionInfoDataList
Definition: account.h:226
Definition: account.h:368
UserId UserHandle
Definition: user.h:34
int getDiscount() const
Gets the discount price over the fee of the subscription for the current period.
uint32_t getFeatures() const
Gets account features bitmap.
bool hasPaymentMethod() const
Checks if the account has set up a payment method.
Definition: account.h:49
Definition: account.h:50
uint64_t getUsedStorage() const
Gets the used storage of the account.