Renamed “Request” to “Connection”.

It will be used not for only one request, but for all requests to an instance.
This commit is contained in:
tastytea 2020-01-05 09:38:13 +01:00
parent edc2bba718
commit f872707036
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
4 changed files with 16 additions and 16 deletions

View File

@ -14,8 +14,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef MASTODONPP_REQUEST_HPP #ifndef MASTODONPP_CONNECTION_HPP
#define MASTODONPP_REQUEST_HPP #define MASTODONPP_CONNECTION_HPP
#include "api.hpp" #include "api.hpp"
#include "curl_wrapper.hpp" #include "curl_wrapper.hpp"
@ -30,23 +30,23 @@ namespace mastodonpp
using std::string; using std::string;
/*! /*!
* @brief Used to make a request to the Mastodon %API. * @brief Represents a connection to an instance. Used for requests.
* *
* @since 0.1.0 * @since 0.1.0
* *
* @headerfile request.hpp mastodonpp/request.hpp * @headerfile connection.hpp mastodonpp/connection.hpp
*/ */
class Request : public CURLWrapper class Connection : public CURLWrapper
{ {
public: public:
/*! /*!
* @brief Construct a new Request object. * @brief Construct a new Connection object.
* *
* @param instance An Instance with the access data. * @param instance An Instance with the access data.
* *
* @since 0.1.0 * @since 0.1.0
*/ */
explicit Request(Instance &instance); explicit Connection(Instance &instance);
/*! /*!
* @brief Make a HTTP GET call. * @brief Make a HTTP GET call.
@ -75,4 +75,4 @@ private:
} // namespace mastodonpp } // namespace mastodonpp
#endif // MASTODONPP_REQUEST_HPP #endif // MASTODONPP_CONNECTION_HPP

View File

@ -20,7 +20,7 @@
#include "api.hpp" #include "api.hpp"
#include "exceptions.hpp" #include "exceptions.hpp"
#include "instance.hpp" #include "instance.hpp"
#include "request.hpp" #include "connection.hpp"
#include "return_types.hpp" #include "return_types.hpp"
/*! /*!

View File

@ -14,23 +14,23 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "request.hpp" #include "connection.hpp"
namespace mastodonpp namespace mastodonpp
{ {
Request::Request(Instance &instance) Connection::Connection(Instance &instance)
: _instance{instance} : _instance{instance}
{} {}
answer_type Request::get(API::endpoint_type endpoint) answer_type Connection::get(API::endpoint_type endpoint)
{ {
answer_type answer; answer_type answer;
answer.body = API{endpoint}.to_string(); answer.body = API{endpoint}.to_string();
return answer; return answer;
} }
answer_type Request::get(string endpoint) answer_type Connection::get(string endpoint)
{ {
answer_type answer; answer_type answer;
answer.body = make_request(http_method::GET, "https://ip.tastytea.de/"); answer.body = make_request(http_method::GET, "https://ip.tastytea.de/");

View File

@ -15,7 +15,7 @@
*/ */
#include "instance.hpp" #include "instance.hpp"
#include "request.hpp" #include "connection.hpp"
#include <catch.hpp> #include <catch.hpp>
@ -48,12 +48,12 @@ SCENARIO ("Instantiations.")
} }
} }
WHEN ("Request is instantiated.") WHEN ("Connection is instantiated.")
{ {
try try
{ {
Instance instance{"example.com", ""}; Instance instance{"example.com", ""};
Request request{instance}; Connection connection{instance};
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {