Subversion Repositories SmartDukaan

Rev

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