diff --git a/languages/cpp/README.md b/languages/cpp/README.md index ceb90b01e..23b59ac76 100644 --- a/languages/cpp/README.md +++ b/languages/cpp/README.md @@ -11,8 +11,8 @@ Review the help documentation on [Access Tokens] ### Client settings ```c++ +// Optional - if not stressed, then default values are used BitwardenSettings bitwardenSettings; -// Optional - if not stressed,then default values are used bitwardenSettings.set_api_url(""); bitwardenSettings.set_identity_url(""); ``` @@ -22,6 +22,7 @@ bitwardenSettings.set_identity_url(""); ```c++ std::string accessToken = ""; +// Optional - argument in BitwardenClient BitwardenClient bitwardenClient = BitwardenClient(bitwardenSettings); bitwardenClient.accessTokenLogin(accessToken); ``` diff --git a/languages/cpp/examples/Wrapper.cpp b/languages/cpp/examples/Wrapper.cpp index 9ad9ffb4f..df4aa164c 100644 --- a/languages/cpp/examples/Wrapper.cpp +++ b/languages/cpp/examples/Wrapper.cpp @@ -15,14 +15,15 @@ int main() { std::string accessToken = accessTokenEnv; std::string organizationId = organizationIdEnv; - BitwardenSettings bitwardenSettings; + // Optional - commented to use default values + // BitwardenSettings bitwardenSettings; // bitwardenSettings.set_api_url(""); // bitwardenSettings.set_identity_url(""); // Create a Bitwarden client instance - BitwardenClient bitwardenClient = BitwardenClient(bitwardenSettings); + BitwardenClient bitwardenClient = BitwardenClient(); // // Access token login bitwardenClient.accessTokenLogin(accessToken); // Organization ID diff --git a/languages/cpp/include/BitwardenClient.h b/languages/cpp/include/BitwardenClient.h index 8f329e8e2..a5cf72475 100644 --- a/languages/cpp/include/BitwardenClient.h +++ b/languages/cpp/include/BitwardenClient.h @@ -9,7 +9,7 @@ class BitwardenClient { public: - BitwardenClient(const BitwardenSettings& bitwardenSettings); + BitwardenClient(const BitwardenSettings& bitwardenSettings = BitwardenSettings()); ~BitwardenClient(); void accessTokenLogin(const std::string& accessToken); diff --git a/languages/cpp/src/BitwardenClient.cpp b/languages/cpp/src/BitwardenClient.cpp index b3f087fff..fef9ea267 100644 --- a/languages/cpp/src/BitwardenClient.cpp +++ b/languages/cpp/src/BitwardenClient.cpp @@ -2,7 +2,8 @@ #include #include -BitwardenClient::BitwardenClient(const BitwardenSettings& bitwardenSettings) : library(nullptr), commandRunner(nullptr), isClientOpen(false), projects(nullptr), secrets(nullptr) { +BitwardenClient::BitwardenClient(const BitwardenSettings& bitwardenSettings) + : library(nullptr), commandRunner(nullptr), isClientOpen(false), projects(nullptr), secrets(nullptr) { // Set default values for optional strings boost::optional apiUrl = bitwardenSettings.get_api_url().empty()