1 /*
2     Copyright (C) 2016 Volker Krause <vkrause@kde.org>
3 
4     Permission is hereby granted, free of charge, to any person obtaining
5     a copy of this software and associated documentation files (the
6     "Software"), to deal in the Software without restriction, including
7     without limitation the rights to use, copy, modify, merge, publish,
8     distribute, sublicense, and/or sell copies of the Software, and to
9     permit persons to whom the Software is furnished to do so, subject to
10     the following conditions:
11 
12     The above copyright notice and this permission notice shall be included
13     in all copies or substantial portions of the Software.
14 
15     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23 
24 #ifndef KUSERFEEDBACK_CONSOLE_RESTAPI_H
25 #define KUSERFEEDBACK_CONSOLE_RESTAPI_H
26 
27 class QNetworkReply;
28 template <typename T> class QVector;
29 
30 namespace KUserFeedback {
31 namespace Console {
32 
33 class Product;
34 class RESTClient;
35 class Sample;
36 class Survey;
37 
38 /** C++ wrapper for the server-side API.
39  *  Precondition for all methods is that client->isConnected() returns @c true.
40  */
41 namespace RESTApi
42 {
43     /** Check if server database schema is up-to-date. */
44     QNetworkReply* checkSchema(RESTClient *client);
45 
46     /** List all products. */
47     QNetworkReply* listProducts(RESTClient *client);
48 
49     /** Add a new product.
50      *  @param p The product to add. Must be valid.
51      */
52     QNetworkReply* createProduct(RESTClient *client, const Product &p);
53 
54     /** Update an existing product.
55      *  @param p The product to add. Must be valid.
56      */
57     QNetworkReply* updateProduct(RESTClient *client, const Product &p);
58 
59     /** Deletes a product.
60      *  @param p The product to add. Must be valid.
61      */
62     QNetworkReply* deleteProduct(RESTClient *client, const Product &p);
63 
64     /** Get all samples for a product.
65      *  @param p The product to add. Must be valid.
66      */
67     QNetworkReply* listSamples(RESTClient *client, const Product &p);
68 
69     /** Add the given samples to a product.
70      *  @param p The product to add. Must be valid.
71      */
72     QNetworkReply* addSamples(RESTClient *client, const Product &p, const QVector<Sample> &samples);
73 
74     /** List all surveys for product @p p. */
75     QNetworkReply* listSurveys(RESTClient *client, const Product &p);
76 
77     /** Create a new survey. */
78     QNetworkReply* createSurvey(RESTClient *client, const Product &p, const Survey &s);
79 
80     /** Update an existing survey. */
81     QNetworkReply* updateSurvey(RESTClient *client, const Survey &s);
82 
83     /** Delete a survey. */
84     QNetworkReply* deleteSurvey(RESTClient *client, const Survey &s);
85 }
86 
87 }
88 }
89 
90 #endif // KUSERFEEDBACK_CONSOLE_RESTAPI_H
91