Subversion Repositories SmartDukaan

Rev

Rev 130 | Rev 506 | 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
}

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:string line1,
        2:string line2,
        3:string landmark,
        4:string city,
        5:string state,
        6:string pin,
        7:string country,
        8:i64 id,
        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,
}

/**
Primary information of the user
**/
struct UserPrimaryInfo{
        1:i64 userId,
        2:string title,
        3:string firstName,
        4:string lastName,
        5:string pictureUrl,
        6:string email,
        7:string dummy,
        8:set<Phone> phones,
        9:string userHandle,
        10:string password,
        11:SocialHandles socialHandles,
        12:i64 dateOfBirth,
        13:i64 anniversary,
        14:set<Address> addresses,
        16:i32 shipmentOption,
        17:string middleName,
        18:string occupation,
        19:string hintQuestion,
        20:string hintAnswer
}

/**
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:bool isEmailVerified,
        3:i64 lastLogin,
        4:i64 lastLogout,
        5:i64 emailVerificationSentOn,
        6:i64 smsVerificationSentOn,
        7:bool isSMSVerified,
        8:i64 activeSince,
        9:bool isLoggedIn,
        10:list<IPMap> ips,
        11:i64 shoppingCartHandle,
        12:AccountStatus status
}

/**
complete user structre
**/
struct UserContext{
        1:UserPrimaryInfo primaryInfo,
        2:UserInternalInfo internalInfo,
        3:UserState userState,
        4:i64 id
        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
}

/**
service
*/

service UserContextService{
        UserContext createContext(1: UserContext context, 2: bool updateExisting) throws (1:UserContextException cex),
        UserContext getContextFromId(1:i64 userId, 2:bool isSessionId) throws (1:UserContextException ucx),
        UserContext getContextFromEmailOrHandle(1:string emailorhandle, 2:bool isEmail) throws (1:UserContextException ucx),
        UserState getState(1:i64 userId, 2:bool isSessionId) throws (1:UserContextException ucx),
        UserPrimaryInfo getPrimaryInfo(1:i64 userId, 2:bool isSessionId) throws (1:UserContextException ucx),
        UserInternalInfo getInternalInfo(1:i64 userId, 2:bool isSessionId) throws (1:UserContextException ucx),
        UserContext getContext(1:string email, 2:string password) throws (1:AuthenticationException ax),
        bool authenticateUser(1:string handle, 2:string password, 3:bool isEmail) throws (1:AuthenticationException ax),
        bool userExists(1:string email)throws (1:UserContextException ucx),
        bool addIpAdressForUser(1:string ip, 2:i64 timestamp, 3:i64 userId)throws (1:UserContextException ucx),
        bool addAddressForUser(1:Address address, 2:i64 userid, 3:i64 timestamp)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 updatePassword(1:i64 userid, 2:string password)throws (1:UserContextException ucx),
        bool deleteUser(1:i64 userid, 2:bool isSessionId)throws (1:UserContextException ucx),
        bool sendEmailVerification(1:i64 userid)throws (1:UserContextException ucx),
        bool sendSMSVerification(1:i64 userid)throws (1:UserContextException ucx),
        bool confirmEmailVerification(1:i64 userid)throws (1:UserContextException ucx),
        bool confirmSMSVerification(1:i64 userid)throws (1:UserContextException ucx),
        bool addSocialhandle(1:i64 userid, 2:string socialService, 3:string handle)throws (1:UserContextException ucx),
        bool sendNewPasswordById(1:i64 userid) throws (1:UserContextException ucx),
        bool sendNewPasswordByHandle(1:string emailOrHandle, 2:bool isEmail)throws (1:UserContextException ucx)
}