=begin #UltraCart Rest API V2 #UltraCart REST API Version 2 The version of the OpenAPI document: 2.0.0 Contact: support@ultracart.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 6.0.1-SNAPSHOT =end require 'date' require 'time' module UltracartClient class LibraryItem attr_accessor :assets attr_accessor :attributes attr_accessor :categories attr_accessor :content attr_accessor :content_type attr_accessor :description attr_accessor :industries attr_accessor :library_item_oid attr_accessor :merchant_id # If this is a public item and the merchant has already purchased it, this is their version. If not yet purchased, this will be zero. This value will only be populated during a searchPublicItems() call. attr_accessor :my_purchased_version # This id points to the original object that was added to the library. For flows and campaigns, this is a uuid string. For upsells, it is an oid integer. For transactional_emails, it is an email name. attr_accessor :original_object_id # The price of the published item. Null for any private library items. attr_accessor :price # The formatted price of the published item. Null for any private library items. attr_accessor :price_formatted # True if this library item is a published item (not source) attr_accessor :published # The timestamp of the last published version attr_accessor :published_dts # The source item used to publish this item. This allows for comparisons between source and published attr_accessor :published_from_library_item_oid attr_accessor :published_meta # The source version when this item was published. This allows for out-of-date alerts to be shown when there is a difference between source and published attr_accessor :published_version # True if this library item has been purchased attr_accessor :purchased # The published item that was purchased to make this item. This allows for comparisons between published and purchased attr_accessor :purchased_from_library_item_oid attr_accessor :purchased_meta # The published version when this item was purchased. This allows for out-of-date alerts to be shown when there is a difference between published and purchased attr_accessor :purchased_version # Any published library reviewed by UltraCart staff for malicious or inappropriate content will have this flag set to true. This is always false for non-published items attr_accessor :rejected # Any rejected published item will have this field populated with the reason. attr_accessor :rejected_reason # Release notes specific to each published version and only appearing on public items. attr_accessor :release_notes # This counter records how many times a library item has been published. This is used to show version history. attr_accessor :release_version # Any published library items must be reviewed by UltraCart staff for malicious content. This flag shows the status of that review. This is always false for non-published items attr_accessor :reviewed # This is the timestamp for a published items formal review by UltraCart staff for malicious content. attr_accessor :reviewed_dts attr_accessor :screenshots attr_accessor :share_with_accounts attr_accessor :share_with_other_emails # True if this item is shared from another merchant account attr_accessor :shared # True if this library item has been published attr_accessor :source # This oid points to the published library item, if there is one. attr_accessor :source_to_library_item_oid # The version of this item. Increment every time the item is saved. attr_accessor :source_version attr_accessor :style attr_accessor :times_purchased attr_accessor :title attr_accessor :type # True if this library item was published but is awaiting review from UltraCart staff. attr_accessor :under_review # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'assets' => :'assets', :'attributes' => :'attributes', :'categories' => :'categories', :'content' => :'content', :'content_type' => :'content_type', :'description' => :'description', :'industries' => :'industries', :'library_item_oid' => :'library_item_oid', :'merchant_id' => :'merchant_id', :'my_purchased_version' => :'my_purchased_version', :'original_object_id' => :'original_object_id', :'price' => :'price', :'price_formatted' => :'price_formatted', :'published' => :'published', :'published_dts' => :'published_dts', :'published_from_library_item_oid' => :'published_from_library_item_oid', :'published_meta' => :'published_meta', :'published_version' => :'published_version', :'purchased' => :'purchased', :'purchased_from_library_item_oid' => :'purchased_from_library_item_oid', :'purchased_meta' => :'purchased_meta', :'purchased_version' => :'purchased_version', :'rejected' => :'rejected', :'rejected_reason' => :'rejected_reason', :'release_notes' => :'release_notes', :'release_version' => :'release_version', :'reviewed' => :'reviewed', :'reviewed_dts' => :'reviewed_dts', :'screenshots' => :'screenshots', :'share_with_accounts' => :'share_with_accounts', :'share_with_other_emails' => :'share_with_other_emails', :'shared' => :'shared', :'source' => :'source', :'source_to_library_item_oid' => :'source_to_library_item_oid', :'source_version' => :'source_version', :'style' => :'style', :'times_purchased' => :'times_purchased', :'title' => :'title', :'type' => :'type', :'under_review' => :'under_review' } end # Returns all the JSON keys this model knows about def self.acceptable_attributes attribute_map.values end # Attribute type mapping. def self.openapi_types { :'assets' => :'Array', :'attributes' => :'Array', :'categories' => :'Array', :'content' => :'String', :'content_type' => :'String', :'description' => :'String', :'industries' => :'Array', :'library_item_oid' => :'Integer', :'merchant_id' => :'String', :'my_purchased_version' => :'Integer', :'original_object_id' => :'String', :'price' => :'Float', :'price_formatted' => :'String', :'published' => :'Boolean', :'published_dts' => :'Object', :'published_from_library_item_oid' => :'Integer', :'published_meta' => :'LibraryItemPublishedMeta', :'published_version' => :'Integer', :'purchased' => :'Boolean', :'purchased_from_library_item_oid' => :'Integer', :'purchased_meta' => :'LibraryItemPurchasedMeta', :'purchased_version' => :'Integer', :'rejected' => :'Boolean', :'rejected_reason' => :'String', :'release_notes' => :'String', :'release_version' => :'Integer', :'reviewed' => :'Boolean', :'reviewed_dts' => :'Object', :'screenshots' => :'Array', :'share_with_accounts' => :'Array', :'share_with_other_emails' => :'Array', :'shared' => :'Boolean', :'source' => :'Boolean', :'source_to_library_item_oid' => :'Integer', :'source_version' => :'Integer', :'style' => :'String', :'times_purchased' => :'Integer', :'title' => :'String', :'type' => :'String', :'under_review' => :'Boolean' } end # List of attributes with nullable: true def self.openapi_nullable Set.new([ ]) end # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::LibraryItem` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::LibraryItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'assets') if (value = attributes[:'assets']).is_a?(Array) self.assets = value end end if attributes.key?(:'attributes') if (value = attributes[:'attributes']).is_a?(Array) self.attributes = value end end if attributes.key?(:'categories') if (value = attributes[:'categories']).is_a?(Array) self.categories = value end end if attributes.key?(:'content') self.content = attributes[:'content'] end if attributes.key?(:'content_type') self.content_type = attributes[:'content_type'] end if attributes.key?(:'description') self.description = attributes[:'description'] end if attributes.key?(:'industries') if (value = attributes[:'industries']).is_a?(Array) self.industries = value end end if attributes.key?(:'library_item_oid') self.library_item_oid = attributes[:'library_item_oid'] end if attributes.key?(:'merchant_id') self.merchant_id = attributes[:'merchant_id'] end if attributes.key?(:'my_purchased_version') self.my_purchased_version = attributes[:'my_purchased_version'] end if attributes.key?(:'original_object_id') self.original_object_id = attributes[:'original_object_id'] end if attributes.key?(:'price') self.price = attributes[:'price'] end if attributes.key?(:'price_formatted') self.price_formatted = attributes[:'price_formatted'] end if attributes.key?(:'published') self.published = attributes[:'published'] end if attributes.key?(:'published_dts') self.published_dts = attributes[:'published_dts'] end if attributes.key?(:'published_from_library_item_oid') self.published_from_library_item_oid = attributes[:'published_from_library_item_oid'] end if attributes.key?(:'published_meta') self.published_meta = attributes[:'published_meta'] end if attributes.key?(:'published_version') self.published_version = attributes[:'published_version'] end if attributes.key?(:'purchased') self.purchased = attributes[:'purchased'] end if attributes.key?(:'purchased_from_library_item_oid') self.purchased_from_library_item_oid = attributes[:'purchased_from_library_item_oid'] end if attributes.key?(:'purchased_meta') self.purchased_meta = attributes[:'purchased_meta'] end if attributes.key?(:'purchased_version') self.purchased_version = attributes[:'purchased_version'] end if attributes.key?(:'rejected') self.rejected = attributes[:'rejected'] end if attributes.key?(:'rejected_reason') self.rejected_reason = attributes[:'rejected_reason'] end if attributes.key?(:'release_notes') self.release_notes = attributes[:'release_notes'] end if attributes.key?(:'release_version') self.release_version = attributes[:'release_version'] end if attributes.key?(:'reviewed') self.reviewed = attributes[:'reviewed'] end if attributes.key?(:'reviewed_dts') self.reviewed_dts = attributes[:'reviewed_dts'] end if attributes.key?(:'screenshots') if (value = attributes[:'screenshots']).is_a?(Array) self.screenshots = value end end if attributes.key?(:'share_with_accounts') if (value = attributes[:'share_with_accounts']).is_a?(Array) self.share_with_accounts = value end end if attributes.key?(:'share_with_other_emails') if (value = attributes[:'share_with_other_emails']).is_a?(Array) self.share_with_other_emails = value end end if attributes.key?(:'shared') self.shared = attributes[:'shared'] end if attributes.key?(:'source') self.source = attributes[:'source'] end if attributes.key?(:'source_to_library_item_oid') self.source_to_library_item_oid = attributes[:'source_to_library_item_oid'] end if attributes.key?(:'source_version') self.source_version = attributes[:'source_version'] end if attributes.key?(:'style') self.style = attributes[:'style'] end if attributes.key?(:'times_purchased') self.times_purchased = attributes[:'times_purchased'] end if attributes.key?(:'title') self.title = attributes[:'title'] end if attributes.key?(:'type') self.type = attributes[:'type'] end if attributes.key?(:'under_review') self.under_review = attributes[:'under_review'] end end # Show invalid properties with the reasons. Usually used together with valid? # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = Array.new invalid_properties end # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? true end # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && assets == o.assets && attributes == o.attributes && categories == o.categories && content == o.content && content_type == o.content_type && description == o.description && industries == o.industries && library_item_oid == o.library_item_oid && merchant_id == o.merchant_id && my_purchased_version == o.my_purchased_version && original_object_id == o.original_object_id && price == o.price && price_formatted == o.price_formatted && published == o.published && published_dts == o.published_dts && published_from_library_item_oid == o.published_from_library_item_oid && published_meta == o.published_meta && published_version == o.published_version && purchased == o.purchased && purchased_from_library_item_oid == o.purchased_from_library_item_oid && purchased_meta == o.purchased_meta && purchased_version == o.purchased_version && rejected == o.rejected && rejected_reason == o.rejected_reason && release_notes == o.release_notes && release_version == o.release_version && reviewed == o.reviewed && reviewed_dts == o.reviewed_dts && screenshots == o.screenshots && share_with_accounts == o.share_with_accounts && share_with_other_emails == o.share_with_other_emails && shared == o.shared && source == o.source && source_to_library_item_oid == o.source_to_library_item_oid && source_version == o.source_version && style == o.style && times_purchased == o.times_purchased && title == o.title && type == o.type && under_review == o.under_review end # @see the `==` method # @param [Object] Object to be compared def eql?(o) self == o end # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash [assets, attributes, categories, content, content_type, description, industries, library_item_oid, merchant_id, my_purchased_version, original_object_id, price, price_formatted, published, published_dts, published_from_library_item_oid, published_meta, published_version, purchased, purchased_from_library_item_oid, purchased_meta, purchased_version, rejected, rejected_reason, release_notes, release_version, reviewed, reviewed_dts, screenshots, share_with_accounts, share_with_other_emails, shared, source, source_to_library_item_oid, source_version, style, times_purchased, title, type, under_review].hash end # Builds the object from hash # @param [Hash] attributes Model attributes in the form of hash # @return [Object] Returns the model itself def self.build_from_hash(attributes) new.build_from_hash(attributes) end # Builds the object from hash # @param [Hash] attributes Model attributes in the form of hash # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) self.class.openapi_types.each_pair do |key, type| if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) self.send("#{key}=", nil) elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end end self end # Deserializes the data based on type # @param string type Data type # @param string value Value to be deserialized # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym when :Time Time.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?.+?), (?.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model # models (e.g. Pet) or oneOf klass = UltracartClient.const_get(type) klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end # Returns the string representation of the object # @return [String] String presentation of the object def to_s to_hash.to_s end # to_body is an alias to to_hash (backward compatibility) # @return [Hash] Returns the object in the form of hash def to_body to_hash end # Returns the object in the form of hash # @return [Hash] Returns the object in the form of hash def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value # @param [Object] value Any valid value # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end end end