Subversion Repositories SmartDukaan

Rev

Rev 895 | Rev 1142 | 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
 
4
/**
5
Exceptions
6
*/
7
exception AuthenticationException{
8
	1:string message,
9
	2:i32 errorCode
10
}
11
 
12
exception UserContextException{
13
	1:i32 errorCode,
14
	2:string message
15
}
16
 
552 chandransh 17
exception ShoppingCartException{
18
	1:i64 id,
19
	2:string message
20
}
21
 
1116 varun.gupt 22
exception UserCommunicationException{
23
	1:i64 id,
24
	2:string message
25
}
26
 
121 ashish 27
enum AddressType{
130 ashish 28
	WORK = 0,
29
	HOME = 1
48 ashish 30
}
31
 
130 ashish 32
enum PhoneType{
33
	WORK = 0,
34
	HOME = 1,
35
	MOBILE = 2
36
}
37
 
38
enum AccountStatus{
39
	ACTIVE = 0,
40
	DELETED = 1,
41
	INACTIVE = 2,
42
	INCOMPLETE = 3
43
}
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,
56
	OTHER = 7
57
}
58
 
59
/**
121 ashish 60
All the social handles
48 ashish 61
*/
121 ashish 62
struct SocialHandles{
48 ashish 63
	1:string facebook,
64
	2:string opensocial,
65
	3:string twitter
66
}
67
 
121 ashish 68
/**
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
 
130 ashish 87
/**Phone
88
**/
89
struct Phone{
90
	1:i64 id,
91
	2:string countryCode,
92
	3:string areaCode,
93
	4:string number,
94
	5:string extension,
552 chandransh 95
	6:PhoneType type
130 ashish 96
}
97
 
121 ashish 98
/**
99
Internal information to be used by system. various variables which aid in serving the user are identified and put here
100
**/
101
struct UserInternalInfo{
48 ashish 102
	1:i64 userId,
121 ashish 103
	2:i64 geoZone,
104
	3:i64 shipmentZone,
48 ashish 105
	4:i64 taxZone,
106
	5:double userRankScore
107
}
108
 
121 ashish 109
/**
110
structure representing timestamp and ip at which user logged into the system
111
**/
112
struct IPMap{
113
	1:i64 timestamp
123 ashish 114
	2:string ip
48 ashish 115
}
116
 
121 ashish 117
/**
118
dynamic user state 
119
**/
120
struct UserState{
48 ashish 121
	1:i64 userId,
552 chandransh 122
	2:i64 lastLogin,
123
	3:i64 lastLogout,
124
	4:i64 emailVerificationSentOn,
125
	5:i64 smsVerificationSentOn,
126
	6:bool isEmailVerified,
48 ashish 127
	7:bool isSMSVerified,
128
	8:i64 activeSince,
552 chandransh 129
	9:list<IPMap> ips,
130
	10:AccountStatus status
48 ashish 131
}
132
 
552 chandransh 133
enum Sex{
134
	MALE,
135
	FEMALE,
136
	WONT_SAY
137
}
138
 
121 ashish 139
/**
552 chandransh 140
The user structure holding the basic information that identifies the user.
121 ashish 141
**/
552 chandransh 142
struct User{
143
	1:i64 userId,
144
	2:string email,
145
	3:string password,
146
	4:string name,
566 rajveer 147
	5:string dateOfBirth,
1116 varun.gupt 148
	6:Sex sex,
149
	7:string mobileNumber,
552 chandransh 150
	8:SocialHandles socialHandles,
151
	9:list<Address> addresses,
152
	10:i64 defaultAddressId,
153
	11:string communicationEmail,
154
	12:i64 activeCartId,
155
	13:string jsessionId,
156
	14:bool isAnonymous
48 ashish 157
}
158
 
1116 varun.gupt 159
struct UserCommunication{
160
	1:i64 id,
161
	2:i64 userId,
162
	3:UserCommunicationType communicationType,
163
	4:i64 orderId,
164
	5:string airwaybillNo,
165
	6:string replyTo,
166
	7:string productName,
167
	8:string subject,
168
	9:string message,
169
	10:i64 addedAt
170
}
171
 
552 chandransh 172
//Various statuses for line items
173
enum LineStatus{
174
	LINE_ACTIVE,			//line is active
175
	LINE_DELETED,			//line is deleted
176
	LINE_EXPIRED,			//line is expired, on laspse of fixed amount of time
177
	LINE_COMMITED,			//line is committed, sent for processing.
178
	LINE_COMMIT_FAILED,		//line was committed, but commit failed due to some reason, possibly during cart validation.
179
	LINE_AUTO_DELETED,		//line was auto deleted internally due to some reason(item delisted, price changed etc).
180
}
181
 
182
//Various statuses for Cart
183
enum CartStatus{
184
	ACTIVE,					
185
	INACTIVE,
186
	EXPIRED,
187
	COMMITTED,
188
	COMMIT_FAILED
189
}
190
 
191
struct Line{
646 chandransh 192
	1:i64 cartId,				//identifier
552 chandransh 193
	2:i64 itemId,			//item id added
194
	3:double quantity,		//quantity added 
195
	4:i64 createdOn,		//addition timestamp
196
	5:i64 updatedOn, 		//any updation in quantity or status
197
	6:LineStatus lineStatus,	//current status
613 chandransh 198
	7:i32 estimate			//delivery estimate in hours
552 chandransh 199
}
200
 
201
struct Cart{
202
	1:i64 id,				//identifier
203
	2:list<Line> lines,		//list of lines
204
	3:CartStatus status,	//current status
205
	4:i64 createdOn,		//creation timestamp
206
	5:i64 updatedOn,		//time of last update in cart (like addition/deletion/updation of cart items )
687 chandransh 207
	6:i64 checkedOutOn,		//commited timestamp
552 chandransh 208
	7:i64 userId,			//user id to which it belongs
613 chandransh 209
	8:i64 addressId,	    //address on which this will be shipped			
552 chandransh 210
}
211
 
212
enum WidgetType{
770 rajveer 213
	MY_RESEARCH,
214
	BROWSE_HISTORY
215
}
216
 
217
/** Not used right now, will decide later
218
enum WidgetType{
219
	ACCESSORIES,
220
	RATINGS,
552 chandransh 221
	SIMILAR_ITEMS,
222
	RECOMMENDED_ITEMS,
770 rajveer 223
	DEAL_PROMOTIONS,
224
 
552 chandransh 225
	MY_RESEARCH,
770 rajveer 226
	BROWSE_HISTORY
552 chandransh 227
}
228
 
229
enum RatingType{
230
	SHOP2020,
231
	AMAZON,
232
	USER_ALL,
233
	USER_CURRENT
234
}
235
 
236
struct RatingsWidget{
237
	1:i64 catalog_item_id,
238
	2:map<RatingType,double> ratings,
239
	3:i64 user_id
240
}
770 rajveer 241
*/
552 chandransh 242
struct WidgetItem{
243
	1:i64 id,
244
	2:i64 item_id,
770 rajveer 245
	3:bool enabled,
246
	4:i64 timestamp
552 chandransh 247
}
248
 
249
struct Widget{
250
	1:i64 id,
251
	2:WidgetType type,
770 rajveer 252
	3:i64 user_id,
552 chandransh 253
	4:list<WidgetItem> items,
254
	5:bool enabled,
770 rajveer 255
	6:string name
552 chandransh 256
}
257
 
258
exception WidgetException{
259
	1:i64 id,
260
	2:string message
261
}
262
 
48 ashish 263
/**
264
service
265
*/
266
service UserContextService{
763 rajveer 267
	/**
268
	* For closing the open session in sqlalchemy
269
	*/
270
	void closeSession(),
271
 
552 chandransh 272
	User createAnonymousUser(1:string jsessionId) throws (1:UserContextException ucex),
273
	User getUserById(1:i64 userId) throws (1:UserContextException ucex),
274
	User createUser(1:User user) throws (1:UserContextException ucex),
275
	User updateUser(1:User user) throws (1:UserContextException ucex),
276
	bool deleteUser(1:i64 userId) throws (1:UserContextException ucex),
277
	UserState getUserState(1:i64 userId) throws (1:UserContextException ucex),
278
	User authenticateUser(1:string email, 2:string password) throws (1:AuthenticationException auex),
279
	bool userExists(1:string email) throws (1:UserContextException ucx),
566 rajveer 280
	i64 addAddressForUser(1:i64 userId, 2:Address address, 3:bool setDefault)throws (1:UserContextException ucx),
48 ashish 281
	bool removeAddressForUser(1:i64 userid, 2:i64 addressId)throws (1:UserContextException ucx),
282
	bool setUserAsLoggedIn(1:i64 userId, 2:i64 timestamp)throws (1:UserContextException ucx),
283
	bool setUserAsLoggedOut(1:i64 userid, 2:i64 timestamp)throws (1:UserContextException ucx),
506 rajveer 284
	bool setDefaultAddress(1:i64 userid, 2:i64 addressId)throws (1:UserContextException ucx),
592 rajveer 285
	bool updatePassword(1:i64 userid, 2:string oldPassword, 3:string newPassword)throws (1:UserContextException ucx),
895 rajveer 286
	bool forgotPassword(1:string email, 2:string newPassword)throws (1:UserContextException ucx),
592 rajveer 287
	list<Address> getAllAddressesForUser(1:i64 userId)throws (1:UserContextException ucx),
288
	i64 getDefaultAddressId(1:i64 userId)throws (1:UserContextException ucx),
783 rajveer 289
	string getDefaultPincode(1:i64 userId)throws (1:UserContextException ucx),
552 chandransh 290
 
1116 varun.gupt 291
	bool saveUserCommunication(1:UserCommunication user_communication)throws (1:UserCommunicationException ucx) 
292
 
552 chandransh 293
	i64 createCart(1:i64 userId) throws (1:ShoppingCartException scx),
294
	Cart getCurrentCart(1:i64 userId) throws (1:ShoppingCartException scx),	
295
	Cart getCart(1:i64 cartId) throws (1:ShoppingCartException scx),
296
	list<Cart> getCartsForUser(1:i64 userId, 2:CartStatus status) throws (1:ShoppingCartException scx),
297
	list<Cart> getCartsByStatus(1:CartStatus status) throws (1:ShoppingCartException scx),
298
	list<Cart> getCartsByTime(1:i64 from_time, 2:i64 to_time, 3:CartStatus status) throws (1:ShoppingCartException scx),
299
	void changeCartStatus(1:i64 cartId, 2:CartStatus status) throws (1:ShoppingCartException scx),
300
	void addItemToCart(1:i64 cartId, 2:i64 itemId, 3:i64 quantity) throws (1:ShoppingCartException scx),
301
	void deleteItemFromCart(1:i64 cartId, 2:i64 itemId) throws (1:ShoppingCartException scx),
302
	void changeQuantity(1:i64 cartId, 2:i64 itemId, 3:i64 quantity) throws (1:ShoppingCartException scx),
303
	void changeItemStatus(1:i64 cartId, 2:i64 itemId, 3:LineStatus status) throws (1:ShoppingCartException scx),
577 chandransh 304
	void addAddressToCart(1:i64 cartId, 2:i64 addressId) throws (1:ShoppingCartException scx),
687 chandransh 305
 
306
	/**
307
	 Creates a transaction and multiple orders for the given cart. Returns the transaction ID created.
308
	*/
309
	i64 createOrders(1:i64 cartId) throws (1:ShoppingCartException scx),
310
 
311
	/**
312
	 Validates that:
313
	 1. The checkout timestamp is greater than the updatedOn timestamp.
314
	 2. None of the lines in the cart for an inactive item.
315
	 3. The estimate for any of the lines in cart doesn't change.
316
	 Returns true only if all three hold.
317
	*/
577 chandransh 318
	bool validateCart(1:i64 cartId) throws (1:ShoppingCartException scex),
552 chandransh 319
 
687 chandransh 320
	/**
321
	 Merges the lines from the first cart into the second cart. Lines with duplicate items are removed.
322
	*/
323
	void mergeCart(1:i64 fromCartId, 2:i64 toCartId),
324
 
325
	/**
326
	 Sets the checkedOutOn timestamp of the cart. Raises an exception if the specified cart can't be found.
327
	*/
328
	bool checkOut(1:i64 cartId) throws (1:ShoppingCartException scex),
329
 
330
	/**
331
	 The second parameter is a map of item ids and their quantities which have been successfully processed.
332
	 This methods removes the specified quantiry of the specified item from the cart.
770 rajveer 333
	 */
334
	bool resetCart(1:i64 cartId, 2:map<i64, double> items) throws (1:ShoppingCartException scex),
335
 
336
	/**
337
	* Widgets 
687 chandransh 338
	*/
770 rajveer 339
	Widget getMyResearch(1:i64 userId) throws (1:WidgetException scx),
340
	bool updateMyResearch(1:i64 userId, 2:i64 itemId) throws (1:WidgetException scx),
341
	void deleteItemFromMyResearch(1:i64 userId, 2:i64 itemId) throws (1:WidgetException scx),
342
 
343
	void updateBrowseHistory(1:i64 userId, 2:i64 itemId),
344
	Widget getBrowseHistory(1:i64 userId) throws (1:WidgetException scx),
345
	void mergeBrowseHistory(1:i64 fromUserId, 2:i64 toUserId)
687 chandransh 346
 
770 rajveer 347
	/** Masking right now. May be used later.	
552 chandransh 348
	void addWidget(1:Widget widget) throws (1:WidgetException scx),
349
	void addItemToWidget(1:i64 widget_id, 2:list<i64> items) throws (1:WidgetException scx),
350
	void deleteItemFromWidget(1:i64 widget_id, 2:i64 item_id) throws (1:WidgetException scx),
351
	void updateWidget(1:i64 widgetId, 2:bool enable) throws (1:WidgetException scx),
352
	void updateWidgetItem(1:i64 widgetId, 2:bool enable) throws (1:WidgetException scx),
353
	Widget getWidget(1:WidgetType type, 2:i64 userId, 3:bool onlyEnabled) throws (1:WidgetException scx),
770 rajveer 354
	*/
48 ashish 355
}
356