summaryrefslogtreecommitdiffstats
path: root/src/api.cpp
diff options
context:
space:
mode:
authortastytea2020-01-04 09:12:54 +0100
committertastytea2020-01-04 09:29:52 +0100
commit0311b868aab14e03018950d20695a8dd68befe7b (patch)
treee721ecfcc74ff00544691feab31d5c33c39f2489 /src/api.cpp
parent5f96861ea8dae0b4149a970dc29c31947a524a98 (diff)
downloadmastodonpp-0311b868aab14e03018950d20695a8dd68befe7b.tar
mastodonpp-0311b868aab14e03018950d20695a8dd68befe7b.tar.gz
mastodonpp-0311b868aab14e03018950d20695a8dd68befe7b.zip
Put API endpoints in class API.
Diffstat (limited to 'src/api.cpp')
-rw-r--r--src/api.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/api.cpp b/src/api.cpp
new file mode 100644
index 0000000..30a11b9
--- /dev/null
+++ b/src/api.cpp
@@ -0,0 +1,43 @@
+/* This file is part of mastodonpp.
+ * Copyright © 2020 tastytea <tastytea@tastytea.de>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "api.hpp"
+
+#include <map>
+#include <string_view>
+#include <utility>
+
+namespace mastodonpp
+{
+
+using std::map;
+using std::string_view;
+using std::move;
+
+API::API(endpoint_type &endpoint)
+ : _endpoint{move(endpoint)}
+{}
+
+string API::to_string() const
+{
+ static const map<endpoint_type,string_view> endpoint_map
+ {
+ {v1::instance, "/api/v1/instance"},
+ {v2::search, "/api/v2/search"}
+ };
+ return endpoint_map.at(_endpoint).data();
+}
+} // namespace mastodonpp