Subversion Repositories SmartDukaan

Rev

Rev 2814 | Rev 3026 | 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
 
1995 vikas 27
exception UserAffiliateException{
1848 vikas 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,
2020 vikas 166
	14:bool isAnonymous,
2814 vikas 167
	15:string source,
168
	16:i64 sourceStartTime
48 ashish 169
}
170
 
1116 varun.gupt 171
struct UserCommunication{
172
	1:i64 id,
173
	2:i64 userId,
174
	3:UserCommunicationType communicationType,
175
	4:i64 orderId,
176
	5:string airwaybillNo,
177
	6:string replyTo,
178
	7:string productName,
179
	8:string subject,
180
	9:string message,
1299 varun.gupt 181
	10:i64 communication_timestamp
1116 varun.gupt 182
}
183
 
1848 vikas 184
struct MasterAffiliate{
185
    1:i64 id,
186
    2:string name,
1861 vikas 187
    3:i64 addedOn
1848 vikas 188
}
189
 
190
struct Affiliate{
191
    1:i64 id,
192
    2:string name,
193
    3:string url,
1861 vikas 194
    4:i64 masterAffiliateId,
195
    5:i64 addedOn
1848 vikas 196
}
197
 
198
struct Tracker{
199
    1:i64 id,
1861 vikas 200
    2:i64 affiliateId,
1848 vikas 201
}
202
 
203
struct TrackLog{
204
    1:i64 id,
1861 vikas 205
    2:i64 addedOn,
1995 vikas 206
    3:i64 affiliateId,
1861 vikas 207
    4:i64 userId,
208
    5:string event,
209
    6:string url,
210
    7:string data
1848 vikas 211
}
212
 
2642 varun.gupt 213
struct UserNote{
214
	1:i64 user_id,
215
	2:i64 entity_id,
2717 varun.gupt 216
	3:string slide,
2642 varun.gupt 217
	4:string note
218
}
219
 
552 chandransh 220
//Various statuses for line items
221
enum LineStatus{
222
	LINE_ACTIVE,			//line is active
223
	LINE_DELETED,			//line is deleted
224
	LINE_EXPIRED,			//line is expired, on laspse of fixed amount of time
225
	LINE_COMMITED,			//line is committed, sent for processing.
226
	LINE_COMMIT_FAILED,		//line was committed, but commit failed due to some reason, possibly during cart validation.
227
	LINE_AUTO_DELETED,		//line was auto deleted internally due to some reason(item delisted, price changed etc).
228
}
229
 
230
//Various statuses for Cart
231
enum CartStatus{
232
	ACTIVE,					
233
	INACTIVE,
234
	EXPIRED,
235
	COMMITTED,
236
	COMMIT_FAILED
237
}
238
 
239
struct Line{
646 chandransh 240
	1:i64 cartId,				//identifier
552 chandransh 241
	2:i64 itemId,			//item id added
242
	3:double quantity,		//quantity added 
243
	4:i64 createdOn,		//addition timestamp
244
	5:i64 updatedOn, 		//any updation in quantity or status
245
	6:LineStatus lineStatus,	//current status
1984 varun.gupt 246
	7:i32 estimate,			//delivery estimate in hours
247
	8:double actualPrice,
248
	9:double discountedPrice
552 chandransh 249
}
250
 
251
struct Cart{
252
	1:i64 id,				//identifier
253
	2:list<Line> lines,		//list of lines
254
	3:CartStatus status,	//current status
255
	4:i64 createdOn,		//creation timestamp
256
	5:i64 updatedOn,		//time of last update in cart (like addition/deletion/updation of cart items )
687 chandransh 257
	6:i64 checkedOutOn,		//commited timestamp
552 chandransh 258
	7:i64 userId,			//user id to which it belongs
1984 varun.gupt 259
	8:i64 addressId,	    //address on which this will be shipped
260
	9:double totalPrice,
261
	10:double discountedPrice,
262
	11:string couponCode
552 chandransh 263
}
264
 
265
enum WidgetType{
770 rajveer 266
	MY_RESEARCH,
267
	BROWSE_HISTORY
268
}
269
 
2981 rajveer 270
struct UserWidgetItem{
271
	1:i64 userId,
272
	2:i64 widgetId,
273
	3:i64 itemId,
274
	4:i64 addedOn
552 chandransh 275
}
276
 
277
exception WidgetException{
278
	1:i64 id,
279
	2:string message
280
}
281
 
48 ashish 282
/**
1984 varun.gupt 283
Exceptions for Promotion Service
284
*/
285
exception PromotionException{
286
	1:i64 id,
287
	2:string message
288
}
289
 
290
/**
291
Types for Promotion Service
292
*/
293
 
294
struct Promotion{
295
	1:i64 id,
296
	2:string name,
297
	3:string ruleExecutionSrc,
298
	4:i64 startOn,
299
	5:i64 endOn,
300
	6:i64 createdOn
301
}
302
 
303
struct Coupon{
304
	1:string couponCode
305
	2:i64 promotionId
306
	3:string arguments
307
}
308
 
309
struct PromotionTracking{
310
	1:string couponCode,
311
	2:i64 transactionId,
312
	3:i64 userId,
313
	4:bool appliedOn
314
}
315
 
316
/**
317
Promotion Service
318
*/
319
service PromotionService{
320
	/**
321
	* For closing the open session in sqlalchemy
322
	*/
323
	void closeSession(),
324
 
325
	void createPromotion(1:string name, 2:string ruleExecutionSrc, 3:i64 startOn, 4:i64 endOn) throws (1:PromotionException pex),
326
	list<Promotion> getAllPromotions() throws (1:PromotionException pex),
327
	Promotion getPromotionById(1:i64 promotionId) throws (1:PromotionException pex),
328
	void generateCouponsForPromotion(1:i64 promotionId, 2:string couponCode) throws (1:PromotionException pex),
329
	Cart applyCoupon(1:string couponCode, 2:i64 cartId) throws (1:PromotionException pex),
330
    void trackCouponUsage(1:string couponCode, 2:i64 transactionId, 3:i64 userId) throws (1:PromotionException pex),
331
    i64 getCouponUsageCountByUser(1:string couponCode, 2:i64 userId) throws (1:PromotionException pex)
332
}
333
 
334
/**
48 ashish 335
service
336
*/
337
service UserContextService{
763 rajveer 338
	/**
339
	* For closing the open session in sqlalchemy
340
	*/
341
	void closeSession(),
342
 
552 chandransh 343
	User createAnonymousUser(1:string jsessionId) throws (1:UserContextException ucex),
344
	User getUserById(1:i64 userId) throws (1:UserContextException ucex),
1491 vikas 345
	User getUserByEmail(1:string email) throws (1:UserContextException ucex),
552 chandransh 346
	User createUser(1:User user) throws (1:UserContextException ucex),
347
	User updateUser(1:User user) throws (1:UserContextException ucex),
348
	bool deleteUser(1:i64 userId) throws (1:UserContextException ucex),
349
	UserState getUserState(1:i64 userId) throws (1:UserContextException ucex),
350
	User authenticateUser(1:string email, 2:string password) throws (1:AuthenticationException auex),
351
	bool userExists(1:string email) throws (1:UserContextException ucx),
566 rajveer 352
	i64 addAddressForUser(1:i64 userId, 2:Address address, 3:bool setDefault)throws (1:UserContextException ucx),
48 ashish 353
	bool removeAddressForUser(1:i64 userid, 2:i64 addressId)throws (1:UserContextException ucx),
354
	bool setUserAsLoggedIn(1:i64 userId, 2:i64 timestamp)throws (1:UserContextException ucx),
355
	bool setUserAsLoggedOut(1:i64 userid, 2:i64 timestamp)throws (1:UserContextException ucx),
506 rajveer 356
	bool setDefaultAddress(1:i64 userid, 2:i64 addressId)throws (1:UserContextException ucx),
592 rajveer 357
	bool updatePassword(1:i64 userid, 2:string oldPassword, 3:string newPassword)throws (1:UserContextException ucx),
895 rajveer 358
	bool forgotPassword(1:string email, 2:string newPassword)throws (1:UserContextException ucx),
592 rajveer 359
	list<Address> getAllAddressesForUser(1:i64 userId)throws (1:UserContextException ucx),
1892 vikas 360
	Address getAddressById(1:i64 addressId)throws (1:UserContextException ucx),
592 rajveer 361
	i64 getDefaultAddressId(1:i64 userId)throws (1:UserContextException ucx),
783 rajveer 362
	string getDefaultPincode(1:i64 userId)throws (1:UserContextException ucx),
552 chandransh 363
 
1167 varun.gupt 364
	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 365
	UserCommunication getUserCommunicationById(1:i64 id) throws (1:UserCommunicationException ucx)
366
	list<UserCommunication> getUserCommunicationByUser(1:i64 userId) throws (1:UserCommunicationException ucx)
367
	list<UserCommunication> getAllUserCommunications() throws (1:UserCommunicationException ucx)
1116 varun.gupt 368
 
1995 vikas 369
	MasterAffiliate createMasterAffiliate(1:string name, 2:i64 addedOn) throws (1:UserAffiliateException utx)
370
	list<MasterAffiliate> getAllMasterAffiliates() throws (1:UserAffiliateException utx)
371
	MasterAffiliate getMasterAffiliateById(1:i64 id) throws (1:UserAffiliateException utx)
372
    MasterAffiliate getMasterAffiliateByName(1:string name) throws (1:UserAffiliateException utx)
373
	Affiliate createAffiliate(1:string name, 2:string url, 3:i64 masterAffiliateId, 4:i64 addedOn) throws (1:UserAffiliateException utx)
374
	Affiliate getAffiliateById(1:i64 id) throws (1:UserAffiliateException utx)
375
	Affiliate getAffiliateByName(1:string name) throws (1:UserAffiliateException utx)
376
	Tracker getTrackerById(1:i64 id) throws (1:UserAffiliateException utx)
377
	list<Affiliate> getAffiliatesByMasterAffiliate(1:i64 id) throws (1:UserAffiliateException utx)
378
	i64 addTrackLog(1:i64 affiliateId, 2:i64 userId, 3:string event, 4:string url, 5:string data, 6:i64 addedOn) throws (1:UserAffiliateException utx)
379
	TrackLog getTrackLogById(1:i64 id) throws (1:UserAffiliateException utx)
380
	list<TrackLog> getTrackLogsByAffiliate(1:i64 affiliateId) throws (1:UserAffiliateException utx)
381
	list<TrackLog> getTrackLogsByUser(1:i64 userId) throws (1:UserAffiliateException utx)
382
	list<TrackLog> getTrackLogs(1:i64 userId, 2:string event, 3:string url) throws (1:UserAffiliateException utx)
1848 vikas 383
 
552 chandransh 384
	i64 createCart(1:i64 userId) throws (1:ShoppingCartException scx),
385
	Cart getCurrentCart(1:i64 userId) throws (1:ShoppingCartException scx),	
386
	Cart getCart(1:i64 cartId) throws (1:ShoppingCartException scx),
387
	list<Cart> getCartsForUser(1:i64 userId, 2:CartStatus status) throws (1:ShoppingCartException scx),
388
	list<Cart> getCartsByStatus(1:CartStatus status) throws (1:ShoppingCartException scx),
389
	list<Cart> getCartsByTime(1:i64 from_time, 2:i64 to_time, 3:CartStatus status) throws (1:ShoppingCartException scx),
390
	void changeCartStatus(1:i64 cartId, 2:CartStatus status) throws (1:ShoppingCartException scx),
2033 rajveer 391
	string addItemToCart(1:i64 cartId, 2:i64 itemId, 3:i64 quantity) throws (1:ShoppingCartException scx),
552 chandransh 392
	void deleteItemFromCart(1:i64 cartId, 2:i64 itemId) throws (1:ShoppingCartException scx),
393
	void changeQuantity(1:i64 cartId, 2:i64 itemId, 3:i64 quantity) throws (1:ShoppingCartException scx),
394
	void changeItemStatus(1:i64 cartId, 2:i64 itemId, 3:LineStatus status) throws (1:ShoppingCartException scx),
577 chandransh 395
	void addAddressToCart(1:i64 cartId, 2:i64 addressId) throws (1:ShoppingCartException scx),
1984 varun.gupt 396
	void applyCouponToCart(1:i64 cartId, 2:string couponCode, 3:double totalPrice, 4:double discountedPrice) throws (1:ShoppingCartException scx),
397
	void removeCoupon(1:i64 cartId) throws (1:ShoppingCartException scx),
687 chandransh 398
 
399
	/**
400
	 Creates a transaction and multiple orders for the given cart. Returns the transaction ID created.
401
	*/
2814 vikas 402
	i64 createOrders(1:i64 cartId, 2:string sessionSource, 3:i64 sessionStartTime) throws (1:ShoppingCartException scx),
687 chandransh 403
 
404
	/**
405
	 Validates that:
406
	 1. The checkout timestamp is greater than the updatedOn timestamp.
1466 ankur.sing 407
	 2. All of the lines in the cart are active items.
687 chandransh 408
	 3. The estimate for any of the lines in cart doesn't change.
1466 ankur.sing 409
	 If all three are true, returns empty string; else returns appropriate message.
687 chandransh 410
	*/
1466 ankur.sing 411
	string validateCart(1:i64 cartId) throws (1:ShoppingCartException scex),
552 chandransh 412
 
687 chandransh 413
	/**
414
	 Merges the lines from the first cart into the second cart. Lines with duplicate items are removed.
415
	*/
416
	void mergeCart(1:i64 fromCartId, 2:i64 toCartId),
417
 
418
	/**
419
	 Sets the checkedOutOn timestamp of the cart. Raises an exception if the specified cart can't be found.
420
	*/
421
	bool checkOut(1:i64 cartId) throws (1:ShoppingCartException scex),
422
 
423
	/**
424
	 The second parameter is a map of item ids and their quantities which have been successfully processed.
425
	 This methods removes the specified quantiry of the specified item from the cart.
770 rajveer 426
	 */
427
	bool resetCart(1:i64 cartId, 2:map<i64, double> items) throws (1:ShoppingCartException scex),
428
 
687 chandransh 429
 
1599 ankur.sing 430
	/**
431
	Returns number of registered users.
432
	If userType = null, then it returns count of all users, including anonymous
433
	If userType = UserType.ANONYMOUS, then it returns count of anonymous users only
434
	If userType = UserType.USER, then it returns count of non-anonymous users only
435
	*/
1672 ankur.sing 436
	i64 getUserCount(1:UserType userType),
1599 ankur.sing 437
 
1672 ankur.sing 438
	/**
1891 ankur.sing 439
	Returns list of users of type userType who registered between startDate and endDate (both inclusive).
440
	If any of startDate or endDate is -1, then that filter is ignored. 
441
	If userType is null, then returns all the users, irrespective of anonymous flag
442
 
1672 ankur.sing 443
	*/
2642 varun.gupt 444
	list<User> getAllUsers(1:UserType userType, 2:i64 startDate, 3:i64 endDate),
2717 varun.gupt 445
 
1599 ankur.sing 446
 
2717 varun.gupt 447
	void putUserNote(1:i64 user_id, 2:i64 entity_id, 3:string slide, 4:string note),
2981 rajveer 448
	list<UserNote> getUserNotes(1:i64 user_id, 2:i64 entity_id),
449
 
450
 
451
	/**
452
	Returns list of item ids in myresearch for the user
453
	*/
454
	list<i64> getMyResearchItems(1:i64 userId) throws (1:WidgetException scx),
455
	/**
456
	add item to my research for a user
457
	*/
458
	bool updateMyResearch(1:i64 userId, 2:i64 itemId) throws (1:WidgetException scx),
459
	/**
460
	delete item from my research for a user
461
	*/
462
	void deleteItemFromMyResearch(1:i64 userId, 2:i64 itemId) throws (1:WidgetException scx),
463
	/**
464
	Returns list of item ids in browse history for the user. It will return maximum 10 items.
465
	*/
466
	list<i64> getBrowseHistoryItems(1:i64 userId) throws (1:WidgetException scx),
467
	/**
468
	add item to browse history for a user
469
	*/
470
	void updateBrowseHistory(1:i64 userId, 2:i64 itemId)
471
 
2642 varun.gupt 472
}