Portability Libraries  2015.2.0.0
Common Methods and Objects for Platform Independance.
UpnContact.hpp
Go to the documentation of this file.
1 /*
2 
3  BEGIN_COPYRIGHT
4 
5  Copyright (C) 2016 Douglas Mark Royer, All Rights Reserved.
6 
7  NOTICE:
8 
9  THIS SOURCE CODE BELONGS TO DOUGLAS MARK ROYER AN INDIVIDUAL.
10  THIS CODE IS PROPERTY OF THE COPYRIGHT HOLDER AND IS NOT TO
11  BE DIVULGED OR USED BY PARTIES WHO HAVE NOT RECEIVED WRITTEN
12  AUTHORIZATION FROM THE OWNER.
13 
14  THIS SOFTWARE AND MANUAL ARE BOTH PROTECTED BY UNITED STATES
15  COPYRIGHT LAW (TITLE 17 UNITED STATES CODE). UNAUTHORIZED REPRODUCTION
16  AND/OR SALE MAY RESULT IN IMPRISONMENT OF UP TO ONE YEAR AND FINES
17  OF UP TO $100,000 (17 USC 506). COPYRIGHT INFRINGERS MAY ALSO
18  BE SUBJECT TO CIVIL LIABILITY.
19 
20  THIS NOTICE AND THE ABOVE COPYRIGHT NOTICE MUST REMAIN IN ALL
21  COPIES AND ANY DERIVED WORK.
22 
23  ALL OF THIS CODE IS ORIGINAL WORK BY THE COPYRIGHT HOLDER.
24 
25  THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN IS
26  PROVIDED ON AN "AS IS" BASIS AND OWNER DISCLAIM ALL WARRANTIES,
27  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY
28  THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE
29  ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY
30  OR FITNESS FOR A PARTICULAR PURPOSE.
31 
32  END_INET_COPYRIGHT
33 
34 */
35 
36 #ifndef __DOUGLAD_MARK_ROYER_LIBRARY_UPN_CONTACT_HPP__
37 #define __DOUGLAD_MARK_ROYER_LIBRARY_UPN_CONTACT_HPP__
38 
39 #ifndef EXPORT_UPN
40 #ifdef BUILDING_LIBRARY_UPNDB
41 #define EXPORT_UPN EXPORT_OUT
42 #else
43 #define EXPORT_UPN EXPORT_IN
44 #endif
45 #endif
46 
47 #ifdef BUILDING_LIBRARY_UPNDB
48 #include "Change.hpp"
49 #include "UpnDB.hpp"
50 #else
51 #include <SaS/UpnDb/Change.hpp>
52 #include <SaS/UpnDb/UpnDB.hpp>
53 #endif
54 
55 namespace SoftwareAndServices
56 {
57  namespace Library
58  {
59  namespace UPN
60  {
61 
63 
64  /**
65  * @class UpnContact UpnContact.hpp <SaS/UpnDb/UpnDB.hpp>
66  * An object that identifies a contact.
67  */
69  : public Change
70  {
71 
72  /**
73  * UpnDbContact() - Default constructor.
74  */
75  UpnDbContact();
76 
77  /**
78  * ~UpnDbContact() - Destructor.
79  */
80  virtual ~UpnDbContact();
81 
82  /**
83  * Load contact record.
84  *
85  * @param Auth An authentiation handle.
86  *
87  * @param Db The UpnDB to use.
88  *
89  * @param CompanyId The company ID to load.
90  *
91  * @param Results a std::list<UpnDbContact*> of
92  * the found objects.
93  *
94  * @return The number of records returned in Results.
95  */
96  static uint64_t
97  LoadAllForCompany(UpnDbAuthHandle_t Auth,
98  UpnDB & Db,
99  UpnDbCompanyDbId_t CompanyId,
100  std::list<UpnDbContact*> & Results);
101 
102  /**
103  * Add a new UpnDbContact
104  *
105  * @param Auth An authentiation handle.
106  *
107  * @param Db The UpnDB to use.
108  *
109  * @param CompanyId The Database ID of the company.
110  *
111  * @param ContactUpnId The UPN ID of the contact.
112  *
113  * @return The true when added, and ContactUpnId
114  * is a contact UPN.
115  */
116  bool Add(UpnDbAuthHandle_t Auth,
117  UpnDB & Db,
118  UpnDbCompanyDbId_t CompanyId,
119  UpnDbUpnId_t ContactUpnId);
120 
121 
122  /**
123  * Update an existig UpnDbContact
124  *
125  * @param Auth An authentiation handle.
126  *
127  * @param Db The UpnDB to use.
128  *
129  * @return true if saved.
130  */
131  bool Update(UpnDbAuthHandle_t Auth,
132  UpnDB & Db);
133 
134 
135  /**
136  * Find matching contact, matching wild card.
137  *
138  * @param Auth An authentiation handle.
139  *
140  * @param Db The UpnDB to use.
141  *
142  * @WildCard Some of the characters of the contact
143  * name. Example "abc" will find: "Abc Contact",
144  * "Super abcd inc", and so one.
145  *
146  * Matches any location of WildCard in any contact name.
147  *
148  * @param CompanyId The company who's contacts
149  * we are looking for.
150  *
151  * @param Results A reference to a std::list<const char*>
152  * that will be cleared, any contents freed, and then
153  * filled up with the results of matching contact names.
154  *
155  * @returns The number found.
156  *
157  * @note Caller must free each (const char*) entry in
158  * Results, when no longer needed.
159  *
160  * @note Your can repeatedly call Find() with
161  * the same Results, without clearing Results first,
162  * as Find() will clear free the contents of Results
163  * before processing.
164  *
165  * @note For SQL aware users, this calls for a select
166  * on the UPN table something like:
167  *
168  * SELECT upn from upns WHERE upn ILIKE '%WildCard%'
169  *
170  */
171  static uint64_t
172  Find(UpnDbAuthHandle_t Auth,
173  UpnDB & Db,
174  const char * WildCard,
175  UpnDbCompanyDbId_t CompanyId,
176  std::list<const char*> & Results);
177 
178  /**
179  * @return this records contact database ID.
180  */
181  UpnDbContactDbId_t ContactDbId() const;
182 
183  /**
184  * Set this records contact database ID.
185  *
186  * @param CompId The contact database ID.
187  *
188  * @param Normally, the database methods set this value.
189  */
190  void ContactDbId(UpnDbContactDbId_t CompId);
191 
192  /**
193  * @return The UPN ID of the contact.
194  * A persons UPN ID.
195  */
196  UpnDbUpnId_t ContactUpnId() const;
197 
198  /**
199  * Set the UPN ID of the contact.
200  * A persons UPN ID.
201  *
202  * @param CompId The contact UPN ID.
203  */
204  void ContactUpnId(UpnDbUpnId_t CompId);
205 
206  /**
207  * @return The CUSTOMER ID (a UPN) to contact.
208  * The UPN ID of the company to contact.
209  */
210  UpnDbUpnId_t CustomerUpnId() const;
211 
212  /**
213  * Set the COMPANY ID (a database ID) to contact.
214  *
215  * @param CompId The company database ID.
216  */
217  void CompanyDbId(UpnDbCompanyDbId_t CompId);
218 
219  /**
220  * @return The COMPANY ID (a database ID) to contact.
221  */
222  UpnDbUpnId_t CompanyDbId() const;
223 
224  /**
225  * Set the CUSTOMER ID (a UPN) to contact.
226  * The UPN ID of the company to contact.
227  *
228  * @param CompId The contact UPN ID.
229  */
230  void CustomerUpnId(UpnDbUpnId_t CompId);
231 
232  /**
233  * @return The ADDRESS ID of the contact.
234  * Or zero (0) when none.
235  */
236  UpnDbAddressId_t AddressId() const;
237 
238  /**
239  * Set the ADDRESS ID of the contact.
240  *
241  * @param CompId The contact ADDRESS ID.
242  * Or zero (0) when none.
243  */
244  void AddressId(UpnDbAddressId_t CompId);
245 
246  /**
247  * @return The PHONE ID to contact.
248  * Or zero (0) when none.
249  */
250  UpnDbPhoneId_t PhoneId() const;
251 
252  /**
253  * Set the PHONE ID of the contact.
254  *
255  * @param CompId The contact PHONE ID.
256  * Or zero (0) when none.
257  */
258  void PhoneId(UpnDbPhoneId_t CompId);
259 
260  /**
261  * @return The EMAIL ID to contact.
262  * Or zero (0) when none.
263  */
264  UpnDbEmailId_t EmailId() const;
265 
266  /**
267  * Set the EMAIL ID of to contact.
268  *
269  * @param CompId The contact EMAIL ID.
270  * Or zero (0) when none.
271  */
272  void EmailId(UpnDbEmailId_t CompId);
273 
274  /**
275  * @return true if this contact get text message updates.
276  */
277  bool TextUpdates() const;
278 
279  /**
280  * Set if this contact get text message updates.
281  *
282  * @param DoSend When true, send this contact text
283  * message updates.
284  */
285  void TextUpdates(bool DoSend);
286 
287  /**
288  * @return true if this contact get email message updates.
289  */
290  bool EmailUpdates() const;
291 
292  /**
293  * Set if this contact get email message updates.
294  *
295  * @param DoSend When true, send this contact text
296  * message updates.
297  */
298  void EmailUpdates(bool DoSend);
299 
300  /**
301  * @return true if this contact get marketing email.
302  */
303  bool MarketingUpdates() const;
304 
305  /**
306  * Set if this contact get marketing email.
307  *
308  * @param DoSend When true, send this contact marketing
309  * email messages.
310  */
311  void MarketingUpdates(bool DoSend);
312 
313  private:
314 
315  /**
316  * The database ID for this record (contact_id in database).
317  */
318  UpnDbContactDbId_t _ContactDbId;
319 
320  /**
321  * The UPN ID of who to contact (upn_id in database).
322  */
323  UpnDbUpnId_t _ContactUpnId;
324 
325  /**
326  * The customer UPN ID.
327  */
328  UpnDbUpnId_t _CustomerUpnId;
329 
330  /**
331  * The database ID of the COMPANY
332  */
333  UpnDbUpnId_t _CompanyDbId;
334 
335  /**
336  * The UPN ID of the address contact, or
337  * zero if none (address_id in database).
338  */
339  UpnDbAddressId_t _AddressId;
340 
341  /**
342  * The UPN ID of the phone called, or
343  * zero if none (phone_id in database).
344  */
345  UpnDbAddressId_t _PhoneId;
346 
347  /**
348  * The UPN ID of the email address sent to, or
349  * zero if none (email_id in database).
350  */
351  UpnDbAddressId_t _EmailId;
352 
353  /**
354  * When true, send text status updates.
355  */
356  bool _SendTextUpdates;
357 
358  /**
359  * When true, send email status updates.
360  */
361  bool _SendEmailUpdates;
362 
363  /**
364  * When true, send marketing updates.
365  */
366  bool _SendMarketingUpdates;
367 
368 
369  };
370 
371  }
372  }
373 }
374 #endif /* __DOUGLAD_MARK_ROYER_LIBRARY_UPN_CONTACT_HPP__ */
void * UpnDbAuthHandle_t
Definition: UpnDB.h:83
DNSDB * Db
unsigned long long UpnDbEmailId_t
Definition: UpnEmail.h:62
unsigned long long UpnDbAddressId_t
Definition: UpnAddress.h:64
unsigned long long UpnDbPhoneId_t
Definition: UpnPhone.h:71
unsigned long long UpnDbUpnId_t
Definition: UpnRecord.h:55