Use native tribufu sdk

This commit is contained in:
2024-08-25 16:29:26 -03:00
parent 60126abfa5
commit 5eb1e81f19
32 changed files with 98 additions and 947 deletions

20
include/tribufu++/sdk.h Normal file
View File

@ -0,0 +1,20 @@
// Copyright (c) Tribufu. All Rights Reserved.
#pragma once
#include <tribufu/sdk.h>
namespace tribufu
{
class TRIBUFU_API TribufuSdk
{
public:
static bool Initialize();
static void Shutdown();
static bool Ping();
static void PingAsync(void *client_date, TribufuSdkPingCallback callback);
private:
static void PingCallbackHandler(void *client_data, bool result);
};
}

View File

@ -1,6 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
#pragma once
#include <tribufu/client.h>
#include <tribufu/json.h>

View File

@ -1,27 +0,0 @@
// 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);
};
}

View File

@ -1,21 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
#pragma once
#include <tribufu/api.h>
#include <tribufu/prelude.h>
namespace tribufu
{
class TRIBUFU_API TribufuClient : public TribufuApi
{
private:
uint64_t client_id;
std::string client_secret;
public:
TribufuClient(uint64_t id, const std::string &secret);
~TribufuClient();
uint64_t &get_client_id();
};
}

View File

@ -1,11 +0,0 @@
// 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

View File

@ -1,18 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
#pragma once
#ifdef __cplusplus
#define TRIBUFU_CPP
#endif
#ifdef TRIBUFU_LIBRARY
#define TRIBUFU_API DLLEXPORT
#else
#define TRIBUFU_API DLLIMPORT
#endif
// Macros Utils
#define TRIBUFU_EXPAND_MACRO(x) x
#define TRIBUFU_STRINGIFY_MACRO(x) #x

View File

@ -1,5 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
#pragma once
#include <tribufu/prelude.h>

View File

@ -1,133 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
#pragma once
#include <tribufu/prelude.h>
namespace tribufu
{
enum class TRIBUFU_API OAuth2ResponseType
{
Code,
Token,
};
enum class TRIBUFU_API OAuth2ClientType
{
Confidential,
Public,
};
enum class TRIBUFU_API OAuth2TokenHintType
{
AccessToken,
RefreshToken,
};
enum class TRIBUFU_API OAuth2GrantType
{
AuthorizationCode,
ClientCredentials,
DeviceCode,
Password,
RefreshToken,
};
enum class TRIBUFU_API OAuth2AuthorizeError
{
AccessDenied,
InvalidRequest,
InvalidScope,
ServerError,
TemporarilyUnavailable,
UnauthorizedClient,
UnsupportedResponseType,
};
enum class TRIBUFU_API OAuth2TokenType
{
Bearer,
};
class TRIBUFU_API OAuth2AuthorizeRequest
{
private:
OAuth2ResponseType response_type;
uint64_t client_id;
std::string client_secret;
std::string redirect_uri;
std::string scope;
std::string state;
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();
};
class TRIBUFU_API OAuth2CodeResponse
{
private:
std::string code;
std::string state;
public:
OAuth2CodeResponse();
OAuth2CodeResponse(const std::string &code, const std::string &state);
~OAuth2CodeResponse();
};
class TRIBUFU_API OAuth2ErrorResponse
{
private:
OAuth2AuthorizeError error;
std::string error_description;
std::string error_uri;
std::string state;
public:
OAuth2ErrorResponse();
OAuth2ErrorResponse(OAuth2AuthorizeError error, const std::string &error_description,
const std::string &error_uri, const std::string &state);
~OAuth2ErrorResponse();
};
class TRIBUFU_API OAuth2TokenRequest
{
private:
OAuth2GrantType grant_type;
uint64_t client_id;
std::string client_secret;
std::string redirect_uri;
std::string code;
std::string refresh_token;
std::string username;
std::string password;
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();
};
class TRIBUFU_API OAuth2TokenResponse
{
private:
OAuth2TokenType token_type;
std::string access_token;
std::string refresh_token;
std::string scope;
std::string state;
uint64_t expires_in;
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();
};
}

View File

@ -1,24 +0,0 @@
// 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();
};
}

View File

@ -1,21 +0,0 @@
// 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

View File

@ -1,8 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
#pragma once
#include <tribufu/macros.h>
#include <tribufu/native.h>
#include <tribufu/platform.h>
#include <tribufu/std.h>

View File

@ -1,20 +0,0 @@
// 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();
};
}

View File

@ -1,28 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
#pragma once
#include <tribufu/prelude.h>
#include <tribufu/json.h>
namespace tribufu
{
class TRIBUFU_API Server
{
private:
uint64_t id;
std::string name;
std::string description;
std::string address;
uint16_t game_port;
uint16_t query_port;
uint64_t package_id;
public:
Server();
Server(json data);
~Server();
json to_json();
};
}

View File

@ -1,24 +0,0 @@
// 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

View File

@ -1,47 +0,0 @@
// Copyright (c) Tribufu. All Rights Reserved.
#pragma once
#include <tribufu/prelude.h>
#include <tribufu/json.h>
namespace tribufu
{
enum class UserType
{
User,
Bot,
Org,
};
class TRIBUFU_API Profile
{
private:
uint64_t id;
std::string uuid;
std::string name;
std::string display_name;
UserType type;
uint64_t public_flags;
bool verified;
uint32_t level;
double experience;
bool public_birthday;
double points;
std::string location;
std::string photo_url;
std::string banner_url;
std::string last_online;
std::string biography;
uint32_t view_count;
std::string created;
std::string updated;
public:
Profile();
Profile(json data);
~Profile();
json to_json();
};
}