Subversion Repositories SmartDukaan

Rev

Rev 513 | Rev 566 | 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,
128
	5:i64 dateOfBirth,
129
	6:Sex sex
130
	7:set<Phone> phones,
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{
160
	1:i64 id,				//identifier
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
166
}
167
 
168
struct Cart{
169
	1:i64 id,				//identifier
170
	2:list<Line> lines,		//list of lines
171
	3:CartStatus status,	//current status
172
	4:i64 createdOn,		//creation timestamp
173
	5:i64 updatedOn,		//time of last update in cart (like addition/deletion/updation of cart items )
174
	6:i64 committedOn,		//commited timestamp
175
	7:i64 userId,			//user id to which it belongs
176
	8:i64 addressId		    //address on which this will be shipped
177
}
178
 
179
enum WidgetType{
180
	SIMILAR_ITEMS,
181
	RECOMMENDED_ITEMS,
182
	MY_RESEARCH,
183
	ACCESSORIES,
184
	RATINGS,
185
	BROWSE_HISTORY,
186
	DEAL_PROMOTIONS
187
}
188
 
189
enum RatingType{
190
	SHOP2020,
191
	AMAZON,
192
	USER_ALL,
193
	USER_CURRENT
194
}
195
 
196
struct RatingsWidget{
197
	1:i64 catalog_item_id,
198
	2:map<RatingType,double> ratings,
199
	3:i64 user_id
200
}
201
 
202
struct WidgetItem{
203
	1:i64 id,
204
	2:i64 item_id,
205
	3:string snippet,
206
	4:bool enabled,
207
	5:i64 timestamp
208
}
209
 
210
struct Widget{
211
	1:i64 id,
212
	2:WidgetType type,
213
	3:i64 customer_id, //will be valid for MY_RESEARCH
214
	4:list<WidgetItem> items,
215
	5:bool enabled,
216
	6:string name,	
217
	7:bool session_id  //will be valid for BROWSE_HISTORY
218
}
219
 
220
exception WidgetException{
221
	1:i64 id,
222
	2:string message
223
}
224
 
48 ashish 225
/**
226
service
227
*/
228
service UserContextService{
552 chandransh 229
	User createAnonymousUser(1:string jsessionId) throws (1:UserContextException ucex),
230
	User getUserById(1:i64 userId) throws (1:UserContextException ucex),
231
	User createUser(1:User user) throws (1:UserContextException ucex),
232
	User updateUser(1:User user) throws (1:UserContextException ucex),
233
	bool deleteUser(1:i64 userId) throws (1:UserContextException ucex),
234
	UserState getUserState(1:i64 userId) throws (1:UserContextException ucex),
235
	User authenticateUser(1:string email, 2:string password) throws (1:AuthenticationException auex),
236
	bool userExists(1:string email) throws (1:UserContextException ucx),
237
	bool addAddressForUser(1:i64 userId, 2:Address address, 3:i64 timestamp, 4:bool setDefault)throws (1:UserContextException ucx),
48 ashish 238
	bool removeAddressForUser(1:i64 userid, 2:i64 addressId)throws (1:UserContextException ucx),
239
	bool setUserAsLoggedIn(1:i64 userId, 2:i64 timestamp)throws (1:UserContextException ucx),
240
	bool setUserAsLoggedOut(1:i64 userid, 2:i64 timestamp)throws (1:UserContextException ucx),
506 rajveer 241
	bool setDefaultAddress(1:i64 userid, 2:i64 addressId)throws (1:UserContextException ucx),
48 ashish 242
	bool updatePassword(1:i64 userid, 2:string password)throws (1:UserContextException ucx),
552 chandransh 243
 
244
	i64 createCart(1:i64 userId) throws (1:ShoppingCartException scx),
245
	Cart getCurrentCart(1:i64 userId) throws (1:ShoppingCartException scx),	
246
	Cart getCart(1:i64 cartId) throws (1:ShoppingCartException scx),
247
	list<Cart> getCartsForUser(1:i64 userId, 2:CartStatus status) throws (1:ShoppingCartException scx),
248
	list<Cart> getCartsByStatus(1:CartStatus status) throws (1:ShoppingCartException scx),
249
	list<Cart> getCartsByTime(1:i64 from_time, 2:i64 to_time, 3:CartStatus status) throws (1:ShoppingCartException scx),
250
	void changeCartStatus(1:i64 cartId, 2:CartStatus status) throws (1:ShoppingCartException scx),
251
	void addItemToCart(1:i64 cartId, 2:i64 itemId, 3:i64 quantity) throws (1:ShoppingCartException scx),
252
	void deleteItemFromCart(1:i64 cartId, 2:i64 itemId) throws (1:ShoppingCartException scx),
253
	void changeQuantity(1:i64 cartId, 2:i64 itemId, 3:i64 quantity) throws (1:ShoppingCartException scx),
254
	void changeItemStatus(1:i64 cartId, 2:i64 itemId, 3:LineStatus status) throws (1:ShoppingCartException scx),
255
	void addAddressToCart(1:i64 cartId, 2:i64 addressId),
256
	bool commitCart(1:i64 cartId) throws (1:ShoppingCartException scx),
257
	bool validateCart(1:i64 cartId),
258
	void mergeCart(1:i64 fromCartId, 2:i64 toCartId)
259
 
260
	void addWidget(1:Widget widget) throws (1:WidgetException scx),
261
	void addItemToWidget(1:i64 widget_id, 2:list<i64> items) throws (1:WidgetException scx),
262
	void deleteItemFromWidget(1:i64 widget_id, 2:i64 item_id) throws (1:WidgetException scx),
263
	void updateWidget(1:i64 widgetId, 2:bool enable) throws (1:WidgetException scx),
264
	void updateWidgetItem(1:i64 widgetId, 2:bool enable) throws (1:WidgetException scx),
265
	Widget getWidget(1:WidgetType type, 2:i64 userId, 3:bool onlyEnabled) throws (1:WidgetException scx),
266
 
267
	Widget getMyResearch(1:i64 user_id) throws (1:WidgetException scx),
268
	bool updateMyResearch(1:i64 user_id, 2:i64 item_id) throws (1:WidgetException scx),
269
	void deleteItemFromMyResearch(1:i64 user_id, 2:i64 item_id) throws (1:WidgetException scx),
270
 
271
	void updateRatings(1:i64 item_id, 2:RatingType type, 3:double rating, 4:i64 user_id),
272
	RatingsWidget getRatings(1:i64 item_id, 2:i64 user_id)  throws (1:WidgetException scx),
273
 
274
	void updateBrowseHistory(1:i64 user_id, 2:i64 item_id, 3:bool isSessionId),
275
	Widget getBrowseHistory(1:i64 userId, 2:bool isSessionId) throws (1:WidgetException scx)
48 ashish 276
}
277