Add fame_list() to Api.
With this commit the whole remote API is currently covered.
This commit is contained in:
parent
5b480f3ae5
commit
b4c9b013a0
4 changed files with 55 additions and 0 deletions
15
src/main.cpp
15
src/main.cpp
|
@ -50,5 +50,20 @@ int main(int argc, char* argv[]) {
|
|||
std::cout << shop.items.size() << " items\n";
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto fame = oro_api.fame_list();
|
||||
std::cout << "Forgers: ";
|
||||
for (const auto& forger : fame.second.forgers) {
|
||||
std::cout << forger.name << ", ";
|
||||
}
|
||||
std::cout << '\n';
|
||||
std::cout << "Brewers: ";
|
||||
for (const auto& brewer : fame.second.brewers) {
|
||||
std::cout << brewer.name << ", ";
|
||||
}
|
||||
std::cout << '\n';
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -89,6 +89,21 @@ BOOST_FUSION_ADAPT_STRUCT(
|
|||
(std::vector<oro::Shop>, shops)
|
||||
)
|
||||
|
||||
BOOST_FUSION_ADAPT_STRUCT(
|
||||
oro::Creator,
|
||||
(unsigned int, id)
|
||||
(std::string, name)
|
||||
(unsigned int, points)
|
||||
)
|
||||
|
||||
BOOST_FUSION_ADAPT_STRUCT(
|
||||
oro::Creators,
|
||||
(oro::Timestamp, generation_timestamp)
|
||||
(int, version)
|
||||
(std::vector<oro::Creator>, brewers)
|
||||
(std::vector<oro::Creator>, forgers)
|
||||
)
|
||||
|
||||
namespace oro {
|
||||
namespace {
|
||||
constexpr const std::int64_t g_max_json_mem = 1024 * 1024 * 20;
|
||||
|
@ -97,6 +112,7 @@ namespace {
|
|||
constexpr const char g_endpoint_items_list[] = "api/v1/items/list";
|
||||
constexpr const char g_endpoint_items_icons[] = "api/v1/items/icons";
|
||||
constexpr const char g_endpoint_market_list[] = "api/v1/market/list";
|
||||
constexpr const char g_endpoint_fame_list[] = "api/v1/fame/list";
|
||||
|
||||
template <typename T>
|
||||
std::pair<Header, T> call_rest_api (
|
||||
|
@ -180,4 +196,8 @@ std::pair<Header, Shops> Api::market_list() {
|
|||
return call_rest_api<oro::Shops>(*m_client, m_prefix + g_endpoint_market_list, m_api_key, m_client_name, m_client_purpose);
|
||||
}
|
||||
|
||||
std::pair<Header, Creators> Api::fame_list() {
|
||||
return call_rest_api<oro::Creators>(*m_client, m_prefix + g_endpoint_fame_list, m_api_key, m_client_name, m_client_purpose);
|
||||
}
|
||||
|
||||
} //namespace oro
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "items.hpp"
|
||||
#include "icons.hpp"
|
||||
#include "shops.hpp"
|
||||
#include "creators.hpp"
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <memory>
|
||||
|
@ -62,6 +63,7 @@ public:
|
|||
std::pair<Header, Items> items_list();
|
||||
std::pair<Header, Icons> items_icons();
|
||||
std::pair<Header, Shops> market_list();
|
||||
std::pair<Header, Creators> fame_list();
|
||||
|
||||
private:
|
||||
std::string m_prefix;
|
||||
|
|
18
src/oro/creators.hpp
Normal file
18
src/oro/creators.hpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
|
||||
#include "datatypes.hpp"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace oro {
|
||||
struct Creator {
|
||||
unsigned int id;
|
||||
std::string name;
|
||||
unsigned int points;
|
||||
};
|
||||
|
||||
struct Creators : BaseJsonReply {
|
||||
std::vector<Creator> brewers;
|
||||
std::vector<Creator> forgers;
|
||||
};
|
||||
} //namespace oro
|
Loading…
Reference in a new issue