Class: SquareConnect::CatalogItem
- Inherits:
-
Object
- Object
- SquareConnect::CatalogItem
- Defined in:
- lib/square_connect/models/catalog_item.rb
Overview
An item (i.e., product family) in the Catalog object model.
Defined Under Namespace
Classes: EnumAttributeValidator
Instance Attribute Summary collapse
-
#abbreviation ⇒ Object
The text of the item’s display label in the Square Point of Sale app.
-
#available_electronically ⇒ Object
If ‘true`, the item can be added to electronically fulfilled orders from the merchant’s online store.
-
#available_for_pickup ⇒ Object
If ‘true`, the item can be added to pickup orders from the merchant’s online store.
-
#available_online ⇒ Object
If ‘true`, the item can be added to shipping orders from the merchant’s online store.
-
#category_id ⇒ Object
The ID of the item’s category, if any.
-
#description ⇒ Object
The item’s description.
-
#image_url ⇒ Object
The URL of an image representing this item.
-
#label_color ⇒ Object
The color of the item’s display label in the Square Point of Sale app.
-
#modifier_list_info ⇒ Object
A set of [CatalogItemModifierListInfo](#type-catalogitemmodifierlistinfo) objects representing the modifier lists that apply to this item, along with the overrides and min and max limits that are specific to this item.
-
#name ⇒ Object
The item’s name.
-
#product_type ⇒ Object
The product type of the item.
-
#skip_modifier_screen ⇒ Object
If ‘false`, the Square Point of Sale app will present the [CatalogItem](#type-catalogitem)’s details screen immediately, allowing the merchant to choose [CatalogModifier](#type-catalogmodifier)s before adding the item to the cart.
-
#tax_ids ⇒ Object
A set of IDs indicating the [CatalogTax](#type-catalogtax)es that are enabled for this item.
-
#variations ⇒ Object
A list of [CatalogObject](#type-catalogobject)s containing the [CatalogItemVariation](#type-catalogitemvariation)s for this item.
Class Method Summary collapse
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.swagger_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
-
#build_from_hash(attributes) ⇒ Object
Builds the object from hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ CatalogItem
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ CatalogItem
Initializes the object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/square_connect/models/catalog_item.rb', line 121 def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} if attributes.has_key?(:'name') self.name = attributes[:'name'] end if attributes.has_key?(:'description') self.description = attributes[:'description'] end if attributes.has_key?(:'abbreviation') self.abbreviation = attributes[:'abbreviation'] end if attributes.has_key?(:'label_color') self.label_color = attributes[:'label_color'] end if attributes.has_key?(:'available_online') self.available_online = attributes[:'available_online'] end if attributes.has_key?(:'available_for_pickup') self.available_for_pickup = attributes[:'available_for_pickup'] end if attributes.has_key?(:'available_electronically') self.available_electronically = attributes[:'available_electronically'] end if attributes.has_key?(:'category_id') self.category_id = attributes[:'category_id'] end if attributes.has_key?(:'tax_ids') if (value = attributes[:'tax_ids']).is_a?(Array) self.tax_ids = value end end if attributes.has_key?(:'modifier_list_info') if (value = attributes[:'modifier_list_info']).is_a?(Array) self.modifier_list_info = value end end if attributes.has_key?(:'image_url') self.image_url = attributes[:'image_url'] end if attributes.has_key?(:'variations') if (value = attributes[:'variations']).is_a?(Array) self.variations = value end end if attributes.has_key?(:'product_type') self.product_type = attributes[:'product_type'] end if attributes.has_key?(:'skip_modifier_screen') self.skip_modifier_screen = attributes[:'skip_modifier_screen'] end end |
Instance Attribute Details
#abbreviation ⇒ Object
The text of the item’s display label in the Square Point of Sale app. Only up to the first five characters of the string are used. Searchable.
22 23 24 |
# File 'lib/square_connect/models/catalog_item.rb', line 22 def abbreviation @abbreviation end |
#available_electronically ⇒ Object
If ‘true`, the item can be added to electronically fulfilled orders from the merchant’s online store.
34 35 36 |
# File 'lib/square_connect/models/catalog_item.rb', line 34 def available_electronically @available_electronically end |
#available_for_pickup ⇒ Object
If ‘true`, the item can be added to pickup orders from the merchant’s online store.
31 32 33 |
# File 'lib/square_connect/models/catalog_item.rb', line 31 def available_for_pickup @available_for_pickup end |
#available_online ⇒ Object
If ‘true`, the item can be added to shipping orders from the merchant’s online store.
28 29 30 |
# File 'lib/square_connect/models/catalog_item.rb', line 28 def available_online @available_online end |
#category_id ⇒ Object
The ID of the item’s category, if any.
37 38 39 |
# File 'lib/square_connect/models/catalog_item.rb', line 37 def category_id @category_id end |
#description ⇒ Object
The item’s description. Searchable.
19 20 21 |
# File 'lib/square_connect/models/catalog_item.rb', line 19 def description @description end |
#image_url ⇒ Object
The URL of an image representing this item.
46 47 48 |
# File 'lib/square_connect/models/catalog_item.rb', line 46 def image_url @image_url end |
#label_color ⇒ Object
The color of the item’s display label in the Square Point of Sale app.
25 26 27 |
# File 'lib/square_connect/models/catalog_item.rb', line 25 def label_color @label_color end |
#modifier_list_info ⇒ Object
A set of [CatalogItemModifierListInfo](#type-catalogitemmodifierlistinfo) objects representing the modifier lists that apply to this item, along with the overrides and min and max limits that are specific to this item. [CatalogModifierList](#type-catalogmodifierlist)s may also be added to or deleted from an item using ‘UpdateItemModifierLists`.
43 44 45 |
# File 'lib/square_connect/models/catalog_item.rb', line 43 def modifier_list_info @modifier_list_info end |
#name ⇒ Object
The item’s name. Searchable.
16 17 18 |
# File 'lib/square_connect/models/catalog_item.rb', line 16 def name @name end |
#product_type ⇒ Object
The product type of the item. May not be changed once an item has been created. Only items of product type ‘REGULAR` may be created by this API; items with other product types are read-only. See [CatalogItemProductType](#type-catalogitemproducttype) for all possible values.
52 53 54 |
# File 'lib/square_connect/models/catalog_item.rb', line 52 def product_type @product_type end |
#skip_modifier_screen ⇒ Object
If ‘false`, the Square Point of Sale app will present the [CatalogItem](#type-catalogitem)’s details screen immediately, allowing the merchant to choose [CatalogModifier](#type-catalogmodifier)s before adding the item to the cart. This is the default behavior. If ‘true`, the Square Point of Sale app will immediately add the item to the cart with the pre-selected modifiers, and merchants can edit modifiers by drilling down onto the item’s details. Third-party clients are encouraged to implement similar behaviors.
55 56 57 |
# File 'lib/square_connect/models/catalog_item.rb', line 55 def skip_modifier_screen @skip_modifier_screen end |
#tax_ids ⇒ Object
A set of IDs indicating the [CatalogTax](#type-catalogtax)es that are enabled for this item. When updating an item, any taxes listed here will be added to the item. [CatalogTax](#type-catalogtax)es may also be added to or deleted from an item using ‘UpdateItemTaxes`.
40 41 42 |
# File 'lib/square_connect/models/catalog_item.rb', line 40 def tax_ids @tax_ids end |
#variations ⇒ Object
A list of [CatalogObject](#type-catalogobject)s containing the [CatalogItemVariation](#type-catalogitemvariation)s for this item.
49 50 51 |
# File 'lib/square_connect/models/catalog_item.rb', line 49 def variations @variations end |
Class Method Details
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/square_connect/models/catalog_item.rb', line 80 def self.attribute_map { :'name' => :'name', :'description' => :'description', :'abbreviation' => :'abbreviation', :'label_color' => :'label_color', :'available_online' => :'available_online', :'available_for_pickup' => :'available_for_pickup', :'available_electronically' => :'available_electronically', :'category_id' => :'category_id', :'tax_ids' => :'tax_ids', :'modifier_list_info' => :'modifier_list_info', :'image_url' => :'image_url', :'variations' => :'variations', :'product_type' => :'product_type', :'skip_modifier_screen' => :'skip_modifier_screen' } end |
.swagger_types ⇒ Object
Attribute type mapping.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/square_connect/models/catalog_item.rb', line 100 def self.swagger_types { :'name' => :'String', :'description' => :'String', :'abbreviation' => :'String', :'label_color' => :'String', :'available_online' => :'BOOLEAN', :'available_for_pickup' => :'BOOLEAN', :'available_electronically' => :'BOOLEAN', :'category_id' => :'String', :'tax_ids' => :'Array<String>', :'modifier_list_info' => :'Array<CatalogItemModifierListInfo>', :'image_url' => :'String', :'variations' => :'Array<CatalogObject>', :'product_type' => :'String', :'skip_modifier_screen' => :'BOOLEAN' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/square_connect/models/catalog_item.rb', line 242 def ==(o) return true if self.equal?(o) self.class == o.class && name == o.name && description == o.description && abbreviation == o.abbreviation && label_color == o.label_color && available_online == o.available_online && available_for_pickup == o.available_for_pickup && available_electronically == o.available_electronically && category_id == o.category_id && tax_ids == o.tax_ids && modifier_list_info == o.modifier_list_info && image_url == o.image_url && variations == o.variations && product_type == o.product_type && skip_modifier_screen == o.skip_modifier_screen end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
# File 'lib/square_connect/models/catalog_item.rb', line 297 def _deserialize(type, value) case type.to_sym when :DateTime DateTime.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<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\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 temp_model = SquareConnect.const_get(type).new temp_model.build_from_hash(value) end end |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
363 364 365 366 367 368 369 370 371 372 373 374 375 |
# File 'lib/square_connect/models/catalog_item.rb', line 363 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 |
#build_from_hash(attributes) ⇒ Object
Builds the object from hash
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/square_connect/models/catalog_item.rb', line 276 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the 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 # or else data not found in attributes(hash), not an issue as the data can be optional end self end |
#eql?(o) ⇒ Boolean
263 264 265 |
# File 'lib/square_connect/models/catalog_item.rb', line 263 def eql?(o) self == o end |
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
269 270 271 |
# File 'lib/square_connect/models/catalog_item.rb', line 269 def hash [name, description, abbreviation, label_color, available_online, available_for_pickup, available_electronically, category_id, tax_ids, modifier_list_info, image_url, variations, product_type, skip_modifier_screen].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/square_connect/models/catalog_item.rb', line 193 def list_invalid_properties invalid_properties = Array.new if @name.nil? invalid_properties.push("invalid value for 'name', name cannot be nil.") end if @name.to_s.length < 1 invalid_properties.push("invalid value for 'name', the character length must be great than or equal to 1.") end return invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
343 344 345 |
# File 'lib/square_connect/models/catalog_item.rb', line 343 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
349 350 351 352 353 354 355 356 357 |
# File 'lib/square_connect/models/catalog_item.rb', line 349 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? hash[param] = _to_hash(value) end hash end |
#to_s ⇒ String
Returns the string representation of the object
337 338 339 |
# File 'lib/square_connect/models/catalog_item.rb', line 337 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
208 209 210 211 212 213 214 |
# File 'lib/square_connect/models/catalog_item.rb', line 208 def valid? return false if @name.nil? return false if @name.to_s.length < 1 product_type_validator = EnumAttributeValidator.new('String', ["REGULAR", "GIFT_CARD", "APPOINTMENTS_SERVICE", "RETAIL_ITEM", "RESTAURANT_ITEM"]) return false unless product_type_validator.valid?(@product_type) return true end |