| 48 |
ashish |
1 |
namespace java in.shop2020.model.v1.user
|
| 95 |
ashish |
2 |
namespace py shop2020.thriftpy.model.v1.user
|
| 48 |
ashish |
3 |
|
|
|
4 |
/**
|
|
|
5 |
Exceptions
|
|
|
6 |
*/
|
|
|
7 |
exception AuthenticationException{
|
|
|
8 |
1:string message,
|
|
|
9 |
2:i32 errorCode
|
|
|
10 |
}
|
|
|
11 |
|
|
|
12 |
exception UserContextException{
|
|
|
13 |
1:i32 errorCode,
|
|
|
14 |
2:string message
|
|
|
15 |
}
|
|
|
16 |
|
| 552 |
chandransh |
17 |
exception ShoppingCartException{
|
|
|
18 |
1:i64 id,
|
|
|
19 |
2:string message
|
|
|
20 |
}
|
|
|
21 |
|
| 121 |
ashish |
22 |
enum AddressType{
|
| 130 |
ashish |
23 |
WORK = 0,
|
|
|
24 |
HOME = 1
|
| 48 |
ashish |
25 |
}
|
|
|
26 |
|
| 130 |
ashish |
27 |
enum PhoneType{
|
|
|
28 |
WORK = 0,
|
|
|
29 |
HOME = 1,
|
|
|
30 |
MOBILE = 2
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
enum AccountStatus{
|
|
|
34 |
ACTIVE = 0,
|
|
|
35 |
DELETED = 1,
|
|
|
36 |
INACTIVE = 2,
|
|
|
37 |
INCOMPLETE = 3
|
|
|
38 |
}
|
|
|
39 |
|
| 48 |
ashish |
40 |
/**
|
| 121 |
ashish |
41 |
All the social handles
|
| 48 |
ashish |
42 |
*/
|
| 121 |
ashish |
43 |
struct SocialHandles{
|
| 48 |
ashish |
44 |
1:string facebook,
|
|
|
45 |
2:string opensocial,
|
|
|
46 |
3:string twitter
|
|
|
47 |
}
|
|
|
48 |
|
| 121 |
ashish |
49 |
/**
|
|
|
50 |
Address
|
|
|
51 |
*/
|
|
|
52 |
struct Address{
|
| 552 |
chandransh |
53 |
1:i64 id,
|
|
|
54 |
2:string line1,
|
|
|
55 |
3:string line2,
|
|
|
56 |
4:string landmark,
|
|
|
57 |
5:string city,
|
|
|
58 |
6:string state,
|
|
|
59 |
7:string pin,
|
|
|
60 |
8:string country,
|
| 48 |
ashish |
61 |
9:bool enabled,
|
| 123 |
ashish |
62 |
10:AddressType type,
|
| 414 |
ashish |
63 |
11:i64 addedOn,
|
|
|
64 |
12:string name,
|
|
|
65 |
13:string phone
|
| 48 |
ashish |
66 |
}
|
|
|
67 |
|
| 130 |
ashish |
68 |
/**Phone
|
|
|
69 |
**/
|
|
|
70 |
struct Phone{
|
|
|
71 |
1:i64 id,
|
|
|
72 |
2:string countryCode,
|
|
|
73 |
3:string areaCode,
|
|
|
74 |
4:string number,
|
|
|
75 |
5:string extension,
|
| 552 |
chandransh |
76 |
6:PhoneType type
|
| 130 |
ashish |
77 |
}
|
|
|
78 |
|
| 121 |
ashish |
79 |
/**
|
|
|
80 |
Internal information to be used by system. various variables which aid in serving the user are identified and put here
|
|
|
81 |
**/
|
|
|
82 |
struct UserInternalInfo{
|
| 48 |
ashish |
83 |
1:i64 userId,
|
| 121 |
ashish |
84 |
2:i64 geoZone,
|
|
|
85 |
3:i64 shipmentZone,
|
| 48 |
ashish |
86 |
4:i64 taxZone,
|
|
|
87 |
5:double userRankScore
|
|
|
88 |
}
|
|
|
89 |
|
| 121 |
ashish |
90 |
/**
|
|
|
91 |
structure representing timestamp and ip at which user logged into the system
|
|
|
92 |
**/
|
|
|
93 |
struct IPMap{
|
|
|
94 |
1:i64 timestamp
|
| 123 |
ashish |
95 |
2:string ip
|
| 48 |
ashish |
96 |
}
|
|
|
97 |
|
| 121 |
ashish |
98 |
/**
|
|
|
99 |
dynamic user state
|
|
|
100 |
**/
|
|
|
101 |
struct UserState{
|
| 48 |
ashish |
102 |
1:i64 userId,
|
| 552 |
chandransh |
103 |
2:i64 lastLogin,
|
|
|
104 |
3:i64 lastLogout,
|
|
|
105 |
4:i64 emailVerificationSentOn,
|
|
|
106 |
5:i64 smsVerificationSentOn,
|
|
|
107 |
6:bool isEmailVerified,
|
| 48 |
ashish |
108 |
7:bool isSMSVerified,
|
|
|
109 |
8:i64 activeSince,
|
| 552 |
chandransh |
110 |
9:list<IPMap> ips,
|
|
|
111 |
10:AccountStatus status
|
| 48 |
ashish |
112 |
}
|
|
|
113 |
|
| 552 |
chandransh |
114 |
enum Sex{
|
|
|
115 |
MALE,
|
|
|
116 |
FEMALE,
|
|
|
117 |
WONT_SAY
|
|
|
118 |
}
|
|
|
119 |
|
| 121 |
ashish |
120 |
/**
|
| 552 |
chandransh |
121 |
The user structure holding the basic information that identifies the user.
|
| 121 |
ashish |
122 |
**/
|
| 552 |
chandransh |
123 |
struct User{
|
|
|
124 |
1:i64 userId,
|
|
|
125 |
2:string email,
|
|
|
126 |
3:string password,
|
|
|
127 |
4:string name,
|
| 566 |
rajveer |
128 |
5:string dateOfBirth,
|
| 552 |
chandransh |
129 |
6:Sex sex
|
| 566 |
rajveer |
130 |
7:string mobileNumber
|
| 552 |
chandransh |
131 |
8:SocialHandles socialHandles,
|
|
|
132 |
9:list<Address> addresses,
|
|
|
133 |
10:i64 defaultAddressId,
|
|
|
134 |
11:string communicationEmail,
|
|
|
135 |
12:i64 activeCartId,
|
|
|
136 |
13:string jsessionId,
|
|
|
137 |
14:bool isAnonymous
|
| 48 |
ashish |
138 |
}
|
|
|
139 |
|
| 552 |
chandransh |
140 |
//Various statuses for line items
|
|
|
141 |
enum LineStatus{
|
|
|
142 |
LINE_ACTIVE, //line is active
|
|
|
143 |
LINE_DELETED, //line is deleted
|
|
|
144 |
LINE_EXPIRED, //line is expired, on laspse of fixed amount of time
|
|
|
145 |
LINE_COMMITED, //line is committed, sent for processing.
|
|
|
146 |
LINE_COMMIT_FAILED, //line was committed, but commit failed due to some reason, possibly during cart validation.
|
|
|
147 |
LINE_AUTO_DELETED, //line was auto deleted internally due to some reason(item delisted, price changed etc).
|
|
|
148 |
}
|
|
|
149 |
|
|
|
150 |
//Various statuses for Cart
|
|
|
151 |
enum CartStatus{
|
|
|
152 |
ACTIVE,
|
|
|
153 |
INACTIVE,
|
|
|
154 |
EXPIRED,
|
|
|
155 |
COMMITTED,
|
|
|
156 |
COMMIT_FAILED
|
|
|
157 |
}
|
|
|
158 |
|
|
|
159 |
struct Line{
|
| 646 |
chandransh |
160 |
1:i64 cartId, //identifier
|
| 552 |
chandransh |
161 |
2:i64 itemId, //item id added
|
|
|
162 |
3:double quantity, //quantity added
|
|
|
163 |
4:i64 createdOn, //addition timestamp
|
|
|
164 |
5:i64 updatedOn, //any updation in quantity or status
|
|
|
165 |
6:LineStatus lineStatus, //current status
|
| 613 |
chandransh |
166 |
7:i32 estimate //delivery estimate in hours
|
| 552 |
chandransh |
167 |
}
|
|
|
168 |
|
|
|
169 |
struct Cart{
|
|
|
170 |
1:i64 id, //identifier
|
|
|
171 |
2:list<Line> lines, //list of lines
|
|
|
172 |
3:CartStatus status, //current status
|
|
|
173 |
4:i64 createdOn, //creation timestamp
|
|
|
174 |
5:i64 updatedOn, //time of last update in cart (like addition/deletion/updation of cart items )
|
| 687 |
chandransh |
175 |
6:i64 checkedOutOn, //commited timestamp
|
| 552 |
chandransh |
176 |
7:i64 userId, //user id to which it belongs
|
| 613 |
chandransh |
177 |
8:i64 addressId, //address on which this will be shipped
|
| 552 |
chandransh |
178 |
}
|
|
|
179 |
|
|
|
180 |
enum WidgetType{
|
| 770 |
rajveer |
181 |
MY_RESEARCH,
|
|
|
182 |
BROWSE_HISTORY
|
|
|
183 |
}
|
|
|
184 |
|
|
|
185 |
/** Not used right now, will decide later
|
|
|
186 |
enum WidgetType{
|
|
|
187 |
ACCESSORIES,
|
|
|
188 |
RATINGS,
|
| 552 |
chandransh |
189 |
SIMILAR_ITEMS,
|
|
|
190 |
RECOMMENDED_ITEMS,
|
| 770 |
rajveer |
191 |
DEAL_PROMOTIONS,
|
|
|
192 |
|
| 552 |
chandransh |
193 |
MY_RESEARCH,
|
| 770 |
rajveer |
194 |
BROWSE_HISTORY
|
| 552 |
chandransh |
195 |
}
|
|
|
196 |
|
|
|
197 |
enum RatingType{
|
|
|
198 |
SHOP2020,
|
|
|
199 |
AMAZON,
|
|
|
200 |
USER_ALL,
|
|
|
201 |
USER_CURRENT
|
|
|
202 |
}
|
|
|
203 |
|
|
|
204 |
struct RatingsWidget{
|
|
|
205 |
1:i64 catalog_item_id,
|
|
|
206 |
2:map<RatingType,double> ratings,
|
|
|
207 |
3:i64 user_id
|
|
|
208 |
}
|
| 770 |
rajveer |
209 |
*/
|
| 552 |
chandransh |
210 |
struct WidgetItem{
|
|
|
211 |
1:i64 id,
|
|
|
212 |
2:i64 item_id,
|
| 770 |
rajveer |
213 |
3:bool enabled,
|
|
|
214 |
4:i64 timestamp
|
| 552 |
chandransh |
215 |
}
|
|
|
216 |
|
|
|
217 |
struct Widget{
|
|
|
218 |
1:i64 id,
|
|
|
219 |
2:WidgetType type,
|
| 770 |
rajveer |
220 |
3:i64 user_id,
|
| 552 |
chandransh |
221 |
4:list<WidgetItem> items,
|
|
|
222 |
5:bool enabled,
|
| 770 |
rajveer |
223 |
6:string name
|
| 552 |
chandransh |
224 |
}
|
|
|
225 |
|
|
|
226 |
exception WidgetException{
|
|
|
227 |
1:i64 id,
|
|
|
228 |
2:string message
|
|
|
229 |
}
|
|
|
230 |
|
| 48 |
ashish |
231 |
/**
|
|
|
232 |
service
|
|
|
233 |
*/
|
|
|
234 |
service UserContextService{
|
| 763 |
rajveer |
235 |
/**
|
|
|
236 |
* For closing the open session in sqlalchemy
|
|
|
237 |
*/
|
|
|
238 |
void closeSession(),
|
|
|
239 |
|
| 552 |
chandransh |
240 |
User createAnonymousUser(1:string jsessionId) throws (1:UserContextException ucex),
|
|
|
241 |
User getUserById(1:i64 userId) throws (1:UserContextException ucex),
|
|
|
242 |
User createUser(1:User user) throws (1:UserContextException ucex),
|
|
|
243 |
User updateUser(1:User user) throws (1:UserContextException ucex),
|
|
|
244 |
bool deleteUser(1:i64 userId) throws (1:UserContextException ucex),
|
|
|
245 |
UserState getUserState(1:i64 userId) throws (1:UserContextException ucex),
|
|
|
246 |
User authenticateUser(1:string email, 2:string password) throws (1:AuthenticationException auex),
|
|
|
247 |
bool userExists(1:string email) throws (1:UserContextException ucx),
|
| 566 |
rajveer |
248 |
i64 addAddressForUser(1:i64 userId, 2:Address address, 3:bool setDefault)throws (1:UserContextException ucx),
|
| 48 |
ashish |
249 |
bool removeAddressForUser(1:i64 userid, 2:i64 addressId)throws (1:UserContextException ucx),
|
|
|
250 |
bool setUserAsLoggedIn(1:i64 userId, 2:i64 timestamp)throws (1:UserContextException ucx),
|
|
|
251 |
bool setUserAsLoggedOut(1:i64 userid, 2:i64 timestamp)throws (1:UserContextException ucx),
|
| 506 |
rajveer |
252 |
bool setDefaultAddress(1:i64 userid, 2:i64 addressId)throws (1:UserContextException ucx),
|
| 592 |
rajveer |
253 |
bool updatePassword(1:i64 userid, 2:string oldPassword, 3:string newPassword)throws (1:UserContextException ucx),
|
| 895 |
rajveer |
254 |
bool forgotPassword(1:string email, 2:string newPassword)throws (1:UserContextException ucx),
|
| 592 |
rajveer |
255 |
list<Address> getAllAddressesForUser(1:i64 userId)throws (1:UserContextException ucx),
|
|
|
256 |
i64 getDefaultAddressId(1:i64 userId)throws (1:UserContextException ucx),
|
| 783 |
rajveer |
257 |
string getDefaultPincode(1:i64 userId)throws (1:UserContextException ucx),
|
| 552 |
chandransh |
258 |
|
|
|
259 |
i64 createCart(1:i64 userId) throws (1:ShoppingCartException scx),
|
|
|
260 |
Cart getCurrentCart(1:i64 userId) throws (1:ShoppingCartException scx),
|
|
|
261 |
Cart getCart(1:i64 cartId) throws (1:ShoppingCartException scx),
|
|
|
262 |
list<Cart> getCartsForUser(1:i64 userId, 2:CartStatus status) throws (1:ShoppingCartException scx),
|
|
|
263 |
list<Cart> getCartsByStatus(1:CartStatus status) throws (1:ShoppingCartException scx),
|
|
|
264 |
list<Cart> getCartsByTime(1:i64 from_time, 2:i64 to_time, 3:CartStatus status) throws (1:ShoppingCartException scx),
|
|
|
265 |
void changeCartStatus(1:i64 cartId, 2:CartStatus status) throws (1:ShoppingCartException scx),
|
|
|
266 |
void addItemToCart(1:i64 cartId, 2:i64 itemId, 3:i64 quantity) throws (1:ShoppingCartException scx),
|
|
|
267 |
void deleteItemFromCart(1:i64 cartId, 2:i64 itemId) throws (1:ShoppingCartException scx),
|
|
|
268 |
void changeQuantity(1:i64 cartId, 2:i64 itemId, 3:i64 quantity) throws (1:ShoppingCartException scx),
|
|
|
269 |
void changeItemStatus(1:i64 cartId, 2:i64 itemId, 3:LineStatus status) throws (1:ShoppingCartException scx),
|
| 577 |
chandransh |
270 |
void addAddressToCart(1:i64 cartId, 2:i64 addressId) throws (1:ShoppingCartException scx),
|
| 687 |
chandransh |
271 |
|
|
|
272 |
/**
|
|
|
273 |
Creates a transaction and multiple orders for the given cart. Returns the transaction ID created.
|
|
|
274 |
*/
|
|
|
275 |
i64 createOrders(1:i64 cartId) throws (1:ShoppingCartException scx),
|
|
|
276 |
|
|
|
277 |
/**
|
|
|
278 |
Validates that:
|
|
|
279 |
1. The checkout timestamp is greater than the updatedOn timestamp.
|
|
|
280 |
2. None of the lines in the cart for an inactive item.
|
|
|
281 |
3. The estimate for any of the lines in cart doesn't change.
|
|
|
282 |
Returns true only if all three hold.
|
|
|
283 |
*/
|
| 577 |
chandransh |
284 |
bool validateCart(1:i64 cartId) throws (1:ShoppingCartException scex),
|
| 552 |
chandransh |
285 |
|
| 687 |
chandransh |
286 |
/**
|
|
|
287 |
Merges the lines from the first cart into the second cart. Lines with duplicate items are removed.
|
|
|
288 |
*/
|
|
|
289 |
void mergeCart(1:i64 fromCartId, 2:i64 toCartId),
|
|
|
290 |
|
|
|
291 |
/**
|
|
|
292 |
Sets the checkedOutOn timestamp of the cart. Raises an exception if the specified cart can't be found.
|
|
|
293 |
*/
|
|
|
294 |
bool checkOut(1:i64 cartId) throws (1:ShoppingCartException scex),
|
|
|
295 |
|
|
|
296 |
/**
|
|
|
297 |
The second parameter is a map of item ids and their quantities which have been successfully processed.
|
|
|
298 |
This methods removes the specified quantiry of the specified item from the cart.
|
| 770 |
rajveer |
299 |
*/
|
|
|
300 |
bool resetCart(1:i64 cartId, 2:map<i64, double> items) throws (1:ShoppingCartException scex),
|
|
|
301 |
|
|
|
302 |
/**
|
|
|
303 |
* Widgets
|
| 687 |
chandransh |
304 |
*/
|
| 770 |
rajveer |
305 |
Widget getMyResearch(1:i64 userId) throws (1:WidgetException scx),
|
|
|
306 |
bool updateMyResearch(1:i64 userId, 2:i64 itemId) throws (1:WidgetException scx),
|
|
|
307 |
void deleteItemFromMyResearch(1:i64 userId, 2:i64 itemId) throws (1:WidgetException scx),
|
|
|
308 |
|
|
|
309 |
void updateBrowseHistory(1:i64 userId, 2:i64 itemId),
|
|
|
310 |
Widget getBrowseHistory(1:i64 userId) throws (1:WidgetException scx),
|
|
|
311 |
void mergeBrowseHistory(1:i64 fromUserId, 2:i64 toUserId)
|
| 687 |
chandransh |
312 |
|
| 770 |
rajveer |
313 |
/** Masking right now. May be used later.
|
| 552 |
chandransh |
314 |
void addWidget(1:Widget widget) throws (1:WidgetException scx),
|
|
|
315 |
void addItemToWidget(1:i64 widget_id, 2:list<i64> items) throws (1:WidgetException scx),
|
|
|
316 |
void deleteItemFromWidget(1:i64 widget_id, 2:i64 item_id) throws (1:WidgetException scx),
|
|
|
317 |
void updateWidget(1:i64 widgetId, 2:bool enable) throws (1:WidgetException scx),
|
|
|
318 |
void updateWidgetItem(1:i64 widgetId, 2:bool enable) throws (1:WidgetException scx),
|
|
|
319 |
Widget getWidget(1:WidgetType type, 2:i64 userId, 3:bool onlyEnabled) throws (1:WidgetException scx),
|
| 770 |
rajveer |
320 |
*/
|
| 48 |
ashish |
321 |
}
|
|
|
322 |
|