summaryrefslogtreecommitdiff
path: root/interchange.hxx
blob: cdd3e9a2f040aa1f13e6da524d51beac8a1ec7a0 (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef INTERCHANGE_HXX
#define INTERCHANGE_HXX

#include <QObject>
#include "interchange/catalog.hxx"

namespace QInterchange {

	class Ord;

	class Interchange : 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 cookie Path to the cookie file.
			 * \param certificate Path to the CA certificate file.
			 */
			Interchange(const char* sampleURL,
					const char* image_Dir,
					const QString& cookie = "",
					const QString& certificate = "");
			/*!
			 * \brief Destructor.
			 */
			~Interchange();

		public slots:
			/*!
			 * \brief Generic function for fetching data using
			 * a relative path.
			 * \param path The path.
			 */
			void page(QString const& path);
			/*!
			 * \brief For fetching products that belong a specific group.
			 * \param prodGroup The name of the product group.
			 */
			void catalog(QString const& prodGroup);
			/*!
			 * \brief For fetching data about all active products.
			 */
			void allProducts();
			/*!
			 * \brief For fetching data about a specific product.
			 * \param sku The SKU of the item to order.
			 */
			void product(QString const& sku);
			/*!
			 * \brief For fetching products that belong a specific group.
			 * \param prodGroup The name of the product group.
			 */
			void defaultCatalog(QString const& prodGroup);
			/*!
			 * \brief For fetching data about all active products.
			 */
			void defaultAllProducts();
			/*!
			 * \brief For putting an item to a cart.
			 * \param sku The product or variant SKU of the item.
			 * \param item The product SKU of the item to order.
			 * \param quantity The quantity of the item to order.
			 * \param opts Any additional pairs of custom options.
			 */
			void order(const QString &sku,
					const QString &item = "",
					const int quantity = 1,
					const QVariant &options = {});

		signals:
			void gotPage(QString const& path,
					QString const& response);
			void gotCatalog(QString const& response);
			void gotProduct(QString const& response);
			void gotOrder(const QString &response);

		protected:
			void emitPage(QString const& path,
					QString const& response);
			void emitCatalog(QString const& response);
			void emitProduct(QString const& response);
			void emitOrder(const QString &response);
	};

}

#endif