Sha256: b359ce6836c701c3eb8e7cdd4d4db63e6e32b4cf166bc332cc393c338d7bf84c
Contents?: true
Size: 1.8 KB
Versions: 24
Compression:
Stored size: 1.8 KB
Contents
module JanioAPI class Item < Base VALID_ITEM_CATEGORIES = ["Fashion Accessories", "Fashion Footwear", "Fashion Apparels (Men)", "Fashion Apparels (Women)", "Fashion Apparels (Babies, Toddlers and Children)", "Fashion Apparel", "Electronics", "Electronics (Non-Telecommunications)", "Electronics (Telecommunications)", "Lifestyle Products", "Lifestyle (Health Related)", "Lifestyle (Beauty Related)", "Lifestyle (Home & Living)", "Lifestyle (Hobbies & Collection)", "Lifestyle (Pantry & Packaged Food & Beverages)", "Others", "Printed Matters"].freeze validates :item_desc, :item_quantity, :item_price_value, :item_price_currency, presence: true validates :item_category, inclusion: {in: VALID_ITEM_CATEGORIES, message: "%{value} is not a valid item category, valid item categories are #{VALID_ITEM_CATEGORIES.join(", ")}"} class << self def find(*args) raise "JanioAPI::Item cannot be fetched directly, plesase use JanioAPI::Order to fetch the items under the order." end def create raise "JanioAPI::Item cannot be created directly, "\ "please include it in an JanioAPI::Order to create it under a new JanioAPI::Order." end end def initialize(attributes = {}, persisted = false) default_attrs = { item_desc: nil, item_quantity: nil, item_price_value: nil, item_price_currency: nil, item_category: nil } attributes = default_attrs.merge(attributes) super end def create self.class.create end def update raise "JanioAPI::Item cannot be updated, only creation is supported and "\ "please include it in an JanioAPI::Order to create it under a new JanioAPI::Order." end end end
Version data entries
24 entries across 24 versions & 1 rubygems