diff --git a/src/api/delete.cpp b/src/api/delete.cpp index 0ee18ba..02d1d06 100644 --- a/src/api/delete.cpp +++ b/src/api/delete.cpp @@ -24,46 +24,28 @@ const uint_fast16_t API::del(const Mastodon::API::v1 &call, const parametermap ¶meters) { string strcall = ""; + string strid = ""; + + // The ID is part of the path + const auto &it = parameters.find("id"); + if (it != parameters.end()) + { + strid = it->second[0]; + } switch (call) { case v1::domain_blocks: strcall = "/api/v1/domain_blocks"; break; - default: - ttdebug << "ERROR: Invalid call.\n"; - return 11; - break; - } - - string answer; - return _http.request(http::method::DELETE, strcall, - maptoformdata(parameters), answer); -} - -const uint_fast16_t API::del(const Mastodon::API::v1 &call, - const string &argument) -{ - const parametermap p = {}; - return del(call, argument, p); -} -const uint_fast16_t API::del(const Mastodon::API::v1 &call, - const string &argument, - const parametermap ¶meters) -{ - string strcall = ""; - const string argument_encoded = urlencode(argument); - - switch (call) - { case v1::lists_id: - strcall = "/api/v1/lists/" + argument_encoded; + strcall = "/api/v1/lists/" + strid; break; case v1::lists_id_accounts: - strcall = "/api/v1/lists/" + argument_encoded + "/accounts"; + strcall = "/api/v1/lists/" + strid + "/accounts"; break; case v1::statuses_id: - strcall = "/api/v1/statuses/" + argument_encoded; + strcall = "/api/v1/statuses/" + strid; break; default: ttdebug << "ERROR: Invalid call.\n"; @@ -72,8 +54,7 @@ const uint_fast16_t API::del(const Mastodon::API::v1 &call, } string answer; - return _http.request(http::method::DELETE, strcall, - maptoformdata(parameters), answer); + return del(strcall, parameters, answer); } const uint_fast16_t API::del(const std::string &call, @@ -83,3 +64,30 @@ const uint_fast16_t API::del(const std::string &call, return _http.request(http::method::DELETE, call, maptoformdata(parameters), answer); } + + +// ↓↓ DEPRECATED ↓↓ + +const uint_fast16_t API::del(const Mastodon::API::v1 &call, + const string &argument) +{ + const parametermap p = {}; + return del(call, argument, p); +} + +const uint_fast16_t API::del(const Mastodon::API::v1 &call, + const string &argument, + const parametermap ¶meters) +{ + parametermap newparameters = parameters; + + // Emulate old behaviour + switch (call) + { + default: + newparameters["id"] = { argument }; + break; + } + + return del(call, parameters); +} diff --git a/src/api/get.cpp b/src/api/get.cpp index f772f4b..81e1f4d 100644 --- a/src/api/get.cpp +++ b/src/api/get.cpp @@ -21,16 +21,19 @@ using namespace Mastodon; using std::cerr; -const uint_fast16_t API::get(const Mastodon::API::v1 &call, string &answer) -{ - const parametermap p; - return get(call, p, answer); -} - const uint_fast16_t API::get(const Mastodon::API::v1 &call, const parametermap ¶meters, string &answer) { string strcall = ""; + string strid = ""; + + // The ID is part of the path + const auto &it = parameters.find("id"); + if (it != parameters.end()) + { + strid = it->second[0]; + } + switch (call) { case v1::accounts_verify_credentials: @@ -75,11 +78,69 @@ const uint_fast16_t API::get(const Mastodon::API::v1 &call, case v1::accounts_relationships: strcall = "/api/v1/accounts/relationships"; break; + case v1::accounts_id: + strcall = "/api/v1/accounts/" + strid; + break; + case v1::accounts_id_followers: + strcall = "/api/v1/accounts/" + strid + "/followers"; + break; + case v1::accounts_id_following: + strcall = "/api/v1/accounts/" + strid + "/following"; + break; + case v1::accounts_id_statuses: + strcall = "/api/v1/accounts/" + strid + "/statuses"; + break; case v1::accounts_search: strcall = "/api/v1/accounts/search"; break; + case v1::accounts_id_lists: + strcall = "/api/v1/accounts/" + strid + "/lists"; + break; + case v1::lists_id_accounts: + strcall = "/api/v1/lists/" + strid + "/accounts"; + break; + case v1::lists_id: + strcall = "/api/v1/lists/" + strid; + break; + case v1::notifications_id: + strcall = "/api/v1/notifications/" + strid; + break; case v1::search: strcall = "/api/v1/search"; + break; + case v1::statuses_id: + strcall = "/api/v1/statuses/" + strid; + break; + case v1::statuses_id_context: + strcall = "/api/v1/statuses/" + strid + "/context"; + break; + case v1::statuses_id_card: + strcall = "/api/v1/statuses/" + strid + "/card"; + break; + case v1::statuses_id_reblogged_by: + strcall = "/api/v1/statuses/" + strid + "/reblogged_by"; + break; + case v1::statuses_id_favourited_by: + strcall = "/api/v1/statuses/" + strid + "/favourited_by"; + break; + case v1::timelines_tag_hashtag: + { + // The hashtag is part of the path + const auto &it = parameters.find("hashtag"); + if (it != parameters.end()) + { + strcall = "/api/v1/timelines/tag/" + urlencode(it->second[0]); + } + else + { + ttdebug << "ERROR: Invalid call.\n"; + return 11; + } + } + break; + case v1::timelines_list_list_id: + strcall = "/api/v1/timelines/list/" + strid; + break; default: ttdebug << "ERROR: Invalid call.\n"; return 11; @@ -88,10 +149,53 @@ const uint_fast16_t API::get(const Mastodon::API::v1 &call, if (parameters.size() > 0) { - strcall += maptostr(parameters); + // Delete the parameters that are already in strcall + parametermap newparameters = parameters; + newparameters.erase("id"); + newparameters.erase("hashtag"); + strcall += maptostr(newparameters); } - return _http.request(http::method::GET, strcall, answer); + return get(strcall, answer); +} + +const uint_fast16_t API::get(const Mastodon::API::v1 &call, string &answer) +{ + const parametermap p; + return get(call, p, answer); +} + +const uint_fast16_t API::get(const std::string &call, string &answer) +{ + return _http.request(http::method::GET, call, answer); +} + + + +// ↓↓ DEPRECATED ↓↓ + +const uint_fast16_t API::get(const Mastodon::API::v1 &call, + const string &argument, + const parametermap ¶meters, string &answer) +{ + parametermap newparameters = parameters; + + // Emulate old behaviour + switch (call) + { + case v1::search: + case v1::accounts_search: + newparameters["q"] = { argument }; + break; + case v1::timelines_tag_hashtag: + newparameters["hashtag"] = { argument }; + break; + default: + newparameters["id"] = { argument }; + break; + } + + return get(call, newparameters, answer); } const uint_fast16_t API::get(const Mastodon::API::v1 &call, @@ -100,88 +204,3 @@ const uint_fast16_t API::get(const Mastodon::API::v1 &call, const parametermap p; return get(call, argument, p, answer); } -const uint_fast16_t API::get(const Mastodon::API::v1 &call, - const string &argument, - const parametermap ¶meters, string &answer) -{ - string strcall = ""; - bool firstparam = true; - const string argument_encoded = urlencode(argument); - - switch (call) - { - case v1::accounts_id: - strcall = "/api/v1/accounts/" + argument_encoded; - break; - case v1::accounts_id_followers: - strcall = "/api/v1/accounts/" + argument_encoded + "/followers"; - break; - case v1::accounts_id_following: - strcall = "/api/v1/accounts/" + argument_encoded + "/following"; - break; - case v1::accounts_id_statuses: - strcall = "/api/v1/accounts/" + argument_encoded + "/statuses"; - break; - case v1::accounts_relationships: - strcall = "/api/v1/accounts/relationships?id=" + argument_encoded; - firstparam = false; - break; - case v1::accounts_search: - strcall = "/api/v1/accounts/search?q=" + argument_encoded; - firstparam = false; - break; - case v1::accounts_id_lists: - strcall = "/api/v1/accounts/" + argument_encoded + "/lists"; - break; - case v1::lists_id_accounts: - strcall = "/api/v1/lists/" + argument_encoded + "/accounts"; - break; - case v1::lists_id: - strcall = "/api/v1/lists/" + argument_encoded; - break; - case v1::notifications_id: - strcall = "/api/v1/notifications/" + argument_encoded; - break; - case v1::search: - strcall = "/api/v1/search?q=" + argument_encoded; - firstparam = false; - break; - case v1::statuses_id: - strcall = "/api/v1/statuses/" + argument_encoded; - break; - case v1::statuses_id_context: - strcall = "/api/v1/statuses/" + argument_encoded + "/context"; - break; - case v1::statuses_id_card: - strcall = "/api/v1/statuses/" + argument_encoded + "/card"; - break; - case v1::statuses_id_reblogged_by: - strcall = "/api/v1/statuses/" + argument_encoded + "/reblogged_by"; - break; - case v1::statuses_id_favourited_by: - strcall = "/api/v1/statuses/" + argument_encoded + "/favourited_by"; - break; - case v1::timelines_tag_hashtag: - strcall = "/api/v1/timelines/tag/" + argument_encoded; - break; - case v1::timelines_list_list_id: - strcall = "/api/v1/timelines/list/" + argument_encoded; - break; - default: - ttdebug << "ERROR: Invalid call.\n"; - return 11; - break; - } - - if (parameters.size() > 0) - { - strcall += maptostr(parameters, firstparam); - } - - return _http.request(http::method::GET, strcall, answer); -} - -const uint_fast16_t API::get(const std::string &call, string &answer) -{ - return _http.request(http::method::GET, call, answer); -} diff --git a/src/api/get_stream.cpp b/src/api/get_stream.cpp index d7d45c2..2c01d37 100644 --- a/src/api/get_stream.cpp +++ b/src/api/get_stream.cpp @@ -22,32 +22,7 @@ using namespace Mastodon; using std::cerr; const uint_fast16_t API::get_stream(const Mastodon::API::v1 &call, - const string &argument, - string &answer, - std::unique_ptr &ptr) -{ - string strcall = ""; - const string argument_encoded = urlencode(argument); - - switch (call) - { - case v1::streaming_hashtag: - strcall = "/api/v1/streaming/hashtag?tag=" + argument_encoded; - break; - case v1::streaming_list: - strcall = "/api/v1/streaming/list?list=" + argument_encoded; - break; - default: - ttdebug << "ERROR: Invalid call.\n"; - return 11; - break; - } - - ptr = std::make_unique(*this, _instance, _access_token); - return ptr->request(http::method::GET_STREAM, strcall, answer); -} - -const uint_fast16_t API::get_stream(const Mastodon::API::v1 &call, + const parametermap ¶meters, string &answer, std::unique_ptr &ptr) { @@ -64,14 +39,32 @@ const uint_fast16_t API::get_stream(const Mastodon::API::v1 &call, case v1::streaming_public_local: strcall = "/api/v1/streaming/public/local"; break; + case v1::streaming_hashtag: + strcall = "/api/v1/streaming/hashtag"; + break; + case v1::streaming_list: + strcall = "/api/v1/streaming/list"; + break; default: ttdebug << "ERROR: Invalid call.\n"; return 11; break; } - ptr = std::make_unique(*this, _instance, _access_token); - return ptr->request(http::method::GET_STREAM, strcall, answer); + if (parameters.size() > 0) + { + strcall += maptostr(parameters); + } + + return get_stream(strcall, answer, ptr); +} + +const uint_fast16_t API::get_stream(const Mastodon::API::v1 &call, + string &answer, + std::unique_ptr &ptr) +{ + parametermap p = {}; + return get_stream(call, p, answer, ptr); } const uint_fast16_t API::get_stream(const std::string &call, string &answer, @@ -80,3 +73,31 @@ const uint_fast16_t API::get_stream(const std::string &call, string &answer, ptr = std::make_unique(*this, _instance, _access_token); return ptr->request(http::method::GET_STREAM, call, answer); } + + +// ↓↓ DEPRECATED ↓↓ + +const uint_fast16_t API::get_stream(const Mastodon::API::v1 &call, + const string &argument, + string &answer, + std::unique_ptr &ptr) +{ + parametermap parameters; + + // Emulate old behaviour + switch (call) + { + case v1::streaming_hashtag: + parameters["tag"] = { argument }; + break; + case v1::streaming_list: + parameters["list"] = { argument }; + break; + default: + ttdebug << "ERROR: Invalid call.\n"; + return 11; + break; + } + + return get_stream(call, parameters, answer, ptr); +} diff --git a/src/api/post.cpp b/src/api/post.cpp index 98829c4..c344b1f 100644 --- a/src/api/post.cpp +++ b/src/api/post.cpp @@ -20,16 +20,18 @@ using namespace Mastodon; -const uint_fast16_t API::post(const Mastodon::API::v1 &call, string &answer) -{ - const parametermap p; - return post(call, p, answer); -} - const uint_fast16_t API::post(const Mastodon::API::v1 &call, const parametermap ¶meters, string &answer) { string strcall = ""; + string strid = ""; + + // The ID is part of the path + const auto &it = parameters.find("id"); + if (it != parameters.end()) + { + strid = it->second[0]; + } switch (call) { @@ -60,81 +62,56 @@ const uint_fast16_t API::post(const Mastodon::API::v1 &call, case v1::statuses: strcall = "/api/v1/statuses"; break; - default: - ttdebug << "ERROR: Invalid call.\n"; - return 11; - break; - } - - return _http.request(http::method::POST, strcall, - maptoformdata(parameters), answer); -} - -const uint_fast16_t API::post(const Mastodon::API::v1 &call, - const string &argument, string &answer) -{ - const parametermap p; - return post(call, argument, p, answer); -} -const uint_fast16_t API::post(const Mastodon::API::v1 &call, - const string &argument, - const parametermap ¶meters, string &answer) -{ - string strcall = ""; - const string argument_encoded = curlpp::escape(argument); - - switch (call) - { case v1::accounts_id_follow: - strcall = "/api/v1/accounts/" + argument_encoded + "/follow"; + strcall = "/api/v1/accounts/" + strid + "/follow"; break; case v1::accounts_id_unfollow: - strcall = "/api/v1/accounts/" + argument_encoded + "/unfollow"; + strcall = "/api/v1/accounts/" + strid + "/unfollow"; break; case v1::accounts_id_block: - strcall = "/api/v1/accounts/" + argument_encoded + "/block"; + strcall = "/api/v1/accounts/" + strid + "/block"; break; case v1::accounts_id_unblock: - strcall = "/api/v1/accounts/" + argument_encoded + "/unblock"; + strcall = "/api/v1/accounts/" + strid + "/unblock"; break; case v1::accounts_id_mute: - strcall = "/api/v1/accounts/" + argument_encoded + "/mute"; + strcall = "/api/v1/accounts/" + strid + "/mute"; break; case v1::accounts_id_unmute: - strcall = "/api/v1/accounts/" + argument_encoded + "/unmute"; + strcall = "/api/v1/accounts/" + strid + "/unmute"; break; case v1::follow_requests_id_authorize: - strcall = "/api/v1/folow_requests/" + argument_encoded + "/authorize"; + strcall = "/api/v1/folow_requests/" + strid + "/authorize"; break; case v1::follow_requests_id_reject: - strcall = "/api/v1/folow_requests/" + argument_encoded + "/reject"; + strcall = "/api/v1/folow_requests/" + strid + "/reject"; break; case v1::lists_id_accounts: - strcall = "/api/v1/lists/" + argument_encoded + "/accounts"; + strcall = "/api/v1/lists/" + strid + "/accounts"; break; case v1::statuses_id_reblog: - strcall = "/api/v1/statuses/" + argument_encoded + "/reblog"; + strcall = "/api/v1/statuses/" + strid + "/reblog"; break; case v1::statuses_id_unreblog: - strcall = "/api/v1/statuses/" + argument_encoded + "/unreblog"; + strcall = "/api/v1/statuses/" + strid + "/unreblog"; break; case v1::statuses_id_favourite: - strcall = "/api/v1/statuses/" + argument_encoded + "/favourite"; + strcall = "/api/v1/statuses/" + strid + "/favourite"; break; case v1::statuses_id_unfavourite: - strcall = "/api/v1/statuses/" + argument_encoded + "/unfavourite"; + strcall = "/api/v1/statuses/" + strid + "/unfavourite"; break; case v1::statuses_id_pin: - strcall = "/api/v1/statuses/" + argument_encoded + "/pin"; + strcall = "/api/v1/statuses/" + strid + "/pin"; break; case v1::statuses_id_unpin: - strcall = "/api/v1/statuses/" + argument_encoded + "/unpin"; + strcall = "/api/v1/statuses/" + strid + "/unpin"; break; case v1::statuses_id_mute: - strcall = "/api/v1/statuses/" + argument_encoded + "/mute"; + strcall = "/api/v1/statuses/" + strid + "/mute"; break; case v1::statuses_id_unmute: - strcall = "/api/v1/statuses/" + argument_encoded + "/unmute"; + strcall = "/api/v1/statuses/" + strid + "/unmute"; break; default: ttdebug << "ERROR: Invalid call.\n"; @@ -142,8 +119,13 @@ const uint_fast16_t API::post(const Mastodon::API::v1 &call, break; } - return _http.request(http::method::POST, strcall, - maptoformdata(parameters), answer); + return post(strcall, parameters, answer); +} + +const uint_fast16_t API::post(const Mastodon::API::v1 &call, string &answer) +{ + const parametermap p; + return post(call, p, answer); } const uint_fast16_t API::post(const string &call, @@ -153,3 +135,30 @@ const uint_fast16_t API::post(const string &call, return _http.request(http::method::POST, call, maptoformdata(parameters), answer); } + + +// ↓↓ DEPRECATED ↓↓ + +const uint_fast16_t API::post(const Mastodon::API::v1 &call, + const string &argument, + const parametermap ¶meters, string &answer) +{ + parametermap newparameters = parameters; + + // Emulate old behaviour + switch (call) + { + default: + newparameters["id"] = { argument }; + break; + } + + return post(call, newparameters, answer); +} + +const uint_fast16_t API::post(const Mastodon::API::v1 &call, + const string &argument, string &answer) +{ + const parametermap p; + return post(call, argument, p, answer); +} diff --git a/src/api/put.cpp b/src/api/put.cpp index 8847dd8..4110b7d 100644 --- a/src/api/put.cpp +++ b/src/api/put.cpp @@ -21,16 +21,25 @@ using namespace Mastodon; const uint_fast16_t API::put(const Mastodon::API::v1 &call, - const string &argument, const parametermap ¶meters, string &answer) { string strcall = ""; - const string argument_encoded = urlencode(argument); + string strid = ""; + + // The ID is part of the path + const auto &it = parameters.find("id"); + if (it != parameters.end()) + { + strid = it->second[0]; + } switch (call) { case v1::lists_id: - strcall = "/api/v1/lists/" + argument_encoded; + strcall = "/api/v1/lists/" + strid; + break; + case v1::media_id: + strcall = "/api/v1/media/" + strid; break; default: ttdebug << "ERROR: Invalid call.\n"; @@ -38,8 +47,7 @@ const uint_fast16_t API::put(const Mastodon::API::v1 &call, break; } - return _http.request(http::method::PUT, strcall, - maptoformdata(parameters), answer); + return put(strcall, parameters, answer); } const uint_fast16_t API::put(const string &call, @@ -49,3 +57,22 @@ const uint_fast16_t API::put(const string &call, return _http.request(http::method::PUT, call, maptoformdata(parameters), answer); } + + +// ↓↓ DEPRECATED ↓↓ +const uint_fast16_t API::put(const Mastodon::API::v1 &call, + const string &argument, + const parametermap ¶meters, string &answer) +{ + parametermap newparameters = parameters; + + // Emulate old behaviour + switch (call) + { + default: + newparameters["id"] = { argument }; + break; + } + + return put(call, newparameters, answer); +} diff --git a/src/mastodon-cpp.hpp b/src/mastodon-cpp.hpp index 589780f..9cd5f37 100644 --- a/src/mastodon-cpp.hpp +++ b/src/mastodon-cpp.hpp @@ -217,6 +217,8 @@ public: statuses_id_unpin, statuses_id_mute, statuses_id_unmute, + // PUT + media_id, // Streaming streaming_user, streaming_public, @@ -376,22 +378,6 @@ public: */ const uint_fast16_t get(const Mastodon::API::v1 &call, string &answer); - /*! - * @brief Make a GET request which requires a parameter as part of the - * call. - * - * @param call A call defined in Mastodon::API::v1 - * @param argument The parameter that is part of the call - * @param answer The answer from the server. Usually JSON. On error an - * empty string. - * - * @return @ref error "Error code". If the URL has permanently changed, 13 - * is returned and answer is set to the new URL. - */ - const uint_fast16_t get(const Mastodon::API::v1 &call, - const string &argument, - string &answer); - /*! * @brief Make a GET request which requires parameters. * @@ -407,24 +393,6 @@ public: const parametermap ¶meters, string &answer); - /*! - * @brief Make a GET request which requires a parameter as part of the - * call and parameters. - * - * @param call A call defined in Mastodon::API::v1 - * @param argument The parameter that is part of the call - * @param parameters A Mastodon::API::parametermap containing parameters - * @param answer The answer from the server. Usually JSON. On error - * an empty string. - * - * @return @ref error "Error code". If the URL has permanently changed, 13 - * is returned and answer is set to the new URL. - */ - const uint_fast16_t get(const Mastodon::API::v1 &call, - const string &argument, - const parametermap ¶meters, - string &answer); - /*! * @brief Make a custom GET request. * @@ -438,19 +406,59 @@ public: const uint_fast16_t get(const string &call, string &answer); /*! - * @brief Make a streaming GET request. + * @brief Make a GET request which requires a parameter as part of the + * call. * * @param call A call defined in Mastodon::API::v1 * @param argument The parameter that is part of the call - * @param answer The answer from the server. Events with JSON-payload. - * @param ptr Pointer to the http object. Can be used to call - * ptr->abort_stream() + * @param answer The answer from the server. Usually JSON. On error an + * empty string. + * + * @return @ref error "Error code". If the URL has permanently changed, 13 + * is returned and answer is set to the new URL. + * + * @deprecated Will vanish in 1.0.0 + */ + [[deprecated("Will vanish in 1.0.0, use get() without argument instead.")]] + const uint_fast16_t get(const Mastodon::API::v1 &call, + const string &argument, + string &answer); + + /*! + * @brief Make a GET request which requires a parameter as part of the + * call and parameters. + * + * @param call A call defined in Mastodon::API::v1 + * @param argument The parameter that is part of the call + * @param parameters A Mastodon::API::parametermap containing parameters + * @param answer The answer from the server. Usually JSON. On error + * an empty string. + * + * @return @ref error "Error code". If the URL has permanently changed, 13 + * is returned and answer is set to the new URL. + * + * @deprecated Will vanish in 1.0.0 + */ + [[deprecated("Will vanish in 1.0.0, use get() without argument instead.")]] + const uint_fast16_t get(const Mastodon::API::v1 &call, + const string &argument, + const parametermap ¶meters, + string &answer); + + /*! + * @brief Make a streaming GET request. + * + * @param call A call defined in Mastodon::API::v1 + * @param parameters A Mastodon::API::parametermap containing parameters + * @param answer The answer from the server. Events with JSON-payload. + * @param ptr Pointer to the http object. Can be used to call + * ptr->abort_stream() * * @return @ref error "Error code". If the URL has permanently changed, 13 * is returned and answer is set to the new URL. */ const uint_fast16_t get_stream(const Mastodon::API::v1 &call, - const string &argument, + const parametermap ¶meters, string &answer, std::unique_ptr &ptr); @@ -485,6 +493,26 @@ public: string &answer, std::unique_ptr &ptr); + /*! + * @brief Make a streaming GET request. + * + * @param call A call defined in Mastodon::API::v1 + * @param argument The parameter that is part of the call + * @param answer The answer from the server. Events with JSON-payload. + * @param ptr Pointer to the http object. Can be used to call + * ptr->abort_stream() + * + * @return @ref error "Error code". If the URL has permanently changed, 13 + * is returned and answer is set to the new URL. + * + * @deprecated Vill vanish in 1.0.0 + */ + [[deprecated("Will vanish in 1.0.0, use get_stream() without argument instead.")]] + const uint_fast16_t get_stream(const Mastodon::API::v1 &call, + const string &argument, + string &answer, + std::unique_ptr &ptr); + /*! * @brief Make a PATCH request. * @@ -514,22 +542,6 @@ public: */ const uint_fast16_t post(const Mastodon::API::v1 &call, string &answer); - /*! - * @brief Make a POST request which requires a parameter as part of the - * call. - * - * @param call A call defined in Mastodon::API::v1 - * @param argument The parameter that is part of the call - * @param answer The answer from the server. Usually JSON. On error an - * empty string. - * - * @return @ref error "Error code". If the URL has permanently changed, 13 - * is returned and answer is set to the new URL. - */ - const uint_fast16_t post(const Mastodon::API::v1 &call, - const string &argument, - string &answer); - /*! * @brief Make a POST request which requires parameters. * @@ -547,26 +559,6 @@ public: const parametermap ¶meters, string &answer); - /*! - * @brief Make a POST request which requires a parameter as part of the - * call and parameters. - * - * Binary data must be base64-encoded or a filename. - * - * @param call A call defined in Mastodon::API::v1 - * @param argument The parameter that is part of the call - * @param parameters A Mastodon::API::parametermap containing parameters - * @param answer The answer from the server. Usually JSON. On error - * an empty string. - * - * @return @ref error "Error code". If the URL has permanently changed, 13 - * is returned and answer is set to the new URL. - */ - const uint_fast16_t post(const Mastodon::API::v1 &call, - const string &argument, - const parametermap ¶meters, - string &answer); - /*! * @brief Make a custom POST request. * @@ -585,11 +577,51 @@ public: string &answer); /*! - * @brief Make a PUT request which requires a parameter as part of the + * @brief Make a POST request which requires a parameter as part of the + * call. + * + * @param call A call defined in Mastodon::API::v1 + * @param argument The parameter that is part of the call + * @param answer The answer from the server. Usually JSON. On error an + * empty string. + * + * @return @ref error "Error code". If the URL has permanently changed, 13 + * is returned and answer is set to the new URL. + * + * @deprecated Will vanish in 1.0.0 + */ + [[deprecated("Will vanish in 1.0.0, use post() without argument instead.")]] + const uint_fast16_t post(const Mastodon::API::v1 &call, + const string &argument, + string &answer); + + /*! + * @brief Make a POST request which requires a parameter as part of the * call and parameters. * + * Binary data must be base64-encoded or a filename. + * * @param call A call defined in Mastodon::API::v1 * @param argument The parameter that is part of the call + * @param parameters A Mastodon::API::parametermap containing parameters + * @param answer The answer from the server. Usually JSON. On error + * an empty string. + * + * @return @ref error "Error code". If the URL has permanently changed, 13 + * is returned and answer is set to the new URL. + * + * @deprecated Will vanish in 1.0.0 + */ + [[deprecated("Will vanish in 1.0.0, use post() without argument instead.")]] + const uint_fast16_t post(const Mastodon::API::v1 &call, + const string &argument, + const parametermap ¶meters, + string &answer); + + /*! + * @brief Make a PUT request which requires a parameters. + * + * @param call A call defined in Mastodon::API::v1 * @param parameters A Mastodon::API::parametermap containing * parameters * @param answer The answer from the server. Usually JSON. On error @@ -599,7 +631,6 @@ public: * is returned and answer is set to the new URL. */ const uint_fast16_t put(const Mastodon::API::v1 &call, - const string &argument, const parametermap ¶meters, string &answer); @@ -620,16 +651,26 @@ public: string &answer); /*! - * @brief Make a DELETE request which requires a parameter as part of the - * call. + * @brief Make a PUT request which requires a parameter as part of the + * call and parameters. * - * @param call A call defined in Mastodon::API::v1 - * @param argument The parameter that is part of the call + * @param call A call defined in Mastodon::API::v1 + * @param argument The parameter that is part of the call + * @param parameters A Mastodon::API::parametermap containing + * parameters + * @param answer The answer from the server. Usually JSON. On error + * an empty string. * - * @return @ref error "Error code". + * @return @ref error "Error code". If the URL has permanently changed, 13 + * is returned and answer is set to the new URL. + * + * @deprecated Will vanish in 1.0.0 */ - const uint_fast16_t del(const Mastodon::API::v1 &call, - const string &argument); + [[deprecated("Will vanish in 1.0.0, use put() without argument instead.")]] + const uint_fast16_t put(const Mastodon::API::v1 &call, + const string &argument, + const parametermap ¶meters, + string &answer); /*! * @brief Make a DELETE request which requires parameters. @@ -642,20 +683,6 @@ public: const uint_fast16_t del(const Mastodon::API::v1 &call, const parametermap ¶meters); - /*! - * @brief Make a DELETE request which requires a parameter as part of the - * call and parameters. - * - * @param call A call defined in Mastodon::API::v1 - * @param argument The parameter that is part of the call - * @param parameters A Mastodon::API::parametermap containing parameters - * - * @return @ref error "Error code". - */ - const uint_fast16_t del(const Mastodon::API::v1 &call, - const string &argument, - const parametermap ¶meters); - /*! * @brief Make a custom DELETE request. * @@ -671,6 +698,38 @@ public: const parametermap ¶meters, string &answer); + /*! + * @brief Make a DELETE request which requires a parameter as part of the + * call. + * + * @param call A call defined in Mastodon::API::v1 + * @param argument The parameter that is part of the call + * + * @return @ref error "Error code". + * + * @deprecated Will vanish in 1.0.0 + */ + [[deprecated("Will vanish in 1.0.0, use del() without argument instead.")]] + const uint_fast16_t del(const Mastodon::API::v1 &call, + const string &argument); + + /*! + * @brief Make a DELETE request which requires a parameter as part of the + * call and parameters. + * + * @param call A call defined in Mastodon::API::v1 + * @param argument The parameter that is part of the call + * @param parameters A Mastodon::API::parametermap containing parameters + * + * @return @ref error "Error code". + * + * @deprecated Will vanish in 1.0.0 + */ + [[deprecated("Will vanish in 1.0.0, use del() without argument instead.")]] + const uint_fast16_t del(const Mastodon::API::v1 &call, + const string &argument, + const parametermap ¶meters); + private: const string _instance; string _access_token;