mirror of
https://github.com/tribufu/sdk-cpp
synced 2025-06-15 11:24:18 +00:00
Update main branch (#3)
* New api from upstream * Create .clang-format * Update .clang-format * Remove mintaka submodule * Add premake-core submodule * Update premake-core * Fix includes
This commit is contained in:
221
.clang-format
Normal file
221
.clang-format
Normal file
@ -0,0 +1,221 @@
|
||||
---
|
||||
Language: Cpp
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignArrayOfStructures: None
|
||||
AlignConsecutiveAssignments:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
PadOperators: true
|
||||
AlignConsecutiveBitFields:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveDeclarations:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
PadOperators: false
|
||||
AlignConsecutiveMacros:
|
||||
Enabled: false
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: false
|
||||
PadOperators: false
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: Align
|
||||
AlignTrailingComments:
|
||||
Kind: Always
|
||||
OverEmptyLines: 0
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: MultiLine
|
||||
AttributeMacros:
|
||||
- __capability
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BitFieldColonSpacing: Both
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: true
|
||||
AfterControlStatement: Always
|
||||
AfterEnum: true
|
||||
AfterExternBlock: true
|
||||
AfterFunction: true
|
||||
AfterNamespace: true
|
||||
AfterObjCDeclaration: true
|
||||
AfterStruct: true
|
||||
AfterUnion: false
|
||||
BeforeCatch: true
|
||||
BeforeElse: true
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakAfterAttributes: Never
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakArrays: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeConceptDeclarations: Always
|
||||
BreakBeforeBraces: Custom
|
||||
BreakBeforeInlineASMColon: OnlyMultiline
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 120
|
||||
CommentPragmas: "^ IWYU pragma:"
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
EmptyLineAfterAccessModifier: Never
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: false
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IfMacros:
|
||||
- KJ_IF_MAYBE
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: ".*"
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
IncludeIsMainRegex: "(Test)?$"
|
||||
IncludeIsMainSourceRegex: ""
|
||||
IndentAccessModifiers: false
|
||||
IndentCaseBlocks: false
|
||||
IndentCaseLabels: false
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentRequiresClause: true
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
InsertBraces: false
|
||||
InsertNewlineAtEOF: false
|
||||
InsertTrailingCommas: None
|
||||
IntegerLiteralSeparator:
|
||||
Binary: 0
|
||||
Decimal: 0
|
||||
Hex: 0
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
LambdaBodyIndentation: Signature
|
||||
LineEnding: DeriveLF
|
||||
MacroBlockBegin: ""
|
||||
MacroBlockEnd: ""
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: All
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PackConstructorInitializers: BinPack
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakOpenParenthesis: 0
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyIndentedWhitespace: 0
|
||||
PenaltyReturnTypeOnItsOwnLine: 1000
|
||||
PointerAlignment: Right
|
||||
PPIndentWidth: -1
|
||||
QualifierAlignment: Leave
|
||||
ReferenceAlignment: Pointer
|
||||
ReflowComments: true
|
||||
RemoveBracesLLVM: false
|
||||
RemoveSemicolon: false
|
||||
RequiresClausePosition: OwnLine
|
||||
RequiresExpressionIndentation: OuterScope
|
||||
SeparateDefinitionBlocks: Leave
|
||||
ShortNamespaceLines: 1
|
||||
SortIncludes: CaseSensitive
|
||||
SortJavaStaticImport: Before
|
||||
SortUsingDeclarations: LexicographicNumeric
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeParensOptions:
|
||||
AfterControlStatements: true
|
||||
AfterForeachMacros: true
|
||||
AfterFunctionDefinitionName: false
|
||||
AfterFunctionDeclarationName: false
|
||||
AfterIfMacros: true
|
||||
AfterOverloadedOperator: false
|
||||
AfterRequiresInClause: false
|
||||
AfterRequiresInExpression: false
|
||||
BeforeNonEmptyParentheses: false
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceBeforeSquareBrackets: false
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: Never
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: -1
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Latest
|
||||
StatementAttributeLikeMacros:
|
||||
- Q_EMIT
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
WhitespaceSensitiveMacros:
|
||||
- BOOST_PP_STRINGIZE
|
||||
- CF_SWIFT_NAME
|
||||
- NS_SWIFT_NAME
|
||||
- PP_STRINGIZE
|
||||
- STRINGIZE
|
||||
---
|
||||
|
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -1,3 +1,3 @@
|
||||
[submodule "vendor/Mintaka"]
|
||||
path = vendor/Mintaka
|
||||
url = https://github.com/Tribufu/Mintaka
|
||||
[submodule "vendor/premake-core"]
|
||||
path = vendor/premake-core
|
||||
url = https://github.com/TribufuForks/premake-core
|
||||
|
@ -14,4 +14,3 @@ crate-type = ["staticlib"]
|
||||
path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
mintaka-native = { path = "./vendor/Mintaka/src/native" }
|
||||
|
@ -1,26 +1,11 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <tribufu/client.h>
|
||||
|
||||
using namespace tribufu;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
auto client = new TribufuClient(0, "client_secret");
|
||||
std::cout << "client_id: " << client->get_id() << std::endl;
|
||||
|
||||
json json_obj = {
|
||||
{"nome", "John"},
|
||||
{"idade", 25},
|
||||
{"cidade", "Exemplo"}};
|
||||
|
||||
std::string json_str = json_obj.dump(4);
|
||||
|
||||
std::cout << json_str << std::endl;
|
||||
|
||||
client->get_token();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -3,3 +3,4 @@
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/client.h>
|
||||
#include <tribufu/json.h>
|
||||
|
27
include/tribufu/api.h
Normal file
27
include/tribufu/api.h
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/options.h>
|
||||
#include <tribufu/prelude.h>
|
||||
|
||||
namespace tribufu
|
||||
{
|
||||
static const char *VERSION = "0.0.4";
|
||||
static const char *API_URL = "https://api.tribufu.com";
|
||||
|
||||
class TRIBUFU_API TribufuApi
|
||||
{
|
||||
private:
|
||||
std::string base_url;
|
||||
TribufuApiOptions options;
|
||||
|
||||
public:
|
||||
TribufuApi();
|
||||
TribufuApi(std::string api_key);
|
||||
TribufuApi(TribufuApiOptions options);
|
||||
~TribufuApi();
|
||||
static TribufuApi from_env();
|
||||
static TribufuApi from_env(std::string prefix);
|
||||
};
|
||||
}
|
@ -2,28 +2,20 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/api.h>
|
||||
#include <tribufu/prelude.h>
|
||||
|
||||
const char *VERSION = "0.0.4";
|
||||
|
||||
namespace tribufu
|
||||
{
|
||||
class TRIBUFU_API TribufuClient
|
||||
class TRIBUFU_API TribufuClient : public TribufuApi
|
||||
{
|
||||
private:
|
||||
uint64_t id;
|
||||
std::string secret;
|
||||
HttpClient http;
|
||||
uint64_t client_id;
|
||||
std::string client_secret;
|
||||
|
||||
public:
|
||||
TribufuClient(uint64_t id, const std::string &secret);
|
||||
~TribufuClient();
|
||||
|
||||
uint64_t get_id() const
|
||||
{
|
||||
return this->id;
|
||||
}
|
||||
|
||||
void get_token();
|
||||
uint64_t &get_client_id();
|
||||
};
|
||||
}
|
||||
|
11
include/tribufu/json.h
Normal file
11
include/tribufu/json.h
Normal file
@ -0,0 +1,11 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/native.h>
|
||||
#include <tribufu/prelude.h>
|
||||
|
||||
#ifdef TRIBUFU_CPP
|
||||
#include <nlohmann/json.hpp>
|
||||
using json = nlohmann::json;
|
||||
#endif
|
@ -61,7 +61,8 @@ namespace tribufu
|
||||
|
||||
public:
|
||||
OAuth2AuthorizeRequest();
|
||||
OAuth2AuthorizeRequest(OAuth2ResponseType response_type, uint64_t client_id, const std::string &client_secret, const std::string &redirect_uri, const std::string &scope, const std::string &state);
|
||||
OAuth2AuthorizeRequest(OAuth2ResponseType response_type, uint64_t client_id, const std::string &client_secret,
|
||||
const std::string &redirect_uri, const std::string &scope, const std::string &state);
|
||||
~OAuth2AuthorizeRequest();
|
||||
};
|
||||
|
||||
@ -87,7 +88,8 @@ namespace tribufu
|
||||
|
||||
public:
|
||||
OAuth2ErrorResponse();
|
||||
OAuth2ErrorResponse(OAuth2AuthorizeError error, const std::string &error_description, const std::string &error_uri, const std::string &state);
|
||||
OAuth2ErrorResponse(OAuth2AuthorizeError error, const std::string &error_description,
|
||||
const std::string &error_uri, const std::string &state);
|
||||
~OAuth2ErrorResponse();
|
||||
};
|
||||
|
||||
@ -105,7 +107,9 @@ namespace tribufu
|
||||
|
||||
public:
|
||||
OAuth2TokenRequest();
|
||||
OAuth2TokenRequest(OAuth2GrantType grant_type, uint64_t client_id, const std::string &client_secret, const std::string &redirect_uri, const std::string &code, const std::string &refresh_token, const std::string &username, const std::string &password);
|
||||
OAuth2TokenRequest(OAuth2GrantType grant_type, uint64_t client_id, const std::string &client_secret,
|
||||
const std::string &redirect_uri, const std::string &code, const std::string &refresh_token,
|
||||
const std::string &username, const std::string &password);
|
||||
~OAuth2TokenRequest();
|
||||
};
|
||||
|
||||
@ -121,7 +125,9 @@ namespace tribufu
|
||||
|
||||
public:
|
||||
OAuth2TokenResponse();
|
||||
OAuth2TokenResponse(OAuth2TokenType token_type, const std::string &access_token, const std::string &refresh_token, const std::string &scope, const std::string &state, uint64_t expires_in);
|
||||
OAuth2TokenResponse(OAuth2TokenType token_type, const std::string &access_token,
|
||||
const std::string &refresh_token, const std::string &scope, const std::string &state,
|
||||
uint64_t expires_in);
|
||||
~OAuth2TokenResponse();
|
||||
};
|
||||
}
|
||||
|
24
include/tribufu/options.h
Normal file
24
include/tribufu/options.h
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/prelude.h>
|
||||
|
||||
namespace tribufu
|
||||
{
|
||||
class TRIBUFU_API TribufuApiOptions
|
||||
{
|
||||
public:
|
||||
std::string api_key;
|
||||
std::string access_token;
|
||||
std::string refresh_token;
|
||||
float expires_in;
|
||||
|
||||
public:
|
||||
TribufuApiOptions();
|
||||
TribufuApiOptions(std::string api_key);
|
||||
TribufuApiOptions(std::string access_token, std::string refresh_token, float expires_in);
|
||||
TribufuApiOptions(std::string api_key, std::string access_token, std::string refresh_token, float expires_in);
|
||||
~TribufuApiOptions();
|
||||
};
|
||||
}
|
21
include/tribufu/platform.h
Normal file
21
include/tribufu/platform.h
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef DLLEXPORT
|
||||
#define DLLEXPORT __declspec(dllexport)
|
||||
#endif
|
||||
#ifndef DLLIMPORT
|
||||
#define DLLIMPORT __declspec(dllimport)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __MACH__ || __APPLE__ || __linux__ || __FreeBSD__ || __ANDROID__
|
||||
#ifndef DLLEXPORT
|
||||
#define DLLEXPORT __attribute__((visibility("default")))
|
||||
#endif
|
||||
#ifndef DLLIMPORT
|
||||
#define DLLIMPORT __attribute__((visibility("default")))
|
||||
#endif
|
||||
#endif
|
@ -2,12 +2,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mintaka/framework.h>
|
||||
#include <tribufu/macros.h>
|
||||
#include <tribufu/native.h>
|
||||
|
||||
#ifdef TRIBUFU_CPP
|
||||
|
||||
using namespace mintaka;
|
||||
|
||||
#endif
|
||||
#include <tribufu/platform.h>
|
||||
#include <tribufu/std.h>
|
||||
|
20
include/tribufu/server.h
Normal file
20
include/tribufu/server.h
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/client.h>
|
||||
#include <tribufu/prelude.h>
|
||||
|
||||
namespace tribufu
|
||||
{
|
||||
class TRIBUFU_API TribufuServer : public TribufuClient
|
||||
{
|
||||
private:
|
||||
uint64_t server_id;
|
||||
|
||||
public:
|
||||
TribufuServer(uint64_t server_id, uint64_t client_id, const std::string &client_secret);
|
||||
~TribufuServer();
|
||||
uint64_t &get_server_id();
|
||||
};
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/prelude.h>
|
||||
#include <tribufu/json.h>
|
||||
|
||||
namespace tribufu
|
||||
{
|
||||
|
24
include/tribufu/std.h
Normal file
24
include/tribufu/std.h
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef TRIBUFU_CPP
|
||||
#include <algorithm>
|
||||
#include <cstdarg>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <new>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#endif
|
@ -3,6 +3,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <tribufu/prelude.h>
|
||||
#include <tribufu/json.h>
|
||||
|
||||
namespace tribufu
|
||||
{
|
||||
|
@ -1,3 +1,3 @@
|
||||
@echo off
|
||||
|
||||
call .\vendor\Mintaka\vendor\premake-core\windows\premake5.exe vs2022
|
||||
call .\vendor\premake-core\windows\premake5.exe vs2022
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
if [ "$(expr substr $(uname -s) 1 5)" = "Linux" ]
|
||||
then
|
||||
./vendor/Mintaka/vendor/premake-core/linux/premake5 gmake2
|
||||
./vendor/premake-core/linux/premake5 gmake2
|
||||
|
||||
elif [ "$(uname)" = "Darwin" ]
|
||||
then
|
||||
./vendor/Mintaka/vendor/premake-core/mac/premake5 xcode4
|
||||
./vendor/premake-core/mac/premake5 xcode4
|
||||
fi
|
||||
|
51
src/api.cpp
Normal file
51
src/api.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#include <tribufu/api.h>
|
||||
|
||||
namespace tribufu
|
||||
{
|
||||
TribufuApi::TribufuApi()
|
||||
{
|
||||
}
|
||||
|
||||
TribufuApi::TribufuApi(std::string api_key)
|
||||
{
|
||||
this->options.api_key = api_key;
|
||||
}
|
||||
|
||||
TribufuApi::TribufuApi(TribufuApiOptions options)
|
||||
{
|
||||
this->options = options;
|
||||
}
|
||||
|
||||
TribufuApi::~TribufuApi()
|
||||
{
|
||||
}
|
||||
|
||||
TribufuApi TribufuApi::from_env()
|
||||
{
|
||||
return TribufuApi::from_env("");
|
||||
}
|
||||
|
||||
TribufuApi TribufuApi::from_env(std::string prefix)
|
||||
{
|
||||
std::string env_prefix = "";
|
||||
|
||||
if (prefix != "")
|
||||
{
|
||||
env_prefix = prefix + "_";
|
||||
}
|
||||
|
||||
size_t required_size;
|
||||
char api_key[64];
|
||||
|
||||
auto response = getenv_s(&required_size, api_key, sizeof(api_key), (env_prefix + "API_KEY").c_str());
|
||||
|
||||
if (response == 0 && required_size > 0)
|
||||
{
|
||||
return TribufuApi(api_key);
|
||||
}
|
||||
|
||||
return TribufuApi();
|
||||
}
|
||||
}
|
@ -4,17 +4,22 @@
|
||||
|
||||
namespace tribufu
|
||||
{
|
||||
TribufuClient::TribufuClient(uint64_t id, const std::string &secret)
|
||||
TribufuClient::TribufuClient(uint64_t client_id, const std::string &client_secret) : TribufuApi()
|
||||
{
|
||||
this->id = id;
|
||||
this->secret = secret;
|
||||
this->http = HttpClient();
|
||||
this->client_id = client_id;
|
||||
this->client_secret = client_secret;
|
||||
}
|
||||
|
||||
TribufuClient::~TribufuClient()
|
||||
{
|
||||
}
|
||||
|
||||
uint64_t &TribufuClient::get_client_id()
|
||||
{
|
||||
return this->client_id;
|
||||
}
|
||||
|
||||
/*
|
||||
void TribufuClient::get_token()
|
||||
{
|
||||
try
|
||||
@ -37,4 +42,5 @@ namespace tribufu
|
||||
std::cout << "exception: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
@ -8,7 +8,9 @@ namespace tribufu
|
||||
{
|
||||
}
|
||||
|
||||
OAuth2AuthorizeRequest::OAuth2AuthorizeRequest(OAuth2ResponseType response_type, uint64_t client_id, const std::string &client_secret, const std::string &redirect_uri, const std::string &scope, const std::string &state)
|
||||
OAuth2AuthorizeRequest::OAuth2AuthorizeRequest(OAuth2ResponseType response_type, uint64_t client_id,
|
||||
const std::string &client_secret, const std::string &redirect_uri,
|
||||
const std::string &scope, const std::string &state)
|
||||
{
|
||||
this->response_type = response_type;
|
||||
this->client_id = client_id;
|
||||
@ -40,7 +42,8 @@ namespace tribufu
|
||||
{
|
||||
}
|
||||
|
||||
OAuth2ErrorResponse::OAuth2ErrorResponse(OAuth2AuthorizeError error, const std::string &error_description, const std::string &error_uri, const std::string &state)
|
||||
OAuth2ErrorResponse::OAuth2ErrorResponse(OAuth2AuthorizeError error, const std::string &error_description,
|
||||
const std::string &error_uri, const std::string &state)
|
||||
{
|
||||
this->error = error;
|
||||
this->error_description = error_description;
|
||||
@ -56,7 +59,10 @@ namespace tribufu
|
||||
{
|
||||
}
|
||||
|
||||
OAuth2TokenRequest::OAuth2TokenRequest(OAuth2GrantType grant_type, uint64_t client_id, const std::string &client_secret, const std::string &redirect_uri, const std::string &code, const std::string &refresh_token, const std::string &username, const std::string &password)
|
||||
OAuth2TokenRequest::OAuth2TokenRequest(OAuth2GrantType grant_type, uint64_t client_id,
|
||||
const std::string &client_secret, const std::string &redirect_uri,
|
||||
const std::string &code, const std::string &refresh_token,
|
||||
const std::string &username, const std::string &password)
|
||||
{
|
||||
this->grant_type = grant_type;
|
||||
this->client_id = client_id;
|
||||
@ -76,7 +82,9 @@ namespace tribufu
|
||||
{
|
||||
}
|
||||
|
||||
OAuth2TokenResponse::OAuth2TokenResponse(OAuth2TokenType token_type, const std::string &access_token, const std::string &refresh_token, const std::string &scope, const std::string &state, uint64_t expires_in)
|
||||
OAuth2TokenResponse::OAuth2TokenResponse(OAuth2TokenType token_type, const std::string &access_token,
|
||||
const std::string &refresh_token, const std::string &scope,
|
||||
const std::string &state, uint64_t expires_in)
|
||||
{
|
||||
this->token_type = token_type;
|
||||
this->access_token = access_token;
|
||||
|
32
src/options.cpp
Normal file
32
src/options.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#include <tribufu/options.h>
|
||||
|
||||
namespace tribufu
|
||||
{
|
||||
TribufuApiOptions::TribufuApiOptions() : TribufuApiOptions(nullptr, nullptr, nullptr, 0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
TribufuApiOptions::TribufuApiOptions(std::string api_key) : TribufuApiOptions(api_key, nullptr, nullptr, 0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
TribufuApiOptions::TribufuApiOptions(std::string access_token, std::string refresh_token, float expires_in)
|
||||
: TribufuApiOptions(nullptr, access_token, refresh_token, expires_in)
|
||||
{
|
||||
}
|
||||
|
||||
TribufuApiOptions::TribufuApiOptions(std::string api_key, std::string access_token, std::string refresh_token,
|
||||
float expires_in)
|
||||
{
|
||||
this->api_key = api_key;
|
||||
this->access_token = access_token;
|
||||
this->refresh_token = refresh_token;
|
||||
this->expires_in = expires_in;
|
||||
}
|
||||
|
||||
TribufuApiOptions::~TribufuApiOptions()
|
||||
{
|
||||
}
|
||||
}
|
21
src/server.cpp
Normal file
21
src/server.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
|
||||
#include <tribufu/server.h>
|
||||
|
||||
namespace tribufu
|
||||
{
|
||||
TribufuServer::TribufuServer(uint64_t server_id, uint64_t client_id, const std::string &client_secret)
|
||||
: TribufuClient(client_id, client_secret)
|
||||
{
|
||||
this->server_id = server_id;
|
||||
}
|
||||
|
||||
TribufuServer::~TribufuServer()
|
||||
{
|
||||
}
|
||||
|
||||
uint64_t &TribufuServer::get_server_id()
|
||||
{
|
||||
return this->server_id;
|
||||
}
|
||||
}
|
1
vendor/Mintaka
vendored
1
vendor/Mintaka
vendored
Submodule vendor/Mintaka deleted from 6733b056f6
1
vendor/premake-core
vendored
Submodule
1
vendor/premake-core
vendored
Submodule
Submodule vendor/premake-core added at 4bd56019c4
Reference in New Issue
Block a user