summaryrefslogtreecommitdiff
path: root/qicclient/client.hxx
blob: 26d540dcc65279e20e89324bc04dfdbe9f5c1823 (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
92
93
94
95
96
97
98
99
100
101
102
103
#ifndef QICCLIENT_CLIENT_HXX
#define QICCLIENT_CLIENT_HXX

#include <QObject>

struct icclient_member;

namespace QICClient {

	using std::shared_ptr;
	class Catalog;
	class Product;
	class Basket;

	class Client : public QObject
	{
		Q_OBJECT

		public:
			/*!
			 * \brief Constructor.
			 * \param url Server root URL.
			 * \param certificate Path to the CA certificate file.
			 */
			Client(char const* url, char const* certificate = nullptr);
			~Client();

			/*!
			 * \brief For fetching products that belong a specific group.
			 * \param prodGroup The name of the product group.
			 * \param handler A pointer to a cURL write function callback.
			 */
			void results(QString const& prodGroup,
					size_t (*handler)(void*, size_t, size_t, void*));

			/*!
			 * \brief For fetching data about all active products.
			 * \param handler A pointer to a cURL write function callback.
			 */
			void allProducts(size_t (*handler)(void*, size_t, size_t, void*));

			/*!
			 * \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,
					size_t (*handler)(void*, size_t, size_t, void*));

			/*!
			 * \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,
					Basket& order);

			void logIn(size_t (*handler)(void*, size_t, size_t, void*),
					icclient_member* member,
					QString const& username,
					QString const& password,
					QString const& successPage = nullptr,
					QString const& nextPage = nullptr,
					QString const& failPage = nullptr);

		public slots:
			/*
			void remove(unsigned int const& indices);
			void checkout();
			*/
		/*
			void account(QString const& firstName
					, QString const& lastName
					, QString const& address1
					, QString const& address2
					, QString const& city
					, QString const& state
					, QString const& zip
					, QString const& email
					, QString const& phoneDay);
			void changePassword(QString const& passwordOld
					, QString const& password
					, QString const& verify);
					*/
			void logOut();
			/*
			void newItem(QString const& description
					, QString const& comment,
					QString const& price
					, QString const& imagePath);
					*/

		signals:
			void gotResults(Catalog* catalog);
			void gotFlyPage(shared_ptr<Product> product);
			void loggedIn(icclient_member* member);
			void loggedOut();
	};

}

#endif // QICCLIENT_CLIENT_HXX