Browse Source

Parameter support, added documentation.

tastytea 11 months ago
parent
commit
46c67052ab
Signed by: tastytea <tastytea@tastytea.de> GPG Key ID: 59346E0EA35C67E5
9 changed files with 414 additions and 93 deletions
  1. 1
    0
      .gitignore
  2. 1
    1
      CMakeLists.txt
  3. 198
    0
      Doxyfile
  4. 8
    9
      README.md
  5. 9
    0
      build.sh
  6. 8
    0
      build_doc.sh
  7. 17
    0
      src/api_get.cpp
  8. 10
    1
      src/example/example.cpp
  9. 162
    82
      src/mastodon-cpp.hpp

+ 1
- 0
.gitignore View File

@@ -1 +1,2 @@
1 1
 /build/
2
+/doc/

+ 1
- 1
CMakeLists.txt View File

@@ -1,6 +1,6 @@
1 1
 cmake_minimum_required (VERSION 3.7)
2 2
 project (mastodon-cpp
3
-         VERSION 0.0.2
3
+         VERSION 0.0.3
4 4
          LANGUAGES CXX
5 5
 )
6 6
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")

+ 198
- 0
Doxyfile View File

@@ -0,0 +1,198 @@
1
+DOXYFILE_ENCODING      = UTF-8
2
+PROJECT_NAME           = "mastodon-cpp"
3
+PROJECT_NUMBER         = 0.0.0
4
+INPUT                  = README.md src/mastodon-cpp.hpp
5
+USE_MDFILE_AS_MAINPAGE = README.md
6
+CREATE_SUBDIRS         = NO
7
+ALLOW_UNICODE_NAMES    = YES
8
+OUTPUT_LANGUAGE        = English
9
+BRIEF_MEMBER_DESC      = YES
10
+REPEAT_BRIEF           = YES
11
+ALWAYS_DETAILED_SEC    = NO
12
+INLINE_INHERITED_MEMB  = NO
13
+FULL_PATH_NAMES        = YES
14
+SHORT_NAMES            = NO
15
+JAVADOC_AUTOBRIEF      = NO
16
+QT_AUTOBRIEF           = NO
17
+MULTILINE_CPP_IS_BRIEF = NO
18
+INHERIT_DOCS           = YES
19
+SEPARATE_MEMBER_PAGES  = NO
20
+TAB_SIZE               = 4
21
+OPTIMIZE_OUTPUT_FOR_C  = NO
22
+OPTIMIZE_OUTPUT_JAVA   = NO
23
+OPTIMIZE_FOR_FORTRAN   = NO
24
+OPTIMIZE_OUTPUT_VHDL   = NO
25
+MARKDOWN_SUPPORT       = YES
26
+AUTOLINK_SUPPORT       = YES
27
+BUILTIN_STL_SUPPORT    = NO
28
+CPP_CLI_SUPPORT        = NO
29
+SIP_SUPPORT            = NO
30
+IDL_PROPERTY_SUPPORT   = YES
31
+DISTRIBUTE_GROUP_DOC   = NO
32
+GROUP_NESTED_COMPOUNDS = NO
33
+SUBGROUPING            = YES
34
+INLINE_GROUPED_CLASSES = NO
35
+INLINE_SIMPLE_STRUCTS  = NO
36
+TYPEDEF_HIDES_STRUCT   = NO
37
+LOOKUP_CACHE_SIZE      = 0
38
+EXTRACT_ALL            = NO
39
+EXTRACT_PRIVATE        = NO
40
+EXTRACT_PACKAGE        = NO
41
+EXTRACT_STATIC         = NO
42
+EXTRACT_LOCAL_CLASSES  = YES
43
+EXTRACT_LOCAL_METHODS  = NO
44
+EXTRACT_ANON_NSPACES   = NO
45
+HIDE_UNDOC_MEMBERS     = NO
46
+HIDE_UNDOC_CLASSES     = NO
47
+HIDE_FRIEND_COMPOUNDS  = NO
48
+HIDE_IN_BODY_DOCS      = NO
49
+INTERNAL_DOCS          = NO
50
+CASE_SENSE_NAMES       = YES
51
+HIDE_SCOPE_NAMES       = NO
52
+HIDE_COMPOUND_REFERENCE= NO
53
+SHOW_INCLUDE_FILES     = YES
54
+SHOW_GROUPED_MEMB_INC  = NO
55
+FORCE_LOCAL_INCLUDES   = NO
56
+INLINE_INFO            = YES
57
+SORT_MEMBER_DOCS       = YES
58
+SORT_BRIEF_DOCS        = NO
59
+SORT_MEMBERS_CTORS_1ST = NO
60
+SORT_GROUP_NAMES       = NO
61
+SORT_BY_SCOPE_NAME     = NO
62
+STRICT_PROTO_MATCHING  = NO
63
+GENERATE_TODOLIST      = YES
64
+GENERATE_TESTLIST      = YES
65
+GENERATE_BUGLIST       = YES
66
+GENERATE_DEPRECATEDLIST= YES
67
+MAX_INITIALIZER_LINES  = 30
68
+SHOW_USED_FILES        = YES
69
+SHOW_FILES             = YES
70
+SHOW_NAMESPACES        = YES
71
+QUIET                  = NO
72
+WARNINGS               = YES
73
+WARN_IF_UNDOCUMENTED   = YES
74
+WARN_IF_DOC_ERROR      = YES
75
+WARN_NO_PARAMDOC       = NO
76
+WARN_FORMAT            = "$file:$line: $text"
77
+INPUT_ENCODING         = UTF-8
78
+RECURSIVE              = NO
79
+EXCLUDE_SYMLINKS       = NO
80
+EXAMPLE_PATH           = examples
81
+EXAMPLE_RECURSIVE      = NO
82
+FILTER_SOURCE_FILES    = NO
83
+SOURCE_BROWSER         = NO
84
+INLINE_SOURCES         = YES
85
+STRIP_CODE_COMMENTS    = YES
86
+REFERENCED_BY_RELATION = NO
87
+REFERENCES_RELATION    = NO
88
+REFERENCES_LINK_SOURCE = YES
89
+SOURCE_TOOLTIPS        = YES
90
+USE_HTAGS              = NO
91
+VERBATIM_HEADERS       = YES
92
+CLANG_ASSISTED_PARSING = NO
93
+ALPHABETICAL_INDEX     = YES
94
+COLS_IN_ALPHA_INDEX    = 5
95
+GENERATE_HTML          = YES
96
+HTML_OUTPUT            = doc/html
97
+HTML_FILE_EXTENSION    = .html
98
+HTML_COLORSTYLE_HUE    = 220
99
+HTML_COLORSTYLE_SAT    = 100
100
+HTML_COLORSTYLE_GAMMA  = 80
101
+HTML_TIMESTAMP         = NO
102
+HTML_DYNAMIC_SECTIONS  = NO
103
+HTML_INDEX_NUM_ENTRIES = 100
104
+GENERATE_DOCSET        = NO
105
+DOCSET_FEEDNAME        = "Doxygen generated docs"
106
+DOCSET_BUNDLE_ID       = org.doxygen.Project
107
+DOCSET_PUBLISHER_ID    = org.doxygen.Publisher
108
+DOCSET_PUBLISHER_NAME  = Publisher
109
+GENERATE_HTMLHELP      = NO
110
+GENERATE_CHI           = NO
111
+BINARY_TOC             = NO
112
+TOC_EXPAND             = NO
113
+GENERATE_QHP           = NO
114
+QHP_NAMESPACE          = org.doxygen.Project
115
+QHP_VIRTUAL_FOLDER     = doc
116
+GENERATE_ECLIPSEHELP   = NO
117
+ECLIPSE_DOC_ID         = org.doxygen.Project
118
+DISABLE_INDEX          = NO
119
+GENERATE_TREEVIEW      = NO
120
+ENUM_VALUES_PER_LINE   = 4
121
+TREEVIEW_WIDTH         = 250
122
+EXT_LINKS_IN_WINDOW    = NO
123
+FORMULA_FONTSIZE       = 10
124
+FORMULA_TRANSPARENT    = YES
125
+USE_MATHJAX            = NO
126
+MATHJAX_FORMAT         = HTML-CSS
127
+MATHJAX_RELPATH        = http://cdn.mathjax.org/mathjax/latest
128
+SEARCHENGINE           = YES
129
+SERVER_BASED_SEARCH    = NO
130
+EXTERNAL_SEARCH        = NO
131
+SEARCHDATA_FILE        = searchdata.xml
132
+GENERATE_LATEX         = NO
133
+LATEX_OUTPUT           = latex
134
+LATEX_CMD_NAME         = latex
135
+MAKEINDEX_CMD_NAME     = makeindex
136
+COMPACT_LATEX          = NO
137
+PAPER_TYPE             = a4
138
+PDF_HYPERLINKS         = YES
139
+USE_PDFLATEX           = YES
140
+LATEX_BATCHMODE        = NO
141
+LATEX_HIDE_INDICES     = NO
142
+LATEX_SOURCE_CODE      = NO
143
+LATEX_BIB_STYLE        = plain
144
+GENERATE_RTF           = NO
145
+RTF_OUTPUT             = rtf
146
+COMPACT_RTF            = NO
147
+RTF_HYPERLINKS         = NO
148
+RTF_SOURCE_CODE        = NO
149
+GENERATE_MAN           = NO
150
+MAN_OUTPUT             = man
151
+MAN_EXTENSION          = .3
152
+MAN_SUBDIR             =
153
+MAN_LINKS              = NO
154
+GENERATE_XML           = NO
155
+XML_OUTPUT             = xml
156
+XML_PROGRAMLISTING     = YES
157
+GENERATE_DOCBOOK       = NO
158
+DOCBOOK_OUTPUT         = docbook
159
+DOCBOOK_PROGRAMLISTING = NO
160
+GENERATE_AUTOGEN_DEF   = NO
161
+GENERATE_PERLMOD       = NO
162
+PERLMOD_LATEX          = NO
163
+PERLMOD_PRETTY         = YES
164
+ENABLE_PREPROCESSING   = YES
165
+MACRO_EXPANSION        = NO
166
+EXPAND_ONLY_PREDEF     = NO
167
+SEARCH_INCLUDES        = YES
168
+SKIP_FUNCTION_MACROS   = YES
169
+ALLEXTERNALS           = NO
170
+EXTERNAL_GROUPS        = YES
171
+EXTERNAL_PAGES         = YES
172
+PERL_PATH              = /usr/bin/perl
173
+CLASS_DIAGRAMS         = YES
174
+HIDE_UNDOC_RELATIONS   = YES
175
+HAVE_DOT               = NO
176
+DOT_NUM_THREADS        = 0
177
+DOT_FONTNAME           = Helvetica
178
+DOT_FONTSIZE           = 10
179
+CLASS_GRAPH            = YES
180
+COLLABORATION_GRAPH    = YES
181
+GROUP_GRAPHS           = YES
182
+UML_LOOK               = NO
183
+UML_LIMIT_NUM_FIELDS   = 10
184
+TEMPLATE_RELATIONS     = NO
185
+INCLUDE_GRAPH          = YES
186
+INCLUDED_BY_GRAPH      = YES
187
+CALL_GRAPH             = NO
188
+CALLER_GRAPH           = NO
189
+GRAPHICAL_HIERARCHY    = YES
190
+DIRECTORY_GRAPH        = YES
191
+DOT_IMAGE_FORMAT       = png
192
+INTERACTIVE_SVG        = NO
193
+DOT_GRAPH_MAX_NODES    = 50
194
+MAX_DOT_GRAPH_DEPTH    = 0
195
+DOT_TRANSPARENT        = NO
196
+DOT_MULTI_TARGETS      = NO
197
+GENERATE_LEGEND        = YES
198
+DOT_CLEANUP            = YES

+ 8
- 9
README.md View File

@@ -1,6 +1,6 @@
1
-**mastodon-cpp** is a CPP wrapper for the Mastodon API. The aim is to be as simple as possible.
1
+**mastodon-cpp** is a C++ wrapper for the Mastodon API. The aim is to be as simple as possible.
2 2
 The library takes care of the network stuff. You submit a query and get the raw JSON.
3
-All versions below 1.0.0 (SOVERSION 0) are considered insecure, unstable and can change drastically any time.
3
+All versions below 1.0.0 (SOVERSION 0) are considered insecure, unstable and can change any time.
4 4
 
5 5
 # Install
6 6
 ## Dependencies
@@ -8,6 +8,7 @@ All versions below 1.0.0 (SOVERSION 0) are considered insecure, unstable and can
8 8
  * C++ compiler (tested: gcc 6.4)
9 9
  * [cmake](https://cmake.org/) (tested: 3.9.6)
10 10
  * [boost](http://www.boost.org/) (tested: 1.63.0)
11
+ * Optional: [doxygen](https://www.stack.nl/~dimitri/doxygen/) (tested: 1.8.13)
11 12
 
12 13
 ## Get sourcecode
13 14
 ### Development version
@@ -20,15 +21,12 @@ All versions below 1.0.0 (SOVERSION 0) are considered insecure, unstable and can
20 21
     make
21 22
 
22 23
 # Usage
23
-    Mastodon::API masto("social.example.com", "access token");
24
-    std::cout << masto.get(Mastodon::API::v1::timelines_home) << '\n';
25
-    std::cout << masto.get(Mastodon::API::v1::accounts_id, "12345") << '\n';
26 24
 
27
-There is an example in `src/example`.
25
+The reference can be generated with `build_doc.sh`, if doxygen is installed. Or just look in `src/mastodon-cpp.hpp`. There is an example in `src/example`.
28 26
 
29 27
 # TODO
30 28
  * Version 0.1.0
31
-    * [ ] Implement all GET methods
29
+    * [x] Implement all GET methods
32 30
     * [ ] Proper error handling
33 31
     * [x] Network stuff
34 32
     * [ ] Comprehensive example
@@ -37,8 +35,8 @@ There is an example in `src/example`.
37 35
      * [ ] Implement all POST methods
38 36
      * [ ] Implement all DELETE methods
39 37
  * Later
40
-    [ ] Escape user input
41
-    [ ] Asynchronous I/O
38
+    * [ ] Escape user input
39
+    * [ ] Asynchronous I/O
42 40
 
43 41
 ## Status of implementation
44 42
  * [x] GET /api/v1/accounts/:id
@@ -108,6 +106,7 @@ There is an example in `src/example`.
108 106
 [Full reference](https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md)
109 107
 
110 108
 # Copyright
109
+
111 110
     Copyright © 2018 tastytea <tastytea@tastytea.de>.
112 111
     License GPLv3: GNU GPL version 3 <https://www.gnu.org/licenses/gpl-3.0.html>.
113 112
     This program comes with ABSOLUTELY NO WARRANTY. This is free software,

+ 9
- 0
build.sh View File

@@ -0,0 +1,9 @@
1
+#!/bin/sh
2
+mkdir -p build && \
3
+cd build/ &&
4
+cmake .. && \
5
+make
6
+
7
+if [ "$(basename ${PWD})" == "build" ]; then
8
+    cd ..
9
+fi

+ 8
- 0
build_doc.sh View File

@@ -0,0 +1,8 @@
1
+#!/bin/sh
2
+
3
+if [ -f Doxyfile ]; then
4
+    mkdir -p doc
5
+    (cat Doxyfile && echo -n "PROJECT_NUMBER = " &&
6
+       grep -Eo '[0-9]+.[0-9]+.[0-9]+$' CMakeLists.txt) \
7
+       | doxygen -
8
+fi

+ 17
- 0
src/api_get.cpp View File

@@ -95,6 +95,8 @@ const string API::get(const Mastodon::API::v1 &call,
95 95
                       const std::vector<string> &parameters)
96 96
 {
97 97
     string strcall = "";
98
+    char delim = '?';
99
+
98 100
     switch (call)
99 101
     {
100 102
         case v1::accounts_id:
@@ -111,9 +113,11 @@ const string API::get(const Mastodon::API::v1 &call,
111 113
             break;
112 114
         case v1::accounts_relationships:
113 115
             strcall = "/api/v1/accounts/relationships?id=" + argument;
116
+            delim = '&';
114 117
             break;
115 118
         case v1::accounts_search:
116 119
             strcall = "/api/v1/accounts/search?q=" + argument;
120
+            delim = '&';
117 121
             break;
118 122
         case v1::accounts_id_lists:
119 123
             strcall = "/api/v1/accounts/" + argument + "/lists";
@@ -129,6 +133,7 @@ const string API::get(const Mastodon::API::v1 &call,
129 133
             break;
130 134
         case v1::search:
131 135
             strcall = "/api/v1/search?q=" + argument;
136
+            delim = '&';
132 137
             break;
133 138
         case v1::statuses_id:
134 139
             strcall = "/api/v1/statuses/" + argument;
@@ -157,6 +162,18 @@ const string API::get(const Mastodon::API::v1 &call,
157 162
             break;
158 163
     }
159 164
 
165
+    if (parameters.size() > 0)
166
+    {
167
+        for (const string p : parameters)
168
+        {
169
+            strcall += delim + p;
170
+            if (delim == '?')
171
+            {
172
+                delim = '&';
173
+            }
174
+        }
175
+    }
176
+
160 177
     string answer;
161 178
     _http.request_sync(http::method::GET, strcall, answer);
162 179
     return answer;

+ 10
- 1
src/example/example.cpp View File

@@ -2,6 +2,8 @@
2 2
  */
3 3
 
4 4
 #include <iostream>
5
+#include <vector>
6
+#include <string>
5 7
 #include "../mastodon-cpp.hpp"
6 8
 
7 9
 using Mastodon::API;
@@ -16,5 +18,12 @@ int main(int argc, char *argv[])
16 18
 
17 19
     Mastodon::API masto(argv[1], argv[2]);
18 20
 
19
-    std::cout << masto.get(API::v1::timelines_tag_hashtag, "FOSS") << '\n';
21
+    std::vector<std::string> parameters =
22
+    {
23
+        "limit=2",
24
+        "only_media=1"
25
+    };
26
+    std::cout << 
27
+        masto.get(API::v1::accounts_id_statuses, "44897", parameters) <<
28
+        '\n';
20 29
 }

+ 162
- 82
src/mastodon-cpp.hpp View File

@@ -25,97 +25,177 @@
25 25
 
26 26
 namespace Mastodon
27 27
 {
28
-    class API
28
+class API
29
+{
30
+public:
31
+    /*!
32
+     *  @brief  A list of all API calls.
33
+     *
34
+     *          The original `/` are substituted by `_`. Currently only GET
35
+     *          requests.
36
+     */
37
+    enum class v1
38
+    {
39
+        accounts_id,
40
+        accounts_verify_credentials,
41
+        accounts_id_followers,
42
+        accounts_id_following,
43
+        accounts_id_statuses,
44
+        accounts_relationships,
45
+        accounts_search,
46
+        blocks,
47
+        domain_blocks,
48
+        favourites,
49
+        follow_requests,
50
+        instance,
51
+        custom_emojis,
52
+        lists,
53
+        accounts_id_lists,
54
+        lists_id_accounts,
55
+        lists_id,
56
+        mutes,
57
+        notifications,
58
+        notifications_id,
59
+        reports,
60
+        search,
61
+        statuses_id,
62
+        statuses_id_context,
63
+        statuses_id_card,
64
+        statuses_id_reblogged_by,
65
+        statuses_id_favourited_by,
66
+        timelines_home,
67
+        timelines_public,
68
+        timelines_tag_hashtag,
69
+        timelines_list_list_id
70
+    };
71
+
72
+    /*!
73
+     *  @brief  Constructs a new API object.
74
+     *
75
+     *  @param  instance      The hostname of your instance
76
+     *  @param  access_token  Your access token. You have to generate it
77
+     *                        manually for now.
78
+     */
79
+    explicit API(const std::string &instance,
80
+                 const std::string &access_token);
81
+
82
+    /*!
83
+     *  @brief  Make a GET request which doesn't require an argument.
84
+     *
85
+     *  @param  call    A call defined in Mastodon::API::v1
86
+     *
87
+     *  @return The answer from the server. Usually JSON.
88
+     */
89
+    const std::string get(const Mastodon::API::v1 &call);
90
+
91
+    /*!
92
+     *  @brief  Make a GET request which requires an argument
93
+     *
94
+     *  @param  call      A call defined in Mastodon::API::v1
95
+     *  @param  argument  The non-optional argument
96
+     *
97
+     *  @return The answer from the server. Usually JSON.
98
+     */
99
+    const std::string get(const Mastodon::API::v1 &call,
100
+                          const std::string &argument);
101
+
102
+    /*!
103
+     *  @brief  Make a GET request which doesn't require an argument, pass
104
+     *          optional parameters.
105
+     *
106
+     *  @param  call        A call defined in Mastodon::API::v1
107
+     *  @param  parameters  A std::vector containing optional parameters in the
108
+     *                      form `field=value`
109
+     *
110
+     *  @return The answer from the server. Usually JSON.
111
+     */
112
+    const std::string get(const Mastodon::API::v1 &call,
113
+                          const std::vector<std::string> &parameters);
114
+
115
+    /*!
116
+     *  @brief  Make a GET request which requires an argument, pass optional
117
+     *          parameters.
118
+     *
119
+     *          Example:
120
+     *
121
+     *              Mastodon::API masto(argv[1], argv[2]);
122
+     *             std::vector<std::string> parameters =
123
+     *             {
124
+     *                 "limit=2",
125
+     *                 "only_media=1"
126
+     *             };
127
+     *             masto.get(Mastodon::API::v1::accounts_id_statuses, "12345", parameters);
128
+     *
129
+     *  @param  call        A call defined in Mastodon::API::v1
130
+     *  @param  argument    The non-optional argument
131
+     *  @param  parameters  A std::vector containing optional parameters in the
132
+     *                      form `field=value`
133
+     *
134
+     *  @return The answer from the server. Usually JSON.
135
+     */
136
+    const std::string get(const Mastodon::API::v1 &call,
137
+                          const std::string &argument,
138
+                          const std::vector<std::string> &parameters);
139
+
140
+    /*!
141
+     *  @brief  Make a custom GET request.
142
+     *
143
+     *  @param  call    String in the form `/api/v1/example`
144
+     *
145
+     *  @return The answer from the server. Usually JSON.
146
+     */
147
+    const std::string get(const std::string &call);
148
+
149
+    /*!
150
+     *  @brief  Sets the useragent. Default is mastodon-cpp/version.
151
+     *
152
+     *  @param  useragent  The useragent
153
+     */
154
+    const void set_useragent(const std::string &useragent);
155
+
156
+    /*!
157
+     *  @brief  Gets the useragent.
158
+     *
159
+     *  @return The useragent.
160
+     */
161
+    const std::string get_useragent() const;
162
+
163
+private:
164
+    const std::string _instance;
165
+    const std::string _access_token;
166
+    std::string _useragent;
167
+
168
+    class http
29 169
     {
30 170
     public:
31
-        enum class v1
171
+        enum class method
32 172
         {
33
-            accounts_id,
34
-            accounts_verify_credentials,
35
-            accounts_id_followers,
36
-            accounts_id_following,
37
-            accounts_id_statuses,
38
-            accounts_relationships,
39
-            accounts_search,
40
-            blocks,
41
-            domain_blocks,
42
-            favourites,
43
-            follow_requests,
44
-            instance,
45
-            custom_emojis,
46
-            lists,
47
-            accounts_id_lists,
48
-            lists_id_accounts,
49
-            lists_id,
50
-            mutes,
51
-            notifications,
52
-            notifications_id,
53
-            reports,
54
-            search,
55
-            statuses_id,
56
-            statuses_id_context,
57
-            statuses_id_card,
58
-            statuses_id_reblogged_by,
59
-            statuses_id_favourited_by,
60
-            timelines_home,
61
-            timelines_public,
62
-            timelines_tag_hashtag,
63
-            timelines_list_list_id
173
+            GET,
174
+            PATCH,
175
+            POST,
176
+            DELETE
64 177
         };
65 178
 
66
-        explicit API(const std::string &instance,
67
-                     const std::string &access_token);
68
-        // Select one of the predefined methods.
69
-        const std::string get(const Mastodon::API::v1 &call);
70
-        const std::string get(const Mastodon::API::v1 &call,
71
-                              const std::vector<std::string> &parameters);
72
-        const std::string get(const Mastodon::API::v1 &call,
73
-                              const std::string &argument,
74
-                              const std::vector<std::string> &parameters);
75
-        const std::string get(const Mastodon::API::v1 &call,
76
-                              const std::string &argument);
77
-        // Supply a custom call as string.
78
-        const std::string get(const std::string &call);
79
-
80
-        const void set_useragent(const std::string &useragent);
81
-        const std::string get_useragent() const;
179
+        explicit http(const API &api, const std::string &instance,
180
+                      const std::string &access_token);
181
+        const std::uint16_t request_sync(const method &meth,
182
+                                         const std::string &path,
183
+                                         std::string &answer);
184
+        const std::uint16_t request_sync(const method &meth,
185
+                                         const std::string &path,
186
+                                         const std::string &data,
187
+                                         std::string &answer);
82 188
 
83 189
     private:
190
+        const API &parent;
84 191
         const std::string _instance;
85 192
         const std::string _access_token;
86
-        std::string _useragent;
87
-
88
-        class http
89
-        {
90
-        public:
91
-            enum class method
92
-            {
93
-                GET,
94
-                PATCH,
95
-                POST,
96
-                DELETE
97
-            };
98
-
99
-            explicit http(const API &api, const std::string &instance,
100
-                          const std::string &access_token);
101
-            const std::uint16_t request_sync(const method &meth,
102
-                                             const std::string &path,
103
-                                             std::string &answer);
104
-            const std::uint16_t request_sync(const method &meth,
105
-                                             const std::string &path,
106
-                                             const std::string &data,
107
-                                             std::string &answer);
108
-
109
-        private:
110
-            const API &parent;
111
-            const std::string _instance;
112
-            const std::string _access_token;
113
-            boost::asio::ssl::context _ctx;
114
-            boost::asio::io_service _io_service;
115
-            boost::asio::ip::tcp::resolver _resolver;
116
-            boost::asio::ssl::stream<boost::asio::ip::tcp::socket> _socket;
117
-        } _http;
118
-    };
193
+        boost::asio::ssl::context _ctx;
194
+        boost::asio::io_service _io_service;
195
+        boost::asio::ip::tcp::resolver _resolver;
196
+        boost::asio::ssl::stream<boost::asio::ip::tcp::socket> _socket;
197
+    } _http;
198
+};
119 199
 }
120 200
 
121 201
 #endif

Loading…
Cancel
Save