Subversion Repositories SmartDukaan

Rev

Rev 2824 | Rev 2975 | 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

/**
        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 is currently paused
        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.
}

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

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

enum BillingType {
        OURS = 0,
        EXTERNAL = 1
}

/* 
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,
        4:status warehouseStatus,
        5:i64 addedOn,
        6:i64 lastCheckedOn,
        7:string tinNumber,
        8:string pincode,
        9:string vendorString,
        10:WarehouseLocation logisticsLocation,
        11:string vendor,
        12:i64 vendorId,
        13:BillingType billingType
}
/* */
struct ItemInventory{
        1:i64 id,
        2:map<i64,i64> availability
}


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

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 mop, //market operative price
        15:optional double sellingPrice, //Selling price
        16:optional double transferPrice,
        17:optional double weight,
        18:i64 addedOn,
        19:optional i64 startDate,
        20:optional i64 retireDate,
        21:status itemStatus,
        22:string status_description,
        23:map<string,string> otherInfo,
        24:string bestDealText,
        25:optional double bestDealValue,
        26:optional double dealerPrice,
        27:bool defaultForEntity,
        28:i64 updatedOn,
        29:optional i64 bestSellingRank, 
        30:string hotspotCategory,
        31:bool risky,
        32:i64 similarityIndex
}

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
}

struct VendorItemMapping{
        1:i64 vendorId,
        2:string itemKey,
        3:i64 itemId,
        4:string vendorCategory
}
   
exception InventoryServiceException{
        1:i64 id,
        2:string message
}

service InventoryService{

        /**
        * For closing the open session in sqlalchemy
        */
        void closeSession(),
        
/**
        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),
        bool isActive(1:i64 itemId) throws (1:InventoryServiceException isex),
        string getItemStatusDescription(1:i64 itemId) throws (1:InventoryServiceException isex),
        void updateInventory(1:i64 warehouse_id, 2:string timestamp, 3:map<string, i64> availability) throws (1:InventoryServiceException cex),
        // commented right now. write on based of requirement
        // void updatePrice(1:i64 item_id, 2:i64 warehouse_id, 3:double price) 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> 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),
        
        
        /**
          Returns the id of the warehouse with the largest inventory of the item and the inventory size in the given locations.
          The size of list will always be 2.
         */
        list<i64> getItemAvailabilityAtLocation(1:i64 warehouse_loc, 2:i64 item_id) 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> getLatestArrivals() throws (1:InventoryServiceException isex),
        list<i64> getLatestArrivalsCatalogIds(1:i64 beginIndex, 2:i64 totalItems, 3:string brand, 4:i64 category) throws (1:InventoryServiceException cex),
        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 warehouseId) 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(), 
        
        /**
        Checks if the item exists in VendorItemMapping for the given hotspot parameters (ProductGroup,Brand,ModelNumber,Color),
        vendor and category.
        Returns true if it exists else false.
        */
        bool itemExists(1:string productGroup, 2:string brand, 3:string modelNumber, 4:string color, 5:i64 vendor_id, 6:string category),
        
        /**
        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 ProductGroup, Brand, ModelNumber, Color)
        If yes, returns the itemId else returns 0
        */
        i64 checkSimilarItem(1:string productGroup, 2:string brand, 3:string modelNumber, 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 vendor category.
        Raises exception if vendorCategory is null. 
        */
        list<Item> getItemsByVendorCategory(1:string vendorCategory),
        
        /**
        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),
}