Subversion Repositories SmartDukaan

Rev

Rev 3379 | Rev 3428 | 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
 
3374 rajveer 4
include "GenericService.thrift"
5
 
48 ashish 6
/**
7
Exceptions
8
*/
9
exception AuthenticationException{
10
	1:string message,
11
	2:i32 errorCode
12
}
13
 
14
exception UserContextException{
15
	1:i32 errorCode,
16
	2:string message
17
}
18
 
552 chandransh 19
exception ShoppingCartException{
20
	1:i64 id,
21
	2:string message
22
}
23
 
1116 varun.gupt 24
exception UserCommunicationException{
25
	1:i64 id,
26
	2:string message
27
}
28
 
1995 vikas 29
exception UserAffiliateException{
1848 vikas 30
    1:i64 id,
31
    2:string message
32
}
33
 
1599 ankur.sing 34
enum UserType{
35
	USER = 0,
36
	ANONYMOUS = 1 
37
}
38
 
121 ashish 39
enum AddressType{
130 ashish 40
	WORK = 0,
41
	HOME = 1
48 ashish 42
}
43
 
130 ashish 44
enum PhoneType{
45
	WORK = 0,
46
	HOME = 1,
47
	MOBILE = 2
48
}
49
 
50
enum AccountStatus{
51
	ACTIVE = 0,
52
	DELETED = 1,
53
	INACTIVE = 2,
54
	INCOMPLETE = 3
55
}
56
 
48 ashish 57
/**
1116 varun.gupt 58
Form types for Contact Us form
59
*/
60
enum UserCommunicationType{
61
	RETURN_FORM = 1,
62
	ORDER_CANCELLATION = 2,
63
	DELIVERY_PROBLEM = 3,
64
	PAYMENT_STATUS = 4,
65
	ORDER_STATUS = 5,
66
	PRODUCT_REQUEST = 6,
67
	PRODUCT_QUESTION = 7,
3339 mandeep.dh 68
	OTHER = 8
1116 varun.gupt 69
}
70
 
71
/**
3379 vikas 72
Affiliate track log types for affiliate tracking
73
*/
74
enum TrackLogType{
75
    NEW_REGISTRATION = 1,
76
    PAYMENT_SUCCESS = 2
77
}
78
 
79
/**
121 ashish 80
All the social handles
48 ashish 81
*/
121 ashish 82
struct SocialHandles{
48 ashish 83
	1:string facebook,
84
	2:string opensocial,
85
	3:string twitter
86
}
87
 
121 ashish 88
/**
89
Address
90
*/
91
struct Address{
552 chandransh 92
	1:i64 id,
93
	2:string line1,
94
	3:string line2,
95
	4:string landmark,
96
	5:string city,
97
	6:string state,
98
	7:string pin,
99
	8:string country,
48 ashish 100
	9:bool enabled,
123 ashish 101
	10:AddressType type,
414 ashish 102
	11:i64 addedOn,
103
	12:string name,
104
	13:string phone
48 ashish 105
}
106
 
130 ashish 107
/**Phone
108
**/
109
struct Phone{
110
	1:i64 id,
111
	2:string countryCode,
112
	3:string areaCode,
113
	4:string number,
114
	5:string extension,
552 chandransh 115
	6:PhoneType type
130 ashish 116
}
117
 
121 ashish 118
/**
119
Internal information to be used by system. various variables which aid in serving the user are identified and put here
120
**/
121
struct UserInternalInfo{
48 ashish 122
	1:i64 userId,
121 ashish 123
	2:i64 geoZone,
124
	3:i64 shipmentZone,
48 ashish 125
	4:i64 taxZone,
126
	5:double userRankScore
127
}
128
 
121 ashish 129
/**
130
structure representing timestamp and ip at which user logged into the system
131
**/
132
struct IPMap{
133
	1:i64 timestamp
123 ashish 134
	2:string ip
48 ashish 135
}
136
 
121 ashish 137
/**
138
dynamic user state 
139
**/
140
struct UserState{
48 ashish 141
	1:i64 userId,
552 chandransh 142
	2:i64 lastLogin,
143
	3:i64 lastLogout,
144
	4:i64 emailVerificationSentOn,
145
	5:i64 smsVerificationSentOn,
146
	6:bool isEmailVerified,
48 ashish 147
	7:bool isSMSVerified,
148
	8:i64 activeSince,
552 chandransh 149
	9:list<IPMap> ips,
150
	10:AccountStatus status
48 ashish 151
}
152
 
552 chandransh 153
enum Sex{
154
	MALE,
155
	FEMALE,
156
	WONT_SAY
157
}
158
 
121 ashish 159
/**
552 chandransh 160
The user structure holding the basic information that identifies the user.
121 ashish 161
**/
552 chandransh 162
struct User{
163
	1:i64 userId,
164
	2:string email,
165
	3:string password,
166
	4:string name,
566 rajveer 167
	5:string dateOfBirth,
1116 varun.gupt 168
	6:Sex sex,
169
	7:string mobileNumber,
552 chandransh 170
	8:SocialHandles socialHandles,
171
	9:list<Address> addresses,
172
	10:i64 defaultAddressId,
173
	11:string communicationEmail,
174
	12:i64 activeCartId,
175
	13:string jsessionId,
2020 vikas 176
	14:bool isAnonymous,
2814 vikas 177
	15:string source,
178
	16:i64 sourceStartTime
48 ashish 179
}
180
 
1116 varun.gupt 181
struct UserCommunication{
182
	1:i64 id,
183
	2:i64 userId,
184
	3:UserCommunicationType communicationType,
185
	4:i64 orderId,
186
	5:string airwaybillNo,
187
	6:string replyTo,
188
	7:string productName,
189
	8:string subject,
190
	9:string message,
1299 varun.gupt 191
	10:i64 communication_timestamp
1116 varun.gupt 192
}
193
 
1848 vikas 194
struct MasterAffiliate{
195
    1:i64 id,
196
    2:string name,
1861 vikas 197
    3:i64 addedOn
1848 vikas 198
}
199
 
200
struct Affiliate{
201
    1:i64 id,
202
    2:string name,
203
    3:string url,
1861 vikas 204
    4:i64 masterAffiliateId,
205
    5:i64 addedOn
1848 vikas 206
}
207
 
208
struct Tracker{
209
    1:i64 id,
1861 vikas 210
    2:i64 affiliateId,
1848 vikas 211
}
212
 
213
struct TrackLog{
214
    1:i64 id,
1861 vikas 215
    2:i64 addedOn,
1995 vikas 216
    3:i64 affiliateId,
1861 vikas 217
    4:i64 userId,
3379 vikas 218
    5:TrackLogType eventType,
1861 vikas 219
    6:string url,
220
    7:string data
1848 vikas 221
}
222
 
2642 varun.gupt 223
struct UserNote{
224
	1:i64 user_id,
225
	2:i64 entity_id,
2717 varun.gupt 226
	3:string slide,
2642 varun.gupt 227
	4:string note
228
}
229
 
552 chandransh 230
//Various statuses for line items
231
enum LineStatus{
232
	LINE_ACTIVE,			//line is active
233
	LINE_DELETED,			//line is deleted
234
	LINE_EXPIRED,			//line is expired, on laspse of fixed amount of time
235
	LINE_COMMITED,			//line is committed, sent for processing.
236
	LINE_COMMIT_FAILED,		//line was committed, but commit failed due to some reason, possibly during cart validation.
237
	LINE_AUTO_DELETED,		//line was auto deleted internally due to some reason(item delisted, price changed etc).
238
}
239
 
240
//Various statuses for Cart
241
enum CartStatus{
242
	ACTIVE,					
243
	INACTIVE,
244
	EXPIRED,
245
	COMMITTED,
246
	COMMIT_FAILED
247
}
248
 
249
struct Line{
646 chandransh 250
	1:i64 cartId,				//identifier
552 chandransh 251
	2:i64 itemId,			//item id added
252
	3:double quantity,		//quantity added 
253
	4:i64 createdOn,		//addition timestamp
254
	5:i64 updatedOn, 		//any updation in quantity or status
255
	6:LineStatus lineStatus,	//current status
1984 varun.gupt 256
	7:i32 estimate,			//delivery estimate in hours
257
	8:double actualPrice,
258
	9:double discountedPrice
552 chandransh 259
}
260
 
261
struct Cart{
262
	1:i64 id,				//identifier
263
	2:list<Line> lines,		//list of lines
264
	3:CartStatus status,	//current status
265
	4:i64 createdOn,		//creation timestamp
266
	5:i64 updatedOn,		//time of last update in cart (like addition/deletion/updation of cart items )
687 chandransh 267
	6:i64 checkedOutOn,		//commited timestamp
552 chandransh 268
	7:i64 userId,			//user id to which it belongs
1984 varun.gupt 269
	8:i64 addressId,	    //address on which this will be shipped
270
	9:double totalPrice,
271
	10:double discountedPrice,
272
	11:string couponCode
552 chandransh 273
}
274
 
275
enum WidgetType{
770 rajveer 276
	MY_RESEARCH,
277
	BROWSE_HISTORY
278
}
279
 
2981 rajveer 280
struct UserWidgetItem{
281
	1:i64 userId,
282
	2:i64 widgetId,
283
	3:i64 itemId,
284
	4:i64 addedOn
552 chandransh 285
}
286
 
287
exception WidgetException{
288
	1:i64 id,
289
	2:string message
290
}
291
 
48 ashish 292
/**
1984 varun.gupt 293
Exceptions for Promotion Service
294
*/
295
exception PromotionException{
296
	1:i64 id,
297
	2:string message
298
}
299
 
300
/**
301
Types for Promotion Service
302
*/
303
 
304
struct Promotion{
305
	1:i64 id,
306
	2:string name,
307
	3:string ruleExecutionSrc,
308
	4:i64 startOn,
309
	5:i64 endOn,
310
	6:i64 createdOn
311
}
312
 
313
struct Coupon{
314
	1:string couponCode
3385 varun.gupt 315
	2:Promotion promotion
1984 varun.gupt 316
	3:string arguments
317
}
318
 
319
struct PromotionTracking{
320
	1:string couponCode,
321
	2:i64 transactionId,
322
	3:i64 userId,
323
	4:bool appliedOn
324
}
325
 
326
/**
327
Promotion Service
328
*/
3374 rajveer 329
service PromotionService extends GenericService.GenericService{
1984 varun.gupt 330
	/**
331
	* For closing the open session in sqlalchemy
332
	*/
333
	void closeSession(),
334
 
335
	void createPromotion(1:string name, 2:string ruleExecutionSrc, 3:i64 startOn, 4:i64 endOn) throws (1:PromotionException pex),
336
	list<Promotion> getAllPromotions() throws (1:PromotionException pex),
337
	Promotion getPromotionById(1:i64 promotionId) throws (1:PromotionException pex),
338
	void generateCouponsForPromotion(1:i64 promotionId, 2:string couponCode) throws (1:PromotionException pex),
339
	Cart applyCoupon(1:string couponCode, 2:i64 cartId) throws (1:PromotionException pex),
340
    void trackCouponUsage(1:string couponCode, 2:i64 transactionId, 3:i64 userId) throws (1:PromotionException pex),
3385 varun.gupt 341
    i64 getCouponUsageCountByUser(1:string couponCode, 2:i64 userId) throws (1:PromotionException pex),
342
 
343
    /**
344
     Returns a list of active coupons
345
     */
346
    list<Coupon> getActiveCoupons() throws (1:PromotionException pex),
347
 
348
    /**
349
     Returns the count of successful payments done using a given coupon
350
     */
351
    i64 getSuccessfulPaymentCountForCoupon(1:string couponCode) throws (1:PromotionException pex),
352
 
353
    /**
354
     Returns the doc string of the rule module
355
     */
356
    string getRuleDocString(1:string ruleName)
1984 varun.gupt 357
}
358
 
359
/**
48 ashish 360
service
361
*/
3374 rajveer 362
service UserContextService extends GenericService.GenericService{
763 rajveer 363
 
552 chandransh 364
	User createAnonymousUser(1:string jsessionId) throws (1:UserContextException ucex),
365
	User getUserById(1:i64 userId) throws (1:UserContextException ucex),
1491 vikas 366
	User getUserByEmail(1:string email) throws (1:UserContextException ucex),
3026 mandeep.dh 367
    User getUserByMobileNumber(1:i64 mobileNumber) throws (1:UserContextException ucex),
552 chandransh 368
	User createUser(1:User user) throws (1:UserContextException ucex),
369
	User updateUser(1:User user) throws (1:UserContextException ucex),
370
	bool deleteUser(1:i64 userId) throws (1:UserContextException ucex),
371
	UserState getUserState(1:i64 userId) throws (1:UserContextException ucex),
372
	User authenticateUser(1:string email, 2:string password) throws (1:AuthenticationException auex),
373
	bool userExists(1:string email) throws (1:UserContextException ucx),
566 rajveer 374
	i64 addAddressForUser(1:i64 userId, 2:Address address, 3:bool setDefault)throws (1:UserContextException ucx),
48 ashish 375
	bool removeAddressForUser(1:i64 userid, 2:i64 addressId)throws (1:UserContextException ucx),
376
	bool setUserAsLoggedIn(1:i64 userId, 2:i64 timestamp)throws (1:UserContextException ucx),
377
	bool setUserAsLoggedOut(1:i64 userid, 2:i64 timestamp)throws (1:UserContextException ucx),
506 rajveer 378
	bool setDefaultAddress(1:i64 userid, 2:i64 addressId)throws (1:UserContextException ucx),
592 rajveer 379
	bool updatePassword(1:i64 userid, 2:string oldPassword, 3:string newPassword)throws (1:UserContextException ucx),
895 rajveer 380
	bool forgotPassword(1:string email, 2:string newPassword)throws (1:UserContextException ucx),
592 rajveer 381
	list<Address> getAllAddressesForUser(1:i64 userId)throws (1:UserContextException ucx),
1892 vikas 382
	Address getAddressById(1:i64 addressId)throws (1:UserContextException ucx),
592 rajveer 383
	i64 getDefaultAddressId(1:i64 userId)throws (1:UserContextException ucx),
783 rajveer 384
	string getDefaultPincode(1:i64 userId)throws (1:UserContextException ucx),
552 chandransh 385
 
1167 varun.gupt 386
	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 387
	UserCommunication getUserCommunicationById(1:i64 id) throws (1:UserCommunicationException ucx)
388
	list<UserCommunication> getUserCommunicationByUser(1:i64 userId) throws (1:UserCommunicationException ucx)
389
	list<UserCommunication> getAllUserCommunications() throws (1:UserCommunicationException ucx)
1116 varun.gupt 390
 
1995 vikas 391
	MasterAffiliate createMasterAffiliate(1:string name, 2:i64 addedOn) throws (1:UserAffiliateException utx)
392
	list<MasterAffiliate> getAllMasterAffiliates() throws (1:UserAffiliateException utx)
393
	MasterAffiliate getMasterAffiliateById(1:i64 id) throws (1:UserAffiliateException utx)
394
    MasterAffiliate getMasterAffiliateByName(1:string name) throws (1:UserAffiliateException utx)
395
	Affiliate createAffiliate(1:string name, 2:string url, 3:i64 masterAffiliateId, 4:i64 addedOn) throws (1:UserAffiliateException utx)
396
	Affiliate getAffiliateById(1:i64 id) throws (1:UserAffiliateException utx)
397
	Affiliate getAffiliateByName(1:string name) throws (1:UserAffiliateException utx)
398
	Tracker getTrackerById(1:i64 id) throws (1:UserAffiliateException utx)
399
	list<Affiliate> getAffiliatesByMasterAffiliate(1:i64 id) throws (1:UserAffiliateException utx)
3379 vikas 400
	i64 addTrackLog(1:i64 affiliateId, 2:i64 userId, 3:TrackLogType event, 4:string url, 5:string data, 6:i64 addedOn) throws (1:UserAffiliateException utx)
1995 vikas 401
	TrackLog getTrackLogById(1:i64 id) throws (1:UserAffiliateException utx)
3293 vikas 402
	list<TrackLog> getTrackLogsByAffiliate(1:i64 affiliateId, 2:i64 startDate, 3:i64 endDate) throws (1:UserAffiliateException utx)
1995 vikas 403
	list<TrackLog> getTrackLogsByUser(1:i64 userId) throws (1:UserAffiliateException utx)
404
	list<TrackLog> getTrackLogs(1:i64 userId, 2:string event, 3:string url) throws (1:UserAffiliateException utx)
1848 vikas 405
 
552 chandransh 406
	i64 createCart(1:i64 userId) throws (1:ShoppingCartException scx),
407
	Cart getCurrentCart(1:i64 userId) throws (1:ShoppingCartException scx),	
408
	Cart getCart(1:i64 cartId) throws (1:ShoppingCartException scx),
409
	list<Cart> getCartsForUser(1:i64 userId, 2:CartStatus status) throws (1:ShoppingCartException scx),
410
	list<Cart> getCartsByStatus(1:CartStatus status) throws (1:ShoppingCartException scx),
411
	list<Cart> getCartsByTime(1:i64 from_time, 2:i64 to_time, 3:CartStatus status) throws (1:ShoppingCartException scx),
412
	void changeCartStatus(1:i64 cartId, 2:CartStatus status) throws (1:ShoppingCartException scx),
2033 rajveer 413
	string addItemToCart(1:i64 cartId, 2:i64 itemId, 3:i64 quantity) throws (1:ShoppingCartException scx),
552 chandransh 414
	void deleteItemFromCart(1:i64 cartId, 2:i64 itemId) throws (1:ShoppingCartException scx),
415
	void changeQuantity(1:i64 cartId, 2:i64 itemId, 3:i64 quantity) throws (1:ShoppingCartException scx),
416
	void changeItemStatus(1:i64 cartId, 2:i64 itemId, 3:LineStatus status) throws (1:ShoppingCartException scx),
577 chandransh 417
	void addAddressToCart(1:i64 cartId, 2:i64 addressId) throws (1:ShoppingCartException scx),
1984 varun.gupt 418
	void applyCouponToCart(1:i64 cartId, 2:string couponCode, 3:double totalPrice, 4:double discountedPrice) throws (1:ShoppingCartException scx),
419
	void removeCoupon(1:i64 cartId) throws (1:ShoppingCartException scx),
687 chandransh 420
 
421
	/**
422
	 Creates a transaction and multiple orders for the given cart. Returns the transaction ID created.
423
	*/
2814 vikas 424
	i64 createOrders(1:i64 cartId, 2:string sessionSource, 3:i64 sessionStartTime) throws (1:ShoppingCartException scx),
687 chandransh 425
 
426
	/**
427
	 Validates that:
428
	 1. The checkout timestamp is greater than the updatedOn timestamp.
1466 ankur.sing 429
	 2. All of the lines in the cart are active items.
687 chandransh 430
	 3. The estimate for any of the lines in cart doesn't change.
1466 ankur.sing 431
	 If all three are true, returns empty string; else returns appropriate message.
687 chandransh 432
	*/
1466 ankur.sing 433
	string validateCart(1:i64 cartId) throws (1:ShoppingCartException scex),
552 chandransh 434
 
687 chandransh 435
	/**
436
	 Merges the lines from the first cart into the second cart. Lines with duplicate items are removed.
437
	*/
438
	void mergeCart(1:i64 fromCartId, 2:i64 toCartId),
439
 
440
	/**
441
	 Sets the checkedOutOn timestamp of the cart. Raises an exception if the specified cart can't be found.
442
	*/
443
	bool checkOut(1:i64 cartId) throws (1:ShoppingCartException scex),
444
 
445
	/**
446
	 The second parameter is a map of item ids and their quantities which have been successfully processed.
447
	 This methods removes the specified quantiry of the specified item from the cart.
770 rajveer 448
	 */
449
	bool resetCart(1:i64 cartId, 2:map<i64, double> items) throws (1:ShoppingCartException scex),
450
 
687 chandransh 451
 
1599 ankur.sing 452
	/**
453
	Returns number of registered users.
454
	If userType = null, then it returns count of all users, including anonymous
455
	If userType = UserType.ANONYMOUS, then it returns count of anonymous users only
456
	If userType = UserType.USER, then it returns count of non-anonymous users only
457
	*/
1672 ankur.sing 458
	i64 getUserCount(1:UserType userType),
1599 ankur.sing 459
 
1672 ankur.sing 460
	/**
1891 ankur.sing 461
	Returns list of users of type userType who registered between startDate and endDate (both inclusive).
462
	If any of startDate or endDate is -1, then that filter is ignored. 
463
	If userType is null, then returns all the users, irrespective of anonymous flag
464
 
1672 ankur.sing 465
	*/
2642 varun.gupt 466
	list<User> getAllUsers(1:UserType userType, 2:i64 startDate, 3:i64 endDate),
2717 varun.gupt 467
 
1599 ankur.sing 468
 
2717 varun.gupt 469
	void putUserNote(1:i64 user_id, 2:i64 entity_id, 3:string slide, 4:string note),
2981 rajveer 470
	list<UserNote> getUserNotes(1:i64 user_id, 2:i64 entity_id),
471
 
472
 
473
	/**
474
	Returns list of item ids in myresearch for the user
475
	*/
476
	list<i64> getMyResearchItems(1:i64 userId) throws (1:WidgetException scx),
477
	/**
478
	add item to my research for a user
479
	*/
480
	bool updateMyResearch(1:i64 userId, 2:i64 itemId) throws (1:WidgetException scx),
481
	/**
482
	delete item from my research for a user
483
	*/
484
	void deleteItemFromMyResearch(1:i64 userId, 2:i64 itemId) throws (1:WidgetException scx),
485
	/**
486
	Returns list of item ids in browse history for the user. It will return maximum 10 items.
487
	*/
488
	list<i64> getBrowseHistoryItems(1:i64 userId) throws (1:WidgetException scx),
489
	/**
490
	add item to browse history for a user
491
	*/
3385 varun.gupt 492
	void updateBrowseHistory(1:i64 userId, 2:i64 itemId),
493
 
494
	/**
495
	Returns count of Carts with given coupon applied
496
	*/
497
	i64 getCartsWithCouponCount(1:string couponCode)
2642 varun.gupt 498
}