| D++ (DPP) C++ Discord API Bot Library

Search
Loading...
Searching...
No Matches
dpp::sku Class Reference

A definition of a discord SKU. More...

`#include <sku.h>`

Inheritance diagram for dpp::sku:
[legend]
Collaboration diagram for dpp::sku:
[legend]

## Public Member Functions

| sku ()=default
| Construct a new SKU object.
| sku (const snowflake id, const sku_type type, const snowflake application_id, const std::string name, const std::string slug, const uint16_t flags)
| Construct a new SKU object with all data required.
std::string | build_json (bool with_id=false) const
| Convert object to json string.
sku & | fill_from_json (nlohmann::json *j)
| Convert object from nlohmann::json.
constexpr double | get_creation_time () const noexcept
| Get the creation time of this object according to Discord.
sku_type | get_type () const
| Get the type of SKU.
bool | is_available () const
| Is the SKU available for purchase?
bool | is_guild_subscription () const
| Is the SKU a guild subscription?
bool | is_user_subscription () const
| Is the SKU a user subscription?
constexpr bool | operator!= (const managed &other) const noexcept
| Comparison operator for comparing two managed objects by id.
constexpr bool | operator== (const managed &other) const noexcept
| Comparison operator for comparing two managed objects by id.
auto | to_json (bool with_id=false) const
| Convert object to nlohmann::json.

## Public Attributes

snowflake | application_id {0}
| ID of the parent application.
uint16_t | flags {0}
| Flags bitmap from dpp::sku_flags.
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.
std::string | name {}
| Customer-facing name of your premium offering.
std::string | slug {}
| System-generated URL slug based on the SKU's name.
sku_type | type {sku_type::SUBSCRIPTION}
| The type of SKU.

## Protected Member Functions

sku & | fill_from_json_impl (nlohmann::json *j)
json | to_json_impl (bool with_id=false) const
| Build json for this SKU object.

## Friends

struct | json_interface< sku >

## Detailed Description

A definition of a discord SKU.

## Constructor & Destructor Documentation

## ◆ sku() [1/2]

dpp::sku::sku | ( |  | ) |

default

Construct a new SKU object.

## ◆ sku() [2/2]

dpp::sku::sku | ( | const snowflake | id,
|  | const sku_type | type,
|  | const snowflake | application_id,
|  | const std::string | name,
|  | const std::string | slug,
|  | const uint16_t | flags )

Construct a new SKU object with all data required.

Parameters

  id | ID of the SKU.
  type | Type of SKU (sku_type).
  application_id | ID of the parent application.
  name | Customer-facing name of your premium offering.
  slug | System-generated URL slug based on the SKU's name.
  flags | Flags bitmap from dpp::sku_flags.

## Member Function Documentation

## ◆ build_json()

std::string dpp::json_interface< sku >::build_json | ( | bool | with_id = false | ) | const

inline inherited

Convert object to json string.

Parameters

  with_id | Whether 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()

sku & dpp::json_interface< sku >::fill_from_json | ( | nlohmann::json * | j | ) |

inline inherited

Convert object from nlohmann::json.

Parameters

  j | nlohmann::json object

Returns
  T& Reference to self for fluent calling

## ◆ fill_from_json_impl()

sku & dpp::sku::fill_from_json_impl | ( | nlohmann::json * | j | ) |

protected

Read class values from json object

Parameters

  j | A json object to read from

Returns
  A reference to self

## ◆ get_creation_time()

double dpp::managed::get_creation_time | ( |  | ) | const

inline constexpr noexcept inherited

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()

sku_type dpp::sku::get_type | ( |  | ) | const

Get the type of SKU.

Returns
  sku_type SKU type

## ◆ is_available()

bool dpp::sku::is_available | ( |  | ) | const

Is the SKU available for purchase?

Returns
  true if the SKU can be purchased.

## ◆ is_guild_subscription()

bool dpp::sku::is_guild_subscription | ( |  | ) | const

Is the SKU a guild subscription?

Returns
  true if the SKU is a guild subscription.

## ◆ is_user_subscription()

bool dpp::sku::is_user_subscription | ( |  | ) | const

Is the SKU a user subscription?

Returns
  true if the SKU is a user subscription

## ◆ operator!=()

bool dpp::managed::operator!= | ( | const managed & | other | ) | const

inline constexpr noexcept inherited

Comparison operator for comparing two managed objects by id.

Parameters

  other | Other object to compare against

Returns
  true objects are not the same id
  false objects are the same id

## ◆ operator==()

bool dpp::managed::operator== | ( | const managed & | other | ) | const

inline constexpr noexcept inherited

Comparison operator for comparing two managed objects by id.

Parameters

  other | Other object to compare against

Returns
  true objects are the same id
  false objects are not the same id

## ◆ to_json()

auto dpp::json_interface< sku >::to_json | ( | bool | with_id = false | ) | const

inline inherited

Convert object to nlohmann::json.

Parameters

  with_id | Whether 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::sku::to_json_impl | ( | bool | with_id = false | ) | const

protected

Build json for this SKU object.

Parameters

  with_id | include the ID in the json

Returns
  json JSON object

## Friends And Related Symbol Documentation

## ◆ json_interface< sku >

friend struct json_interface< sku >

friend

## Member Data Documentation

## ◆ application_id

snowflake dpp::sku::application_id {0}

ID of the parent application.

## ◆ flags

uint16_t dpp::sku::flags {0}

Flags bitmap from dpp::sku_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.

## ◆ name

std::string dpp::sku::name {}

Customer-facing name of your premium offering.

## ◆ slug

std::string dpp::sku::slug {}

System-generated URL slug based on the SKU's name.

## ◆ type

sku_type dpp::sku::type {sku_type::SUBSCRIPTION}

The type of SKU.

D++ Library version 9.0.13 D++ Library version 9.0.12 D++ Library version 9.0.11 D++ Library version 9.0.10 D++ Library version 9.0.9 D++ Library version 9.0.8 D++ Library version 9.0.7 D++ Library version 9.0.6 D++ Library version 9.0.5 D++ Library version 9.0.4 D++ Library version 9.0.3 D++ Library version 9.0.2 D++ Library version 9.0.1 D++ Library version 9.0.0 D++ Library version 1.0.2 D++ Library version 1.0.1 D++ Library version 1.0.0