Subversion Repositories SmartDukaan

Rev

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

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

include "GenericService.thrift"

/**
        Objects
*/

/**
Caution :- Never ever change the numbers in it. Please confirm from @Chandranshu or @Rajveer before any changes in enum and other entries in file.
**/
enum status {
        PHASED_OUT = 0,         //Item is no longer selling
        DELETED = 1,            //Item has been deliberately deleted 
        PAUSED = 2,                     //Item's sale has been paused manually.
        ACTIVE = 3,                     //Item is available for sale as of now
        IN_PROCESS = 4,         //Item has been added, but content is not available for the same
        CONTENT_COMPLETE = 5,  //The content for this item has been completed. We can start selling the item now.
        PAUSED_BY_RISK = 6,    //Item's sale has been automatically paused since it was marked as risky
        COMING_SOON= 7          //Item is now in Coming Soon Page and will move to ACTIVE gradually as it achieves the Start date.
}

enum WarehouseLocation {
        Mumbai = 0,
        Delhi = 1,
        Bangalore = 2,
        Kolkata = 3
}

struct Vendor {
        1:i64 id,
        2:string name
}

enum BillingType {
        OURS = 0,
        EXTERNAL = 1
}

enum WarehouseType {
    OURS = 0,
    THIRD_PARTY = 1
}

enum InventoryType {
    GOOD = 0,
    BAD = 1,
    VIRTUAL = 2
}

enum HolidayType {
        WEEKLY = 0,
        MONTHLY = 1,
        SPECIFIC = 2
}

/* 
Warehouse fields details
location: it is full address
vendorString: some key for the warehouse
*/
struct Warehouse {
        1:i64 id,
        2:string displayName,
        3:string location,
        5:i64 addedOn,
        6:i64 lastCheckedOn,
        7:string tinNumber,
        8:string pincode,
        9:string vendorString,
        10:WarehouseLocation logisticsLocation,
        12:BillingType billingType,
        13:WarehouseType warehouseType,
        14:InventoryType inventoryType,
        15:Vendor vendor,
        16:i64 shippingWarehouseId,
        17:i64 billingWarehouseId,
        18:bool isAvailabilityMonitored,
        19:i64 transferDelayInHours
}

/* */
struct ItemInventory{
        1:i64 id,
        2:map<i64,i64> availability,
        3:map<i64,i64> reserved
}


struct ItemInventoryHistory{
        1:i64 item_id,
        2:i64 warehouse_id,
        3:i64 timestamp,
        4:i64 availability
}

enum ItemType {
    SERIALIZED = 1,
    NON_SERIALIZED = 2
}

struct Item{
        1:i64 id,
        2:string productGroup
        3:string brand,
        4:string modelNumber,
        5:string modelName,
        6:string color,
        7:i64 category,
        8:string comments,
        9:i64 catalogItemId,
        10:i64 featureId,
        11:string featureDescription,
        12:ItemInventory itemInventory,
        13:optional double mrp, //maxmimum retail price
        14:optional double sellingPrice, //Selling price
        15:optional double weight,
        16:i64 addedOn,
        17:optional i64 startDate,
        18:optional i64 retireDate,
        19:status itemStatus,
        20:string status_description,
        21:map<string,string> otherInfo,
        22:string bestDealText,
        23:optional double bestDealValue,
        24:bool defaultForEntity,
        25:i64 updatedOn,
        26:optional i64 bestSellingRank,
        27:bool risky,
        28:optional i32 expectedDelay,
        29:optional bool isWarehousePreferenceSticky,
        30:i32 warrantyPeriod,
        31:optional i64 preferredVendor,
        32:ItemType type,
        33:optional i64 comingSoonStartDate,
        34:optional i64 expectedArrivalDate,
        35:bool hasItemNo,
        36:bool clearance
}

struct VendorItemPricing{
        1:i64 vendorId,
        2:i64 itemId,
        3:double transferPrice,
        4:double mop,
        5:double dealerPrice
}

struct Category{
        1:i64 id,
        2:string label,
        3:string description,
        4:i64 parent_category_id,
        /**
        * This field should not be used.
        */
        5:list<i64> children_category_ids
        6:string display_name
}

struct VendorItemMapping{
        1:i64 vendorId,
        2:string itemKey,
        3:i64 itemId
}

struct ItemShippingInfo{
        1:bool isActive,
        2:optional bool isRisky,
        3:optional i64 quantity
}

struct Source{
        1:i64 id,
        2:string name,
        3:string identifier
}

struct SourceItemPricing{
        1:i64 sourceId,
        2:i64 itemId,
        3:double mrp,
        4:double sellingPrice
}

struct AvailableAndReservedStock {
        1:i64 itemId,
        2:i64 available,
        3:i64 reserved,
        4:i64 minimumStock
}

struct ProductNotificationRequest       {
        1:Item item,
        2:string email,
        3:i64 addedOn
}

struct ProductNotificationRequestCount  {
        1:Item item,
        2:i64 count
}

struct VoucherItemMapping{
        1:i64 voucherType,
        2:i64 itemId,
        3:i64 amount
}

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

service InventoryService extends GenericService.GenericService{

/**
        Availability and inventory attributes   
*/
        //all add and update methods - added by Ashish
        i64 addItem(1:Item item) throws (1:InventoryServiceException cex),
        i64 updateItem(1:Item item) throws (1:InventoryServiceException cex),
        i64 addWarehouse(1:Warehouse warehouse) throws (1:InventoryServiceException cex),
        
        /**
        add a new vendor
        */
        i64 addVendor(1:Vendor vendor) throws (1:InventoryServiceException cex),
        
        /**
        Checks if the item given to the corresponding itemId is active. If it's active,
        whether it's risky and if it's risky, its inventory position.
        */
        ItemShippingInfo isActive(1:i64 itemId) throws (1:InventoryServiceException isex),
        
        string getItemStatusDescription(1:i64 itemId) throws (1:InventoryServiceException isex),
        
        /**
        Stores the incremental warehouse updates of items.
        */
        void updateInventoryHistory(1:i64 warehouse_id, 2:string timestamp, 3:map<string, i64> availability) throws (1:InventoryServiceException cex),
        
        /**
        Stores the final inventory stocks of items.
        */
        void updateInventory(1:i64 warehouse_id, 2:string timestamp, 3:map<string, i64> availability) throws (1:InventoryServiceException cex),

        /**
        Add the inventory to existing stock.
        */
        void addInventory(1:i64 itemId, 2:i64 warehouseId, 3:i64 quantity) throws (1:InventoryServiceException cex),

        //all delete methods
        void retireWarehouse(1:i64 warehouse_id) throws (1:InventoryServiceException cex),
        
        //Item management apis
        void startItemOn(1:i64 item_id, 2:i64 timestamp) throws (1:InventoryServiceException cex),
        void retireItemOn(1:i64 item_id, 2:i64 timestamp) throws (1:InventoryServiceException cex),
        void changeItemStatus(1:i64 item_id, 2:i64 timestamp, 3:status newstatus) throws (1:InventoryServiceException cex),
        //Other accessor methods - added by Ashish
        Item getItem(1:i64 item_id) throws (1:InventoryServiceException cex),
        list<Item> getItemsByCatalogId(1:i64 catalog_item_id) throws  (1:InventoryServiceException cex),
        list<Item> getValidItemsByCatalogId(1:i64 catalog_item_id) throws  (1:InventoryServiceException cex),
        list<Item> getAllItems(1:bool isActive) throws (1:InventoryServiceException cex),
        list<Item> getAllItemsByStatus(1:status itemStatus) throws (1:InventoryServiceException cex),
        //ItemInventory getItemInventory(1:i64 item_id) throws (1:InventoryServiceException cex),
        ItemInventory getItemInventoryByItemId(1:i64 item_id) throws (1:InventoryServiceException cex),
        //ItemInventory getItemInventoryByCatalogId(1:i64 item_id) throws (1:InventoryServiceException cex),
        i64 getItemAvailibilityAtWarehouse(1:i64 warehouse_id, 2:i64 item_id) throws (1:InventoryServiceException cex),
        bool markItemAsContentComplete(1:i64 entityId, 2:i64 category, 3:string brand, 4:string modelName, 5:string modelNumber) throws (1:InventoryServiceException cex),
        
        /**
        Gets at most 'limit' items starting at the given offset. Returns an empty list if there are no more items at the given offset.
        */
        list<Item> getAllItemsInRange(1:i64 offset, 2:i64 limit) throws (1:InventoryServiceException cex),
        
        /**
        Gets at most 'limit' items starting at the given offset in the given status. Returns an empty list if there are no more items at the given offset.
        */
        list<Item> getAllItemsByStatusInRange(1:status itemStatus, 2:i64 offset, 3:i64 limit) throws (1:InventoryServiceException cex),
        
        /**
        Gets a count of all items by status
        */
        i32 getItemCountByStatus(1:bool useStatus, 2:status itemStatus),
        /**
        Determines the warehouse that should be used to fulfil an order for the given item.
        It first checks all the warehouses which are in the logistics location given by the
        warehouse_loc parameter. If none of the warehouses there have any inventory, then the
        preferred warehouse for the item is used. 
        
        Returns an ordered list of size 4 with following elements in the given order:
        1. Id of the fulfillment warehouse which was finally picked up.
        2. Expected delay added by the category manager.
        3. Id of the billing warehouse which was finally picked up.
         */
        list<i64> getItemAvailabilityAtLocation(1:i64 itemId) throws (1:InventoryServiceException isex),
        
        list<Warehouse> getAllWarehouses(1:bool isActive) throws (1:InventoryServiceException cex),
        
        /**
         Returns the warehouse with the given id.
        */
        Warehouse getWarehouse(1:i64 warehouse_id) throws (1:InventoryServiceException cex),
        list<Warehouse> getAllWarehousesForItem(1:i64 item_id) throws (1:InventoryServiceException cex),
        list<Item> getAllItemsForWarehouse(1:i64 warehouse_id) throws (1:InventoryServiceException cex),
        
        /**
         Increases the reservation count for an item in a warehouse. Should always succeed normally.
        */
        bool reserveItemInWarehouse(1:i64 itemId, 2:i64 warehouseId, 3:double quantity) throws (1:InventoryServiceException cex),
        
        /**
         Decreases the reservation count for an item in a warehouse. Should always succeed normally.
        */
        bool reduceReservationCount(1:i64 itemId, 2:i64 warehouseId, 3:double quantity) throws (1:InventoryServiceException cex),
        
        // for home page .... best deals, best sellers and latest arrivals
        list<Item> getBestSellers() throws (1:InventoryServiceException isex),
        list<i64> getBestSellersCatalogIds(1:i64 beginIndex, 2:i64 totalItems, 3:string brand, 4:i64 category) throws (1:InventoryServiceException cex),
        i64 getBestSellersCount() throws (1:InventoryServiceException cex),
        
        list<Item> getBestDeals() throws (1:InventoryServiceException isex),
        list<i64> getBestDealsCatalogIds(1:i64 beginIndex, 2:i64 totalItems, 3:string brand, 4:i64 category) throws (1:InventoryServiceException cex),
        i64 getBestDealsCount() throws (1:InventoryServiceException cex),

        list<Item> getComingSoon() throws (1:InventoryServiceException isex),
        list<i64> getComingSoonCatalogIds(1:i64 beginIndex, 2:i64 totalItems, 3:string brand, 4:i64 category) throws (1:InventoryServiceException cex),
        i64 getComingSoonCount() throws (1:InventoryServiceException cex),
        
        /**
        Returns a list of items sorted in the descending order by start date.
        The list is limited to the 'latest_arrivals_count' configuraiton parameter.
        */
        list<Item> getLatestArrivals() throws (1:InventoryServiceException isex),

        /**
        Returns the list of catalog ids of latest arrivals in the given categories of the given brand.
        To ignore the categories, pass the list as empty. To ignore brand, pass it as null.   
        */
        list<i64> getLatestArrivalsCatalogIds(1:i64 beginIndex, 2:i64 totalItems, 3:string brand, 4:list<i64> categories) throws (1:InventoryServiceException cex),
        
        /**
        Get the total number of latest arrivals we are willing to show.
        The count's upper bound is the 'latest_arrivals_count' configuraiton parameter.
        */
        i64 getLatestArrivalsCount() throws (1:InventoryServiceException cex),
        
        
        i64 generateNewEntityID(),
        
        /**
        Returns the pricing information of an item associated with the vendor of the given warehouse.
        Raises an exception if either the item, vendor or the associated pricing information can't be found.
        */
        VendorItemPricing getItemPricing(1:i64 itemId, 2:i64 vendorId) throws (1:InventoryServiceException cex),
        
        /**
        * Store category object and retrieve it
        */
        /**
        bool putCategoryObject(1:binary object),
        binary getCategoryObject()
        */
        
        /**
        * All category related functions
        */
        bool addCategory(1:Category category),
        Category getCategory(1:i64 id),
        list<Category> getAllCategories(),
        
        /**
        Returns the list of vendor pricing information of an item.
        Raises an exception if item not found corresponding to itemId
        */
        list<VendorItemPricing> getAllItemPricing(1:i64 itemId) throws (1:InventoryServiceException cex),
        
        
        /**
        Adds vendor prices corresponding to the item. If pricing already exists then updates the prices. 
        Raises an exception if either the item or vendor can't be found corresponding to their ids.
        */
        void addVendorItemPricing(1:VendorItemPricing vendorItemPricing) throws (1:InventoryServiceException cex),
        
        /**
        Return list of all vendors
        */
        list<Vendor> getAllVendors(), 
        
        /**
        Returns the list of similar items.
        */
        list<Item> getAllSimilarItems(1:i64 itemId),
        
        /**
        Adds similar item.
        */
        Item addSimilarItem(1:i64 itemId, 2:i64 catalogItemId) throws (1:InventoryServiceException cex),
        
        /**
        Delete similar item.
        */
        bool deleteSimilarItem(1:i64 itemId, 2:i64 catalogItemId) throws (1:InventoryServiceException cex),
        
        /**
        Adds VendorItemMapping. Updates VendorItemMapping if exists corresponding to the item key.  
        */
        void addVendorItemMapping(1:string key, 2:VendorItemMapping vendorItemMapping) throws (1:InventoryServiceException cex),
        
        /**
        Returns the list of vendor item mapping corresponding to itemId passed as parameter.
        Raises an exception if item not found corresponding to itemId
        */
        list<VendorItemMapping> getVendorItemMappings(1:i64 itemId) throws (1:InventoryServiceException cex),
        
        /**
        Checks if similar item exists (with same Brand, ModelNumber, ModelName, Color)
        If yes, returns the itemId else returns 0
        */
        i64 checkSimilarItem(1:string brand, 2:string modelNumber, 3:string modelName, 4:string color),
        
        /**
        Marks/Unmarks an item as risky. This flag is used for automatic marking of an item as INACTIVE in case of zero inventory.
        */
        void changeItemRiskyFlag(1:i64 itemId, 2:bool risky),
        
        /**
        Returns list of items marked as risky.
        */
        list<Item> getItemsByRiskyFlag(),
        
        /**
        Returns list of items with any status except PHASED_OUT and filtered by category, brand.
        */
        list<Item> getItemsForMasterSheet(1:string category, 2:string brand),
        
        /**
        Returns list of catalog ids of items with same similarity index as of the given itemId 
        */
        list<i64> getSimilarItemsCatalogIds(1:i64 beginIndex, 2:i64 totalItems, 3:i64 itemId),

        /**
        Add user requests for out of stock items. Once user will ask for notify me an entry will 
        */
        bool addProductNotification(i64 itemId, string email),
        
        /**
                Send the product notifications to the users for items which has stock.
        */
        bool sendProductNotifications(),
        
        /**
                Returns list of brand names for a given category Id
        */
        list<string> getAllBrandsByCategory(1:i64 categoryId),
    
    /**
                Returns list of brand names
        */
        list<string> getAllBrands(),
    
        /**
        Return list of all sources
        */
        list<Source> getAllSources(), 
                
        /**
        Returns the pricing information of an item. If no information is found, exception will be thrown.
        */
        SourceItemPricing getItemPricingBySource(1:i64 itemId, 2:i64 sourceId) throws (1:InventoryServiceException cex),
        
        /**
        Adds prices to be displayed corresponding to the item if user comes from a source.
        If item is not found or source is not found, it will throw exception.
        */
        void addSourceItemPricing(1:SourceItemPricing sourceItemPricing) throws (1:InventoryServiceException cex),
        
        /**
        Returns the list of source pricing information of an item.
        Raises an exception if item not found corresponding to itemId
        */
        list<SourceItemPricing> getAllSourcePricing(1:i64 itemId) throws (1:InventoryServiceException cex),
        
        /**
        Get the item for a given itemId and sourceId. MRP and sellingPrice will be updated for source if we have different prices for source.
        */
        Item getItemForSource(1:i64 item_id, 2:optional i64  sourceId) throws (1:InventoryServiceException cex),
        
        /**
        Searches items matching the the given terms in the catalog and returns results within the specified range.
        */
        list<Item> searchItemsInRange(1:list<string> searchTerms, 2:i64 offset, 3:i64 limit),
        
        /**
        Gets the count of search results for the given search terms so that the user can go through all the pages.
        */
        i32 getSearchResultCount(1:list<string> searchTerms),
        
        /**
        Returns a list of inventory stock for items for which there are pending orders for the given vendor.
        */
        list<AvailableAndReservedStock> getPendingOrdersInventory(1:i64 vendorid),
        
        /**
        Returns a list of product notifications added after a supplied datetime
        */
        list<ProductNotificationRequest> getProductNotifications(1:i64 startDateTime),
        
        /**
        Returns a list of count of requests for product notification against each item
        */
        list<ProductNotificationRequestCount> getProductNotificationRequestCount(1:i64 startDateTime)
        
        /**
        This method adds a log to authorize table with Item Id, username who authorized the change, reason.
        */
        bool addAuthorizationLog(1:i64 itemId, 2:string username, 3:string reason) throws (1:InventoryServiceException cex),

        /**
         This method returns all warehouses for a given warehosueType, inventoryType, vendor, billingWarehouse and shippingWarehouse.
         getWarehouses(WarehouseType.OURS, InventoryType.GOOD, 3, 7, 7) would return ours warehouse with GOOD type inventory for vendor 1 for billing warehouse 7 and shipping warehouse 7
         getWarehouses(WarehouseType.OURS, InventoryType.GOOD, 3, 7, 7) would return ours warehouse with GOOD type inventory for vendor 3 for billing warehouse 7 and shipping warehouse 7
     getWarehouses(null, null, 3, 7, 7) would return all type warehouses with all type inventory for vendor 3 for billing warehouse 7 and shipping warehouse 7
     getWarehouses(null, null, 0, 0, 7) would return all type warehouses with all type inventory for all vendors for all billing warehouses at shipping warehouse 7
         */
        list<Warehouse> getWarehouses(1:WarehouseType warehouseType, 2:InventoryType inventoryType, 3:i64 vendorId, 4:i64 billingWarehouseId, 5:i64 shippingWarehouseId);

    /**
     * Resets availability of an item to the quantity mentioned in a warehouse.
     */
    void resetAvailability(1:string itemKey, 2:i64 vendorId, 3:i64 quantity, 4:i64 warehouseId) throws (1:InventoryServiceException cex);

    /**
     * Resets availability of a warehouse to zero.
     */
    void resetAvailabilityForWarehouse(1:i64 warehouseId) throws (1:InventoryServiceException cex);

    /**
     * Returns the list of item keys which need to be processed for a given warehouse.
     * This is currently used by Support application to send item keys whose inventory needs 
     * to be updated from PLB
     */
    list<string> getItemKeysToBeProcessed(1:i64 warehouseId);

    /**
     * Marks/Deletes missed inventory updates for a given key and warehouse.
     * This generally happens when updates from PLB are applied on the currentinventorysnapshot for an item
     */
    void markMissedInventoryUpdatesAsProcessed(1:string itemKey, 2:i64 warehouseId);

    /**
     * Returns all the item key mappings that have been ignored until date. Value of map has the warehouse id
     * and the timestamp from where alert was raised.
     */
    map<string, map<i64, i64>> getIgnoredItemKeys();

    /**
    Add the BAD type inventory to existing stock.
    */
    void addBadInventory(1:i64 itemId, 2:i64 warehouseId, 3:i64 quantity) throws (1:InventoryServiceException cex);

    /**
    Returns all shipping locations
    */    
    list<Warehouse> getShippingLocations();

    /**
     * Fetches all the vendor item mappings present.
     */    
    list<VendorItemMapping> getAllVendorItemMappings();

    /**
     * Gets items' inventory for a warehouse
     * If warehouse is passed as zero, items' inventory across all warehouses is sent
     */
    map<i64, ItemInventory> getInventorySnapshot(1:i64 warehouseId);
    
    /**
    * Clear item availability cache.
    */
    void clearItemAvailabilityCache();
    
    list<i64> getClearanceSaleCatalogIds() throws (1:InventoryServiceException cex),
        
        bool addupdateVoucherForItem(1:i64 catalog_item_id, 2:i64 voucherType, 3:i64 voucherAmount) throws (1:InventoryServiceException cex),
        
        bool deleteVoucherForItem(1:i64 catalog_item_id, 2:i64 voucherType) throws (1:InventoryServiceException cex),
        
        i64 getVoucherAmount(1:i64 itemId, 2:i64 voucherType),
        
        list<VoucherItemMapping> getAllItemVouchers(1:i64 itemId),
        
        bool isValidCatalogItemId(1:i64 catalog_item_id),

    void updateVendorString(1:i64 warehouseId, 2:string vendorString);
}