summaryrefslogtreecommitdiff
path: root/qicclient.hxx
blob: 3b7f0d58f21c5be6bf183d17e90f478d8e7b8c9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef QICCLIENT_HXX
#define QICCLIENT_HXX

#include <QObject>
#include "qicclient/catalog.hxx"
#include <icclient.h>

namespace QICClient {

	using std::shared_ptr;
	class Ord;

	class Client : public QObject
	{
		Q_OBJECT

		public:
			/*!
			 * \brief Constructor.
			 * \param sampleURL The value of the SAMPLEURL setting in products/variable.txt.
			 * \param image_Dir The value of the IMAGE_DIR setting in products/variable.txt.
			 * \param certificate Path to the CA certificate file.
			 */
			Client(char const* sampleURL, char const* image_Dir, char const* certificate = nullptr);
			/*!
			 * \brief Destructor.
			 */
			~Client();
			/*!
			 * \brief For fetching data about a specific product.
			 * \param sku The SKU of the item to order.
			 * \param handler A pointer to a cURL write function callback.
			 */
			void flyPage(QString const& sku, void (*handler)(icclient_response*));
			/*!
			 * \brief For putting an item to a cart.
			 * \param sku The SKU of the item to order.
			 * \param catalog The catalog from which the item is.
			 * \param order The order.
			 */
			void order(QString const& sku, Catalog const& catalog, Ord& order);
			void emitResults(QString const& response);
			void emitCatalog(Catalog* catalog);

		public slots:
			/*!
			 * \brief For fetching products that belong a specific group.
			 * \param prodGroup The name of the product group.
			 */
			void results(QString const& prodGroup);
			/*!
			 * \brief For fetching data about all active products.
			 */
			void allProducts();
			/*!
			 * \brief For fetching products that belong a specific group.
			 * \param prodGroup The name of the product group.
			 * \param handler A C style pointer to function for custom handling.
			 */
			void strapResults(QString const& prodGroup);
			/*!
			 * \brief For fetching data about all active products.
			 */
			void strapAllProducts();

		signals:
			void gotResults(QString const& results);
			void gotCatalog(Catalog* catalog);
			void gotFlyPage(shared_ptr<Product> product);
	};

}

#endif