iberbox  2.1.0
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 
16 #ifdef EMSCRIPTEN
17 typedef std::string AccountHandle;
18 typedef std::string PermissionHandle;
19 #else
20 typedef uint64_t AccountHandle;
21 typedef uint64_t PermissionHandle;
22 #endif
23 
24 #ifdef USE_SCAPIX
25 #include <scapix/bridge/object.h>
26 #endif
27 
28 #include <inttypes.h>
29 #include <memory>
30 #include <vector>
31 #include <string>
32 
33 namespace iberbox {
34 
39 #ifdef USE_SCAPIX
40  : public scapix::bridge::object<AccountInfoData>
41 #endif
42 {
43 public:
45  {
46  RW_ACCESS = 0,
47  RO_ACCESS = 1,
48  };
56  virtual ~AccountInfoData();
57 
62  uint64_t getId() const;
67  const AccountHandle& getHandle() const;
72  const std::string& getStringHandle() const;
77  int getType() const;
83  std::string getName() const;
88  uint64_t getCreationTime() const;
93  uint64_t getTotalStorage() const;
98  uint64_t getUsedStorage() const;
103  uint64_t getRenewTime() const;
110  int getPeriod() const;
115  int getAmount() const;
120  int getDiscount() const;
126  int getTotal() const;
133  bool hasCredit() const;
139  bool hasPaymentMethod() const;
144  std::string getPlan() const;
149  std::string getNIF() const;
154  uint64_t getStatusId() const;
159  std::string getReferrerCode() const;
164  int getBalance() const;
169  int getUpgrades() const;
176  bool isReseller() const;
181  uint32_t getFeatures() const;
182 
186  unsigned getCrypto() const;
187  uint8_t getAccessLevel() const;
188 
189  static const uint64_t INVALID_ID;
191 
192 protected:
193  uint64_t mId;
194  std::string mHandle;
195  int mType;
196  std::string mName;
197  uint64_t mCreationTime;
198  uint64_t mTotalStorage;
199  uint64_t mUsedStorage;
200  uint64_t mRenewTime;
201  int mPeriod;
202  int mAmount;
203  int mDiscount;
204  int mHasCredit;
205  int mHasPaymentMethod;
206  std::string mPlan;
207  std::string mNif;
208  uint64_t mStatusId;
209  std::string mReferrerCode;
210  int mBalance;
211  int mUpgrades;
212  bool mIsReseller;
213  uint32_t mFeatures;
214  uint8_t mCrypto;
215  uint8_t mAccessLevel;
216 };
217 
218 typedef std::shared_ptr<AccountInfoData> AccountInfo;
219 
220 
222 typedef std::shared_ptr<SessionInfoData> SessionInfo;
223 typedef std::vector<SessionInfo> SessionInfoDataList;
224 typedef std::shared_ptr<SessionInfoDataList> SessionInfoList;
225 
227 #ifdef USE_SCAPIX
228  : public scapix::bridge::object<SessionInfoData>
229 #endif
230 {
231 public:
232  SessionInfoData();
233  virtual ~SessionInfoData();
234 
235  uint64_t getId() const;
236  std::string getHandle() const;
237  uint64_t getCreationTime() const;
238  uint64_t getLastTime() const;
239  std::string getIP() const;
240  std::string getUserAgent() const;
241  bool isActive() const;
242 
243 protected:
244  uint64_t mId;
245  std::string mHandle;
246  uint64_t mCreationTime;
247  uint64_t mLastTime;
248  std::string mIP;
249  std::string mUserAgent;
250  int mActive;
251 };
252 
254 #ifdef USE_SCAPIX
255  : public scapix::bridge::object<BalanceInfoData>
256 #endif
257 {
258  public:
259  BalanceInfoData();
260  virtual ~BalanceInfoData();
261 
262  enum BalanceType {
263  NONE = 0,
264  REFERRAL = 1,
265  INVOICE = 2,
266  COUPON = 3,
267  };
268 
269  int32_t getId() const;
270  int64_t getCreationTime() const;
271  int32_t getType() const;
272  std::string getSubject() const;
273  int32_t getAmount() const;
274 
275  protected:
276  int32_t mId;
277  int64_t mCreationTime;
278  int32_t mType;
279  std::string mSubject;
280  int32_t mAmount;
281 };
282 typedef std::shared_ptr<BalanceInfoData> BalanceInfo;
283 typedef std::vector<BalanceInfo> BalanceInfoDataList;
284 typedef std::shared_ptr<BalanceInfoDataList> BalanceInfoList;
285 
287 #ifdef USE_SCAPIX
288  : public scapix::bridge::object<BalancesInfoData>
289 #endif
290 {
291  public:
293  virtual ~BalancesInfoData();
294 
295  int32_t getTotal() const;
296  BalanceInfoList getBalances() const;
297  protected:
298  int32_t mTotal;
299  BalanceInfoList mBalances;
300 
301 };
302 typedef std::shared_ptr<BalancesInfoData> BalancesInfo;
303 
305 #ifdef USE_SCAPIX
306  : public scapix::bridge::object<CouponInfoData>
307 #endif
308 {
309  public:
310  CouponInfoData();
311  virtual ~CouponInfoData();
312 
313  enum CouponType {
314  NONE = 0,
315  RESELLER = 1,
316  SPECIAL_PLAN = 2,
317  DISCOUNT = 3
318  };
319 
320  int32_t getId() const;
321  std::string getCode() const;
322  int32_t getType() const;
323  std::string getEmail() const;
324  int64_t getCreationTime() const;
325  int64_t getUsedTime() const;
326 
327  protected:
328  int32_t mId;
329  std::string mCode;
330  int32_t mType;
331  std::string mEmail;
332  int64_t mCreationTime;
333  int64_t mUsedTime;
334 };
335 typedef std::shared_ptr<CouponInfoData> CouponInfo;
336 typedef std::vector<CouponInfo> CouponInfoDataList;
337 typedef std::shared_ptr<CouponInfoDataList> CouponInfoList;
338 
340 #ifdef USE_SCAPIX
341  : public scapix::bridge::object<PermissionInfoData>
342 #endif
343 {
344  public:
346  virtual ~PermissionInfoData();
347 
348  uint64_t getId() const;
349  const PermissionHandle &getHandle() const;
350  std::string getName() const;
351  int64_t getCreationTime() const;
352  int32_t getAccessLevel() const;
353 
354  protected:
355  uint64_t mId;
356  std::string mHandle;
357  std::string mName;
358  int64_t mCreationTime;
359  int32_t mAccessLevel;
360 };
361 typedef std::shared_ptr<PermissionInfoData> PermissionInfo;
362 typedef std::vector<PermissionInfo> PermissionInfoDataList;
363 typedef std::shared_ptr<PermissionInfoDataList> PermissionInfoList;
364 
365 }
366 
367 #endif // ACCOUNT_H
std::shared_ptr< CouponInfoDataList > CouponInfoList
Definition: account.h:337
bool hasCredit() const
Gets whether the account has credit or not.
uint8_t getAccessLevel() const
std::shared_ptr< BalancesInfoData > BalancesInfo
Definition: account.h:302
uint64_t getCreationTime() const
Gets the time when the account was created.
static const uint64_t INVALID_ID
Definition: account.h:189
virtual ~AccountInfoData()
Destroys the Account Info Data object.
CouponType
Definition: account.h:313
std::vector< BalanceInfo > BalanceInfoDataList
Definition: account.h:283
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::vector< CouponInfo > CouponInfoDataList
Definition: account.h:336
The iberbox namespace.
Definition: task.h:21
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:221
Definition: account.h:304
int getTotal() const
Gets the total price of the subscription for the current period.
unsigned getCrypto() const
Gets the default cryto scheme.
std::shared_ptr< AccountInfoData > AccountInfo
Definition: account.h:218
uint64_t PermissionHandle
Definition: account.h:21
uint64_t AccountHandle
Definition: account.h:20
Definition: account.h:286
Definition: account.h:339
std::shared_ptr< PermissionInfoDataList > PermissionInfoList
Definition: account.h:363
Definition: account.h:226
AccountInfoData()
Constructs a new Account Info Data object.
AccessLevel
Definition: account.h:44
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:361
Definition: account.h:253
int getBalance() const
Gets the balance of the account.
std::shared_ptr< CouponInfoData > CouponInfo
Definition: account.h:335
BalanceType
Definition: account.h:262
std::shared_ptr< SessionInfoDataList > SessionInfoList
Definition: account.h:224
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:284
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:38
static const AccountHandle INVALID_HANDLE
Definition: account.h:190
const std::string & getStringHandle() const
Gets the string handle of the account.
std::vector< PermissionInfo > PermissionInfoDataList
Definition: account.h:362
std::shared_ptr< BalanceInfoData > BalanceInfo
Definition: account.h:282
std::vector< SessionInfo > SessionInfoDataList
Definition: account.h:223
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:46
Definition: account.h:47
uint64_t getUsedStorage() const
Gets the used storage of the account.