orotool/src/main.cpp

55 lines
1.6 KiB
C++
Raw Normal View History

2020-06-20 01:27:47 +02:00
#include "oro/api.hpp"
#include "orotool_config.hpp"
#include <iostream>
2020-06-22 19:40:37 +02:00
int main(int argc, char* argv[]) {
if (2 != argc) {
std::cerr << "Please provide your API key\n";
return 2;
}
oro::Api oro_api(duck::g_base_url, argv[1], "RESTC_CPP", "Testing");
2020-06-20 01:27:47 +02:00
auto ping = oro_api.ping();
std::cout << "date: " << ping.first.date << '\n';
2020-06-20 01:27:47 +02:00
std::cout << "rate limit: " << ping.first.rate_limit << '\n';
std::cout << "remaining: " << ping.first.rate_limit_remaining << '\n';
std::cout << "reset: " << ping.first.rate_limit_reset << '\n';
std::cout << "retry after: " << ping.first.retry_after << '\n';
std::cout << "server: " << ping.first.server << '\n';
std::cout << "-----\n";
std::cout << "timestamp: " << ping.second.generation_timestamp << '\n';
2020-06-20 01:27:47 +02:00
std::cout << "answer: " << ping.second.message << '\n';
std::cout << "version: " << ping.second.version << '\n';
2020-06-22 19:40:37 +02:00
{
auto whoami = oro_api.who_am_i();
std::cout << "master id: " << whoami.second.master_id << '\n';
}
2020-06-22 20:53:56 +02:00
{
auto items = oro_api.items_list();
std::cout << "Total items in DB: " << items.second.items.size() << '\n';
}
2020-06-22 22:29:14 +02:00
{
auto icons = oro_api.items_icons();
std::cout << "Total icons in DB: " << icons.second.icons.size() << '\n';
}
2020-06-23 10:19:02 +02:00
{
auto shops = oro_api.market_list();
for (const auto& shop : shops.second.shops) {
std::cout << "Shop \"" << shop.title << "\" by " << shop.owner <<
" in " << shop.location.map <<
" at <" << shop.location.x << ", " << shop.location.y << "> ";
if (shop.type == oro::ShopType::Buying)
std::cout << "buying ";
else
std::cout << "selling ";
std::cout << shop.items.size() << " items\n";
}
}
return 0;
}