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:
Guilherme Werner
2024-03-06 19:01:54 -03:00
committed by GitHub
parent 67b1d41f22
commit 2e2462fd38
25 changed files with 501 additions and 55 deletions

View File

@ -3,3 +3,4 @@
#pragma once
#include <tribufu/client.h>
#include <tribufu/json.h>

27
include/tribufu/api.h Normal file
View 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);
};
}

View File

@ -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
View 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

View File

@ -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
View 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();
};
}

View 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

View File

@ -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
View 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();
};
}

View File

@ -3,6 +3,7 @@
#pragma once
#include <tribufu/prelude.h>
#include <tribufu/json.h>
namespace tribufu
{

24
include/tribufu/std.h Normal file
View 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

View File

@ -3,6 +3,7 @@
#pragma once
#include <tribufu/prelude.h>
#include <tribufu/json.h>
namespace tribufu
{