/* This file is part of mastodon-cpp. * Copyright © 2019 tastytea * * 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 . */ #ifndef MASTODON_CPP_TYPES_HPP #define MASTODON_CPP_TYPES_HPP #include #include #include using std::string; using std::vector; namespace Mastodon { /*! * @brief A single parameter. * * @param key The key as a string. * @param values The values as a vector of strings. * * @since 0.100.0 */ typedef struct param { string key; vector values; /*! @brief Returns key */ operator const string() const; } param; /*! * @brief Vector of Mastodon::param, used for passing parameters in calls. * * The only difference to a std::vector is the added member find. * * Example: * @code * parameters p = * { * { "media_ids", { "1234", "4321" } }, * { "status", { "Hello world!" } } * }; * @endcode * * @since 0.100.0 */ typedef struct parameters : public vector { using vector::vector; /*! * @brief Get iterator to element with key. * * Searches parameters for an element with a key equivalent to key and * returns an iterator to it if found, otherwise it returns an iterator * to parameters::end(). * * @param key String to search for. * * @return Iterator to element with key or parameters::end(). * * @since 0.100.0 */ const std::vector::const_iterator find(const string &key) const; } parameters; /*! * @brief HTTP methods. Used in API calls. * * @since 0.100.0 */ enum class http_method { GET, PATCH, POST, PUT, DELETE, GET_STREAM }; enum class error { OK = 0, INVALID_ARGUMENT = 1, URL_CHANGED = 10, CONNECTION_TIMEOUT = 11, CONNECTION_REFUSED = 12, DNS = 13, ENCRYPTION = 14, UNKNOWN = 127 }; } #endif // MASTODON_CPP_TYPES_HPP