Subversion Repositories SmartDukaan

Rev

Rev 1599 | Rev 1848 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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