Skip to content

Commit a6b0259

Browse files
Added UserAccountInfoResponse class (#1114)
Part of exposing user information. UserAccountInfoResponse is created to store information about user account. It contains email, firstname, lastname, phone number, etc. Relates-To: OLPEDGE-2384 Signed-off-by: Andrey Kashcheev <[email protected]>
1 parent 4fd3f49 commit a6b0259

File tree

1 file changed

+362
-0
lines changed

1 file changed

+362
-0
lines changed
Lines changed: 362 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,362 @@
1+
/*
2+
* Copyright (C) 2020 HERE Europe B.V.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
* License-Filename: LICENSE
18+
*/
19+
20+
#pragma once
21+
22+
#include "AuthenticationApi.h"
23+
24+
namespace olp {
25+
namespace authentication {
26+
/**
27+
* @brief An account information.
28+
*/
29+
class AUTHENTICATION_API UserAccountInfoResponse {
30+
public:
31+
/**
32+
* @brief Gets the HERE Account ID of the user.
33+
*
34+
* @return The HERE Account ID of the user.
35+
*/
36+
const std::string& GetUserId() const { return user_id_; }
37+
38+
/**
39+
* @brief Sets the HERE Account ID of the user.
40+
*
41+
* @param user_id The HERE Account ID of the user.
42+
*/
43+
void SetUserId(std::string user_id) { user_id_ = std::move(user_id); }
44+
45+
/**
46+
* @brief Gets the realm in which the user account exists.
47+
*
48+
* @return The user realm.
49+
*/
50+
const std::string& GetRealm() const { return realm_; }
51+
52+
/**
53+
* @brief Sets the realm in which the user account exists.
54+
*
55+
* @param realm The user realm.
56+
*/
57+
void SetRealm(std::string realm) { realm_ = std::move(realm); }
58+
59+
/**
60+
* @brief Gets the Facebook ID of the user.
61+
*
62+
* @note Not empty only if the account was created as a result of signing up
63+
* with a Facebook token.
64+
*
65+
* @return The Facebook ID of the user.
66+
*/
67+
const std::string& GetFacebookId() const { return facebook_id_; }
68+
69+
/**
70+
* @brief Sets the Facebook ID of the user.
71+
*
72+
* @param facebook_id The Facebook ID of the user.
73+
*/
74+
void SetFacebookId(std::string facebook_id) {
75+
facebook_id_ = std::move(facebook_id);
76+
}
77+
78+
/**
79+
* @brief Gets the first name of the user.
80+
*
81+
* @return The first name of the user.
82+
*/
83+
const std::string& GetFirstname() const { return firstname_; }
84+
85+
/**
86+
* @brief Sets the first name of the user.
87+
*
88+
* @param firstname The first name of the user.
89+
*/
90+
void SetFirstname(std::string firstname) {
91+
firstname_ = std::move(firstname);
92+
}
93+
94+
/**
95+
* @brief Gets the last name of the user.
96+
*
97+
* @return The last name of the user.
98+
*/
99+
const std::string& GetLastname() const { return lastname_; }
100+
101+
/**
102+
* @brief Sets the last name of the user.
103+
*
104+
* @param lastname The last name of the user.
105+
*/
106+
void SetLastname(std::string lastname) { lastname_ = std::move(lastname); }
107+
108+
/**
109+
* @brief Gets the primary email address.
110+
*
111+
* @return The primary email address.
112+
*/
113+
const std::string& GetEmail() const { return email_; }
114+
115+
/**
116+
* @brief Sets the primary email address.
117+
*
118+
* @param email The primary email address.
119+
*/
120+
void SetEmail(std::string email) { email_ = std::move(email); }
121+
122+
/**
123+
* @brief Gets the recovery email address.
124+
*
125+
* @return The recovery email address.
126+
*/
127+
const std::string& GetRecoveryEmail() const { return recovery_email_; }
128+
129+
/**
130+
* @brief Sets the recovery email address.
131+
*
132+
* @param recovery_email The recovery email address.
133+
*/
134+
void SetRecoveryEmail(std::string recovery_email) {
135+
recovery_email_ = std::move(recovery_email);
136+
}
137+
138+
/**
139+
* @brief Gets the day of birth in the day/month/year format.
140+
*
141+
* @return The day of birth.
142+
*/
143+
const std::string& GetDob() const { return dob_; }
144+
145+
/**
146+
* @brief Sets the day of birth.
147+
*
148+
* @param dob The day of birth.
149+
*/
150+
void SetDob(std::string dob) { dob_ = std::move(dob); }
151+
152+
/**
153+
* @brief Gets the code of the user's country in the ISO 3166-1 alpha-3
154+
* format.
155+
*
156+
* @return The country code.
157+
*/
158+
const std::string& GetCountryCode() const { return country_code_; }
159+
160+
/**
161+
* @brief Sets the code of the user's country in the ISO 3166-1 alpha-3
162+
* format.
163+
*
164+
* @param country_code The country code.
165+
*/
166+
void SetCountryCode(std::string country_code) {
167+
country_code_ = std::move(country_code);
168+
}
169+
170+
/**
171+
* @brief Gets the code of the user's language in the ISO 639-1 2 format.
172+
*
173+
* @return The language code.
174+
*/
175+
const std::string& GetLanguage() const { return language_; }
176+
177+
/**
178+
* @brief Sets the code of the user's language in the ISO 639-1 2 format.
179+
*
180+
* @param language The language code.
181+
*/
182+
void SetLanguage(std::string language) { language_ = std::move(language); }
183+
184+
/**
185+
* @brief Gets the verification of the primary email address.
186+
*
187+
* @note The user is asked to verify their email on signup, but doing so is
188+
* optional.
189+
*
190+
* @return True if the primary email address was verified; false otherwise.
191+
*/
192+
bool GetEmailVerified() const { return email_verified_; }
193+
194+
/**
195+
* @brief Sets the verification of the primary email address.
196+
*
197+
* @param email_verified True if the primary email address was verified; false
198+
* otherwise.
199+
*/
200+
void SetEmailVerified(bool email_verified) {
201+
email_verified_ = email_verified;
202+
}
203+
204+
/**
205+
* @brief Gets the user's phone number.
206+
*
207+
* @return The phone number.
208+
*/
209+
const std::string& GetPhoneNumber() const { return phone_number_; }
210+
211+
/**
212+
* @brief Sets the user's phone number.
213+
*
214+
* @param phone_number The phone number.
215+
*/
216+
void SetPhoneNumber(std::string phone_number) {
217+
phone_number_ = phone_number;
218+
}
219+
220+
/**
221+
* @brief Gets the verification of the phone number.
222+
*
223+
* @return True if the phone number was verified; false otherwise.
224+
*/
225+
bool GetPhoneNumberVerified() const { return phone_number_verified_; }
226+
227+
/**
228+
* @brief Sets the verification of the phone number.
229+
*
230+
* @param phone_number_verified True if the phone number was verified; false
231+
* otherwise.
232+
*/
233+
void SetPhoneNumberVerified(bool phone_number_verified) {
234+
phone_number_verified_ = phone_number_verified;
235+
}
236+
237+
/**
238+
* @brief Checks if the marketing is enabled.
239+
*
240+
* @return True if the marketing is enabled; false otherwise.
241+
*/
242+
bool GetMarketingEnabled() const { return marketing_enabled_; }
243+
244+
/**
245+
* @brief Sets the marketing if it is enabled.
246+
*
247+
* @param marketing_enabled True if the marketing is enabled; false otherwise.
248+
*/
249+
void SetMarketingEnabled(bool marketing_enabled) {
250+
marketing_enabled_ = marketing_enabled;
251+
}
252+
253+
/**
254+
* @brief Gets the timestamp (milliseconds since the Unix epoch) of when
255+
* the account was created.
256+
*
257+
* @return The epoch time when the account was created.
258+
*/
259+
time_t GetCreatedTime() const { return created_time_; }
260+
261+
/**
262+
* @brief Sets the timestamp (milliseconds since the Unix epoch) of when
263+
* the account was created.
264+
*
265+
* @param time The epoch time when the account was created.
266+
*/
267+
void SetCreatedTime(time_t created_time) { created_time_ = created_time; }
268+
269+
/**
270+
* @brief Gets the timestamp (milliseconds since the Unix epoch) of when the
271+
* account was last updated.
272+
*
273+
* @note The time is updated when the following
274+
* user properties are changed: `email`, `recoveryEmail`, `dob`,
275+
* `countryCode`, `firstname`, `lastname`, `language`, `phoneNumber`.
276+
*
277+
* @return The epoch time when the account was updated.
278+
*/
279+
time_t GetUpdatedTime() const { return updated_time_; }
280+
281+
/**
282+
* @brief Sets the timestamp (milliseconds since the Unix epoch) of when the
283+
* account was last updated.
284+
*
285+
* @return The epoch time when the account was updated.
286+
*/
287+
void SetUpdatedTime(time_t updated_time) { updated_time_ = updated_time; }
288+
289+
/**
290+
* @brief Gets the current state of the account.
291+
*
292+
* @note The list of the possible states of the account:
293+
* 'deleted' - The account was permanently deleted.
294+
* 'disabled' - The account was disabled by an administrator.
295+
* 'locked' - The account was automatically locked due to suspicious activity
296+
* and will be unlocked after some time.
297+
* 'enabled' - The account is enabled, and the user can log in.
298+
*
299+
* @return The current state of the account.
300+
*/
301+
const std::string& GetState() const { return state_; }
302+
303+
/**
304+
* @brief Sets the current state of the account.
305+
*
306+
* @param state The current state of the account.
307+
*/
308+
void SetState(std::string state) { state_ = std::move(state); }
309+
310+
/**
311+
* @brief Gets the HRN of the user.
312+
*
313+
* @return The user HRN.
314+
*/
315+
const std::string& GetHrn() const { return hrn_; }
316+
317+
/**
318+
* @brief Sets the HRN of the user.
319+
*
320+
* @param hrn The user HRN.
321+
*/
322+
void SetHrn(std::string hrn) { hrn_ = std::move(hrn); }
323+
324+
/**
325+
* @brief Gets the account type.
326+
*
327+
* @return The account type.
328+
*/
329+
const std::string& GetAccountType() const { return account_type_; }
330+
331+
/**
332+
* @brief Sets the account type.
333+
*
334+
* @param account_type The account type.
335+
*/
336+
void SetAccountType(std::string account_type) {
337+
account_type_ = std::move(account_type);
338+
}
339+
340+
private:
341+
std::string user_id_;
342+
std::string realm_;
343+
std::string facebook_id_;
344+
std::string firstname_;
345+
std::string lastname_;
346+
std::string email_;
347+
std::string recovery_email_;
348+
std::string dob_;
349+
std::string country_code_;
350+
std::string language_;
351+
bool email_verified_;
352+
std::string phone_number_;
353+
bool phone_number_verified_;
354+
bool marketing_enabled_;
355+
time_t created_time_;
356+
time_t updated_time_;
357+
std::string state_;
358+
std::string hrn_;
359+
std::string account_type_;
360+
};
361+
} // namespace authentication
362+
} // namespace olp

0 commit comments

Comments
 (0)