Subversion Repositories SmartDukaan

Rev

Rev 592 | Rev 646 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

namespace java in.shop2020.model.v1.user
namespace py shop2020.thriftpy.model.v1.user

/**
Exceptions
*/
exception AuthenticationException{
        1:string message,
        2:i32 errorCode
}

exception UserContextException{
        1:i32 errorCode,
        2:string message
}

exception ShoppingCartException{
        1:i64 id,
        2:string message
}

enum AddressType{
        WORK = 0,
        HOME = 1
}

enum PhoneType{
        WORK = 0,
        HOME = 1,
        MOBILE = 2
}

enum AccountStatus{
        ACTIVE = 0,
        DELETED = 1,
        INACTIVE = 2,
        INCOMPLETE = 3
}

/**
All the social handles
*/
struct SocialHandles{
        1:string facebook,
        2:string opensocial,
        3:string twitter
}

/**
Address
*/
struct Address{
        1:i64 id,
        2:string line1,
        3:string line2,
        4:string landmark,
        5:string city,
        6:string state,
        7:string pin,
        8:string country,
        9:bool enabled,
        10:AddressType type,
        11:i64 addedOn,
        12:string name,
        13:string phone
}

/**Phone
**/
struct Phone{
        1:i64 id,
        2:string countryCode,
        3:string areaCode,
        4:string number,
        5:string extension,
        6:PhoneType type
}

/**
Internal information to be used by system. various variables which aid in serving the user are identified and put here
**/
struct UserInternalInfo{
        1:i64 userId,
        2:i64 geoZone,
        3:i64 shipmentZone,
        4:i64 taxZone,
        5:double userRankScore
}

/**
structure representing timestamp and ip at which user logged into the system
**/
struct IPMap{
        1:i64 timestamp
        2:string ip
}

/**
dynamic user state 
**/
struct UserState{
        1:i64 userId,
        2:i64 lastLogin,
        3:i64 lastLogout,
        4:i64 emailVerificationSentOn,
        5:i64 smsVerificationSentOn,
        6:bool isEmailVerified,
        7:bool isSMSVerified,
        8:i64 activeSince,
        9:list<IPMap> ips,
        10:AccountStatus status
}

enum Sex{
        MALE,
        FEMALE,
        WONT_SAY
}

/**
The user structure holding the basic information that identifies the user.
**/
struct User{
        1:i64 userId,
        2:string email,
        3:string password,
        4:string name,
        5:string dateOfBirth,
        6:Sex sex
        7:string mobileNumber
        8:SocialHandles socialHandles,
        9:list<Address> addresses,
        10:i64 defaultAddressId,
        11:string communicationEmail,
        12:i64 activeCartId,
        13:string jsessionId,
        14:bool isAnonymous
}

//Various statuses for line items
enum LineStatus{
        LINE_ACTIVE,                    //line is active
        LINE_DELETED,                   //line is deleted
        LINE_EXPIRED,                   //line is expired, on laspse of fixed amount of time
        LINE_COMMITED,                  //line is committed, sent for processing.
        LINE_COMMIT_FAILED,             //line was committed, but commit failed due to some reason, possibly during cart validation.
        LINE_AUTO_DELETED,              //line was auto deleted internally due to some reason(item delisted, price changed etc).
}

//Various statuses for Cart
enum CartStatus{
        ACTIVE,                                 
        INACTIVE,
        EXPIRED,
        COMMITTED,
        COMMIT_FAILED
}

struct Line{
        1:i64 id,                               //identifier
        2:i64 itemId,                   //item id added
        3:double quantity,              //quantity added 
        4:i64 createdOn,                //addition timestamp
        5:i64 updatedOn,                //any updation in quantity or status
        6:LineStatus lineStatus,        //current status
        7:i32 estimate                  //delivery estimate in hours
}

struct Cart{
        1:i64 id,                               //identifier
        2:list<Line> lines,             //list of lines
        3:CartStatus status,    //current status
        4:i64 createdOn,                //creation timestamp
        5:i64 updatedOn,                //time of last update in cart (like addition/deletion/updation of cart items )
        6:i64 committedOn,              //commited timestamp
        7:i64 userId,                   //user id to which it belongs
        8:i64 addressId,            //address on which this will be shipped                     
}

enum WidgetType{
        SIMILAR_ITEMS,
        RECOMMENDED_ITEMS,
        MY_RESEARCH,
        ACCESSORIES,
        RATINGS,
        BROWSE_HISTORY,
        DEAL_PROMOTIONS
}

enum RatingType{
        SHOP2020,
        AMAZON,
        USER_ALL,
        USER_CURRENT
}

struct RatingsWidget{
        1:i64 catalog_item_id,
        2:map<RatingType,double> ratings,
        3:i64 user_id
}

struct WidgetItem{
        1:i64 id,
        2:i64 item_id,
        3:string snippet,
        4:bool enabled,
        5:i64 timestamp
}

struct Widget{
        1:i64 id,
        2:WidgetType type,
        3:i64 customer_id, //will be valid for MY_RESEARCH
        4:list<WidgetItem> items,
        5:bool enabled,
        6:string name,  
        7:bool session_id  //will be valid for BROWSE_HISTORY
}

exception WidgetException{
        1:i64 id,
        2:string message
}

/**
service
*/
service UserContextService{
        User createAnonymousUser(1:string jsessionId) throws (1:UserContextException ucex),
        User getUserById(1:i64 userId) throws (1:UserContextException ucex),
        User createUser(1:User user) throws (1:UserContextException ucex),
        User updateUser(1:User user) throws (1:UserContextException ucex),
        bool deleteUser(1:i64 userId) throws (1:UserContextException ucex),
        UserState getUserState(1:i64 userId) throws (1:UserContextException ucex),
        User authenticateUser(1:string email, 2:string password) throws (1:AuthenticationException auex),
        bool userExists(1:string email) throws (1:UserContextException ucx),
        i64 addAddressForUser(1:i64 userId, 2:Address address, 3:bool setDefault)throws (1:UserContextException ucx),
        bool removeAddressForUser(1:i64 userid, 2:i64 addressId)throws (1:UserContextException ucx),
        bool setUserAsLoggedIn(1:i64 userId, 2:i64 timestamp)throws (1:UserContextException ucx),
        bool setUserAsLoggedOut(1:i64 userid, 2:i64 timestamp)throws (1:UserContextException ucx),
        bool setDefaultAddress(1:i64 userid, 2:i64 addressId)throws (1:UserContextException ucx),
        bool updatePassword(1:i64 userid, 2:string oldPassword, 3:string newPassword)throws (1:UserContextException ucx),
        bool forgotPassword(1:string email)throws (1:UserContextException ucx),
        list<Address> getAllAddressesForUser(1:i64 userId)throws (1:UserContextException ucx),
        i64 getDefaultAddressId(1:i64 userId)throws (1:UserContextException ucx),
        
        i64 createCart(1:i64 userId) throws (1:ShoppingCartException scx),
        Cart getCurrentCart(1:i64 userId) throws (1:ShoppingCartException scx), 
        Cart getCart(1:i64 cartId) throws (1:ShoppingCartException scx),
        list<Cart> getCartsForUser(1:i64 userId, 2:CartStatus status) throws (1:ShoppingCartException scx),
        list<Cart> getCartsByStatus(1:CartStatus status) throws (1:ShoppingCartException scx),
        list<Cart> getCartsByTime(1:i64 from_time, 2:i64 to_time, 3:CartStatus status) throws (1:ShoppingCartException scx),
        void changeCartStatus(1:i64 cartId, 2:CartStatus status) throws (1:ShoppingCartException scx),
        void addItemToCart(1:i64 cartId, 2:i64 itemId, 3:i64 quantity) throws (1:ShoppingCartException scx),
        void deleteItemFromCart(1:i64 cartId, 2:i64 itemId) throws (1:ShoppingCartException scx),
        void changeQuantity(1:i64 cartId, 2:i64 itemId, 3:i64 quantity) throws (1:ShoppingCartException scx),
        void changeItemStatus(1:i64 cartId, 2:i64 itemId, 3:LineStatus status) throws (1:ShoppingCartException scx),
        void addAddressToCart(1:i64 cartId, 2:i64 addressId) throws (1:ShoppingCartException scx),
        i64 commitCart(1:i64 cartId) throws (1:ShoppingCartException scx),
        bool validateCart(1:i64 cartId) throws (1:ShoppingCartException scex),
        bool refreshCart(1:i64 cartId) throws (1:ShoppingCartException scex),
        void mergeCart(1:i64 fromCartId, 2:i64 toCartId)
        
        void addWidget(1:Widget widget) throws (1:WidgetException scx),
        void addItemToWidget(1:i64 widget_id, 2:list<i64> items) throws (1:WidgetException scx),
        void deleteItemFromWidget(1:i64 widget_id, 2:i64 item_id) throws (1:WidgetException scx),
        void updateWidget(1:i64 widgetId, 2:bool enable) throws (1:WidgetException scx),
        void updateWidgetItem(1:i64 widgetId, 2:bool enable) throws (1:WidgetException scx),
        Widget getWidget(1:WidgetType type, 2:i64 userId, 3:bool onlyEnabled) throws (1:WidgetException scx),
        
        Widget getMyResearch(1:i64 user_id) throws (1:WidgetException scx),
        bool updateMyResearch(1:i64 user_id, 2:i64 item_id) throws (1:WidgetException scx),
        void deleteItemFromMyResearch(1:i64 user_id, 2:i64 item_id) throws (1:WidgetException scx),
                
        void updateRatings(1:i64 item_id, 2:RatingType type, 3:double rating, 4:i64 user_id),
        RatingsWidget getRatings(1:i64 item_id, 2:i64 user_id)  throws (1:WidgetException scx),
        
        void updateBrowseHistory(1:i64 user_id, 2:i64 item_id, 3:bool isSessionId),
        Widget getBrowseHistory(1:i64 userId, 2:bool isSessionId) throws (1:WidgetException scx)
}