Subversion Repositories SmartDukaan

Rev

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