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.
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.
-
#item_options ⇒ Object
List of item options IDs for 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
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 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 |
# File 'lib/square_connect/models/catalog_item.rb', line 100 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?(:'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 if attributes.has_key?(:'item_options') if (value = attributes[:'item_options']).is_a?(Array) self. = value end 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. This field has max length of 24 Unicode code points.
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. This field has max length of 4096 Unicode code points.
19 20 21 |
# File 'lib/square_connect/models/catalog_item.rb', line 19 def description @description end |
#item_options ⇒ Object
List of item options IDs for this item. Used to manage and group item variations in a specified order. Maximum: 6 item options.
55 56 57 |
# File 'lib/square_connect/models/catalog_item.rb', line 55 def @item_options end |
#label_color ⇒ Object
The color of the item’s display label in the Square Point of Sale app. This must be a valid hex color code.
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. This field must not be empty. This field has max length of 512 Unicode code points.
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` or `APPOINTMENTS_SERVICE` may be created by this API; items with other product types are read-only. See [CatalogItemProductType](#type-catalogitemproducttype) for possible values
49 50 51 |
# File 'lib/square_connect/models/catalog_item.rb', line 49 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.
52 53 54 |
# File 'lib/square_connect/models/catalog_item.rb', line 52 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. Maximum: 250 item variations
46 47 48 |
# File 'lib/square_connect/models/catalog_item.rb', line 46 def variations @variations end |
Class Method Details
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/square_connect/models/catalog_item.rb', line 59 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', :'variations' => :'variations', :'product_type' => :'product_type', :'skip_modifier_screen' => :'skip_modifier_screen', :'item_options' => :'item_options' } end |
.swagger_types ⇒ Object
Attribute type mapping.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/square_connect/models/catalog_item.rb', line 79 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>', :'variations' => :'Array<CatalogObject>', :'product_type' => :'String', :'skip_modifier_screen' => :'BOOLEAN', :'item_options' => :'Array<CatalogItemOptionForItem>' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/square_connect/models/catalog_item.rb', line 187 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 && variations == o.variations && product_type == o.product_type && skip_modifier_screen == o.skip_modifier_screen && == o. end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
# File 'lib/square_connect/models/catalog_item.rb', line 242 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
308 309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/square_connect/models/catalog_item.rb', line 308 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
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/square_connect/models/catalog_item.rb', line 221 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
208 209 210 |
# File 'lib/square_connect/models/catalog_item.rb', line 208 def eql?(o) self == o end |
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
214 215 216 |
# File 'lib/square_connect/models/catalog_item.rb', line 214 def hash [name, description, abbreviation, label_color, available_online, available_for_pickup, available_electronically, category_id, tax_ids, modifier_list_info, variations, product_type, skip_modifier_screen, ].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
174 175 176 177 |
# File 'lib/square_connect/models/catalog_item.rb', line 174 def list_invalid_properties invalid_properties = Array.new return invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
288 289 290 |
# File 'lib/square_connect/models/catalog_item.rb', line 288 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
294 295 296 297 298 299 300 301 302 |
# File 'lib/square_connect/models/catalog_item.rb', line 294 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
282 283 284 |
# File 'lib/square_connect/models/catalog_item.rb', line 282 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
181 182 183 |
# File 'lib/square_connect/models/catalog_item.rb', line 181 def valid? return true end |