Subversion Repositories SmartDukaan

Rev

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