Class: ConnectWise::CatalogItem

Inherits:
Object
  • Object
show all
Defined in:
lib/connectwise-ruby-sdk/models/catalog_item.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ CatalogItem

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
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
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 153

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?(:'id')
    self.id = attributes[:'id']
  end

  if attributes.has_key?(:'identifier')
    self.identifier = attributes[:'identifier']
  end

  if attributes.has_key?(:'description')
    self.description = attributes[:'description']
  end

  if attributes.has_key?(:'inactiveFlag')
    self.inactive_flag = attributes[:'inactiveFlag']
  end

  if attributes.has_key?(:'subcategory')
    self.subcategory = attributes[:'subcategory']
  end

  if attributes.has_key?(:'type')
    self.type = attributes[:'type']
  end

  if attributes.has_key?(:'productClass')
    self.product_class = attributes[:'productClass']
  end

  if attributes.has_key?(:'serializedFlag')
    self.serialized_flag = attributes[:'serializedFlag']
  end

  if attributes.has_key?(:'serializedCostFlag')
    self.serialized_cost_flag = attributes[:'serializedCostFlag']
  end

  if attributes.has_key?(:'phaseProductFlag')
    self.phase_product_flag = attributes[:'phaseProductFlag']
  end

  if attributes.has_key?(:'unitOfMeasure')
    self.unit_of_measure = attributes[:'unitOfMeasure']
  end

  if attributes.has_key?(:'minStockLevel')
    self.min_stock_level = attributes[:'minStockLevel']
  end

  if attributes.has_key?(:'price')
    self.price = attributes[:'price']
  end

  if attributes.has_key?(:'cost')
    self.cost = attributes[:'cost']
  end

  if attributes.has_key?(:'priceAttribute')
    self.price_attribute = attributes[:'priceAttribute']
  end

  if attributes.has_key?(:'taxableFlag')
    self.taxable_flag = attributes[:'taxableFlag']
  end

  if attributes.has_key?(:'customerDescription')
    self.customer_description = attributes[:'customerDescription']
  end

  if attributes.has_key?(:'manufacturer')
    self.manufacturer = attributes[:'manufacturer']
  end

  if attributes.has_key?(:'manufacturerPartNumber')
    self.manufacturer_part_number = attributes[:'manufacturerPartNumber']
  end

  if attributes.has_key?(:'vendor')
    self.vendor = attributes[:'vendor']
  end

  if attributes.has_key?(:'vendorSku')
    self.vendor_sku = attributes[:'vendorSku']
  end

  if attributes.has_key?(:'notes')
    self.notes = attributes[:'notes']
  end

  if attributes.has_key?(:'integrationXRef')
    self.integration_x_ref = attributes[:'integrationXRef']
  end

  if attributes.has_key?(:'dateEntered')
    self.date_entered = attributes[:'dateEntered']
  end

  if attributes.has_key?(:'category')
    self.category = attributes[:'category']
  end

  if attributes.has_key?(:'_info')
    self._info = attributes[:'_info']
  end

  if attributes.has_key?(:'customFields')
    if (value = attributes[:'customFields']).is_a?(Array)
      self.custom_fields = value
    end
  end

end

Instance Attribute Details

#_infoObject

Metadata of the entity



59
60
61
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 59

def _info
  @_info
end

#categoryObject

Returns the value of attribute category.



56
57
58
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 56

def category
  @category
end

#costObject

Returns the value of attribute cost.



34
35
36
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 34

def cost
  @cost
end

#custom_fieldsObject

Returns the value of attribute custom_fields.



61
62
63
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 61

def custom_fields
  @custom_fields
end

#customer_descriptionObject

Returns the value of attribute customer_description.



40
41
42
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 40

def customer_description
  @customer_description
end

#date_enteredObject

Returns the value of attribute date_entered.



54
55
56
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 54

def date_entered
  @date_entered
end

#descriptionObject

Returns the value of attribute description.



11
12
13
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 11

def description
  @description
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 7

def id
  @id
end

#identifierObject

Returns the value of attribute identifier.



9
10
11
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 9

def identifier
  @identifier
end

#inactive_flagObject

Returns the value of attribute inactive_flag.



13
14
15
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 13

def inactive_flag
  @inactive_flag
end

#integration_x_refObject

Returns the value of attribute integration_x_ref.



52
53
54
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 52

def integration_x_ref
  @integration_x_ref
end

#manufacturerObject

Returns the value of attribute manufacturer.



42
43
44
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 42

def manufacturer
  @manufacturer
end

#manufacturer_part_numberObject

Returns the value of attribute manufacturer_part_number.



44
45
46
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 44

def manufacturer_part_number
  @manufacturer_part_number
end

#min_stock_levelObject

Returns the value of attribute min_stock_level.



30
31
32
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 30

def min_stock_level
  @min_stock_level
end

#notesObject

Returns the value of attribute notes.



50
51
52
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 50

def notes
  @notes
end

#phase_product_flagObject

Returns the value of attribute phase_product_flag.



26
27
28
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 26

def phase_product_flag
  @phase_product_flag
end

#priceObject

Returns the value of attribute price.



32
33
34
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 32

def price
  @price
end

#price_attributeObject

Returns the value of attribute price_attribute.



36
37
38
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 36

def price_attribute
  @price_attribute
end

#product_classObject

Defaults to Non-Inventory



20
21
22
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 20

def product_class
  @product_class
end

#serialized_cost_flagObject

Returns the value of attribute serialized_cost_flag.



24
25
26
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 24

def serialized_cost_flag
  @serialized_cost_flag
end

#serialized_flagObject

Returns the value of attribute serialized_flag.



22
23
24
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 22

def serialized_flag
  @serialized_flag
end

#subcategoryObject

Returns the value of attribute subcategory.



15
16
17
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 15

def subcategory
  @subcategory
end

#taxable_flagObject

Returns the value of attribute taxable_flag.



38
39
40
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 38

def taxable_flag
  @taxable_flag
end

#typeObject

Returns the value of attribute type.



17
18
19
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 17

def type
  @type
end

#unit_of_measureObject

Returns the value of attribute unit_of_measure.



28
29
30
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 28

def unit_of_measure
  @unit_of_measure
end

#vendorObject

Returns the value of attribute vendor.



46
47
48
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 46

def vendor
  @vendor
end

#vendor_skuObject

Returns the value of attribute vendor_sku.



48
49
50
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 48

def vendor_sku
  @vendor_sku
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 86

def self.attribute_map
  {
    :'id' => :'id',
    :'identifier' => :'identifier',
    :'description' => :'description',
    :'inactive_flag' => :'inactiveFlag',
    :'subcategory' => :'subcategory',
    :'type' => :'type',
    :'product_class' => :'productClass',
    :'serialized_flag' => :'serializedFlag',
    :'serialized_cost_flag' => :'serializedCostFlag',
    :'phase_product_flag' => :'phaseProductFlag',
    :'unit_of_measure' => :'unitOfMeasure',
    :'min_stock_level' => :'minStockLevel',
    :'price' => :'price',
    :'cost' => :'cost',
    :'price_attribute' => :'priceAttribute',
    :'taxable_flag' => :'taxableFlag',
    :'customer_description' => :'customerDescription',
    :'manufacturer' => :'manufacturer',
    :'manufacturer_part_number' => :'manufacturerPartNumber',
    :'vendor' => :'vendor',
    :'vendor_sku' => :'vendorSku',
    :'notes' => :'notes',
    :'integration_x_ref' => :'integrationXRef',
    :'date_entered' => :'dateEntered',
    :'category' => :'category',
    :'_info' => :'_info',
    :'custom_fields' => :'customFields'
  }
end

.swagger_typesObject

Attribute type mapping.



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
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 119

def self.swagger_types
  {
    :'id' => :'Integer',
    :'identifier' => :'String',
    :'description' => :'String',
    :'inactive_flag' => :'BOOLEAN',
    :'subcategory' => :'ProductSubCategoryReference',
    :'type' => :'ProductTypeReference',
    :'product_class' => :'String',
    :'serialized_flag' => :'BOOLEAN',
    :'serialized_cost_flag' => :'BOOLEAN',
    :'phase_product_flag' => :'BOOLEAN',
    :'unit_of_measure' => :'UnitOfMeasureReference',
    :'min_stock_level' => :'Integer',
    :'price' => :'Float',
    :'cost' => :'Float',
    :'price_attribute' => :'String',
    :'taxable_flag' => :'BOOLEAN',
    :'customer_description' => :'String',
    :'manufacturer' => :'ManufacturerReference',
    :'manufacturer_part_number' => :'String',
    :'vendor' => :'CompanyReference',
    :'vendor_sku' => :'String',
    :'notes' => :'String',
    :'integration_x_ref' => :'String',
    :'date_entered' => :'String',
    :'category' => :'ProductCategoryReference',
    :'_info' => :'Metadata',
    :'custom_fields' => :'Array<CustomFieldValue>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 440

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      identifier == o.identifier &&
      description == o.description &&
      inactive_flag == o.inactive_flag &&
      subcategory == o.subcategory &&
      type == o.type &&
      product_class == o.product_class &&
      serialized_flag == o.serialized_flag &&
      serialized_cost_flag == o.serialized_cost_flag &&
      phase_product_flag == o.phase_product_flag &&
      unit_of_measure == o.unit_of_measure &&
      min_stock_level == o.min_stock_level &&
      price == o.price &&
      cost == o.cost &&
      price_attribute == o.price_attribute &&
      taxable_flag == o.taxable_flag &&
      customer_description == o.customer_description &&
      manufacturer == o.manufacturer &&
      manufacturer_part_number == o.manufacturer_part_number &&
      vendor == o.vendor &&
      vendor_sku == o.vendor_sku &&
      notes == o.notes &&
      integration_x_ref == o.integration_x_ref &&
      date_entered == o.date_entered &&
      category == o.category &&
      _info == o._info &&
      custom_fields == o.custom_fields
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 508

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 = ConnectWise.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

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



574
575
576
577
578
579
580
581
582
583
584
585
586
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 574

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

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 487

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

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


474
475
476
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 474

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



480
481
482
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 480

def hash
  [id, identifier, description, inactive_flag, subcategory, type, product_class, serialized_flag, serialized_cost_flag, phase_product_flag, unit_of_measure, min_stock_level, price, cost, price_attribute, taxable_flag, customer_description, manufacturer, manufacturer_part_number, vendor, vendor_sku, notes, integration_x_ref, date_entered, category, _info, custom_fields].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properies with the reasons



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 273

def list_invalid_properties
  invalid_properties = Array.new
  if @identifier.nil?
    invalid_properties.push("invalid value for 'identifier', identifier cannot be nil.")
  end

  if @identifier.to_s.length > 60
    invalid_properties.push("invalid value for 'identifier', the character length must be smaller than or equal to 60.")
  end

  if @description.nil?
    invalid_properties.push("invalid value for 'description', description cannot be nil.")
  end

  if @description.to_s.length > 60
    invalid_properties.push("invalid value for 'description', the character length must be smaller than or equal to 60.")
  end

  if @subcategory.nil?
    invalid_properties.push("invalid value for 'subcategory', subcategory cannot be nil.")
  end

  if @type.nil?
    invalid_properties.push("invalid value for 'type', type cannot be nil.")
  end

  if @customer_description.nil?
    invalid_properties.push("invalid value for 'customer_description', customer_description cannot be nil.")
  end

  if @customer_description.to_s.length > 6000
    invalid_properties.push("invalid value for 'customer_description', the character length must be smaller than or equal to 6000.")
  end

  if !@manufacturer_part_number.nil? && @manufacturer_part_number.to_s.length > 50
    invalid_properties.push("invalid value for 'manufacturer_part_number', the character length must be smaller than or equal to 50.")
  end

  if !@vendor_sku.nil? && @vendor_sku.to_s.length > 50
    invalid_properties.push("invalid value for 'vendor_sku', the character length must be smaller than or equal to 50.")
  end

  if !@integration_x_ref.nil? && @integration_x_ref.to_s.length > 50
    invalid_properties.push("invalid value for 'integration_x_ref', the character length must be smaller than or equal to 50.")
  end

  return invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



554
555
556
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 554

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



560
561
562
563
564
565
566
567
568
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 560

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_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



548
549
550
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 548

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'lib/connectwise-ruby-sdk/models/catalog_item.rb', line 324

def valid?
  return false if @identifier.nil?
  return false if @identifier.to_s.length > 60
  return false if @description.nil?
  return false if @description.to_s.length > 60
  return false if @subcategory.nil?
  return false if @type.nil?
  product_class_validator = EnumAttributeValidator.new('String', ["Agreement", "Bundle", "Inventory", "NonInventory", "Service"])
  return false unless product_class_validator.valid?(@product_class)
  price_attribute_validator = EnumAttributeValidator.new('String', ["FixedFee", "NotToExceed", "TimeAndMaterials", "OverrideRate"])
  return false unless price_attribute_validator.valid?(@price_attribute)
  return false if @customer_description.nil?
  return false if @customer_description.to_s.length > 6000
  return false if !@manufacturer_part_number.nil? && @manufacturer_part_number.to_s.length > 50
  return false if !@vendor_sku.nil? && @vendor_sku.to_s.length > 50
  return false if !@integration_x_ref.nil? && @integration_x_ref.to_s.length > 50
  return true
end