simplified calls, only 1 type of parameters

This commit is contained in:
tastytea 2018-04-19 00:20:43 +02:00
parent 42dcc47f5b
commit 77b9a66e9c
Signed by: tastytea
GPG Key ID: 59346E0EA35C67E5
6 changed files with 448 additions and 305 deletions

View File

@ -24,46 +24,28 @@ const uint_fast16_t API::del(const Mastodon::API::v1 &call,
const parametermap &parameters)
{
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 &parameters)
{
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 &parameters)
{
parametermap newparameters = parameters;
// Emulate old behaviour
switch (call)
{
default:
newparameters["id"] = { argument };
break;
}
return del(call, parameters);
}

View File

@ -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 &parameters, 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 &parameters, 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 &parameters, 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);
}

View File

@ -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<Mastodon::API::http> &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<http>(*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 &parameters,
string &answer,
std::unique_ptr<Mastodon::API::http> &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<http>(*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<Mastodon::API::http> &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<http>(*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<Mastodon::API::http> &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);
}

View File

@ -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 &parameters, 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 &parameters, 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 &parameters, 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);
}

View File

@ -21,16 +21,25 @@
using namespace Mastodon;
const uint_fast16_t API::put(const Mastodon::API::v1 &call,
const string &argument,
const parametermap &parameters, 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 &parameters, string &answer)
{
parametermap newparameters = parameters;
// Emulate old behaviour
switch (call)
{
default:
newparameters["id"] = { argument };
break;
}
return put(call, newparameters, answer);
}

View File

@ -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 &parameters,
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 &parameters,
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 &parameters,
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 &parameters,
string &answer,
std::unique_ptr<Mastodon::API::http> &ptr);
@ -485,6 +493,26 @@ public:
string &answer,
std::unique_ptr<Mastodon::API::http> &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<Mastodon::API::http> &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 &parameters,
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 &parameters,
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 &parameters,
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 &parameters,
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 &parameters,
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 &parameters);
/*!
* @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 &parameters);
/*!
* @brief Make a custom DELETE request.
*
@ -671,6 +698,38 @@ public:
const parametermap &parameters,
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 &parameters);
private:
const string _instance;
string _access_token;