Subversion Repositories SmartDukaan

Rev

Rev 513 | Rev 566 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 513 Rev 552
Line 2... Line 2...
2
namespace py shop2020.thriftpy.model.v1.user
2
namespace py shop2020.thriftpy.model.v1.user
3
 
3
 
4
/**
4
/**
5
Exceptions
5
Exceptions
6
*/
6
*/
7
 
-
 
8
 
-
 
9
exception AuthenticationException{
7
exception AuthenticationException{
10
	1:string message,
8
	1:string message,
11
	2:i32 errorCode
9
	2:i32 errorCode
12
}
10
}
13
 
11
 
14
exception UserContextException{
12
exception UserContextException{
15
	1:i32 errorCode,
13
	1:i32 errorCode,
16
	2:string message
14
	2:string message
17
}
15
}
18
 
16
 
-
 
17
exception ShoppingCartException{
-
 
18
	1:i64 id,
-
 
19
	2:string message
-
 
20
}
-
 
21
 
19
enum AddressType{
22
enum AddressType{
20
	WORK = 0,
23
	WORK = 0,
21
	HOME = 1
24
	HOME = 1
22
}
25
}
23
 
26
 
Line 45... Line 48...
45
 
48
 
46
/**
49
/**
47
Address
50
Address
48
*/
51
*/
49
struct Address{
52
struct Address{
-
 
53
	1:i64 id,
50
	1:string line1,
54
	2:string line1,
51
	2:string line2,
55
	3:string line2,
52
	3:string landmark,
56
	4:string landmark,
53
	4:string city,
57
	5:string city,
54
	5:string state,
58
	6:string state,
55
	6:string pin,
59
	7:string pin,
56
	7:string country,
60
	8:string country,
57
	8:i64 id,
-
 
58
	9:bool enabled,
61
	9:bool enabled,
59
	10:AddressType type,
62
	10:AddressType type,
60
	11:i64 addedOn,
63
	11:i64 addedOn,
61
	12:string name,
64
	12:string name,
62
	13:string phone
65
	13:string phone
Line 68... Line 71...
68
	1:i64 id,
71
	1:i64 id,
69
	2:string countryCode,
72
	2:string countryCode,
70
	3:string areaCode,
73
	3:string areaCode,
71
	4:string number,
74
	4:string number,
72
	5:string extension,
75
	5:string extension,
73
	6:PhoneType type,
76
	6:PhoneType type
74
}
-
 
75
 
-
 
76
/**
-
 
77
Primary information of the user
-
 
78
**/
-
 
79
struct UserPrimaryInfo{
-
 
80
	1:i64 userId,
-
 
81
	2:string title,
-
 
82
	3:string firstName,
-
 
83
	4:string lastName,
-
 
84
	5:string pictureUrl,
-
 
85
	6:string email,
-
 
86
	7:string dummy,
-
 
87
	8:set<Phone> phones,
-
 
88
	9:string userHandle,
-
 
89
	10:string password,
-
 
90
	11:SocialHandles socialHandles,
-
 
91
	12:i64 dateOfBirth,
-
 
92
	13:i64 anniversary,
-
 
93
	14:list<Address> addresses,
-
 
94
	16:i32 shipmentOption,
-
 
95
	17:string middleName,
-
 
96
	18:string occupation,
-
 
97
	19:string hintQuestion,
-
 
98
	20:string hintAnswer,
-
 
99
	21:i64 defaultAddressId,
-
 
100
	22:string communicationEmail
-
 
101
}
77
}
102
 
78
 
103
/**
79
/**
104
Internal information to be used by system. various variables which aid in serving the user are identified and put here
80
Internal information to be used by system. various variables which aid in serving the user are identified and put here
105
**/
81
**/
106
 
-
 
107
struct UserInternalInfo{
82
struct UserInternalInfo{
108
	1:i64 userId,
83
	1:i64 userId,
109
	2:i64 geoZone,
84
	2:i64 geoZone,
110
	3:i64 shipmentZone,
85
	3:i64 shipmentZone,
111
	4:i64 taxZone,
86
	4:i64 taxZone,
Line 123... Line 98...
123
/**
98
/**
124
dynamic user state 
99
dynamic user state 
125
**/
100
**/
126
struct UserState{
101
struct UserState{
127
	1:i64 userId,
102
	1:i64 userId,
128
	2:bool isEmailVerified,
-
 
129
	3:i64 lastLogin,
103
	2:i64 lastLogin,
130
	4:i64 lastLogout,
104
	3:i64 lastLogout,
131
	5:i64 emailVerificationSentOn,
105
	4:i64 emailVerificationSentOn,
132
	6:i64 smsVerificationSentOn,
106
	5:i64 smsVerificationSentOn,
-
 
107
	6:bool isEmailVerified,
133
	7:bool isSMSVerified,
108
	7:bool isSMSVerified,
134
	8:i64 activeSince,
109
	8:i64 activeSince,
135
	9:bool isLoggedIn,
-
 
136
	10:list<IPMap> ips,
110
	9:list<IPMap> ips,
137
	11:i64 shoppingCartHandle,
-
 
138
	12:AccountStatus status
111
	10:AccountStatus status
-
 
112
}
-
 
113
 
-
 
114
enum Sex{
-
 
115
	MALE,
-
 
116
	FEMALE,
-
 
117
	WONT_SAY
139
}
118
}
140
 
119
 
141
/**
120
/**
142
complete user structre
121
The user structure holding the basic information that identifies the user.
143
**/
122
**/
144
struct UserContext{
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,
145
	1:UserPrimaryInfo primaryInfo,
134
	11:string communicationEmail,
-
 
135
	12:i64 activeCartId,
-
 
136
	13:string jsessionId,
-
 
137
	14:bool isAnonymous
-
 
138
}
-
 
139
 
-
 
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,
146
	2:UserInternalInfo internalInfo,
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,
147
	3:UserState userState,
205
	3:string snippet,
-
 
206
	4:bool enabled,
-
 
207
	5:i64 timestamp
-
 
208
}
-
 
209
 
-
 
210
struct Widget{
148
	4:i64 id
211
	1:i64 id,
-
 
212
	2:WidgetType type,
149
	5:i64 sessionid //in case user is not logged in, the id would be -1 and session id would help to uniquely identify the user
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
150
}
223
}
151
 
224
 
152
/**
225
/**
153
service
226
service
154
*/
227
*/
155
 
-
 
156
service UserContextService{
228
service UserContextService{
157
	UserContext createContext(1: UserContext context, 2: bool updateExisting) throws (1:UserContextException cex),
229
	User createAnonymousUser(1:string jsessionId) throws (1:UserContextException ucex),
158
	UserContext getContextFromId(1:i64 userId, 2:bool isSessionId) throws (1:UserContextException ucx),
230
	User getUserById(1:i64 userId) throws (1:UserContextException ucex),
159
	UserContext getContextFromEmailOrHandle(1:string emailorhandle, 2:bool isEmail) throws (1:UserContextException ucx),
231
	User createUser(1:User user) throws (1:UserContextException ucex),
160
	UserState getState(1:i64 userId, 2:bool isSessionId) throws (1:UserContextException ucx),
232
	User updateUser(1:User user) throws (1:UserContextException ucex),
161
	UserPrimaryInfo getPrimaryInfo(1:i64 userId, 2:bool isSessionId) throws (1:UserContextException ucx),
233
	bool deleteUser(1:i64 userId) throws (1:UserContextException ucex),
162
	UserInternalInfo getInternalInfo(1:i64 userId, 2:bool isSessionId) throws (1:UserContextException ucx),
234
	UserState getUserState(1:i64 userId) throws (1:UserContextException ucex),
163
	UserContext getContext(1:string email, 2:string password) throws (1:AuthenticationException ax),
235
	User authenticateUser(1:string email, 2:string password) throws (1:AuthenticationException auex),
164
	bool authenticateUser(1:string handle, 2:string password, 3:bool isEmail) throws (1:AuthenticationException ax),
-
 
165
	bool userExists(1:string email)throws (1:UserContextException ucx),
236
	bool userExists(1:string email) throws (1:UserContextException ucx),
166
	bool addIpAdressForUser(1:string ip, 2:i64 timestamp, 3:i64 userId)throws (1:UserContextException ucx),
-
 
167
	bool addAddressForUser(1:Address address, 2:i64 userid, 3:i64 timestamp, 4:bool setDefault)throws (1:UserContextException ucx),
237
	bool addAddressForUser(1:i64 userId, 2:Address address, 3:i64 timestamp, 4:bool setDefault)throws (1:UserContextException ucx),
168
	bool removeAddressForUser(1:i64 userid, 2:i64 addressId)throws (1:UserContextException ucx),
238
	bool removeAddressForUser(1:i64 userid, 2:i64 addressId)throws (1:UserContextException ucx),
169
	bool setUserAsLoggedIn(1:i64 userId, 2:i64 timestamp)throws (1:UserContextException ucx),
239
	bool setUserAsLoggedIn(1:i64 userId, 2:i64 timestamp)throws (1:UserContextException ucx),
170
	bool setUserAsLoggedOut(1:i64 userid, 2:i64 timestamp)throws (1:UserContextException ucx),
240
	bool setUserAsLoggedOut(1:i64 userid, 2:i64 timestamp)throws (1:UserContextException ucx),
171
	bool setDefaultAddress(1:i64 userid, 2:i64 addressId)throws (1:UserContextException ucx),
241
	bool setDefaultAddress(1:i64 userid, 2:i64 addressId)throws (1:UserContextException ucx),
172
	bool updatePassword(1:i64 userid, 2:string password)throws (1:UserContextException ucx),
242
	bool updatePassword(1:i64 userid, 2:string password)throws (1:UserContextException ucx),
-
 
243
	
173
	bool deleteUser(1:i64 userid, 2:bool isSessionId)throws (1:UserContextException ucx),
244
	i64 createCart(1:i64 userId) throws (1:ShoppingCartException scx),
174
	bool sendEmailVerification(1:i64 userid)throws (1:UserContextException ucx),
245
	Cart getCurrentCart(1:i64 userId) throws (1:ShoppingCartException scx),	
175
	bool sendSMSVerification(1:i64 userid)throws (1:UserContextException ucx),
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),
176
	bool confirmEmailVerification(1:i64 userid)throws (1:UserContextException ucx),
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),
177
	bool confirmSMSVerification(1:i64 userid)throws (1:UserContextException ucx),
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),
178
	bool addSocialhandle(1:i64 userid, 2:string socialService, 3:string handle)throws (1:UserContextException ucx),
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
	
179
	bool sendNewPasswordById(1:i64 userid) throws (1:UserContextException ucx),
267
	Widget getMyResearch(1:i64 user_id) throws (1:WidgetException scx),
180
	bool sendNewPasswordByHandle(1:string emailOrHandle, 2:bool isEmail)throws (1:UserContextException ucx)
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)
181
}
276
}
182
 
277