Subversion Repositories SmartDukaan

Rev

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