orotool/src/main.cpp

94 lines
2.7 KiB
C++
Raw Normal View History

2020-08-10 11:22:25 +01:00
/* Copyright 2020, Michele Santullo
* This file is part of orotool.
*
* Orotool is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Orotool is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Orotool. If not, see <http://www.gnu.org/licenses/>.
*/
2020-06-20 01:27:47 +02:00
#include "oro/api.hpp"
2020-08-10 02:34:09 +01:00
#include "oro/originsdb.hpp"
#include "orotool_config.hpp"
#include "evloop.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
2020-08-10 02:34:09 +01:00
oro::OriginsDB db;
duck::test(&oro_api, &db);
2020-08-09 21:07:54 +01:00
/*
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";
}
}
{
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';
}
2020-08-09 21:07:54 +01:00
*/
return 0;
}