D++ (DPP)
C++ Discord API Bot Library
dpp::entitlement Class Reference

A definition of a discord entitlement. More...

#include <entitlement.h>

+ Inheritance diagram for dpp::entitlement:
+ Collaboration diagram for dpp::entitlement:

Public Member Functions

 entitlement ()=default
 Construct a new entitlement object. More...
 
 entitlement (const snowflake sku_id, const snowflake id=0, const snowflake application_id=0, const entitlement_type type=dpp::entitlement_type::APPLICATION_SUBSCRIPTION, const uint8_t flags=0)
 Construct a new entitlement object with sku_id, ID, application_id, type, and flags. More...
 
entitlement_type get_type () const
 Get the type of entitlement. More...
 
bool is_deleted () const
 Was the entitlement deleted? More...
 
constexpr double get_creation_time () const noexcept
 Get the creation time of this object according to Discord. More...
 
constexpr bool operator== (const managed &other) const noexcept
 Comparison operator for comparing two managed objects by id. More...
 
constexpr bool operator!= (const managed &other) const noexcept
 Comparison operator for comparing two managed objects by id. More...
 
entitlementfill_from_json (nlohmann::json *j)
 Convert object from nlohmann::json. More...
 
auto to_json (bool with_id=false) const
 Convert object to nlohmann::json. More...
 
std::string build_json (bool with_id=false) const
 Convert object to json string. More...
 

Public Attributes

snowflake sku_id {0}
 ID of the SKU. More...
 
snowflake application_id {0}
 ID of the parent application. More...
 
snowflake owner_id {0}
 Optional: ID of the user/guild that is granted access to the entitlement's SKU. More...
 
entitlement_type type = entitlement_type::APPLICATION_SUBSCRIPTION
 The type of entitlement. More...
 
time_t starts_at {0}
 Optional: Start date at which the entitlement is valid. More...
 
time_t ends_at {0}
 Optional: Date at which the entitlement is no longer valid. More...
 
uint16_t flags {0}
 Flags bitmap from dpp::entitlement_flags. More...
 
snowflake id = {}
 Unique ID of object set by Discord. This value contains a timestamp, worker ID, internal server ID, and an incrementing value. Only the timestamp is relevant to us as useful metadata. More...
 

Protected Member Functions

entitlementfill_from_json_impl (nlohmann::json *j)
 
json to_json_impl (bool with_id=false) const
 Build json for this entitlement object. More...
 

Friends

struct json_interface< entitlement >
 

Detailed Description

A definition of a discord entitlement.

Constructor & Destructor Documentation

◆ entitlement() [1/2]

dpp::entitlement::entitlement ( )
default

Construct a new entitlement object.

◆ entitlement() [2/2]

dpp::entitlement::entitlement ( const snowflake  sku_id,
const snowflake  id = 0,
const snowflake  application_id = 0,
const entitlement_type  type = dpp::entitlement_type::APPLICATION_SUBSCRIPTION,
const uint8_t  flags = 0 
)

Construct a new entitlement object with sku_id, ID, application_id, type, and flags.

Parameters
sku_idThe ID of the SKU.
idThe ID of the entitlement.
application_idThe ID of the parent application.
typeThe type of entitlement (Should only ever be APPLICATION_SUBSCRIPTION unless you going to use this object as a parameter for dpp::cluster::entitlement_test_create).
flagsThe flags for the SKU from dpp::entitlement_flags.

Member Function Documentation

◆ build_json()

std::string dpp::json_interface< entitlement >::build_json ( bool  with_id = false) const
inlineinherited

Convert object to json string.

Parameters
with_idWhether to include the ID or not
Note
Some fields are conditionally filled, do not rely on all fields being present
Returns
std::string Json built from the structure

◆ fill_from_json()

entitlement & dpp::json_interface< entitlement >::fill_from_json ( nlohmann::json *  j)
inlineinherited

Convert object from nlohmann::json.

Parameters
jnlohmann::json object
Returns
T& Reference to self for fluent calling

◆ fill_from_json_impl()

entitlement & dpp::entitlement::fill_from_json_impl ( nlohmann::json *  j)
protected

Read class values from json object

Parameters
jA json object to read from
Returns
A reference to self

◆ get_creation_time()

constexpr double dpp::managed::get_creation_time ( ) const
inlineconstexprnoexceptinherited

Get the creation time of this object according to Discord.

Returns
double creation time inferred from the snowflake ID. The minimum possible value is the first second of 2015.

◆ get_type()

entitlement_type dpp::entitlement::get_type ( ) const

Get the type of entitlement.

Returns
entitlement_type Entitlement type

◆ is_deleted()

bool dpp::entitlement::is_deleted ( ) const

Was the entitlement deleted?

Returns
true if the entitlement was deleted.

◆ operator!=()

constexpr bool dpp::managed::operator!= ( const managed other) const
inlineconstexprnoexceptinherited

Comparison operator for comparing two managed objects by id.

Parameters
otherOther object to compare against
Returns
true objects are not the same id
false objects are the same id

◆ operator==()

constexpr bool dpp::managed::operator== ( const managed other) const
inlineconstexprnoexceptinherited

Comparison operator for comparing two managed objects by id.

Parameters
otherOther object to compare against
Returns
true objects are the same id
false objects are not the same id

◆ to_json()

auto dpp::json_interface< entitlement >::to_json ( bool  with_id = false) const
inlineinherited

Convert object to nlohmann::json.

Parameters
with_idWhether to include the ID or not
Note
Some fields are conditionally filled, do not rely on all fields being present
Returns
json Json built from the structure

◆ to_json_impl()

json dpp::entitlement::to_json_impl ( bool  with_id = false) const
protected

Build json for this entitlement object.

Parameters
with_idinclude the ID in the json
Returns
json JSON object

Friends And Related Function Documentation

◆ json_interface< entitlement >

friend struct json_interface< entitlement >
friend

Member Data Documentation

◆ application_id

snowflake dpp::entitlement::application_id {0}

ID of the parent application.

◆ ends_at

time_t dpp::entitlement::ends_at {0}

Optional: Date at which the entitlement is no longer valid.

Note
Not present when using test entitlements.

◆ flags

uint16_t dpp::entitlement::flags {0}

Flags bitmap from dpp::entitlement_flags.

◆ id

snowflake dpp::managed::id = {}
inherited

Unique ID of object set by Discord. This value contains a timestamp, worker ID, internal server ID, and an incrementing value. Only the timestamp is relevant to us as useful metadata.

◆ owner_id

snowflake dpp::entitlement::owner_id {0}

Optional: ID of the user/guild that is granted access to the entitlement's SKU.

◆ sku_id

snowflake dpp::entitlement::sku_id {0}

ID of the SKU.

◆ starts_at

time_t dpp::entitlement::starts_at {0}

Optional: Start date at which the entitlement is valid.

Note
Not present when using test entitlements.

◆ type

entitlement_type dpp::entitlement::type = entitlement_type::APPLICATION_SUBSCRIPTION

The type of entitlement.

D++ Library version 10.0.35D++ Library version 10.0.34D++ Library version 10.0.33D++ Library version 10.0.32D++ Library version 10.0.31D++ Library version 10.0.30D++ Library version 10.0.29D++ Library version 10.0.28D++ Library version 10.0.27D++ Library version 10.0.26D++ Library version 10.0.25D++ Library version 10.0.24D++ Library version 10.0.23D++ Library version 10.0.22D++ Library version 10.0.21D++ Library version 10.0.20D++ Library version 10.0.19D++ Library version 10.0.18D++ Library version 10.0.17D++ Library version 10.0.16D++ Library version 10.0.15D++ Library version 10.0.14D++ Library version 10.0.13D++ Library version 10.0.12D++ Library version 10.0.11D++ Library version 10.0.10D++ Library version 10.0.9D++ Library version 10.0.8D++ Library version 10.0.7D++ Library version 10.0.6D++ Library version 10.0.5D++ Library version 10.0.4D++ Library version 10.0.3D++ Library version 10.0.2D++ Library version 10.0.1D++ Library version 10.0.0D++ Library version 9.0.19D++ Library version 9.0.18D++ Library version 9.0.17D++ Library version 9.0.16D++ Library version 9.0.15D++ Library version 9.0.14D++ Library version 9.0.13D++ Library version 9.0.12D++ Library version 9.0.11D++ Library version 9.0.10D++ Library version 9.0.9D++ Library version 9.0.8D++ Library version 9.0.7D++ Library version 9.0.6D++ Library version 9.0.5D++ Library version 9.0.4D++ Library version 9.0.3D++ Library version 9.0.2D++ Library version 9.0.1D++ Library version 9.0.0D++ Library version 1.0.2D++ Library version 1.0.1D++ Library version 1.0.0