Skip to content

Commit

Permalink
made default vaulue with created object of bitwardenSettings for Bitw…
Browse files Browse the repository at this point in the history
…ardenClient
  • Loading branch information
Todosijevic-Slobodan authored and Todosijevic-Slobodan committed Nov 28, 2023
1 parent 03e19be commit dd62664
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion languages/cpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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("<bitwarden-url>");
bitwardenSettings.set_identity_url("<bitwarden-identity>");
```
Expand All @@ -22,6 +22,7 @@ bitwardenSettings.set_identity_url("<bitwarden-identity>");

```c++
std::string accessToken = "<access-token>";
// Optional - argument in BitwardenClient
BitwardenClient bitwardenClient = BitwardenClient(bitwardenSettings);
bitwardenClient.accessTokenLogin(accessToken);
```
Expand Down
5 changes: 3 additions & 2 deletions languages/cpp/examples/Wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("<bitwarden-url>");
// bitwardenSettings.set_identity_url("<bitwarden-identity>");

// Create a Bitwarden client instance
BitwardenClient bitwardenClient = BitwardenClient(bitwardenSettings);
BitwardenClient bitwardenClient = BitwardenClient();
// // Access token login
bitwardenClient.accessTokenLogin(accessToken);
// Organization ID
Expand Down
2 changes: 1 addition & 1 deletion languages/cpp/include/BitwardenClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class BitwardenClient {
public:
BitwardenClient(const BitwardenSettings& bitwardenSettings);
BitwardenClient(const BitwardenSettings& bitwardenSettings = BitwardenSettings());
~BitwardenClient();

void accessTokenLogin(const std::string& accessToken);
Expand Down
3 changes: 2 additions & 1 deletion languages/cpp/src/BitwardenClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#include <iostream>
#include <string>

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<std::string> apiUrl = bitwardenSettings.get_api_url().empty()
Expand Down

0 comments on commit dd62664

Please sign in to comment.