Subversion Repositories SmartDukaan

Rev

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