Subversion Repositories SmartDukaan

Rev

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